--- taxonomySearch.module 2008-06-16 18:20:45.000000000 -0500 +++ taxonomySearch.module.patched 2008-06-16 18:21:16.000000000 -0500 @@ -98,14 +98,19 @@ function taxonomySearch_widget($op, &$no $options_term = array(); - foreach (taxonomy_get_tree($field['widget']['ts_vid']) as $term) { - $options_term[$term->tid] = $term->name; + $potential = array_keys(_nodereference_potential_references($field)); + if (!empty($potential)) { + $result = db_query('SELECT DISTINCT tid FROM {term_node} tn WHERE tn.nid IN ('.implode(',',$potential).')'); + $tids = array(); + while ($row = db_fetch_object($result)) $tids[] = $row->tid; + foreach (taxonomy_get_tree($field['widget']['ts_vid']) as $term) { + if (in_array($term->tid,$tids)) $options_term[]->option[$term->tid] = $term->name; + } } - $form[$fieldname]['ts_tids'] = array( '#type' => 'select', - '#title' => t($field['widget']['label'])." Selector ", + '#title' => t('@label Selector',array('@label' => $field['widget']['label'])), '#default_value' => $items['default tids'], '#multiple' => $field['multiple'], '#options' => $options_term, @@ -119,7 +124,7 @@ function taxonomySearch_widget($op, &$no $options = _nodereference_potential_references($field, true); foreach ($options as $key => $value) { - $options[$key] = _nodereference_item($field, $value); + $options[$key] = _nodereference_item($field, $value, FALSE); } if (!$field['required']) { $options = array(0 => t('')) + $options; @@ -128,7 +133,7 @@ function taxonomySearch_widget($op, &$no $form[$fieldname]['nids'] = array( '#type' => 'select', - '#title' => t($field['widget']['label']), + '#title' => t('@label filtered list',array('@label' => $field['widget']['label'])), '#default_value' => $items['default nids'], '#multiple' => $field['multiple'], '#options' => $options, @@ -201,8 +206,8 @@ function taxonomySearch_autocomplete($fi foreach (_nodereference_potential_references($field, TRUE, '') as $row) { $tags=taxonomy_node_get_terms($row->nid); - if (isset($tags[$string])) { - $matches[$row->nid] = _nodereference_item($field, $row, TRUE); + if (empty($string) or isset($tags[$string])) { + $matches[$row->nid] = _nodereference_item($field, $row, FALSE); } } print drupal_to_js($matches);