00001 <?php
00002
00011 class SIplusAuthModule extends SObject {
00012 private $userName;
00013 private $firstName;
00014 private $lastName;
00015 private $email;
00016 private $userId;
00017 private $role;
00018
00026 public function __construct() {
00027 parent::__construct();
00028 }
00029
00039 public function authenticate($username, $password) {
00040
00041 IPModelBase::init();
00042
00043 $users = IPUserRole::getListMulti(array('Base.user.username' => $username,
00044 'Base.user.password' => SWATFunctions::hashPassword(
00045 $password, $GLOBALS['IPLUS_PASSWORD_SALT'])));
00046 if(count($users) == 0)
00047 return false;
00048
00049 $user = $users[0];
00050
00051 # Otherwise, set our values from the CSERD DB
00052 $this->userId = $user->user->id;
00053 $this->userName = $user->user->username;
00054 $this->firstName = $user->user->firstName;
00055 $this->lastName = $user->user->lastName;
00056 $this->email = $user->user->email;
00057 $this->role = array();
00058 foreach($users as $user)
00059 $this->role[] = $user->role->id;
00060
00061 return true;
00062 }
00063
00071 public function getRole() {
00072 return $this->role;
00073 }
00074
00083 public function hasRole($role) {
00084 return in_array($role, $this->role);
00085 }
00086
00094 public function getPermissions() {
00095 return false;
00096 }
00097
00105 public function getUID() {
00106 return $this->userId;
00107 }
00108
00116 public function getFirstName() {
00117 return $this->firstName;
00118 }
00119
00127 public function getLastName() {
00128 return $this->lastName;
00129 }
00130
00131 public function getUserName() {
00132 return $this->userName;
00133 }
00134
00142 public function getEmail() {
00143 return $this->email;
00144 }
00145
00153 public function __sleep() {
00154 return array_keys(get_object_vars($this));
00155 }
00156
00164 public function __wakeup() {
00165 return array_keys(get_object_vars($this));
00166 }
00167
00168 }
00169
00170 ?>