"unenrol me" buttons on user pages and course pages.
<?php print_string("configteacherassignteachers") ?>
</td>
</tr>
+<tr valign=top>
+ <td align=right><p>allowunenroll:</td>
+ <td>
+ <?php
+ unset($options);
+ $options[0] = get_string("no");
+ $options[1] = get_string("yes");
+
+ choose_from_menu ($options, "allowunenroll", $config->allowunenroll, "", "", "");
+ ?>
+ </td>
+ <td>
+ <?php print_string("configallowunenroll") ?>
+ </td>
+</tr>
<tr valign=top>
<td align=right><p>maxbytes:</td>
<td>
$admindata[]="<a href=\"$CFG->changepassword\">".get_string("changepassword")."...</a>";
$adminicon[]="<img src=\"$CFG->pixpath/i/user.gif\" height=16 width=16 alt=\"\">";
}
- $admindata[]="<a href=\"unenrol.php?id=$course->id\">".get_string("unenrolme", "", $course->shortname)."...</a>";
+ if ($CFG->allowunenroll) {
+ $admindata[]="<a href=\"unenrol.php?id=$course->id\">".get_string("unenrolme", "", $course->shortname)."...</a>";
+ }
$adminicon[]="<img src=\"$CFG->pixpath/i/user.gif\" height=16 width=16 alt=\"\">";
}
error("You must be a teacher to do this");
}
+ if ($user->id == $USER->id and !$CFG->allowunenroll) {
+ error("You are not allowed to unenroll");
+ }
+
if (isset($confirm)) {
if (! unenrol_student($user->id, $course->id)) {
$string['closewindow'] = "Close this window";
$string['comparelanguage'] = "Compare and edit current language";
$string['complete'] = "Complete";
+$string['configallowunenroll'] = "If this is set 'Yes', then students are allowed to unenroll themselves from courses whenever they like. Otherwise they are not allowed, and this process will be solely controlled by the teachers and administrators.";
$string['configcountry'] = "If you set a country here, then this country will be selected by default on new user accounts. To force users to choose a country, just leave this unset.";
$string['configdebug'] = "If you turn this on, then PHP's error_reporting will be increased so that more warnings are printed. This is only useful for developers.";
$string['configgdversion'] = "Indicate the version of GD that is installed. The version shown by default is the one that has been auto-detected. Don't change this unless you really know what you're doing.";
$defaults = array (
"auth" => "email",
+ "allowunenroll" => true,
"changepassword" => true,
"country" => "",
"debug" => 7,
}
}
if ($course->category and
- ((isstudent($course->id) and ($user->id == $USER->id) and !isguest()) or
+ ((isstudent($course->id) and ($user->id == $USER->id) and !isguest() and $CFG->allowunenroll) or
(isteacher($course->id) and isstudent($course->id, $user->id))) ) {
echo "<TD NOWRAP><P><FORM ACTION=\"../course/unenrol.php\" METHOD=GET>";
echo "<INPUT type=hidden name=id value=\"$course->id\">";