2012-03-27 17 views
0

私はZend Frameworkを使っていくつかの練習として基本的なブログのコンセプトに取り組んでいます。私は管理者としてログインしていwhatever.com/blog/post/DATE/TITLE/追加のURLパラメータを使用してaclを編集する

に類似した記事にアクセスするためのURLを持っている

<?php 

class App_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract 
{ 
    public function preDispatch(Zend_Controller_Request_Abstract $request) 
    { 
     // resources 

     $acl = new Zend_Acl(); 

     $acl->addRole(new Zend_Acl_Role('guest')); 
     $acl->addRole(new Zend_Acl_Role('free'), 'guest'); 
     $acl->addRole(new Zend_Acl_Role('paid'), 'free'); 
     $acl->addRole(new Zend_Acl_Role('admin'), 'paid'); 


     $acl->add(new Zend_Acl_Resource('index')); 
     $acl->add(new Zend_Acl_Resource('auth')); 
     $acl->add(new Zend_Acl_Resource('error')); 
     $acl->add(new Zend_Acl_Resource('user')); 
     $acl->add(new Zend_Acl_Resource('page')); 
     $acl->add(new Zend_Acl_Resource('blog')); 
     $acl->add(new Zend_Acl_Resource('admin')); 

     // set up the access rules 
     // everyone has full access to index, error and auth 

     $acl->allow(null, array('index', 'error', 'auth', 'blog', 'page')); 
     $acl->allow('guest', array('index', 'error', 'auth', 'blog', 'page')); 
     $acl->allow('admin', null); 


     // a guest can only read content and login 
     // $acl->deny('guest', 'blog', 'comment'); 


     // free users can access the user panel 
     $acl->allow('free', 'user'); 

     // cms users can also work with content 
     //$acl->allow('user', 'page', array('list', 'create', 'edit', 'delete')); 

     // administrators can do anything 
     $acl->allow('admin', null); 


     // load the auth instance 
     $auth = Zend_Auth::getInstance(); 

     // set a default role of guest 
     if ($auth->hasIdentity()) { 
      $identity = $auth->getIdentity(); 
      $role = strtolower($identity->role); 
     } else{ 
      $role = 'guest'; 
     } 

     // check the request 
     $controller = $request->controller; 
     $action = $request->action; 

     // verify they have permission 
     if (!$acl->isAllowed($role, $controller, $action)) { 
      if ($role == 'guest') { 
       $request->setControllerName('auth'); 
       $request->setActionName('login'); 
      } else { 
       $request->setControllerName('error'); 
       $request->setActionName('noauth'); 
      } 
     } 
    } 
} 

それで、私が欲しいZendの1.11を使用しています、と私は何もしてwhatever.com/blog/post/を表示することはできません

私は他のパラメータを入れても、インデックス/インデックスにリダイレクトされます...

何が問題なのですか?どのようなコードIDK私はエラーをしたかもしれないところをお見せするために投稿する必要がありますので、私は、エラーが可能性は考えている....

EDIT私はapplication.ini

; ------------------------------------------------------ 
[production] 
; ------------------------------------------------------ 
phpSettings.display_startup_errors = 0 
phpSettings.display_errors = 0 
includePaths.library = APPLICATION_PATH "/../library" 
bootstrap.path = APPLICATION_PATH "/Bootstrap.php" 
bootstrap.class = "Bootstrap" 
appnamespace = "Application" 
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" 
resources.frontController.params.displayExceptions = 0 
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts" 
resources.frontController.plugins.acl = "App_Controller_Plugin_Acl" 
resources.view.helperPath.App_View_Helper_ = "App/View/Helper/" 

resources.db.adapter = PDO_MYSQL 
resources.db.params.host = localhost 
resources.db.params.username = root 
resources.db.params.password = 
resources.db.params.dbname = zendcasts 

autoloaderNamespaces.app = App_ 

私の認証がありますOK、私はokでログインでき、私の身元は正しい情報を保存します....

答えて

0

Aclクラスでは問題はありません。私は問題が他の場所で検索すべきだと思う。最初にapplication.iniを見たいと思います。そして、私たちは何をすべきかを決めることを試みる。可能であれば、私にあなたのコードを送ったり、ここにaplication.iniを公開してください。

+0

私は自分のapplication.iniを含むように投稿を編集しましたが、そこに問題はありません。私はおそらくルータが行動面白いと思ったのですか? – KiaiFighter

+0

私が想像できる唯一のことは、サーバー上のmod_rewriteの設定や.htaccessの設定が間違っていることです。 –

+0

このリンクが役立つかもしれません。 http://codeutopia.net/blog/tag/zend_acl/ –

関連する問題