function role_export_install in Role Export 6
Same name and namespace in other branches
- 7 role_export.install \role_export_install()
Implements hook_install().
File
- ./
role_export.install, line 25 - Install, Uninstall, Schema and Update functions for role_export
Code
function role_export_install() {
$ret = array();
// Add machine_name field to the 'role' table.
db_add_field($ret, 'role', 'machine_name', array(
'description' => 'The machine name assigned by the user during creation of the role.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
));
// Update any existing roles (except anonymous, authenticated) to have a
// machine name and save it to the 'role' table.
$roles = db_query("SELECT rid, name FROM {role} WHERE rid > 2");
while ($role = db_fetch_object($roles)) {
$rid = $role->rid;
$machine_name = str_replace(' ', '_', strtolower($role->name));
db_query("UPDATE {role} SET machine_name = '%s' WHERE rid = %d", $machine_name, $rid);
}
}