欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

drupal 给角色授予权限的api

shiping1 的头像

Permissions API

Permissions Reset

Overview

The permissions_api module provides a method for granting and revoking permissions for a given role. This module helps with the issue of staging a Drupal site across multiple environments, from development sandbox to production environment.

The ability to import CCK content types through code is great until you decide that you want members of specific roles to be able to do something with this content type. Currently, the only way to grant the permissions is to navigate through the access control page in the admin interface, which is completely unusable if you have a lot of roles and a lot of modules.

This module addresses that problem by providing the following functions:

permissions_grant_permissions()
permissions_revoke_permissions()
permissions_grant_all_permissions()
permissions_grant_all_permissions_by_module()
permissions_revoke_all_permissions_by_module()
permissions_get_permissions_for_role()
permissions_get_role()
permissions_create_role()
permissions_delete_role()
permissions_role_inherit()

Maintainer

Developed and maintained by Erich Beyrent
Originally sponsored by CommonPlaces e-Solutions, LLC

News

Drupal 5 No new functionality is being added to the D5 version of this module.

Drupal 6 Version 6.x-2.8 fixes a bug where permissions supplied to grant/revoke actions were not being validated against defined permissions.
Version 6.x-2.9 adds support for Drush!

Drupal 7 It looks like much of the functionality provided by this module has been added to core in D7. I haven't fully looked at the patch yet, but at this point, it looks like there will not be a D7 version of this module. See #300993: User roles and permissions API

Contrib

Permissions Reset

The Permissions Reset module adds a new fieldset to the standard Drupal permissions administration form, and adds functionality to perform bulk grants and revokes on permissions for given roles. This module was created by KarenS.

Examples

Grant specific permissions to a specific role:

<?php
$permissions
= array(
 
'create some_content_type content',
 
'edit some_content_type content',
 
'edit own some_content_type content',
);

permissions_grant_permissions('some role', $permissions); 
?>

Grant all permissions to a specific role:

<?php
// Create a "super-admin" role by granting all permissions
permissions_grant_all_permissions('some admin role');
?>

Grant all permissions defined by a specific module to a specific role:

<?php
// Grant all permissions defined by a module's hook_perm implementation
permissions_grant_all_permissions_by_module('some role', 'some module')
?>

Inherit all permissions from one role to another:

<?php
permissions_role_inherit
('new role', 'original role');
?>

Downloads

Recommended releases

VersionDownloadsDateLinks
6.x-3.1tar.gz (14.24 KB) | zip (16.61 KB)2012-Apr-12Notes

Development releases

VersionDownloadsDateLinks
6.x-3.x-devtar.gz (14.27 KB) | zip (16.62 KB)2013-May-25Notes

Project Information

来自   https://drupal.org/project/permissions_api

 

普通分类: