--- d:\drupal-4.5.2\modules\taxonomy.module Fri Dec 24 07:49:46 2004 +++ d:\ccoro\modules\taxonomy.module Mon Jan 24 00:11:04 2005 @@ -804,7 +804,11 @@ * @return * A resource identifier pointing to the query results. */ -function taxonomy_select_nodes($tids = array(), $operator = 'or', $depth = 0, $pager = TRUE) { +function taxonomy_select_nodes($tids = array(), $operator = 'or', $depth = 0, $pager = TRUE, $types=array()) { + // build type filter + $typefilter = ''; + if (!empty($types)) $typefilter = " AND n.type IN ('". implode("', '", $types) ."')"; + if (count($tids) > 0) { // For each term ID, generate an array of descendant term IDs to the right depth. $descendant_tids = array(); @@ -819,8 +823,8 @@ if ($operator == 'or') { $str_tids = implode(',', call_user_func_array('array_merge', $descendant_tids)); - $sql = 'SELECT DISTINCT(n.nid), n.sticky, n.created FROM {node} n '. node_access_join_sql() .' INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('. $str_tids .') AND n.status = 1 AND '. node_access_where_sql() .' ORDER BY n.sticky DESC, n.created DESC'; - $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n '. node_access_join_sql() .' INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('. $str_tids .') AND n.status = 1 AND '. node_access_where_sql(); + $sql = 'SELECT DISTINCT(n.nid), n.sticky, n.created FROM {node} n '. node_access_join_sql() .' INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('. $str_tids .') AND n.status = 1 AND '. node_access_where_sql() . $typefilter . ' ORDER BY n.sticky DESC, n.created DESC'; + $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n '. node_access_join_sql() .' INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('. $str_tids .') AND n.status = 1 ' . $typefilter . ' AND '. node_access_where_sql(); } else { $joins = ''; @@ -829,8 +833,8 @@ $joins .= ' INNER JOIN {term_node} tn'. $index .' ON n.nid = tn'. $index .'.nid'; $wheres .= ' AND tn'. $index .'.tid IN ('. implode(',', $tids) .')'; } - $sql = 'SELECT DISTINCT(n.nid), n.sticky, n.created FROM {node} n '. node_access_join_sql() . $joins .' WHERE n.status = 1 AND '. node_access_where_sql() . $wheres .' ORDER BY n.sticky DESC, n.created DESC'; - $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n '. node_access_join_sql() . $joins .' WHERE n.status = 1 AND '. node_access_where_sql() . $wheres; + $sql = 'SELECT DISTINCT(n.nid), n.sticky, n.created FROM {node} n '. node_access_join_sql() . $joins .' WHERE n.status = 1 AND '. node_access_where_sql() . $wheres . $typefilter . ' ORDER BY n.sticky DESC, n.created DESC'; + $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n '. node_access_join_sql() . $joins .' WHERE n.status = 1 ' . $typefilter . ' AND '. node_access_where_sql() . $wheres; } if ($pager) { @@ -882,6 +886,16 @@ * Menu callback; displays all nodes associated with a term. */ function taxonomy_term_page($str_tids = '', $depth = 0, $op = 'page') { + // extract node types + list($str_tids,$tps) = split ('[()]', $str_tids); + // check every node type + if (!empty($tps)) { + $types=explode(',',$tps); + foreach ($types as $tp => $c) { + if (!in_array($c, node_list())) drupal_not_found(); + } + } + if (preg_match('/^([0-9]+[+ ])+[0-9]+$/', $str_tids)) { $operator = 'or'; // The '+' character in a query string may be parsed as ' '. @@ -922,7 +936,7 @@ drupal_set_html_head(''); - $output = taxonomy_render_nodes(taxonomy_select_nodes($tids, $operator, $depth, TRUE)); + $output = taxonomy_render_nodes(taxonomy_select_nodes($tids, $operator, $depth, TRUE, $types)); $output .= theme('xml_icon', url("taxonomy/term/$str_tids/$depth/feed")); print theme('page', $output, $title); break; @@ -933,7 +947,7 @@ $channel['title'] = variable_get('site_name', 'drupal') .' - '. $title; $channel['description'] = $term->description; - $result = taxonomy_select_nodes($tids, $operator, $depth, FALSE); + $result = taxonomy_select_nodes($tids, $operator, $depth, FALSE, $types); node_feed($result, $channel); break; default: