You are here

autotag.install in Taxonomy Autotagger 6.2

Same filename and directory in other branches
  1. 8.3 autotag.install
  2. 6 autotag.install
  3. 7.3 autotag.install

File

autotag.install
View source
<?php

/**
 * hook_install
 */
function autotag_install() {

  // We need to ensure the module is a little weightier than the taxonomy module
  // in order to ensure this modules hook executes after taxonomy's.
  $result[] = db_query("UPDATE {system} SET weight=10 WHERE name='autotag'");

  // Create tables.
  drupal_install_schema('autotag');
}

/**
 * hook_schema
 */
function autotag_schema() {
  return array(
    'autotag' => array(
      'fields' => array(
        'nid' => array(
          'type' => 'int',
          'not null' => true,
        ),
        'tid' => array(
          'type' => 'int',
          'not null' => true,
        ),
      ),
      'primary key' => array(
        'nid',
        'tid',
      ),
    ),
  );
}
function autotag_update_6101() {
  $result = array();
  $taxonomy_weight = array_pop(db_fetch_array(db_query("SELECT weight FROM {system} WHERE name='taxonomy'")));
  $result[] = update_sql("UPDATE {system} SET weight=%d WHERE name='autotag'", $taxonomy_weight + 10);
  return $result;
}
function autotag_update_6102() {
  variable_set('autotag_node_preview', variable_get('node_preview', 1));
  variable_set('node_preview', 0);
  return array(
    '#finished' => TRUE,
  );
}
function autotag_update_6103() {
  variable_set('autotag_node_preview', variable_get('node_preview', 1));
  variable_set('autotag_broken_node_types', array_unique(array_merge(variable_get('autotag_broken_node_types', array(
    'webform',
    'biblio',
  )), array(
    'image',
  ))));
  return array(
    '#finished' => TRUE,
  );
}
function autotag_update_6104() {
  $result = array();
  $field_group_weight = array_pop(db_fetch_array(db_query("SELECT weight+1 FROM {system} WHERE name = 'fieldgroup'")));

  // $field_group_weight is guaranteed to be clean, so this is OK!
  $result[] = update_sql("UPDATE {system} SET weight = {$field_group_weight} WHERE name = 'autotag'");
  return $result;
}
function autotag_update_6105() {

  // 6103 has failed due to code in the nexus.install file which didn't mention
  // the image module.
  variable_set('autotag_broken_node_types', array_unique(array_merge(variable_get('autotag_broken_node_types', array()), array(
    'biblio',
    'image',
    'webform',
  ))));
  return array(
    '#finished' => TRUE,
  );
}
function autotag_update_6106() {

  // Set weight as 10 (more than fieldgroup and taxonomy).
  $result[] = db_query("UPDATE {system} SET weight=10 WHERE name='autotag'");
  return array(
    '#finished' => TRUE,
  );
}

/**
 * Update the menu.
 */
function autotag_update_6107() {
  return array(
    '#finished' => TRUE,
  );
}

/**
 * Clean up unwanted variables.
 */
function autotag_update_6201() {
  variable_del('autotag_broken_node_types');
  variable_del('autotag_disable_vids');
  variable_del('autotag_dont_autotag');
  variable_del('autotag_node_preview');
  variable_del('autotag_totally_borked');
  variable_del('autotag_without_user_input');
  return array(
    '#finished' => TRUE,
  );
}