| 1 |
<?php
|
| 2 |
// $Id: subscriptions_taxonomy.install,v 1.2 2009/07/20 21:55:53 salvis Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Subscriptions Taxonomy module installation.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of hook_install().
|
| 11 |
*/
|
| 12 |
function subscriptions_taxonomy_install() {
|
| 13 |
}
|
| 14 |
|
| 15 |
/**
|
| 16 |
* Database update function 2 (replaces update function 1!).
|
| 17 |
*
|
| 18 |
* Remove taxonomy subscriptions left over from deleted terms.
|
| 19 |
*/
|
| 20 |
function subscriptions_taxonomy_update_2() {
|
| 21 |
$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(' : '')
|
| 22 |
."t.tid". ($GLOBALS['db_type'] == 'pgsql' ? ' AS VARCHAR)' : '')
|
| 23 |
." WHERE s.module = 'node' AND s.field = 'tid' AND t.tid IS NULL");
|
| 24 |
while ($orphan = db_fetch_array($result)) {
|
| 25 |
$orphans[] = $orphan['tid'];
|
| 26 |
}
|
| 27 |
if (isset($orphans)) {
|
| 28 |
db_query("DELETE FROM {subscriptions_queue} WHERE module = 'node' AND field = 'tid' AND value IN (". db_placeholders($orphans, 'varchar') .")", $orphans);
|
| 29 |
$orphans = NULL;
|
| 30 |
}
|
| 31 |
$result = db_query("SELECT s.value AS tid FROM {subscriptions} s LEFT JOIN {term_data} t ON s.value = ". ($GLOBALS['db_type'] == 'pgsql' ? 'CAST(' : '')
|
| 32 |
."t.tid". ($GLOBALS['db_type'] == 'pgsql' ? ' AS VARCHAR)' : '')
|
| 33 |
." WHERE s.module = 'node' AND s.field = 'tid' AND t.tid IS NULL");
|
| 34 |
while ($orphan = db_fetch_array($result)) {
|
| 35 |
$orphans[] = $orphan['tid'];
|
| 36 |
}
|
| 37 |
if (isset($orphans)) {
|
| 38 |
db_query("DELETE FROM {subscriptions} WHERE module = 'node' AND field = 'tid' AND value IN (". db_placeholders($orphans, 'varchar') .")", $orphans);
|
| 39 |
}
|
| 40 |
return array();
|
| 41 |
}
|
| 42 |
|
| 43 |
/**
|
| 44 |
* Implementation of hook_uninstall().
|
| 45 |
*/
|
| 46 |
function subscriptions_taxonomy_uninstall() {
|
| 47 |
}
|