adminrole.install in Admin role 6
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.
$rid = db_result(db_query_range("SELECT 1 FROM {role} WHERE name LIKE 'admin%%'", 0, 1));
if (!$rid) {
db_query("INSERT INTO {role} (name) VALUES ('%s')", 'administrator');
$rid = db_last_insert_id('role', 'rid');
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');
}
/**
* Change the variable adminrole_adminrole to user_admin_role.
*/
function adminrole_update_5100() {
variable_set('user_admin_role', variable_get('adminrole_adminrole', 0));
variable_del('adminrole_adminrole');
return array();
}
Functions
Name | Description |
---|---|
adminrole_enable | Implements hook_enable(). |
adminrole_install | Implements hook_install(). |
adminrole_uninstall | Implements hook_uninstall(). |
adminrole_update_5100 | Change the variable adminrole_adminrole to user_admin_role. |