Commit cd5ced3f authored by Klaus Purer's avatar Klaus Purer
Browse files

Fixed hook doc blocks, converted a select query to DBTNG

parent f8f8ae0c
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@
 */

/**
 * Implementation of hook_schema_alter.
 * Implements hook_schema_alter().
 */
function role_export_schema_alter(&$schema) {
  // Add machine_name field to the 'role' table.
@@ -20,7 +20,7 @@ function role_export_schema_alter(&$schema) {
}

/**
 * Implementation of hook_install().
 * Implements hook_install().
 */
function role_export_install() {
  db_add_field('role', 'machine_name', array(
@@ -33,7 +33,11 @@ function role_export_install() {

  // 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 != 1 AND rid != 2");
  $roles = db_select('role')
    ->fields('role', array('rid', 'name'))
    ->condition('rid', array(1, 2), 'NOT IN')
    ->execute()
    ->fetchAll();
  foreach ($roles as $role) {
    $rid = $role->rid;
    $machine_name = 'role-' . str_replace(' ', '_', strtolower($role->name));
@@ -47,7 +51,7 @@ function role_export_install() {
}

/**
 * Implementation of hook_uninstall().
 * Implements hook_uninstall().
 */
function role_export_uninstall() {
  db_drop_field('role', 'machine_name');
+5 −2
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@
 */

/**
 * Implementation of hook_form_alter().
 * Implements hook_form_alter().
 */
function role_export_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
@@ -77,7 +77,7 @@ function role_export_submit($form, &$form_state) {
}

/**
 * Implementation of hook_theme().
 * Implements hook_theme().
 */
function role_export_theme() {
  return array(
@@ -113,6 +113,9 @@ function role_export_roles() {
  return $roles;
}

/**
 * Implements hook_user_role_insert().
 */
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