[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

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

   1  <?php
   2  // $Id: features.install,v 1.1.2.6 2009/12/21 16:58:45 yhahn Exp $
   3  
   4  /**
   5   * Implementaton of hook_install().
   6   */
   7  function features_install() {
   8    _features_install_menu();
   9    db_query("UPDATE {system} SET weight = 20 WHERE name = 'features' AND type = 'module'");
  10  }
  11  
  12  /**
  13   * Implementation of hook_uninstall().
  14   */
  15  function features_uninstall() {
  16    variable_del('features_codecache');
  17    variable_del('features_semaphore');
  18    variable_del('features_ignored_orphans');
  19    db_query("DELETE FROM {menu_custom} WHERE menu_name = 'features'");
  20    db_query("DELETE FROM {menu_links} WHERE module = 'features'");
  21  }
  22  
  23  /**
  24   * Create menu. See menu.install for an example.
  25   */
  26  function _features_install_menu() {
  27    if (db_table_exists('menu_custom') && !db_result(db_query("SELECT menu_name FROM {menu_custom} WHERE menu_name = 'features'"))) {
  28      $t = get_t();
  29      db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '%s')", 'features', $t('Features'), $t('Menu items for any enabled features.'));
  30    }
  31  }
  32  
  33  /**
  34   * Update 6100: Set module on all feature node types to 'features'.
  35   
  36   * This update can be re-run as needed to repair any node types that are not 
  37   * removed after disabling the associated feature.
  38   * 
  39   * Any feature implementing a node component that was exported prior to this 
  40   * version of the features.module will need to have its 'module' declaration 
  41   * in hook_node_info() changed from 'node' to 'features'.
  42   */
  43  function features_update_6100() {
  44    $ret = array();
  45  
  46    foreach (features_get_features(NULL, TRUE) as $feature) {
  47      if (module_exists($feature->name) && $types = module_invoke($feature->name, 'node_info')) {
  48        foreach ($types as $type => $type_data) {
  49          $sql = "SELECT COUNT(*) FROM {node_type} WHERE module = 'node' AND type = '%s'";
  50          // Only update if the hook_node_info type's module is 'features' and the db type's
  51          // module is 'node'.
  52          if (($type_data['module'] == 'features') && db_result(db_query($sql, $type))) {
  53            $ret[] = update_sql("UPDATE {node_type} SET module = 'features' WHERE type = '$type'");
  54          }
  55        }
  56      }
  57    }
  58    return $ret;
  59  }
  60  
  61  /**
  62   * Update 6101: Set codestate signature for all features.
  63   *
  64   * This update generates a codestate for all feature/component pairs which
  65   * have been installed prior to this version of Features. This prevents
  66   * automatic rebuilds from occurring against any rebuildable components
  67   * that have been overridden.
  68   */
  69  function features_update_6101() {
  70    // Ensure all of our own API functions still exist in in this version
  71    // of Features. It's possible that the "future me" will not have these
  72    // functions, so I should check.
  73    module_load_include('inc', 'features', "features.export");
  74    $functions = array(
  75      'features_include',
  76      'features_hook',
  77      'features_get_components',
  78      'features_get_features',
  79      'features_get_signature',
  80      'features_set_signature',
  81    );
  82    $doit = TRUE;
  83    foreach ($functions as $function) {
  84      $doit = $doit && function_exists($function);
  85    }
  86    if ($doit) {
  87      features_include();
  88      $features = array_keys(features_get_features(NULL, TRUE));
  89      $components = array_keys(features_get_components());
  90      foreach ($features as $feature) {
  91        if (module_exists($feature)) {
  92          foreach ($components as $component) {
  93            if (features_hook($component, 'features_rebuild') && features_get_signature('cache', $feature, $component) === FALSE) {
  94              features_set_signature($feature, $component, -1);
  95            }
  96          }
  97        }
  98      }
  99    }
 100    return array();
 101  }


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