You are here

follow.install in Follow 7.2

Same filename and directory in other branches
  1. 8.2 follow.install
  2. 5 follow.install
  3. 6 follow.install
  4. 7 follow.install

Follow module's install and uninstall code.

File

follow.install
View source
<?php

/**
 * @file
 *   Follow module's install and uninstall code.
 */

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

  // Add a default link to this site's node RSS feed.
  db_insert('follow_links')
    ->fields(array(
    'name' => 'this-site',
    'path' => 'rss.xml',
    'options' => 'a:0:{}',
    'uid' => 0,
    'weight' => 0,
  ))
    ->execute();

  // Save the initial CSS.
  follow_save_css();
}

/**
 * Implements hook_schema().
 */
function follow_schema() {
  $schema['follow_links'] = array(
    'description' => 'Stores sitewide and user follow links.',
    'fields' => array(
      'lid' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'Unique identifier for the {follow_links}.',
      ),
      'name' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => "The machine name of the {follow_links}.",
      ),
      'uid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => "User's {users} uid.  Sitewide {follow_links} use uid 0",
      ),
      'path' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The Drupal path or extenal URL the {follow_links} should point to.',
      ),
      'options' => array(
        'description' => 'A serialized array of options to be passed to the url() or l() function, such as a query string or HTML attributes.',
        'type' => 'text',
        'translatable' => TRUE,
        'serialize' => TRUE,
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The human readable name for the link.',
      ),
      'weight' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'The weight of this {follow_links}.',
      ),
    ),
    'primary key' => array(
      'lid',
    ),
    'unique keys' => array(
      'uid_name' => array(
        'uid',
        'name',
      ),
    ),
  );
  return $schema;
}

/**
 * Implements hook_uninstall().
 */
function follow_uninstall() {
  variable_del('follow_user_block_title');
  variable_del('follow_site_block_title');
  variable_del('follow_site_block_user');
  variable_del('follow_site_icon_style');
  variable_del('follow_user_icon_style');
  variable_del('follow_site_alignment');
  variable_del('follow_user_alignment');
  variable_del('follow_site_hide_text');
  variable_del('follow_user_hide_text');
}

/**
 * Implements hook_update_last_removed().
 */
function follow_update_last_removed() {

  // We need to ensure that all D6 users have upgraded to the latest version of
  // Follow before upgrading to D7.
  return 6003;
}

/**
 * Rename the alignment and link style variables to have 'site' in the name.
 */
function follow_update_7004() {
  if ($value = variable_get('follow_icon_style')) {
    variable_set('follow_site_icon_style', $value);
    variable_del('follow_icon_style');
  }
  if ($value = variable_get('follow_alignment')) {
    variable_set('follow_site_alignment', $value);
    variable_del('follow_alignment');
  }

  // Save the initial CSS.
  follow_save_css();
  return t("Renamed Follow module's alignment and icon style variables.");
}

/**
 * &lt;none&gt; is no longer supported in titles, so remove it. If you would like to
 * hide the titles of the follow links, configure the appropriate block
 * instead.
 */
function follow_update_7005() {
  $query = db_update('follow_links')
    ->fields(array(
    'title' => '',
  ))
    ->condition('title', '<none>');
  $query
    ->execute();
}

Functions

Namesort descending Description
follow_install Implements hook_install().
follow_schema Implements hook_schema().
follow_uninstall Implements hook_uninstall().
follow_update_7004 Rename the alignment and link style variables to have 'site' in the name.
follow_update_7005 &lt;none&gt; is no longer supported in titles, so remove it. If you would like to hide the titles of the follow links, configure the appropriate block instead.
follow_update_last_removed Implements hook_update_last_removed().