function hosting_add_permissions

7.x-3.x hosting.features.inc hosting_add_permissions($module, $role_perms)

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 548
Include for functionality related to Hosting module features.

Code

function hosting_add_permissions($module, $role_perms) {
  $perm_hook = $module . '_permission';
  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') {
        $perms = call_user_func($module . '_permission');
        user_role_grant_permissions($rid, array_keys($perms));
      }

      if (array_key_exists($name, $role_perms)) {
        user_role_grant_permissions($rid, $role_perms[$name]);
        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' : '',
        )));
      }
    }
  }
}