You are here

js_injector.install in JS injector 6.2

Install file for js_injector.

File

js_injector.install
View source
<?php

/**
 * @file
 * Install file for js_injector.
 */

/**
 * Implementation of hook_install().
 */
function js_injector_install() {
  drupal_install_schema('js_injector');
}

/**
 * Implementation of hook_schema().
 */
function js_injector_schema() {
  $schema['js_injector_rule'] = array(
    'fields' => array(
      'crid' => array(
        'description' => 'The primary identifier for the js injection rule',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'title' => array(
        'description' => 'The descriptive title of the js injection rule',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'rule_type' => array(
        'description' => 'The type of rule to use when determining if the js should be injected',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'rule_conditions' => array(
        'description' => 'The data to evaluate when determining if the js should be injected',
        'type' => 'text',
        'not null' => TRUE,
      ),
      'scope' => array(
        'description' => 'The scope type of the js file (header, footer, etc.)',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'preprocess' => array(
        'description' => 'Whether the js file should be included by the js preprocessor',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'cache' => array(
        'description' => 'Whether the js file should be cahed by the js cache',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'crid',
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_uninstall().
 */
function js_injector_uninstall() {
  cache_clear_all('js_injector:*', 'cache', TRUE);
  $results = db_query("SELECT * FROM {js_injector_rule}");
  while ($rule = db_fetch_array($results)) {
    file_delete(file_create_path($rule['file_path']));
  }
  db_query("DROP TABLE {js_injector_rule}");
}

/**
 * Removes file path field from table.
 */
function js_injector_update_6000() {
  $ret = array();
  db_drop_field($ret, 'js_injector_rule', 'file_path');
  return $ret;
}

Functions

Namesort descending Description
js_injector_install Implementation of hook_install().
js_injector_schema Implementation of hook_schema().
js_injector_uninstall Implementation of hook_uninstall().
js_injector_update_6000 Removes file path field from table.