Ejemplo n.º 1
0
 /**
  * Determines whether a page should be accepted when iterating using ACL
  * 
  * Validates that the role set in helper inherits or is the same as
  * the role(s) found in the page
  * 
  * @param Zym_Navigation_Page $page  page to check
  * @param bool $recursive  [optional] whether it should check recursively
  * @return bool
  */
 protected function _acceptAcl(Zym_Navigation_Page $page, $recursive = true)
 {
     if (!($acl = $this->getAcl())) {
         // no acl registered means don't use acl
         return true;
     }
     // do not accept by default
     $accept = false;
     // do not accept if helper has no role
     if ($role = $this->getRole()) {
         $resource = $page->getResource();
         $privilege = $page->getPrivilege();
         if ($resource || $privilege) {
             // determine using helper role and page resource/privilege
             $accept = $this->getAcl()->isAllowed($role, $resource, $privilege);
         } else {
             // accept if page has no resource or privilege
             $accept = true;
         }
     }
     // loop parent(s) recursively if page is accepted and recurisve is true
     if ($accept && $recursive) {
         $parent = $page->getParent();
         if ($parent instanceof Zym_Navigation_Page) {
             $accept = $this->_acceptAcl($parent, true);
         }
     }
     return $accept;
 }