You are here

browscap.install in Browscap 7

Install, update and uninstall functions for the Browscap module.

File

browscap.install
View source
<?php

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

/**
 * Implements hook_install().
 */
function browscap_schema() {
  $schema['browscap'] = array(
    'fields' => array(
      'useragent' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'data' => array(
        'type' => 'blob',
        'size' => 'big',
      ),
    ),
    'primary key' => array(
      'useragent',
    ),
  );
  $schema['browscap_statistics'] = array(
    'fields' => array(
      'parent' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'counter' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'is_crawler' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'parent',
    ),
  );
  $schema['cache_browscap'] = array(
    'fields' => array(
      'cid' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'data' => array(
        'type' => 'blob',
        'size' => 'big',
      ),
      'expire' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'created' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'headers' => array(
        'type' => 'text',
      ),
      'serialized' => array(
        'type' => 'int',
        'size' => 'small',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'cid',
    ),
    'indexes' => array(
      'expire' => array(
        'expire',
      ),
    ),
  );
  return $schema;
}

/**
 * Implements hook_install().
 */
function browscap_install() {

  // Update the browscap information
  _browscap_import();

  // Record when the browscap information was updated
  variable_set('browscap_imported', REQUEST_TIME);
}

/**
 * Implements hook_uninstall().
 */
function browscap_uninstall() {
  variable_del('browscap_imported');
  variable_del('browscap_version');
  variable_del('browscap_enable_automatic_updates');
  variable_del('browscap_automatic_updates_timer');
  variable_del('browscap_enable_user_agent_log');
}

/**
 * Set the version number for new Browscap installations.
 */
function browscap_update_7000() {
  $return = array();
  return $return;
}

/**
 * Port and remove old variables.
 */
function browscap_update_7001() {

  // Port and remove browscap_update_interval
  $browscap_update_interval = variable_get('browscap_update_interval', 7);
  if ($browscap_update_interval == 0) {
    variable_set('browscap_enable_automatic_updates', FALSE);
  }
  variable_del('browscap_update_interval');

  // Port and remove browscap_monitor
  $browscap_monitor = variable_get('browscap_monitor', FALSE);
  variable_set('browscap_enable_user_agent_log', $browscap_monitor);
  variable_del('browscap_monitor');
}

Functions

Namesort descending Description
browscap_install Implements hook_install().
browscap_schema Implements hook_install().
browscap_uninstall Implements hook_uninstall().
browscap_update_7000 Set the version number for new Browscap installations.
browscap_update_7001 Port and remove old variables.