<?php
// $Id: basic_metatags.install,v 1.1.2.10 2009/09/23 09:38:56 kiam Exp $

/**
 * @file
 * Installation file for Basic meta tags.
 */

/**
 * Implementation of hook_install().
 */
function basic_metatags_install() {
  $table = db_table_exists('nodewords') ? '{nodewords}' : '{metatags}';
  db_query("DELETE FROM {" . $table . "} WHERE type = 'robots'");
  db_query("UPDATE {system} SET weight = 10 WHERE name = 'basic_metatags'");
}

/**
 * Implementation of hook_update_NN().
 */
function basic_metatags_update_6100() {
  $ret = array();
  $table = db_table_exists('nodewords') ? '{nodewords}' : '{metatags}';

  $ret[] = update_sql("DELETE FROM {" . $table . "} WHERE type = 'robots'");

  return $ret;
}

/**
 * Implementation of hook_update_NN().
 */
function basic_metatags_update_6101() {
  $ret = array();

  $ret[] = update_sql("UPDATE {system} SET weight = 10 WHERE name = 'basic_metatags'");

  return $ret;
}

/**
 * Implementation of hook_uninstall().
 */
function basic_metatags_uninstall() {
  $table = db_table_exists('nodewords') ? '{nodewords}' : '{metatags}';

  if (db_table_exists($table)) {
    $metatags = array(
      'abstract',
      'canonical',
      'copyright',
      'description',
      'keywords',
      'revisit-after',
      'robots'
    );

    db_query("DELETE FROM {" . $table . "} WHERE name IN (" . db_placeholders($metatags, 'varchar') . ")", $metatags);
  }

  db_query("DELETE FROM {variable} WHERE name LIKE 'basic\_metatags\_%'");
}
