function hosting_add_permissions in Hosting 7.4
Same name and namespace in other branches
- 7.3 hosting.features.inc \hosting_add_permissions()
Add a module's permissions to the appropriate roles.
Parameters
string $module: The name of the module whose permissions we're adding.
array $role_perms: An array of arrays keyed by the role name. The values are the permissions to enable.
1 call to hosting_add_permissions()
- hosting_features_enable in ./
hosting.features.inc - Enable one or more Hosting features.
File
- ./
hosting.features.inc, line 563 - Include for functionality related to Hosting module features.
Code
function hosting_add_permissions($module, $role_perms) {
$perm_hook = $module . '_permission';
// @TODO: This doesn't make sense. Aegir's "hook_hosting_features" modules include permissions from other modules. It may not have it's own permission hook.
if (function_exists($perm_hook)) {
$roles = user_roles();
foreach ($roles as $rid => $name) {
// The Aegir admin role gets all hosting module permissions.
if ($name == 'aegir administrator') {
// @TODO: This doesn't make sense. Aegir's "hook_hosting_features" modules include permissions from other modules.
// This only grants full access to the "aegir administrator" role to the parent module's hook_permissions implementation,
// not the list of permissions included in the hook_hosting_feature implementations.
$perms = call_user_func($module . '_permission');
user_role_grant_permissions($rid, array_keys($perms));
}
if (array_key_exists($name, $role_perms)) {
drupal_set_message(t("The '%role' role was assigned the following permission!plural: '%perms'.", array(
'%role' => $name,
'%perms' => implode('\', \'', $role_perms[$name]),
'!plural' => count($role_perms[$name]) > 1 ? 's' : '',
)));
}
}
}
}