From 97a188592c679890a25c37ab78463add76a52ff7 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Fri, 21 Jun 2024 15:51:27 +0000 Subject: [PATCH] fix php8 warning, fixes #4341 Closes #4341 Merge request studip/studip!3143 --- app/controllers/course/timesrooms.php | 4 ++-- app/controllers/profile.php | 25 ++++++++++++------------- app/views/profile/index.php | 4 ++-- lib/activities/Context.php | 2 +- lib/filesystem/CourseGroupFolder.php | 4 ++-- templates/layouts/dialog.php | 4 ++-- 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/app/controllers/course/timesrooms.php b/app/controllers/course/timesrooms.php index f452f4d0169..4788eee05e0 100644 --- a/app/controllers/course/timesrooms.php +++ b/app/controllers/course/timesrooms.php @@ -516,7 +516,7 @@ class Course_TimesroomsController extends AuthenticatedController '<strong>' . htmlReady($singledate->toString()) . '</strong>' )); } - if ($singledate->messages['error']) { + if (!empty($singledate->messages['error'])) { PageLayout::postError( _('Die folgenden Fehler traten beim Bearbeiten des Termins auf:'), htmlReady($singledate->messages['error']) @@ -1687,7 +1687,7 @@ class Course_TimesroomsController extends AuthenticatedController } else { $user_rooms = RoomManager::getUserRooms($current_user); foreach ($user_rooms as $room) { - if ($room->userHasBookingRights($current_user, $begin, $end)) { + if ($room->userHasBookingRights($current_user, $begin ?? null, $end ?? null)) { $rooms_with_booking_permissions++; if ($only_bookable_rooms) { foreach ($all_time_intervals as $interval) { diff --git a/app/controllers/profile.php b/app/controllers/profile.php index 72a500e20d2..1412c9cd591 100644 --- a/app/controllers/profile.php +++ b/app/controllers/profile.php @@ -40,14 +40,14 @@ class ProfileController extends AuthenticatedController // set the page title depending on user selection if ( - $this->user + isset($this->user, $this->current_user) && $this->current_user->id === $this->user->id && !$this->current_user->locked ) { PageLayout::setTitle(_('Mein Profil')); UserConfig::get($this->user->id)->store('PROFILE_LAST_VISIT', time()); } elseif ( - $this->current_user->id + !empty($this->current_user->id) && ( $this->perm->have_perm('root') || ( @@ -139,17 +139,16 @@ class ProfileController extends AuthenticatedController } // calendar - $this->dates = ''; - if (Config::get()->CALENDAR_ENABLE) { - if (!in_array($this->current_user->perms, ['admin', 'root'])) { - if (Visibility::verify('termine', $this->current_user->user_id)) { - $start = time(); - $end = strtotime('+1 week 23:59:59'); - - $response = $this->relay('calendar/contentbox/display/' . $this->current_user->user_id . '/' . ($end - $start)); - $this->dates = $response->body; - } - } + if ( + Config::get()->CALENDAR_ENABLE + && !in_array($this->current_user->perms, ['admin', 'root']) + && Visibility::verify('termine', $this->current_user->user_id) + ) { + $start = time(); + $end = strtotime('+1 week 23:59:59'); + + $response = $this->relay('calendar/contentbox/display/' . $this->current_user->user_id . '/' . ($end - $start)); + $this->dates = $response->body; } // include and show votes and tests diff --git a/app/views/profile/index.php b/app/views/profile/index.php index b1911513eb9..9b7cb4f5b20 100644 --- a/app/views/profile/index.php +++ b/app/views/profile/index.php @@ -83,9 +83,9 @@ </section> -<?= $news ?> +<?= $news ?? '' ?> -<?= $dates ?> +<?= $dates ?? '' ?> <?= $questionnaires ?? '' ?> diff --git a/lib/activities/Context.php b/lib/activities/Context.php index 17055287266..dba0d0f9eb6 100644 --- a/lib/activities/Context.php +++ b/lib/activities/Context.php @@ -147,7 +147,7 @@ abstract class Context } else { foreach ($providers as $provider) { $ctype = $this->getContextType(); - $filtered_classes = $filter->getType()->$ctype; + $filtered_classes = $filter->getType()->$ctype ?? null; if (is_array($filtered_classes)) { foreach ($filtered_classes as $class) { diff --git a/lib/filesystem/CourseGroupFolder.php b/lib/filesystem/CourseGroupFolder.php index 81867f66491..36bbb922a84 100644 --- a/lib/filesystem/CourseGroupFolder.php +++ b/lib/filesystem/CourseGroupFolder.php @@ -123,7 +123,7 @@ class CourseGroupFolder extends StandardFolder public function getEditTemplate() { $template = $GLOBALS['template_factory']->open('filesystem/group_folder/edit.php'); - $group = Statusgruppen::find($this->folderdata['data_content']['group']); + $group = Statusgruppen::find($this->folderdata['data_content']['group'] ?? null); $template->set_attribute('group', $group); $template->set_attribute('folder', $this); return $template; @@ -151,7 +151,7 @@ class CourseGroupFolder extends StandardFolder */ public function getDescriptionTemplate() { - $group = new Statusgruppen($this->folderdata['data_content']['group']); + $group = new Statusgruppen($this->folderdata['data_content']['group'] ?? null); $template = $GLOBALS['template_factory']->open('filesystem/group_folder/description.php'); $template->type = self::getTypeName(); diff --git a/templates/layouts/dialog.php b/templates/layouts/dialog.php index ddf9280eed0..147f69d7579 100644 --- a/templates/layouts/dialog.php +++ b/templates/layouts/dialog.php @@ -1,2 +1,2 @@ -<?= implode(PageLayout::getMessages()) ?> -<?= $content_for_layout ?> \ No newline at end of file +<?= implode('', PageLayout::getMessages()) ?> +<?= $content_for_layout ?> -- GitLab