Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [ZendFramework] Problem z przełączeniem kontrolera w pluginie, Zend_Controller_Plugin_Abstract i preDispatch()
Walian
post
Post #1





Grupa: Zarejestrowani
Postów: 124
Pomógł: 1
Dołączył: 13.07.2009

Ostrzeżenie: (0%)
-----


  1. <?php
  2. class My_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract
  3. {
  4. public function preDispatch(Zend_Controller_Request_Abstract $request)
  5. {
  6. $acl = Zend_Registry::get('acl');
  7. $auth = Zend_Auth::getInstance();
  8. $identity = $auth->getIdentity();
  9. if (!$identity || (empty($identity->account_type)))
  10. $roleName = 'guest';
  11. else if ($identity->account_type == 1)
  12. $roleName = 'client';
  13. else if ($identity->account_type == 2)
  14. $roleName = 'vip';
  15. else if ($identity->account_type == 3)
  16. $roleName = 'admin';
  17.  
  18. $resourceName = $request->getControllerName();
  19. $privilegeName = $request->getActionName();
  20. if (!$acl->isAllowed($roleName, $resourceName, $privilegeName))
  21. {
  22. //$request->setControllerName('error');
  23. //$request->setActionName('index');
  24. }
  25. }
  26. }


Jeśli zmienię akcję, to jest OK, ale jak tylko przełączę na jakikolwiek kontroler (nawet "index" i akcja "index") to mam Internal Server Error. Chcę po prostu zablokować dostęp do pewnych stron - nie wiem czy tak powinienem to robić...
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 25.12.2025 - 11:47