summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbschilt2011-08-31 20:55:58 (GMT)
committer bschilt2011-08-31 20:55:58 (GMT)
commitcd1594ec7986d841670313c6ac872a79684106b9 (patch)
tree8579e1903fc36271e6ac4955f3847cee8aec8895
parent1d849910daf6c89b01a8d1edbfe0709c3e1f3e0f (diff)
Issue #1189444: standard groups are now displayed in the audience
selector for group posts.
-rw-r--r--og_subgroups.module22
1 files changed, 18 insertions, 4 deletions
diff --git a/og_subgroups.module b/og_subgroups.module
index 0c2ebdb..49cd918 100644
--- a/og_subgroups.module
+++ b/og_subgroups.module
@@ -64,12 +64,26 @@ function og_subgroups_form_alter(&$form, &$form_state, $form_id) {
if (og_is_group_post_type($node->type)) {
// Override the default group audience select list to show hierarchy
if (is_array($form['og_nodeapi']['visible']['og_groups']['#options'])) {
+ // Get a flat list of subgroups
+ $tree = og_subgroups_get_tree();
+ $flat_tree = og_subgroups_flatten_tree($tree);
+
+ // Remove subgroups from My Groups and Other Groups
+ if (is_array($form['og_nodeapi']['visible']['og_groups']['#options']['My groups'])) {
+ $mygroups = array_diff_key($form['og_nodeapi']['visible']['og_groups']['#options']['My groups'], $flat_tree);
+ $form['og_nodeapi']['visible']['og_groups']['#options']['My groups'] = $mygroups;
+ }
+ if (is_array($form['og_nodeapi']['visible']['og_groups']['#options']['Other groups'])) {
+ $othergroups = array_diff_key($form['og_nodeapi']['visible']['og_groups']['#options']['Other groups'], $flat_tree);
+ $form['og_nodeapi']['visible']['og_groups']['#options']['Other groups'] = $othergroups;
+ }
+
// Fetch the list of available groups indented with hierarchy
- $groups = og_subgroups_group_select_options();
+ $subgroups = og_subgroups_group_select_options();
// Remove the unneeded default option
- unset($groups[0]);
- // Replace the groups with our list
- $form['og_nodeapi']['visible']['og_groups']['#options'] = $groups;
+ unset($subgroups[0]);
+ // Add the subgroups to the audience field
+ $form['og_nodeapi']['visible']['og_groups']['#options']['Subgroups'] = $subgroups;
}
}
}