function og_get_all_group in Organic groups 7
Same name and namespace in other branches
- 7.2 og.module \og_get_all_group()
Return all existing groups with a certain state.
Parameters
$states: Array of states the group must be in.
$options:
- return query: If TRUE the return value will be the $query object. Defaults to FALSE.
- count: If TRUE the function will return the total numer of groups in the desired states. Defaults to FALSE.
4 calls to og_get_all_group()
- OGRulesDataUIGroup::optionsList in ./
og.rules.inc - og_field_audience_options in ./
og.field.inc - Get an array of allowed values for OG audience field.
- og_field_audience_potential_groups_standard in ./
og.field.inc - Helper function for og_field_audience_potential_groups().
- _og_devel_generate in ./
og.devel_generate.inc
File
- ./
og.module, line 1558 - Enable users to create and manage groups with roles and permissions.
Code
function og_get_all_group($states = array(
OG_STATE_ACTIVE,
), $options = array()) {
// Initialize values.
$options += array(
'count' => FALSE,
'return query' => FALSE,
);
$return = array();
$query = db_select('og', 'og');
$query
->addMetaData('id', 'og_get_all_group');
$query
->fields('og', array(
'gid',
));
if (!empty($states)) {
// Get only the groups with the correct state.
$query
->condition('state', $states, 'IN');
}
if ($options['return query']) {
// Return the query itself.
$return = $query;
}
elseif ($options['count']) {
// Return the total number of groups found.
$return = $query
->countQuery()
->execute()
->fetchField();
}
else {
// Return the group IDs.
$result = $query
->execute()
->fetchAll();
foreach ($result as $value) {
$return[$value->gid] = $value->gid;
}
}
return $return;
}