You are here

services.install in Services 6

@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.
 */

/**
 * Implementation of hook_schema().
 */
function services_schema() {
  $schema['services_keys'] = array(
    'description' => 'Stores all Service keys.',
    'fields' => array(
      'kid' => array(
        'description' => 'The service key ID.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'title' => array(
        'description' => 'The title of the service key.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'domain' => array(
        'description' => 'The domain of the service key.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'kid',
    ),
  );
  $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',
    ),
  );
  return $schema;
}

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

/**
 * Implementation of hook_uninstall().
 */
function services_uninstall() {
  drupal_uninstall_schema('services');
  variable_del('services_use_key');
  variable_del('services_use_sessid');
  variable_del('services_debug');
}

/**
 * Implementation of 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' => '',
      ),
    ),
  );
  $update = array();
  db_create_table($update, 'services_timestamp_nonce', $schema['services_timestamp_nonce']);
  return $update;
}

/*
 * Update to ensure that new menu options are loaded.
 */
function services_update_6002() {
  $update = array();
  return $update;
}

Functions

Namesort descending Description
services_install Implementation of hook_install().
services_schema Implementation of hook_schema().
services_uninstall Implementation of hook_uninstall().
services_update_6001 Implementation of hook_update().
services_update_6002