Closed (fixed)
Project:
Node Limit Number
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
17 Nov 2009 at 02:43 UTC
Updated:
8 Feb 2011 at 16:40 UTC
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
Comment #1
jdwfly commentedUnless I am misunderstanding you this can be accomplished without modifying the code. You would need to create a separate rule for each group though.
Comment #2
jdwfly commentedI'm pretty sure I won't be changing this since it can be done with multiple rules.
Comment #3
nasso commentedI 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 :)
Comment #4
jdwfly commentedI'll look into this, but I think there is another reason why I decided to exclude this.
Comment #5
rconstantine commented@nasso - that's the same reason I made the changes in the first place. royal pain in the ... and completely unmanageable without the change.
Comment #6
nasso commentedDid you find the other reason?
Comment #7
jdwfly commentedNeeds patch and reviews/testing, until then I won't commit it.
Comment #8
jdwfly commentedcommitted