function _update_7000_user_role_grant_permissions

Utility function: grant a set of permissions to a role during update.

This function is valid for a database schema version 7000.

Parameters

$rid: The role ID.

$permissions: An array of permissions names.

$module: The name of the module defining the permissions.

Related topics

5 calls to _update_7000_user_role_grant_permissions()

File

drupal/modules/user/user.install, line 394
Install, update and uninstall functions for the user module.

Code

function _update_7000_user_role_grant_permissions($rid, array $permissions, $module) {

  // Grant new permissions for the role.
  foreach ($permissions as $name) {
    db_merge('role_permission')
      ->key(array(
      'rid' => $rid,
      'permission' => $name,
    ))
      ->fields(array(
      'module' => $module,
    ))
      ->execute();
  }
}