示例#1
0
 /**
  * AdminController::userList()
  * List all the users
  * @return void
  */
 protected function userList()
 {
     $oUser = new APP_Model_User();
     $sFilteredBy = null;
     $aClauses = array();
     if (($iRoleFilter = $this->get('rolefilter', '')) !== '') {
         $sFilteredBy = PPI_Helper_User::getRoleNameNice(PPI_Helper_User::getRoleNameFromID($iRoleFilter));
         $aClauses[] = 'role_id = ' . $oUser->quote($iRoleFilter);
     }
     // Get the users
     $users = $oUser->getList(!empty($aClauses) ? implode(' AND ', $aClauses) : '')->fetchAll();
     // If there was a filter applied but returned no results, we default the userlist back to normal
     foreach ($users as $key => $user) {
         $users[$key]['role_name'] = PPI_Helper_User::getRoleNameFromID($user['role_id']);
     }
     $sUsernameField = $this->getConfig()->system->usernameField;
     $this->adminLoad('admin/user_list', compact('users', 'sFilteredBy', 'sUsernameField'));
 }
示例#2
0
 /**
  * Login function for the user, passing the username and password.
  * @param string $username The username (the value of the usernameField from the config)
  * @param string $password The plaintext password
  * @return boolean
  */
 function login($username, $password)
 {
     $oConfig = $this->getConfig();
     $user = $this->fetch($oConfig->system->usernameField . ' = ' . $this->quote($username));
     if (!empty($user)) {
         if ($this->encryptPassword($oConfig->system->userAuthSalt, $password) === $user['password']) {
             if (array_key_exists('password', $user)) {
                 unset($user['password']);
             }
             $user['role_name'] = PPI_Helper_User::getRoleNameFromID($user['role_id']);
             $user['role_name_nice'] = PPI_Helper_User::getRoleNameNice($user['role_name']);
             $this->getSession()->setAuthData($user);
             return true;
         }
     }
     return false;
 }