You are here

shorten.install in Shorten URLs 6

(Un)installs the Shorten module.

File

shorten.install
View source
<?php

/**
 * @file
 *   (Un)installs the Shorten module.
 */

/**
 * Implementation of hook_install().
 */
function shorten_install() {
  drupal_install_schema('shorten');
}

/**
 * Implementation of hook_schema().
 */
function shorten_schema() {
  $schema = array();
  $schema['cache_shorten'] = drupal_get_schema_unprocessed('system', 'cache');
  return $schema;
}

/**
 * Implementation of hook_uninstall().
 */
function shorten_uninstall() {
  drupal_uninstall_schema('shorten');

  // The adjix and adjix_custom variables aren't used any more but they should
  // still be deleted from installations that previously used them.
  variable_del('shorten_ez');
  variable_del('shorten_www');
  variable_del('shorten_adjix');
  variable_del('shorten_cligs');
  variable_del('shorten_budurl');
  variable_del('shorten_fwd4me');
  variable_del('shorten_method');
  variable_del('shorten_redirec');
  variable_del('shorten_service');
  variable_del('shorten_timeout');
  variable_del('shorten_bitly_key');
  variable_del('shorten_use_alias');
  variable_del('shorten_bitly_login');
  variable_del('shorten_adjix_custom');
  variable_del('shorten_show_service');
  variable_del('shorten_cache_duration');
  variable_del('shorten_generate_token');
  variable_del('shorten_service_backup');
  variable_del('shorten_invisible_services');
  variable_del('shorten_cache_fail_duration');
}

/**
 * Implementation of hook_update_N().
 */
function shorten_update_6100() {
  $r = FALSE;
  if (variable_get('shorten_service', 'is.gd') == 'Drupal ShortURL module') {
    variable_set('shorten_service', 'This site');
    $r = TRUE;
  }
  if (variable_get('shorten_service_backup', 'TinyURL') == 'Drupal ShortURL module') {
    variable_set('shorten_service_backup', 'This site');
    $r = TRUE;
  }
  return array(
    array(
      'success' => TRUE,
      'query' => $r ? t('Shorten URLs service updated') : t('Caches refreshed'),
    ),
  );
}

/**
 * Implementation of hook_update_N().
 */
function shorten_update_6101() {
  $ret = array();
  $schema = drupal_get_schema_unprocessed('system', 'cache');
  db_create_table($ret, 'cache_shorten', $schema);
  return $ret;
}

/**
 * Implementation of hook_update_N().
 */
function shorten_update_6102() {
  $disabled_services = variable_get('shorten_invisible_services', array());
  if (isset($disabled_services['This site'])) {
    $value = $disabled_services['This site'] ? 'Drupal ShortURL module' : 0;
    $disabled_services['Drupal ShortURL module'] = $value;
    unset($disabled_services['This site']);
    variable_set('shorten_invisible_services', $disabled_services);
  }
  if (variable_get('shorten_service', 'is.gd') == 'This site') {
    variable_set('shorten_service', 'Drupal ShortURL module');
  }
  if (variable_get('shorten_service_backup', 'TinyURL') == 'This site') {
    variable_set('shorten_service_backup', 'Drupal ShortURL module');
  }
  return array();
}

Functions

Namesort descending Description
shorten_install Implementation of hook_install().
shorten_schema Implementation of hook_schema().
shorten_uninstall Implementation of hook_uninstall().
shorten_update_6100 Implementation of hook_update_N().
shorten_update_6101 Implementation of hook_update_N().
shorten_update_6102 Implementation of hook_update_N().