mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 01:16:44 +02:00
MDL-22033 groupings now enabled unconditionally, groupmembersonly kept as experimental - this simplifies groups code logic a bit, user interface changes should not be significant because the groupings are not visible much until at least one created; hopefully the new description of groupmembersonly will have to preventsome gradebook complaints
This commit is contained in:
parent
e8c2189d78
commit
98da60215e
31 changed files with 137 additions and 214 deletions
|
@ -3056,7 +3056,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
|||
}
|
||||
|
||||
if ($result && $oldversion < 2010033101.02) {
|
||||
|
||||
|
||||
/// Define table license to be created
|
||||
$table = new xmldb_table('license');
|
||||
|
||||
|
@ -3435,6 +3435,17 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
|||
upgrade_main_savepoint($result, 2010033102.09);
|
||||
}
|
||||
|
||||
if ($result && $oldversion < 2010040700) {
|
||||
// migrate old groupings --> groupmembersonly setting
|
||||
if (isset($CFG->enablegroupings)) {
|
||||
set_config('enablegroupmembersonly', $CFG->enablegroupings);
|
||||
unset_config('enablegroupings');
|
||||
}
|
||||
|
||||
// Main savepoint reached
|
||||
upgrade_main_savepoint($result, 2010040700);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
|
@ -320,7 +320,7 @@ class external_api {
|
|||
throw new invalid_parameter_exception('Invalid activity.');
|
||||
}
|
||||
// verify group memebers
|
||||
if (!empty($CFG->enablegroupings) and $cm and $cm->groupmembersonly and !has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_MODULE, $cm->id))) {
|
||||
if (!empty($CFG->enablegroupmembersonly) and $cm and $cm->groupmembersonly and !has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_MODULE, $cm->id))) {
|
||||
if (!groups_has_membership($cm)) {
|
||||
throw new invalid_parameter_exception('Must be member of at least one group.');
|
||||
}
|
||||
|
|
|
@ -144,12 +144,6 @@ function groups_get_grouping($groupingid, $fields='*', $strictness=IGNORE_MISSIN
|
|||
function groups_get_all_groups($courseid, $userid=0, $groupingid=0, $fields='g.*') {
|
||||
global $CFG, $DB;
|
||||
|
||||
// groupings are ignored when not enabled
|
||||
if (empty($CFG->enablegroupings)) {
|
||||
$groupingid = 0;
|
||||
}
|
||||
|
||||
|
||||
if (empty($userid)) {
|
||||
$userfrom = "";
|
||||
$userwhere = "";
|
||||
|
@ -238,10 +232,6 @@ function groups_get_user_groups($courseid, $userid=0) {
|
|||
function groups_get_all_groupings($courseid) {
|
||||
global $CFG, $DB;
|
||||
|
||||
// groupings are ignored when not enabled
|
||||
if (empty($CFG->enablegroupings)) {
|
||||
return(false);
|
||||
}
|
||||
return $DB->get_records_sql("SELECT *
|
||||
FROM {groupings}
|
||||
WHERE courseid = ?
|
||||
|
@ -287,11 +277,6 @@ function groups_has_membership($cm, $userid=null) {
|
|||
|
||||
static $cache = array();
|
||||
|
||||
// groupings are ignored when not enabled
|
||||
if (empty($CFG->enablegroupings)) {
|
||||
$cm->groupingid = 0;
|
||||
}
|
||||
|
||||
if (empty($userid)) {
|
||||
$userid = $USER->id;
|
||||
}
|
||||
|
@ -521,11 +506,6 @@ function groups_print_activity_menu($cm, $urlroot, $return=false, $hideallpartic
|
|||
DEBUG_DEVELOPER);
|
||||
}
|
||||
|
||||
// groupings are ignored when not enabled
|
||||
if (empty($CFG->enablegroupings)) {
|
||||
$cm->groupingid = 0;
|
||||
}
|
||||
|
||||
if (!$groupmode = groups_get_activity_groupmode($cm)) {
|
||||
if ($return) {
|
||||
return '';
|
||||
|
@ -694,11 +674,6 @@ function groups_get_course_group($course, $update=false) {
|
|||
function groups_get_activity_group($cm, $update=false) {
|
||||
global $CFG, $USER, $SESSION;
|
||||
|
||||
// groupings are ignored when not enabled
|
||||
if (empty($CFG->enablegroupings)) {
|
||||
$cm->groupingid = 0;
|
||||
}
|
||||
|
||||
if (!$groupmode = groups_get_activity_groupmode($cm)) {
|
||||
// NOGROUPS used
|
||||
return false;
|
||||
|
@ -807,7 +782,7 @@ function groups_course_module_visible($cm, $userid=null) {
|
|||
if (empty($userid)) {
|
||||
$userid = $USER->id;
|
||||
}
|
||||
if (empty($CFG->enablegroupings)) {
|
||||
if (empty($CFG->enablegroupmembersonly)) {
|
||||
return true;
|
||||
}
|
||||
if (empty($cm->groupmembersonly)) {
|
||||
|
|
|
@ -2216,7 +2216,7 @@ function require_login($courseorid=0, $autologinguest=true, $cm=null, $setwantsu
|
|||
}
|
||||
|
||||
/// groupmembersonly access control
|
||||
if (!empty($CFG->enablegroupings) and $cm and $cm->groupmembersonly and !has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_MODULE, $cm->id))) {
|
||||
if (!empty($CFG->enablegroupmembersonly) and $cm and $cm->groupmembersonly and !has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_MODULE, $cm->id))) {
|
||||
if (isguestuser() or !groups_has_membership($cm)) {
|
||||
print_error('groupmembersonlyerror', 'group', $CFG->wwwroot.'/course/view.php?id='.$cm->course);
|
||||
}
|
||||
|
@ -2393,7 +2393,7 @@ function require_course_login($courseorid, $autologinguest=true, $cm=null, $setw
|
|||
if ($cm and empty($cm->visible)) {
|
||||
// hidden activities are not accessible without login
|
||||
require_login($courseorid, $autologinguest, $cm, $setwantsurltome);
|
||||
} else if ($cm and !empty($CFG->enablegroupings) and $cm->groupmembersonly) {
|
||||
} else if ($cm and !empty($CFG->enablegroupmembersonly) and $cm->groupmembersonly) {
|
||||
// not-logged-in users do not have any group membership
|
||||
require_login($courseorid, $autologinguest, $cm, $setwantsurltome);
|
||||
} else {
|
||||
|
@ -2841,7 +2841,7 @@ function &get_fast_modinfo(&$course, $userid=0) {
|
|||
if ((!$cm->visible or !$cm->available) and !has_capability('moodle/course:viewhiddenactivities', $modcontext, $userid)) {
|
||||
$cm->uservisible = false;
|
||||
|
||||
} else if (!empty($CFG->enablegroupings) and !empty($cm->groupmembersonly)
|
||||
} else if (!empty($CFG->enablegroupmembersonly) and !empty($cm->groupmembersonly)
|
||||
and !has_capability('moodle/site:accessallgroups', $modcontext, $userid)) {
|
||||
if (is_null($modinfo->groups)) {
|
||||
$modinfo->groups = groups_get_user_groups($course->id, $userid);
|
||||
|
|
|
@ -1248,8 +1248,6 @@ get_string('configmemcachedpconn', 'admin', NULL);
|
|||
get_string('no', '', NULL);
|
||||
get_string('yes', '', NULL);
|
||||
get_string('registration', 'admin', NULL);
|
||||
get_string('enablegroupings', 'admin', NULL);
|
||||
get_string('configenablegroupings', 'admin', NULL);
|
||||
get_string('enableoutcomes', 'grades', NULL);
|
||||
get_string('configenableoutcomes', 'grades', NULL);
|
||||
get_string('usetags', 'admin', NULL);
|
||||
|
|
|
@ -1248,8 +1248,6 @@ old_get_string('configmemcachedpconn', 'admin', NULL);
|
|||
old_get_string('no', '', NULL);
|
||||
old_get_string('yes', '', NULL);
|
||||
old_get_string('registration', 'admin', NULL);
|
||||
old_get_string('enablegroupings', 'admin', NULL);
|
||||
old_get_string('configenablegroupings', 'admin', NULL);
|
||||
old_get_string('enableoutcomes', 'grades', NULL);
|
||||
old_get_string('configenableoutcomes', 'grades', NULL);
|
||||
old_get_string('usetags', 'admin', NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue