Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [ZF] $this->_redirect
toomeczek
post
Post #1





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 7.03.2007
Skąd: Mszczonów

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


Mam plugin który wykonuje sie przed Dispatcherem i sprawdza czy użytkownik jest zalogowany. Jak nie jest zalogowany to powinien przekierować do panelu logowania, tylko nie wiem jak sie odwołać do _redirect(''), bo $this dowoluje sie do Zend_Controller_Plugin_Abstract, a tu nie ma tej metody. Macie jakiś pomysł?

  1. <?php
  2. class Zend_Controller_Plugin_Authorization extends Zend_Controller_Plugin_Abstract
  3. {
  4. public function preDispatch(Zend_Controller_Request_Abstract $request)
  5. {
  6. $name = $this->getRequest()->getControllerName();
  7. $auth = Zend_Auth::getInstance();
  8.  
  9. if(!$auth->hasIdentity() and $name!='admin')
  10. {  
  11.  $this->_redirect('/admin'); //niezalogowany
  12. }
  13. }
  14. }
  15. ?>


Zmieniłem na coś takiego
  1. <?php
  2. if(!$auth->hasIdentity() and $name!='admin')
  3. {  
  4.  $this->getRequest()->setControllerName('admin');
  5. }
  6. ?>


Ten post edytował toomeczek 26.06.2008, 11:37:13
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
toomeczek
post
Post #2





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 7.03.2007
Skąd: Mszczonów

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


Tak tylko nie wiedzialem jak sie do niej odwołać ale zapomnialem o helperach:

  1. <?php
  2. $this->_helper->layout->setLayout
  3. ?>


Mam jeszcze jedno pytanie mam nadzieje ze ostatnie, bo po zalogowaniu przez Zend_Auth_Adapter_DbTable

chce w layoutach używające helpera pokazywać dane użytkownika zalogowanygo, np przy linku wyloguj, ale jak wczytuje helper

  1. <?php
  2. class Zend_View_Hepler_Admin{
  3.  
  4. function Admin(){
  5. $auth = Zend_Auth::getInstance();
  6. $user=$auth->getIdentity();
  7.  
  8. return $user;
  9. }
  10.  
  11. }
  12. ?>

który jest w katalogu application/views/helpers/

i wywoluje go w pliku phtml
  1. <?php
  2. $this->Admin();
  3. ?>


to dostaje bląd

  1. <?php
  2. exception 'Zend_View_Exception' with message 'helper 'Admin' not found in path' in /home/emadness/public_html/cms/library/Zend/View/Abstract.php:1004Stack trace:
  3. #0 /home/emadness/public_html/cms/library/Zend/View/Abstract.php(497): Zend_View_Abstract->_loadClass('helper', 'Admin')
  4. #1 /home/emadness/public_html/cms/library/Zend/View/Abstract.php(294): Zend_View_Abstract->getHelper('Admin')
  5. #2 [internal function]: Zend_View_Abstract->__call('Admin', Array)
  6. #3 /home/emadness/public_html/cms/application/views/scripts/header.phtml(19): Zend_View->Admin()
  7. #4 /home/emadness/public_html/cms/library/Zend/View.php(46): include('/home/emadness/...')
  8. #5 /home/emadness/public_html/cms/library/Zend/View/Abstract.php(769): Zend_View->_run('./application/v...')
  9. #6 /home/emadness/public_html/cms/application/views/scripts/index/index.phtml(1): Zend_View_Abstract->render('header.phtml')#
  10. /home/emadness/public_html/cms/library/Zend/View.php(46): include('/home/emadness/...')
  11. #8 /home/emadness/public_html/cms/library/Zend/View/Abstract.php(769): Zend_View->_run('./application/v...')
  12. #9 /home/emadness/public_html/cms/library/Zend/Controller/Action/Helper/ViewRenderer.php(895): Zend_View_Abstract->render('index/index.pht...')
  13. #10 /home/emadness/public_html/cms/library/Zend/Controller/Action/Helper/ViewRenderer.php(916): Zend_Controller_Action_Helper_ViewRenderer->renderScript('index/index.pht...', NULL)
  14. #11 /home/emadness/public_html/cms/library/Zend/Controller/Action/Helper/ViewRenderer.php(955): Zend_Controller_Action_Helper_ViewRenderer->render()
  15. #12 /home/emadness/public_html/cms/library/Zend/Controller/Action/HelperBroker.php(161): Zend_Controller_Action_Helper_ViewRenderer->postDispatch()
  16. #13 /home/emadness/public_html/cms/library/Zend/Controller/Action.php(512): Zend_Controller_Action_HelperBroker->notifyPostDispatch()
  17. #14 /home/emadness/public_html/cms/library/Zend/Controller/Dispatcher/Standard.php(293): Zend_Controller_Action->dispatch('indexAction')
  18. #15 /home/emadness/public_html/cms/library/Zend/Controller/Front.php(914): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
  19. #16 /home/emadness/public_html/cms/index.php(53): Zend_Controller_Front->dispatch()
  20. #17 {main}" exception 'Zend_View_Exception' with message 'helper 'Admin' not found in path' in /home/emadness/public_html/cms/library/Zend/View/Abstract.php:1004
  21.  Stack trace:
  22.  #0 /home/emadness/public_html/cms/library/Zend/View/Abstract.php(497): Zend_View_Abstract->_loadClass('helper', 'Admin')
  23.  #1 /home/emadness/public_html/cms/library/Zend/View/Abstract.php(294): Zend_View_Abstract->getHelper('Admin')
  24.  #2 [internal function]: Zend_View_Abstract->__call('Admin', Array)
  25.  #3 /home/emadness/public_html/cms/application/views/scripts/header.phtml(19): Zend_View->Admin()
  26.  #4 /home/emadness/public_html/cms/library/Zend/View.php(46): include('/home/emadness/...')
  27.  #5 /home/emadness/public_html/cms/library/Zend/View/Abstract.php(769): Zend_View->_run('./application/v...')
  28.  #6 /home/emadness/public_html/cms/application/views/scripts/index/index.phtml(1): Zend_View_Abstract->render('header.phtml')
  29.  #7 /home/emadness/public_html/cms/library/Zend/View.php(46): include('/home/emadness/...')
  30.  #8 /home/emadness/public_html/cms/library/Zend/View/Abstract.php(769): Zend_View->_run('./application/v...')
  31.  #9 /home/emadness/public_html/cms/library/Zend/Controller/Action/Helper/ViewRenderer.php(895): Zend_View_Abstract->render('index/index.pht...')
  32.  #10 /home/emadness/public_html/cms/library/Zend/Controller/Action/Helper/ViewRenderer.php(916): Zend_Controller_Action_Helper_ViewRenderer->renderScript('index/index.pht...', NULL)
  33.  #11 /home/emadness/public_html/cms/library/Zend/Controller/Action/Helper/ViewRenderer.php(955): Zend_Controller_Action_Helper_ViewRenderer->render()
  34.  #12 /home/emadness/public_html/cms/library/Zend/Controller/Action/HelperBroker.php(161): Zend_Controller_Action_Helper_ViewRenderer->postDispatch()
  35.  #13 /home/emadness/public_html/cms/library/Zend/Controller/Action.php(512): Zend_Controller_Action_HelperBroker->notifyPostDispatch()
  36.  #14 /home/emadness/public_html/cms/library/Zend/Controller/Dispatcher/Standard.php(293): Zend_Controller_Action->dispatch('indexAction')
  37.  #15 /home/emadness/public_html/cms/library/Zend/Controller/Front.php(914): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
  38.  #16 /home/emadness/public_html/cms/index.php(53): Zend_Controller_Front->dispatch()
  39.  #17 {main}
  40. ?>
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: 8.10.2025 - 16:46