Advertisement
NFL

Untitled

NFL
May 23rd, 2012
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. <?php
  2. class Base_Admin extends Zend_Controller_Action {
  3.    
  4.     const ROLE_ADMIN = 'admin';
  5.     const ROLE_USER = 'user';
  6.     const ROLE_GUEST = 'guest';
  7.    
  8.     public function init() {
  9.         $requestUri = $this->getRequest ()->getServer ( 'REQUEST_URI' );
  10.         $auth = Zend_Auth::getInstance ();
  11.         //exit($auth->getIdentity()->role);
  12.         if (! $auth->hasIdentity ()) {
  13.             return $this->_redirect ( '/user/login' );
  14.         } else {
  15.             $identity = $auth->getIdentity ();
  16.             $role = ! empty ( $identity->role ) ? $identity->role : self::ROLE_GUEST;
  17.             if ($role == self::ROLE_GUEST) {
  18.                 return $this->_redirect ( '/' );
  19.             }
  20.             if ($role == self::ROLE_USER) {
  21.                 return $this->_redirect ( '/user/index' );
  22.             }      
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement