Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Zend ACL dwa moduły.
cykcykacz
post
Post #1





Grupa: Zarejestrowani
Postów: 550
Pomógł: 9
Dołączył: 29.05.2009
Skąd: Ostrów Wielkopolski

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


Witam,
staram się dodać acl do aplikacji w której mam dwa moduły: default, admin.
  1. class Plugin_Acl extends Zend_Controller_Plugin_Abstract
  2. {
  3. public function preDispatch(Zend_Controller_Request_Abstract $request)
  4. {
  5. // set up acl
  6. $acl = new Zend_Acl();
  7.  
  8. // add the roles
  9. $acl->addRole(new Zend_Acl_Role('guest'));
  10. $acl->addRole(new Zend_Acl_Role('user'), 'guest');
  11. $acl->addRole(new Zend_Acl_Role('administrator'), 'user');
  12.  
  13. /** Default module */
  14. $acl->add(new Zend_Acl_Resource('index'))
  15. ->add(new Zend_Acl_Resource('index2'));
  16.  
  17. /** Admin module */
  18. $acl->add(new Zend_Acl_Resource('admin'))
  19. //->add(new Zend_Acl_Resource('index', 'admin'))
  20. ;
  21. // add the resources
  22.  
  23. $acl->allow('guest', 'index')
  24. ->allow('guest', 'index2')
  25. ->deny('guest','admin', 'index');
  26.  
  27. $auth = Zend_Auth::getInstance();
  28. if($auth->hasIdentity()) {
  29. $identity = $auth->getIdentity();
  30. $role = strtolower($identity->role);
  31. }else{
  32. $role = 'guest';
  33. }
  34. $controller = $request->controller;
  35. $action = $request->action;
  36. if (!$acl->isAllowed($role, $controller, $action)) {
  37. if ($role == 'guest') {
  38. $request->setControllerName('user')
  39. ->setActionName('login')
  40. ->setModuleName('admin');
  41. } else {
  42. $request->setControllerName('error')
  43. ->setActionName('noauth');
  44. }
  45. }
  46. }


I nie wiem dlaczego ale jak ustawię $acl->allow('guest', 'index'), gość ma wstęp do admin/index. A chcę aby miał dostęp do "default/index" a nie do "admin/index".

Ten post edytował cykcykacz 29.01.2012, 16:50:51
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: 24.12.2025 - 15:27