You are here

regcode_roles.install in Registration codes 7

Install, update and uninstall functions for the regcode_roles module.

File

regcode_roles/regcode_roles.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the regcode_roles module.
 */

/**
 * Implements hook_install().
 *
 * When using this module with role_expire and regcode_voucher, the
 * regcode_voucher module must run after the role_expire module. Otherwise,
 * role_expire wipes any new expiriations that regcode_roles tries to create.
 */
function regcode_roles_install() {
  if (module_exists('role_expire') && module_exists('regcode_voucher')) {
    $weight = db_select('system', 's')
      ->fields('s', array(
      'weight',
    ))
      ->condition('name', 'role_expire', '=')
      ->execute()
      ->fetchField();
    db_update('system')
      ->fields(array(
      'weight' => $weight + 1,
    ))
      ->condition('name', 'regcode_voucher', '=')
      ->execute();
  }
}

/**
 * Implements hook_uninstall().
 */
function regcode_roles_uninstall() {
  variable_del('regcode_og_settings');
}

/**
 * Implements hook_schema().
 */
function regcode_roles_schema() {
  $schema['regcode_roles'] = array(
    'description' => 'Store registration role rules',
    'fields' => array(
      'id' => array(
        'description' => 'ID',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'term_id' => array(
        'description' => 'Term ID',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'role_id' => array(
        'description' => 'Role ID',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'expire_date' => array(
        'description' => 'Expiration date',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
      'expire_duration' => array(
        'description' => 'Expiration duration',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  return $schema;
}

Functions