コード例 #1
0
ファイル: UserEditLink.php プロジェクト: rexmac/zyndax
 /**
  * Render user edit link
  *
  * @param Rexmac\Zyndax\Entity\User|int $user User entity or ID
  * @return string
  */
 public function userEditLink($user = null)
 {
     if (is_numeric($user)) {
         $user = UserService::findOneById($user);
     }
     if (null === $user) {
         return '';
     }
     if (!Zend_Registry::get('acl')->isUserAllowed('mvc:admin:users:edit', 'view')) {
         return $this->view->escape($user->getUsername());
     }
     return sprintf('<a href="%s" title="Edit user">%s</a>', $this->view->url(array('userId' => $user->getId()), 'adminUserEdit'), $this->view->escape($user->getUsername()));
 }
コード例 #2
0
ファイル: UserController.php プロジェクト: rexmac/zyndax
 /**
  * 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
         }
     }
 }
コード例 #3
0
ファイル: UsersController.php プロジェクト: rexmac/zyndax
 /**
  * Login-as action
  *
  * @return void
  */
 public function loginasAction()
 {
     $request = $this->getRequest();
     if (null === ($user = UserService::findOneById($request->getParam('userId')))) {
         throw new Exception('Invalid user ID');
     }
     // Need to avoid admin users
     if ($user->isAdmin()) {
         #throw new Exception('Invalid user ID');
         throw new Exception('Cannot login-as admin user');
     }
     // "Authenticate" as user
     $authCookieName = Zend_Registry::get('config')->session->auth->name;
     $ssa = new Zend_Session_Namespace($authCookieName);
     $ssa->loginAsUser = $user->getId();
     // Track login-as event
     UserLoginAsEventService::create(array('user' => $this->_user, 'account' => $user, 'date' => new DateTime(), 'ip' => $this->getRequest()->getServer('REMOTE_ADDR')));
     $siteDomain = str_replace('admin.', '', Zend_Registry::get('siteDomain'));
     return $this->_helper->getHelper('Redirector')->gotoUrl('http://' . $siteDomain . '/home');
 }