You are here

hierarchical_select.install in Hierarchical Select 5.2

File

hierarchical_select.install
View source
<?php

/**
 * Implementation of hook_install().
 */
function hierarchical_select_install() {

  // Ensure the Hierarchical Select module runs after the Taxonomy and Content
  // Taxonomy modules! This should not be necessary to do, but apparently some
  // idiot module developer is changing the weight of the Taxonomy module...
  $weight = db_result(db_query("SELECT weight FROM {system} WHERE name = 'taxonomy'"));
  $weight = max($weight, db_result(db_query("SELECT weight FROM {system} WHERE name = 'content_taxonomy'")));

  // Also ensure the Hierarchical Select module runs after the i18ntaxonomy
  // module.
  $weight = max($weight, db_result(db_query("SELECT weight FROM {system} WHERE name = 'i18ntaxonomy'")));
  db_query("UPDATE {system} SET weight = %d WHERE name  = '%s'", $weight + 1, 'hierarchical_select');
}

//----------------------------------------------------------------------------

// Schema updates.
// Update module weight.
function hierarchical_select_update_1() {
  $ret = array();

  // Ensure the Hierarchical Select module runs after the Taxonomy and Content
  // Taxonomy modules! This should not be necessary to do, but apparently some
  // idiot module developer is changing the weight of the Taxonomy module...
  $weight = db_result(db_query("SELECT weight FROM {system} WHERE name = 'taxonomy'"));
  $weight = max($weight, db_result(db_query("SELECT weight FROM {system} WHERE name = 'content_taxonomy'")));
  $weight++;
  $ret[] = update_sql("UPDATE {system} SET weight = {$weight} WHERE name  = 'hierarchical_select'");
  return $ret;
}

// Update module weight again, this time for i18ntaxonomy compatibility.
function hierarchical_select_update_2() {
  $ret = array();
  $weight = db_result(db_query("SELECT weight FROM {system} WHERE name = 'taxonomy'"));
  $weight = max($weight, db_result(db_query("SELECT weight FROM {system} WHERE name = 'content_taxonomy'")));
  $weight = max($weight, db_result(db_query("SELECT weight FROM {system} WHERE name = 'i18ntaxonomy'")));
  $weight++;
  $ret[] = update_sql("UPDATE {system} SET weight = {$weight} WHERE name  = 'hierarchical_select'");
  return $ret;
}