You are here

openlayers_cck.install in Openlayers 6

Same filename and directory in other branches
  1. 6.2 modules/openlayers_cck/openlayers_cck.install

This file holds the functions for the installing and enabling of the openlayers_cck module.

File

modules/openlayers_cck/openlayers_cck.install
View source
<?php

/**
 * @file
 * This file holds the functions for the installing
 * and enabling of the openlayers_cck module.
 *
 * @ingroup openlayers
 */

/**
 * Implementation of hook_enable().
 */
function openlayers_cck_enable() {

  // Let content/cck know about our actions
  drupal_load('module', 'content');
  content_notify('enable', 'openlayers_cck');

  // As needed for upgrading to 2.x (while accounting
  // for 0.x), we set a variable that can help
  // the upgrade function in 2.x understand what needs
  // to be done.  Note, it is not meant to actually
  // maintain the schema version.
  variable_set('openlayers_cck_schema_version', 6100);
}

/**
 * Implementation of hook_disable().
 */
function openlayers_cck_disable() {

  // Let content/cck know about our actions
  drupal_load('module', 'content');
  content_notify('disable', 'openlayers_cck');
}

/**
 * Implementation of hook_install().
 */
function openlayers_cck_install() {

  // Let content/cck know about our actions
  drupal_load('module', 'content');
  content_notify('install', 'openlayers_cck');
}

/**
 * Implementation of hook_uninstall().
 */
function openlayers_cck_uninstall() {

  // Let content/cck know about our actions
  drupal_load('module', 'content');
  content_notify('uninstall', 'openlayers_cck');

  // Get module variables
  $results = db_query("SELECT v.name FROM {variable} AS v WHERE v.name LIKE '%s%%'", 'openlayers_cck_');

  // Remove variables
  while ($row = db_fetch_array($results)) {
    variable_del($row['name']);
  }
}

/**
 * Implementation of hook_update_N().
 *
 * For the CCK Map formatters, the new default is to not
 * show empty maps, so this update attempts to
 * set that default to TRUE.
 *
 * No need for translation in update function:
 * http://drupal.org/node/322731
 */
function openlayers_cck_update_6100(&$sandbox) {
  $ret = array();

  // Get each field instance
  $query = "SELECT * FROM {content_node_field_instance} WHERE widget_type = 'openlayers_wkt_widget'";
  $results = db_query($query);
  while ($row = db_fetch_object($results)) {

    // Get current widget settings and update
    $widget_settings = unserialize($row->widget_settings);
    $widget_settings['openlayers_cck_show_empty_map'] = TRUE;
    $widget_settings = serialize($widget_settings);
    $query = "UPDATE {content_node_field_instance} SET widget_settings = '%s'";
    $result = db_query($query, $widget_settings);
  }
  return $ret;
}

/**
 * Implementation of hook_update_N().
 *
 * No need for translation in update function:
 * http://drupal.org/node/322731
 */
function openlayers_cck_update_6101(&$sandbox) {

  // As needed for upgrading to 2.x (while accounting
  // for 0.x), we set a variable that can help
  // the upgrade function in 2.x understand what needs
  // to be done.  Note, it is not meant to actually
  // maintain the schema version.
  variable_set('openlayers_cck_schema_version', 6100);
  return array(
    0 => array(
      'success' => TRUE,
      'query' => 'Setup for upgrading to 2.x: openlayers_cck_schema_version',
    ),
  );
}

Related topics

Functions

Namesort descending Description
openlayers_cck_disable Implementation of hook_disable().
openlayers_cck_enable Implementation of hook_enable().
openlayers_cck_install Implementation of hook_install().
openlayers_cck_uninstall Implementation of hook_uninstall().
openlayers_cck_update_6100 Implementation of hook_update_N().
openlayers_cck_update_6101 Implementation of hook_update_N().