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


PHP Zend_Acl::removeAllow方法代码示例

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


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

示例1: testRemoveAllowWithNullResourceAppliesToAllResources

 /**
  * @group ZF-9643
  */
 public function testRemoveAllowWithNullResourceAppliesToAllResources()
 {
     $this->_acl->addRole('guest');
     $this->_acl->addResource('blogpost');
     $this->_acl->addResource('newsletter');
     $this->_acl->allow('guest', 'blogpost', 'read');
     $this->_acl->allow('guest', 'newsletter', 'read');
     $this->assertTrue($this->_acl->isAllowed('guest', 'blogpost', 'read'));
     $this->assertTrue($this->_acl->isAllowed('guest', 'newsletter', 'read'));
     $this->_acl->removeAllow('guest', 'newsletter', 'read');
     $this->assertTrue($this->_acl->isAllowed('guest', 'blogpost', 'read'));
     $this->assertFalse($this->_acl->isAllowed('guest', 'newsletter', 'read'));
     $this->_acl->removeAllow('guest', null, 'read');
     $this->assertFalse($this->_acl->isAllowed('guest', 'blogpost', 'read'));
     $this->assertFalse($this->_acl->isAllowed('guest', 'newsletter', 'read'));
     // ensure allow null/all resoures works
     $this->_acl->allow('guest', null, 'read');
     $this->assertTrue($this->_acl->isAllowed('guest', 'blogpost', 'read'));
     $this->assertTrue($this->_acl->isAllowed('guest', 'newsletter', 'read'));
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:23,代码来源:AclTest.php

示例2: testCMSExample


//.........这里部分代码省略.........
     $this->assertFalse($this->_acl->isAllowed('guest', null, 'delete'));
     $this->assertFalse($this->_acl->isAllowed('guest', null, 'unknown'));
     $this->assertFalse($this->_acl->isAllowed('guest'));
     $this->assertTrue($this->_acl->isAllowed('staff', null, 'view'));
     $this->assertTrue($this->_acl->isAllowed('staff', null, 'edit'));
     $this->assertTrue($this->_acl->isAllowed('staff', null, 'submit'));
     $this->assertTrue($this->_acl->isAllowed('staff', null, 'revise'));
     $this->assertFalse($this->_acl->isAllowed('staff', null, 'publish'));
     $this->assertFalse($this->_acl->isAllowed('staff', null, 'archive'));
     $this->assertFalse($this->_acl->isAllowed('staff', null, 'delete'));
     $this->assertFalse($this->_acl->isAllowed('staff', null, 'unknown'));
     $this->assertFalse($this->_acl->isAllowed('staff'));
     $this->assertTrue($this->_acl->isAllowed('editor', null, 'view'));
     $this->assertTrue($this->_acl->isAllowed('editor', null, 'edit'));
     $this->assertTrue($this->_acl->isAllowed('editor', null, 'submit'));
     $this->assertTrue($this->_acl->isAllowed('editor', null, 'revise'));
     $this->assertTrue($this->_acl->isAllowed('editor', null, 'publish'));
     $this->assertTrue($this->_acl->isAllowed('editor', null, 'archive'));
     $this->assertTrue($this->_acl->isAllowed('editor', null, 'delete'));
     $this->assertFalse($this->_acl->isAllowed('editor', null, 'unknown'));
     $this->assertFalse($this->_acl->isAllowed('editor'));
     $this->assertTrue($this->_acl->isAllowed('administrator', null, 'view'));
     $this->assertTrue($this->_acl->isAllowed('administrator', null, 'edit'));
     $this->assertTrue($this->_acl->isAllowed('administrator', null, 'submit'));
     $this->assertTrue($this->_acl->isAllowed('administrator', null, 'revise'));
     $this->assertTrue($this->_acl->isAllowed('administrator', null, 'publish'));
     $this->assertTrue($this->_acl->isAllowed('administrator', null, 'archive'));
     $this->assertTrue($this->_acl->isAllowed('administrator', null, 'delete'));
     $this->assertTrue($this->_acl->isAllowed('administrator', null, 'unknown'));
     $this->assertTrue($this->_acl->isAllowed('administrator'));
     // Some checks on specific areas, which inherit access controls from the root ACL node
     $this->_acl->add(new Zend_Acl_Resource('newsletter'))->add(new Zend_Acl_Resource('pending'), 'newsletter')->add(new Zend_Acl_Resource('gallery'))->add(new Zend_Acl_Resource('profiles', 'gallery'))->add(new Zend_Acl_Resource('config'))->add(new Zend_Acl_Resource('hosts'), 'config');
     $this->assertTrue($this->_acl->isAllowed('guest', 'pending', 'view'));
     $this->assertTrue($this->_acl->isAllowed('staff', 'profiles', 'revise'));
     $this->assertTrue($this->_acl->isAllowed('staff', 'pending', 'view'));
     $this->assertTrue($this->_acl->isAllowed('staff', 'pending', 'edit'));
     $this->assertFalse($this->_acl->isAllowed('staff', 'pending', 'publish'));
     $this->assertFalse($this->_acl->isAllowed('staff', 'pending'));
     $this->assertFalse($this->_acl->isAllowed('editor', 'hosts', 'unknown'));
     $this->assertTrue($this->_acl->isAllowed('administrator', 'pending'));
     // Add a new group, marketing, which bases its permissions on staff
     $this->_acl->addRole(new Zend_Acl_Role('marketing'), 'staff');
     // Refine the privilege sets for more specific needs
     // Allow marketing to publish and archive newsletters
     $this->_acl->allow('marketing', 'newsletter', array('publish', 'archive'));
     // Allow marketing to publish and archive latest news
     $this->_acl->add(new Zend_Acl_Resource('news'))->add(new Zend_Acl_Resource('latest'), 'news');
     $this->_acl->allow('marketing', 'latest', array('publish', 'archive'));
     // Deny staff (and marketing, by inheritance) rights to revise latest news
     $this->_acl->deny('staff', 'latest', 'revise');
     // Deny everyone access to archive news announcements
     $this->_acl->add(new Zend_Acl_Resource('announcement'), 'news');
     $this->_acl->deny(null, 'announcement', 'archive');
     // Access control checks for the above refined permission sets
     $this->assertTrue($this->_acl->isAllowed('marketing', null, 'view'));
     $this->assertTrue($this->_acl->isAllowed('marketing', null, 'edit'));
     $this->assertTrue($this->_acl->isAllowed('marketing', null, 'submit'));
     $this->assertTrue($this->_acl->isAllowed('marketing', null, 'revise'));
     $this->assertFalse($this->_acl->isAllowed('marketing', null, 'publish'));
     $this->assertFalse($this->_acl->isAllowed('marketing', null, 'archive'));
     $this->assertFalse($this->_acl->isAllowed('marketing', null, 'delete'));
     $this->assertFalse($this->_acl->isAllowed('marketing', null, 'unknown'));
     $this->assertFalse($this->_acl->isAllowed('marketing'));
     $this->assertTrue($this->_acl->isAllowed('marketing', 'newsletter', 'publish'));
     $this->assertFalse($this->_acl->isAllowed('staff', 'pending', 'publish'));
     $this->assertTrue($this->_acl->isAllowed('marketing', 'pending', 'publish'));
     $this->assertTrue($this->_acl->isAllowed('marketing', 'newsletter', 'archive'));
     $this->assertFalse($this->_acl->isAllowed('marketing', 'newsletter', 'delete'));
     $this->assertFalse($this->_acl->isAllowed('marketing', 'newsletter'));
     $this->assertTrue($this->_acl->isAllowed('marketing', 'latest', 'publish'));
     $this->assertTrue($this->_acl->isAllowed('marketing', 'latest', 'archive'));
     $this->assertFalse($this->_acl->isAllowed('marketing', 'latest', 'delete'));
     $this->assertFalse($this->_acl->isAllowed('marketing', 'latest', 'revise'));
     $this->assertFalse($this->_acl->isAllowed('marketing', 'latest'));
     $this->assertFalse($this->_acl->isAllowed('marketing', 'announcement', 'archive'));
     $this->assertFalse($this->_acl->isAllowed('staff', 'announcement', 'archive'));
     $this->assertFalse($this->_acl->isAllowed('administrator', 'announcement', 'archive'));
     $this->assertFalse($this->_acl->isAllowed('staff', 'latest', 'publish'));
     $this->assertFalse($this->_acl->isAllowed('editor', 'announcement', 'archive'));
     // Remove some previous permission specifications
     // Marketing can no longer publish and archive newsletters
     $this->_acl->removeAllow('marketing', 'newsletter', array('publish', 'archive'));
     // Marketing can no longer archive the latest news
     $this->_acl->removeAllow('marketing', 'latest', 'archive');
     // Now staff (and marketing, by inheritance) may revise latest news
     $this->_acl->removeDeny('staff', 'latest', 'revise');
     // Access control checks for the above refinements
     $this->assertFalse($this->_acl->isAllowed('marketing', 'newsletter', 'publish'));
     $this->assertFalse($this->_acl->isAllowed('marketing', 'newsletter', 'archive'));
     $this->assertFalse($this->_acl->isAllowed('marketing', 'latest', 'archive'));
     $this->assertTrue($this->_acl->isAllowed('staff', 'latest', 'revise'));
     $this->assertTrue($this->_acl->isAllowed('marketing', 'latest', 'revise'));
     // Grant marketing all permissions on the latest news
     $this->_acl->allow('marketing', 'latest');
     // Access control checks for the above refinement
     $this->assertTrue($this->_acl->isAllowed('marketing', 'latest', 'archive'));
     $this->assertTrue($this->_acl->isAllowed('marketing', 'latest', 'publish'));
     $this->assertTrue($this->_acl->isAllowed('marketing', 'latest', 'edit'));
     $this->assertTrue($this->_acl->isAllowed('marketing', 'latest'));
 }
开发者ID:jon9872,项目名称:zend-framework,代码行数:101,代码来源:AclTest.php

示例3: testMethodRemoveAllowDoesNotThrowNotice

 /**
  * @group ZF-8039
  *
  * Meant to test for the (in)existance of this notice:
  * "Notice: Undefined index: allPrivileges in lib/Zend/Acl.php on line 682"
  */
 public function testMethodRemoveAllowDoesNotThrowNotice()
 {
     $acl = new Zend_Acl();
     $acl->addRole('admin');
     $acl->addResource('blog');
     $acl->allow('admin', 'blog', 'read');
     $acl->removeAllow(array('admin'), array('blog'), null);
 }
开发者ID:netvlies,项目名称:zf,代码行数:14,代码来源:AclTest.php


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