You are here

addanother.install in Add Another 7.2

Install, update and uninstall functions for the Add another module.

File

addanother.install
View source
<?php

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

/**
 * Implements hook_uninstall().
 */
function addanother_uninstall() {
  $types = node_type_get_types();
  foreach ($types as $type) {
    $typeid = $type->type;
    variable_del('addanother_message_' . $typeid);
    variable_del('addanother_tab_' . $typeid);
    variable_del('addanother_tab_edit_' . $typeid);
    variable_del('addanother_button_' . $typeid);
  }

  // Can't put the word default at the end of this variable name in the rare
  // case that there is a content type with a machine name of 'default'.
  variable_del('addanother_default_message');
  variable_del('addanother_default_tab');
  variable_del('addanother_default_tab_edit');
  variable_del('addanother_default_button');
}

/**
 * Update last removed.
 */
function addanother_update_last_removed() {

  // All 5.x update functions have been removed.
  return 2;
}

/**
 * Port over to the new variable storage system.
 */
function addanother_update_7001() {
  $types = node_type_get_types();
  $addanother_nodetypes = variable_get('addanother_nodetypes', array());
  $tab = variable_get('addanother_tab', FALSE);
  $tabedit = variable_get('addanother_tab_edit', FALSE);
  $message = variable_get('addanother_message', FALSE);
  foreach ($types as $type) {
    $typeid = $type->type;
    if (!empty($addanother_nodetypes[$typeid])) {
      if ($message) {
        variable_set('addanother_message_' . $typeid, TRUE);
      }
      if ($tab) {
        variable_set('addanother_tab_' . $typeid, TRUE);
      }
      if ($tabedit) {
        variable_set('addanother_tab_edit_' . $typeid, TRUE);
      }
    }
  }
  variable_del('addanother_nodetypes');
  variable_del('addanother_tab');
  variable_del('addanother_tab_edit');
  variable_del('addanother_message');
  return t('Existing Add another node options have been upgraded.  Please review the new Add another options for each node type.');
}

/**
 * Implements hook_update_N().
 *
 * Clears site-wide menu cache as our callback
 * and access arguments have changed.
 */
function addanother_update_7002() {
  cache_clear_all(NULL, 'cache_menu');
  menu_rebuild();
}

Functions

Namesort descending Description
addanother_uninstall Implements hook_uninstall().
addanother_update_7001 Port over to the new variable storage system.
addanother_update_7002 Implements hook_update_N().
addanother_update_last_removed Update last removed.