You are here

function og_field_audience_potential_groups in Organic groups 7

Fetch an array of all candidate groups.

This info is used in various places (allowed values, autocomplete results, input validation...). Some of them only need the nids, others nid + titles, others yet nid + titles + rendered row (for display in widgets).

The array we return contains all the potentially needed information, and lets consumers use the parts they actually need.

Parameters

$field: The field description.

$string: Optional string to filter titles on (used by autocomplete).

$match: Operator to match filtered name against, can be any of: 'contains', 'equals', 'starts_with'

$ids: Optional node ids to lookup (the $string and $match arguments will be ignored).

$limit: If non-zero, limit the size of the result set.

Return value

An array of valid nodes in the form: array( gid => 'rendered' -- The text to display in widgets (can be HTML) ); @todo Check whether we still need the 'rendered' value (hook_options_list() does not need it anymore). Should probably be clearer after the 'Views' mode is ported.

3 calls to og_field_audience_potential_groups()
og_field_audience_autocomplete in ./og.field.inc
Menu callback for the autocomplete results.
og_field_audience_autocomplete_validate in ./og.field.inc
Validation callback for a group audience autocomplete element.
__og_field_validate in ./og.field.inc
Implements hook_field_validate().

File

./og.field.inc, line 767
Field module functionality for the Organic groups module.

Code

function og_field_audience_potential_groups($string = '', $match = 'contains', $ids = array(), $limit = NULL) {
  $results =& drupal_static(__FUNCTION__, array());

  // Create unique id for static cache.
  $cid = $match . ':' . ($string !== '' ? $string : implode('-', $ids)) . ':' . $limit;
  if (!isset($results[$cid])) {
    $groups = og_field_audience_potential_groups_standard($string, $match, $ids, $limit);

    // Store the results.
    $results[$cid] = !empty($groups) ? $groups : array();
  }
  return $results[$cid];
}