<?php
//$Id: date_popup.install,v 1.5.6.5 2009/02/16 23:46:08 karens Exp $
/**
 * Implementation of hook_install().
 */
function date_popup_install() {
  if (module_exists('content')) {
    drupal_load('module', 'content');
    if (!db_table_exists(content_instance_tablename())) {
      return;
    }
    if (module_exists('date_repeat')) {
      db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=1 WHERE widget_type='%s' OR widget_type='%s'", 'date_popup', 'date_popup_repeat');
    }
    else {
      db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=1 WHERE widget_type='%s'", 'date_popup');
    }
    content_clear_type_cache(TRUE);
  }
}

/**
 * Implementation of hook_uninstall().
 */
function date_popup_uninstall() {
  if (module_exists('content')) {
    drupal_load('module', 'content');
    if (!db_table_exists(content_instance_tablename())) {
      return;
    }
    if (module_exists('date_repeat')) {
      db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_type='%s' OR widget_type='%s'", 'date_popup', 'date_popup_repeat');
    }
    else {
      db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_type='%s'", 'date_popup');
    }
    content_clear_type_cache(TRUE);
  }
}

/**
 * Implementation of hook_enable().
 */
function date_popup_enable() {
  if (module_exists('content')) {
    drupal_load('module', 'content');
    if (!db_table_exists(content_instance_tablename())) {
      return;
    }
    if (module_exists('date_repeat')) {
      db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=1 WHERE widget_type='%s' OR widget_type='%s'", 'date_popup', 'date_popup_repeat');
    }
    else {
      db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=1 WHERE widget_type='%s'", 'date_popup');
    }
    content_clear_type_cache(TRUE);
  }
}

/**
 * Implementation of hook_disable().
 */
function date_popup_disable() {
  if (module_exists('content')) {
    drupal_load('module', 'content');
    if (!db_table_exists(content_instance_tablename())) {
      return;
    }
    if (module_exists('date_repeat')) {
      db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_type='%s' OR widget_type='%s'", 'date_popup', 'date_popup_repeat');
    }
    else {
      db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_type='%s'", 'date_popup');
    }
    content_clear_type_cache(TRUE);
  }
}