You are here

function adminrole_install in Admin role 7

Same name and namespace in other branches
  1. 5 adminrole.install \adminrole_install()
  2. 6 adminrole.install \adminrole_install()

Implements hook_install().

File

./adminrole.install, line 10
Install, update and uninstall functions for the adminrole module.

Code

function adminrole_install() {

  // Check if there is an existing 'admin' named role. If so, do not add a new administrator role.
  if (!db_query("SELECT 1 FROM {role} WHERE name LIKE :name", array(
    ':name' => '%' . db_like('admin') . '%',
  ))
    ->fetchField()) {
    $rid = db_insert('role')
      ->fields(array(
      'name' => 'administrator',
    ))
      ->execute();
    variable_set('user_admin_role', $rid);
    drupal_set_message(t('A new user role of <em>administrator</em> has been added. Its permissions will be automatically managed by the Admin role module.'));
  }
}