From 4695506d9ea6d0dce90e16f12ae0bb215ce1a01b Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms Date: Mon, 17 Oct 2022 14:50:20 +0000 Subject: fix php8 warnings, fixes #1679 Closes #1679 Merge request studip/studip!1084 --- app/controllers/calendar/calendar.php | 12 +++--- app/controllers/calendar/schedule.php | 1 + app/controllers/contact.php | 3 +- app/controllers/course/details.php | 6 +-- app/controllers/course/members.php | 1 + app/controllers/elearning.php | 12 ++++-- app/controllers/news.php | 4 +- app/controllers/profilemodules.php | 12 +++--- app/controllers/search/archive.php | 1 + app/controllers/settings/statusgruppen.php | 2 +- app/views/api/authorizations/index.php | 4 +- app/views/calendar/schedule/index.php | 2 +- app/views/course/details/index.php | 8 ++-- app/views/course/feedback/index_for.php | 4 +- app/views/course/members/autor_list.php | 4 +- app/views/course/plus/index.php | 4 +- app/views/course/wizard/steps/studyareas/_node.php | 2 +- app/views/files/_fileref_tr.php | 4 +- app/views/files/_files_thead.php | 18 ++++---- app/views/files/_overview.php | 2 +- app/views/files/index.php | 4 +- app/views/files_dashboard/_input-group-search.php | 4 +- app/views/score/index.php | 12 +++--- app/views/settings/studies/index.php | 4 +- lib/calendar/CalendarColumn.class.php | 2 +- lib/classes/ForumHelpers.php | 2 +- lib/classes/I18NString.php | 2 +- lib/classes/LinkButton.class.php | 17 ++++---- lib/classes/ModulesNotification.class.php | 13 ++++-- lib/classes/MultiPersonSearch.class.php | 26 ++++++------ lib/classes/SemBrowse.class.php | 2 +- lib/classes/SemClass.class.php | 3 +- lib/classes/SmileyFormat.php | 2 +- lib/classes/WikiFormat.php | 2 +- lib/classes/calendar/CalendarScheduleModel.php | 2 +- .../HTMLPurifier_Injector_TransformLinks.php | 2 +- lib/filesystem/FileManager.php | 10 ++--- lib/functions.php | 8 ++-- lib/meine_seminare_func.inc.php | 19 ++++++--- lib/models/BlubberThread.php | 3 ++ lib/models/DataField.class.php | 2 +- lib/models/DatafieldEntryModel.class.php | 4 +- lib/models/StudipNews.class.php | 46 +++++++++++---------- lib/models/User.class.php | 2 +- lib/models/resources/Resource.class.php | 2 +- lib/user_visible.inc.php | 2 +- lib/visual.inc.php | 4 +- templates/dates/seminar_html_location.php | 27 +++++++----- templates/header.php | 2 +- templates/layouts/base.php | 2 +- templates/shared/pagechooser.php | 4 +- templates/sidebar/room-search-criteria-seats.php | 2 +- tests/unit/lib/classes/LinkButtonTest.php | 48 ++++++++++++++-------- 53 files changed, 223 insertions(+), 169 deletions(-) diff --git a/app/controllers/calendar/calendar.php b/app/controllers/calendar/calendar.php index 65dafa2..5ad138f 100644 --- a/app/controllers/calendar/calendar.php +++ b/app/controllers/calendar/calendar.php @@ -109,12 +109,12 @@ class Calendar_CalendarController extends AuthenticatedController $tmpl->action_url = $this->url_for('calendar/group/switch'); $tmpl->view = $this->action; $filters->addElement(new WidgetElement($tmpl->render())); - $filters->addCheckbox(_('Abgelehnte Termine anzeigen'), - $this->settings['show_declined'], - $this->url_for($this->base . 'show_declined', - ['show_declined' => 1]), - $this->url_for($this->base . 'show_declined', - ['show_declined' => 0])); + $filters->addCheckbox( + _('Abgelehnte Termine anzeigen'), + $this->settings['show_declined'] ?? false, + $this->url_for($this->base . 'show_declined', ['show_declined' => 1]), + $this->url_for($this->base . 'show_declined', ['show_declined' => 0]) + ); } Sidebar::get()->addWidget($filters); } diff --git a/app/controllers/calendar/schedule.php b/app/controllers/calendar/schedule.php index c20fbea..9b106bd 100644 --- a/app/controllers/calendar/schedule.php +++ b/app/controllers/calendar/schedule.php @@ -63,6 +63,7 @@ class Calendar_ScheduleController extends AuthenticatedController { $schedule_settings = CalendarScheduleModel::getScheduleSettings(); $inst_mode = false; + $institute_id = null; if ($GLOBALS['perm']->have_perm('admin')) { $inst_mode = true; } diff --git a/app/controllers/contact.php b/app/controllers/contact.php index 35b693c..0225149 100644 --- a/app/controllers/contact.php +++ b/app/controllers/contact.php @@ -76,6 +76,7 @@ class ContactController extends AuthenticatedController $selected = $this->group; $contacts = SimpleCollection::createFromArray(User::findMany($selected->members->pluck('user_id'))); } else { + $selected = false; $contacts = User::findCurrent()->contacts; } $contacts = $contacts->filter(function($u) { @@ -206,7 +207,7 @@ class ContactController extends AuthenticatedController $letterlist = new SidebarWidget(); $html = ''; foreach (range('A', 'Z') as $letter) { - if ($this->contacts[$letter]) { + if (!empty($this->contacts[$letter])) { $html .= "{$letter}"; } else { $html .= "{$letter}"; diff --git a/app/controllers/course/details.php b/app/controllers/course/details.php index 5eaedf7..a956f07 100644 --- a/app/controllers/course/details.php +++ b/app/controllers/course/details.php @@ -24,7 +24,7 @@ class Course_DetailsController extends AuthenticatedController { parent::before_filter($action, $args); - $course_id = Request::option('sem_id', $args[0]); + $course_id = Request::option('sem_id', $args[0] ?? null); if (empty($course_id)) { checkObject(); //wirft Exception, wenn Context::get() leer ist $course_id = $GLOBALS['SessionSeminar']; @@ -217,7 +217,7 @@ class Course_DetailsController extends AuthenticatedController Icon::create('print'), ['class' => 'print_action', 'target' => '_blank'] ); - if ($enrolment_info['enrolment_allowed'] && $sidebarlink) { + if (isset($enrolment_info) && $enrolment_info['enrolment_allowed'] && $sidebarlink) { if (in_array($enrolment_info['cause'], ['member', 'root', 'courseadmin'])) { $abo_msg = _('direkt zur Veranstaltung'); } else { @@ -291,7 +291,7 @@ class Course_DetailsController extends AuthenticatedController ); $sidebar->addWidget($share); - if ($enrolment_info['description']) { + if (isset($enrolment_info) && $enrolment_info['description']) { PageLayout::postInfo($enrolment_info['description']); } } diff --git a/app/controllers/course/members.php b/app/controllers/course/members.php index 1fe9f57..c0c5075 100644 --- a/app/controllers/course/members.php +++ b/app/controllers/course/members.php @@ -145,6 +145,7 @@ class Course_MembersController extends AuthenticatedController $this->studipticket = Seminar_Session::get_ticket(); $this->subject = $this->getSubject(); $this->groups = $this->status_groups; + $this->semAdmissionEnabled = false; // Check Seminar $this->waitingTitle = _('Warteliste (nicht aktiv)'); $this->waiting_type = 'awaiting'; diff --git a/app/controllers/elearning.php b/app/controllers/elearning.php index 082a210..97b1b90 100644 --- a/app/controllers/elearning.php +++ b/app/controllers/elearning.php @@ -40,7 +40,7 @@ class ElearningController extends AuthenticatedController $this->cms_select = Request::quoted('cms_select'); $GLOBALS['cms_select'] = $this->cms_select; $this->cms_list = []; - if ($_SESSION['elearning_open_close']["type"] != "user") { + if (isset($_SESSION['elearning_open_close']) && $_SESSION['elearning_open_close']["type"] != "user") { unset($_SESSION['elearning_open_close']); } $_SESSION['elearning_open_close']["type"] = "user"; @@ -140,6 +140,7 @@ class ElearningController extends AuthenticatedController $sidebar = Sidebar::get(); $widget = new ActionsWidget(); + $link_count = 0; if ($GLOBALS['perm']->have_perm('autor') AND count($this->cms_list)) { foreach($this->cms_list as $cms_key => $cms_data) { if ($connected_cms[$cms_key]->user->isConnected()) { @@ -153,13 +154,16 @@ class ElearningController extends AuthenticatedController } } } - if ($link_count) + if ($link_count) { $sidebar->addWidget($widget); + } // terminate objects - if (is_array($connected_cms)) - foreach($connected_cms as $system) + if (is_array($connected_cms)) { + foreach ($connected_cms as $system) { $system->terminate(); + } + } if (is_array($messages)) { foreach ($messages as $mtype => $mtext) { diff --git a/app/controllers/news.php b/app/controllers/news.php index d41ee63..2048ec7 100644 --- a/app/controllers/news.php +++ b/app/controllers/news.php @@ -435,7 +435,7 @@ class NewsController extends StudipController } else { $this->news_startdate = time(); } - if (is_array($this->area_structure[$area_type])) { + if (isset($this->area_structure[$area_type]) && is_array($this->area_structure[$area_type])) { $this->area_type = $area_type; } PageLayout::setTitle(_('Meine Ankündigungen')); @@ -523,7 +523,7 @@ class NewsController extends StudipController $counter = 0; // check for delete-buttons and news limit foreach ($this->area_structure as $type => $area_data) { - if (is_array($this->news_items[$type])) { + if (isset($this->news_items[$type]) && is_array($this->news_items[$type])) { foreach($this->news_items[$type] as $key => $news) { // has trash icon been clicked? if (Request::submitted('news_remove_' . $news['object']->news_id . '_' . $news['range_id']) && Request::isPost()) { diff --git a/app/controllers/profilemodules.php b/app/controllers/profilemodules.php index 3c0a354..607a798 100644 --- a/app/controllers/profilemodules.php +++ b/app/controllers/profilemodules.php @@ -282,24 +282,24 @@ class ProfileModulesController extends AuthenticatedController if ($config['displaystyle'] !== 'category'){ $cat = 'Funktionen von A-Z'; } else { - $cat = $metadata['category'] ?: 'Sonstiges'; + $cat = !empty($metadata['category']) ? $metadata['category'] : 'Sonstiges'; } - $icon = $metadata['icon']; + $icon = $metadata['icon'] ?? false; if ($icon && !$icon instanceof Icon) { $icon = Icon::create("{$plugin->getPluginURL()}/{$metadata['icon']}"); } $item = [ 'id' => $plugin->getPluginId(), - 'name' => $metadata['displayname'] ?: $plugin->getPluginname(), + 'name' => !empty($metadata['displayname']) ? $metadata['displayname'] : $plugin->getPluginname(), 'url' => $plugin->getPluginURL(), 'activated' => $manager->isPluginActivatedForUser($plugin->getPluginId(), $this->user->id), 'icon' => $icon, - 'abstract' => str_replace('\n', ' ', $metadata['descriptionshort'] ?? $metadata['summary']), - 'description' => str_replace('\n', ' ', $metadata['descriptionlong'] ?? $metadata['description']), + 'abstract' => str_replace('\n', ' ', $metadata['descriptionshort'] ?? $metadata['summary'] ?? ''), + 'description' => str_replace('\n', ' ', $metadata['descriptionlong'] ?? $metadata['description'] ?? ''), 'screenshots' => [], - 'keywords' => $metadata['keywords'] ? explode(';', $metadata['keywords']) : [], + 'keywords' => isset($metadata['keywords']) ? explode(';', $metadata['keywords']) : [], 'homepage' => $metadata['homepage'] ?? '', 'helplink' => $metadata['helplink'] ?? '', ]; diff --git a/app/controllers/search/archive.php b/app/controllers/search/archive.php index 624baeb..9276508 100644 --- a/app/controllers/search/archive.php +++ b/app/controllers/search/archive.php @@ -39,6 +39,7 @@ class Search_ArchiveController extends AuthenticatedController $this->teacher = trim(Request::get('teacher')); $this->semester = Request::get('semester'); $this->institute = Request::get('institute'); + $this->courses = []; // the optional parameter my_courses_only says that only the courses of // the current user shall be searched with the search criteria diff --git a/app/controllers/settings/statusgruppen.php b/app/controllers/settings/statusgruppen.php index fd7d91c..789d0ca 100644 --- a/app/controllers/settings/statusgruppen.php +++ b/app/controllers/settings/statusgruppen.php @@ -45,6 +45,7 @@ class Settings_StatusgruppenController extends Settings_SettingsController public function index_action($verify_action = null, $verify_id = null) { $all_rights = false; + $admin_insts = []; if ($this->user->username != $GLOBALS['user']->username) { $query = "SELECT Institut_id FROM Institute @@ -79,7 +80,6 @@ class Settings_StatusgruppenController extends Settings_SettingsController $statement->execute($parameters); $institutes = $statement->fetchAll(PDO::FETCH_ASSOC); - $admin_insts = []; foreach ($institutes as $institute) { $institute['groups'] = GetAllStatusgruppen($institute['Institut_id'], $this->user->id) ?: []; diff --git a/app/views/api/authorizations/index.php b/app/views/api/authorizations/index.php index 1b07dad..95645f4 100644 --- a/app/views/api/authorizations/index.php +++ b/app/views/api/authorizations/index.php @@ -22,8 +22,8 @@ title) ?> - type]): ?> - () + type])): ?> + (type]) ?>) description): ?> diff --git a/app/views/calendar/schedule/index.php b/app/views/calendar/schedule/index.php index 31339f5..45a4c32 100644 --- a/app/views/calendar/schedule/index.php +++ b/app/views/calendar/schedule/index.php @@ -72,7 +72,7 @@ $sidebar->addWidget($options, 'calendar/schedule/options'); - +
render_partial('calendar/schedule/_dialog', [ 'content_for_layout' => $this->render_partial('calendar/schedule/entry', [ diff --git a/app/views/course/details/index.php b/app/views/course/details/index.php index 7621519..0e82494 100644 --- a/app/views/course/details/index.php +++ b/app/views/course/details/index.php @@ -138,7 +138,7 @@ - + @@ -343,7 +343,7 @@ -required_children) : ?> +required_children) : ?>

@@ -384,7 +384,7 @@ +if (!empty($mvv_tree)) : ?>

@@ -400,7 +400,7 @@ if ($mvv_tree) : ?>
- +

diff --git a/app/views/course/feedback/index_for.php b/app/views/course/feedback/index_for.php index 7e27bfd..d2e82e6 100644 --- a/app/views/course/feedback/index_for.php +++ b/app/views/course/feedback/index_for.php @@ -8,7 +8,7 @@
- \ No newline at end of file + diff --git a/app/views/course/members/autor_list.php b/app/views/course/members/autor_list.php index e40a454..5c2ca17 100644 --- a/app/views/course/members/autor_list.php +++ b/app/views/course/members/autor_list.php @@ -81,7 +81,7 @@ - + @@ -175,7 +175,7 @@ - 0) : ?> + diff --git a/app/views/course/plus/index.php b/app/views/course/plus/index.php index f3a348f..a034f57 100644 --- a/app/views/course/plus/index.php +++ b/app/views/course/plus/index.php @@ -25,7 +25,7 @@ use Studip\Button; if ($_SESSION['plus']['displaystyle'] != 'category' && $category != 'Funktionen von A-Z') { $visibility = 'invisible'; } - if (isset($_SESSION['plus']) && !$_SESSION['plus']['Kategorie'][$category] && $category != 'Funktionen von A-Z') { + if (isset($_SESSION['plus']) && empty($_SESSION['plus']['Kategorie'][$category]) && $category != 'Funktionen von A-Z') { $visibility = 'invisible'; } ?> @@ -61,7 +61,7 @@ use Studip\Button; id="" name="" data-moduleclass="" - data-key="" + data-key="" value="TRUE" onClick="STUDIP.Plus.setModule.call(this);">
diff --git a/app/views/course/wizard/steps/studyareas/_node.php b/app/views/course/wizard/steps/studyareas/_node.php index 75e37c2..00238a4 100644 --- a/app/views/course/wizard/steps/studyareas/_node.php +++ b/app/views/course/wizard/steps/studyareas/_node.php @@ -1,4 +1,4 @@ -id, $search_result)) : ?> +id, $search_result)) : ?>
  • isAssignable()) : ?> asInput(["name" => 'assign['.$node->id.']', "onclick" => "return STUDIP.CourseWizard.assignNode('".$node->id."')", "class" => in_array($node->id,$values['studyareas']?:[])?'hidden-no-js':'', "style" => in_array($node->id,$values['studyareas']?:[])?'display:none':false]) ?> diff --git a/app/views/files/_fileref_tr.php b/app/views/files/_fileref_tr.php index 2bf7fe2..7ab64a7 100644 --- a/app/views/files/_fileref_tr.php +++ b/app/views/files/_fileref_tr.php @@ -17,7 +17,7 @@ if ($file->isDownloadable($GLOBALS['user']->id)) { getId(), (array) $marked_element_ids) ? 'checked' : '' ?>> + getId(), (array) ($marked_element_ids ?? [])) ? 'checked' : '' ?>> @@ -40,7 +40,7 @@ if ($file->isDownloadable($GLOBALS['user']->id)) { getTermsOfUse() ?> - isDownloadable($topFolder->range_id, $topFolder->range_type, false)) : ?> + isDownloadable($topFolder->range_id, $topFolder->range_type, false)) : ?> asImg(['title' => _('Das Herunterladen dieser Datei ist nur eingeschränkt möglich.')]) ?> diff --git a/app/views/files/_files_thead.php b/app/views/files/_files_thead.php index 4bad9f7..a6024e9 100644 --- a/app/views/files/_files_thead.php +++ b/app/views/files/_files_thead.php @@ -1,11 +1,11 @@ - + - + @@ -17,11 +17,11 @@ - @@ -36,11 +36,11 @@ - - getAdditionalColumns() as $index => $column_name) : ?> - - - + + getAdditionalColumns() as $column_name) : ?> + + + diff --git a/app/views/files/_overview.php b/app/views/files/_overview.php index 6fd203f..9027822 100644 --- a/app/views/files/_overview.php +++ b/app/views/files/_overview.php @@ -102,6 +102,6 @@
  • - + diff --git a/app/views/files/index.php b/app/views/files/index.php index a0fc2bc..94ae3f4 100644 --- a/app/views/files/index.php +++ b/app/views/files/index.php @@ -1,6 +1,6 @@ range_type !== 'user') { $controllerpath = $topFolder->range_type . '/' . $controllerpath; @@ -81,7 +81,7 @@ } ?> - +
    render_partial('files_dashboard/_input-group-search') ?>
    diff --git a/app/views/files_dashboard/_input-group-search.php b/app/views/files_dashboard/_input-group-search.php index 0606b68..258f83b 100644 --- a/app/views/files_dashboard/_input-group-search.php +++ b/app/views/files_dashboard/_input-group-search.php @@ -1,7 +1,7 @@