I've been using the module and looks great. But one of my client requiremets is the possibility of select what content types will be propagated.

I've made a patch to include than functionality.

Comments

bschilt’s picture

Status: Needs review » Needs work

Thanks for working on this. Seems like it would be a good option to add as long as its done right and won't drastically affect currently installed modules. I would like to see this patch applied to both content and users. On the propagation settings page, users should only be able to enable propagation on content types that are group nodes and have been enabled on the main subgroups settings page.

Also I don't want to disrupt currently installed versions so when a site upgrades subgroups and doesn't check any propagation boxes, it should continue to propagate content and users as it does in the current version.

+++ b/modules/og_subgroups_prop/includes/admin.inc
@@ -5,6 +5,8 @@
+  // Find content types
+  $types = node_get_types('names');

We only need to retrieve the content types that are "subgroups enabled". Doesn't make sense to get all content types.

+++ b/modules/og_subgroups_prop/includes/admin.inc
@@ -22,6 +24,14 @@ function og_subgroups_prop_settings() {
+  //Content types that will not be propagated
+  $form['propagte_content']['og_subgroups_propagate_content_bytype'] = array(
+    '#type' => 'checkboxes', ¶
+    '#title' => t('Not apply content propagation to this types'), ¶
+    '#default_value' => variable_get('og_subgroups_propagate_content_bytype', array('')), ¶
+    '#options' => $types, ¶
+    '#description' => t('Select content types which that will not propagate'), ¶
+  );

The checkboxes will need to enable propagation for the selected content types, not prevent propagation.

If no checkboxes are ticked then all content types will have propagation, this way the default subgroups behavior is preserved.

Also remove the trailing white spaces.

+++ b/modules/og_subgroups_prop/og_subgroups_prop.module
@@ -199,9 +199,12 @@ function og_subgroups_prop_propagate_content(&$node) {
+  $types = variable_get('og_subgroups_propagate_content_bytype', array());

change variable name to 'og_subgroups_propagate_enabled_{$content_type}'

Follow the way its done on the main subgroups settings page.

Let me know if you have questions or need me to clear anything up.

Thanks

aheredia’s picture

Status: Active » Needs work

Only one thing. In my patch by default all checkboxes are not selected so the propagation would take place for all content types, only those content types with the checkbox selected will not propagate.Doing this way all subgroups enabled before appliying this patch will propagate all their content types. I'm not sure if this is the correct behavior.

Please excuse my limited English

bschilt’s picture

Drupal core has already set a precedence for this type of thing. Take a look at the block add/edit form (admin/build/block/add) and scroll down to the "Role specific visibility settings" fieldset. When selecting block visibility by role it says "Show this block only for the selected role(s). If you select no roles, the block will be visible to all users" in the description.

I would like this feature to be implemented in a similar way. If no checkboxes are ticked for enabling content/user propagation, then propagation should happen to all enabled subgroups. But if a box is ticked then propagation only happens to that particular group(s).

aheredia’s picture

Ok. You are right.

aheredia’s picture

StatusFileSize
new2.42 KB

I think I've made the required changes.
Please Have a look if they are correct
Thanks

bschilt’s picture

You will need to submit a new patch with a different name. You cannot use # in the patch name, see #284899: Drupal url problem with clean urls

Review the Submitting Patches page for best practices.

aheredia’s picture

Sorry i'm newbie

aheredia’s picture

Status: Needs work » Needs review

I forgot to change the status

bschilt’s picture

+++ b/modules/og_subgroups_prop/includes/admin.inc
@@ -5,6 +5,11 @@
+  // Find group post content types
+  $types_initial = og_get_types('group_post');
+  foreach ($types_initial as $key=>$value) {
+    $types[$value] = $value;
+  }

This is a little closer but the available options should be the groups that have been "enabled" on the subgroups settings page. In your foreach loop, use the og_subgroups_node_type_enabled_{$type} variable to determine which group types are enabled.

+++ b/modules/og_subgroups_prop/includes/admin.inc
@@ -22,6 +27,14 @@ function og_subgroups_prop_settings() {
+  //Content types that will be propagated
+  $form['propagte_content']['og_subgroups_propagate_enabled_'] = array(
+    '#type' => 'checkboxes',
+    '#title' => t('Apply content propagation to these types'),
+    '#options' => $types,
+    '#default_value' => variable_get('og_subgroups_propagate_enabled_', array('')), ¶
+    '#description' => t('Select content types that will propagate. If none selected all content types will be propagated'),
+  );

Instead of using the checkboxes form field, use the same method that is used in the og_subgroups_settings() function to display the node types to enable. Except that the possible values will only be the group types have have been enabled.

+++ b/modules/og_subgroups_prop/og_subgroups_prop.module
@@ -199,9 +199,22 @@ function og_subgroups_prop_propagate_content(&$node) {
+  // Determine excluded content types
+  $types = variable_get('og_subgroups_propagate_enabled_', array());
+  $enabled_type = True;
+  $i=0;
+  $values = array_values($types);
+  // Determine if none checkbox is selected
+  while ($enabled_type && $i<count($values)){
+    if ($values[$i]) {
+      $enabled_type=FALSE;
+    }
+    $i++;
+  }
+

This would no longer be needed

+++ b/modules/og_subgroups_prop/og_subgroups_prop.module
@@ -199,9 +199,22 @@ function og_subgroups_prop_propagate_content(&$node) {
+  if (isset($node->og_groups) && !empty($node->og_groups) && ($enabled_type || ($types[$node->type]))) {

only need to check a single variable... if(variable_get(og_subgroups_propagate_enabled_{node->type}, FALSE))

lahode’s picture

Hi for your info, the patch I published few weeks ago does that:
http://drupal.org/node/1226002#comment-5088694

Still wondering however why there is new updates for this module...

Cheers

aheredia’s picture

I'm a little bit lost.
The idea of the patch was to being able to select what content types defined as group post would be propagated.

So i've used the function og_get_types('group_post') to select that content types first. i don't realise why i've to use og_subgroups_node_type_enabled_{$type} :( which defines what content types are a group container.

Another dude is why shouldn't be new updates for this module. Only version for drupal 7 is active?

lahode’s picture

Hi Aheredia,

Sorry, I made a mistake when filtering the issues. My patch is for D7, I leave Bshilt reply to your answer as OG Group in D6 is a completely different concept

Cheers

aheredia’s picture

Thanks for the explanation
"I made a mistake when filtering the issues" Dont worry this can happen to anyone.
regards

aheredia’s picture

Status: Needs work » Needs review

I'm a little bit lost.
The idea of the patch was to being able to select what content types defined as group post would be propagated.

So i've used the function og_get_types('group_post') to select that content types first. i don't realise why i've to use og_subgroups_node_type_enabled_{$type} :( which defines what content types are a group container.