这有点奇怪,因为我在我的日志文件中看到了这些错误,并且没有一个对应于我拥有的任何资源。事实上,我什至不认识错误文件中显示的任何这些资源
2010-12-26T12:19:46+00:00 ERR (3): 找不到错误消息资源“res” 2010-12-26T12:19:46+00:00 ERR (3): Stack Trace #0 /var/www/application/library/Zend/Acl.php(691): Zend_Acl->get('res') #1 /var/www/application/library/My/Controller/Plugin/Acl.php(29): Zend_Acl->isAllowed('guest', 'res', '2127250264.html') 2010-12-26T12:50:21+00:00 ERR (3): 找不到错误消息资源“fcs” 2010-12-26T12:50:21+00:00 ERR (3): Stack Trace #0 /var/www/application/library/Zend/Acl.php(691): Zend_Acl->get('fcs') #1 /var/www/application/library/My/Controller/Plugin/Acl.php(29): Zend_Acl->isAllowed('guest', 'fcs', 'ident2') 2010-12-26T12:50:22+00:00 ERR (3): 找不到错误消息资源“打开” 2010-12-26T12:50:22+00:00 ERR (3): Stack Trace #0 /var/www/application/library/Zend/Acl.php(691): Zend_Acl->get('open') #1 /var/www/application/library/My/Controller/Plugin/Acl.php(29): Zend_Acl->isAllowed('guest', 'open', '1')
资源 res、fcs、open 或 2127250264.html - 这些不是我的应用程序中的资源 - 所以我不确定这些错误是什么意思。
任何人都可以阐明我如何进行调试。
编辑
类 My_Controller_Plugin_Acl 扩展 Zend_Controller_Plugin_Abstract { 私人 $_acl = null; 公共函数 __construct(Zend_Acl $acl) { $this->_acl = $acl; } 公共函数 preDispatch(Zend_Controller_Request_Abstract $request) { //和前面的例子一样,经过身份验证的用户将拥有角色用户 $role = (Zend_Auth::getInstance()->hasIdentity()) ? '用户' : '来宾'; $controller = $request->getControllerName(); $action = $request->getActionName(); $requestUri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri(); $session = new Zend_Session_Namespace('lastRequest'); // 临时修复不将视图图像保存为最后请求的 URL if(strpos($requestUri, 'snapshot')==false && $controller != 'register' && $controller != 'login' && $action != 'view-image' && $action != 'play-video' && $action != '配置') { //仅在未登录时才保存请求的操作 $session->lastRequestUri = $requestUri; } if(!$this->_acl->isAllowed($role, $controller, $action)) { //如果用户没有访问权限,我们通过更改请求将他发送到其他地方 $request->setModuleName('default') ->setControllerName('登录') ->setActionName('log'); } } }
这是我定义资源的类
类 My_Acl 扩展 Zend_Acl { 公共函数 __construct() { //添加一个名为“guest”的新角色 $this->addRole(new Zend_Acl_Role('guest')); //添加一个名为user的角色,继承自guest $this->addRole(new Zend_Acl_Role('user'), 'guest'); //添加一个名为page的资源 $this->add(new Zend_Acl_Resource('video')); $this->add(new Zend_Acl_Resource('error')); $this->add(new Zend_Acl_Resource('index')); $this->add(new Zend_Acl_Resource('login')); $this->add(new Zend_Acl_Resource('register')); $this->add(new Zend_Acl_Resource('profile')); $this->add(new Zend_Acl_Resource('edit-profile')); $this->add(new Zend_Acl_Resource('css')); $this->add(new Zend_Acl_Resource('js')); $this->add(new Zend_Acl_Resource('images')); $this->add(new Zend_Acl_Resource('snapshots')); //最后,我们要允许客人查看页面 $this->allow('guest', 'css'); $this->allow('guest', 'js'); $this->allow('guest', 'snapshots'); $this->allow('guest', 'images'); $this->allow('guest', 'error'); $this->allow('guest', 'login'); $this->allow('guest', 'index'); $this->allow('guest', 'register'); $this->allow('guest', 'profile','view-profile'); $this->allow('guest', 'profile','view-image'); $this->allow('guest', 'profile','all-videos'); $this->allow('guest', 'profile','all-fans'); $this->allow('guest', 'profile','favorite-artists'); $this->allow('guest', 'profile','favorite-videos'); $this->allow('guest', 'video','display-thumb'); $this->allow('guest', 'video', 'config'); $this->allow('guest', 'video', 'play'); $this->allow('guest', 'video', 'play-video'); $this->allow('guest', 'video', 'new-videos'); $this->allow('guest', 'video', 'category'); $this->allow('guest', 'video', 'index'); $this->allow('guest', 'video', 'search'); $this->allow('user', 'video'); $this->allow('user', 'profile'); } }