mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-37765 course: Add capability to ignore availability restrictions.
Allow a role to view activities without addressing the restriction rules.
This commit is contained in:
parent
216ea39be7
commit
6a36b8526e
8 changed files with 73 additions and 13 deletions
|
@ -1930,8 +1930,9 @@ class cm_info implements IteratorAggregate {
|
|||
|
||||
// If the user cannot access the activity set the uservisible flag to false.
|
||||
// Additional checks are required to determine whether the activity is entirely hidden or just greyed out.
|
||||
if ((!$this->visible or !$this->get_available()) and
|
||||
!has_capability('moodle/course:viewhiddenactivities', $this->get_context(), $userid)) {
|
||||
if ((!$this->visible && !has_capability('moodle/course:viewhiddenactivities', $this->get_context(), $userid)) ||
|
||||
(!$this->get_available() &&
|
||||
!has_capability('moodle/course:ignoreavailabilityrestrictions', $this->get_context(), $userid))) {
|
||||
|
||||
$this->uservisible = false;
|
||||
}
|
||||
|
@ -2760,7 +2761,10 @@ class section_info implements IteratorAggregate {
|
|||
$this->_uservisible = true;
|
||||
if (!$this->_visible || !$this->get_available()) {
|
||||
$coursecontext = context_course::instance($this->get_course());
|
||||
if (!has_capability('moodle/course:viewhiddensections', $coursecontext, $userid)) {
|
||||
if (!$this->_visible && !has_capability('moodle/course:viewhiddensections', $coursecontext, $userid) ||
|
||||
(!$this->get_available() &&
|
||||
!has_capability('moodle/course:ignoreavailabilityrestrictions', $coursecontext, $userid))) {
|
||||
|
||||
$this->_uservisible = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue