[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/date/date_popup/ -> date_popup.install (source)

   1  <?php
   2  //$Id: date_popup.install,v 1.5.6.10 2010/12/21 12:21:16 karens Exp $
   3  
   4  /**
   5   * Implementation of hook_requirements().
   6   * Added to be sure the Date API version matches this code so invalid
   7   * functions are not called.
   8   */
   9  function date_popup_requirements($phase) {
  10    $requirements = array();
  11    $t = get_t();
  12    switch ($phase) {
  13      case 'runtime':
  14        if (!module_exists('jquery_ui')) {
  15          $requirements['date_popup_jquery_ui'] = array(
  16            'title' => $t('Date Popup requirements'),
  17            'value' => $t('The Date Popup module needs code added by the <a href="http://drupal.org/project/jquery_ui">jQuery UI module.</a> This is not yet a requirement, but soon will be, so you are encouraged to install that module as soon as possible. In the meantime, a version of the needed code is included here.'),
  18            'severity' => REQUIREMENT_WARNING,
  19            );
  20        }
  21        break;
  22    }
  23    return $requirements;
  24  }
  25  
  26  /**
  27   * Implementation of hook_install().
  28   */
  29  function date_popup_install() {
  30    if (module_exists('content')) {
  31      drupal_load('module', 'content');
  32      if (!db_table_exists(content_instance_tablename())) {
  33        return;
  34      }
  35      if (module_exists('date_repeat')) {
  36        db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=1 WHERE widget_type='%s' OR widget_type='%s'", 'date_popup', 'date_popup_repeat');
  37      }
  38      else {
  39        db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=1 WHERE widget_type='%s'", 'date_popup');
  40      }
  41      content_clear_type_cache(TRUE);
  42    }
  43  }
  44  
  45  /**
  46   * Implementation of hook_uninstall().
  47   */
  48  function date_popup_uninstall() {
  49    if (module_exists('content')) {
  50      drupal_load('module', 'content');
  51      if (!db_table_exists(content_instance_tablename())) {
  52        return;
  53      }
  54      if (module_exists('date_repeat')) {
  55        db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_type='%s' OR widget_type='%s'", 'date_popup', 'date_popup_repeat');
  56      }
  57      else {
  58        db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_type='%s'", 'date_popup');
  59      }
  60      content_clear_type_cache(TRUE);
  61    }
  62  }
  63  
  64  /**
  65   * Implementation of hook_enable().
  66   */
  67  function date_popup_enable() {
  68    if (module_exists('content')) {
  69      drupal_load('module', 'content');
  70      if (!db_table_exists(content_instance_tablename())) {
  71        return;
  72      }
  73      if (module_exists('date_repeat')) {
  74        db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=1 WHERE widget_type='%s' OR widget_type='%s'", 'date_popup', 'date_popup_repeat');
  75      }
  76      else {
  77        db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=1 WHERE widget_type='%s'", 'date_popup');
  78      }
  79      content_clear_type_cache(TRUE);
  80    }
  81  }
  82  
  83  /**
  84   * Implementation of hook_disable().
  85   */
  86  function date_popup_disable() {
  87    if (module_exists('content')) {
  88      drupal_load('module', 'content');
  89      if (!db_table_exists(content_instance_tablename())) {
  90        return;
  91      }
  92      if (module_exists('date_repeat')) {
  93        db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_type='%s' OR widget_type='%s'", 'date_popup', 'date_popup_repeat');
  94      }
  95      else {
  96        db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_type='%s'", 'date_popup');
  97      }
  98      content_clear_type_cache(TRUE);
  99    }
 100  }
 101  
 102  /**
 103   * Update default path for date popup css
 104   */
 105  function date_popup_update_6001() {
 106    $ret = array();
 107    $version = function_exists('jquery_ui_get_version') ? jquery_ui_get_version() : '1.6';
 108    switch ($version) {
 109      case '1.6':
 110        $path = drupal_get_path('module', 'date_popup') . '/themes/datepicker.css';
 111        break;
 112      default:
 113        $path = drupal_get_path('module', 'date_popup') . '/themes/datepicker.1.7.css';
 114        break;
 115    }
 116    variable_set('date_popup_css_file', $path);
 117    if (!module_exists('jquery_ui')) {
 118      drupal_set_message('The jQuery UI module is now required when using Date Popup. See the <a href="http://drupal.org/project/jquery_ui">jQuery UI</a> page for installation instructions.', 'error');
 119    }
 120    return $ret;
 121  }


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7