Skip to content
Snippets Groups Projects
Commit c69e480c authored by David Siegfried's avatar David Siegfried
Browse files

prevent php-warnings, closes #2292

Closes #2292

Merge request studip/studip!1516
parent 3e722420
No related branches found
No related tags found
1 merge request!4Draft: Icon creation
...@@ -45,7 +45,7 @@ page_open(["sess" => "Seminar_Session", ...@@ -45,7 +45,7 @@ page_open(["sess" => "Seminar_Session",
"user" => "Seminar_User"]); "user" => "Seminar_User"]);
//Load plugins, unless they are disabled via an URL parameter. //Load plugins, unless they are disabled via an URL parameter.
if (Request::int('disable_plugins') !== null && ($user->id === 'nobody' || $perm->have_perm('root'))) { if (Request::int('disable_plugins') !== null && ($GLOBALS['user']->id === 'nobody' || $GLOBALS['perm']->have_perm('root'))) {
// deactivate non-core plugins // deactivate non-core plugins
PluginManager::getInstance()->setPluginsDisabled(Request::int('disable_plugins')); PluginManager::getInstance()->setPluginsDisabled(Request::int('disable_plugins'));
} }
...@@ -65,6 +65,8 @@ if ($type < 0 || $type > 7) { ...@@ -65,6 +65,8 @@ if ($type < 0 || $type > 7) {
$no_access = true; $no_access = true;
$file_missing = false; $file_missing = false;
$file = null;
$file_ref = null;
switch ($type) { switch ($type) {
//download from course or institute or document is a message attachment //download from course or institute or document is a message attachment
...@@ -114,13 +116,13 @@ if ($file_missing) { ...@@ -114,13 +116,13 @@ if ($file_missing) {
//if download not allowed throw exception to terminate script //if download not allowed throw exception to terminate script
if ($no_access) { if ($no_access) {
// redirect to login page if user is not logged in // redirect to login page if user is not logged in
$auth->login_if($auth->auth['uid'] == 'nobody'); $GLOBALS['auth']->login_if($GLOBALS['auth']->auth['uid'] === 'nobody');
throw new AccessDeniedException(_("Sie haben keine Zugriffsberechtigung für diesen Download!")); throw new AccessDeniedException(_("Sie haben keine Zugriffsberechtigung für diesen Download!"));
} }
//replace bad charakters to avoid problems when saving the file //replace bad charakters to avoid problems when saving the file
$file_name = FileManager::cleanFileName(Request::get('file_name')); $file_name = FileManager::cleanFileName(Request::get('file_name'));
$path_file = '';
switch ($type) { switch ($type) {
//We want to download from the archive (this mode performs perm checks) //We want to download from the archive (this mode performs perm checks)
case 1: case 1:
...@@ -151,7 +153,10 @@ switch ($type) { ...@@ -151,7 +153,10 @@ switch ($type) {
// check if linked file is obtainable // check if linked file is obtainable
$filesize = 0; $filesize = 0;
if (isset($file_ref) && $file_ref->file->metadata['access_type'] == 'proxy') { if (
isset($file_ref, $file_ref->file, $file_ref->file->metadata['access_type'])
&& $file_ref->file->metadata['access_type'] === 'proxy'
) {
$link_data = FileManager::fetchURLMetadata($file_ref->file->metadata['url']); $link_data = FileManager::fetchURLMetadata($file_ref->file->metadata['url']);
if ($link_data['response_code'] != 200) { if ($link_data['response_code'] != 200) {
throw new Exception(_("Diese Datei wird von einem externen Server geladen und ist dort momentan nicht erreichbar!")); throw new Exception(_("Diese Datei wird von einem externen Server geladen und ist dort momentan nicht erreichbar!"));
...@@ -258,6 +263,6 @@ if (isset($file_ref) && !$start) { ...@@ -258,6 +263,6 @@ if (isset($file_ref) && !$start) {
} }
//remove temporary file //remove temporary file
if ($type == 4) { if ($type === 4) {
@unlink($path_file); @unlink($path_file);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment