Commit 16c33ec1 authored by Brett Wilkins's avatar Brett Wilkins

MaharaAuthPlugin: give admin users sysop privileges if admin in mahara

parent 465e0899
......@@ -80,7 +80,7 @@ class MaharaAuthPlugin extends AuthPlugin {
public function authenticate( $username, $password ) {
$username = strtolower($username);
$db = $this->getDatabase();
$sql = "SELECT username, password, salt FROM ".$this->prefix."usr where LOWER(username) = '".$username."'";
$sql = "SELECT username, password, salt FROM ".$this->prefix."usr where LOWER(username) = '".$username."' and deleted != 1";
$res = $db->query($sql);
$val = $db->fetchObject($res);
$db->close();
......@@ -143,6 +143,11 @@ class MaharaAuthPlugin extends AuthPlugin {
$user->setOption('nickname',$val->username);
$user->setEmail($val->email);
$user->setRealName($val->firstname.' '.$val->lastname);
if ($val->admin == 1) {
$user->addGroup('sysop');
} else if (in_array('sysop',$user->getGroups)) {
$user->removeGroup('sysop');
}
return true;
}
......@@ -259,15 +264,7 @@ class MaharaAuthPlugin extends AuthPlugin {
* @param $autocreate bool True if user is being autocreated on login
*/
public function initUser( &$user, $autocreate=false ) {
$username = strtolower($user->mName);
$db = $this->getDatabase();
$sql = "SELECT * FROM ".$this->prefix."usr where LOWER(username) = '".$username."'";
$res = $db->query($sql);
$val = $db->fetchObject($res);
$db->close();
$user->setOption('nickname',$val->username);
$user->setEmail($val->email);
$user->setRealName($val->firstname.' '.$val->lastname);
return $this->updateUser($user);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment