Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marcus Eibrink-Lunzenauer
Stud.IP
Commits
711983b9
Commit
711983b9
authored
1 year ago
by
Rasmus Fuhse
Browse files
Options
Downloads
Patches
Plain Diff
Resolve "OER: Merkwürdigkeiten beim Dateiupload"
Closes #2589 Merge request
studip/studip!1892
parent
256be6d2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/controllers/oer/addfile.php
+24
-14
24 additions, 14 deletions
app/controllers/oer/addfile.php
lib/models/OERHostOERSI.php
+1
-1
1 addition, 1 deletion
lib/models/OERHostOERSI.php
with
25 additions
and
15 deletions
app/controllers/oer/addfile.php
+
24
−
14
View file @
711983b9
...
@@ -18,23 +18,33 @@ class Oer_AddfileController extends AuthenticatedController
...
@@ -18,23 +18,33 @@ class Oer_AddfileController extends AuthenticatedController
if
(
Request
::
option
(
"material_id"
))
{
if
(
Request
::
option
(
"material_id"
))
{
$material
=
OERMaterial
::
find
(
Request
::
option
(
"material_id"
));
$material
=
OERMaterial
::
find
(
Request
::
option
(
"material_id"
));
$uploaded_file
=
[
$uploaded_file
=
[
'name'
=>
$material
[
'
file
name'
],
'name'
=>
$material
[
'name'
],
'type'
=>
$material
[
'content_type'
],
'type'
=>
$material
[
'content_type'
],
'content_terms_of_use_id'
=>
"FREE_LICENSE"
,
'content_terms_of_use_id'
=>
"FREE_LICENSE"
,
'description'
=>
$material
[
'description'
]
'description'
=>
$material
[
'description'
]
];
];
if
(
$material
[
'host_id'
])
{
$url
=
$material
->
getDownloadUrl
();
$tmp_name
=
$GLOBALS
[
'TMP_PATH'
]
.
"/oer_"
.
$material
->
getId
();
if
(
$url
)
{
$url
=
$material
->
getDownloadUrl
();
if
(
$material
[
'host_id'
])
{
file_put_contents
(
$tmp_name
,
file_get_contents
(
$url
,
false
,
get_default_http_stream_context
(
$url
)));
$tmp_name
=
$GLOBALS
[
'TMP_PATH'
]
.
'/oer_'
.
$material
->
getId
();
$uploaded_file
[
'tmp_name'
]
=
$tmp_name
;
file_put_contents
(
$tmp_name
,
file_get_contents
(
$url
,
false
,
get_default_http_stream_context
(
$url
)));
$uploaded_file
[
'type'
]
=
filesize
(
$tmp_name
);
$uploaded_file
[
'tmp_name'
]
=
$tmp_name
;
}
else
{
$uploaded_file
[
'size'
]
=
filesize
(
$tmp_name
);
$uploaded_file
[
'tmp_name'
]
=
$material
->
getFilePath
();
}
else
{
$uploaded_file
[
'size'
]
=
filesize
(
$material
->
getFilePath
());
$uploaded_file
[
'tmp_name'
]
=
$material
->
getFilePath
();
}
$uploaded_file
[
'size'
]
=
filesize
(
$material
->
getFilePath
());
}
$standardfile
=
StandardFile
::
create
(
$uploaded_file
);
$standardfile
=
StandardFile
::
create
(
$uploaded_file
);
}
elseif
(
$material
[
'source_url'
])
{
$standardfile
=
URLFile
::
create
([
'url'
=>
$material
[
'source_url'
],
'name'
=>
$material
[
'name'
],
'author_name'
=>
implode
(
', '
,
array_map
(
function
(
$a
)
{
return
$a
[
'name'
];
},
$material
)),
'description'
=>
$material
[
'description'
],
'content_terms_of_use_id'
=>
"FREE_LICENSE"
]);
}
if
(
$standardfile
->
getSize
())
{
if
(
$standardfile
->
getSize
())
{
$error
=
$this
->
to_folder_type
->
validateUpload
(
$standardfile
,
User
::
findCurrent
()
->
id
);
$error
=
$this
->
to_folder_type
->
validateUpload
(
$standardfile
,
User
::
findCurrent
()
->
id
);
...
@@ -51,15 +61,15 @@ class Oer_AddfileController extends AuthenticatedController
...
@@ -51,15 +61,15 @@ class Oer_AddfileController extends AuthenticatedController
}
}
if
(
!
$newfile
)
{
if
(
!
$newfile
)
{
PageLayout
::
postError
(
_
(
'Daten konnten nicht kopiert werden!'
));
PageLayout
::
postError
(
_
(
'Daten konnten nicht kopiert werden!'
));
}
else
{
PageLayout
::
postSuccess
(
_
(
'Datei wurde hinzugefügt.'
));
}
}
PageLayout
::
postSuccess
(
_
(
'Datei wurde hinzugefügt.'
));
}
else
{
}
else
{
if
(
$tmp_name
)
{
if
(
$tmp_name
)
{
@
unlink
(
$tmp_name
);
@
unlink
(
$tmp_name
);
}
}
PageLayout
::
postError
(
_
(
'Daten konnten nicht kopiert werden!'
));
PageLayout
::
postError
(
_
(
'Daten konnten nicht kopiert werden!'
));
}
}
PageLayout
::
postSuccess
(
_
(
'Datei wurde hinzugefügt.'
));
return
$this
->
redirectToFolder
(
$this
->
to_folder_type
);
return
$this
->
redirectToFolder
(
$this
->
to_folder_type
);
}
}
...
...
This diff is collapsed.
Click to expand it.
lib/models/OERHostOERSI.php
+
1
−
1
View file @
711983b9
...
@@ -175,7 +175,7 @@ class OERHostOERSI extends OERHost
...
@@ -175,7 +175,7 @@ class OERHostOERSI extends OERHost
public
function
getDownloadURLForMaterial
(
OERMaterial
$material
)
public
function
getDownloadURLForMaterial
(
OERMaterial
$material
)
{
{
return
$material
[
'uri'
];
return
$material
[
'data'
][
'download'
]
??
$material
[
'uri'
];
}
}
public
function
cbCreateKeysIfNecessary
()
public
function
cbCreateKeysIfNecessary
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment