adminrole.install in Admin role 7
Same filename and directory in other branches
Install, update and uninstall functions for the adminrole module.
File
adminrole.installView source
<?php
/**
 * @file
 * Install, update and uninstall functions for the adminrole module.
 */
/**
 * Implements hook_install().
 */
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.'));
  }
}
/**
 * Implements hook_enable().
 */
function adminrole_enable() {
  adminrole_update_permissions();
}
/**
 * Implements hook_uninstall().
 */
function adminrole_uninstall() {
  variable_del('adminrole_adminrole');
  variable_del('user_admin_role');
  variable_del('adminrole_exclude_permissions');
}Functions
| 
            Name | 
                  Description | 
|---|---|
| adminrole_enable | Implements hook_enable(). | 
| adminrole_install | Implements hook_install(). | 
| adminrole_uninstall | Implements hook_uninstall(). |