aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Siegfried <david.siegfried@uni-vechta.de>2024-03-17 12:55:15 +0000
committerJan-Hendrik Willms <tleilax+studip@gmail.com>2024-03-17 12:55:15 +0000
commitfe48cbf3615094722acb00a7a7a0cbc1df60a8a1 (patch)
tree8250654854150d19646a7d19ec0c8273fbd49e6d
parent0e6fdeadeca43045dbea72b7468a52cbf0cc9e4e (diff)
cleanup user-config, closes #3803
Closes #3803 Merge request studip/studip!2672
-rw-r--r--app/controllers/admin/courseplanning.php11
-rw-r--r--app/controllers/course/timesrooms.php5
-rw-r--r--app/controllers/my_courses.php18
-rw-r--r--app/views/admin/courses/courses.php2
-rw-r--r--db/migrations/5.4.16_reset_my_courses_filter.php14
-rw-r--r--lib/classes/MyRealmModel.php12
6 files changed, 32 insertions, 30 deletions
diff --git a/app/controllers/admin/courseplanning.php b/app/controllers/admin/courseplanning.php
index 14612ee..b8971e2 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 672495f..2e3b3fe 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 27210b3..410947b 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 830ac4d..d225270 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 0000000..48709bd
--- /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 439094f..6d1ef02 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);