示例#1
0
 /**
  * Loads the currently active accessor into this instance
  * @return bool
  */
 function LoadCurrent()
 {
     $this->user = null;
     $userID = null;
     if (isset($_SESSION[self::$sessionParam])) {
         $userID = $_SESSION[self::$sessionParam];
     }
     if ($userID) {
         $user = new User($userID);
         if ($user->Exists()) {
             $this->user = $user;
         }
     }
     return $this->user !== null;
 }
示例#2
0
 /**
  * Gets the first user that is an admin
  * @return User The admin user, if present
  */
 private function FirstAdmin()
 {
     $sql = Access::SqlBuilder();
     $tblUser = User::Schema()->Table();
     $where = $sql->Equals($tblUser->Field('IsAdmin'), $sql->Value(true));
     $orderBy = $sql->OrderList($sql->OrderAsc($tblUser->Field('ID')));
     return User::Schema()->First($where, $orderBy);
 }
示例#3
0
 private function SavePassword()
 {
     $password = $this->Value('Password');
     if ($password) {
         $salt = String::Start(md5(uniqid(microtime())), 8);
         $pwHash = hash('sha256', $password . $salt);
         $this->user->SetPassword($pwHash);
         $this->user->SetPasswordSalt($salt);
     }
 }
 private function UserGroupWhere(Usergroup $group)
 {
     $sql = Access::SqlBuilder();
     $tblUug = UserUsergroup::Schema()->Table();
     return $sql->Equals($tblUug->Field('User'), $sql->Value($this->user->GetID()))->And_($sql->Equals($tblUug->Field('UserGroup'), $sql->Value($group->GetID())));
 }
示例#5
0
 /**
  * Gets the site for removal if delete id is posted
  * @return User
  */
 protected function RemovalObject()
 {
     $id = Request::PostData('delete');
     return $id ? User::Schema()->ByID($id) : null;
 }