initial setup of framework code
[cacert-mgr.git] / manager / application / views / helpers / UserInfo.php
1 <?php
2 /**
3 * Zend Framework
4 *
5 * LICENSE
6 *
7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
14 *
15 * @category Zend
16 * @package Zend_View
17 * @subpackage Helper
18 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
19 * @version $Id: UserInfo.php 33 2009-12-10 15:08:38Z markus $
20 * @license http://framework.zend.com/license/new-bsd New BSD License
21 */
22
23 /** Zend_View_Helper_Placeholder_Container_Standalone */
24 require_once 'Zend/View/Helper/Placeholder/Container/Standalone.php';
25
26 /**
27 * Helper for displaying an user info div somewhere
28 *
29 * @uses Zend_View_Helper_Placeholder_Container_Standalone
30 * @package Zend_View
31 * @subpackage Helper
32 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
33 * @license http://framework.zend.com/license/new-bsd New BSD License
34 */
35 class Zend_View_Helper_UserInfo extends Zend_View_Helper_Placeholder_Container_Standalone
36 {
37 /**
38 * Registry key for placeholder
39 * @var string
40 */
41 protected $_regKey = 'Zend_View_Helper_UserInfo';
42
43 private $items = array();
44
45 /**
46 * Retrieve placeholder for navigation element and optionally set state
47 *
48 * Single Link elements to be made with $this->url(array('controller'=>'<controller>'), 'default', true);
49 *
50 * @param array $data
51 * @return Zend_View_Helper_UserData
52 */
53 public function UserInfo($ar = null, $setType = Zend_View_Helper_Placeholder_Container_Abstract::APPEND, $setPos = 0)
54 {
55 if ($ar !== null && is_array($ar)) {
56 $this->items = $ar;
57 }
58 return $this;
59 }
60
61 /**
62 * Turn helper into string
63 *
64 * @param string|null $indent
65 * @param string|null $locale
66 * @return string
67 */
68 public function __toString($indent = null, $locale = null)
69 {
70 $session = Zend_Registry::get('session');
71 $this->items = $session->authdata;
72
73 $output = '';
74
75 if ($session->authdata['authed'] !== true)
76 return $output;
77
78 # $indent = (null !== $indent)
79 # ? $this->getWhitespace($indent)
80 # : $this->getIndent();
81 $indent = '';
82
83 $output .= $indent . "<div id=\"userinfo\">\n";
84 $output .= $indent . "\tUser: " . $this->items['authed_username'] . "<br>\n";
85 $output .= $indent . "\tName: " . $this->items['authed_fname'] . ' ' . $this->items['authed_lname'] . "<br>\n";
86 $output .= $indent . "\tRole: " . $this->items['authed_role'] . "<br>\n";
87 if ($this->items['authed_by_crt'] === true)
88 $output .= $indent . "\tLoginmethod: CRT<br>\n";
89 else
90 $output .= $indent . "\tLoginmethod: PASSWD<br>\n";
91 $output .= $indent . "</div>\n";
92
93 return $output;
94 }
95 }