function og_subgroups_selective_groups_options in Subgroups for Organic groups 5.3
1 call to og_subgroups_selective_groups_options()
- og_subgroups_form_add_audience in ./
og_subgroups.module - A modified version of og_form_add_og_audience that takes into account appropriate parent types of OG homepage nodes.
File
- ./
og_subgroups.module, line 277 - Maintains a hierarchy of group/subgroup relationships.
Code
function og_subgroups_selective_groups_options($type) {
//Note that these two things are possible:
//1) Type is not set, in which case we return a non-selective list of node types.
//2) Type is set but this type has no parent types available
if (empty($type) && !in_array($type, variable_get('og_node_types', array(
'og',
)))) {
//type is not set or node is not an og_type
return og_all_groups_options();
}
else {
$types = variable_get('og_subgroups_' . $type . '_parents', array());
}
if (!empty($types) && count($types) > 0) {
//Does $types have any contents?
list($types, $in) = og_subgroups_get_sql_args($type);
$sql = "SELECT n.title, n.nid FROM {node} n WHERE n.type IN ({$in}) AND n.status = 1 ORDER BY n.title ASC";
$result = db_query($sql, $types);
while ($row = db_fetch_object($result)) {
$options[$row->nid] = $row->title;
}
return $options ? $options : array();
}
else {
return array();
//If not, return an empty array.
}
}