Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan-Hendrik Willms
Stud.IP
Commits
78da395b
Commit
78da395b
authored
2 years ago
by
Jan-Hendrik Willms
Committed by
Jan-Hendrik Willms
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
valid semester from config, fixes #1774
Closes #1774 Merge request
studip/studip!1151
parent
5fc88cf5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/controllers/my_courses.php
+45
-8
45 additions, 8 deletions
app/controllers/my_courses.php
lib/classes/MyRealmModel.php
+7
-4
7 additions, 4 deletions
lib/classes/MyRealmModel.php
with
52 additions
and
12 deletions
app/controllers/my_courses.php
+
45
−
8
View file @
78da395b
...
...
@@ -803,12 +803,8 @@ class MyCoursesController extends AuthenticatedController
$widget
=
new
SelectWidget
(
_
(
'Semesterfilter'
),
$this
->
url_for
(
'my_courses/set_semester'
),
'sem_select'
);
$widget
->
setMaxLength
(
50
);
$widget
->
addElement
(
new
SelectElement
(
'current'
,
_
(
'Aktuelles Semester'
),
$sem
===
'current'
));
$widget
->
addElement
(
new
SelectElement
(
'future'
,
_
(
'Aktuelles und nächstes Semester'
),
$sem
===
'future'
));
$widget
->
addElement
(
new
SelectElement
(
'last'
,
_
(
'Aktuelles und letztes Semester'
),
$sem
===
'last'
));
$widget
->
addElement
(
new
SelectElement
(
'lastandnext'
,
_
(
'Letztes, aktuelles, nächstes Semester'
),
$sem
===
'lastandnext'
));
if
(
Config
::
get
()
->
MY_COURSES_ENABLE_ALL_SEMESTERS
)
{
$widget
->
addElement
(
new
SelectElement
(
'all'
,
_
(
'Alle Semester'
),
$sem
===
'all'
));
foreach
(
$this
->
getTextualSemesterEntries
()
as
$key
=>
$label
)
{
$widget
->
addElement
(
new
SelectElement
(
$key
,
$label
,
$sem
===
$key
));
}
$query
=
"SELECT semester_data.semester_id
...
...
@@ -846,7 +842,7 @@ class MyCoursesController extends AuthenticatedController
}
// create settings url depended on selected cycle
if
(
isset
(
$sem
)
&&
!
in_array
(
$sem
,
words
(
'future all last current'
)
))
{
if
(
isset
(
$sem
)
&&
!
$this
->
isValidTextualSemesterEntry
(
$sem
))
{
$this
->
settings_url
=
"dispatch.php/my_courses/groups/
{
$sem
}
"
;
}
else
{
$this
->
settings_url
=
'dispatch.php/my_courses/groups'
;
...
...
@@ -1074,12 +1070,21 @@ class MyCoursesController extends AuthenticatedController
$config_sem
=
'future'
;
}
if
(
$config_sem
&&
!
$this
->
isValidTextualSemesterEntry
(
$config_sem
)
&&
!
Semester
::
exists
(
$config_sem
)
)
{
$config_sem
=
null
;
}
$sem
=
Request
::
get
(
'sem_select'
,
$config_sem
?:
Config
::
get
()
->
MY_COURSES_DEFAULT_CYCLE
);
if
(
$sem
&&
!
in_array
(
$sem
,
[
'future'
,
'all'
,
'last'
,
'current'
]))
{
if
(
$sem
&&
!
$this
->
isValidTextualSemesterEntry
(
$sem
))
{
Request
::
set
(
'sem_select'
,
$sem
);
}
...
...
@@ -1108,4 +1113,36 @@ class MyCoursesController extends AuthenticatedController
return
$group_field
===
'not_grouped'
?
'sem_number'
:
$group_field
;
}
/**
* Returns all valid textual semester entries like 'last', 'future' etc
*
* @return array<string, string>
*/
private
function
getTextualSemesterEntries
():
array
{
$entries
=
[
'current'
=>
_
(
'Aktuelles Semester'
),
'future'
=>
_
(
'Aktuelles und nächstes Semester'
),
'last'
=>
_
(
'Aktuelles und letztes Semester'
),
'lastandnext'
=>
_
(
'Letztes, aktuelles, nächstes Semester'
),
];
if
(
Config
::
get
()
->
MY_COURSES_ENABLE_ALL_SEMESTERS
)
{
$entries
[
'all'
]
=
_
(
'Alle Semester'
);
}
return
$entries
;
}
/**
* Returns whether the given entry is a valid textual semester entry.
*
* @see getTextualSemesterEntries()
* @return bool
*/
private
function
isValidTextualSemesterEntry
(
string
$entry
):
bool
{
return
array_key_exists
(
$entry
,
$this
->
getTextualSemesterEntries
());
}
}
This diff is collapsed.
Click to expand it.
lib/classes/MyRealmModel.php
+
7
−
4
View file @
78da395b
...
...
@@ -169,12 +169,15 @@ class MyRealmModel
$sem_data
=
Semester
::
getAllAsArray
();
$semester_ids
=
[];
for
(
$i
=
$min_sem_key
;
$i
<=
$max_sem_key
;
$i
++
)
{
if
(
!
empty
(
$sem_data
[
$i
][
'semester_id'
]))
{
$semester_ids
[]
=
$sem_data
[
$i
][
'semester_id'
];
$semester_ids
=
[];
if
(
is_numeric
(
$min_sem_key
)
&&
is_numeric
(
$max_sem_key
))
{
foreach
(
$sem_data
as
$index
=>
$data
)
{
if
(
$index
>=
$min_sem_key
&&
$index
<=
$max_sem_key
)
{
$semester_ids
[]
=
$data
[
'semester_id'
];
}
}
}
$semesters
=
Semester
::
findMany
(
$semester_ids
);
$studygroup_filter
=
!
$params
[
'studygroups_enabled'
]
?
false
:
true
;
$ordering
=
''
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment