You are here

emimage.install in Embedded Media Field 6.3

Same filename and directory in other branches
  1. 6 contrib/emimage/emimage.install
  2. 6.2 contrib/emimage/emimage.install

This is the emimage.module's install, configuration, and removal instructions.

File

contrib/emimage/emimage.install
View source
<?php

/**
 * @file
 * This is the emimage.module's install, configuration, and removal instructions.
 */

/**
 * Implementation of hook_install().
 */
function emimage_install() {
  drupal_load('module', 'content');
  content_notify('install', 'emimage');

  // Fix up our mess from image_ncck, if necessary.
  return _emimage_upgrade_from_image_ncck();
}

/**
 * Implementation of hook_uninstall().
 */
function emimage_uninstall() {
  drupal_load('module', 'content');
  content_notify('uninstall', 'emimage');
}

/**
 * Implementation of hook_enable().
 */
function emimage_enable() {
  drupal_load('module', 'content');
  content_notify('enable', 'emimage');
}

/**
 * Implementation of hook_disable().
 */
function _emimage_upgrade_from_image_ncck() {
  $ret = array();

  // Change any fields from 'image_ncck' to 'emimage' type.
  db_query("UPDATE {content_node_field} SET type='emimage' WHERE type='image_ncck'");
  db_query("UPDATE {content_node_field_instance} SET widget_type='emimage_textfields' WHERE widget_type='image_ncck_textfields'");

  // Rebuild our content types.
  content_clear_type_cache();

  // Load our existing fields.
  $fields = content_fields();
  drupal_load('module', 'emfield');
  foreach (emfield_system_list('emimage') as $provider) {
    $test = variable_get('emfield_image_ncck_allow_' . $provider->name, NULL) || variable_get('image_ncck_allow_' . $provider->name, NULL);
    if (isset($test)) {
      variable_set('emfield_emimage_allow_' . $provider->name, $test);
      variable_del('emfield_image_ncck_allow_' . $provider->name);
      variable_del('image_ncck_allow_' . $provider->name);
    }
  }

  // </Fancy Hand-Waving>
  return TRUE;
}
function emimage_disable() {
  drupal_load('module', 'content');
  content_notify('disable', 'emimage');
}
function emimage_update_1() {
  $ret = _emimage_update_reset_cache_views();
  return $ret;
}
function emimage_update_6001() {

  // We added options to themes, so need to rebuild the theme registry.
  drupal_rebuild_theme_registry();
  return array();
}
function emimage_update_6002() {

  // We added options to themes, so need to rebuild the theme registry.
  drupal_rebuild_theme_registry();
  $ret[] = array(
    'query' => t('Rebuilt the theme to accommodate new options.'),
    'success' => TRUE,
  );
  return $ret;
}

// I'd like this to be conditional, so it only runs if they don't have Views installed.
// However, module_exists doesn't actually work in the update scripts.
// TODO: Conditional on if table exists instead...
function _emimage_update_reset_cache_views() {
  $ret = array();
  $ret[] = update_sql("DELETE FROM {cache_views}");
  return $ret;
}