Permalink
Browse files

A new configuration parameter 'allowunenroll' will enable/disable the

"unenrol me" buttons on user pages and course pages.
  • Loading branch information...
1 parent 7267053 commit 5204d8316aab2c066fac839eb6f9deee9d0a2461 moodler committed Oct 12, 2003
Showing with 25 additions and 2 deletions.
  1. +15 −0 admin/config.html
  2. +3 −1 course/lib.php
  3. +4 −0 course/unenrol.php
  4. +1 −0 lang/en/moodle.php
  5. +1 −0 lib/defaults.php
  6. +1 −1 user/view.php
View
@@ -300,6 +300,21 @@
<?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>
View
@@ -870,7 +870,9 @@ function print_course_admin_links($course, $width=180) {
$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=\"\">";
}
View
@@ -24,6 +24,10 @@
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)) {
View
@@ -107,6 +107,7 @@
$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.";
View
@@ -5,6 +5,7 @@
$defaults = array (
"auth" => "email",
+ "allowunenroll" => true,
"changepassword" => true,
"country" => "",
"debug" => 7,
View
@@ -150,7 +150,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\">";

0 comments on commit 5204d83

Please sign in to comment.