My solution was to patch the search_config module with og_vocab support.

After line 104 in search_config.module:

$terms = variable_get('search_config_disable_category', array());

Insert the following:

            if (module_exists('og_vocab')) {
              $groupnode = og_get_group_context();
              $sql = "SELECT t.tid FROM {vocabulary} v, {term_data} t LEFT JOIN {og_vocab} ov ON v.vid = ov.vid WHERE (v.module = 'og_vocab' AND ov.nid != %d) AND t.vid=v.vid";
              $result = db_query($sql, $groupnode->nid);

              while ($row = db_fetch_object($result)) {            
                $terms[$row->tid] = $row->tid;
              }          
            }

Also posting this as a search_config issue.

Comments

moshe weitzman’s picture

Status: Needs review » Needs work

we ned to form alter this advanced search form.

amitaibu’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev
Assigned: Unassigned » amitaibu
Status: Needs work » Active

Indeed. we need to form_alter() the advanced search and only show vocabs that are global _or_ that a user is a member in the associated group.

amitaibu’s picture

Title: og_vocab in search_form - advanced search categories show all vocabularies and terms, not filtered to specific member groups. » Show accessiable vocabs in advanced search

Better title.

amitaibu’s picture

Moshe I need your help on this one:

1) We can't form_alter() as the vid doesn't appear in the list, only the vocab title.
2) This keeps us with db_rewrite_sql(), however I have an endless loop problem which I don't know how to solve:

/**
 * Implementation of hook_db_rewrite_sql().
 * 
 * Remove inaccessibale vocabularies from the advanced 
 * search form.
 */
function og_vocab_db_rewrite_sql($query, $primary_table, $primary_field, $args) {
  if ($primary_table == 'v') {
    $item = menu_get_item();
    // Check if we are in search form context.
     if ($item['path'] == 'search/node/%') {
      $vocabs = og_vocab_get_accessible_vocabs(); // <--- This causes the loop as that function calls taxonomy_get_vocabularies().
      $return['where'] = 'v.vid IN (' .implode(', ', $vocabs). ')';
      return $return;       
    }
  }
}
moshe weitzman’s picture

Title: Show accessiable vocabs in advanced search » Show accessible vocabs in advanced search

Seems like the easiest approach is to do one of:

  1. in hook_form_alter(), build up our own $options array and do a http://us3.php.net/manual/en/function.array-intersect-assoc.php or similar function to filter our the inaccessible terms.
  2. completely remove the existing taxonomy form element and replace with our own in hook_form_alter().
amitaibu’s picture

Status: Active » Fixed

Done.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.