You are here

readmorecontrol.install in Read More Control 7

Standand installation functions.

File

readmorecontrol.install
View source
<?php

/**
 * @file
 * Standand installation functions.
 */

/**
 * Implements hook_uninstall().
 */
function readmorecontrol_uninstall() {
  db_delete('variable')
    ->condition('name', db_like('readmorecontrol_format__') . '%', 'LIKE')
    ->execute();
  db_delete('variable')
    ->condition('name', db_like('readmorecontrol_behaviour__') . '%', 'LIKE')
    ->execute();
  variable_del('readmorecontrol_disabled_view_modes');
  variable_del('readmodecontrol_external_view_modes');

  // Now delete the readmore_behaviour values from node field instances.

  /*
  $node_bundles = field_info_instances('node');
  foreach ($node_bundles as $bundle => $bundle_instances) {
    foreach ($bundle_instances as $field_name => $instance) {
      if (isset($instance['readmore_behaviour'])) {
        unset($instance['readmore_behaviour']);
        field_update_instance($instance);
      }
    }
  }
  */
}

/**
 * Update naming of internal variable 'node_readmorecontrol_%'.
 */
function readmorecontrol_update_7000() {
  foreach (node_type_get_types() as $key => $type) {

    // Only update if it is set so that the defaults still work.
    if ($value = variable_get('node_readmorecontrol_' . $key, FALSE)) {
      variable_set('readmorecontrol_node_' . $key, $value);
      variable_del('node_readmorecontrol_' . $key);
    }
  }
}

/**
 * Update node instance settings if required.
 */
function readmorecontrol_update_7001() {
  $node_bundles = field_info_instances('node');
  foreach ($node_bundles as $bundle => $bundle_instances) {
    foreach ($bundle_instances as $field_name => $instance) {
      if (isset($instance['readmorecontrol_ignore'])) {
        $instance['readmore_behaviour'] = $instance['readmorecontrol_ignore'] ? 'ignore' : 'process';
        unset($instance['readmorecontrol_ignore']);
        field_update_instance($instance);
      }
    }
  }
}

/**
 * Refreshes the menu and updates internal settings to support multiple
 * entities and view modes.
 */
function readmorecontrol_update_7002() {
  if ($value = variable_get('readmorecontrol_default_node_behaviour', FALSE)) {
    variable_set('readmorecontrol_behaviour__node', $value);
    variable_del('readmorecontrol_default_node_behaviour');
  }
  foreach (node_type_get_types() as $key => $type) {

    // Only update if it is set so that the defaults still work.
    if ($value = variable_get('readmorecontrol_node_' . $key, FALSE)) {
      variable_set('readmorecontrol_behaviour__node__' . $key, $value);
      variable_del('readmorecontrol_node_' . $key);
    }
  }
  variable_set('menu_rebuild_needed', TRUE);
  return t('Menu links are queued to be rebuilt.');
}

Functions

Namesort descending Description
readmorecontrol_uninstall Implements hook_uninstall().
readmorecontrol_update_7000 Update naming of internal variable 'node_readmorecontrol_%'.
readmorecontrol_update_7001 Update node instance settings if required.
readmorecontrol_update_7002 Refreshes the menu and updates internal settings to support multiple entities and view modes.