diff --git a/app/controllers/admin/courseplanning.php b/app/controllers/admin/courseplanning.php index 14612ee393db7e259c69103424d6528018e03148..b8971e2de1a6e980ce56cb376f39da1709492fa2 100644 --- a/app/controllers/admin/courseplanning.php +++ b/app/controllers/admin/courseplanning.php @@ -48,10 +48,7 @@ class Admin_CourseplanningController extends AuthenticatedController $stgteil = StudiengangTeil::find($GLOBALS['user']->cfg->MY_COURSES_SELECTED_STGTEIL); $plan_title .= ' - ' . $stgteil->getDisplayName(); } - if ( - isset($this->semester) - && $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE - && $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE !== 'all' + if (isset($this->semester) && $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE ) { $plan_title .= ' - ' . $this->semester->name; } @@ -611,7 +608,7 @@ class Admin_CourseplanningController extends AuthenticatedController $sidebar = Sidebar::Get(); $list = new SelectWidget(_('Semester'), $this->url_for('admin/courseplanning/set_selection/' . $this->selected_weekday), 'sem_select'); foreach ($semesters as $semester) { - if (!$GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE ||$GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE == 'all') { + if (!$GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE) { $GLOBALS['user']->cfg->store('MY_COURSES_SELECTED_CYCLE', $semester->id); } $list->addElement(new SelectElement( @@ -726,7 +723,7 @@ class Admin_CourseplanningController extends AuthenticatedController $sidebar = Sidebar::Get(); $list = new SelectWidget(_('Lehrendenfilter'), $this->url_for('admin/courseplanning/index'), 'teacher_filter'); - $list->addElement(new SelectElement('all', _('alle'), Request::get('teacher_filter') == 'all'), 'teacher_filter-all'); + $list->addElement(new SelectElement('', _('alle'), Request::get('teacher_filter') === ''), 'teacher_filter-all'); foreach ($teachers as $teacher) { $list->addElement(new SelectElement( @@ -848,7 +845,7 @@ class Admin_CourseplanningController extends AuthenticatedController if (Request::option('sem_select')) { $GLOBALS['user']->cfg->store('MY_COURSES_SELECTED_CYCLE', Request::option('sem_select')); - if (Request::option('sem_select') !== 'all') { + if (Request::option('sem_select') !== '') { PageLayout::postSuccess(sprintf( _('Das %s wurde ausgewählt'), htmlReady(Semester::find(Request::option('sem_select'))->name) diff --git a/app/controllers/course/timesrooms.php b/app/controllers/course/timesrooms.php index 672495f8c2e3e7f804ab5eb8956d17f3894ea46f..2e3b3fefc7d128bde992eda58a29cbcd49934368 100644 --- a/app/controllers/course/timesrooms.php +++ b/app/controllers/course/timesrooms.php @@ -90,10 +90,7 @@ class Course_TimesroomsController extends AuthenticatedController if (!Request::isXhr()) { $this->setSidebar(); } elseif (Request::isXhr() && $this->flash['update-times']) { - $semester_id = $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE; - if ($semester_id === 'all') { - $semester_id = ''; - } + $semester_id = $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE ?? ''; $this->response->add_header( 'X-Raumzeit-Update-Times', json_encode([ diff --git a/app/controllers/my_courses.php b/app/controllers/my_courses.php index 27210b3761390bdc50a5c1768f59b89c46d2df9d..410947bf05f56f58cf3dd9cafdc1e86749cc34c8 100644 --- a/app/controllers/my_courses.php +++ b/app/controllers/my_courses.php @@ -344,7 +344,7 @@ class MyCoursesController extends AuthenticatedController * @param string $type * @param string $sem */ - public function tabularasa_action($sem = 'all', $timestamp = null) + public function tabularasa_action($sem = '', $timestamp = null) { NotificationCenter::postNotification('OverviewWillClear', $GLOBALS['user']->id); @@ -628,7 +628,8 @@ class MyCoursesController extends AuthenticatedController */ public function set_semester_action() { - $sem = Request::option('sem_select', null); + $sem = Request::option('sem_select'); + if (!is_null($sem)) { $GLOBALS['user']->cfg->store('MY_COURSES_SELECTED_CYCLE', $sem); PageLayout::postSuccess( @@ -1118,7 +1119,7 @@ class MyCoursesController extends AuthenticatedController private function getSemesterKey() { $config_sem = $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE; - if (!Config::get()->MY_COURSES_ENABLE_ALL_SEMESTERS && $config_sem === 'all') { + if (!Config::get()->MY_COURSES_ENABLE_ALL_SEMESTERS && $config_sem === '') { $config_sem = 'future'; } @@ -1130,11 +1131,10 @@ class MyCoursesController extends AuthenticatedController $config_sem = null; } - $sem = Request::get( - 'sem_select', - $config_sem ?: Config::get()->MY_COURSES_DEFAULT_CYCLE - ); - + if (!Config::get()->MY_COURSES_ENABLE_ALL_SEMESTERS && !$config_sem) { + $config_sem = Config::get()->MY_COURSES_DEFAULT_CYCLE; + } + $sem = Request::get('sem_select', $config_sem); if ($sem && !$this->isValidTextualSemesterEntry($sem)) { Request::set('sem_select', $sem); @@ -1181,7 +1181,7 @@ class MyCoursesController extends AuthenticatedController ]; if (Config::get()->MY_COURSES_ENABLE_ALL_SEMESTERS) { - $entries['all'] = _('Alle Semester'); + $entries[''] = _('Alle Semester'); } return $entries; diff --git a/app/views/admin/courses/courses.php b/app/views/admin/courses/courses.php index 830ac4da62351246ef14baf2667e1e7f46935ec7..d22527076d05731d77fa954bef34bb561c40fba2 100644 --- a/app/views/admin/courses/courses.php +++ b/app/views/admin/courses/courses.php @@ -85,7 +85,7 @@ $colspan = 2 </colgroup> <caption> - <? if (!$GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE || ($GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE === "all")) : ?> + <? if (!$GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE) : ?> <?= _('Veranstaltungen') ?> <? else : ?> <?= htmlReady(sprintf(_('Veranstaltungen im %s'), $semester->name)) ?> diff --git a/db/migrations/5.4.16_reset_my_courses_filter.php b/db/migrations/5.4.16_reset_my_courses_filter.php new file mode 100644 index 0000000000000000000000000000000000000000..48709bd915916316cb388528579a2741fe9cfa05 --- /dev/null +++ b/db/migrations/5.4.16_reset_my_courses_filter.php @@ -0,0 +1,14 @@ +<?php + +final class ResetMyCoursesFilter extends Migration +{ + public function description() + { + return 'Cleanup user-config'; + } + + public function up() + { + DBManager::get()->exec("UPDATE `config_values` SET `value` = '' WHERE `value` = 'all' AND `field` IN ('ADMIN_COURSES_TEACHERFILTER', 'MY_COURSES_SELECTED_CYCLE')"); + } +} diff --git a/lib/classes/MyRealmModel.php b/lib/classes/MyRealmModel.php index 439094fde12fa3f2d468b3d282ab4275b7e734ae..6d1ef02a86f7d51c1e76b01bd19a32491f4aa936 100644 --- a/lib/classes/MyRealmModel.php +++ b/lib/classes/MyRealmModel.php @@ -225,7 +225,7 @@ class MyRealmModel return self::sortCourses($courses, $ordering); } - public static function getSelectedSemesters($sem = 'all') + public static function getSelectedSemesters($sem = '') { $sem_data = Semester::getAllAsArray(); $semesters = []; @@ -241,14 +241,8 @@ class MyRealmModel $max_sem = $current_sem; } - if (isset($sem_data[$current_sem + 2])) { - $after_next_sem = $current_sem + 2; - } else { - $after_next_sem = $max_sem; - } - // Get the needed semester - if (!in_array($sem, ['all', 'current', 'future', 'last', 'lastandnext'])) { + if (!in_array($sem, ['', 'current', 'future', 'last', 'lastandnext'])) { $semesters[] = Semester::getIndexById($sem); } else { switch ($sem) { @@ -284,7 +278,7 @@ class MyRealmModel * @param array $params Additional parameters * @return array */ - public static function getPreparedCourses($sem = 'all', $params = []) + public static function getPreparedCourses($sem = '', $params = []) { $semesters = self::getSelectedSemesters($sem); $current_semester_nr = Semester::getIndexById(@Semester::findCurrent()->id);