Merged MDL-13152 from 1.9

This commit is contained in:
moodler
2008-02-14 03:15:03 +00:00
parent 874e184158
commit b225cf3663
+10 -2
View File
@@ -656,8 +656,16 @@ if ($formdata = $mform->is_cancelled()) {
// group exists?
$addgroup = $user->{'group'.$i};
if (!array_key_exists($addgroup, $ccache[$shortname]->groups)) {
$upt->track('enrolments', get_string('unknowgroup', 'error', $addgroup), 'error');
continue;
// if group doesn't exist, create it
$newgroupdata = new object();
$newgroupdata->name = $addgroup;
$newgroupdata->courseid = $ccache[$shortname]->id;
if ($ccache[$shortname]->groups[$addgroup]->id = groups_create_group($newgroupdata)){
$ccache[$shortname]->groups[$addgroup]->name = $newgroupdata->name;
} else {
$upt->track('enrolments', get_string('unknowngroup', 'error', $addgroup), 'error');
continue;
}
}
$gid = $ccache[$shortname]->groups[$addgroup]->id;
$gname = $ccache[$shortname]->groups[$addgroup]->name;