Guest User

Untitled

a guest
Jun 22nd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. #problem: plugin is not loading.
  2.  
  3. ## snippets of my bootstrap: [php]
  4. class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
  5. {
  6. protected function _initAutoload()
  7. {
  8. $moduleLoader = new Zend_Application_Module_Autoloader(array(
  9. 'namespace' => '',
  10. 'basePath' => APPLICATION_PATH));
  11. return $moduleLoader;
  12. }
  13.  
  14. function _initPlugins()
  15. {
  16. $front = Zend_Controller_Front::getInstance();
  17. $front->registerPlugin(new AccessControlPlugin());
  18. }
  19.  
  20. // ...
  21.  
  22. }
  23.  
  24. ## my plugin (located in APPLICATION_PATH/library/Jobs): [php]
  25. class AccessControlPlugin extends Zend_Controller_Plugin_Abstract
  26. {
  27. public function preDispatch(Zend_Controller_Request_Abstract $request)
  28. {
  29. $req = $this->getRequest();
  30. $resp = $this->getResponse();
  31.  
  32. //ignore the login pages.
  33. if (strtolower($req->getControllerName()) == "login") {
  34. return true;
  35. }
  36.  
  37. // if we were ignoring the current request, the above code should have exited the function.
  38. // So, make sure the user is logged in. If not, redirect to the login page.
  39. $session = Zend_Registry::get("session");
  40. if (empty($session->userid))
  41. //user is not logged in, redirect to the login page.
  42. $resp->setRedirect('/login');
  43. }
  44. }
  45. }
Add Comment
Please, Sign In to add comment