You are here

function role_export_user_role_insert in Role Export 7

Implements hook_user_role_insert().

File

./role_export.module, line 115
Role Export's primary module file.

Code

function role_export_user_role_insert($role) {

  // Use the role name if no machine name is present.
  // Generate a machine name from the role name if the machine name is not
  // present.
  if (empty($role->machine_name)) {
    $role->machine_name = role_export_machine_name_gen($role->name);
  }

  // Generate a unique numeric id.
  $id = role_export_generate_id($role->machine_name);

  // Update the numeric id.
  db_update('role')
    ->fields(array(
    'rid' => $id,
  ))
    ->condition('rid', $role->rid)
    ->execute();

  // Set the new role id in the role object, so that it is available for
  // other modules.
  $role->rid = $id;
}