I just updated my version of global limits, it was not working, if i had a number besides 0 or a negative it would not allow me to join a group that had a limit. so i went into the code dumped the very last function
function og_global_limits_can_add_more_members($group = NULL, $new_member_count = 1)
on the line that was passing false and found that $group did not have the
$group->og_global_limits_available_memberships assigned to it.
i went up to find out where it was assigned, in the case: load in
function og_global_limits_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL)
and found that it was assigning it there, but for some reason wasn't sticking. i had to patch it quick so i just changed the
og_global_limits_can_add_more_members function to this:
function og_global_limits_can_add_more_members($group = NULL, $new_member_count = 1) {
if (is_numeric($group)) {
$group = node_load($group);
}
else if ($group == NULL) {
return FALSE;
}
$owner = user_load($group->uid);
+ $member_count = db_result(db_query("SELECT COUNT(*) FROM {og_uid} WHERE nid=%d AND uid!=%d", $group->nid, $group->uid));
+ $limit_override = db_result(db_query("SELECT lim FROM {og_global_limits} WHERE nid=%d", $group->nid));
+ $limit = variable_get('og_global_limits_' . $group->type . '_max_per_group', 5);
+ if ($limit_override !== FALSE)
+ {
+ $limit = $limit_override;
+ $node->og_override_limit = $limit;
+ }
+ $group->og_global_limits_available_memberships = $limit - $member_count;
// first, take the easy way out if we can if the admin chose not
// to limit the number of members that can be in a group or if the
// group owner can exceed the limit or if the group owner set the
// limit to 0 (which creates a negative available number)
if (variable_get('og_global_limits_' . $group->type . '_max_per_group', 5) == 0 || user_access('exceed max per group limit', $owner) || $group->og_global_limits_available_memberships < 0)
{
return TRUE;
}
if ($new_member_count > $group->og_global_limits_available_memberships) {
return FALSE;
}
return TRUE;
}
this appears to fix the issue i was having, but just so you know somewhere along the line its loosing the og_global_limits_available_memberships variable in the node. i haven't the time to track down where this is happening so for now if anyone else is having this issue, this is what i did to
fix the problem till a real patch could be released.
-=Levi=-
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | og_global_limits-529230.patch | 906 bytes | elliotttf |
Comments
Comment #1
elliotttf commentedI couldn't reproduce your problem but I think I see what's happening. It's possible a node object is being passed to the og_global_limits_can_add_more_members function that hasn't been fully loaded. You're essentially loading the missing element with your patch. I have attached another patch that does the same thing that I would like you to try out. The patch uses node_load instead so the value is cached (statically). This would help take load off the DB in the event that the og_global_limits_can_add_more_members function was called several more times in short succession.
Let me know if this fixes your problem and I'll apply the changes.
Comment #2
Levi DeHaan commentedI have my administrator account set to no limits on group joins, and i think that might be the issue, but the users that are posting the group dont have administrator permissions and do not have the checkbox for no limits on joins, though even then, why would it pass false if a user Did have permissions for no limits on joins?
i tried unchecking the no limits on group joins for the admin account (however the admin account is not trying to join a group and did not create the group), and the limitation check worked and the user was allowed to join. the only problem is the user who was getting the 'cannot join' error (because the variable was not being added into the $node) did not have the no limitations checked, (the number for the limitation was set to several numbers but originally started at 2) and was getting the error that too many users were signed up (there was only 1 user, the creator of the group (non-admin)). so i am not sure if the user_access() function is passing true incorrectly (i ran a var_dump on user_access($node) exit(); in the og_global_limits_nodeapi() and it passed true)? and so that is why the variable was not assigned, but why would it disallow access even if the no limit was checked? and there is another user_access() check in the og_global_limits_can_add_more_members() function and that one passed false, so i am not sure what i did incorrectly, the module didnt work right after i updated from the dev version. but it appears i am the only one having this issue :D. i am going to pry in a bit more and try to find out what is going on, but it wasnt that the variable wasnt being fully loaded, it wasnt loaded at all because user_access() passed true. so with nobody being able to bypass the limitation, it all seems to work fine :). thanks for helping me out. i dont really need anyone to be able to bypass so its not a big deal, and it could be just on my end. again thanks for the help.
-=Levi=-
Comment #3
avpadernoI am closing this issue, since it is for a Drupal version that now is not supported.
Please re-open it if the issue is also relevant for other project branches that require a supported Drupal version.