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


PHP ACL::group_can方法代码示例

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


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

示例1: test_creategroup

	function test_creategroup()
	{
		$user = User::create( array( 'username' => 'testcaseuser', 'email' => 'test@example.com', 'password' => 'test') );
		$this->assert_true(
			$user instanceof User,
			'Could not create test user.'
		);

		$group = UserGroup::create( array( 'name' => 'new test group' ) );
		$this->assert_true(
			$group instanceof UserGroup,
			'Could not create a new group named "new test group".'
		);

		ACL::create_token( 'test permission', 'A permission for test cases', 'Administration' );
		ACL::create_token( 'test deny permission', 'A permission for test cases', 'Administration' );

		$this->assert_true(
			ACL::token_exists('test permission'),
			'The test permission was not created.'
		);
		$this->assert_true(
			ACL::token_exists(' test  PeRmission '),
			'Permission names are not normalized.'
		);

		$group->add( 'testcaseuser' );
		$group->grant( 'test permission' );
		$group->deny( 'test  deny permisSion' );
		$group->update();

		$newgroup = UserGroup::get( 'new test group' );

		$this->assert_true(
			in_array( $user->id, $newgroup->members ),
			'The created user is not a member of the new group.'
		);

		$this->assert_true(
			in_array( ACL::token_id( 'test permission' ), array_keys( $newgroup->permissions ) ),
			'The group does not have the new permission.'
		);

		$this->assert_true(
			ACL::group_can( 'new test group', 'test permission' ),
			'The group does not have the new permission.'
		);

		$this->assert_false(
			ACL::group_can( 'new test group', 'test deny permission' ),
			'The group has a denied permission.'
		);

		$this->assert_true(
			$user->can( 'test permission' ),
			'The user does not have a permission his group has been granted.'
		);

	}
开发者ID:rick-c,项目名称:tests,代码行数:59,代码来源:test_usergroup.php

示例2: test_group_permissions

	public function test_group_permissions()
	{
		ACL::create_token( 'acltest', 'A test ACL permission', 'Administration' );

		$this->assert_true(
			ACL::token_exists( 'acltest' ),
			'Could not create acltest permission.'
		);

		$this->assert_true(
			ACL::token_exists( 'acLtEst ' ),
			'Permission names are not normalized.'
		);

		$token_id = ACL::token_id( 'acltest' );

		ACL::grant_group( $this->acl_group->id, $token_id, 'full' );
		$this->assert_true(
			$this->acl_group->can( 'acltest', 'full' ),
			'Could not grant acltest permission to acltest-group.'
		);

		ACL::revoke_group_token( $this->acl_group->id, $token_id );
		$this->assert_false(
			ACL::group_can( $this->acl_group->id, $token_id, 'full' ),
			'Could not revoke acltest permission from acltest-group.'
		);

		// check alternate means of granting a permission
		$this->acl_group->grant( 'acltest', 'full' );
		$this->assert_true(
			$this->acl_group->can( 'acltest', 'full' ),
			'Could not grant acltest permission to acltest-group through UserGroup call.'
		);

		// full > read/edit
		$this->assert_true(
			$this->acl_group->can( 'acltest', 'read' ),
			"Group with 'full' acltest permission cannot 'read'."
		);
		$this->assert_true(
			$this->acl_group->can( 'acltest', 'edit' ),
			"Group with 'full' acltest permission cannot 'edit'."
		);
		$this->assert_true(
			$this->acl_group->can( 'acltest', 'full' ),
			"Group with 'full' acltest permission cannot 'full'."
		);
		$this->assert_exception( 'InvalidArgumentException', "'write' is an invalid token flag." );
		$this->acl_group->can( 'acltest', 'write' );

		ACL::destroy_token( 'acltest' );
	}
开发者ID:rynodivino,项目名称:tests,代码行数:53,代码来源:test_acl.php

示例3: test_group_permissions

 public function test_group_permissions()
 {
     $this->markTestSkipped('Test does not match class code; needs updating');
     ACL::create_permission('acltest', 'A test ACL permission');
     $this->assertTrue(ACL::token_exists('acltest'), 'Could not create acltest permission.');
     $token_id = ACL::token_id('acltest');
     ACL::grant_group($this->acl_group->id, $token_id, 'full');
     $this->assertTrue($this->acl_group->can('acltest', 'full'), 'Could not grant acltest permission to acltest-group.');
     ACL::revoke_group_permission($this->acl_group->id, $token_id);
     $this->assert_false(ACL::group_can($this->acl_group->id, $token_id, 'full'), 'Could not revoke acltest permission from acltest-group.');
     // check alternate means of granting a permission
     $this->acl_group->grant('acltest', 'full');
     $this->assertTrue($this->acl_group->can('acltest', 'full'), 'Could not grant acltest permission to acltest-group through UserGroup call.');
     // full > read/write
     $this->assertTrue($this->acl_group->can('acltest', 'read'), "Group with 'full' acltest permission cannot 'read'.");
     $this->assertTrue($this->acl_group->can('acltest', 'write'), "Group with 'full' acltest permission cannot 'write'.");
 }
开发者ID:psaintlaurent,项目名称:Habari,代码行数:17,代码来源:aclTest.php

示例4: upgrade_db_post_4770

 private function upgrade_db_post_4770()
 {
     // Add CRUD access tokens for other users' unpublished posts
     ACL::create_token('post_unpublished', _t("Permissions to other users' unpublished posts"), _t('Content'), true);
     // If a group doesn't have super_user permission, deny access to post_unpublished
     $groups = UserGroups::get_all();
     foreach ($groups as $group) {
         if (!ACL::group_can($group->id, 'super_user', 'read')) {
             $group->deny('post_unpublished');
         }
     }
 }
开发者ID:habari,项目名称:system,代码行数:12,代码来源:installhandler.php


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