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)) {
$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.';