imap class / mail controller
[cacert-mgr.git] / manager / library / plugins / plugin.loginlogout.php
1 <?php
2
3 /**
4 * this plugin just monitors the authdata section in the current session and adds an login / logout link to the
5 * top navigation bar depending on the value that was found
6 * @author markus
7 * $Id: plugin.loginlogout.php 95 2010-03-19 14:14:39Z markus $
8 */
9 class LoginLogout extends Zend_Controller_Plugin_Abstract {
10 public function postDispatch(Zend_Controller_Request_Abstract $request) {
11 $session = Zend_Registry::get('session');
12 if (!isset($session->authdata) || !isset($session->authdata['authed']) || $session->authdata['authed'] === false) {
13 $controller = 'login';
14 $text = 'Login';
15 }
16 else {
17 $controller = 'logout';
18 $text = 'Logout';
19 }
20 $cur_ctrl = $request->getControllerName();
21 if ($cur_ctrl == 'login')
22 $aclass=' class="active"';
23 else
24 $aclass='';
25
26 $view = Zend_Registry::get('view');
27 $view->topNav('<a href="' .
28 $view->url(array('controller' => $controller), 'default', true) .
29 '"' . $aclass . '>' . I18n::_($text) . '</a>', Zend_View_Helper_Placeholder_Container_Abstract::SET, 1000);
30 }
31 }