Subscriptions taxonomy from multiple vocabularies (Drupal 6)

Sometimes the needed functionality that goes beyond the boundaries of what we have.
But the problem is trivial, and there is no solution - we have to finish her ​​decision on the basis of existing modules.

So, the problem is to select the module Substsriptions terms from different vocabularies s

o that the filtered material in the subscription as the "AND" rather than "OR".

The solution I found is not optimal, but still works.
During the creation of a new node module looks for all the subscriptions of users who subscribe to terms which are present in this node. For this purpose, the module creates subscriptions SQL-query which we can supplement with the hooks. Yes, that complement, rather than modify, it is important.

So, I created a new module in which there is only one function, called - "_subscriptions_taxonomy_queue". So, it's not quite the right hook, he is likely done for the internal modules. But it works.
Inside, we add to the SQL-query our condition. It states that if a user selected terms from the two dictionaries, then add nodes to the subscriptions queue only when the node has at least one term from each vocabulary.

/**
 * Implementation of hook_subscriptions().
 *
 * @ingroup hooks
 * @param null $arg0
 * @param null $arg1
 * @param null $arg2
 * @return array|null
 */
function _subscriptions_taxonomy_queue($arg0 = NULL, $arg1 = NULL, $arg2 = NULL) {

  if ($arg0['module'] == 'node') {
    $node = $arg0['node'];

    $tid = 'tid';
    if ($GLOBALS['db_type'] == 'pgsql') {
      $tid = "САSТ(" . $tid . " AS VАRСНАR )";
    }
    $params['node']['tid'] = array(
      'join' => 'INNER JOIN {term_node} tn ON s.value = ' . $tid,
      'where' => 'tn.nid = %d',
      'args' => array($node->nid),
      'groupby' => 'GROUP BY u.uid, tn.nid',
    );

    foreach($node->taxonomy AS $vid => $tids) {
      if (is_numeric($vid))
        $params['node']['tid']['where'] .= " АND ЕXISТS (SЕLЕСТ sqs.* FRОМ {subscriptions} sqs INNЕR JОIN {term_data} sqtd ON sqtd.tid = sqs.value WНЕRЕ sqs.recipient_uid = s.recipient_uid АND sqs.value IN (" . implode(',', $tids) . ") АND sqtd.vid = " . $vid . " )";
    }

    if ($arg0['type'] == 'comment') {
      $where = ' AND s.send_comments = 1';
    }
    elseif ($arg0['type'] == 'node' && $arg0['action'] == 'update') {
      $where  = ' AND s.send_updates = 1';
    }
    if (isset($where)) {
      $params['node']['tid']['where'] .= $where;
    }
    return $params;
  }
}
Rating: 
0 out of 10 based on 0 ratings.
Tags: