Skip to content
Permalink
Browse files

Merge branch 'MDL-34931-master' of git://github.com/FMCorz/moodle

  • Loading branch information...
stronk7 committed Oct 1, 2012
2 parents a5fc5b6 + 5fee56d commit 5522e44658372251fbf83c4f4b03a49fe77e5675
Showing with 30 additions and 14 deletions.
  1. +13 −11 grade/report/user/lib.php
  2. +17 −3 lib/modinfolib.php
@@ -341,23 +341,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').']';
@@ -1103,17 +1103,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;
}
/**

0 comments on commit 5522e44

Please sign in to comment.
You can’t perform that action at this time.