You are here

function merci_enable in MERCI (Manage Equipment Reservations, Checkout and Inventory) 6.2

Same name and namespace in other branches
  1. 6 merci.install \merci_enable()
  2. 7.2 merci.install \merci_enable()

Implementation of hook_enable().

File

./merci.install, line 76
merci Installer / Uninstaller

Code

function merci_enable() {
  merci_add_group_taxonomy();
  merci_create_cck_fields();

  // Add any node types to the MERCI tables that aren't already there.
  $existing_types = db_query("SELECT type FROM {merci_node_type}");
  $types = array();
  while ($existing_type = db_fetch_object($existing_types)) {
    $types[] = $existing_type->type;
  }
  if (empty($types)) {
    $new_types = db_query("SELECT type FROM {node_type}");
  }
  else {
    $new_types = db_query(db_rewrite_sql("SELECT type FROM {node} n WHERE type NOT IN (" . db_placeholders($types, 'varchar') . ")"), $types);
  }
  while ($new_type = db_fetch_object($new_types)) {
    db_query("INSERT INTO {merci_node_type} (type) VALUES ('%s')", $new_type->type);
  }
  $results = db_query("SELECT type,merci_type_setting,merci_grouping FROM {merci_node_type}");
  while ($result = db_fetch_array($results)) {
    variable_set('merci_type_setting_' . $result['type'], $result['merci_type_setting']);
    variable_set('merci_grouping_' . $result['type'], $result['merci_grouping']);
  }

  //merci_check_default_timezone();
}