diff options
| author | Jan-Hendrik Willms <tleilax+github@gmail.com> | 2022-02-03 14:13:06 +0100 |
|---|---|---|
| committer | Moritz Strohm <strohm@data-quest.de> | 2022-04-12 15:44:24 +0000 |
| commit | 9b7bae8c79ccb90e7cc6508f85bd30dfc9aef120 (patch) | |
| tree | 623d33fb731d97292209350a02c5f92db383bef3 | |
| parent | 07f7c722f182e180115d3dabfb92554dc6532ca2 (diff) | |
transfer changeset 59563 from svn
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 .= "<a href=\"#letter_{$letter}\">{$letter}</a>"; } else { $html .= "<span>{$letter}</span>"; 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 <em>%s</em>', - '%s Module gefunden für die Suche nach <em>%s</em>', - 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 <em>%s</em>', + '%s Module gefunden für die Suche nach <em>%s</em>', + 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 @@ <div class="blubber_panel" data-active_thread="<?= htmlReady($thread->getId()) ?>" data-thread_data="<?= htmlReady(json_encode($thread_data ?: ['thread_posting' => []])) ?>" - data-threads_more_down="<?= htmlReady($threads_more_down) ?>" + data-threads_more_down="<?= htmlReady($threads_more_down ?? '') ?>" :class="waiting ? 'waiting' : ''"> <div id="blubber_stream_container"> 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( '<a href="%s">%s</a> ', @@ -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( '<a href="%s">%s</a> ', @@ -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( '<a href="%s">%s</a> ', 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 @@ <? $sum_points = count($bc_points) - 1; ?> <? $index = 0; ?> <? foreach($bc_points as $type => $point):?> - <? $id2 = reset(array_values((array) $point['add'])); ?> - <? $link = $controller->link_for('/' . $point['actn'], $point['id'], $id2); ?> - <? if (is_array($point['add'])) : ?> + <? $id2 = isset($point['add']) ? reset(array_values((array) $point['add'])) : null; ?> + <? $link = $controller->link_for('/' . $point['actn'], $point['id'] ?? null, $id2); ?> + <? if (isset($point['add']) && is_array($point['add'])) : ?> <? $mvv_object = $type::find($point['id']); ?> <? if ($mvv_object && $type == 'Fach' && $additional_object = Abschluss::find($point['add']['Abschluss'])) : ?> <a href="<?= $link ?>"><?= htmlReady($mvv_object->getDisplayName() . ' (' . $additional_object->name . ')') ?></a> @@ -16,7 +16,7 @@ <? else : ?> <? if ($type == 'StudiengangTeil' && $mvv_object = $type::find($point['id'])) : ?> <a href="<?= $link ?>"><?= htmlReady($mvv_object->getDisplayName(ModuleManagementModel::DISPLAY_FACH)) ?></a> - <? elseif ($point['id'] && $mvv_object = $type::find($point['id'])) : ?> + <? elseif (!empty($point['id']) && $mvv_object = $type::find($point['id'])) : ?> <a href="<?= $link ?>"><?= htmlReady($mvv_object->getDisplayName(0)) ?></a> <? else : ?> <a href="<?= $link ?>"><?= htmlReady($point['name']) ?></a> 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 @@ <!-- Trefferset --> <table class="default collapsable"> <caption> - <? if ($count) : ?> + <? if (isset($count)) : ?> <?= sprintf(_('Gefundene Module für <i>%s</i>'), htmlReady($sterm)) ?> <span class="actions"> <? printf(ngettext('%s Modul', '%s Module', $count), $count); ?> 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 @@ <table class="mvv-modul-details default nohover"> <caption> <?= htmlReady($studiengangTeilName) ?> - <? if ($studiengang && $stgTeilBez) : ?> + <? if ($studiengang && !empty($stgTeilBez)) : ?> <h3> <?= sprintf(_('%s im Studiengang %s'), htmlReady($stgTeilBez->getDisplayName()), htmlReady($studiengang->getDisplayName(ModuleManagementModel::DISPLAY_ABSCHLUSS))) ?> <? if (Config::get()->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('<audio ', '<audio id="' . $random_id . '" onerror="STUDIP.Audio.handle(this);" ', $media); } - if ($link && $tag === "img") { + if (isset($link) && $tag === "img") { $media = sprintf('<a href="%s"%s>%s</a>', $link, !isLinkIntern($link) ? ' target="_blank" rel="noreferrer noopener"' : "", $media ); } - if ($position) { + if (isset($position)) { $media = '<div style="text-align: '.$position.'">'.$media.'</div>'; } $media .= $whitespace; diff --git a/lib/classes/StudipRangeTree.class.php b/lib/classes/StudipRangeTree.class.php index 2dea8a0..fb22614 100644 --- a/lib/classes/StudipRangeTree.class.php +++ b/lib/classes/StudipRangeTree.class.php @@ -42,6 +42,8 @@ class StudipRangeTree extends TreeAbstract { var $sem_dates; + protected $entries_init_done = false; + /** * constructor * @@ -186,9 +188,12 @@ class StudipRangeTree extends TreeAbstract { } function getNumEntries($item_id, $num_entries_from_kids = false){ - if (!$this->tree_data[$item_id]) + if (!$this->tree_data[$item_id]) { return false; - if (!$this->entries_init_done) $this->initEntries(); + } + if (!$this->entries_init_done) { + $this->initEntries(); + } return parent::getNumEntries($item_id, $num_entries_from_kids); } diff --git a/lib/classes/TreeAbstract.class.php b/lib/classes/TreeAbstract.class.php index a23c494..846d27d 100644 --- a/lib/classes/TreeAbstract.class.php +++ b/lib/classes/TreeAbstract.class.php @@ -206,7 +206,10 @@ class TreeAbstract { */ public function getKids($item_id) { - return (is_array($this->tree_childs[$item_id])) ? $this->tree_childs[$item_id] : null; + if (!isset($this->tree_childs[$item_id]) || !is_array($this->tree_childs[$item_id])) { + return null; + } + return $this->tree_childs[$item_id]; } /** @@ -219,7 +222,7 @@ class TreeAbstract { public function getNumKids($item_id) { if(!isset($this->tree_num_childs[$item_id])){ - $this->tree_num_childs[$item_id] = (is_array($this->tree_childs[$item_id])) ? count($this->tree_childs[$item_id]) : 0; + $this->tree_num_childs[$item_id] = count($this->getKids($item_id) ?? []); } return $this->tree_num_childs[$item_id]; } diff --git a/lib/classes/calendar/CalendarScheduleModel.php b/lib/classes/calendar/CalendarScheduleModel.php index 20f66c5..b3f8db6 100644 --- a/lib/classes/calendar/CalendarScheduleModel.php +++ b/lib/classes/calendar/CalendarScheduleModel.php @@ -221,13 +221,13 @@ class CalendarScheduleModel $details = $stmt->fetch(); if ($entry['type'] == 'virtual') { - $entry['color'] = $details['color'] ? $details['color'] : DEFAULT_COLOR_VIRTUAL; + $entry['color'] = ($details && $details['color']) ? $details['color'] : DEFAULT_COLOR_VIRTUAL; $entry['icons'][] = [ 'image' => 'virtual.png', 'title' => _("Dies ist eine vorgemerkte Veranstaltung") ]; } else { - $entry['color'] = $details['color'] ?: ($member->gruppe % 9 + 1); + $entry['color'] = ($details && $details['color']) ? $details['color'] : ($member->gruppe % 9 + 1); } $entry['visible'] = $details ? $details['visible'] : 1; @@ -789,7 +789,7 @@ class CalendarScheduleModel $view = new CalendarWeekView($entries, 'schedule'); - $view->setHeight(40 + (20 * $schedule_settings['zoom'])); + $view->setHeight(40 + 20 * ($schedule_settings['zoom'] ?? 0)); $view->setRange($schedule_settings['glb_start_time'], $schedule_settings['glb_end_time']); $view->setInsertFunction("function (entry, column, hour, end_hour) { STUDIP.Schedule.newEntry(entry, column, hour, end_hour) diff --git a/lib/models/BlubberThread.php b/lib/models/BlubberThread.php index 0be5cd2..e473717 100644 --- a/lib/models/BlubberThread.php +++ b/lib/models/BlubberThread.php @@ -48,7 +48,7 @@ class BlubberThread extends SimpleORMap implements PrivacyObject } public static $mention_thread_id = null; - protected $last_visit = null; + protected $last_visit = []; /** * Pre-Markup rule. Recognizes mentions in blubber as @username or @"Firstname lastname" @@ -921,9 +921,8 @@ class BlubberThread extends SimpleORMap implements PrivacyObject 'user_id' => $user_id, 'html_id' => "blubberthread_".$this->getId() ]); - $this->last_visit[$user_id] = !$this->last_visit[$user_id] - ? object_get_visit($this->getId(), "blubberthread", "last", "", $user_id) - : $this->last_visit[$user_id]; + $this->last_visit[$user_id] = $this->last_visit[$user_id] + ?? object_get_visit($this->getId(), 'blubberthread', 'last', '', $user_id); UserConfig::get($user_id)->store("BLUBBERTHREAD_VISITED_".$this->getId(), time()); } @@ -955,7 +954,13 @@ class BlubberThread extends SimpleORMap implements PrivacyObject } foreach ($matches[1] as $tag) { - $hashtags[mb_strtolower($tag)] += 1; + $tag = mb_strtolower($tag); + + if (!isset($hashtags[$tag])) { + $hashtags[$tag] = 0; + } + + $hashtags[$tag] += 1; } } asort($hashtags); diff --git a/lib/models/SimpleCollection.class.php b/lib/models/SimpleCollection.class.php index 4d98087..f001106 100644 --- a/lib/models/SimpleCollection.class.php +++ b/lib/models/SimpleCollection.class.php @@ -684,7 +684,7 @@ class SimpleCollection extends StudipArrayObject $func = function ($d1, $d2) use ($sorter, $sort_func, $sort_locale) { do { - list($field, $dir) = current($sorter); + @list($field, $dir) = current($sorter); if (!$sort_locale) { $value1 = $d1[$field]; $value2 = $d2[$field]; @@ -693,7 +693,9 @@ class SimpleCollection extends StudipArrayObject $value2 = static::translitLatin1(mb_substr($d2[$field], 0, 100)); } $ret = $sort_func($value1, $value2); - if (strtolower($dir) == 'desc') $ret = $ret * -1; + if (strtolower($dir) === 'desc') { + $ret = $ret * -1; + } } while ($ret === 0 && next($sorter)); return $ret; diff --git a/lib/models/SimpleORMap.class.php b/lib/models/SimpleORMap.class.php index 75df771..7245490 100644 --- a/lib/models/SimpleORMap.class.php +++ b/lib/models/SimpleORMap.class.php @@ -822,6 +822,7 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate */ public static function __callStatic($name, $arguments) { + $order = ''; $db_table = static::config('db_table'); $alias_fields = static::config('alias_fields'); $db_fields = static::config('db_fields'); @@ -1036,17 +1037,17 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate } if ($type === 'has_and_belongs_to_many') { $thru_table = $options['thru_table']; - if (!$options['thru_key']) { + if (!isset($options['thru_key'])) { $options['thru_key'] = $this->pk[0]; } - if (!$options['thru_assoc_key'] || !$options['assoc_foreign_key']) { + if (!isset($options['thru_assoc_key']) || !isset($options['assoc_foreign_key'])) { $class = $options['class_name']; $record = new $class(); $meta = $record->getTableMetadata(); - if (!$options['thru_assoc_key'] ) { + if (!isset($options['thru_assoc_key'])) { $options['thru_assoc_key'] = $meta['pk'][0]; } - if (!$options['assoc_foreign_key']) { + if (!isset($options['assoc_foreign_key'])) { $options['assoc_foreign_key']= $meta['pk'][0]; } } @@ -1818,6 +1819,7 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate if ($this->applyCallbacks('before_store') === false) { return false; } + $ret = 0; if (!$this->isDeleted() && ($this->isDirty() || $this->isNew())) { if ($this->isNew()) { if ($this->applyCallbacks('before_create') === false) { @@ -2142,7 +2144,7 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate } else { $p = (array)$params($this); $records = call_user_func_array($to_call, count($p) ? $p : [null]); - $result = is_array($records) ? $records[0] : $records; + $result = is_array($records) ? ($records[0] ?? null) : $records; $this->relations[$relation] = $result; } } diff --git a/lib/models/resources/Room.class.php b/lib/models/resources/Room.class.php index e5960db..59c06fd 100644 --- a/lib/models/resources/Room.class.php +++ b/lib/models/resources/Room.class.php @@ -40,7 +40,7 @@ class Room extends Resource protected static function configure($config = []) { - if (!is_array($config['additional_fields'])) { + if (!isset($config['additional_fields']) || !is_array($config['additional_fields'])) { $config['additional_fields'] = []; } foreach (self::$required_properties as $property) { diff --git a/lib/object.inc.php b/lib/object.inc.php index f7bcf90..c0c4e15 100644 --- a/lib/object.inc.php +++ b/lib/object.inc.php @@ -104,7 +104,7 @@ function object_get_visit($object_id, $plugin_id, $mode = "last", $open_object_i $cache[$object_id][$plugin_id][$user_id] = null; } - if ($cache[$object_id][$plugin_id][$user_id]) { + if (isset($cache[$object_id][$plugin_id][$user_id])) { return $mode == 'last' ? $cache[$object_id][$plugin_id][$user_id]['last_visitdate'] : $cache[$object_id][$plugin_id][$user_id]['visitdate']; diff --git a/lib/user_visible.inc.php b/lib/user_visible.inc.php index cf0da1c..c7b07f0 100644 --- a/lib/user_visible.inc.php +++ b/lib/user_visible.inc.php @@ -119,6 +119,8 @@ function get_vis_query($table_alias = 'auth_user_md5', $context = '') { $context_default = (int) Config::get()->getValue(mb_strtoupper($context) . '_VISIBILITY_DEFAULT'); $contextQuery = " AND (IFNULL(user_visibility.{$context}, {$context_default}) = 1 OR {$table_alias}.visible = 'always')"; + } else { + $contextQuery = ''; } $my_domains = UserDomain::getUserDomainsForUser($GLOBALS['user']->id); diff --git a/lib/visual.inc.php b/lib/visual.inc.php index e6a66b5..4dc1127 100644 --- a/lib/visual.inc.php +++ b/lib/visual.inc.php @@ -311,9 +311,9 @@ function isLinkIntern($url) { return true; } - return in_array($pum['scheme'], ['https', 'http', NULL], true) - && in_array($pum['host'], [$_SERVER['SERVER_NAME'], NULL], true) - && in_array($pum['port'], [$_SERVER['SERVER_PORT'], NULL], true) + return in_array($pum['scheme'] ?? null, ['https', 'http', null], true) + && in_array($pum['host'] ?? null, [$_SERVER['SERVER_NAME'], null], true) + && in_array($pum['port'] ?? null, [$_SERVER['SERVER_PORT'], null], true) && mb_strpos($pum['path'], $GLOBALS['CANONICAL_RELATIVE_PATH_STUDIP']) === 0; } |
