From a67dd90008ea023cb5b7a59fb0f87afce840fa70 Mon Sep 17 00:00:00 2001 From: paca70 Date: Wed, 13 Oct 2004 07:27:34 +0000 Subject: [PATCH] Prevent auth_iscreator from overriding users course creation status --- auth/ldap/lib.php | 2 +- lib/moodlelib.php | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/auth/ldap/lib.php b/auth/ldap/lib.php index 212b977f6e1..6789587f9a6 100644 --- a/auth/ldap/lib.php +++ b/auth/ldap/lib.php @@ -368,7 +368,7 @@ function auth_iscreator($username=0) { } if ((! $CFG->ldap_creators) OR (! $CFG->ldap_memberattribute)) { - return false; + return null; } return auth_ldap_isgroupmember($username, $CFG->ldap_creators); diff --git a/lib/moodlelib.php b/lib/moodlelib.php index f76b0567673..63c83390a15 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -949,20 +949,23 @@ function authenticate_user_login($username, $password) { } if (function_exists('auth_iscreator')) { // Check if the user is a creator - if (auth_iscreator($username)) { - if (! record_exists("user_coursecreators", "userid", $user->id)) { - $cdata->userid = $user->id; - if (! insert_record("user_coursecreators", $cdata)) { - error("Cannot add user to course creators."); + $useriscreator=auth_iscreator($username); + if(!is_null($useriscreator)) { + if ($useriscreator) { + if (! record_exists("user_coursecreators", "userid", $user->id)) { + $cdata->userid = $user->id; + if (! insert_record("user_coursecreators", $cdata)) { + error("Cannot add user to course creators."); + } + } + } else { + if ( record_exists("user_coursecreators", "userid", $user->id)) { + if (! delete_records("user_coursecreators", "userid", $user->id)) { + error("Cannot remove user from course creators."); + } } } - } else { - if ( record_exists("user_coursecreators", "userid", $user->id)) { - if (! delete_records("user_coursecreators", "userid", $user->id)) { - error("Cannot remove user from course creators."); - } - } - } + } } return $user;