本文整理汇总了PHP中BaseUser::getSession方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseUser::getSession方法的具体用法?PHP BaseUser::getSession怎么用?PHP BaseUser::getSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseUser
的用法示例。
在下文中一共展示了BaseUser::getSession方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _checkFlagFlippers
/**
* Queries the Flag and Flipper and redirects the user to a different
* page if he/her doesn't have the required permissions for
* accessing the current page
*
* @access protected
* @return void
*/
protected function _checkFlagFlippers()
{
$controllerName = Zend_Registry::get('controllerName');
$actionName = Zend_Registry::get('actionName');
$user = BaseUser::getSession();
if (Zend_Registry::get('IS_DEVELOPMENT') && $controllerName != 'error') {
$flagModel = new Flag();
$flag = strtolower(CURRENT_MODULE) . '-' . $controllerName;
if (!$flagModel->checkRegistered($flag, App_Inflector::camelCaseToDash($actionName))) {
$params = array('originalController' => $controllerName, 'originalAction' => $actionName);
$this->_forward('flagflippers', 'error', NULL, $params);
return;
}
}
//Check the flag and flippers for ZFDebug
if (!App_FlagFlippers_Manager::isAllowed($user->group->name, 'testing', 'zfdebug')) {
Zend_Controller_Front::getInstance()->unregisterPlugin('ZFDebug_Controller_Plugin_Debug');
}
if (!App_FlagFlippers_Manager::isAllowed($user->group->name, $controllerName, $actionName)) {
if (empty($user->id)) {
// the user is a guest, save the request and redirect him to
// the login page
$session = new Zend_Session_Namespace('FrontendRequest');
$session->request = serialize($this->getRequest());
if (Zend_Controller_Front::getInstance()->getRequest()->getModuleName() == "frontend") {
$this->_redirect($this->view->url(array('module' => 'frontend', 'controller' => 'user', 'action' => 'login'), 'default', true));
} else {
$this->_redirect('/profile/login/');
}
} else {
$this->_redirect('/error/forbidden/');
}
}
}
示例2: isAllowed
/**
* Check if a role is allowed for a certain resource
*
* @param string $role
* @param string $resource
* @return boolean
*/
public static function isAllowed($role = NULL, $resource = NULL, $action = NULL)
{
if (empty($role)) {
$user = BaseUser::getSession();
$role = $user->group->name;
}
if (!empty($resource)) {
$resource = strtolower(CURRENT_MODULE) . '-' . $resource;
}
if (!empty($action)) {
$action = App_Inflector::camelCaseToDash($action);
}
return App_FlagFlippers_Manager::_getFromRegistry()->isAllowed($role, $resource, $action);
}
示例3: isLogged
/**
* Check if the current user is logged
*
* @return void
*/
public static function isLogged()
{
$user = BaseUser::getSession();
return isset($user->id);
}