From 9b7bae8c79ccb90e7cc6508f85bd30dfc9aef120 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms Date: Thu, 3 Feb 2022 14:13:06 +0100 Subject: transfer changeset 59563 from svn --- app/controllers/calendar/schedule.php | 1 + app/controllers/contact.php | 5 ++-- app/controllers/search/courses.php | 2 +- app/controllers/search/globalsearch.php | 2 +- app/controllers/search/module.php | 34 ++++++++++++++------------ app/controllers/search/studiengaenge.php | 4 +-- app/views/blubber/index.php | 2 +- app/views/score/index.php | 6 ++--- app/views/search/breadcrumb.php | 8 +++--- app/views/search/module/index.php | 2 +- app/views/search/studiengaenge/verlauf.php | 2 +- lib/classes/BlubberFormat.php | 6 ++--- lib/classes/BreadCrumb.class.php | 6 +++-- lib/classes/Config.class.php | 2 +- lib/classes/MultiPersonSearch.class.php | 2 +- lib/classes/RangeConfig.class.php | 2 +- lib/classes/SQLQuery.php | 20 ++++++++------- lib/classes/Score.class.php | 4 +-- lib/classes/SemClass.class.php | 10 ++++---- lib/classes/StudipCoreFormat.php | 20 +++++++-------- lib/classes/StudipRangeTree.class.php | 9 +++++-- lib/classes/TreeAbstract.class.php | 7 ++++-- lib/classes/calendar/CalendarScheduleModel.php | 6 ++--- lib/models/BlubberThread.php | 15 ++++++++---- lib/models/SimpleCollection.class.php | 6 +++-- lib/models/SimpleORMap.class.php | 12 +++++---- lib/models/resources/Room.class.php | 2 +- lib/object.inc.php | 2 +- lib/user_visible.inc.php | 2 ++ lib/visual.inc.php | 6 ++--- 30 files changed, 117 insertions(+), 90 deletions(-) diff --git a/app/controllers/calendar/schedule.php b/app/controllers/calendar/schedule.php index c20fbea..b40c9dc 100644 --- a/app/controllers/calendar/schedule.php +++ b/app/controllers/calendar/schedule.php @@ -77,6 +77,7 @@ class Calendar_ScheduleController extends AuthenticatedController } Navigation::activateItem('/browse/my_courses/schedule'); } else { + $institute_id = null; Navigation::activateItem('/calendar/schedule'); } diff --git a/app/controllers/contact.php b/app/controllers/contact.php index ea46c82..b69944d 100644 --- a/app/controllers/contact.php +++ b/app/controllers/contact.php @@ -23,7 +23,7 @@ class ContactController extends AuthenticatedController $this->groups = SimpleCollection::createFromArray(Statusgruppen::findByRange_id(User::findCurrent()->id)); // Load requested group - if ($args[0]) { + if (!empty($args[0])) { $this->group = $this->groups->findOneBy('statusgruppe_id', $args[0]); //Check for cheaters @@ -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 (isset($this->contacts[$letter])) { $html .= "{$letter}"; } else { $html .= "{$letter}"; diff --git a/app/controllers/search/courses.php b/app/controllers/search/courses.php index cd38f94..fe8d729 100644 --- a/app/controllers/search/courses.php +++ b/app/controllers/search/courses.php @@ -34,7 +34,7 @@ class Search_CoursesController extends AuthenticatedController Navigation::activateItem('/search/courses/' . $this->nav_option); } else { URLHelper::removeLinkParam('option'); - $level = Request::get('level', $_SESSION['sem_browse_data']['level']); + $level = Request::get('level', $_SESSION['sem_browse_data']['level'] ?? null); $default_option = SemBrowse::getSearchOptionNavigation('sidebar'); if (!$level) { PageLayout::setTitle(_($default_option->getTitle())); diff --git a/app/controllers/search/globalsearch.php b/app/controllers/search/globalsearch.php index 9c41112..b8de786 100644 --- a/app/controllers/search/globalsearch.php +++ b/app/controllers/search/globalsearch.php @@ -116,7 +116,7 @@ class Search_GlobalsearchController extends AuthenticatedController private function getSemesters() { // set the current semester as the initially selected semester - if (!$_SESSION['global_search']['selects']) { + if (empty($_SESSION['global_search']['selects'])) { $current_sem = GlobalSearchModule::getCurrentSemester(); $_SESSION['global_search']['selects']['semester'] = $current_sem; } diff --git a/app/controllers/search/module.php b/app/controllers/search/module.php index dd555e0..57e24d3 100644 --- a/app/controllers/search/module.php +++ b/app/controllers/search/module.php @@ -119,12 +119,15 @@ class Search_ModuleController extends MVVController } if ($do_search) { - PageLayout::postInfo(sprintf(ngettext( - '%s Modul gefunden für die Suche nach %s', - '%s Module gefunden für die Suche nach %s', - count($this->search_result['Modul'])), - count($this->search_result['Modul']), - htmlReady($this->sterm))); + PageLayout::postInfo(sprintf( + ngettext( + '%s Modul gefunden für die Suche nach %s', + '%s Module gefunden für die Suche nach %s', + count($this->search_result['Modul']) + ), + count($this->search_result['Modul']), + htmlReady($this->sterm) + )); } } @@ -147,14 +150,11 @@ class Search_ModuleController extends MVVController $sidebar->addWidget($widget, 'sem_filter'); $this->input_search = $this->sterm; - $this->result_count = is_array($this->search_result['Modul']) ? count($this->search_result['Modul']) : 0; - - $drill_down['studiengaenge']['objects'] = - $this->drilldown_studiengaenge($this->search_result['Modul']); - $drill_down['faecher']['objects'] = - $this->drilldown_faecher($this->search_result['Modul']); - $drill_down['institutes']['objects'] = - $this->drilldown_institutes($this->search_result['Modul']); + $this->result_count = is_array($this->search_result['Modul'] ?? null) ? count($this->search_result['Modul']) : 0; + + $drill_down['studiengaenge']['objects'] = $this->drilldown_studiengaenge($this->search_result['Modul'] ?? null); + $drill_down['faecher']['objects'] = $this->drilldown_faecher($this->search_result['Modul'] ?? null); + $drill_down['institutes']['objects'] = $this->drilldown_institutes($this->search_result['Modul'] ?? null); if (count($drill_down['institutes']['objects']) || count($drill_down['studiengaenge']['objects']) || count($drill_down['faecher']['objects'])) { @@ -214,8 +214,10 @@ class Search_ModuleController extends MVVController } $this->module = []; - if (is_array($this->search_result['Modul']) - && count($this->search_result['Modul'])) { + if (isset($this->search_result['Modul']) + && is_array($this->search_result['Modul']) + && count($this->search_result['Modul']) + ) { if (!empty($this->drill_down_type) && !empty($this->drill_down_id)) { $this->search_result['Modul'] = $this->filter_modules( $this->search_result['Modul'], $this->drill_down_type, $this->drill_down_id); diff --git a/app/controllers/search/studiengaenge.php b/app/controllers/search/studiengaenge.php index 94399fc..92d00f6 100644 --- a/app/controllers/search/studiengaenge.php +++ b/app/controllers/search/studiengaenge.php @@ -197,7 +197,7 @@ class Search_StudiengaengeController extends MVVController $this->sessSet('selected_semester', $sem); } - $this->with_courses = Request::option('with_courses', ($_SESSION['MVV_SEARCH_SEQUENCE_WITH_COURSES'] ?: null)); + $this->with_courses = Request::option('with_courses', $_SESSION['MVV_SEARCH_SEQUENCE_WITH_COURSES'] ?? null); $_SESSION['MVV_SEARCH_SEQUENCE_WITH_COURSES'] = $this->with_courses; $studiengangTeil = StudiengangTeil::find($stgteil_id); @@ -230,7 +230,7 @@ class Search_StudiengaengeController extends MVVController } else { $this->active_sem = Semester::find($this->sessGet('selected_semester', Semester::findCurrent()->id)); } - $this->active_sem = $this->semesters[$this->active_sem->id] ? $this->active_sem : null; + $this->active_sem = isset($this->semesters[$this->active_sem->id]) ? $this->active_sem : null; if (!$this->active_sem && count($this->semesters)) { $active_sem = reset($this->semesters); $this->active_sem = Semester::find($active_sem['semester_id']); diff --git a/app/views/blubber/index.php b/app/views/blubber/index.php index 0daceb6..0394805 100644 --- a/app/views/blubber/index.php +++ b/app/views/blubber/index.php @@ -1,7 +1,7 @@
diff --git a/app/views/score/index.php b/app/views/score/index.php index 55c55be..91f352e 100644 --- a/app/views/score/index.php +++ b/app/views/score/index.php @@ -51,7 +51,7 @@ $content = Assets::img('blank.gif', ['width' => 16]) . ' '; // News - if ($news = $person['newscount']) { + if ($news = ($person['newscount'] ?? false)) { $tmp = sprintf(ngettext('Eine persönliche Ankündigung', '%s persönliche Ankündigungen', $news), $news); $content .= sprintf( '%s ', @@ -63,7 +63,7 @@ } // Votes - if ($vote = $person['votecount']) { + if ($vote = ($person['votecount'] ?? false)) { $tmp = sprintf(ngettext('Eine Umfrage', '%s Umfragen', $vote), $vote); $content .= sprintf( '%s ', @@ -75,7 +75,7 @@ } // Termine - if ($termin = $person['eventcount']) { + if ($termin = ($person['eventcount'] ?? false)) { $tmp = sprintf(ngettext('Ein Termin', '%s Termine', $termin), $termin); $content .= sprintf( '%s ', diff --git a/app/views/search/breadcrumb.php b/app/views/search/breadcrumb.php index da6c3717..f4b19d7 100644 --- a/app/views/search/breadcrumb.php +++ b/app/views/search/breadcrumb.php @@ -3,9 +3,9 @@ $point):?> - - link_for('/' . $point['actn'], $point['id'], $id2); ?> - + + link_for('/' . $point['actn'], $point['id'] ?? null, $id2); ?> + getDisplayName() . ' (' . $additional_object->name . ')') ?> @@ -16,7 +16,7 @@ getDisplayName(ModuleManagementModel::DISPLAY_FACH)) ?> - + getDisplayName(0)) ?> diff --git a/app/views/search/module/index.php b/app/views/search/module/index.php index d0b5353..4c56fda 100644 --- a/app/views/search/module/index.php +++ b/app/views/search/module/index.php @@ -13,7 +13,7 @@
- + %s'), htmlReady($sterm)) ?> diff --git a/app/views/search/studiengaenge/verlauf.php b/app/views/search/studiengaenge/verlauf.php index b930696..8917e24 100644 --- a/app/views/search/studiengaenge/verlauf.php +++ b/app/views/search/studiengaenge/verlauf.php @@ -6,7 +6,7 @@
- +

getDisplayName()), htmlReady($studiengang->getDisplayName(ModuleManagementModel::DISPLAY_ABSCHLUSS))) ?> ENABLE_STUDYCOURSE_INFO_PAGE) : ?> diff --git a/lib/classes/BlubberFormat.php b/lib/classes/BlubberFormat.php index 4a52286..b8f2286 100644 --- a/lib/classes/BlubberFormat.php +++ b/lib/classes/BlubberFormat.php @@ -79,9 +79,9 @@ class BlubberFormat extends StudipFormat $this->addMarkup( $name, $rule['start'], - $rule['end'], - $rule['callback'], - $rule['before'] ?: null + $rule['end'] ?? null, + $rule['callback'] ?? null, + $rule['before'] ?? null ); } } diff --git a/lib/classes/BreadCrumb.class.php b/lib/classes/BreadCrumb.class.php index 386da4f..1848df1 100644 --- a/lib/classes/BreadCrumb.class.php +++ b/lib/classes/BreadCrumb.class.php @@ -66,9 +66,11 @@ class BreadCrumb $newTrail = []; $lastElement = false; foreach ($trail as $key => $trail_item) { - if ($lastElement) break; + if ($lastElement) { + break; + } $newTrail[$key] = $trail_item; - $lastElement = $key === $id; + $lastElement = isset($id) && $key === $id; } $this->trail = $newTrail; } diff --git a/lib/classes/Config.class.php b/lib/classes/Config.class.php index f5afaab..b04fc75 100644 --- a/lib/classes/Config.class.php +++ b/lib/classes/Config.class.php @@ -115,7 +115,7 @@ class Config implements ArrayAccess, Countable, IteratorAggregate */ public function getMetadata($field) { - return $this->metadata[$field]; + return $this->metadata[$field] ?? false; } /** diff --git a/lib/classes/MultiPersonSearch.class.php b/lib/classes/MultiPersonSearch.class.php index 65cad48..3ac408e 100644 --- a/lib/classes/MultiPersonSearch.class.php +++ b/lib/classes/MultiPersonSearch.class.php @@ -83,7 +83,7 @@ class MultiPersonSearch { * @return array containing all new persons */ public function getAddedUsers() { - return $_SESSION['multipersonsearch'][$this->name]['added'] ? : []; + return $_SESSION['multipersonsearch'][$this->name]['added'] ?? []; } /** diff --git a/lib/classes/RangeConfig.class.php b/lib/classes/RangeConfig.class.php index fc90434..a1e1bb9 100644 --- a/lib/classes/RangeConfig.class.php +++ b/lib/classes/RangeConfig.class.php @@ -175,7 +175,7 @@ class RangeConfig extends Config // Otherwise convert it to an appropriate format and store it $metadata = Config::get()->getMetadata($field); - $entry->value = $this->convertForDatabase($metadata['type'], $value, $field); + $entry->value = $this->convertForDatabase($metadata['type'] ?? 'string', $value, $field); $ret = $entry->store(); if ($ret) { diff --git a/lib/classes/SQLQuery.php b/lib/classes/SQLQuery.php index a6539fb..2904fc1 100755 --- a/lib/classes/SQLQuery.php +++ b/lib/classes/SQLQuery.php @@ -95,12 +95,12 @@ class SQLQuery unset($this->settings['where'][$name]); } elseif ($parameter === null && $condition !== null) { $this->settings['where'][$name] = $name; - $this->settings['parameter'] = array_merge((array) $this->settings['parameter'], $condition); + $this->settings['parameter'] = array_merge((array) ($this->settings['parameter'] ?? []), $condition); } elseif ($condition === null) { $this->settings['where'][md5($name)] = $name; } else { $this->settings['where'][$name] = $condition; - $this->settings['parameter'] = array_merge((array) $this->settings['parameter'], $parameter); + $this->settings['parameter'] = array_merge((array) ($this->settings['parameter'] ?? []), $parameter); } return $this; } @@ -218,7 +218,7 @@ class SQLQuery $sql = "SELECT `{$this->settings['table']}`.* "; } - foreach ((array) $this->settings['select'] as $alias => $statement) { + foreach ((array) ($this->settings['select'] ?? []) as $alias => $statement) { $sql .= $statement ? "{$statement} AS {$alias} " : $alias; } @@ -268,25 +268,27 @@ class SQLQuery protected function getQuery() { $sql = "FROM `{$this->settings['table']}` "; + if (isset($this->settings['joins']) && is_array($this->settings['joins'])) { foreach ($this->settings['joins'] as $alias => $joindata) { $table = isset($joindata['table']) ? "{$joindata['table']} AS {$alias}" : $alias; $on = isset($joindata['on']) ? " ON ({$joindata['on']})" : ''; - $sql .= " " . (isset($joindata['join']) ? $joindata['join'] : 'INNER JOIN') . " {$table}{$on} "; + $sql .= " " . ($joindata['join'] ?? 'INNER JOIN') . " {$table}{$on} "; + } } - if ($this->settings['where']) { + if (isset($this->settings['where'])) { $sql .= "WHERE (" . implode(") AND (", $this->settings['where']) . ") "; } - if ($this->settings['groupby']) { + if (isset($this->settings['groupby'])) { $sql .= "GROUP BY {$this->settings['groupby']} "; } - if ($this->settings['having']) { + if (isset($this->settings['having'])) { $sql .= "HAVING (" . implode(") AND (", $this->settings['having']) . ") "; } - if ($this->settings['order']) { + if (isset($this->settings['order'])) { $sql .= "ORDER BY {$this->settings['order']} "; } - if ($this->settings['limit']) { + if (isset($this->settings['limit']) && is_array($this->settings['limit'])) { $sql .= "LIMIT ". (int) $this->settings['limit'][0] . ", " . (int) $this->settings['limit'][1] . " "; } return $sql; diff --git a/lib/classes/Score.class.php b/lib/classes/Score.class.php index 515484b..3376a36 100644 --- a/lib/classes/Score.class.php +++ b/lib/classes/Score.class.php @@ -166,11 +166,11 @@ class Score $statements = []; foreach (self::getActivityTables() as $table) { $statements[] = "SELECT " - . ($table['date_column'] ?: 'mkdate') + . ($table['date_column'] ?? 'mkdate') . " AS mkdate FROM " . $table['table'] . " WHERE " - . ($table['user_id_column'] ?: 'user_id') + . ($table['user_id_column'] ?? 'user_id') . " = :user " . (!empty($table['where']) ? (' AND ' . $table['where']) : ''); } diff --git a/lib/classes/SemClass.class.php b/lib/classes/SemClass.class.php index 6b885f1..bb63a80 100644 --- a/lib/classes/SemClass.class.php +++ b/lib/classes/SemClass.class.php @@ -217,7 +217,7 @@ class SemClass implements ArrayAccess */ public function getModuleMetadata($modulename) { - return $this->data['modules'][$modulename]; + return $this->data['modules'][$modulename] ?? false; } /** @@ -310,8 +310,8 @@ class SemClass implements ArrayAccess public function isModuleAllowed($modulename) { return !isset($this->data['modules'][$modulename]) - || !$this->data['modules'][$modulename]['sticky'] - || $this->data['modules'][$modulename]['activated']; + || empty($this->data['modules'][$modulename]['sticky']) + || !empty($this->data['modules'][$modulename]['activated']); } /** @@ -322,8 +322,8 @@ class SemClass implements ArrayAccess public function isModuleMandatory($module) { return isset($this->data['modules'][$module]) - && $this->data['modules'][$module]['sticky'] - && $this->data['modules'][$module]['activated']; + && !empty($this->data['modules'][$module]['sticky']) + && !empty($this->data['modules'][$module]['activated']); } public function getSemTypes() diff --git a/lib/classes/StudipCoreFormat.php b/lib/classes/StudipCoreFormat.php index 665bb37..e82670f 100644 --- a/lib/classes/StudipCoreFormat.php +++ b/lib/classes/StudipCoreFormat.php @@ -526,10 +526,10 @@ class StudipCoreFormat extends TextFormat */ protected static function markupMedia($markup, $matches) { - $tag = $matches[1]; - $params = explode(":",$matches[2]); - $url = $matches[3]; - $whitespace = $matches[4]; + $tag = $matches[1] ?? null; + $params = explode(':', $matches[2] ?? ''); + $url = $matches[3] ?? null; + $whitespace = $matches[4] ?? null; foreach ($params as $key => $param) { if ($param) { @@ -556,6 +556,8 @@ class StudipCoreFormat extends TextFormat $url = TransformInternalLinks($url); $pu = @parse_url($url); + $pu['first_target'] = false; + $intern = false; if (($pu['scheme'] == 'http' || $pu['scheme'] == 'https') && ($pu['host'] == $_SERVER['HTTP_HOST'] || $pu['host'].':'.$pu['port'] == $_SERVER['HTTP_HOST']) && mb_strpos($pu['path'], $GLOBALS['CANONICAL_RELATIVE_PATH_STUDIP']) === 0) { @@ -563,8 +565,6 @@ class StudipCoreFormat extends TextFormat $checkpath = urldecode(mb_substr($pu['path'], mb_strlen($GLOBALS['CANONICAL_RELATIVE_PATH_STUDIP']))); if (mb_strpos($checkpath, '../') === false) { list($pu['first_target']) = explode('/', $checkpath); - } else { - $pu['first_target'] = false; } } $LOAD_EXTERNAL_MEDIA = Config::GetInstance()->getValue('LOAD_EXTERNAL_MEDIA'); @@ -598,8 +598,8 @@ class StudipCoreFormat extends TextFormat $media = sprintf($format_strings[$tag], $media_url, isset($width) ? "width: ".$width."px;" : "", - $title, - $title + $title ?? '', + $title ?? '' ); } @@ -608,14 +608,14 @@ class StudipCoreFormat extends TextFormat $media = str_replace('