From 02dd7ac2ea8a32a40dbd64acf226fdfb235a98e8 Mon Sep 17 00:00:00 2001 From: sam marshall Date: Fri, 11 Apr 2014 12:05:43 +0100 Subject: [PATCH] MDL-45059 Availability: Hide group options with groupmembersonly When groupmembersonly is turned on, the 'restrict access' options for group and grouping are supposed to appear only for sections (which don't have groupmembersonly) and not for modules. Prior to this fix, they appeared when creating a new module but not when editing an existing one. --- availability/condition/group/classes/frontend.php | 8 +++++--- availability/condition/grouping/classes/frontend.php | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/availability/condition/group/classes/frontend.php b/availability/condition/group/classes/frontend.php index 31f1167c2ec..499d1a45284 100644 --- a/availability/condition/group/classes/frontend.php +++ b/availability/condition/group/classes/frontend.php @@ -79,9 +79,11 @@ class frontend extends \core_availability\frontend { \section_info $section = null) { global $CFG; - // Group option can be used on sections, and on modules but only - // if groupmembersonly is turned off. (To avoid confusion.) - if (!is_null($cm) && $CFG->enablegroupmembersonly) { + // If groupmembersonly is turned on, then you can only add group + // restrictions on sections (which don't use groupmembersonly) and + // not on modules. This is to avoid confusion - otherwise + // there would be two ways to add restrictions based on groups. + if (is_null($section) && $CFG->enablegroupmembersonly) { return false; } diff --git a/availability/condition/grouping/classes/frontend.php b/availability/condition/grouping/classes/frontend.php index 9dfb5e5a145..456fb26033b 100644 --- a/availability/condition/grouping/classes/frontend.php +++ b/availability/condition/grouping/classes/frontend.php @@ -74,9 +74,11 @@ class frontend extends \core_availability\frontend { \section_info $section = null) { global $CFG, $DB; - // Grouping option can be used on sections, and on modules but only - // if groupmembersonly is turned off. (To avoid confusion.) - if (!is_null($cm) && $CFG->enablegroupmembersonly) { + // If groupmembersonly is turned on, then you can only add group + // restrictions on sections (which don't use groupmembersonly) and + // not on modules. This is to avoid confusion - otherwise + // there would be two ways to add restrictions based on groups. + if (is_null($section) && $CFG->enablegroupmembersonly) { return false; }