Removed all of the "Restricted users" hack because Roles can do it all better.

This commit is contained in:
moodler 2006-08-13 07:01:57 +00:00
parent f633ae28ae
commit bade10e350
15 changed files with 3 additions and 80 deletions

View File

@ -54,11 +54,6 @@
$tabsmode = 'assign';
include_once('tabs.php');
/// Don't allow restricted teachers to even see this page (because it contains
/// a lot of email addresses and access to all student on the server
check_for_restricted_user($USER->username, $CFG->wwwroot);
/// Print a help notice about the need to use this page
if (!$frm = data_submitted()) {
@ -151,4 +146,4 @@
}
print_footer($course);
?>
?>

View File

@ -93,8 +93,6 @@
error("Course ID was incorrect (can't find it)");
}
check_for_restricted_user($USER->username, "$CFG->wwwroot/course/view.php?id=$course->id");
//Print header
if (isadmin()) {
print_header("$site->shortname: $strcoursebackup", $site->fullname,

View File

@ -115,8 +115,6 @@
error("Course ID was incorrect (can't find it)");
}
check_for_restricted_user($USER->username, "$CFG->wwwroot/course/view.php?id=$course->id");
//Print header
if (isadmin()) {
print_header("$site->shortname: $strcourserestore", $site->fullname,

View File

@ -232,7 +232,7 @@ class block_admin extends block_list {
}
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" alt="" />';
if (is_internal_auth() && !is_restricted_user($USER->username)) {
if (is_internal_auth()) {
$this->content->items[]='<a href="'.$securewwwroot.'/login/change_password.php?id='.$this->instance->pageid.'">'.get_string('changepassword').'</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" alt="" />';
}

View File

@ -139,10 +139,6 @@ $CFG->admin = 'admin';
// Useful for webhost operators who have alternate methods of backups
// $CFG->disablescheduledbackups = true;
//
// Restrict certain usernames from doing things that may mess up a site
// This is especially useful for demonstration teacher accounts
// $CFG->restrictusers = 'teacher,fred,jim';
//
// Set global password for "Login as", teacher is prompted only once in each session.
// Set your own password and tell it only to teachers that should have access to this feature.
// $CFG->loginaspassword = 'yoursharedpassword';

View File

@ -57,12 +57,6 @@
if ($form = data_submitted() and confirm_sesskey()) {
if (empty($course)) {
check_for_restricted_user($USER->username, "$CFG->wwwroot");
} else {
check_for_restricted_user($USER->username, "$CFG->wwwroot/course/view.php?id=$course->id");
}
$form->startdate = make_timestamp($form->startyear, $form->startmonth, $form->startday);
$form->category = clean_param($form->category, PARAM_INT);

View File

@ -20,7 +20,6 @@
error("Could not find a site!");
}
check_for_restricted_user($USER->username);
/// Refreshing enrolment data in the USER session
if (!($plugins = explode(',', $CFG->enrol_plugins_enabled))) {

View File

@ -51,10 +51,6 @@
"<a href=\"view.php?id=$course->id\">$course->shortname</a> -> $strassigncourses",
"studentform.searchtext");
/// Don't allow restricted teachers to even see this page (because it contains
/// a lot of email addresses and access to all student on the server
check_for_restricted_user($USER->username, "$CFG->wwwroot/course/view.php?id=$course->id");
/// Print a help notice about the need to use this page

View File

@ -50,8 +50,6 @@
error("Only teachers can use this page!");
}
check_for_restricted_user($USER->username, "$CFG->wwwroot/user/view.php?id=$user&amp;course=$course->id");
// validate loginaspassword if defined in config.php
if (empty($SESSION->loginasvalidated) && !empty($CFG->loginaspassword)) {

View File

@ -55,10 +55,6 @@
"<a href=\"view.php?id=$course->id\">$course->shortname</a> -> $strassignstudents",
"studentform.searchtext");
/// Don't allow restricted teachers to even see this page (because it contains
/// a lot of email addresses and access to all student on the server
check_for_restricted_user($USER->username, "$CFG->wwwroot/course/view.php?id=$course->id");
/// Print a help notice about the need to use this page

View File

@ -1808,46 +1808,6 @@ function reset_login_count() {
$SESSION->logincount = 0;
}
/**
* check_for_restricted_user
*
* @uses $CFG
* @uses $USER
* @param string $username ?
* @param string $redirect ?
* @todo Finish documenting this function
*/
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', 'error', fullname($USER)), $redirect);
}
}
}
function is_restricted_user($username){
global $CFG;
if (!empty($CFG->restrictusers)) {
$names = explode(',', $CFG->restrictusers);
if (in_array($username, $names)) {
return true;
}
}
return false;
}
function sync_metacourses() {
global $CFG;

View File

@ -21,8 +21,6 @@
if ($frm = data_submitted()) {
validate_form($frm, $err);
check_for_restricted_user($frm->username);
update_login_count();
if (!count((array)$err)) {

View File

@ -124,7 +124,6 @@
/// Check if the Form has been submitted and display confirmation
////////////////////////////////////////////////////////////
if ($form = data_submitted()) {
check_for_restricted_user($USER->username, "$CFG->wwwroot/course/view.php?id=$course->id");
/// Moodle Log
/// Get additional info
$addloginfo="";

View File

@ -86,10 +86,6 @@
}
}
if (isset($USER->username)) {
check_for_restricted_user($USER->username, "$CFG->wwwroot/course/view.php?id=$course->id");
}
if (isset($usernew->password)) {
unset($usernew->password);
}

View File

@ -300,7 +300,7 @@
// Print other functions
echo '<div class="buttons"><table align="center"><tr>';
if ($currentuser and !isguest() and !is_restricted_user($USER->username)) {
if ($currentuser and !isguest()) {
if ($internalpassword ) {
echo "<td nowrap=\"nowrap\"><form action=\"$internalpassword\" method=\"get\">";
echo "<input type=\"hidden\" name=\"id\" value=\"$course->id\" />";