You are here

maxlength.install in Maxlength 6.2

Install file for the maxlenght module

File

maxlength.install
View source
<?php

/**
 * @file
 * Install file for the maxlenght module
 */

/**
 * 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_' . $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_' . $type;
    $max_title = variable_get($code_old . '_t', '');
    $max_body = variable_get($code_old . '_b', '');
    variable_set('maxlength_title_' . $type, $max_title);
    variable_set('maxlength_body_' . $type, $max_body);
    variable_del($code_old . '_t');
    variable_del($code_old . '_b');
  }
  return array();
}

/**
 * Implementation of hook_update_N().
 */
function maxlength_update_3() {
  $ret = array();
  $ret[] = update_sql("UPDATE {system} SET weight = 1 WHERE name = 'maxlength'");
  return $ret;
}

/**
 * Implementation of hook_istall().
 */
function maxlength_install() {
  db_query("UPDATE {system} SET weight = 1 WHERE name = 'maxlength'");
}

/**
 * Implementation of hook_unistall().
 *
 * @todo clean up CCK field variables as well
 */
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_' . $label . '_' . $type);
    }
  }

  // Remove CCK fields variables
  if (module_exists('content')) {
    foreach (content_fields() as $field_name => $field_info) {
      maxlength_remove_field_variables($field_name);
    }
  }
}

Functions

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