当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Acl::allow方法代码示例

本文整理汇总了PHP中Zend_Acl::allow方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Acl::allow方法的具体用法?PHP Zend_Acl::allow怎么用?PHP Zend_Acl::allow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Acl的用法示例。


在下文中一共展示了Zend_Acl::allow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 /**
  * (non-PHPdoc)
  * @see Zend_Application_Resource_ResourceAbstract#init()
  */
 public function init()
 {
     $this->_acl = new Zend_Acl();
     // static roles
     $this->_acl->addRole(new Zend_Acl_Role('all'));
     $this->_acl->addRole(new Zend_Acl_Role('anonymous'), 'all');
     $this->_acl->addRole(new Zend_Acl_Role('identified'), 'all');
     // dinamic roles
     foreach ($this->_roles as $roleName) {
         if (!$this->_acl->hasRole($roleName)) {
             $this->_acl->addRole(new Zend_Acl_Role($roleName), 'identified');
         }
     }
     //        var_dump($this->_resources);exit;
     // rules
     foreach ($this->_resources as $module => $grants) {
         $module = strtolower($module);
         $this->_acl->add(new Zend_Acl_Resource($module));
         foreach ($grants as $controller => $grant) {
             $controller = strtolower($controller);
             foreach ($grant as $action => $roles) {
                 $resource = $controller . self::RESOURCE_SEPARATOR . $action;
                 foreach (explode(',', $roles) as $role) {
                     if (!empty($role)) {
                         $this->_acl->allow(trim($role), $module, $resource);
                     }
                 }
             }
         }
     }
     Zend_Registry::set('acl', $this->_acl);
     return $this->_acl;
 }
开发者ID:ramonornela,项目名称:trilhas,代码行数:37,代码来源:Acl.php

示例2: _initAlc

 protected function _initAlc()
 {
     // Создаём объект Zend_Acl
     $acl = new Zend_Acl();
     //$acl->removeAll();
     // указываем, что у нас есть ресурсы
     //$acl->addResource(new Zend_Acl_Resource('error'));
     $acl->addResource(new Zend_Acl_Resource('auth'));
     $acl->addResource(new Zend_Acl_Resource('index'));
     $acl->addResource(new Zend_Acl_Resource('models-generator'));
     $acl->addResource(new Zend_Acl_Resource('slugify'));
     $acl->addResource(new Zend_Acl_Resource('sefurl'));
     $acl->addResource(new Zend_Acl_Resource('search-index'));
     $acl->addResource(new Zend_Acl_Resource('test'));
     $acl->addResource(new Zend_Acl_Resource('xml-catalog-generator'));
     $acl->addResource(new Zend_Acl_Resource('csv-catalog-generator'));
     $acl->addResource(new Zend_Acl_Resource('cache-manager'));
     $acl->addResource(new Zend_Acl_Resource('update-image-catalog'));
     $acl->addResource(new Zend_Acl_Resource('products-draft'));
     // далее переходим к созданию ролей, которых у нас 2:
     // гость (неавторизированный пользователь)
     $acl->addRole('guest');
     // администратор, который наследует доступ от гостя
     $acl->addRole('admin', 'guest');
     $acl->deny();
     //$acl->allow('guest', array('default', 'catalog', 'error'));
     $acl->allow('guest', 'auth');
     $acl->allow('admin');
     // получаем экземпляр главного контроллера
     $fc = Zend_Controller_Front::getInstance();
     // регистрируем плагин с названием AclUtils, в который передаём
     // на ACL и экземпляр Zend_Auth
     $fc->registerPlugin(new Plugin_AclUtils($acl, Zend_Auth::getInstance()));
 }
开发者ID:Alpha-Hydro,项目名称:alpha-hydro-antares,代码行数:34,代码来源:Bootstrap.php

示例3: preDispatch

 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $acl = new Zend_Acl();
     $acl->addRole(new Zend_Acl_Role(Model_Role::GUEST));
     $acl->addRole(new Zend_Acl_Role(Model_Role::ADMIN), Model_Role::GUEST);
     $acl->addResource(new Zend_Acl_Resource('admin'));
     $acl->addResource(new Zend_Acl_Resource('blog'));
     $acl->addResource(new Zend_Acl_Resource('error'));
     $acl->addResource(new Zend_Acl_Resource('index'));
     $acl->allow(Model_Role::GUEST, 'blog');
     $acl->allow(Model_Role::GUEST, 'error');
     $acl->allow(Model_Role::GUEST, 'index');
     $acl->allow(Model_Role::GUEST, 'admin', array('login'));
     $acl->allow(Model_Role::ADMIN, 'admin');
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $user = new Model_User($auth->getIdentity());
         $role = $user->role_id;
     } else {
         $role = Model_Role::GUEST;
     }
     $resource = $request->getControllerName();
     $privilege = $request->getActionName();
     if (!$acl->isAllowed($role, $resource, $privilege)) {
         $this->_request->setControllerName('admin')->setActionName('login');
         $this->_response->setRedirect('/admin/login/');
     }
 }
开发者ID:kminkov,项目名称:Blog,代码行数:28,代码来源:Acl.php

示例4: __construct

 public function __construct()
 {
     $acl = new Zend_Acl();
     // добавляем роли
     $acl->addRole(new Zend_Acl_Role('guest'));
     $acl->addRole(new Zend_Acl_Role('admin'));
     // добавляем ресурсы
     $acl->add(new Zend_Acl_Resource('sites'));
     $acl->add(new Zend_Acl_Resource('index'));
     $acl->add(new Zend_Acl_Resource('logs'));
     $acl->add(new Zend_Acl_Resource('auth'));
     $acl->add(new Zend_Acl_Resource('maps'));
     $acl->add(new Zend_Acl_Resource('best'));
     $acl->add(new Zend_Acl_Resource('news'));
     // если нет роли то все запрещаем
     $acl->deny();
     // админу по умолчанию разрешено все
     $acl->allow('admin', null);
     // гостю только контроллер с экшеном для входа
     $acl->allow('guest', 'auth', array('index', 'check'));
     $acl->allow('guest', 'maps', array('cronmaps'));
     $acl->allow('guest', array('module' => 'best', 'controller' => 'news'), array('scan', 'redirect'));
     // если надо запретить экшены в разрешенном контроллере
     /*$acl->deny('user', 'users', array(
           'login', 'registration'
       ));
        * 
        */
     Zend_Registry::set('acl', $acl);
 }
开发者ID:MichaelGogeshvili,项目名称:strap,代码行数:30,代码来源:Acl.php

示例5: __construct

 public function __construct()
 {
     $acl = new Zend_Acl();
     //ролі
     $acl->addRole(new Zend_Acl_Role('guest'));
     //user наслідує усі параметри guest
     $acl->addRole(new Zend_Acl_Role('user'), 'guest');
     $acl->addRole(new Zend_Acl_Role('admin'));
     //ресурси - доступні контролери
     $acl->add(new Zend_Acl_Resource('users'));
     $acl->add(new Zend_Acl_Resource('index'));
     //дозвіл
     $acl->deny();
     //заборонити доступ всім
     $acl->allow('admin', null);
     //дозволити доступ admin-у до всього
     //users це resource - контролер
     // далі $privilege - екшн
     $acl->allow('guest', 'users', array('login', 'registration', 'confirm'));
     $acl->allow('guest', 'index');
     $acl->allow('user', 'users', array('logout'));
     $acl->deny('user', 'users', array('login', 'registration'));
     //глобальний доступ до змінної
     //щоб використати у видах
     Zend_Registry::set('acl', $acl);
     /*
             //isAllowed() - чи має доступ $role до $resourse і $privilege
             //$resource - контролер
             //$privilege - екшн
             if($acl->isAllowed($role, $resource, $privilege)){
                 
             } */
 }
开发者ID:Vika1994,项目名称:comments,代码行数:33,代码来源:Acl.php

示例6: _setupPrivileges

 protected function _setupPrivileges()
 {
     $menu = new Application_Model_DbTable_MenuPermissaoPerfil();
     $listaPermissao = $menu->listaPermissaoPapel();
     //Zend_Registry::get('logger')->log($listaPermissao, Zend_Log::INFO);
     //$this->_acl->allow( 'guest', 'index', array('logout', 'login','index','edit-alterar-perfil','ajuda','lista-centro-custo','edit-centro-custo','add-centro-custo','delete-centro-custo','lista-compra','add-compra','edit-compra','delete-compra','add-projeto','add-servico','add-plano-acao','add-contato','add-noticia','edit-noticia','delete-noticia','lista-projeto','lista-tipo-projeto','edit-tipo-projeto','delete-tipo-projeto','lista-status-projeto','edit-status-projeto','delete-status-projeto') )
     //  ->allow( 'guest', 'error', array('error', 'forbidden') );
     // $this->_acl->allow( 'user', 'index', array('index','logout','lista-remessa','view-remessa','add-projeto') );
     //$this->_acl->allow( 'negocio', 'index', array('index', 'ranking-executivo-negocio','lista-fotos-evento','logout') );
     //$this->_acl->allow( 'gerente', 'index', array('index', 'ranking-gerente','lista-fotos-evento','logout') );
     // $this->_acl->allow( 'produtor', 'index', array('index','lista-fotos-evento','logout','observacao-evento') );
     //$this->_acl->allow( 'produtor', 'upload', array('media','uploadjqAction','uploadjq','lista-videos','videos') );
     //$this->_acl->allow( 'admin', 'index' );
     //$this->_acl->allow( 'admin', 'upload' );
     //$this->_acl->allow( 'Operador', 'index', array('index', 'add-pcp') );
     //$this->_acl->allow( 'Operador', 'index', array('add-pcp','index') );
     $arrayPermissao = array();
     $arrayPerfil = array();
     foreach ($listaPermissao as $value) {
         //$this->_acl->addRole( new Zend_Acl_Role($value['nome']) );
         $arrayPermissao[] = $value["NM_PAGINA"];
         $arrayPerfil[] = $value["nome"];
         $this->_acl->allow($value["nome"], 'index', array($value["NM_PAGINA"], 'index', 'logout', 'error', 'forbidden'));
     }
     //Zend_Registry::get('logger')->log($arrayPermissao, Zend_Log::INFO);
     //Zend_Registry::get('logger')->log($arrayPerfil, Zend_Log::INFO);
     //Zend_Registry::get('logger')->log(array('add-pcp','index'), Zend_Log::INFO);
 }
开发者ID:andrelsguerra,项目名称:pequiambiental,代码行数:28,代码来源:Setup.php

示例7: __construct

 /** The constuctor for the class
  * @access public
  * @param Zend_Acl $aclData
  * @param $roleName string
  * @return void
  **/
 public function __construct(Zend_Acl $aclData, $roleName = 'public')
 {
     $this->_roleName = $roleName;
     if (NULL !== $aclData) {
         $this->setAcl($aclData);
     }
     $front = Zend_Controller_Front::getInstance();
     /** If an error handler hasn't been setup in the front controller, setup one */
     if (!$front->getParam('noErrorHandler') && !$front->hasPlugin('Zend_Controller_Plugin_ErrorHandler')) {
         // Register with stack index of 100
         $front->registerPlugin(new Zend_Controller_Plugin_ErrorHandler(), 100);
     }
     /** Allow error handler in the acl */
     $errorHandler = Zend_Controller_Front::getInstance()->getPlugin('Zend_Controller_Plugin_ErrorHandler');
     $defaultErrorModule = $errorHandler->getErrorHandlerModule();
     $defaultErrorController = $errorHandler->getErrorHandlerController();
     $defaultErrorAction = $errorHandler->getErrorHandlerAction();
     if (NULL !== $defaultErrorModule && $defaultErrorModule != 'default') {
         if (!$this->getAcl()->has($defaultErrorModule)) {
             require_once 'Zend/Acl/Resource.php';
             $this->_acl->add(new Zend_Acl_Resource($defaultErrorModule));
             $this->_acl->add(new Zend_Acl_Resource($defaultErrorModule . ':' . $defaultErrorController, $defaultErrorModule));
             $this->_acl->allow($this->_roleName, $defaultErrorModule . ':' . $defaultErrorController, $defaultErrorAction);
         }
     } else {
         if (!$this->getAcl()->has($defaultErrorController)) {
             $this->_acl->add(new Zend_Acl_Resource($defaultErrorController));
         }
         $this->_acl->allow($this->_roleName, $defaultErrorController, $defaultErrorAction);
     }
     $this->setDeniedAction('denied', $defaultErrorController, $defaultErrorModule);
 }
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:38,代码来源:Acl.php

示例8: getAcl

 /**
  * Get an ACL object for this post. 
  *
  * For now this is generic for all posts, but in the future may be post 
  * specific
  *
  * @return Zend_Acl
  */
 public function getAcl()
 {
     $acl = new Zend_Acl();
     $acl->addRole('guest')->addRole('user', 'guest')->addRole('admin');
     // Guests can view and comment
     $acl->allow('guest', null, array('view', 'comment'));
     // Admin can do anything
     $acl->allow('admin');
     return $acl;
 }
开发者ID:shevron,项目名称:stoa,代码行数:18,代码来源:Post.php

示例9: _setupPrivileges

 protected function _setupPrivileges()
 {
     $userAllowedResources = $this->ca->getupPrivileges($this->id_role);
     foreach ($userAllowedResources as $controller => $Actions) {
         $arrayAllowedActions = array();
         foreach ($Actions as $Action) {
             echo $this->role . ' - ' . $controller . ' - ' . $Action . '<br>';
             $arrayAllowedActions[] = $Action;
         }
         $this->_acl->allow($this->role, $controller, $arrayAllowedActions);
     }
 }
开发者ID:rossanorb,项目名称:zend_acl,代码行数:12,代码来源:Setup.php

示例10: getAcl

 public static function getAcl()
 {
     $acl = new Zend_Acl();
     $acl->addRole(new Zend_Acl_Role('alien'));
     $acl->addRole(new Zend_Acl_Role('guest'), 'alien');
     $acl->addRole(new Zend_Acl_Role('member'), 'guest');
     $acl->addRole(new Zend_Acl_Role('subadmin'), 'member');
     $acl->addRole(new Zend_Acl_Role('admin'), 'subadmin');
     $acl->allow('subadmin', null, 'edit');
     $acl->allow('subadmin', null, 'delete');
     return $acl;
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:12,代码来源:opCommunityAclBuilder.class.php

示例11: testShouldAllowAccessForCorrectRole

 public function testShouldAllowAccessForCorrectRole()
 {
     $request = $this->request->setModuleName('admin')->setControllerName('index')->setActionName('index');
     $this->acl->addResource('admin_index');
     $this->acl->allow(Acl::ROLE_GUEST, 'admin_index');
     $plugin = new Acl($this->acl);
     $plugin->setRequest($this->request);
     $plugin->preDispatch();
     $this->assertEquals('admin', $this->request->getModuleName());
     $this->assertEquals('index', $this->request->getControllerName());
     $this->assertEquals('index', $this->request->getActionName());
 }
开发者ID:lukaszjankowski,项目名称:alchemy,代码行数:12,代码来源:AclTest.php

示例12: appendRules

 public function appendRules(Zend_Acl $acl, $resource = null)
 {
     $acl->allow('everyone', $resource, 'view')->allow('self', $resource, 'edit')->deny('blocked');
     if (Doctrine::getTable('SnsConfig')->get('is_allow_config_public_flag_profile_page')) {
         $config = Doctrine::getTable('SnsConfig')->get('is_allow_config_public_flag_profile_page');
     } elseif ($resource) {
         $config = $resource->getConfig('profile_page_public_flag');
     }
     if ($config && 4 == $config) {
         $acl->allow('anonymous', $resource, 'view');
     }
     return $acl;
 }
开发者ID:kawahara,项目名称:OpenPNE3,代码行数:13,代码来源:MemberTable.class.php

示例13: __construct

 public function __construct()
 {
     $acl = new Zend_Acl();
     $acl->addRole(new Zend_Acl_Role('guest'));
     $acl->addRole(new Zend_Acl_Role('admin'));
     $acl->add(new Zend_Acl_Resource('admin'));
     $acl->add(new Zend_Acl_Resource('index'));
     $acl->deny();
     $acl->allow('admin', null);
     $acl->allow('guest', 'admin', array('login'));
     $acl->allow('guest', 'index');
     Zend_Registry::set('acl', $acl);
 }
开发者ID:p-artem,项目名称:zend.site,代码行数:13,代码来源:Acl.php

示例14: buildAcl

 /**
  * 
  */
 public function buildAcl()
 {
     if (is_null($this->acl)) {
         $this->acl = new Zend_Acl();
     }
     $this->acl->removeAll();
     $permissions = $this->getPermissionList();
     $resources = $this->getResourceList();
     $resourceParents = $this->getResourceParentList();
     $roles = $this->getRoleList();
     $roleParents = $this->getRoleParentList();
     $rolesTmp = array();
     foreach ($roles as $role) {
         $roleId = $role['role_id'];
         $roleName = $role['role_name'];
         $rolesTmp[$roleId] = array('name' => $roleId, 'parents' => array());
         $rolesTmp[$roleName] = array('name' => $roleName, 'parents' => array($roleId));
     }
     foreach ($roleParents as $roleParent) {
         $roleId = $roleParent['role_id'];
         $roleIdParent = $roleParent['role_id_parent'];
         $rolesTmp[$roleId]['parents'][] = $roleIdParent;
     }
     foreach ($rolesTmp as $role) {
         $this->acl->addRole($role['name'], $role['parents']);
     }
     #echo '<pre>';
     $resourcesTmp = array();
     foreach ($resources as $resource) {
         $resourceId = $resource['resource_id'];
         $resourceName = $resource['resource_name'];
         $resourcesTmp[$resourceId] = array('name' => $resourceId, 'parent' => null);
         $resourcesTmp[$resourceName] = array('name' => $resourceName, 'parent' => $resourceId);
     }
     foreach ($resourceParents as $resourceParent) {
         $resourceId = $resourceParent['resource_id'];
         $resourceIdParent = $resourceParent['resource_id_parent'];
         $resourcesTmp[$resourceId]['parent'] = $resourceIdParent;
     }
     foreach ($resourcesTmp as $resource) {
         $this->acl->addResource($resource['name'], $resource['parent']);
     }
     foreach ($permissions as $permission) {
         if (empty($permission['allowed'])) {
             $this->acl->deny($permission['role_id'], $permission['resource_id']);
         } else {
             $this->acl->allow($permission['role_id'], $permission['resource_id']);
         }
     }
 }
开发者ID:ehrlichandreas,项目名称:ehrlichandreas1-aclcms,代码行数:53,代码来源:ModuleExtended.php

示例15: _loadAclRecords

 /**
  * _loadAclRecords 
  * 
  * @return void
  */
 protected function _loadAclRecords()
 {
     $records = $this->_mapper->getAllRecords();
     foreach ($records as $i) {
         if ($i->getResource() && !$this->_acl->has($i->getResource())) {
             $this->_acl->addResource($i->getResource());
         }
         if ($i->getType() == 'allow') {
             $this->_acl->allow($i->getRoleId(), $i->getResource() ?: null, $i->getAction() ?: null);
         } else {
             $this->_acl->deny($i->getRoleId(), $i->getResource() ?: null, $i->getAction() ?: null);
         }
     }
 }
开发者ID:Roave,项目名称:issues,代码行数:19,代码来源:Acl.php


注:本文中的Zend_Acl::allow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。