You are here

dynamic_banner.install in Dynamic Banner 6

The install file of dynamic_banner

File

dynamic_banner.install
View source
<?php

/**
 * @file
 * The install file of dynamic_banner
 */

/**
 * Implements hook_schema().
 *
 * Will create the database needed to store the banner connections
 */
function dynamic_banner_schema() {
  $schema['dynamic_banner'] = array(
    'description' => 'The table for the path to banner relationship',
    'fields' => array(
      'dbid' => array(
        'description' => 'the primary key always unique (probably not used)',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'path' => array(
        'description' => 'The path of the page',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
      ),
      'imgurl' => array(
        'description' => 'The path of the banner',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
      ),
      'text' => array(
        'description' => 'The text to display on this relationship',
        'type' => 'varchar',
        'length' => '255',
        'not null' => FALSE,
      ),
      'link' => array(
        'description' => 'The link to make the banner point to',
        'type' => 'varchar',
        'length' => '255',
        'not null' => FALSE,
      ),
      'mode' => array(
        'description' => 'The Mode for this page, will be things like time_base, rotating, fade, normal',
        'type' => 'varchar',
        'length' => '30',
        'not null' => FALSE,
      ),
      'start_time' => array(
        'description' => 'The Start time for this banner',
        'type' => 'varchar',
        'length' => '50',
        'not null' => FALSE,
      ),
      'end_time' => array(
        'description' => 'The End time for this banner',
        'type' => 'varchar',
        'length' => '50',
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'dbid',
    ),
  );
  return $schema;
}

/**
 * Implements hook_install().
 */
function dynamic_banner_install() {
  drupal_install_schema('dynamic_banner');

  // default settings install
  variable_set('dynamic_banner_display_setting', 'urltext');
  variable_set('dynamic_banner_display_errors', FALSE);
  drupal_set_message(st('Dynamic Banner Module installed successfully.'), 'warning');
}

/**
 * Implements hook_uninstall().
 */
function dynamic_banner_uninstall() {
  drupal_uninstall_schema('dynamic_banner');

  // default settings remove
  variable_del('dynamic_banner_display_setting');
  variable_del('dynamic_banner_display_errors');
  drupal_set_message(st('Dynamic Banner Module uninstalled successfully.'), 'warning');
}

/**
 * Add a new field to store a link to another page, for when clicking on the banner.
 */
function dynamic_banner_update_6300() {
  $ret = array();
  db_add_field($ret, 'dynamic_banner', 'link', array(
    'description' => 'The link to make the banner point to',
    'type' => 'varchar',
    'length' => '255',
    'not null' => FALSE,
  ));
  return $ret;
}

/**
 * Add a new field to store a mode and time for the current banner on a page.
 */
function dynamic_banner_update_6400() {
  $ret = array();
  db_add_field($ret, 'dynamic_banner', 'mode', array(
    'description' => 'The Mode for this page',
    'type' => 'varchar',
    'length' => '30',
    'not null' => FALSE,
  ));
  db_add_field($ret, 'dynamic_banner', 'start_time', array(
    'description' => 'The Start time for this banner',
    'type' => 'varchar',
    'length' => '50',
    'not null' => FALSE,
  ));
  db_add_field($ret, 'dynamic_banner', 'end_time', array(
    'description' => 'The End time for this banner',
    'type' => 'varchar',
    'length' => '50',
    'not null' => FALSE,
  ));
  $sql = "UPDATE {dynamic_banner} SET mode = 'normal'";
  db_query($sql);
  return $ret;
}

Functions

Namesort descending Description
dynamic_banner_install Implements hook_install().
dynamic_banner_schema Implements hook_schema().
dynamic_banner_uninstall Implements hook_uninstall().
dynamic_banner_update_6300 Add a new field to store a link to another page, for when clicking on the banner.
dynamic_banner_update_6400 Add a new field to store a mode and time for the current banner on a page.