本文整理汇总了PHP中Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole方法的具体用法?PHP Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole怎么用?PHP Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_View_Helper_Navigation_HelperAbstract
的用法示例。
在下文中一共展示了Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
//set timeout
$this->_sessionAdmin = new Zend_Session_Namespace(Zend_Auth_Storage_Session::NAMESPACE_DEFAULT);
$this->_sessionAdmin->setExpirationSeconds(30 * 60);
//load acl
$aclLoader = HCMS_Acl_Loader::getInstance();
$aclLoader->load();
if (!Zend_Auth::getInstance()->hasIdentity()) {
$this->_admin = null;
} else {
$this->_admin = Zend_Auth::getInstance()->getIdentity();
$aclLoader->setCurrentRoleCode($aclLoader->getRoleCode($this->_admin->get_role_id()));
}
$this->view->admin = $this->_admin;
if ($this->_checkAuth) {
$this->_checkAuthorization();
}
$this->_redirect_to_ssl();
$this->_checkIP();
//set ACL object for Zend_Navigation
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($aclLoader->getAcl());
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole($aclLoader->getCurrentRoleCode());
$this->_initVersionInfo();
$this->_module = new Application_Model_Module();
if (Application_Model_ModuleMapper::getInstance()->findByCode($this->getRequest()->getModuleName(), $this->_module)) {
$this->view->moduleSettings = $this->_module->get_settings();
}
parent::init();
}
示例2: routeShutdown
public function routeShutdown(Zend_Controller_Request_Abstract $request)
{
$navContainer = null;
$viewRenderer = Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer');
$viewRenderer->initView();
$view = $viewRenderer->view;
$module = $request->getModuleName();
if ($module == "admin") {
$navContainerConfig = new Zend_Config_Xml(APPLICATION_PATH . '/modules/admin/navigation.xml', 'nav');
$navContainer = new Zend_Navigation($navContainerConfig);
// Load the xml navigation menu
// check if the database configuration has been set
if (Shineisp_Main::isReady()) {
// Adding the configuration menu items
$configuration = SettingsGroups::getlist();
$submenu = $navContainer->findOneByLabel('Configuration');
foreach ($configuration as $id => $item) {
$pages[] = array('label' => $item, 'uri' => '/admin/settings/index/groupid/' . $id, 'resource' => 'admin:settings');
}
$submenu->addPages($pages);
}
// Attach the Zend ACL to the Navigation menu
$auth = Zend_Auth::getInstance();
if ($auth) {
$acl = $auth->getStorage()->read();
if (is_object($acl)) {
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($acl);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole("administrator");
}
}
} elseif ($module == "default") {
$navContainerConfig = new Zend_Config_Xml(APPLICATION_PATH . '/modules/default/navigation.xml', 'nav');
$navContainer = new Zend_Navigation($navContainerConfig);
// Load the xml navigation menu
// Attach the Zend ACL to the Navigation menu
$auth = Zend_Auth::getInstance();
if ($auth) {
$acl = $auth->getStorage()->read();
if (is_object($acl)) {
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($acl);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole("guest");
}
}
}
if ($navContainer) {
foreach ($navContainer->getPages() as $page) {
foreach ($page->getPages() as $subpage) {
foreach ($subpage->getPages() as $subsubpage) {
$uri = $subsubpage->getHref();
if ($uri === $request->getRequestUri()) {
$subsubpage->setActive(true);
}
}
}
}
$view->navigation($navContainer);
}
}
示例3: init
public static function init()
{
$aclProvider = new Application_Security_AclProvider();
$acl = $aclProvider->getAcls();
$aclProvider->getLogger()->debug('ACL: bootrapping');
Zend_Registry::set('Opus_Acl', $acl);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($acl);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole(Application_Security_AclProvider::ACTIVE_ROLE);
}
示例4: _initNavigation
/**
* used for handling top-level navigation
* @return Zend_Navigation
*/
protected function _initNavigation()
{
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView();
$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
$container = new Zend_Navigation($config);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl(new My_Acl());
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole(My_Acl_Roles::GUEST);
$view->navigation($container);
}
示例5: routeShutdown
/**
* 在路由结束之后,载入权限分配表。
*
* @see Zend_Controller_Request_Abstract::routeShutdown()
* @param Zend_Controller_Plugin_Abstract $request
* @return void
*/
public function routeShutdown(Zend_Controller_Request_Abstract $request)
{
$user = Zend_Registry::get('user');
$role = ZtChart_Model_Acl_Loader::hash($user->getRoleId());
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole($role);
ZtChart_Model_Acl_Loader::getInstance()->load($this->_acl);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($this->_acl);
// 如果拥有全部游戏,则设置为NULL。
if (($gameTypes = $user->getRole()->getGameTypes(true)) == array_keys(ZtChart_Model_GameType::getGames())) {
$gameTypes = null;
}
ZtChart_Model_Assemble_Backend_Abstract::setAllowedGameTypes($gameTypes);
}
示例6: _initAcl
protected function _initAcl()
{
$options = $this->getOptions();
$config = $options['acl']['roles'];
if (isset($config)) {
$auth = Zend_Auth::getInstance();
$role = $auth->hasIdentity() && !empty($auth->getIdentity()->role) ? $auth->getIdentity()->role : 'guest';
$acl = new ZFExt_Acl();
$acl->_configureNavigationAccess();
// привязываем Acl к Navigation
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($acl);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole($role);
}
return $acl;
}
示例7: init
/**
* Инициализация базовых настроек
* @return void
*/
public function init()
{
parent::init();
$this->_baseUrl = $this->getFrontController()->getBaseUrl();
$auth = Auth::getInstance();
$acl = new Acl();
$auth->setAcl($acl);
$this->view->doctype('XHTML1_TRANSITIONAL');
$this->view->headTitle()->setSeparator(' :: ');
$this->view->headTitle('HR');
$this->view->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper');
// $this->view->addHelperPath('../application/views/helpers/', 'Helper');
$this->view->addHelperPath(APPLICATION_PATH . '/views/helpers/', 'Helper');
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($acl);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole('guest');
$this->_setNavigation();
}
示例8: init
/**
* Инициализация пользовательской сессии
*
* @return array
*/
public function init()
{
$this->_bootstrap->bootstrap('Usersession');
$this->_bootstrap->bootstrap('View');
$acl = new Zend_Acl();
$role = $this->_bootstrap->Usersession->UserData['roleid'];
$acl->addRole(new Zend_Acl_Role($role));
$db = $this->_bootstrap->Db;
$select = $db->select()->from('pw_mvc_resources', new Zend_Db_Expr('DISTINCT module,controller'));
foreach ($db->fetchAll($select) as $row) {
$acl->add(new Zend_Acl_Resource(join(':', $row)));
}
foreach ($this->_bootstrap->Usersession->UserData['acl']['mvc'] as $modulename => $moduledata) {
foreach ($moduledata as $controllername => $controllerdata) {
$acl->allow($role, $modulename . ":" . $controllername, array_keys($controllerdata));
}
}
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($acl);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole($role);
$navigation = $this->_bootstrap->View->navigation();
$dir = APPLICATION_PATH . '/configs/navigation/';
if (is_dir($dir)) {
$handle = opendir($dir);
while ($module = readdir($handle)) {
if (is_dir($dir . $module) && !in_array($module, array('.', '..'))) {
$files = opendir($dir . $module);
while ($file = readdir($files)) {
if (preg_match('#^([^\\.]+)\\.xml$#iu', $file, $fileinfo)) {
$container = new Zend_Navigation(new Zend_Config_Xml($dir . $module . '/' . $file));
$this->_containers[$module][$fileinfo[1]] = array('menu' => $navigation->menu($container)->render(), 'breadcrumbs' => $navigation->breadcrumbs($container)->render());
}
}
closedir($files);
}
}
closedir($handle);
}
$this->_bootstrap->View->assign('Navigation', $this->_containers);
return $this->_containers;
}
示例9: navigation
/**
* Inicializacja navigation
* Dlatego jest to na configu że standardowy resource nie obsluguje menu
* w osobnym pliku.
*/
protected function navigation()
{
$section = 'navigation';
// if(Zend_Auth::getInstance()->getIdentity()->jednostka['type'] == 5) {
// $section = 'administration';
// }
$navigationConfig = new Zend_Config_Ini(APPLICATION_PATH . '/configs/navigation.ini', $section);
$navigation = new Zend_Navigation($navigationConfig);
$this->getResource('view')->navigation($navigation);
Zend_Registry::set(Zend_Application_Resource_Navigation::DEFAULT_REGISTRY_KEY, $navigation);
$acl = $this->getResource('acl');
$authNamespace = new Zend_Session_Namespace('Zend_Auth');
//sprawdzanie czy użytkownik ma ustawionego ws klienta
if ($authNamespace->storage->ws_client_id == null && $authNamespace->storage->profile_id != null) {
//pobieranie stron na których jest wymagany klient
$pages = $navigation->findBy('clientrequired', true, true);
foreach ($pages as $page) {
//blokowanie wyświetlenia menu dla stron do których nie ma dostępu
$acl = $acl->deny('profile_' . $authNamespace->storage->profile_id, $page->getResource(), null);
}
}
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($acl);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole('profile_' . Zend_Auth::getInstance()->getIdentity()->profile_id);
}
示例10: testSetDefaultRoleThrowsExceptionWhenGivenAnArbitraryObject
public function testSetDefaultRoleThrowsExceptionWhenGivenAnArbitraryObject()
{
try {
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole(new stdClass());
$this->fail('An invalid argument was given, but a ' . 'Zend_View_Exception was not thrown');
} catch (Zend_View_Exception $e) {
$this->assertContains('$role must be', $e->getMessage());
}
}
示例11: preDispatch
/**
* Predispatch
* Checks if the current user identified by roleName has rights to the requested url (module/controller/action)
* If not, it will call denyAccess to be redirected to errorPage
*
* @return void
**/
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$controller = strtolower($request->getControllerName());
if (in_array($controller, array("api", "auth", "locale"))) {
$this->setRoleName("G");
} elseif (!Zend_Auth::getInstance()->hasIdentity()) {
if ($controller !== 'login') {
if ($request->isXmlHttpRequest()) {
$url = 'http://' . $request->getHttpHost() . '/login';
$json = Zend_Json::encode(array('auth' => false, 'url' => $url));
// Prepare response
$this->getResponse()->setHttpResponseCode(401)->setBody($json)->sendResponse();
//redirectAndExit() cleans up, sends the headers and stops the script
Zend_Controller_Action_HelperBroker::getStaticHelper('redirector')->redirectAndExit();
} else {
$r = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
$r->gotoSimpleAndExit('index', 'login', $request->getModuleName());
}
}
} else {
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$this->setRoleName($userInfo->type);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($this->_acl);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole($this->_roleName);
$resourceName = '';
if ($request->getModuleName() != 'default') {
$resourceName .= strtolower($request->getModuleName()) . ':';
}
$resourceName .= $controller;
/** Check if the controller/action can be accessed by the current user */
if (!$this->getAcl()->has($resourceName) || !$this->getAcl()->isAllowed($this->_roleName, $resourceName, $request->getActionName())) {
/** Redirect to access denied page */
$this->denyAccess();
}
}
}
示例12: processAcl
public function processAcl(Zend_Controller_Request_Abstract $Request)
{
// Request Info
$sModule = $Request->getModuleName();
$sController = $Request->getControllerName();
$role = $this->getIdentityRole();
// Resource
$resource = $sModule . ':' . $sController;
if (!$this->checkAuth($role, $resource)) {
$this->addError('noAccess');
return $this->_redirectToLogin($Request);
}
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($this->getAcl());
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole($role);
}
示例13: preDispatch
public function preDispatch()
{
$request = $this->getRequest();
if (Axis_Area::isFrontend()) {
if (!Axis::getCustomerId() && $this->getActionController() instanceof Axis_Account_Controller_Abstract) {
$request->setModuleName('Axis_Account')->setControllerName('auth')->setActionName('index')->setDispatched(false);
}
return;
}
if (!Axis_Area::isBackend()) {
return;
}
$auth = Zend_Auth::getInstance();
$auth->setStorage(new Zend_Auth_Storage_Session('admin'));
if (in_array($request->getControllerName(), array('auth', 'forgot')) && 'Axis_Admin' === $request->getModuleName()) {
return;
}
if (!$auth->hasIdentity()) {
if ($request->isXmlHttpRequest()) {
Axis::message()->addError(Axis::translate('admin')->__('Your session has been expired. Please relogin'));
$jsonHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
$jsonHelper->sendFailure();
return;
}
$request->setModuleName('Axis_Admin')->setControllerName('auth')->setActionName('index')->setDispatched(false);
return;
}
$user = Axis::single('admin/user')->find($auth->getIdentity())->current();
if (!$user) {
$request->setModuleName('Axis_Admin')->setControllerName('auth')->setActionName('logout')->setDispatched(false);
return;
}
$acl = new Zend_Acl();
// add resources
$resources = Axis::model('admin/acl_resource')->toFlatTree();
foreach ($resources as $resource) {
$parent = $resource['parent'];
try {
$acl->addResource($resource['id'], $parent);
} catch (Zend_Acl_Exception $e) {
Axis::message()->addError($e->getMessage());
}
}
//add role(s)
$role = (string) $user->role_id;
$acl->addRole($role);
//add permission
$rowset = Axis::single('admin/acl_rule')->select('*')->where('role_id = ?', $role)->fetchRowset();
foreach ($rowset as $row) {
if (!$acl->has($row->resource_id)) {
// $row->delete(); // remove invalid rule
continue;
}
$action = 'deny';
if ('allow' === $row->permission) {
$action = 'allow';
}
try {
$acl->{$action}($row->role_id, $row->resource_id);
} catch (Zend_Acl_Exception $e) {
Axis::message()->addError($e->getMessage());
}
}
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($acl);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole($role);
if (in_array($request->getControllerName(), array('error')) && 'Axis_Admin' === $request->getModuleName()) {
return;
}
//get current resource by request
$request = $this->getRequest();
$inflector = new Zend_Filter_Inflector();
$resource = $inflector->addRules(array(':module' => array('Word_CamelCaseToDash', new Zend_Filter_Word_UnderscoreToSeparator('/'), 'StringToLower'), ':controller' => array('Word_CamelCaseToDash', 'StringToLower', new Zend_Filter_PregReplace('/admin_/', '')), ':action' => array('Word_CamelCaseToDash', 'StringToLower')))->setTarget('admin/:module/:controller/:action')->filter($request->getParams());
if (!$acl->has($resource) || $acl->isAllowed($role, $resource)) {
return;
}
if ($request->isXmlHttpRequest()) {
Axis::message()->addError(Axis::translate('admin')->__('You have no permission for this operation'));
$jsonHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
$jsonHelper->sendFailure();
return;
}
$request->setModuleName('Axis_Admin')->setControllerName('error')->setActionName('access-denied')->setDispatched(false);
}
示例14: getMvcMenus
/**
* Строит MVC-менюшки
*
* @param object $navigation - Zend_View_Helper_Navigation
* @param string $module - Название модуля
* @param string $filename - Имя xml-файла с деревом разделов
*
* @return array
*/
function getMvcMenus($navigation, $module = "default", $filename = "menu")
{
if (!file_exists($this->paths["applct"] . "/modules/" . $module . "/" . $filename . ".xml")) {
return false;
}
$roles = array_values($this->UserData["roles"]);
$role = $roles[0];
$acl = new Zend_Acl();
$acl->addRole(new Zend_Acl_Role($role));
$sql = "SELECT DISTINCT module,controller FROM pw_mvc_resources";
foreach ($this->db->fetchAll($sql) as $row) {
$acl->add(new Zend_Acl_Resource($row["module"] . ":" . $row["controller"]));
}
foreach ($this->UserData["acl"]["mvc"] as $modulename => $moduledata) {
foreach ($moduledata as $controllername => $controllerdata) {
$acl->allow($role, $modulename . ":" . $controllername, array_keys($controllerdata));
}
}
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($acl);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole($role);
$file = $this->paths["applct"] . "modules/" . $module . "/" . $filename . ".xml";
$this->UserSession->mvcMenuContainers[$module][$filename] = $container = new Zend_Navigation(new Zend_Config_Xml($file));
// Верхнее навигационное меню
$menu = $navigation->menu($container);
$menu = $menu->setMinDepth(null)->setMaxDepth(null);
$topmenu = Phorm_Filter_Utf2Win::filter($menu->render());
// Пользовательское меню
$current = $container->findBy("action", "users");
$menu = $navigation->menu($current);
$menu = $menu->setMinDepth(null)->setMaxDepth(null);
$usermenu = Phorm_Filter_Utf2Win::filter($menu->render());
// Подразделы (сестры или детки)
$current = $container->findBy("active", true);
$menu = $navigation->menu($current);
$menu = $menu->setMinDepth(0)->setMaxDepth(0);
$branchmenu = Phorm_Filter_Utf2Win::filter($menu->render());
if ($branchmenu == "" && method_exists($current, "getParent")) {
$menu = $navigation->menu($current->getParent());
$menu = $menu->setMinDepth(0)->setMaxDepth(0);
$branchmenu = Phorm_Filter_Utf2Win::filter($menu->render());
}
// Хлебные крошки
$menu = $navigation->breadcrumbs($container)->setSeparator(" / ");
$breadcrumbs = Phorm_Filter_Utf2Win::filter($menu->render());
return array("topmenu" => $topmenu, "branchmenu" => $branchmenu, "usermenu" => $usermenu, "breadcrumbs" => $breadcrumbs);
}
示例15: _initAcl
protected function _initAcl()
{
$acl = new Acl();
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($acl);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole(UserMap::getRole());
Zend_Registry::set('Zend_Acl', $acl);
return $acl;
}