--- og_vocaborig.module 2008-06-17 16:06:14.000000000 +0100 +++ og_vocab.module 2008-08-02 14:40:32.000000000 +0100 @@ -352,4 +352,88 @@ function og_vocab_pathauto_taxonomy($op, default: break; } -} \ No newline at end of file +} + +//Views (exposed filter) support for OG + +function og_vocab_views_tables() { + + $tables['og_vocab'] = array( + 'name' => 'og_vocab', + 'join' => array( + 'left' => array( + 'table' => 'node', + 'field' => 'nid' + ), + 'right' => array( + 'field' => 'nid' + ), + ), + 'filters' => array( + 'term' => array( + 'name' => t('OG Vocab: Term'), + 'operator' => 'views_handler_operator_andor', + 'list' => 'og_vocab_handler_filter_tid', + 'option' => 'string', + 'handler' => 'views_handler_filter_tid_custom', + 'value-type' => 'array', + 'help' => t('Filter by terms in current group.'), + ), + + ), + ); + + return $tables; +} + +function og_vocab_handler_filter_tid($op, $filterinfo) { + + $tids = array(); + if ($filterinfo['vocabulary']) { + $where = "td.vid = $filterinfo[vocabulary]"; + } + $groupnode = og_get_group_context(); + if($groupnode != NULL) + { + $where2 = "ogv.nid = %d"; + + } + if($groupnode!=NULL && $filterinfo['vocabulary'] ) + { + $where3="AND"; + } + + if($groupnode!=NULL || $filterinfo['vocabulary'] ) + { + $where4="WHERE"; + } + + if($groupnode != NULL) + { + + $sql ="SELECT DISTINCT(td.tid), td.name, td.weight FROM {term_data} td INNER JOIN {og_vocab} ogv ON td.vid = ogv.vid $where4 $where $where3 $where2 ORDER BY td.weight, td.name"; + + $result = db_query($sql, $groupnode->nid); + } + else + { + + // In case we are not in a group node: for example if we are overriding the 'river of news' view and we want to expose this filter, we have to select a term + + $sql ="SELECT DISTINCT(td.tid), td.name, td.weight FROM {term_data} td ORDER BY td.weight, td.name"; + + $result = db_query($sql); + } + + while ($obj = db_fetch_object($result)) { + $tids[$obj->tid] = "$obj->name"; + + } + + return $tids; +} + + + + +?> \ No newline at end of file