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-02 00:16:32 +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 = 'u:logout';
$prefix = '<a href="'.$this->view->url(array('controller' => 'profile'), 'default').'">';
if (strlen($identity->firstName)) {
$prefix .= $identity->firstName;
if (strlen($identity->lastName)) {
$prefix .= ' ' . $identity->lastName[0];
}
} else {
$prefix .= $this->view->translate('Unknown');
}
$prefix .= '</a> | ';
} else {
$options['action'] = 'login';
$display = 'u:login';
}
return $prefix
. '<a href="' . $this->view->url($options, 'auth') . '">'
. $this->view->translate($display)
. '</a>';
}
}