>
> The last argument should be an array of strings.
>
Sorry Matthew I sent you a email by mistake ;)
Thanks for the quick reply.
But I've just a lot of troubles :(
My tree
application
-auth
--controllers
--forms
--views
-categories
--controllers
--forms
--views
-config
--config.ini
--nav.xml
-default
--controllers
--forms
--views
-languages
--en_US.php
--it_IT.php
-layout
--scripts
---layout.phtml
-log
-users
--controllers
--forms
--views
In my bootstrap
protected function _initRouter()
{
$this->bootstrap('frontController');
$front = $this->getResource('frontController');
$front->setControllerDirectory(array(
'default' => APPLICATION_PATH .'/default/controllers',
'auth' => APPLICATION_PATH .'/auth/controllers',
'users' => APPLICATION_PATH .'/users/controllers',
'categories' => APPLICATION_PATH .'/categories/controllers',
));
}
protected function _initPlugins()
{
//Zend_Controller_Action_HelperBroker::addPrefix('W_Controller_Action_Helper');
//$this->bootstrap('frontController');
$front = $this->getResource('frontController');
$acl = new Zend_Acl();
/* Add roles */
$acl->addRole(new Zend_Acl_Role('guest'));
$acl->addRole(new Zend_Acl_Role('member'), 'guest');
$acl->addRole(new Zend_Acl_Role('operator'), 'member');
$acl->addRole(new Zend_Acl_Role('admin'), 'operator');
/* Add default resourses */
$acl->add(new Zend_Acl_Resource('index'));
$acl->add(new Zend_Acl_Resource('error'));
/* Add resourses */
$acl->add(new Zend_Acl_Resource('auth'));
$acl->add(new Zend_Acl_Resource('auth:index'));
$acl->add(new Zend_Acl_Resource('auth:identify'));
$acl->add(new Zend_Acl_Resource('users'));
$acl->add(new Zend_Acl_Resource('users:index'));
$acl->add(new Zend_Acl_Resource('categories'));
$acl->add(new Zend_Acl_Resource('categories:index'));
/* It doesn't work'*/
/*$acl->allow('guest', 'error', array('error','denied'));
$acl->allow('guest', 'auth', array('index','identify') );
$acl->allow('guest', 'index' , array('index'));
$acl->allow('member', 'users', array('index'));
$acl->allow('admin', 'categories' , array('index'));*/
/* It works */
$acl->allow('guest', 'error');
$acl->allow('guest', 'index');
$acl->allow('guest', 'auth');
$acl->allow('guest', 'auth:index');
$acl->allow('guest', 'auth:identify');
$acl->allow('member', 'users');
$acl->allow('member', 'users:index');
$acl->allow('admin', 'categories');
$acl->allow('admin', 'categories:index');
$front->registerPlugin(new W_Controller_Plugin_Acl($acl,'member'));
// $front->registerPlugin(new W_Controller_Plugin_AclDb());
//$front->registerPlugin(new W_Controller_Plugin_FormLoader());
}
In the plugins
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$response = $this->getResponse();
if($response->isException()){
$this->_request->setModuleName('default');
$this->_request->setControllerName('error');
$this->_request->setActionName('error');
return null;
}
$resourceName = '';
if ($request->getModuleName() != 'default') {
$resourceName .= $request->getModuleName() . ':';
}
$resourceName .= $request->getControllerName();
//var_dump($resourceName.'-'.$request->getActionName()); RETURN like
categories:index-index
//var_dump($this->getAcl()->isAllowed('guess', 'categories', 'index'));
/** Check if the controller/action can be accessed by the current
user */
if (!$this->getAcl()->isAllowed($this->_roleName, $resourceName,
$request->getActionName())) {
/** Redirect to access denied page */
$this->denyAccess();
}
}
So I don't know which way to turn :(
What's the trouble ?
--
View this message in context: http://www.nabble.com/Acl-with-modules-syntax-doubt-tp24174953p24181262.html
Sent from the Zend Auth mailing list archive at Nabble.com.
没有评论:
发表评论