當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Acl::removeDeny方法代碼示例

本文整理匯總了PHP中Zend_Acl::removeDeny方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Acl::removeDeny方法的具體用法?PHP Zend_Acl::removeDeny怎麽用?PHP Zend_Acl::removeDeny使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Acl的用法示例。


在下文中一共展示了Zend_Acl::removeDeny方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testRemoveDenyWithNullResourceAppliesToAllResources

    /**
     * @group ZF-9643
     */
    public function testRemoveDenyWithNullResourceAppliesToAllResources()
    {
        $this->_acl->addRole('guest');
        $this->_acl->addResource('blogpost');
        $this->_acl->addResource('newsletter');

        $this->_acl->allow();
        $this->_acl->deny('guest', 'blogpost', 'read');
        $this->_acl->deny('guest', 'newsletter', 'read');
        $this->assertFalse($this->_acl->isAllowed('guest', 'blogpost', 'read'));
        $this->assertFalse($this->_acl->isAllowed('guest', 'newsletter', 'read'));

        $this->_acl->removeDeny('guest', 'newsletter', 'read');
        $this->assertFalse($this->_acl->isAllowed('guest', 'blogpost', 'read'));
        $this->assertTrue($this->_acl->isAllowed('guest', 'newsletter', 'read'));

        $this->_acl->removeDeny('guest', null, 'read');
        $this->assertTrue($this->_acl->isAllowed('guest', 'blogpost', 'read'));
        $this->assertTrue($this->_acl->isAllowed('guest', 'newsletter', 'read'));

        // ensure deny null/all resources works
        $this->_acl->deny('guest', null, 'read');
        $this->assertFalse($this->_acl->isAllowed('guest', 'blogpost', 'read'));
        $this->assertFalse($this->_acl->isAllowed('guest', 'newsletter', 'read'));
    }
開發者ID:benivaldo,項目名稱:zf2-na-pratica,代碼行數:28,代碼來源: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


注:本文中的Zend_Acl::removeDeny方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。