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


PHP ACL::grant_group方法代码示例

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


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

示例1: 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

示例2: 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

示例3: grant

	/**
	 * Assign one or more new permission tokens to this group
	 * @param mixed A permission token ID, name, or array of the same
	 */
	public function grant( $tokens, $access = 'full' )
	{
		$tokens = Utils::single_array( $tokens );
		// Use ids internally for all tokens
		$tokens = array_map( array( 'ACL', 'token_id' ), $tokens );

		// grant the new permissions
		foreach ( $tokens as $token ) {
			ACL::grant_group( $this->id, $token, $access );
		}
	}
开发者ID:rynodivino,项目名称:system,代码行数:15,代码来源:usergroup.php

示例4: populate_groups_add

 /**
  * Add user groups to the groups table, randomly assign them existing tokens.
  * @param integer $num number of groups to add, or configured value if null.
  */
 private function populate_groups_add($num = null)
 {
     if (!isset($num)) {
         $num = Options::get('populate__groups');
     }
     // Get all tokens that we have created.
     $tokens = $this->populate_tokens_get();
     // Add all these groups.
     $count = 0;
     while ($count++ < $num) {
         // Create a new group.
         $group = Usergroup::create(array('name' => 'populate_' . $this->helper_random_name()));
         // assign tokens to this new group.
         $max_tokens = count($tokens) - 1;
         $num_tokens = rand(0, $max_tokens);
         while ($num_tokens-- > 0) {
             $token = rand(0, $max_tokens);
             ACL::grant_group($group->id, $tokens[$token]->id);
         }
     }
     return;
 }
开发者ID:habari-extras,项目名称:populate,代码行数:26,代码来源:populate.plugin.php

示例5: create_token

 /**
  * Create a new permission token, and save it to the permission tokens table
  * @param string $name The name of the permission
  * @param string $description The description of the permission
  * @param string $group The token group for organizational purposes
  * @param bool $crud Indicates if the token is a CRUD or boolean type token (default is boolean)
  * @return mixed the ID of the newly created permission, or boolean false
  */
 public static function create_token($name, $description, $group, $crud = false)
 {
     $name = self::normalize_token($name);
     $crud = $crud ? 1 : 0;
     // first, make sure this isn't a duplicate
     if (ACL::token_exists($name)) {
         return false;
     }
     $allow = true;
     // Plugins have the opportunity to prevent adding this token
     $allow = Plugins::filter('token_create_allow', $allow, $name, $description, $group, $crud);
     if (!$allow) {
         return false;
     }
     Plugins::act('token_create_before', $name, $description, $group, $crud);
     $result = DB::query('INSERT INTO {tokens} (name, description, token_group, token_type) VALUES (?, ?, ?, ?)', array($name, $description, $group, $crud));
     if (!$result) {
         // if it didn't work, don't bother trying to log it
         return false;
     }
     self::clear_caches();
     // Add the token to the admin group
     $token = ACL::token_id($name);
     $admin = UserGroup::get('admin');
     if ($admin) {
         ACL::grant_group($admin->id, $token, 'full');
     }
     EventLog::log('New permission token created: ' . $name, 'info', 'default', 'habari');
     Plugins::act('permission_create_after', $name, $description, $group, $crud);
     return $result;
 }
开发者ID:wwxgitcat,项目名称:habari,代码行数:39,代码来源:acl.php


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