From 9e13d2f5fa4726b54efe8ad046d0b53aadb543bf Mon Sep 17 00:00:00 2001 From: Moritz Strohm Date: Wed, 28 Sep 2022 12:32:56 +0000 Subject: fix for BIESt #1104 Merge request studip/studip!674 --- app/controllers/search/courses.php | 8 +-- app/controllers/search/module.php | 11 +-- app/controllers/search/studiengaenge.php | 2 +- app/views/search/globalsearch/index.php | 2 +- app/views/search/stgtable/index.php | 4 +- app/views/search/studiengaenge/verlauf.php | 2 +- lib/classes/BreadCrumb.class.php | 1 + lib/classes/DbSnapshot.class.php | 3 + lib/classes/QuickSearch.class.php | 7 +- lib/classes/SemBrowse.class.php | 50 +++++++------- lib/classes/StudipForm.class.php | 37 +++++----- lib/classes/StudipSemRangeTreeViewSimple.class.php | 6 +- lib/classes/StudipSemSearch.class.php | 4 +- lib/classes/StudipSemSearchHelper.class.php | 13 ++-- lib/classes/StudipSemTree.class.php | 5 +- lib/classes/StudipSemTreeViewSimple.class.php | 6 +- lib/classes/TreeAbstract.class.php | 9 ++- lib/classes/globalsearch/GlobalSearchCourses.php | 15 +++-- lib/classes/globalsearch/GlobalSearchForum.php | 4 +- lib/classes/globalsearch/GlobalSearchModule.php | 2 +- lib/classes/globalsearch/GlobalSearchMyCourses.php | 10 ++- lib/classes/globalsearch/GlobalSearchUsers.php | 1 + lib/classes/searchtypes/SearchType.class.php | 2 + lib/classes/sidebar/ClipboardWidget.class.php | 3 +- lib/classes/sidebar/ResourceTreeWidget.class.php | 1 + lib/classes/sidebar/RoomSearchWidget.class.php | 2 +- lib/models/Modulteil.php | 4 +- lib/models/SimpleCollection.class.php | 4 +- lib/models/resources/Location.class.php | 78 +++++++++++----------- lib/raumzeit/SingleDate.class.php | 4 +- templates/sidebar/room-clipboard-item.php | 6 +- templates/sidebar/room-search-widget.php | 30 +++++---- vendor/write_excel/OLEwriter.php | 4 +- vendor/write_excel/Parser.php | 14 ++-- 34 files changed, 200 insertions(+), 154 deletions(-) diff --git a/app/controllers/search/courses.php b/app/controllers/search/courses.php index 9a3294c..536c361 100644 --- a/app/controllers/search/courses.php +++ b/app/controllers/search/courses.php @@ -30,12 +30,12 @@ class Search_CoursesController extends AuthenticatedController // activate navigation item $nav_options = Config::get()->COURSE_SEARCH_NAVIGATION_OPTIONS; URLHelper::bindLinkParam('option', $this->nav_option); - if ($nav_options[$this->nav_option] + if (!empty($nav_options[$this->nav_option]) && Navigation::hasItem('/search/courses/' . $this->nav_option)) { 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'] ?? ''); $default_option = SemBrowse::getSearchOptionNavigation('sidebar'); if (!$level) { PageLayout::setTitle(_($default_option->getTitle())); @@ -74,7 +74,7 @@ class Search_CoursesController extends AuthenticatedController $sidebar = Sidebar::get(); // add search options to sidebar - $level = Request::get('level', $_SESSION['sem_browse_data']['level']); + $level = Request::get('level', $_SESSION['sem_browse_data']['level'] ?? ''); $widget = new OptionsWidget(); $widget->setTitle(_('Suche')); @@ -114,7 +114,7 @@ class Search_CoursesController extends AuthenticatedController } // show information about course class if class was changed - $class = $GLOBALS['SEM_CLASS'][$_SESSION['sem_browse_data']['show_class']]; + $class = $GLOBALS['SEM_CLASS'][$_SESSION['sem_browse_data']['show_class']] ?? null; if (is_object($class) && $class->countSeminars() > 0) { if (trim($GLOBALS['SEM_CLASS'][$_SESSION['sem_browse_data']['show_class']]['description'])) { PageLayout::postInfo(sprintf(_('Gewählte Veranstaltungsklasse %1s: %2s'), diff --git a/app/controllers/search/module.php b/app/controllers/search/module.php index 082ad21..38106ea 100644 --- a/app/controllers/search/module.php +++ b/app/controllers/search/module.php @@ -147,14 +147,14 @@ 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; + $this->result_count = (!empty($this->search_result['Modul']) && is_array($this->search_result['Modul'])) ? count($this->search_result['Modul']) : 0; $drill_down['studiengaenge']['objects'] = - $this->drilldown_studiengaenge($this->search_result['Modul']); + $this->drilldown_studiengaenge($this->search_result['Modul'] ?? []); $drill_down['faecher']['objects'] = - $this->drilldown_faecher($this->search_result['Modul']); + $this->drilldown_faecher($this->search_result['Modul'] ?? []); $drill_down['institutes']['objects'] = - $this->drilldown_institutes($this->search_result['Modul']); + $this->drilldown_institutes($this->search_result['Modul'] ?? []); if (count($drill_down['institutes']['objects']) || count($drill_down['studiengaenge']['objects']) || count($drill_down['faecher']['objects'])) { @@ -214,7 +214,8 @@ class Search_ModuleController extends MVVController } $this->module = []; - if (is_array($this->search_result['Modul']) + $this->count = 0; + if (!empty($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( diff --git a/app/controllers/search/studiengaenge.php b/app/controllers/search/studiengaenge.php index 1bd94a4..91d999a 100644 --- a/app/controllers/search/studiengaenge.php +++ b/app/controllers/search/studiengaenge.php @@ -257,7 +257,7 @@ class Search_StudiengaengeController extends MVVController $start_sem = Semester::find($abschnitt_modul->modul->start); $end_sem = Semester::find($abschnitt_modul->modul->end); - if ($start_sem->beginn > $this->active_sem->beginn || ($this->active_sem->ende > $end_sem->ende && $end_sem != null)) { + if (($start_sem && $start_sem->beginn > $this->active_sem->beginn) || ($end_sem && $this->active_sem->ende > $end_sem->ende)) { continue; } diff --git a/app/views/search/globalsearch/index.php b/app/views/search/globalsearch/index.php index e85aa8f..637873e 100644 --- a/app/views/search/globalsearch/index.php +++ b/app/views/search/globalsearch/index.php @@ -1,7 +1,7 @@
'; } else { - $temp_turnus_string = $seminar_obj->getDatesExport([ - 'short' => true, - 'shrink' => true, - ]); + $temp_turnus_string = $seminar_obj->getDatesExport( + [ + 'short' => true, + 'shrink' => true, + 'semester_id' => '' + ] + ); //Shorten, if string too long (add link for details.php) if (mb_strlen($temp_turnus_string) > 70) { $temp_turnus_string = htmlReady(mb_substr($temp_turnus_string, 0, mb_strpos(mb_substr($temp_turnus_string, 70, mb_strlen($temp_turnus_string)), ',') + 71)); @@ -1241,16 +1245,16 @@ class SemBrowse { */ public static function transferSessionData() { - if (Request::option('reset_all')) { - $_SESSION['sem_browse_data'] = null; + if (empty($_SESSION['sem_browse_data']) || Request::option('reset_all')) { + $_SESSION['sem_browse_data'] = []; } $_SESSION['sem_browse_data']['qs_choose'] = Request::get('search_sem_qs_choose', - $_SESSION['sem_browse_data']['qs_choose']); + $_SESSION['sem_browse_data']['qs_choose'] ?? null); // simulate button clicked if semester was changed - if (Request::option('search_sem_sem', $_SESSION['sem_browse_data']['default_sem']) - != $_SESSION['sem_browse_data']['default_sem']) { + $old_default_sem = $_SESSION['sem_browse_data']['default_sem'] ?? null; + if (Request::option('search_sem_sem', $old_default_sem) != $old_default_sem) { $_SESSION['sem_browse_data']['default_sem'] = Request::option('search_sem_sem'); if ($_SESSION['sem_browse_data']['sset']) { Request::set('search_sem_quick_search_parameter', $_SESSION['sem_browse_data']['sset']); @@ -1267,8 +1271,8 @@ class SemBrowse { } // simulate button clicked if class was changed - if (Request::option('show_class', $_SESSION['sem_browse_data']['show_class']) - != $_SESSION['sem_browse_data']['show_class']) { + $old_show_class = $_SESSION['sem_browse_data']['show_class'] ?? null; + if (Request::option('show_class', $old_show_class) != $old_show_class) { $_SESSION['sem_browse_data']['show_class'] = Request::option('show_class'); if ($_SESSION['sem_browse_data']['show_class'] @@ -1300,9 +1304,9 @@ class SemBrowse { ?: 'all'; } $_SESSION['sem_browse_data']['show_class'] = - $_SESSION['sem_browse_data']['show_class'] ?: 'all'; + $_SESSION['sem_browse_data']['show_class'] ?? 'all'; $_SESSION['sem_browse_data']['group_by'] = - $_SESSION['sem_browse_data']['group_by'] ?: '0'; + $_SESSION['sem_browse_data']['group_by'] ?? '0'; } /** @@ -1386,7 +1390,7 @@ class SemBrowse { $stmt->execute([$seminar_id]); $result = $stmt->fetch(); - if ($result['types']) { + if (!empty($result['types'])) { if ($result['type_locked']) { return 2; } diff --git a/lib/classes/StudipForm.class.php b/lib/classes/StudipForm.class.php index fd76fee..88c36fe 100644 --- a/lib/classes/StudipForm.class.php +++ b/lib/classes/StudipForm.class.php @@ -87,7 +87,7 @@ class StudipForm { } if ($this->isSended()){ foreach ($this->form_fields as $name => $foo){ - if (!$foo['disabled']){ + if (empty($foo['disabled'])) { if ( ($field_value = Request::get($this->form_name . "_" . $name)) !== null) { $new_form_values[$name] = trim($field_value); } elseif ( is_array($field_value = Request::getArray($this->form_name . "_" . $name))) { @@ -100,7 +100,7 @@ class StudipForm { } } foreach ($this->form_fields as $name => $value){ - if (!$value['disabled']){ + if (empty($value['disabled'])) { if ($value['type'] == 'combo'){ if ($this->form_values[$name] != $new_form_values[$value['text']]){ //textfeld wurde verändert $new_form_values[$name] = $new_form_values[$value['text']]; @@ -129,7 +129,8 @@ class StudipForm { $new_form_values[$name] = Request::int($this->form_name . "_" . $name, 0); } if ( (isset($this->form_values[$name]) && $this->form_values[$name] != $new_form_values[$name]) - || (!isset($this->form_values[$name]) && $new_form_values[$name] != $this->form_fields[$name]['default_value']) ){ + || (!isset($this->form_values[$name]) && !empty($new_form_values[$name]) && !empty($this->form_fields[$name]['default_value']) + && $new_form_values[$name] != $this->form_fields[$name]['default_value']) ){ $this->value_changed[$name] = true; } } @@ -162,22 +163,22 @@ class StudipForm { if (!$attributes){ $attributes = $this->field_attributes_default; } - if (!$default){ - if (isset($this->form_values[$name])){ + if (empty($default)) { + if (isset($this->form_values[$name])) { $default = $this->form_values[$name]; } else { - $default = $this->form_fields[$name]['default_value']; + $default = $this->form_fields[$name]['default_value'] ?? ''; } } - if (is_array($this->form_fields[$name]['attributes'])){ + if (!empty($this->form_fields[$name]['attributes']) && is_array($this->form_fields[$name]['attributes'])) { $attributes = array_merge((array)$attributes, (array)$this->form_fields[$name]['attributes']); } - if ($this->form_fields[$name]['disabled']){ + if (!empty($this->form_fields[$name]['disabled'])) { $attributes['disabled'] = 'disabled'; } - if ($this->form_fields[$name]['required']){ + if (!empty($this->form_fields[$name]['required'])) { $attributes['required'] = 'required'; } @@ -281,7 +282,7 @@ class StudipForm { function getFormFieldSelect($name, $attributes, $default){ $ret = "\n