Piwik\Plugins\UsersManager\Model::userExists PHP Method

userExists() public method

public userExists ( $userLogin )
    public function userExists($userLogin)
    {
        $db = $this->getDb();
        $count = $db->fetchOne("SELECT count(*) FROM " . $this->table . " WHERE login = ?", $userLogin);
        return $count != 0;
    }

Usage Example

Example #1
0
 /**
  * Returns true if the given userLogin is known in the database
  *
  * @param string $userLogin
  * @return bool true if the user is known
  */
 public function userExists($userLogin)
 {
     if ($userLogin == 'anonymous') {
         return true;
     }
     Piwik::checkUserIsNotAnonymous();
     Piwik::checkUserHasSomeViewAccess();
     if ($userLogin == Piwik::getCurrentUserLogin()) {
         return true;
     }
     return $this->model->userExists($userLogin);
 }