/[drupal]/contributions/modules/subscriptions/subscriptions_content.install
ViewVC logotype

Contents of /contributions/modules/subscriptions/subscriptions_content.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (show annotations) (download) (as text)
Thu Aug 14 14:59:06 2008 UTC (15 months, 1 week ago) by salvis
Branch: MAIN
CVS Tags: DRUPAL-6--1-0-RC1, DRUPAL-6--1-0, DRUPAL-6--1-1, DRUPAL-6--1-0-BETA3, DRUPAL-6--1-0-BETA2, DRUPAL-6--1-0-BETA6, DRUPAL-6--1-0-BETA5, DRUPAL-6--1-0-BETA4, HEAD
Changes since 1.4: +26 -3 lines
File MIME type: text/x-php
#291929: Use hook_taxonomy() and hook_node_type() to catch deletions and clean out orphaned subscriptions.
1 <?php
2 // $Id: subscriptions_content.install,v 1.4 2008/06/18 15:28:56 salvis Exp $
3
4 /**
5 * @file
6 * Subscriptions Content module installation.
7 */
8
9 /**
10 * Implementation of hook_install().
11 */
12 function subscriptions_content_install() {
13 // subscriptions_content.module needs to be heavier than taxonomy.module --
14 // otherwise term_node record has not been written when subscriptions_queue() is called!
15 // subscriptions_content_cron() will ensure this constraint at run-time.
16 $weight = 1 + db_result(db_query("SELECT weight FROM {system} WHERE name = 'taxonomy' AND type = 'module'"));
17 db_query("UPDATE {system} SET weight = %d WHERE name = 'subscriptions_content' AND type = 'module'", $weight);
18 }
19
20 /**
21 * Database update function 1.
22 *
23 * Remove content type subscriptions left over from deleted content types.
24 */
25 function subscriptions_content_update_1() {
26 $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");
27 while ($orphan = db_fetch_array($result)) {
28 $orphans[] = $orphan['tid'];
29 $placeholders[] = "'%s'";
30 }
31 if (isset($orphans)) {
32 db_query("DELETE FROM {subscriptions_queue} WHERE module = 'node' AND field = 'type' AND value IN (". implode(',', $placeholders) .")", $orphans);
33 $orphans = $placeholders = NULL;
34 }
35 $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");
36 while ($orphan = db_fetch_array($result)) {
37 $orphans[] = $orphan['tid'];
38 $placeholders[] = "'%s'";
39 }
40 if (isset($orphans)) {
41 db_query("DELETE FROM {subscriptions} WHERE module = 'node' AND field = 'type' AND value IN (". implode(',', $placeholders) .")", $orphans);
42 }
43 return array();
44 }
45
46 /**
47 * Implementation of hook_uninstall().
48 */
49 function subscriptions_content_uninstall() {
50 }

  ViewVC Help
Powered by ViewVC 1.1.2