I have OG 5.x-7.3 installed.

In OG Subgroups configuration, I only have checked:

Admin status
Click here if you only want users to be able to select groups in which they are administrators.

Everything else is unchecked.

When I add a user to Group A, the user is automatically added to every subgroup of Group A. This is NOT what I want.

Have I missed some configuration somewhere else? What needs to happen to fix this?

Thanks!

CommentFileSizeAuthor
#2 og_subgroupsConfig.jpg143.92 KBsomebodysysop

Comments

amitaibu’s picture

Status: Active » Postponed (maintainer needs more info)

Where do you see this settings? (Better - can you find it in the code?)

somebodysysop’s picture

StatusFileSize
new143.92 KB

Administer->Organic Groups->Organic groups subgroups configuration

admin/og/subgroups

Attached is screenshot of current configuration. Is this correct to NOT have user propagation?

amitaibu’s picture

Do you have other OG related modules enabled? Can you point me to the line in the code that places this checkbox - I kind find it (nor remember i put it there :)

somebodysysop’s picture

In og_subgroups_settings() the variable og_subgroups_propagate_members is set:

  $form['propagte_user']['og_subgroups_propagate_members'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Members propagation'),
    '#description' => t('Set the propogation type for group members (non-admin).'),
    '#options' => array(
      'up' => t('Parents'),
      'down' => t('Children'),
      'side' => t('Syblings'),
    ),
    '#default_value' => variable_get('og_subgroups_propagate_members', NULL),
  );

Since I don't check anything, og_subgroups_propagate_members should be NULL when it hits here:

/** 
* Helper function for og_subgroups_propogate_user().
* 
* @param $gid
*   The group id. 
* @return 
*   Array with the group nids for propagation.
*/
function _og_subgroups_propogate_user_get_tree($gid) {
  $tree = array();
  $directions = variable_get('og_subgroups_propagate_members', NULL);
  foreach ($directions as $direction) {
    if ($direction) {  
      // Get the groups member should be propagated.
      $trees = og_subgroups_get_all_family($gid, $direction);
      foreach ($trees as $group) {
        $tree[$group->gid] = $group->title;
      }   
    }
  }
  return $tree; 
}

The above function _og_subgroups_propogate_user_get_tree is called from the following function:

/**
* Propagates members and admins along the subgroups tree.
* 
* @param $gid
*   The group id.
* @param $uid
*   The propagated user id. 
* @param $args
*   Array with the updated action, as returned from hook_og()
*
*/
function og_subgroups_propogate_user($gid, $uid, $args) {
  $demote = variable_get('og_subgroups_propagate_demote', NULL);

  // User's membership was approved.
  // User was promoted to group admin.
  // User was demoted from admin and demote action should occur.
  if ($args['is_active'] == 1 || $args['is_admin'] == 1 || ($args['is_admin'] == 0 && $demote['remove_admin'])) {
    $tree = _og_subgroups_propogate_user_get_tree($gid);
    $user = user_load(array('uid' => $uid));
    $args['is_admin'] ? $is_admin = 1 : $is_admin = 0;
    foreach ($tree as $gid => $foo) {
      // Check user isn't already subscribed with same rights.
      if (empty($user->og_groups[$gid]) || $user->og_groups[$gid]['is_active'] != 1 || $user->og_groups[$gid]['is_admin'] != $is_admin) {
        // Pass in the $args info about propogation done by og_subgroups module.
        og_save_subscription($gid, $uid, array('is_active' => 1, 'is_admin' => $is_admin, 'og_subgroups' => TRUE));
      }
    }
  } 
}

And the above function og_subgroups_propogate_user, of course, is called by og_subgroups_og every time a user is added/removed from a group:

/**
 * Implementation of hook_og().
 */
function og_subgroups_og($op, $gid, $uid, $args = array()) {
  // Don't propgate in the middle of propogation action.
  if (!$args['og_subgroups']) {
    switch ($op) {
      case 'user insert':
        og_subgroups_propogate_user($gid, $uid, $args);        
        break;
      case 'user update':
        og_subgroups_propogate_user($gid, $uid, $args);        
        break;
      case 'user delete': 
        og_subgroups_propogate_user_removal($gid, $uid, $args);        
        break;
    }
  }
}

I queried the variable table and this is what I got:

Result: select * from variable where name = 'og_subgroups_propagate_members'

og_subgroups_propagate_members	a:5:{i:1;i:1;i:0;i:1;s:2:"up";i:0;s:4:"down";i:0;s:4:"side";i:0;}

Overall, not sure why I'm getting the results I am.

amitaibu’s picture

@SomebodySysop,
You are not answering my question. Please do a find "Click here if you only want users to be able to select groups in which they are administrators" on your modules. This option is _not_ in og_subgroups 5.x.-4.dev - do you have the latest version?

somebodysysop’s picture

Oops. You're right. Sorry!

I forgot that I submitted patch: http://drupal.org/node/301771. I hadn't gone further because I don't even have a 6.x version of my module. The relevant changes (you can also see patch here: http://drupal.org/files/issues/og_subgroups.module.admin_.patch):

/**
 * Menu callback; displays the subgroups configuration page.
 */
function og_subgroups_settings() {
  $form['og_subgroups_admin'] = array(
    '#type' => 'checkbox',
    '#title' => t('Admin status'),
    '#description' => t('Click here if you only want users to be able to select groups in which they are administrators.'),
    '#default_value' => variable_get('og_subgroups_admin', 0),
  );

So that I could optionally list just the groups that a user was admin for in the outline:

/**
 * Implementation of function og_subgroups_outline()
 * Handles all subgroups outline operations.
 */
function og_subgroups_outline($nid) {
  $node = node_load($nid);
  
  // Get all accessible/ inaccesiable groups for the user.
  if (variable_get('og_subgroups_admin', 0) == 1) {
    $options = og_subgroups_get_eligable_groups('admin');
  } else {
    $options = og_subgroups_get_eligable_groups('accessibale');
  }

Finally:

/**
 * Helper function to get the accessibale and inaccessiable groups.
 * 
 * @param $op
 *   The operation
 */
function og_subgroups_get_eligable_groups($op) {
  global $user;
  $eligable_groups = og_node_groups_distinguish(og_all_groups_options(), FALSE);
  $return = array();
  switch ($op) {
    case 'accessibale':
      // Get all accessible groups for the user.
      foreach ($eligable_groups['accessible'] as $key => $group) {
        $return[$key] = $group['title'];
      }
      break;
    case 'inaccessibale':  
      // Get excluded groups.
      foreach ($eligable_groups['inaccessible'] as $group) {
        $return[$group] = $group;
      }
      break; 
    case 'admin':  
      // Get all accessible groups for this user in which he is admin.
      foreach ($eligable_groups['accessible'] as $key => $group) {
        if (db_result(db_query("SELECT COUNT(uid) FROM {og_uid} WHERE nid = %d AND uid = %d AND is_admin = 1", $key, $user->uid))) {
          $return[$key] = $group['title'];
	    }
      }
     break; 
  }
  return $return;
}

The end result of this is to make sure that a user who can create subgroups can only see groups that he is admin in. I don't think this would affect the propagation code, but I could be wrong.

somebodysysop’s picture

Also: The lastest 5.x.-4.dev is dated June 2008. I patched it in August 2008, so I would assume I have the latest version, unless another has been released since then.

amitaibu’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

Let's move the issue back to #301771: Limit Groups in Outline to just those a user is admin in. However like I told you there - the D5 version is a bug fix only.

somebodysysop’s picture

But, the issue at hand is Unwanted User Propagation

This has nothing to do with "limiting groups in outline...". I submit that my patch has nothing to do with the propagation issue. However, if it will make things more clear, I will use an unpatched version of the latest 5.x.-4.dev download to verify.

somebodysysop’s picture

Status: Closed (duplicate) » Active

Yes, the latest unpatched version does the same thing. Is the problem perhaps that there should be a "none" option for user propagation?

amitaibu’s picture

When all the checkboxed are disabled there shouldn't be any propagation. I can't seem to reproduce it.

somebodysysop’s picture

OK. Will test some more to see if I can track it down. Will report back what I find. Thanks for looking at it.

ezra-g’s picture

Any update here, SomebodySysop?