]> git.mjollnir.org Git - moodle.git/commitdiff
New function to restrict defined users
authormoodler <moodler>
Fri, 30 Jan 2004 08:25:49 +0000 (08:25 +0000)
committermoodler <moodler>
Fri, 30 Jan 2004 08:25:49 +0000 (08:25 +0000)
lib/moodlelib.php

index 259331a4a2c4b34d82e61900303303ccd29acaf2..767e835c582b116fd87b3b170182b3bb6517f6a8 100644 (file)
@@ -464,6 +464,25 @@ function reset_login_count() {
     $SESSION->logincount = 0;
 }
 
+function check_for_restricted_user($username=NULL, $redirect="") {
+    global $CFG, $USER;
+
+    if (!$username) {
+        if (!empty($USER->username)) {
+            $username = $USER->username;
+        } else {
+            return false;
+        }
+    }
+
+    if (!empty($CFG->restrictusers)) {
+        $names = explode(',', $CFG->restrictusers);
+        if (in_array($username, $names)) {
+            error(get_string("restricteduser"), $redirect);
+        }
+    }
+}
+
 function isadmin($userid=0) {
 /// Is the user an admin?
     global $USER;