You are here

favorites.install in Favorites 6

Same filename and directory in other branches
  1. 8.2 favorites.install
  2. 7.2 favorites.install
  3. 7 favorites.install

Install, update and uninstall functions for the Favorites module.

File

favorites.install
View source
<?php

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

/**
 * Implements hook_install().
 *
 */
function favorites_install() {
  drupal_install_schema('favorites');
}

/**
 * Implements hook_uninstall().
 *
 */
function favorites_uninstall() {
  drupal_uninstall_schema('favorites');
}

/**
 * Implementats hook_schema().
 */
function favorites_schema() {
  $schema = array();
  $schema['favorites'] = array(
    'description' => "Stores each user's favorite path.",
    'fields' => array(
      'fid' => array(
        'description' => 'The unique ID of the favoite',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'uid' => array(
        'description' => 'The user ID of the user who owns the favorite.',
        'type' => 'int',
        'size' => 'normal',
        'not null' => TRUE,
      ),
      'path' => array(
        'description' => 'The favorited path',
        'type' => 'varchar',
        'length' => 1024,
        'not null' => TRUE,
      ),
      'title' => array(
        'description' => 'The title of the favorite',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'query' => array(
        'description' => "The query parameters for the saved path.",
        'type' => 'varchar',
        'length' => 1024,
        'not null' => TRUE,
      ),
      'timestamp' => array(
        'description' => "The time the favorite was created",
        'type' => 'int',
        'size' => 'normal',
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'fid',
    ),
    'unique keys' => array(
      'fid' => array(
        'fid',
      ),
    ),
    'indexes' => array(
      'uid' => array(
        'uid',
      ),
    ),
  );
  return $schema;
}

/**
 * Implements hook_update_N() for update 6001.
 *
 * Make User Favorites block not cacheable. This update is necessary because
 * of http://drupal.org/node/235673.
 */
function favorites_update_6001() {
  $ret = array();
  $ret[] = update_sql("UPDATE {blocks} SET cache = -1 WHERE module = 'favorites'");
  return $ret;
}

/**
 * Implements hook_update_N() for update 6002.
 *
 * Changes:
 * - Remove duplicate unique key 'fid' as of http://drupal.org/node/1097242
 * - Alter the value length of query column in the database as of
 *   issue http://drupal.org/node/1080340.
 * - Alter the value length of path column in the database.
 */
function favorites_update_6002() {
  $ret = array();
  db_drop_unique_key($ret, 'favorites', 'fid');
  db_change_field($ret, 'favorites', 'query', 'query', array(
    'description' => "The query parameters for the saved path.",
    'type' => 'varchar',
    'length' => 1024,
    'not null' => TRUE,
  ));
  db_change_field($ret, 'favorites', 'path', 'path', array(
    'description' => 'The favorited path',
    'type' => 'varchar',
    'length' => 1024,
    'not null' => TRUE,
  ));
  return $ret;
}

Functions

Namesort descending Description
favorites_install Implements hook_install().
favorites_schema Implementats hook_schema().
favorites_uninstall Implements hook_uninstall().
favorites_update_6001 Implements hook_update_N() for update 6001.
favorites_update_6002 Implements hook_update_N() for update 6002.