Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'MDL-34931-22' of git://github.com/FMCorz/moodle into MO…

…ODLE_22_STABLE
  • Loading branch information...
commit 1950fefc9987211deb9eb62c9f6083efa1546a45 2 parents ab6a0f4 + 0295ae4
@stronk7 stronk7 authored
Showing with 30 additions and 14 deletions.
  1. +13 −11 grade/report/user/lib.php
  2. +17 −3 lib/modinfolib.php
View
24 grade/report/user/lib.php
@@ -339,23 +339,25 @@ private function fill_table_recursive(&$element) {
$hidden = ' hidden';
}
+ $hide = false;
// If this is a hidden grade item, hide it completely from the user.
if ($grade_grade->is_hidden() && !$this->canviewhidden && (
$this->showhiddenitems == GRADE_REPORT_USER_HIDE_HIDDEN ||
($this->showhiddenitems == GRADE_REPORT_USER_HIDE_UNTIL && !$grade_grade->is_hiddenuntil()))) {
- // return false;
- } else {
- // The grade object can be marked visible but still be hidden
- // if "enablegroupmembersonly" is on and its an activity assigned to a grouping the user is not in
- if (!empty($grade_object->itemmodule) && !empty($grade_object->iteminstance)) {
- $instances = $this->gtree->modinfo->get_instances();
- if (!empty($instances[$grade_object->itemmodule][$grade_object->iteminstance])) {
- $cm = $instances[$grade_object->itemmodule][$grade_object->iteminstance];
- if (!$cm->uservisible) {
- return false;
- }
+ $hide = true;
+ } else if (!empty($grade_object->itemmodule) && !empty($grade_object->iteminstance)) {
+ // The grade object can be marked visible but still be hidden if "enablegroupmembersonly"
+ // is on and it's an activity assigned to a grouping the user is not in.
+ $instances = $this->gtree->modinfo->get_instances_of($grade_object->itemmodule);
+ if (!empty($instances[$grade_object->iteminstance])) {
+ $cm = $instances[$grade_object->iteminstance];
+ if ($cm->is_user_access_restricted_by_group()) {
+ $hide = true;
}
}
+ }
+
+ if (!$hide) {
/// Excluded Item
if ($grade_grade->is_excluded()) {
$fullname .= ' ['.get_string('excluded', 'grades').']';
View
20 lib/modinfolib.php
@@ -1003,17 +1003,31 @@ private function update_user_visible() {
}
// Check group membership. The grouping option makes the activity
// completely invisible as it does not apply to the user at all.
+ if ($this->is_user_access_restricted_by_group()) {
+ $this->uservisible = false;
+ // Ensure activity is completely hidden from user.
+ $this->showavailability = 0;
+ }
+ }
+
+ /**
+ * Checks whether the module group settings restrict the user access.
+ * @return bool true if the user access is restricted
+ */
+ public function is_user_access_restricted_by_group() {
+ global $CFG;
+ $modcontext = context_module::instance($this->id);
+ $userid = $this->modinfo->get_user_id();
if (!empty($CFG->enablegroupmembersonly) and !empty($this->groupmembersonly)
and !has_capability('moodle/site:accessallgroups', $modcontext, $userid)) {
// If the activity has 'group members only' and you don't have accessallgroups...
$groups = $this->modinfo->get_groups($this->groupingid);
if (empty($groups)) {
// ...and you don't belong to a group, then set it so you can't see/access it
- $this->uservisible = false;
- // Ensure activity is completely hidden from user.
- $this->showavailability = 0;
+ return true;
}
}
+ return false;
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.