AccessControl.php
00001 <?php
00009 class Dsao_Controller_Action_Helper_AccessControl
00010 extends Zend_Controller_Action_Helper_Abstract
00011 {
00016 protected $_acl = null;
00017
00023 public function preDispatch()
00024 {
00025
00026 if (null === $this->_acl)
00027 {
00028 $this->_acl = Dsao_Registry::get('acl');
00029 }
00030
00031
00032 $roleCurrent = $this->getActionController()->getUser()->getData('role', 'guest');
00033
00034
00035 $filterAcl = new Dsao_Filter_Acl($roleCurrent, $this->_acl);
00036
00037
00038
00039 if ($filterAcl->filter(array($this->getActionController()->getUri())))
00040 {
00041 return true;
00042 }
00043
00044 else if (!Zend_Auth::getInstance()->hasIdentity())
00045 {
00046
00047 $redirectLink = str_replace('/', '_', $this->getActionController()
00048 ->getUri()->getUriString());
00049
00050
00051 $this->getActionController()->forward
00052 ('login', 'login', 'user', array('redirect' => $redirectLink));
00053
00054 return false;
00055 }
00056
00057
00058 $this->getActionController()->forward('privileges', 'error', 'default');
00059
00060 return false;
00061 }
00062 }