exists() public static method

Does the user exist.
public static exists ( integer $id, boolean $active = true ) : boolean
$id integer The userId to check for existence.
$active boolean Should the user be active also?
return boolean
Ejemplo n.º 1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     $this->id = $this->getParameter('id', 'int');
     $error = $this->getParameter('error', 'string');
     $this->loadAuthenticatedUser();
     // If id and error parameters are not set we'll assume the user logged in
     // and has been redirected to this action by the authentication index action.
     // When this is the case the user will be redirected to the index action of this module.
     // An action to which he may not have any user rights.
     // Redirect to the user's own profile instead to avoid unnessary words.
     if ($this->id === null && $error === null && $this->authenticatedUser->getUserId()) {
         $this->redirect(BackendModel::createURLForAction('Edit') . '&id=' . $this->authenticatedUser->getUserId());
     }
     // does the user exists
     if ($this->id !== null && BackendUsersModel::exists($this->id)) {
         parent::execute();
         $this->record = (array) BackendUsersModel::get($this->id);
         $this->loadForm();
         $this->validateForm();
         $this->parse();
         $this->display();
     } else {
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
     }
 }
Ejemplo n.º 2
0
 /**
  * Execute the action
  */
 public function execute()
 {
     // get parameters
     $this->id = $this->getParameter('id', 'int');
     // does the user exist
     if ($this->id !== null && BackendUsersModel::exists($this->id) && BackendAuthentication::getUser()->getUserId() != $this->id) {
         parent::execute();
         // get data
         $user = new BackendUser($this->id);
         // God-users can't be deleted
         if ($user->isGod()) {
             $this->redirect(BackendModel::createURLForAction('Index') . '&error=cant-delete-god');
         }
         // delete item
         BackendUsersModel::delete($this->id);
         // trigger event
         BackendModel::triggerEvent($this->getModule(), 'after_delete', array('id' => $this->id));
         // item was deleted, so redirect
         $this->redirect(BackendModel::createURLForAction('Index') . '&report=deleted&var=' . $user->getSetting('nickname'));
     } else {
         $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing');
     }
 }