diff --git a/app/controllers/admin/courses.php b/app/controllers/admin/courses.php index b0bf9cd8cd493afcd0ab1a8ebb1041f4848aa772..7835fe5f46babf6e1272b84c9916440b2fb43d52 100644 --- a/app/controllers/admin/courses.php +++ b/app/controllers/admin/courses.php @@ -43,7 +43,7 @@ class Admin_CoursesController extends AuthenticatedController { //first get the active datafields of the user: $userSelectedElements = $this->getActiveElements(); - $activeDatafields = $userSelectedElements['datafields']; + $activeDatafields = $userSelectedElements['datafields'] ?? []; if (!$activeDatafields) { return []; @@ -189,7 +189,7 @@ class Admin_CoursesController extends AuthenticatedController } //if there are datafields in the list, draw their input fields, too: - if ($visibleElements['datafields']) { + if (!empty($visibleElements['datafields'])) { //The datafields entry contains an array with datafield-IDs. //We must fetch them from the database and show an appropriate widget //for each datafield. @@ -1190,7 +1190,7 @@ class Admin_CoursesController extends AuthenticatedController $filter->where("sem_classes.studygroup_mode = '0'"); // Get only children of given course - if ($params['parent_course']) { + if (!empty($params['parent_course'])) { $filter->where("parent_course = :parent", [ 'parent' => $params['parent_course'] @@ -1235,10 +1235,10 @@ class Admin_CoursesController extends AuthenticatedController return []; } - $seminars = array_map('reset', $courses); - - if (!empty($seminars)) { - foreach ($seminars as $seminar_id => $seminar) { + $seminars = []; + if (!empty($courses)) { + foreach ($courses as $seminar_id => $seminar) { + $seminars[$seminar_id] = $seminar[0]; $seminars[$seminar_id]['seminar_id'] = $seminar_id; $seminars[$seminar_id]['obj_type'] = 'sem'; $dozenten = $this->getTeacher($seminar_id); @@ -1253,7 +1253,7 @@ class Admin_CoursesController extends AuthenticatedController $seminars[$seminar_id]['navigation'] = MyRealmModel::getAdditionalNavigations( $seminar_id, $seminars[$seminar_id], - $seminars[$seminar_id]['sem_class'], + $seminars[$seminar_id]['sem_class'] ?? null, $GLOBALS['user']->id, $visit_data[$seminar_id] ); @@ -1264,8 +1264,8 @@ class Admin_CoursesController extends AuthenticatedController } if ((int)$this->selected_action === 17) { $seminars[$seminar_id]['admission_locked'] = false; - if ($seminar['course_set']) { - $set = new CourseSet($seminar['course_set']); + if ($seminar[0]['course_set']) { + $set = new CourseSet($seminar[0]['course_set']); if (!is_null($set) && $set->hasAdmissionRule('LockedAdmission')) { $seminars[$seminar_id]['admission_locked'] = 'locked'; } else { diff --git a/app/controllers/my_courses.php b/app/controllers/my_courses.php index 395bef9b02a873ba809cfc4100838769354dd315..45ca5de5f2692c6ec336723bb84d948fc010394c 100644 --- a/app/controllers/my_courses.php +++ b/app/controllers/my_courses.php @@ -122,7 +122,7 @@ class MyCoursesController extends AuthenticatedController foreach ($_outer as $course) { $_courses[$course['seminar_id']] = $course; - if ($course['children']) { + if (!empty($course['children']) && is_array($course['children'])) { foreach ($course['children'] as $child) { $_courses[$child['seminar_id']] = $child; } @@ -722,12 +722,12 @@ class MyCoursesController extends AuthenticatedController */ public function check_course($seminar_content) { - - if ($seminar_content['visitdate'] <= $seminar_content['chdate'] || $seminar_content['last_modified'] > 0) { + $last_modified_timestamp = $seminar_content['last_modified'] ?? 0; + if ($seminar_content['visitdate'] <= $seminar_content['chdate'] || $last_modified_timestamp > 0) { $last_modified = $seminar_content['visitdate'] <= $seminar_content['chdate'] - && $seminar_content['chdate'] > $seminar_content['last_modified'] + && $seminar_content['chdate'] > $last_modified_timestamp ? $seminar_content['chdate'] - : $seminar_content['last_modified']; + : $last_modified_timestamp; if ($last_modified) { return true; } @@ -994,7 +994,7 @@ class MyCoursesController extends AuthenticatedController } else { $attr = $n->getLinkAttributes(); if (empty($attr['title']) && $n->getImage()) { - $attr['title'] = (string) $n->getImage()->getAttributes()['title']; + $attr['title'] = (string) ($n->getImage()->getAttributes()['title'] ?? ''); } if (empty($attr['title'])) { $attr['title'] = (string) $n->getTitle(); diff --git a/app/controllers/plugin_controller.php b/app/controllers/plugin_controller.php index 445f22e2b3e8fbecac9a60065b4cc0aa27bd231f..c18874ed493debca2d4a7daaff89f1ea777d47f3 100644 --- a/app/controllers/plugin_controller.php +++ b/app/controllers/plugin_controller.php @@ -19,7 +19,6 @@ class PluginController extends StudipController } $this->plugin = $dispatcher->current_plugin; - if ($this->plugin && $this->plugin->hasTranslation()) { // Localization $this->_ = function ($string) { diff --git a/app/controllers/studip_controller.php b/app/controllers/studip_controller.php index cad182ae55af9e86a4ff04452ac9c72f6a409a57..cddb82e5035afba2d893decdb5d060c1ea09e763 100644 --- a/app/controllers/studip_controller.php +++ b/app/controllers/studip_controller.php @@ -753,7 +753,7 @@ abstract class StudipController extends Trails_Controller */ protected function controller_path() { - $class = get_class($this->parent_controller ?: $this); + $class = get_class($this->parent_controller ?? $this); $controller = mb_substr($class, 0, -mb_strlen('Controller')); $controller = strtosnakecase($controller); return preg_replace('/_{2,}/', '/', $controller); diff --git a/app/views/admin/courses/_course.php b/app/views/admin/courses/_course.php index 9632aaa98fff7d61f32275f3d96776dbf0acd058..525e151ed3f5bfce2d339de8c0c855c437886eb9 100644 --- a/app/views/admin/courses/_course.php +++ b/app/views/admin/courses/_course.php @@ -204,9 +204,11 @@ if (!$values['parent_course'] || !in_array($values['parent_course'], array_keys( <?= \Studip\LinkButton::create( $actions[$selected_action]['title'], - URLHelper::getURL(sprintf($actions[$selected_action]['url'], $semid), - ($actions[$selected_action]['params'] ? $actions[$selected_action]['params'] : [])), - ($actions[$selected_action]['attributes'] ? $actions[$selected_action]['attributes'] : []) + URLHelper::getURL( + sprintf($actions[$selected_action]['url'], $semid), + $actions[$selected_action]['params'] ?? [] + ), + $actions[$selected_action]['attributes'] ?? [] ) ?> <? endif ?> <? endif ?> diff --git a/app/views/admin/courses/courses.php b/app/views/admin/courses/courses.php index fab169db660c1441f76fa715352c5f398b8db961..ee5ce7e09db616835abb84449f7f53c801ccfa38 100644 --- a/app/views/admin/courses/courses.php +++ b/app/views/admin/courses/courses.php @@ -1,5 +1,5 @@ <? $colspan = 2 ?> -<? if ($actions[$selected_action]['multimode']) : ?> +<? if (!empty($actions[$selected_action]['multimode'])) : ?> <form action="<?= URLHelper::getLink($actions[$selected_action]['url']) ?>" method="post"> <? endif ?> <?= CSRFProtection::tokenTag() ?> @@ -197,7 +197,7 @@ <?= _('Aktion') ?> </th> </tr> - <? if ($actions[$selected_action]['multimode']) : ?> + <? if (!empty($actions[$selected_action]['multimode'])) : ?> <?= $this->render_partial('admin/courses/additional_inputs.php', compact('colspan')) ?> <? if (count($courses) > 10): ?> <tr> @@ -219,10 +219,20 @@ </thead> <tbody> <? foreach ($courses as $semid => $values) : ?> - <?= $this->render_partial('admin/courses/_course', compact('semid', 'values', 'view_filter', 'actions', 'selected_action', 'courses')) ?> + <?= $this->render_partial('admin/courses/_course', + [ + 'semid' => $semid, + 'values' => $values, + 'view_filter' => $view_filter, + 'actions' => $actions, + 'selected_action' => $selected_action, + 'courses' => $courses, + 'parent' => $parent ?? null + ] + ) ?> <? endforeach ?> </tbody> -<? if ($actions[$selected_action]['multimode']) : ?> +<? if (!empty($actions[$selected_action]['multimode'])) : ?> <tfoot> <tr> <td colspan="<?= $colspan ?>" style="text-align: right"> @@ -241,6 +251,6 @@ </tfoot> <? endif ?> </table> -<? if ($actions[$selected_action]['multimode']) : ?> +<? if (!empty($actions[$selected_action]['multimode'])) : ?> </form> <? endif ?> diff --git a/app/views/my_courses/_dozent.php b/app/views/my_courses/_dozent.php index cb7bf9014d151cba10bae102dea06e927a715442..05b5f524ef41da7946973372f412db8fa07bdfc6 100644 --- a/app/views/my_courses/_dozent.php +++ b/app/views/my_courses/_dozent.php @@ -1,4 +1,4 @@ <? # Lifter010: TODO ?> -<?= $colon ? ', ' : '' ?><a href="<?= URLHelper::getLink('dispatch.php/profile', ['username' => $_dozent['username']]) ?>"><?= htmlReady($_dozent["fullname"]) ?></a><? $this->colon = true; ?> +<?= !empty($colon) ? ', ' : '' ?><a href="<?= URLHelper::getLink('dispatch.php/profile', ['username' => $_dozent['username']]) ?>"><?= htmlReady($_dozent['fullname']) ?></a><? $this->colon = true; ?> diff --git a/app/views/my_studygroups/_course.php b/app/views/my_studygroups/_course.php index 12442475ce68ae5dde4ac4512b296464c66f9862..e3855c4c33b17ef6a29da9f1f4a846acd80113c5 100644 --- a/app/views/my_studygroups/_course.php +++ b/app/views/my_studygroups/_course.php @@ -7,7 +7,7 @@ </td> <td style="text-align: left"> <a href="<?= URLHelper::getLink('seminar_main.php', ['auswahl' => $group['seminar_id']]) ?>" - <?= $group['lastvisitdate'] >= $group['chdate'] ? 'style="color: red;"' : '' ?>> + <?= $group['last_visitdate'] >= $group['chdate'] ? 'style="color: red;"' : '' ?>> <?= htmlReady($group['name']) ?> </a> <? if ($group['visible'] == 0) : ?> diff --git a/lib/classes/AdminCourseFilter.class.php b/lib/classes/AdminCourseFilter.class.php index cd9bfacfe27d46884915ddd6e46a08b442cb8ba0..ee4982c639292c90ab7b1afe7dd686dbaa666e97 100644 --- a/lib/classes/AdminCourseFilter.class.php +++ b/lib/classes/AdminCourseFilter.class.php @@ -344,7 +344,7 @@ class AdminCourseFilter $id = md5($where); } $this->settings['query']['where'][$id] = $where; - $this->settings['parameter'] = array_merge((array) $this->settings['parameter'], $parameter); + $this->settings['parameter'] = array_merge((array)($this->settings['parameter'] ?? []), $parameter); return $this; } diff --git a/lib/classes/MyRealmModel.php b/lib/classes/MyRealmModel.php index a68a0c1ac5ff6b2055fdfe894cff1f606aeab738..9f62b427cb2e12faf682fb0dc69e6f2ae290385c 100644 --- a/lib/classes/MyRealmModel.php +++ b/lib/classes/MyRealmModel.php @@ -171,7 +171,7 @@ class MyRealmModel $semester_ids = []; for ($i = $min_sem_key; $i <= $max_sem_key; $i++) { - if ($sem_data[$i]['semester_id']) { + if (!empty($sem_data[$i]['semester_id'])) { $semester_ids[] = $sem_data[$i]['semester_id']; } } @@ -364,7 +364,7 @@ class MyRealmModel // add the the course to the correct semester - if (!$_course['parent_course']) { + if (empty($_course['parent_course'])) { if ($course->isOpenEnded()) { if ($current_semester_nr >= $min_sem_key && $current_semester_nr <= $max_sem_key) { $sem_courses[$current_semester_nr][$course->id] = $_course; @@ -395,7 +395,7 @@ class MyRealmModel return null; } - if ($params['main_navigation']) { + if (!empty($params['main_navigation'])) { return $sem_courses; } @@ -805,7 +805,7 @@ class MyRealmModel $data['tools'] = $studygroup->tools; $data['sem_class'] = $studygroup->getSemClass(); $data['start_semester'] = $studygroup->start_semester->name; - $data['end_semester'] = $studygroup->end_semester->name; + $data['end_semester'] = $studygroup->end_semester->name ?? ''; $data['obj_type'] = 'sem'; $data['user_status'] = $membership->status; $data['gruppe'] = $membership->gruppe; diff --git a/lib/classes/Request.class.php b/lib/classes/Request.class.php index 71c593e58b7866f59cb68ab5496bd82aad40dc0d..22cf29d142dc7fac0c00c966f82637b82f24dd19 100644 --- a/lib/classes/Request.class.php +++ b/lib/classes/Request.class.php @@ -632,7 +632,7 @@ class Request implements ArrayAccess, IteratorAggregate */ public static function method() { - return mb_strtoupper($_SERVER['X_HTTP_METHOD_OVERRIDE'] ?: $_SERVER['REQUEST_METHOD']); + return mb_strtoupper($_SERVER['X_HTTP_METHOD_OVERRIDE'] ?? $_SERVER['REQUEST_METHOD']); } /** diff --git a/lib/classes/SemClass.class.php b/lib/classes/SemClass.class.php index 8f122a3d8947c2347c832fc3b68001a62152f73e..027d29c19391ebfc8e441124f88177e756cacb2f 100644 --- a/lib/classes/SemClass.class.php +++ b/lib/classes/SemClass.class.php @@ -93,7 +93,7 @@ class SemClass implements ArrayAccess foreach ($slots as $slot => $module) { $data[$slot] = $module; - $modules[$module] = ['activated' => (int) $INST_MODULES[$type][$slot], 'sticky' => 0]; + $modules[$module] = ['activated' => (int) ($INST_MODULES[$type][$slot] ?? 0), 'sticky' => 0]; } $data['modules'] = json_encode($modules); @@ -200,7 +200,7 @@ class SemClass implements ArrayAccess */ public function isModuleForbidden($modulename) { - if ($this->data['studygroup_mode']) { + if (!empty($this->data['studygroup_mode'])) { return in_array($modulename, self::$studygroup_forbidden_modules); } else { return strpos($modulename, 'Studygroup') !== false; diff --git a/lib/classes/Seminar.class.php b/lib/classes/Seminar.class.php index 337eea6fe65cc64376e998df28c8ed78c5c85402..00108aa35a2fbeb73c0969b916b499bc3e0a0605 100644 --- a/lib/classes/Seminar.class.php +++ b/lib/classes/Seminar.class.php @@ -72,7 +72,7 @@ class Seminar if ($refresh_cache) { self::$seminar_object_pool[$id] = null; } - if (is_object(self::$seminar_object_pool[$id]) && self::$seminar_object_pool[$id]->getId() == $id) { + if (!empty(self::$seminar_object_pool[$id]) && is_object(self::$seminar_object_pool[$id]) && self::$seminar_object_pool[$id]->getId() == $id) { return self::$seminar_object_pool[$id]; } else { self::$seminar_object_pool[$id] = new Seminar($id); @@ -316,7 +316,7 @@ class Seminar $data = unserialize($cache->read($cache_key)); // build cache from scratch - if (!$data || !$data[$sub_key]) { + if (empty($data) || empty($data[$sub_key])) { $cycles = $this->metadate->getCycleData(); $dates = $this->getSingleDates($filter, $filter); $rooms = []; diff --git a/lib/classes/SeminarCategories.class.php b/lib/classes/SeminarCategories.class.php index fdb955e825a3402bd174ccb88c33ceb3bb36f5ac..5302f1e3dcf0f9c93a051879abb4ee6c8cdf6675 100644 --- a/lib/classes/SeminarCategories.class.php +++ b/lib/classes/SeminarCategories.class.php @@ -45,10 +45,11 @@ class SeminarCategories { * @param String $id * @return Array */ - public static function Get($id){ - if(is_null(self::$seminar_categories[$id])){ + public static function Get($id) + { + if (empty(self::$seminar_categories[$id])) { $cat = new SeminarCategories($id); - if($cat->id !== false) { + if ($cat->id !== false) { self::$seminar_categories[$id] = $cat; } else { self::$seminar_categories[$id] = false; @@ -134,4 +135,4 @@ class SeminarCategories { } } } -?> \ No newline at end of file +?> diff --git a/lib/classes/SkipLinks.php b/lib/classes/SkipLinks.php index c5738b2af6f148c113a9f855167820907a503bf5..684ae424189dcbd8dd93e296a343275c5b49c58c 100644 --- a/lib/classes/SkipLinks.php +++ b/lib/classes/SkipLinks.php @@ -32,7 +32,13 @@ class SkipLinks */ public static function isEnabled() { - return UserConfig::get($GLOBALS['user']->id)->SKIPLINKS_ENABLE; + if (isset($GLOBALS['user']->id)) { + //Use the user configuration: + return UserConfig::get($GLOBALS['user']->id)->SKIPLINKS_ENABLE; + } else { + //Use the global configuration: + return Config::get()->SKIPLINKS_ENABLE; + } } /** diff --git a/lib/classes/WidgetContainer.php b/lib/classes/WidgetContainer.php index 1b0578eb323a614b1897e10ffa5b80f9ae023b5b..39665a9a6cb822df35269563f2cd8df3cc88c71e 100644 --- a/lib/classes/WidgetContainer.php +++ b/lib/classes/WidgetContainer.php @@ -24,7 +24,7 @@ abstract class WidgetContainer public static function Get() { $class = get_called_class(); - if (!isset(static::$instances[$class])) { + if (empty(static::$instances[$class])) { static::$instances[$class] = new static; } return static::$instances[$class]; diff --git a/lib/classes/sidebar/SearchWidget.php b/lib/classes/sidebar/SearchWidget.php index 2b7979e43d80a2580ea0506e5f31b6406b7bf576..626078ef9187e99825d311c48f871a6ec300026e 100644 --- a/lib/classes/sidebar/SearchWidget.php +++ b/lib/classes/sidebar/SearchWidget.php @@ -138,6 +138,8 @@ class SearchWidget extends SidebarWidget } } + $this->template_variables['reset_search'] = ''; + if ($this->hasData()) { // Remove needles from query params for reset link $reset_params = $query_params; diff --git a/lib/classes/sidebar/SelectWidget.php b/lib/classes/sidebar/SelectWidget.php index 789355955dc4d539f8156b68260d8283c4388c21..ce311f698d970804c0c86a06bdedffd95f94fe8d 100644 --- a/lib/classes/sidebar/SelectWidget.php +++ b/lib/classes/sidebar/SelectWidget.php @@ -126,6 +126,9 @@ class SelectWidget extends SidebarWidget //submit-upon-select is not helpful if we have the multiple version if (!$this->template_variables['multiple']) { + if (!array_key_exists('class', $this->template_variables)) { + $this->template_variables['class'] = ''; + } $this->template_variables['class'] .= ' submit-upon-select'; } diff --git a/lib/dates.inc.php b/lib/dates.inc.php index 151cf70ad6874beceb2b9ab36de1c65468f81ac9..e9f08415ab5409c55af432e90e340b71f582be74 100644 --- a/lib/dates.inc.php +++ b/lib/dates.inc.php @@ -207,7 +207,7 @@ function shrink_dates($dates) { if (((date ("z", $dates[$i]["start_time"])-1) == date ("z", $dates[$i-1]["start_time"])) || ((date ("z", $dates[$i]["start_time"]) == 0) && (date ("j", $dates[$i-1]["start_time"]) == 0))) { - if ($dates[$i]["time_match"]) { + if (!empty($dates[$i]["time_match"])) { $dates[$i]["conjuncted"] = true; } } @@ -217,23 +217,24 @@ function shrink_dates($dates) { $return_string = ''; // create text-output for ($i=0; $i < sizeof($dates); $i++) { - if (!$dates[$i]["conjuncted"]) { + $conjuncted = true; + if (empty($dates[$i]["conjuncted"])) { $conjuncted = false; } - if ((!$dates[$i]["conjuncted"]) || (!$dates[$i+1]["conjuncted"])) { + if (empty($dates[$i]["conjuncted"]) || empty($dates[$i+1]["conjuncted"])) { $return_string .= ' ' . strftime('%A', $dates[$i]['start_time']) .'.'; $return_string .= date (" d.m.y", $dates[$i]["start_time"]); } - if ((!$conjuncted) && ($dates[$i+1]["conjuncted"])) { + if (!$conjuncted && !empty($dates[$i+1]["conjuncted"])) { $return_string .= ' -'; $conjuncted = true; - } else if ((!$dates[$i+1]["conjuncted"]) && ($dates[$i+1]["time_match"])) { + } else if (empty($dates[$i+1]["conjuncted"]) && !empty($dates[$i+1]["time_match"])) { $return_string .= ','; } - if (!$dates[$i+1]["time_match"]) { + if (empty($dates[$i+1]["time_match"])) { // check if the current date is for a whole day if ((($dates[$i]["end_time"] - $dates[$i]["start_time"]) / 60 / 60) > 23) { $return_string .= ' ('. _('ganztägig') . ')'; @@ -245,7 +246,7 @@ function shrink_dates($dates) { } } - if ($return_string != '' && !$dates[$i+1]['conjuncted'] && !$dates[$i+1]['time_match']) { + if ($return_string != '' && empty($dates[$i+1]['conjuncted']) && empty($dates[$i+1]['time_match'])) { $ret[] = $return_string; $return_string = ''; } diff --git a/lib/functions.php b/lib/functions.php index a74c8eca46dd71bfc300e81d731439d3d0be025c..812b531e5d7287e3fb28d19f91a8f9cf9dae0488 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -1520,7 +1520,7 @@ function studip_default_exception_handler($exception) { // ajax requests return JSON instead // re-use the http status code determined above - if (!strcasecmp($_SERVER['HTTP_X_REQUESTED_WITH'], 'xmlhttprequest')) { + if (!strcasecmp($_SERVER['HTTP_X_REQUESTED_WITH'] ?? '', 'xmlhttprequest')) { header('Content-Type: application/json; charset=UTF-8'); $template = 'json_exception'; $layout = null; diff --git a/lib/models/Semester.class.php b/lib/models/Semester.class.php index 33b309895d075230b4651c624e2b1eb31939e7bc..10f21ae4352785c1511021ad4d778867dab8228d 100644 --- a/lib/models/Semester.class.php +++ b/lib/models/Semester.class.php @@ -85,7 +85,7 @@ class Semester extends SimpleORMap public static function find($id) { $semester_cache = self::getAll(); - return $semester_cache[$id] ?: null; + return $semester_cache[$id] ?? null; } /** diff --git a/lib/models/SimpleORMap.class.php b/lib/models/SimpleORMap.class.php index 3a28ebd94bb75332e5fbcd43f2127d6d058fa22f..92cdf423af7e2dd9dec5e2a6709b76984566ee2a 100644 --- a/lib/models/SimpleORMap.class.php +++ b/lib/models/SimpleORMap.class.php @@ -218,7 +218,8 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate if (isset($config['additional_fields'])) { foreach ($config['additional_fields'] as $a_field => $a_config) { if (is_array($a_config) && !(isset($a_config['get']) || isset($a_config['set']))) { - list($relation, $relation_field) = $a_config; + $relation = $a_config[0] ?? ''; + $relation_field = $a_config[1] ?? ''; if (!$relation) { list($relation, $relation_field) = explode('_', $a_field); } @@ -620,7 +621,7 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate $record = new $class(); $sql = "SELECT `$db_table`.* FROM `$thru_table` INNER JOIN `$db_table` ON `$thru_table`.`$thru_assoc_key` = `$db_table`.`$assoc_foreign_key` - WHERE `$thru_table`.`$thru_key` = ? " . $options['order_by']; + WHERE `$thru_table`.`$thru_key` = ? " . ($options['order_by'] ?? ''); $db = DBManager::get(); $st = $db->prepare($sql); $st->execute([$foreign_key_value]); @@ -1024,7 +1025,8 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate * @throws Exception if options for thru_table could not be determined * @return array */ - protected function parseRelationOptions($type, $name, $options) { + protected function parseRelationOptions($type, $name, $options) + { if (empty($options['class_name'])) { throw new Exception('Option class_name not set for relation ' . $name); } @@ -1040,14 +1042,14 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate if (!$options['thru_key']) { $options['thru_key'] = $this->pk[0]; } - if (!$options['thru_assoc_key'] || !$options['assoc_foreign_key']) { + if (empty($options['thru_assoc_key']) || empty($options['assoc_foreign_key'])) { $class = $options['class_name']; $record = new $class(); $meta = $record->getTableMetadata(); if (!$options['thru_assoc_key'] ) { $options['thru_assoc_key'] = $meta['pk'][0]; } - if (!$options['assoc_foreign_key']) { + if (empty($options['assoc_foreign_key'])) { $options['assoc_foreign_key']= $meta['pk'][0]; } } @@ -2207,6 +2209,7 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate protected function registerCallback($types, $cb) { $types = is_array($types) ? $types : words($types); + $reg = 0; foreach ($types as $type) { if (isset($this->registered_callbacks[$type])) { $this->registered_callbacks[$type][] = $cb; diff --git a/lib/models/resources/Room.class.php b/lib/models/resources/Room.class.php index f0a54b0628c8b95f61a4b53bb47a1b4d1c682866..d8f2ad4685fbac7142d00d48f4eff0f596852231 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'])) { $config['additional_fields'] = []; } foreach (self::$required_properties as $property) { diff --git a/lib/navigation/BrowseNavigation.php b/lib/navigation/BrowseNavigation.php index 566e9d6a75b5bab032003ce8e766ca97d9e773e9..82b3ac6c282e6b0645d4cd14913667d525b2841c 100644 --- a/lib/navigation/BrowseNavigation.php +++ b/lib/navigation/BrowseNavigation.php @@ -26,6 +26,9 @@ class BrowseNavigation extends Navigation $courselink = null; // check if logged in + $coursetext = ''; + $courseinfo = ''; + $courselink = null; if (is_object($user) && $user->id != 'nobody') { $coursetext = _('Veranstaltungen'); $courseinfo = _('Meine Veranstaltungen & Einrichtungen'); diff --git a/lib/raumzeit/SingleDate.class.php b/lib/raumzeit/SingleDate.class.php index 8159b137e8a1e6fb1644e0380c001c177d2bcc38..c713cc4582ac8788bb044257c2affd1aa3fcd088 100644 --- a/lib/raumzeit/SingleDate.class.php +++ b/lib/raumzeit/SingleDate.class.php @@ -391,8 +391,8 @@ class SingleDate $this->end_time = $daten['end_time']; $this->mkdate = $daten['mkdate']; $this->chdate = $daten ['chdate']; - $this->ex_termin = $daten['ex_termin']; - $this->orig_ex = $daten['ex_termin']; + $this->ex_termin = $daten['ex_termin'] ?? false; + $this->orig_ex = $daten['ex_termin'] ?? false; $this->range_id = $daten['range_id']; $this->author_id = $daten['autor_id']; $this->resource_id = $daten['resource_id']; diff --git a/public/sendfile.php b/public/sendfile.php index 053d46b8d6fdfca625f2dfa5d791ff548df87dc0..5485ca297e69ea590df91c810649d79fb6c275a1 100644 --- a/public/sendfile.php +++ b/public/sendfile.php @@ -150,6 +150,7 @@ switch ($type) { // check if linked file is obtainable +$filesize = 0; if (isset($file_ref) && $file_ref->file->metadata['access_type'] == 'proxy') { $link_data = FileManager::fetchURLMetadata($file_ref->file->metadata['url']); if ($link_data['response_code'] != 200) { @@ -244,7 +245,7 @@ if ($filesize && $file_ref->file->filetype !== 'URLFile') { header("Expires: Mon, 12 Dec 2001 08:00:00 GMT"); header("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT"); -if ($_SERVER['HTTPS'] == "on"){ +if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') { header("Pragma: public"); header("Cache-Control: private"); } else { diff --git a/templates/dates/_seminar_rooms.php b/templates/dates/_seminar_rooms.php index 58d940aabccb41dc02a9a940d0d112ef9ff4f38b..c10fa453e4447f67cdc1823cc1389ab632be6905 100644 --- a/templates/dates/_seminar_rooms.php +++ b/templates/dates/_seminar_rooms.php @@ -8,6 +8,7 @@ $hide_empty = $hide_empty ?? false; $limit = $limit ?? 3; $assigned = $assigned ?: []; $freetext = $freetext ?: []; +$plain = $plain ?? false; if ($assigned || $freetext) { if ($assigned) { diff --git a/templates/dates/seminar_export.php b/templates/dates/seminar_export.php index 944e02cc2cd7cddae47fab1b7f3a41d40e3c624b..ae6fd1b1cf98794eb3d2244f3309b3456e819f92 100644 --- a/templates/dates/seminar_export.php +++ b/templates/dates/seminar_export.php @@ -40,6 +40,9 @@ if (!empty($dates['regular']['turnus_data']) || !empty($dates['irregular'])) : if (is_array($dates['irregular'])): foreach ($dates['irregular'] as $date) : + if (!isset($irregular_rooms[$date['resource_id']])) { + $irregular_rooms[$date['resource_id']] = 0; + } $irregular[] = $date; $irregular_strings[] = $date['tostring']; if ($date['resource_id']) : diff --git a/templates/dates/seminar_html.php b/templates/dates/seminar_html.php index c59b5cea69259b697b46b2a57fea0e9bf0fbaece..2680287d445003d48381ff73ce1026538d8bf897 100644 --- a/templates/dates/seminar_html.php +++ b/templates/dates/seminar_html.php @@ -43,9 +43,13 @@ if (!$dates['regular']['turnus_data'] && empty($dates['irregular'])) { echo $output ? '<br>' : ''; $freetext_rooms = []; + $irregular_rooms = []; if (is_array($dates['irregular'])) { foreach ($dates['irregular'] as $date) { + if (!isset($irregular_rooms[$date['resource_id']])) { + $irregular_rooms[$date['resource_id']] = 0; + } $irregular[] = $date; $irregular_strings[] = $date['tostring']; if ($date['resource_id']) { @@ -100,7 +104,7 @@ if (!$dates['regular']['turnus_data'] && empty($dates['irregular'])) { } } - if ($link_to_dates) { + if (!empty($link_to_dates)) { echo '<br>'; printf( _('Details zu allen Terminen im %sAblaufplan%s'), diff --git a/templates/sidebar/select-widget.php b/templates/sidebar/select-widget.php index e0866aa824cf17041596fcdac56a1bdfaed40bab..73d2315603021e516c4c42143cd72cbfa7000242 100644 --- a/templates/sidebar/select-widget.php +++ b/templates/sidebar/select-widget.php @@ -1,7 +1,7 @@ <form action="<?= URLHelper::getLink($url) ?>" method="<?= $method ?>"> <?= \SelectWidget::arrayToHiddenInput($params) ?> <?= (strtolower($method) == 'post') ? CSRFProtection::tokenTag() : ''; ?> - <select class="sidebar-selectlist <?= $class ?> <? if ($__is_nested): ?>nested-select<? endif; ?>" <? if ($size) printf('size="%u"', $size); ?> <?= $attributes ? arrayToHtmlAttributes($attributes) : '' ?> + <select class="sidebar-selectlist <?= $class ?> <? if ($__is_nested): ?>nested-select<? endif; ?>" <? !empty($size) ? printf('size="%u"', $size) : '' ?> <?= !empty($attributes) ? arrayToHtmlAttributes($attributes) : '' ?> name="<?= sprintf('%s%s', htmlReady($name), $multiple ? '[]' : '') ?>" <? if ($multiple) echo 'multiple'; ?>> <? foreach ($elements as $element): ?>