You are here

subscriptions_content.install in Subscriptions 5.2

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

Subscriptions Content module installation.

File

subscriptions_content.install
View source
<?php

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

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

  // subscriptions_content.module needs to be heavier than taxonomy.module --
  // otherwise term_node record has not been written when subscriptions_queue() is called!
  // subscriptions_content_cron() will ensure this constraint at run-time.
  $weight = 1 + db_result(db_query("SELECT weight FROM {system} WHERE name = 'taxonomy' AND type = 'module'"));
  db_query("UPDATE {system} SET weight = %d WHERE name = 'subscriptions_content' AND type = 'module'", $weight);

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

/**
 * Database update function 1.
 * 
 * Remove content type subscriptions left over from deleted content types.
 */
function subscriptions_content_update_1() {
  $result = db_query("SELECT s.value AS tid FROM {subscriptions_queue} s LEFT JOIN {node_type} t ON s.value = t.type WHERE s.module = 'node' AND s.field = 'type' AND t.type 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 = 'type' AND value IN (" . implode(',', $placeholders) . ")", $orphans);
    $orphans = $placeholders = NULL;
  }
  $result = db_query("SELECT s.value AS tid FROM {subscriptions} s LEFT JOIN {node_type} t ON s.value = t.type WHERE s.module = 'node' AND s.field = 'type' AND t.type 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 = 'type' AND value IN (" . implode(',', $placeholders) . ")", $orphans);
  }
  return array();
}

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

Functions

Namesort descending Description
subscriptions_content_install Implementation of hook_install().
subscriptions_content_uninstall Implementation of hook_uninstall().
subscriptions_content_update_1 Database update function 1.