Zrobiłem to tak:
mam moduł main, w którym mam komponent executeLoginpanel():
public function executeLoginpanel() { $this->form = new LoginForm(); $this->message = $this->getUser()->getFlash('text'); $this->module = $this->getRequestParameter('module');//because it has to know where redirect $this->action = $this->getRequestParameter('action'); $this->getUser()->clearCredentials(); $this->getUser()->setAuthenticated(false); if($this->getRequest()->isMethod('post')) { $login = $this->getRequestParameter('login[login]'); $pass = $this->getRequestParameter('login[pass]'); $c = new Criteria(); $c->add(UsersPeer::LOGIN, $login); $u = UsersPeer::doSelectOne($c); if($u) { $this->getUser()->setAuthenticated(true); $this->getUser()->addCredentials('normal_user'); $this->getUser()->setAttribute('usid', $u->getUsid(), 'user'); $this->getUser()->setAttribute('login', $u->getLogin(), 'user'); }//if $u exist else { $this->getUser()->setFlash('text', 'Access danied'); return $this->getContext()->getController()->redirect('main/index'); } }//end if($this->getRequest()->isMethod('post') }//end executeLoginpanel
no i partial do niego:
<div class="login_panel"> <?php ?> <table> <tr> <td><a href="/register/index">Register</a></td> <td><input type="submit" name="ok_login" class="confirm_button" value="OK" /></td> </tr> <tr> <td></td> <td> </td> <td></td> <td> </td> </tr> <tr> <td></td> <td colspan="4"> </td> </tr> </table> </form> </div>
Wszystko dziala do momentu, gdy probuje go wywołać z innego modułu...powiedzmy register. Komponent się pojawia, ale gdy daje na panelu ok to przekierowuje mnie z powrotem na main i bieżąca strona powiedzmy z czymś już znika...
Jak najlepiej zrobić, żeby panel miał pełną funkcjonalność i żeby był dostępny z każdego modułu...
A wywołuję w templetach main/index i register/index tak:
<?php if ($sf_user->isAuthenticated()): ?> <?php include_component('profile', 'userpanel') ?> <?php else: ?> <?php include_component('main', 'loginpanel') ?> <?php endif; ?>