You are here

services.install in Services 7

@author Services Dev Team

Install, uninstall and update the module.

File

services.install
View source
<?php

/**
 * @author Services Dev Team
 * @file
 *   Install, uninstall and update the module.
 */

/**
 * Implements hook_schema().
 */
function services_schema() {
  return array();
}

/**
 * Implements hook_install().
 */
function services_install() {
  drupal_install_schema('services');
}

/**
 * Implements hook_uninstall().
 */
function services_uninstall() {
  drupal_uninstall_schema('services');
  $ret = array();

  // Drop legacy tables
  $legacy_tables = array(
    'services_keys',
    'services_timestamp_nonce',
  );
  foreach ($legacy_tables as $table) {
    if (db_table_exists($table)) {
      db_drop_table($ret, $table);
    }
  }
  variable_del('services_use_key');
  variable_del('services_use_sessid');
  variable_del('services_debug');
  variable_del('services_auth_module');
}

/**
 * Implements hook_update().
 *
 * Create the nonce table
 */
function services_update_6001() {
  $schema['services_timestamp_nonce'] = array(
    'description' => 'Stores timestamp against nonce for repeat attacks.',
    'fields' => array(
      'timestamp' => array(
        'description' => 'The timestamp used with the Nonce.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'nonce' => array(
        'description' => 'The random string used on the request.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'domain' => array(
        'description' => 'The domain that submitted the request.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'indexes' => array(
      'timestamp' => array(
        'timestamp',
      ),
    ),
    'primary key' => array(
      'nonce',
    ),
  );
  $update = array();
  db_create_table($update, 'services_timestamp_nonce', $schema['services_timestamp_nonce']);
  return $update;
}
function services_update_6002() {
  $ret = array();
  menu_rebuild();
  return $ret;
}