diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2023-08-29 15:29:26 +0000 |
|---|---|---|
| committer | David Siegfried <david.siegfried@uni-vechta.de> | 2023-08-29 15:29:26 +0000 |
| commit | 7ebc446999286d42affc5d27ea888dd997a3d95c (patch) | |
| tree | e1393a88d17fcc74276460604d9ce9998379bdac /lib | |
| parent | fd375126142decc222c1f61369dc198fb58b7f6e (diff) | |
prevent php8 warnings, fixes #3106
Closes #3106
Merge request studip/studip!2095
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/classes/coursewizardsteps/BasicDataWizardStep.php | 6 | ||||
| -rw-r--r-- | lib/elearning/ELearningUtils.class.php | 14 | ||||
| -rw-r--r-- | lib/filesystem/PublicFolder.php | 2 | ||||
| -rw-r--r-- | lib/models/Course.class.php | 6 | ||||
| -rw-r--r-- | lib/models/OERMaterial.php | 6 | ||||
| -rw-r--r-- | lib/models/SimpleCollection.class.php | 2 | ||||
| -rw-r--r-- | lib/plugins/core/CorePlugin.php | 4 | ||||
| -rw-r--r-- | lib/plugins/core/StudIPPlugin.class.php | 4 | ||||
| -rw-r--r-- | lib/plugins/engine/PluginManager.class.php | 6 | ||||
| -rw-r--r-- | lib/visual.inc.php | 13 |
10 files changed, 35 insertions, 28 deletions
diff --git a/lib/classes/coursewizardsteps/BasicDataWizardStep.php b/lib/classes/coursewizardsteps/BasicDataWizardStep.php index ce3b57f..100786b 100644 --- a/lib/classes/coursewizardsteps/BasicDataWizardStep.php +++ b/lib/classes/coursewizardsteps/BasicDataWizardStep.php @@ -344,13 +344,13 @@ class BasicDataWizardStep implements CourseWizardStep if (!trim($values['name'])) { $errors[] = _('Bitte geben Sie den Namen der Veranstaltung an.'); } - if ($values['number'] != '') { + if (!empty($values['number'])) { $course_number_format = Config::get()->COURSE_NUMBER_FORMAT; if ($course_number_format && !preg_match('/^' . $course_number_format . '$/', $values['number'])) { $errors[] = _('Die Veranstaltungsnummer hat ein ungültiges Format.'); } } - if (!$values['lecturers']) { + if (empty($values['lecturers'])) { $errors[] = sprintf( _('Bitte tragen Sie mindestens eine Person als %s ein.'), htmlReady(get_title_for_status('dozent', 1, $values['coursetype'])) @@ -411,7 +411,7 @@ class BasicDataWizardStep implements CourseWizardStep $course->status = $values['coursetype']; $course->name = new I18NString($values['name'], $values['name_i18n'] ?? []); - $course->veranstaltungsnummer = $values['number']; + $course->veranstaltungsnummer = $values['number'] ?? null; $course->beschreibung = new I18NString($values['description'], $values['description_i18n'] ?? []); $course->start_semester = Semester::findByTimestamp($values['start_time']); $course->institut_id = $values['institute']; diff --git a/lib/elearning/ELearningUtils.class.php b/lib/elearning/ELearningUtils.class.php index 30c40c4..d027e37 100644 --- a/lib/elearning/ELearningUtils.class.php +++ b/lib/elearning/ELearningUtils.class.php @@ -472,6 +472,7 @@ class ELearningUtils FROM object_contentmodules WHERE module_type = 'crs' AND object_id = " . $db->quote($sem_id)) ->fetchAll(PDO::FETCH_ASSOC); + $courses = []; foreach ($rs as $row) { $courses[$row['system_type']] = $row['module_id']; } @@ -479,23 +480,26 @@ class ELearningUtils $connected_courses = [ 'courses' => [], ]; - if (is_array($courses)) - foreach ($courses as $system_type => $crs_id) + if (is_array($courses)) { + foreach ($courses as $system_type => $crs_id) { if (self::isCMSActive($system_type)) { self::loadClass($system_type); $connected_courses['courses'][$system_type] = [ - 'url' => URLHelper::getLink($connected_cms[$system_type]->link->cms_link . '?client_id=' . $connected_cms[$system_type]->getClientId() . '&cms_select=' . $system_type . '&ref_id=' . $crs_id . '&type=crs&target=start'), - 'cms_name' => $connected_cms[$system_type]->getName()]; + 'url' => URLHelper::getLink($connected_cms[$system_type]->link->cms_link . '?client_id=' . $connected_cms[$system_type]->getClientId() . '&cms_select=' . $system_type . '&ref_id=' . $crs_id . '&type=crs&target=start'), + 'cms_name' => $connected_cms[$system_type]->getName() + ]; // gegebenenfalls zugeordnete Module aktualisieren if (Request::option('update')) { if ((method_exists($connected_cms[$system_type], "updateConnections"))) { - $connected_cms[$system_type]->updateConnections( $crs_id ); + $connected_cms[$system_type]->updateConnections($crs_id); } } if (method_exists($connected_cms[$system_type]->permissions, 'CheckUserPermissions')) { $connected_cms[$system_type]->permissions->CheckUserPermissions($crs_id); } } + } + } if ($connected_courses['courses']) { if (count($connected_courses['courses']) > 1) { diff --git a/lib/filesystem/PublicFolder.php b/lib/filesystem/PublicFolder.php index 15fdf34..6b06ac9 100644 --- a/lib/filesystem/PublicFolder.php +++ b/lib/filesystem/PublicFolder.php @@ -60,7 +60,7 @@ class PublicFolder extends StandardFolder public function __get($attribute) { if ($attribute === 'viewable') { - return $this->folderdata['data_content']['viewable']; + return !empty($this->folderdata['data_content']['viewable']); } return $this->folderdata[$attribute]; } diff --git a/lib/models/Course.class.php b/lib/models/Course.class.php index e16df06..4c471ea 100644 --- a/lib/models/Course.class.php +++ b/lib/models/Course.class.php @@ -341,7 +341,7 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe { $end_semester = $this->semesters->last(); $start_semester = $this->semesters->first(); - if ($start_semester->id === $semester->id) { + if ($start_semester && $start_semester->id === $semester->id) { return; } if ($end_semester) { @@ -369,7 +369,9 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe { $end_semester = $this->semesters->last(); $start_semester = $this->semesters->first(); - if ((is_null($end_semester) && is_null($semester)) || ($end_semester->id === $semester->id)) { + if ( + (is_null($end_semester) && is_null($semester)) + || ($end_semester && $semester && $end_semester->id === $semester->id)) { return; } if ($start_semester) { diff --git a/lib/models/OERMaterial.php b/lib/models/OERMaterial.php index ea36035..f0e101d 100644 --- a/lib/models/OERMaterial.php +++ b/lib/models/OERMaterial.php @@ -390,8 +390,10 @@ class OERMaterial extends SimpleORMap } $url = $this->getDownloadUrl(); $headers = get_headers($url, true, get_default_http_stream_context($url)); - if ($headers['Content-Disposition'] - && substr($headers['Content-Disposition'], 0, strlen('attachment')) === 'attachment') { + if ( + !empty($headers['Content-Disposition']) + && substr($headers['Content-Disposition'], 0, strlen('attachment')) === 'attachment' + ) { //in this case the server forces to download the document and we cannot display it in an iframe: return false; } diff --git a/lib/models/SimpleCollection.class.php b/lib/models/SimpleCollection.class.php index 11dd296..4228599 100644 --- a/lib/models/SimpleCollection.class.php +++ b/lib/models/SimpleCollection.class.php @@ -592,7 +592,7 @@ class SimpleCollection extends StudipArrayObject public function val($key) { $first = $this->first(); - return $first[$key] ?: null; + return $first[$key] ?? null; } /** diff --git a/lib/plugins/core/CorePlugin.php b/lib/plugins/core/CorePlugin.php index 0bba289..7f1aaed 100644 --- a/lib/plugins/core/CorePlugin.php +++ b/lib/plugins/core/CorePlugin.php @@ -64,10 +64,10 @@ abstract class CorePlugin { $metadata = $this->getMetadata(); $language = getUserLanguage(User::findCurrent()->id); - if ($metadata['descriptionlong_' . $language]) { + if (!empty($metadata['descriptionlong_' . $language])) { return $metadata['descriptionlong_' . $language]; } - if ($metadata['description_' . $language]) { + if (!empty($metadata['description_' . $language])) { return $metadata['description_' . $language]; } $description = $metadata['descriptionlong'] ?? $metadata['description']; diff --git a/lib/plugins/core/StudIPPlugin.class.php b/lib/plugins/core/StudIPPlugin.class.php index a3dacb6..be2c776 100644 --- a/lib/plugins/core/StudIPPlugin.class.php +++ b/lib/plugins/core/StudIPPlugin.class.php @@ -89,10 +89,10 @@ abstract class StudIPPlugin { $metadata = $this->getMetadata(); $language = getUserLanguage(User::findCurrent()->id); - if ($metadata['descriptionlong_' . $language]) { + if (!empty($metadata['descriptionlong_' . $language])) { return $metadata['descriptionlong_' . $language]; } - if ($metadata['description_' . $language]) { + if (!empty($metadata['description_' . $language])) { return $metadata['description_' . $language]; } $description = $metadata['descriptionlong'] ?? $metadata['description']; diff --git a/lib/plugins/engine/PluginManager.class.php b/lib/plugins/engine/PluginManager.class.php index 7fb69bc..39f4e87 100644 --- a/lib/plugins/engine/PluginManager.class.php +++ b/lib/plugins/engine/PluginManager.class.php @@ -87,9 +87,9 @@ class PluginManager 'automatic_update_url' => $plugin['automatic_update_url'], 'automatic_update_secret' => $plugin['automatic_update_secret'], 'description' => $plugin['description'], - 'description_mode' => $plugin['description_mode'], - 'highlight_until' => $plugin['highlight_until'], - 'highlight_text' => $plugin['highlight_text'] + 'description_mode' => $plugin['description_mode'] ?? null, + 'highlight_until' => $plugin['highlight_until'] ?? null, + 'highlight_text' => $plugin['highlight_text'] ?? null, ]; } } diff --git a/lib/visual.inc.php b/lib/visual.inc.php index 8503a5c..2b37a64 100644 --- a/lib/visual.inc.php +++ b/lib/visual.inc.php @@ -399,14 +399,13 @@ function symbol ($text = '') function mila ($titel, $size = 60) { global $auth; - if ($auth->auth["jscript"] AND $size == 60) { + if (!empty($auth->auth['jscript']) && $size == 60) { //hier wird die maximale Laenge berechnet, nach der Abgeschnitten wird (JS dynamisch) - if (mb_strlen ($titel) >$auth->auth["xres"] / 13) - $titel=mb_substr($titel, 0, $auth->auth["xres"] / 13)."... "; - } - else { - if (mb_strlen ($titel) >$size) - $titel=mb_substr($titel, 0, $size)."... "; + if (mb_strlen($titel) > $auth->auth['xres'] / 13) { + $titel = mb_substr($titel, 0, $auth->auth['xres'] / 13) . '... '; + } + } elseif (mb_strlen ($titel) >$size) { + $titel = mb_substr($titel, 0, $size) . '... '; } return $titel; } |
