Archived
1
0
Fork 0
This repository has been archived on 2026-05-10. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
fiktivkod/library/Fiktiv/View/Helper/AuthLink.php
2010-10-30 15:11:34 +02:00

44 lines
1.2 KiB
PHP

<?php
class Fiktiv_View_Helper_AuthLink extends Zend_View_Helper_Abstract
{
public function authLink()
{
$auth = Zend_Auth::getInstance();
$options = array(
'module' => 'index',
'controller' => 'auth'
);
$prefix = '';
if ($auth->hasIdentity()) {
$identity = $auth->getIdentity();
$options['action'] = 'logout';
$display = ' (' . $this->view->translate('u:logout') . ')';
$prefix = '<a href="'.$this->view->url(array('controller' => 'profile'), 'default', true).'">';
if (strlen($identity->firstName)) {
$prefix .= $identity->firstName;
if (strlen($identity->lastName)) {
$prefix .= ' ' . mb_substr($identity->lastName,0,1);
}
} else {
$prefix .= $this->view->translate('Unknown');
}
$prefix .= '</a> ';
} else {
$options['action'] = 'login';
$display = $this->view->translate('u:login');
}
return $prefix
. '<a href="' . $this->view->url($options, 'auth', true) . '">'
. $display
. '</a> ';
}
}