summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormikestefanello2011-12-22 18:20:49 (GMT)
committer mikestefanello2011-12-22 18:20:49 (GMT)
commit89458c4a5f8bffd26e95541dc5801198b9fd9f65 (patch)
tree9da36883036e740165d2b7d0720d26532d296df7
parentdb06a559b14adcf54480ae6d3f7a19efe17f2a59 (diff)
Major bug-fix for group and parent group selection options. If a group type was not subgroups-enabled, it would not appear as an option to place content in.6.x-1.x
-rw-r--r--includes/form.inc16
-rw-r--r--includes/tree.inc7
-rw-r--r--modules/og_subgroups_hs/og_subgroups_hs.module2
-rw-r--r--og_subgroups.module22
4 files changed, 19 insertions, 28 deletions
diff --git a/includes/form.inc b/includes/form.inc
index 4fabc4b..126b764 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -72,7 +72,7 @@ function og_subgroups_add_group_select_form(&$form, $node) {
'#type' => 'select',
'#title' => $title,
'#default_value' => $parent_id,
- '#options' => og_subgroups_group_select_options(),
+ '#options' => og_subgroups_group_select_options(TRUE),
'#description' => $description,
);
}
@@ -89,7 +89,7 @@ function og_subgroups_add_group_select_form(&$form, $node) {
* @return
* A keyed array used for a form select widget
*/
-function og_subgroups_group_select_options($indent = '--') {
+function og_subgroups_group_select_options($only_enabled = FALSE, $indent = '--') {
og_subgroups_include('tree');
$options = array();
@@ -109,7 +109,7 @@ function og_subgroups_group_select_options($indent = '--') {
}
// Add the groups that don't have children
- $options += _og_subgroups_group_select_options_without_family();
+ $options += _og_subgroups_group_select_options_without_family($only_enabled);
// Add no parent as a selection option
$options = array(t('<No parent group>')) + $options;
@@ -139,8 +139,12 @@ function _og_subgroups_group_select_options_recursive(&$options, $branch, $inden
/**
* Helper function to generate a list of select options of groups
* that do not have a hierarchy, meaning they are not in a family
+ *
+ * @param $only_enabled
+ * If TRUE, only return groups which are subgroups-enabled. Defaults
+ * to FALSE.
*/
-function _og_subgroups_group_select_options_without_family() {
+function _og_subgroups_group_select_options_without_family($only_enabled = FALSE) {
og_subgroups_include('tree');
$options = array();
@@ -149,6 +153,10 @@ function _og_subgroups_group_select_options_without_family() {
// Iterate the groups
foreach ($groups as $group) {
+ // Make sure this type is subgroups-enabled, if we're checking
+ if ($only_enabled && !og_subgroups_is_subgroup_type($group->type)) {
+ continue;
+ }
// Check for access
if (!og_subgroups_mask_group($group, TRUE)) {
$options[$group->nid] = $group->title;
diff --git a/includes/tree.inc b/includes/tree.inc
index 0bd59dd..60260bc 100644
--- a/includes/tree.inc
+++ b/includes/tree.inc
@@ -407,7 +407,7 @@ function _og_subgroups_get_group_siblings_recursive($group, $branch) {
* @return
* An array of groups that are not part of a group hierarchy
*/
-function og_subgroups_get_groups_without_family() {
+function og_subgroups_get_groups_without_family($only_enabled = TRUE) {
$groups = array();
$sql = "SELECT og.nid, og.og_private, og.og_selective, n.title, n.status, n.type";
@@ -421,10 +421,7 @@ function og_subgroups_get_groups_without_family() {
// Put the groups in array format
while ($group = db_fetch_object($results)) {
- // Make sure this type is enabled
- if (og_subgroups_is_subgroup_type($group->type)) {
- $groups[$group->nid] = $group;
- }
+ $groups[$group->nid] = $group;
}
return $groups;
diff --git a/modules/og_subgroups_hs/og_subgroups_hs.module b/modules/og_subgroups_hs/og_subgroups_hs.module
index 9df5dce..135025f 100644
--- a/modules/og_subgroups_hs/og_subgroups_hs.module
+++ b/modules/og_subgroups_hs/og_subgroups_hs.module
@@ -154,7 +154,7 @@ function og_subgroups_hs_hierarchical_select_lineage($item, $params) {
* Implementation of hook_hierarchical_select_valid_item().
*/
function og_subgroups_hs_hierarchical_select_valid_item($item, $params) {
- if($item == OG_SUBGROUPS_HS_ANY_OPTION) {
+ if ($item == OG_SUBGROUPS_HS_ANY_OPTION) {
return TRUE;
}
diff --git a/og_subgroups.module b/og_subgroups.module
index 49cd918..0c2ebdb 100644
--- a/og_subgroups.module
+++ b/og_subgroups.module
@@ -64,26 +64,12 @@ 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
- $subgroups = og_subgroups_group_select_options();
+ $groups = og_subgroups_group_select_options();
// Remove the unneeded default option
- unset($subgroups[0]);
- // Add the subgroups to the audience field
- $form['og_nodeapi']['visible']['og_groups']['#options']['Subgroups'] = $subgroups;
+ unset($groups[0]);
+ // Replace the groups with our list
+ $form['og_nodeapi']['visible']['og_groups']['#options'] = $groups;
}
}
}