Exemplo n.º 1
0
 /**
  * Check action
  *
  * @return void
  */
 public function checkAction()
 {
     $request = $this->getRequest();
     $params = $request->getParams();
     $result = null;
     $user = null;
     if (isset($params['userId'])) {
         $user = UserService::findOneById($params['userId']);
         unset($params['userId']);
     }
     foreach ($params as $key => $value) {
         switch ($key) {
             case 'username':
                 if (null !== $user && $user->getUsername() === $value) {
                     $result = true;
                 } else {
                     $result = null === UserService::findOneByUsername(strtolower($value)) && null === AclRoleService::findOneByName(strtolower($value));
                 }
                 break;
             case 'email':
                 if ($user && $user->getEmail() === $value) {
                     $result = true;
                 } else {
                     $result = null === UserService::findOneByEmail(strtolower($value));
                 }
                 break;
         }
         if ($result !== null) {
             $this->getHelper('layout')->disableLayout();
             $this->getHelper('ViewRenderer')->setNoRender();
             #$jsonData = Zend_Json::encode($result);
             $jsonData = Zend_Json::encode(array($key, $result));
             $this->getResponse()->setBody($jsonData);
             break;
             // Exit for-loop early
         }
     }
 }