]> git.mjollnir.org Git - moodle.git/commitdiff
A new configuration parameter 'allowunenroll' will enable/disable the
authormoodler <moodler>
Sun, 12 Oct 2003 18:03:50 +0000 (18:03 +0000)
committermoodler <moodler>
Sun, 12 Oct 2003 18:03:50 +0000 (18:03 +0000)
"unenrol me" buttons on user pages and course pages.

admin/config.html
course/lib.php
course/unenrol.php
lang/en/moodle.php
lib/defaults.php
user/view.php

index 2848bbd29908cb35ec4800b58ed60b036c5bd6cc..162151a7b9ec74a1a35595a9757621e9fc5b6ab9 100644 (file)
     <?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>
index 3aa5068b5c49fbd1518a7f1955ed67269f7f3399..c3e756a85dc3e72023194681e4791fd92da27893 100644 (file)
@@ -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=\"\">";
     } 
 
index d9eb241244a7ccb88fc9e90e8d51c6e4f07a1fc9..a50662f7a2e1518fcec19b20fd2be1e8d08b7dfa 100644 (file)
         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)) {
index f7142d624cb9d8e99be11f6316fb7f9d1442adab..71002d6dbe502e7397e65163d8404f893919c353 100644 (file)
@@ -107,6 +107,7 @@ $string['cleaningtempdata'] = "Cleaning temp data";
 $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.";
index 97223907dceeb564556cd3068aa3d5cdfc5a30e6..3a892a902784416ec84c4be9e28a89a86d937c5e 100644 (file)
@@ -5,6 +5,7 @@
 
    $defaults = array (
        "auth"             => "email",
+       "allowunenroll"    =>  true,
        "changepassword"   =>  true,
        "country"          => "",
        "debug"            =>  7,
index 488b725ebe2b01bfea564b2e5f10e06cee5e23ac..7b3d8a028af54d675e396e5e4119271ee88b910c 100644 (file)
         }
     }
     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\">";