コード例 #1
0
	protected function isResourceInherited($module, $controller, $action, $role_id)
	{
		$inheritsResource = false;
		$roles_table = new Roles();
		$roles_roles_table = new RolesRoles();
		$roles_resources_table = new RolesResources();
		$inherited_ids = $roles_table->getAllAncestors($role_id);
		if (count($inherited_ids) > 0)
		{
			foreach ($inherited_ids as $inherited_id)
			{
				// determine if parent has access to this resource
				$roles_resource = $roles_resources_table->fetchRow(
					"role_id=".$inherited_id." and ".
					"module='".$module."' and ".
					"controller='".$controller."' and ".
					"action='".$action."' "
				);
				if (!is_null($roles_resource))
				{
					//parent has it, role is inherited
					$inheritsResource = true;
				}
			}
		}
		return $inheritsResource;
	}