1 :
2 0 : <?php
3 :
4 : class Zend_View_Helper_LoggedInUser
5 0 : {
6 :
7 : public $view;
8 :
9 : function setView($view)
10 : {
11 0 : $this->view = $view;
12 0 : }
13 :
14 : function loggedInUser()
15 : {
16 0 : $auth = Zend_Auth::getInstance();
17 0 : if ($auth->hasIdentity()) {
18 0 : $logoutUrl = $this->view->url(array('controller' => 'auth', 'action' => 'logout'));
19 0 : $user = $auth->getIdentity();
20 0 : $username = $this->view->escape($user->email);
21 :
22 0 : $string = 'Logged in as ' . $username;
23 0 : $string .= ' | <a href="' . $logoutUrl . '">Log out</a>';
24 0 : } else {
25 :
26 :
27 0 : $string = "<h3>Login</h3>";
28 0 : $login = new Application_Form_UserLogin();
29 0 : $login->getElement('user')->setLabel('Email: ');
30 0 : $login->getElement('pass')->setLabel('Pass: ');
31 0 : $string = $login;
32 : }
33 0 : return $string;
34 : }
35 :
|