[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/vertical_tabs/ -> vertical_tabs.install (source)

   1  <?php
   2  // $Id: vertical_tabs.install,v 1.1.2.11 2010/02/03 19:06:46 davereid Exp $
   3  
   4  /**
   5   * @file
   6   * Install, update and uninstall functions for the vertical_tabs module.
   7   */
   8  
   9  /**
  10   * Implement hook_install().
  11   */
  12  function vertical_tabs_install() {
  13    // Make this module's weight heavy so it runs after most form alterations.
  14    db_query("UPDATE {system} SET weight = 300 WHERE type = 'module' AND name = 'vertical_tabs'");
  15  }
  16  
  17  /**
  18   * Implement hook_enable().
  19   */
  20  function vertical_tabs_enable() {
  21    // Generate color stylesheet.
  22    vertical_tabs_install_color_generate();
  23  }
  24  
  25  /**
  26   * Implement hook_uninstall().
  27   */
  28  function vertical_tabs_uninstall() {
  29    variable_del('vertical_tabs_forms');
  30    variable_del('vertical_tabs_default');
  31    variable_del('vertical_tabs_minimum');
  32  }
  33  
  34  /**
  35   * Reduce the module weight and remove the form settings variable.
  36   */
  37  function vertical_tabs_update_6100() {
  38    $ret = array();
  39    $ret[] = update_sql("UPDATE {system} SET weight = 300 WHERE type = 'module' AND name = 'vertical_tabs'");
  40    variable_del('vertical_tabs_settings_form');
  41    return $ret;
  42  }
  43  
  44  /**
  45   * Color-enable the module if using Garland.
  46   */
  47  function vertical_tabs_update_6101() {
  48    vertical_tabs_install_color_generate();
  49    return array();
  50  }
  51  
  52  /**
  53   * Regenerate the stylesheets if using Garland to accomidate for CSS changes.
  54   */
  55  function vertical_tabs_update_6102() {
  56    vertical_tabs_install_color_generate();
  57    return array();
  58  }
  59  
  60  /**
  61   * Remove any variables of deleted node types.
  62   */
  63  function vertical_tabs_update_6103() {
  64    $query = db_query("SELECT name FROM {variable} WHERE name LIKE 'vertical_tabs_fieldsets_%%'");
  65    $node_types = node_get_types('names');
  66    while ($variable = db_result($query)) {
  67      $node_type = substr($variable, 24);
  68      if (!isset($node_types[$node_type])) {
  69        variable_del($variable);
  70      }
  71    }
  72    return array();
  73  }
  74  
  75  /**
  76   * Delete the node type fieldset configurations.
  77   */
  78  function vertical_tabs_update_6104() {
  79    $config = variable_get('vertical_tabs_forms', array());
  80    $node_types = array_keys(node_get_types('names'));
  81    foreach ($node_types as $node_type) {
  82      $node_type_setting = 'vertical_tabs_fieldsets_' . $node_type;
  83      if (!variable_get($node_type_setting, array())) {
  84        $config[$node_type . '_node_form'] = FALSE;
  85      }
  86      variable_del($node_type_setting);
  87    }
  88    variable_set('vertical_tabs_forms', $config);
  89    return array();
  90  }
  91  
  92  /**
  93   * Initialize the color-enabled stylesheet if using Garland.
  94   */
  95  function vertical_tabs_install_color_generate() {
  96    if (variable_get('theme_default', 'garland') == 'garland' || variable_get('admin_theme', '0') == 'garland') {
  97      if (module_exists('color')) {
  98        $theme = 'garland';
  99        $info = color_get_info($theme);
 100        $palette = color_get_palette($theme);
 101        drupal_load('module', 'vertical_tabs');
 102        vertical_tabs_generate_stylesheet('garland', $info, $palette);
 103      }
 104    }
 105  }


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7