You are here

function subscriptions_taxonomy_taxonomy in Subscriptions 6

Same name and namespace in other branches
  1. 5.2 subscriptions_taxonomy.module \subscriptions_taxonomy_taxonomy()

Implementation of hook_taxonomy().

Remove taxonomy subscriptions when the underlying terms or vocabularies are removed.

File

./subscriptions_taxonomy.module, line 375
Subscriptions to taxonomy terms.

Code

function subscriptions_taxonomy_taxonomy($op, $type, $array) {
  if ($op != 'delete') {
    return;
  }
  switch ($type) {
    case 'term':
      $tid = $array['tid'];
      db_query("DELETE FROM {subscriptions_queue} WHERE module = 'node' AND field = 'tid' AND value = '%s'", $tid);
      db_query("DELETE FROM {subscriptions} WHERE module = 'node' AND field = 'tid' AND value = '%s'", $tid);
      break;
    case 'vocabulary':
      $vid = $array['vid'];
      foreach (array(
        'omitted',
        'restricted',
      ) as $key) {
        $array = variable_get('subscriptions_' . $key . '_taxa', array());
        unset($array[$vid]);
        variable_set('subscriptions_' . $key . '_taxa', $array);
      }
      break;
  }
}