From 7ebc446999286d42affc5d27ea888dd997a3d95c Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms Date: Tue, 29 Aug 2023 15:29:26 +0000 Subject: prevent php8 warnings, fixes #3106 Closes #3106 Merge request studip/studip!2095 --- app/controllers/course/contentmodules.php | 8 ++++---- app/controllers/course/elearning.php | 5 ++++- app/controllers/course/wizard.php | 2 +- app/controllers/new_password.php | 1 + app/controllers/resources/room_request.php | 2 +- app/views/course/contentmodules/info.php | 4 ++-- lib/classes/coursewizardsteps/BasicDataWizardStep.php | 6 +++--- lib/elearning/ELearningUtils.class.php | 14 +++++++++----- lib/filesystem/PublicFolder.php | 2 +- lib/models/Course.class.php | 6 ++++-- lib/models/OERMaterial.php | 6 ++++-- lib/models/SimpleCollection.class.php | 2 +- lib/plugins/core/CorePlugin.php | 4 ++-- lib/plugins/core/StudIPPlugin.class.php | 4 ++-- lib/plugins/engine/PluginManager.class.php | 6 +++--- lib/visual.inc.php | 13 ++++++------- 16 files changed, 48 insertions(+), 37 deletions(-) diff --git a/app/controllers/course/contentmodules.php b/app/controllers/course/contentmodules.php index 06d46de..04eb846 100644 --- a/app/controllers/course/contentmodules.php +++ b/app/controllers/course/contentmodules.php @@ -298,22 +298,22 @@ class Course_ContentmodulesController extends AuthenticatedController 'visibility' => $visibility, 'active' => (bool) $tool, ]; - if ($metadata['icon_clickable']) { + if (!empty($metadata['icon_clickable'])) { $list[$plugin_id]['icon'] = $metadata['icon_clickable'] instanceof Icon ? $metadata['icon_clickable']->asImagePath() : Icon::create($plugin->getPluginURL().'/'.$metadata['icon_clickable'])->asImagePath(); - } elseif ($metadata['icon']) { + } elseif (!empty($metadata['icon'])) { $list[$plugin_id]['icon'] = $metadata['icon'] instanceof Icon ? $metadata['icon']->asImagePath() : Icon::create($plugin->getPluginURL().'/'.$metadata['icon'])->asImagePath(); } else { $list[$plugin_id]['icon'] = null; } - $list[$plugin_id]['summary'] = $metadata['summary']; + $list[$plugin_id]['summary'] = $metadata['summary'] ?? null; $list[$plugin_id]['mandatory'] = $this->sem_class->isModuleMandatory(get_class($plugin)); $list[$plugin_id]['highlighted'] = (bool) $plugin->isHighlighted(); $list[$plugin_id]['highlight_text'] = $plugin->getHighlightText(); - $list[$plugin_id]['category'] = $metadata['category']; + $list[$plugin_id]['category'] = $metadata['category'] ?? null; } return $list; diff --git a/app/controllers/course/elearning.php b/app/controllers/course/elearning.php index a8a7626..6e67b64 100644 --- a/app/controllers/course/elearning.php +++ b/app/controllers/course/elearning.php @@ -57,7 +57,10 @@ class Course_ElearningController extends AuthenticatedController if (!isset($GLOBALS['ELEARNING_INTERFACE_MODULES'][$this->cms_select])) { unset($this->cms_select); } - if ($this->seminar_id != $_SESSION['elearning_open_close']["id"]) { + if ( + isset($_SESSION['elearning_open_close']['id']) + && $this->seminar_id !== $_SESSION['elearning_open_close']['id'] + ) { unset($_SESSION['cache_data']); unset($_SESSION['elearning_open_close']); } diff --git a/app/controllers/course/wizard.php b/app/controllers/course/wizard.php index 009e052..636d6eb 100644 --- a/app/controllers/course/wizard.php +++ b/app/controllers/course/wizard.php @@ -118,7 +118,7 @@ class Course_WizardController extends AuthenticatedController $values[$iterator->key()] = $iterator->current(); $iterator->next(); } - if ($this->steps[$step_number]['classname']) { + if (!empty($this->steps[$step_number]['classname'])) { $this->setStepValues($this->steps[$step_number]['classname'], $values); } // Back or forward button clicked -> set next step accordingly. diff --git a/app/controllers/new_password.php b/app/controllers/new_password.php index 5132c48..525d73b 100644 --- a/app/controllers/new_password.php +++ b/app/controllers/new_password.php @@ -111,6 +111,7 @@ class NewPasswordController extends StudipController $password = Request::get('new_password'); $confirm = Request::get('new_password_confirm'); + $errors = []; if (!$validator->ValidatePassword($password)) { $errors[] = _('Das Passwort ist zu kurz. Es sollte mindestens 8 Zeichen lang sein.'); } else if ($password !== $confirm) { diff --git a/app/controllers/resources/room_request.php b/app/controllers/resources/room_request.php index f128f23..db892e0 100644 --- a/app/controllers/resources/room_request.php +++ b/app/controllers/resources/room_request.php @@ -1997,7 +1997,7 @@ class Resources_RoomRequestController extends AuthenticatedController if ($save_only) { // redirect to reload all infos and showing the most current ones $this->redirect('resources/room_request/resolve/' . $request_id); - } elseif (Request::isDialog()) { + } elseif (Request::isDialog() && Context::get()) { $this->response->add_header('X-Dialog-Execute', '{"func": "STUDIP.AdminCourses.App.loadCourse", "payload": "'.Context::get()->id.'"}'); } } diff --git a/app/views/course/contentmodules/info.php b/app/views/course/contentmodules/info.php index 18d7ccf..11bf9dc 100644 --- a/app/views/course/contentmodules/info.php +++ b/app/views/course/contentmodules/info.php @@ -29,8 +29,8 @@
- - + + 0) : ?>