<?php
/**
 * @file
 * Install file for Date Repeat.
 */
/**
 * Implementation of hook_install().
 */
function date_repeat_install() {
  // Make sure this module loads after date_api.
  db_query("UPDATE {system} SET weight = 1 WHERE name = 'date_repeat'");
  if (module_exists('content')) {
    drupal_load('module', 'content');
    if (!db_table_exists(content_instance_tablename())) {
      return;
    }
    db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=1 WHERE widget_type='%s' OR widget_type='%s' OR widget_type='%s'", 'date_select_repeat', 'date_text_repeat', 'date_popup_repeat');
    content_clear_type_cache(TRUE);
  }
}

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

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

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