From: moodler Date: Fri, 30 Jan 2004 08:25:49 +0000 (+0000) Subject: New function to restrict defined users X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=cb98d3120c1c3fc6b79bcbacab15606f179127a4;p=moodle.git New function to restrict defined users --- diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 259331a4a2..767e835c58 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -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;