From: moodler Date: Thu, 21 Sep 2006 16:11:31 +0000 (+0000) Subject: People under switched roles should not be able to unenrol X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=8cb5bc2b266bd3509e84c9873ac3efedc1384b3a;p=moodle.git People under switched roles should not be able to unenrol --- diff --git a/course/unenrol.php b/course/unenrol.php index 742a04c54d..d33fa84f28 100644 --- a/course/unenrol.php +++ b/course/unenrol.php @@ -22,11 +22,15 @@ require_login($course->id); if ($course->metacourse) { - print_error('cantunenrollfrommetacourse'); + print_error('cantunenrollfrommetacourse', '', $CFG->wwwroot.'/course/view.php?id='.$course->id); } else { require_capability('moodle/role:unassignself', $context, NULL, false); } + if (!empty($USER->switchrole[$context->id])) { + print_error('cantunenrollinthisrole', '', $CFG->wwwroot.'/course/view.php?id='.$course->id); + } + if ($confirm and confirm_sesskey()) { if (! role_unassign(0, $USER->id, 0, $context->id)) { diff --git a/lang/en_utf8/error.php b/lang/en_utf8/error.php index 5e189eafd1..9277ea5a73 100644 --- a/lang/en_utf8/error.php +++ b/lang/en_utf8/error.php @@ -10,6 +10,8 @@ $string['cannotfindcomponent'] = 'Cannot find component.'; $string['cannotsavezipfile'] = 'Cannot save ZIP file.'; $string['cannotunzipfile'] = 'Cannot unzip file.'; $string['cannotsavemd5file'] = 'Cannot save md5 file.'; +$string['cantunenrollinthisrole'] = 'You can not unenrol from this course while you are in your current role.'; +$string['cantunenrollfrommetacourse'] = 'You can not unenrol from this meta course.'; $string['coursegroupunknown'] = 'Course corresponding to group $a not specified'; $string['cmunknown'] = 'Couldn\'t find this course module'; $string['componentisuptodate'] = 'Component is up to date.';