本文整理汇总了PHP中Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl方法的具体用法?PHP Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl怎么用?PHP Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_View_Helper_Navigation_HelperAbstract
的用法示例。
在下文中一共展示了Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
$acl = new Zend_Acl();
$acl->addRole(OpenSKOS_Db_Table_Users::USER_ROLE_GUEST);
$acl->addRole(OpenSKOS_Db_Table_Users::USER_ROLE_USER, OpenSKOS_Db_Table_Users::USER_ROLE_GUEST);
$acl->addRole(OpenSKOS_Db_Table_Users::USER_ROLE_EDITOR, OpenSKOS_Db_Table_Users::USER_ROLE_USER);
$acl->addRole(OpenSKOS_Db_Table_Users::USER_ROLE_ADMINISTRATOR, OpenSKOS_Db_Table_Users::USER_ROLE_EDITOR);
$acl->addRole(OpenSKOS_Db_Table_Users::USER_ROLE_ROOT, OpenSKOS_Db_Table_Users::USER_ROLE_ADMINISTRATOR);
$acl->addResource('website');
$acl->addResource('editor');
$acl->addResource('editor.concepts', 'editor');
$acl->addResource('editor.concept-schemes', 'editor');
$acl->addResource('editor.institution', 'editor');
$acl->addResource('editor.collections', 'editor');
$acl->addResource('editor.delete-all-concepts-in-collection', 'editor');
$acl->addResource('editor.users', 'editor');
$acl->addResource('editor.jobs', 'editor');
$acl->addResource('editor.manage-search-profiles', 'editor');
$acl->allow(OpenSKOS_Db_Table_Users::USER_ROLE_GUEST, 'website', 'view');
$acl->allow(OpenSKOS_Db_Table_Users::USER_ROLE_USER, 'editor', 'view');
$acl->allow(OpenSKOS_Db_Table_Users::USER_ROLE_USER, 'editor.concepts', 'view');
$acl->allow(OpenSKOS_Db_Table_Users::USER_ROLE_EDITOR, 'editor.concepts', array('propose'));
$acl->allow(OpenSKOS_Db_Table_Users::USER_ROLE_ADMINISTRATOR, 'editor.concepts', array('full-create', 'edit', 'delete', 'bulk-status-edit'));
$acl->allow(OpenSKOS_Db_Table_Users::USER_ROLE_ADMINISTRATOR, 'editor.concept-schemes', array('index', 'create', 'edit', 'delete', 'manage-icons'));
$acl->allow(OpenSKOS_Db_Table_Users::USER_ROLE_ADMINISTRATOR, 'editor.institution', null);
$acl->allow(OpenSKOS_Db_Table_Users::USER_ROLE_ADMINISTRATOR, 'editor.collections', array('index', 'manage'));
$acl->allow(OpenSKOS_Db_Table_Users::USER_ROLE_ADMINISTRATOR, 'editor.users', array('index', 'manage'));
$acl->allow(OpenSKOS_Db_Table_Users::USER_ROLE_ADMINISTRATOR, 'editor.jobs', array('index', 'manage'));
$acl->allow(OpenSKOS_Db_Table_Users::USER_ROLE_ADMINISTRATOR, 'editor.manage-search-profiles', null);
$acl->allow(OpenSKOS_Db_Table_Users::USER_ROLE_ROOT, 'editor.delete-all-concepts-in-collection', null);
Zend_Registry::set(self::REGISTRY_KEY, $acl);
//store the ACL for the view:
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($acl);
}
示例2: 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();
}
示例3: 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);
}
}
示例4: 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);
}
示例5: _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);
}
示例6: 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);
}
示例7: _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;
}
示例8: 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();
}
示例9: 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;
}
示例10: 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);
}
示例11: testSetDefaultAclAcceptsNoParam
public function testSetDefaultAclAcceptsNoParam()
{
$acl = new Zend_Acl();
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($acl);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl();
$this->assertNull($this->_helper->getAcl());
}
示例12: 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();
}
}
}
示例13: 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);
}
示例14: 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);
}
示例15: Zend_Acl
<?php
require_once 'Acl_plugin.php';
$ccAcl = new Zend_Acl();
$ccAcl->addRole(new Zend_Acl_Role('G'))->addRole(new Zend_Acl_Role('H'), 'G')->addRole(new Zend_Acl_Role('P'), 'H')->addRole(new Zend_Acl_Role('A'), 'P');
$ccAcl->add(new Zend_Acl_Resource('library'))->add(new Zend_Acl_Resource('index'))->add(new Zend_Acl_Resource('user'))->add(new Zend_Acl_Resource('error'))->add(new Zend_Acl_Resource('login'))->add(new Zend_Acl_Resource('playlist'))->add(new Zend_Acl_Resource('plupload'))->add(new Zend_Acl_Resource('schedule'))->add(new Zend_Acl_Resource('api'))->add(new Zend_Acl_Resource('nowplaying'))->add(new Zend_Acl_Resource('search'))->add(new Zend_Acl_Resource('dashboard'))->add(new Zend_Acl_Resource('preference'))->add(new Zend_Acl_Resource('recorder'))->add(new Zend_Acl_Resource('statistics'));
/** Creating permissions */
$ccAcl->allow('G', 'index')->allow('G', 'login')->allow('G', 'error')->allow('G', 'nowplaying')->allow('G', 'api')->allow('G', 'recorder')->allow('G', 'schedule')->allow('G', 'dashboard')->allow('H', 'plupload')->allow('H', 'library')->allow('H', 'search')->allow('H', 'playlist')->allow('A', 'user')->allow('A', 'preference')->allow('A', 'statistics');
$aclPlugin = new Zend_Controller_Plugin_Acl($ccAcl);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($ccAcl);
$front = Zend_Controller_Front::getInstance();
$front->registerPlugin($aclPlugin);