You are here

subscriptions_taxonomy.install in Subscriptions 5.2

Same filename and directory in other branches
  1. 6 subscriptions_taxonomy.install
  2. 7 subscriptions_taxonomy.install

Subscriptions Taxonomy module installation.

File

subscriptions_taxonomy.install
View source
<?php

/**
 * @file
 * Subscriptions Taxonomy module installation.
 */

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

  // Make sure mail_edit picks up our new mailkeys.
  cache_clear_all('mail_edit_overview', 'cache');
}

/**
 * Database update function 2 (replaces update function 1!).
 * 
 * Remove taxonomy subscriptions left over from deleted terms.
 */
function subscriptions_taxonomy_update_2() {
  $result = db_query("SELECT s.value AS tid FROM {subscriptions_queue} s LEFT JOIN {term_data} t ON s.value = " . ($GLOBALS['db_type'] == 'pgsql' ? 'CAST(' : '') . "t.tid" . ($GLOBALS['db_type'] == 'pgsql' ? ' AS VARCHAR)' : '') . " WHERE s.module = 'node' AND s.field = 'tid' AND t.tid IS NULL");
  while ($orphan = db_fetch_array($result)) {
    $orphans[] = $orphan['tid'];
    $placeholders[] = "'%s'";
  }
  if (isset($orphans)) {
    db_query("DELETE FROM {subscriptions_queue} WHERE module = 'node' AND field = 'tid' AND value IN (" . implode(',', $placeholders) . ")", $orphans);
    $orphans = $placeholders = NULL;
  }
  $result = db_query("SELECT s.value AS tid FROM {subscriptions} s LEFT JOIN {term_data} t ON s.value = " . ($GLOBALS['db_type'] == 'pgsql' ? 'CAST(' : '') . "t.tid" . ($GLOBALS['db_type'] == 'pgsql' ? ' AS VARCHAR)' : '') . " WHERE s.module = 'node' AND s.field = 'tid' AND t.tid IS NULL");
  while ($orphan = db_fetch_array($result)) {
    $orphans[] = $orphan['tid'];
    $placeholders[] = "'%s'";
  }
  if (isset($orphans)) {
    db_query("DELETE FROM {subscriptions} WHERE module = 'node' AND field = 'tid' AND value IN (" . implode(',', $placeholders) . ")", $orphans);
  }
  return array();
}

/**
 * Implementation of hook_uninstall().
 */
function subscriptions_taxonomy_uninstall() {
}

Functions

Namesort descending Description
subscriptions_taxonomy_install Implementation of hook_install().
subscriptions_taxonomy_uninstall Implementation of hook_uninstall().
subscriptions_taxonomy_update_2 Database update function 2 (replaces update function 1!).