Limiting nodes inside each OG

Rosamunda - February 18, 2009 - 15:09
Project:Node Limit Number
Version:6.x-2.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

Could this module do this? When you´ve got Organic Groups, limiting creation of nodes based per group? It seems that no module can do this

#1

bomarmonk - February 24, 2009 - 21:17

Maybe if you promote each group's members to a different role, you could achieve this, although it would be nice in the existing drop down: limit per organic group (and that's a lot better than having to get another module(s) to automatically promote OG members to different roles)

#2

Rosamunda - February 28, 2009 - 18:38

I´ve tried this, but the options to limit node creation are sitewide. Sadly it won´t do with role changing, unless you want to do something like this:
Role A: can create 5 groups and 5 nodes of type page
Role B: can create 10 groups and 10 nodes of type page
and so on.

But this won´t prevent group´s administers from using all their quota in just one group.
So that´s why I think it should be a quota per group and not per user.

#3

ifoundthetao - October 30, 2009 - 03:48

Any updates on this? I'm interested in a solution as well. Let me know! I'm willing to start coding if nothing has been made.

#4

jdwfly - November 2, 2009 - 18:12

This should be possible with the 6.x-2.x version of this module. Since this is a drupal 5 request there is not much that I can help with, but if you make a patch for version 5 that is good I can apply it.

#5

Rosamunda - November 3, 2009 - 19:17
Version:5.x-1.x-dev» 6.x-2.0-alpha1
Category:feature request» support request

This module working with Rules is terrific!
I´ve just downloaded the latest 2.x version, and I´m trying it now.

One question about how to set a specific rule: What if I want to set a limit of users that belong specific groupgs to role X that can join groups, but to be able to set a specific limit for each group?
Group A can have 10 users of role "writer"
Group B can have 50 users of role "writer"
and so on and on...

Thanks!

Rosamunda

#6

jdwfly - November 4, 2009 - 06:29

Currently this module just limits node creation. Though making it create limits for the amount of users in a role/group could be a worthwhile feature.

#7

ifoundthetao - November 4, 2009 - 16:03

Yeah, I must have misread this entire thread. Because I thought the OP was looking for a way to limit the amount of nodes a group could create of a certain type.

So I got all excited when I saw that you could do this via rules. But upon closer inspection, I'm not so sure you can do this without custom code (not that I'm above creating custom code, but I'd rather use something that has been tested by the community instead of reinventing the wheel).

#8

jdwfly - November 4, 2009 - 18:52

I am pretty sure that you cannot limit a group to posting a certain amount of nodes. It is currently a very simple limit that limits individual users node creation ability. I am going to look into limiting via organic group.

#9

ifoundthetao - November 4, 2009 - 23:04
Version:6.x-2.0-alpha1» 6.x-1.0

I'm working on making a Q&D OG module for the 6.x-1.0 version, since that seems pretty stable.

#10

jdwfly - November 5, 2009 - 00:11
Version:6.x-1.0» 6.x-2.x-dev
Category:support request» feature request

I wouldn't bother modifying the 1.0 version. No new features are going to be added to it, only bugfixes. Development is continuing on the 2.x branch and I just committed some code that should add the OG limit functionality.

#11

ifoundthetao - November 5, 2009 - 00:58

OK, the only reason I was going to use the 1.0 was because I didn't want to delve through all the junk in it to get it running properly.

I haven't seen any updates on the 2.x for a while, I'll check it out though.

Edit: D'oh! I've been talking about Node Limit! Not Node Limit Number. I'm going to check it out to see what we can do with that module.

#12

jdwfly - November 5, 2009 - 16:39
Status:active» fixed

Just did some more testing and reworking of the code. You should now be able to limit by Organic Group now.

#13

Rosamunda - November 5, 2009 - 23:07

Sweet! It´s already commited in the dev version?
Thanks!
Rosamunda

#14

jdwfly - November 5, 2009 - 23:41

It is already in there if you pull it from cvs but you will need to wait for the packager to repackage it if you want to download it from the project page. Should happen in two hours, but it may not happen until tomorrow.

#15

ifoundthetao - November 6, 2009 - 01:48

This isn't working for me at all.

I have set up four OGs and each OG has two users, and one admin in the group.

So far, they are being limited, but it isn't taking into account the actual OG that the user is in.

I'm going to look at the code to see what's up. Maybe I can help contribute too. :D

#16

ifoundthetao - November 6, 2009 - 03:26

$node->og_groups should be $user->og_groups!

#17

ifoundthetao - November 6, 2009 - 04:20

Here's a patch that should get everything up and running fine. It needs to be tested, but I believe we have achieved what we were looking to do!!!

That's so awesome! :D

AttachmentSize
node_limit_og.patch 1.78 KB

#18

ifoundthetao - November 6, 2009 - 04:22
Status:fixed» patch (to be ported)

jdwfly, thanks for all your help!

#19

jdwfly - November 6, 2009 - 17:06
Status:patch (to be ported)» needs work

I am not so sure that I understand the problem you are having. You had said that the users are being limited, but then you say it is not taking into account what groups the user is a part of.

From what I have tested with OG a user only has privileges to post into whatever groups they are allowed. Creating the limit should not depend upon the user but upon the node being created.

I am going to need further explanation of your issue before I make a change.

#20

ifoundthetao - November 7, 2009 - 14:27

The problem I was having was that I wanted a group to have a limit of say 5 nodes of a certain type that an arbitrary group could create.

So, what was happening was that if I had X users in a group, with the unpatched code, each user in the group could create 5 nodes of the limited type, instead of the group creating 5 total.

That was one problem with it, and the other was that even users who weren't in a restricted group were having problems if the limit for an OG was reached by another group.

$node was being tested for "$node->og_groups", but that doesn't exist in the $node object, it only exists in the $user object.
Also, $node_gid was being tested (technically, the code wasn't allowing it to go there, because "$node->og_groups" doesn't exist, so it couldn't get to that code).
So here we were trying to test a "group_id" from the node.
if ($value == $node_gid)

But that data isn't stored in the $node object (at least I couldn't find it in my testing). However, the data is stored in the $user object, so I changed it to ..
if ($value == $user_gid['nid])

That way we could get the functionality.

I think that we do need the $user object because if we don't have it, we're going to end up creating content that we shouldn't have. We are starting with a new node, which means that there isn't a gid assigned to it yet. So we get the gid of the current user (or the "author" creating content, if we're running as Admin) and we test from there. All the information is contained in the passed variables to the functions.

I hope that clears it up a bit.

#21

Rosamunda - November 7, 2009 - 16:09

Does this allow to set specific OG limits? I think that would need a specific rule for each group!
Am I right?

#22

ifoundthetao - November 8, 2009 - 08:29

yeah, that's the functionality that I was looking for! Specific ones for each group.

#23

Rosamunda - November 8, 2009 - 16:54

yes, it seems that NO module can do that.

#24

ifoundthetao - November 9, 2009 - 06:18

Yeah, but with the patch to the code that we have, the module does that now.

#25

Rosamunda - November 9, 2009 - 13:31

Oh I see! You mean #20?
Cool, thanks!

Rosamunda

#26

jdwfly - November 9, 2009 - 17:15

I can't seem to duplicate your problem. You are either:

  1. Using old code
  2. Have a poor setup in your rule

Here are the reasons why I am using $node-og_groups:

  1. The limit is imposed upon the group not the user.
  2. Available during the presave. This of course means the rule would need to do an immediate page redirect or the content will be created.

If we check which groups a user is in that does not help us find out which groups the post is being posted to.

Some new code was just committed. Since there was the ability to check several groups it made it nearly impossible for the code to work properly. I decided that it would be simpler to only check one group at a time so you may need to edit your rules and re-select the groups to limit. I have tested this extensively with a couple groups and users and I find that it is performing correctly so long as the rules are setup correctly. You will have to checkout the code via CVS if you want the updates or wait for the new dev package to be created.

By the way this is only going to create a limit for the entire group. If you want to limit how many each user can post to a group that is a whole different feature request.

@ifoundthetao
Post your rule as an attachment and maybe I can help you out.

#27

ifoundthetao - November 10, 2009 - 00:40

@jdwfly
I believe I had all the functionality that I was looking for as far as what I needed to have done.

What I wanted was a rule set up so that a specific group could only create a specified amount of content that is a specific type. It doesn't matter how many users from within the group create the content. My users are different companies. Each different company has a different group, and each group has members. So they get a specific amount of content they can create of a specific type, and when they are done with that, they need to request more. So one user can create the entire limit, or they can spread it out, but it doesn't matter.

As far as using $node->og_groups goes, I don't see it existing.

Here is how I have my site set up.. maybe this will clear things up.

Each user can only be in one group (Aside from Admins, who create groups, add users, and remove users. They have absolute sovereignty).

I have a few types of content..
Page
Story
Group
Group Post

So the groups can only post content type of Group Post.

Let's say I have Group 1, and they have a limit of 3 Group Posts that they can publish. When they click on "Create Content", I test the $user to find out what OG that they're in. That way I can see if that specific group has met its limit. If it is in conflict, there is a page redirect, and there is a message saying, "Sorry, you need to contact the admin to get more Group Posts". If they're not in conflict, then it goes to the page where they can fill out their data.

#28

jdwfly - November 10, 2009 - 19:49
Status:needs work» fixed

I understand what you want but that will only work in your instance. The way I have it coded currently will work in every instance. Your code has problems if the user is in more than one group, because if just one of the groups he is in has reached the limit then he cannot post at all.

The only way to accurately test this is during the presave operation which does have the $node->og_groups array. I do agree that $node->og_groups doesn't exist during the prepare operation because the user has not filled out the form and picked which groups he wants his post to go into. The $user->og_groups exists during both and it tells me which groups a user is a part of, but just because they are a part of a certain group does not mean they will be posting nodes into that group. That is not decided until the user submits the form and then I can check the limit during the presave operation.

#29

System Message - November 24, 2009 - 19:50
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.