properties of Zend_Navigation_Page_Mvc to map the resource and privilege on
an action by action basis. Your helper could find the currently active page,
and query the acl using the given resource/privilege settings, and perhaps
default to the controller name = resource and action name = privilege if
none are provided.
If you were to do this...
I did this and ran into a problem with using the action view helper.
Something about the way Zend_Navigation_Page_Mvc and the actioned request
object interacted didn't quite work, it was still finding the
original/landing page. I worked around this by writing a small helper that
extends Zend_View_Helper_Navigation_HelperAbstract, with these methods to
determine the active page:
public function isCurrentlyActive($page, $currentRequest)
{
if($page->getAction() == $currentRequest->getActionName()) {
if($page->getController() == $currentRequest->getControllerName()) {
$pageModule = $page->getModule();
$pageModule = $pageModule == null ? 'default' : $pageModule;
$requestModule = $currentRequest->getModuleName();
$requestModule = $requestModule == null ? 'default' : $requestModule;
if($pageModule == $requestModule) {
$pageParams = $page->getParams();
if
(count(array_intersect_assoc($currentRequest->getParams(), $pageParams )) ==
count($pageParams )) {
return true;
}
}
}
}
return false;
}
public function findCurrentlyActive(Zend_Controller_Request_Abstract
$request = null)
{
$container = $this->getContainer();
if($request == null) {
$request = Zend_Controller_Front::getInstance()->getRequest();
}
$iterator = new RecursiveIteratorIterator($container,
RecursiveIteratorIterator::CHILD_FIRST);
foreach ($iterator as $page) {
if ($this->isCurrentlyActive($page, $request)) {
$this->setCurrentlyActive($page);
return $page;
}
}
return null;
}
--
View this message in context: http://n4.nabble.com/ACL-but-completely-different-tp1299970p1310968.html
Sent from the Zend Auth mailing list archive at Nabble.com.
没有评论:
发表评论