Initial Commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
class Zend_View_Helper_AuthInfo extends Zend_View_Helper_Abstract
|
||||
{
|
||||
protected $_authService;
|
||||
|
||||
public function authInfo($info = null)
|
||||
{
|
||||
if (null === $this->_authService) {
|
||||
$this->_authService = new App_Service_Auth();
|
||||
}
|
||||
if (null === $info) {
|
||||
return $this;
|
||||
}
|
||||
if (false === $this->isLoggedIn()) {
|
||||
return null;
|
||||
}
|
||||
return $this->_authService->getIdentity()->$info;
|
||||
}
|
||||
|
||||
public function isLoggedIn()
|
||||
{
|
||||
return $this->_authService->getAuth()->hasIdentity();
|
||||
}
|
||||
|
||||
public function checkPermission($resourceName)
|
||||
{
|
||||
if ($this->isLoggedIn()) {
|
||||
return $this->_authService->checkPermission($resourceName);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user