function og_field_audience_potential_groups_standard in Organic groups 7
Helper function for og_field_audience_potential_groups().
1 call to og_field_audience_potential_groups_standard()
- og_field_audience_potential_groups in ./
og.field.inc - Fetch an array of all candidate groups.
File
- ./
og.field.inc, line 787 - Field module functionality for the Organic groups module.
Code
function og_field_audience_potential_groups_standard($string = '', $match = 'contains', $ids = array(), $limit = NULL) {
$query = og_get_all_group(array(
OG_STATE_ACTIVE,
), array(
'return query' => TRUE,
));
$query
->addField('og', 'label');
if ($string !== '') {
$args = array();
switch ($match) {
case 'contains':
$title_clause = 'label LIKE :match';
$args['match'] = '%' . $string . '%';
break;
case 'starts_with':
$title_clause = 'label LIKE :match';
$args['match'] = $string . '%';
break;
case 'equals':
default:
// no match type or incorrect match type: use "="
$title_clause = 'label = :match';
$args['match'] = $string;
break;
}
$query
->where($title_clause, $args);
}
elseif ($ids) {
$query
->condition('gid', $ids, 'IN');
}
$query
->orderBy('label');
if ($limit) {
$query
->range(0, $limit);
}
$gids = $query
->execute()
->fetchAllKeyed();
$groups = og_load_multiple(array_keys($gids));
foreach ($groups as $group) {
$label = og_label($group->gid);
$return[$group->gid] = $label;
}
return $return;
}