You are here

maxlength.install in Maxlength 5.2

File

maxlength.install
View source
<?php

/**
 * @file
 * Install file for the maxlenght module
 */
require_once 'maxlength.inc';

/**
 * Implementation of hook_update_N().
 */
function maxlength_update_1() {
  foreach (node_get_types() as $type => $name) {
    $code_old = 'maxlength_node_type_' . $type;
    $code_new = MAXLENGTH_NODE_TYPE . $type;
    $max_title = variable_get($code_old . '_maxlength_title', '');
    $max_body = variable_get($code_old . '_maxlength_body', '');
    variable_set($code_new . '_t', $max_title);
    variable_set($code_new . '_b', $max_body);
    variable_del($code_old . '_maxlength_title');
    variable_del($code_old . '_maxlength_body');

    // old variables, not used anymore
    variable_del($code_old . '_limit');
    variable_del($code_old . '_maxlength');
  }
  return array();
}

/**
 * Implementation of hook_update_N().
 */
function maxlength_update_2() {
  foreach (node_get_types() as $type => $name) {
    $code_old = MAXLENGTH_NODE_TYPE . $type;
    $max_title = variable_get($code_old . '_t', '');
    $max_body = variable_get($code_old . '_b', '');
    variable_set(MAXLENGTH_NODE_TYPE . 'title_' . $type, $max_title);
    variable_set(MAXLENGTH_NODE_TYPE . 'body_' . $type, $max_body);
    variable_del($code_old . '_t');
    variable_del($code_old . '_b');
  }
  return array();
}

/**
 * Implementation of hook_unistall().
 */
function maxlength_uninstall() {
  foreach (node_get_types() as $type => $name) {
    $labels = array(
      'title',
      'js_title',
      'text_title',
      'body',
      'js_body',
      'text_body',
    );
    foreach ($labels as $label) {
      variable_del(MAXLENGTH_NODE_TYPE . $label . $type);
    }
  }
}

Functions

Namesort descending Description
maxlength_uninstall Implementation of hook_unistall().
maxlength_update_1 Implementation of hook_update_N().
maxlength_update_2 Implementation of hook_update_N().