i'm going to be lazy and not roll a proper patch for two lines of code. sorry. my changes are for the case where each OG should only have one of a certain kind of content type. for example, the og page contains only the og description, and each og has a 'club officers' page associated with it. you don't want more than one of those per group.

the first change is this:

if (module_exists('og')) {
    // if settings['og'] is equal to none this is a simple limit
    if ($settings['og'] != 'none') {
      if (is_array($node->og_groups)) {
        // Loop through each of the og settings to find enabled
        foreach ($node->og_groups as $node_gid) {
          // Loop through each of the groups for the node to see if they match
          if ($settings['og'] == $node_gid || $settings['og'] == 'all') {//<-----------------------------------changed this line
            // The node matches the group with the limit
            // Find all nodes that have been created for that group
            $q = "SELECT * FROM {node} INNER JOIN {og_ancestry} ON node.nid=og_ancestry.nid WHERE og_ancestry.group_nid = %d";
            $result = db_query($q, $node_gid);
            $num = db_affected_rows();
            if ($num >= $settings['limit']) {// We have the data, now we check the limit
              return TRUE;
            }
            // Did not match but we still need to loop through the rest; not returning false
          }
        }
      }
      return FALSE;
    }
  }

the second change is this:

if (module_exists('og')) {
    $q = "SELECT nid,og_description FROM {og}";
    $result = db_query($q);
    while ($data = db_fetch_array($result)) {
      $node = node_load($data['nid']);
      $groups[$node->nid] = $node->title;
    }
    $groups['none'] = t('None');
    $groups['all'] = t('All');//<----------------------------------------------added this line
    $form['settings']['og'] = array(
      '#type' => 'radios',
      '#title' => t('Limit By Organic Group'),
      '#default_value' => $settings['og'],
      '#description' => t('This limits the amount of group posts'),
      '#options' => $groups,
    );
  }

Comments

jdwfly’s picture

Unless I am misunderstanding you this can be accomplished without modifying the code. You would need to create a separate rule for each group though.

jdwfly’s picture

Status: Active » Closed (won't fix)

I'm pretty sure I won't be changing this since it can be done with multiple rules.

nasso’s picture

Status: Closed (won't fix) » Needs review

I have this problem too. Yes, it can be done with multiple rules, my problem is that my users create the groups. Once the site leaves development i will have hundreds of groups. I cant manually add rules, if I did, I would have to stop my users from using the groups until i have manually created the rules. Would take a lot of work.

Please reconsider including this. I havn't tried the fix yet but i will. Would be nice to not have to hack the module, though :)

jdwfly’s picture

Status: Needs review » Needs work

I'll look into this, but I think there is another reason why I decided to exclude this.

rconstantine’s picture

@nasso - that's the same reason I made the changes in the first place. royal pain in the ... and completely unmanageable without the change.

nasso’s picture

Did you find the other reason?

jdwfly’s picture

Needs patch and reviews/testing, until then I won't commit it.

jdwfly’s picture

Status: Needs work » Fixed

committed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.