From 5204d8316aab2c066fac839eb6f9deee9d0a2461 Mon Sep 17 00:00:00 2001 From: moodler Date: Sun, 12 Oct 2003 18:03:50 +0000 Subject: [PATCH] A new configuration parameter 'allowunenroll' will enable/disable the "unenrol me" buttons on user pages and course pages. --- admin/config.html | 15 +++++++++++++++ course/lib.php | 4 +++- course/unenrol.php | 4 ++++ lang/en/moodle.php | 1 + lib/defaults.php | 1 + user/view.php | 2 +- 6 files changed, 25 insertions(+), 2 deletions(-) diff --git a/admin/config.html b/admin/config.html index 2848bbd299..162151a7b9 100644 --- a/admin/config.html +++ b/admin/config.html @@ -300,6 +300,21 @@ + +

allowunenroll: + + allowunenroll, "", "", ""); + ?> + + + + +

maxbytes: diff --git a/course/lib.php b/course/lib.php index 3aa5068b5c..c3e756a85d 100644 --- a/course/lib.php +++ b/course/lib.php @@ -870,7 +870,9 @@ function print_course_admin_links($course, $width=180) { $admindata[]="changepassword\">".get_string("changepassword")."..."; $adminicon[]="pixpath/i/user.gif\" height=16 width=16 alt=\"\">"; } - $admindata[]="id\">".get_string("unenrolme", "", $course->shortname)."..."; + if ($CFG->allowunenroll) { + $admindata[]="id\">".get_string("unenrolme", "", $course->shortname)."..."; + } $adminicon[]="pixpath/i/user.gif\" height=16 width=16 alt=\"\">"; } diff --git a/course/unenrol.php b/course/unenrol.php index d9eb241244..a50662f7a2 100644 --- a/course/unenrol.php +++ b/course/unenrol.php @@ -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)) { diff --git a/lang/en/moodle.php b/lang/en/moodle.php index f7142d624c..71002d6dbe 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -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."; diff --git a/lib/defaults.php b/lib/defaults.php index 97223907dc..3a892a9027 100644 --- a/lib/defaults.php +++ b/lib/defaults.php @@ -5,6 +5,7 @@ $defaults = array ( "auth" => "email", + "allowunenroll" => true, "changepassword" => true, "country" => "", "debug" => 7, diff --git a/user/view.php b/user/view.php index 488b725ebe..7b3d8a028a 100644 --- a/user/view.php +++ b/user/view.php @@ -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 "

"; echo "id\">"; -- 2.39.5