| 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 |
}
|