Skip to content
Snippets Groups Projects
Commit 660b1d5f authored by Moritz Strohm's avatar Moritz Strohm
Browse files

Course::getEnrolmentInformation: fixed checks for root and admin users, fixes #4779

Closes #4779

Merge request studip/studip!3607
parent 5e4964ce
No related branches found
No related tags found
No related merge requests found
......@@ -1567,6 +1567,36 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe
);
}
//Check if the user has root or admin permissions:
$user = User::find($user_id);
if ($GLOBALS['perm']->have_perm('root', $user_id)) {
return new \Studip\EnrolmentInformation(
_('Sie haben root-Rechte und dürfen damit alles in Stud.IP.'),
\Studip\Information::INFO,
'root',
true
);
}
if ($GLOBALS['perm']->have_studip_perm('admin', $this->id, $user_id)) {
return new \Studip\EnrolmentInformation(
_('Sie verwalten diese Veranstaltung.'),
\Studip\Information::INFO,
'course_admin',
true
);
}
if ($GLOBALS['perm']->have_perm('admin', $user_id)) {
return new \Studip\EnrolmentInformation(
_('Als administrierende Person dürfen Sie sich nicht in eine Veranstaltung eintragen.'),
\Studip\Information::INFO,
'admin',
false
);
}
//Check the course set and if the user is on an admission list:
if ($course_set = $this->getCourseSet()) {
......@@ -1622,9 +1652,7 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe
);
}
//Check the permissions of the user:
$user = User::find($user_id);
//Check the permissions of users that are not root or admin:
if (!$user) {
return new \Studip\EnrolmentInformation(
......@@ -1642,30 +1670,6 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe
false
);
}
if ($GLOBALS['perm']->have_perm('root', $user_id)) {
return new \Studip\EnrolmentInformation(
_('Sie haben root-Rechte und dürfen damit alles in Stud.IP.'),
\Studip\Information::INFO,
'root',
true
);
}
if ($GLOBALS['perm']->have_studip_perm('admin', $this->id, $user_id)) {
return new \Studip\EnrolmentInformation(
_('Sie verwalten diese Veranstaltung.'),
\Studip\Information::INFO,
'course_admin',
true
);
}
if ($GLOBALS['perm']->have_perm('admin', $user_id)) {
return new \Studip\EnrolmentInformation(
_('Als administrierende Person dürfen Sie sich nicht in eine Veranstaltung eintragen.'),
\Studip\Information::INFO,
'admin',
false
);
}
//Check the course membership:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment