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 { ...@@ -80,7 +80,7 @@ class MaharaAuthPlugin extends AuthPlugin {
public function authenticate( $username, $password ) { public function authenticate( $username, $password ) {
$username = strtolower($username); $username = strtolower($username);
$db = $this->getDatabase(); $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); $res = $db->query($sql);
$val = $db->fetchObject($res); $val = $db->fetchObject($res);
$db->close(); $db->close();
...@@ -143,6 +143,11 @@ class MaharaAuthPlugin extends AuthPlugin { ...@@ -143,6 +143,11 @@ class MaharaAuthPlugin extends AuthPlugin {
$user->setOption('nickname',$val->username); $user->setOption('nickname',$val->username);
$user->setEmail($val->email); $user->setEmail($val->email);
$user->setRealName($val->firstname.' '.$val->lastname); $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; return true;
} }
...@@ -259,15 +264,7 @@ class MaharaAuthPlugin extends AuthPlugin { ...@@ -259,15 +264,7 @@ class MaharaAuthPlugin extends AuthPlugin {
* @param $autocreate bool True if user is being autocreated on login * @param $autocreate bool True if user is being autocreated on login
*/ */
public function initUser( &$user, $autocreate=false ) { public function initUser( &$user, $autocreate=false ) {
$username = strtolower($user->mName); return $this->updateUser($user);
$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);
} }
/** /**
......
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