You are here

function smartqueue_taxonomy in Nodequeue 5.2

Same name and namespace in other branches
  1. 6.2 smartqueue.module \smartqueue_taxonomy()

Implementation of hook_taxonomy.

2 string references to 'smartqueue_taxonomy'
nodequeue_generate_form_submit in ./nodequeue_generate.module
nodequeue_generate_rehash in ./nodequeue_generate.module
Rebuild all smartqueue_taxonomy queues. Useful after a data migration has wiped your terms. When more smartqueue modules arrive, revisit this function.

File

./smartqueue.module, line 181

Code

function smartqueue_taxonomy($op, $type, $array = NULL) {
  switch ($type) {
    case 'term':
      switch ($op) {

        // If a term was updated, we need to update any relevant nodequeue titles.
        case 'update':
          $tid = $array['tid'];

          // Find subqueues that contain this term.
          $result = db_query("SELECT nq.reference AS reference, sq.reference AS sqref, sq.sqid\n            FROM {nodequeue_queue} nq\n            INNER JOIN {nodequeue_subqueue} sq ON nq.qid = sq.qid\n            WHERE nq.owner = 'smartqueue_taxonomy'\n            AND (sq.reference = '%d'\n              OR sq.reference LIKE '%%-%d'\n              OR sq.reference LIKE '%d-%%'\n              OR sq.reference LIKE '%%-%d-%%')", $tid, $tid, $tid, $tid);
          while ($row = db_fetch_object($result)) {

            // Note that $row already contains the needed $row->reference.
            $title = smartqueue_taxonomy_nodequeue_subqueue_title($row, $row->sqref);
            nodequeue_subqueue_update_title($row->sqid, $title);
          }
          break;

        // If a term was deleted, we need to delete any subqueues containing it.
        case 'delete':
          $tid = $array['tid'];

          // Find subqueues that contain this term.
          $result = db_query("SELECT sq.sqid FROM {nodequeue_subqueue} sq\n            INNER JOIN {nodequeue_queue} nq ON sq.qid = nq.qid\n            WHERE nq.owner = 'smartqueue_taxonomy'\n            AND (sq.reference = '%d'\n              OR sq.reference LIKE '%%-%d'\n              OR sq.reference LIKE '%d-%%'\n              OR sq.reference LIKE '%%-%d-%%')", $tid, $tid, $tid, $tid);
          while ($row = db_fetch_object($result)) {
            nodequeue_remove_subqueue($row->sqid);
          }
          break;
      }
    case 'vocabulary':
      break;
  }
}