Hi, is there a way how to limit nodes for each user in role?
now, if I set limit to 5 for a role, it limits all the nodes from alle the usersto 5, not just 5 for each user, so if one user in that role posts 4 nodes, the other one has only 1 left.
I know, there is a user limit, but setting manually 5000+ users + new ones individually is impossible.
thanx for a help
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | node_limit-458954_1.patch | 3.57 KB | mrtoner |
Comments
Comment #1
mrtoner commentedThis one is a deal breaker for me. I'm creating a directory where each "member" (role) should be limited to one "listing (content type). As czeky points out, manually setting users is impractical, so it makes sense to assign the limit to a role.
Unfortunately, Node Limit Role applies the limit to the role as a whole, rather than each user in that role individually. It does this through by counting all the nodes created by all users in that role.
I'm attaching a patch that changes the default behavior by applying the role limit on a per user basis. I've also included a checkbox ("Inclusive") on the Node Limit form that, when checked, will cause Node Limit Role to use the previous behavior. I've not included any changes to the install file nor any update functions, so you will need to add an integer field "inclusive" to the node_limit_role table. If you do not know how to do that, do not apply this patch.
Also, this patch is only for 6.x.0.3 -- content types are handled differently in later versions and dev is in flux at the moment. Hopefully Dave has or will change how roles are handled in later versions.
Comment #2
crutch commentedI applied this patch tonight and it works perfectly thanks so much! Great work!
Comment #3
jgarbe commentedI too rolled with this patch and it worked perfectly. Highly suggest it be included in the next release of this module. Thanks to both of you for making something so imminently useful!
Comment #4
czeky commentedHi, could someone help? Not working form me.. applied the patch, added a "inclusive" row in node_limit_role sql table (under lid a rid), INT (11), any else settings? auto_increment?.. thank You
Comment #5
fabdel commentedDon't work for me.
Drupal 6.12
Comment #6
mairav commentedI'm using drupal 6.12 and and node_limit 6.x-0.3
#mrtoner I applyed your patch and now it's working as I wanted. Thanks for that patch.
I hope dave can add this soon. But he is not been around here for a while as I can see.
Comment #7
mairav commented#mrtoner I noticed one thing, I don't know if it's ok or not.
If I create a limit, as I said in my las comment it works fine. Then I created another limit for the role designer and "any" content type and it makes something strange.
If I have 4 content types it shares the limit between those 4 content types. If the the limit is 5, then I can create five nodes between all content types, insted of 5 of each one.
It would be great if you can add another option, as the "inclusive" one you added to your patch, where we can decide if the "n" limit is applied to each content type or is shared between all of them.
For now i'll have to create a node limit for each content type. Thanks for your patch again, and I hope you can help with this request too :D
Comment #8
mairav commented#mrtoner after testing it, it works ok about the limits for each user, but it's not working if that user belongs to more than one role.
For example, I have a user with the roles "registered", "designer", "supervisor" who have the limits 1, 10, unlimited respectively. Insted of giving that user the limits for the supervisor, he is registricted to only one node.
I hope you can help me, I'm desperate!. I have to launch the site soon and I couldn't make it work.
I know it's not related to your patch, but maybe you can help me. Thanks in advance. Maira.
Comment #9
mrtoner commentedFor those that have posted here and contacted me directly, I'm afraid that at the moment I'm not able to look into your issues. If and when I look into them, I'll need to know:
@czeky - I'm betting you're using dev, since you opened this issue with that. The patch in #2 won't -- as stated -- apply to dev.
@fabdel - Doesn't work as described? Or the patch doesn't apply? What version of the module?
@car3oon - I can't provide a copy of the module. If you don't know how to apply patches, you'll need to wait for the maintainer to update the module.
@mairav - Is #7 still a problem? Or is #8 the real issue?
Comment #10
mairav commented@mrtoner, both of them are a problem.
About #7, I solved it creating a rule for each content type, instead of using the "any" option, cause with the any option makes what I described in #7. It would be great to have the option to choose if that limit assigned should be shared between the content types, or should be applyed for each one of them.
About #8, It's limiting my supervisors with the limit of 1 given to a registered user. I tryed arranging the rules in different ways, to see if the order helped, but it didn't. So I don't know if the correct assigning of the limits should be done by the ordering of the rules, or making some new section where we can declare which role is more important.
Again, I know this is not something of your patch, but maybe you know how to fix it. I think the importance of a rule should be assigned by the order of them (which is not working), but if it were working, everytime I edit an existing rule, the order is changed and it's really annoying.
I sent a mail some days ago to dave asking him to allow some people to comantain this module, but I get no anwser :(
Thanks again for your help, I hope you can see it soon. For now I gave all the users unlimited permissions, but the site should be launched in some days, and some users shouldnt have the permissions to send unlimited nodes...
Comment #11
SLUH commentedStrange bug: If i make "not inclusive" limit to admin-made-roles, it works properly.
BUT if I make "not inclusive" limit to authenticated user it works like inclusive.
Comment #12
Turkish Delight commentedPosting the shell prompt for creating the 'inclusive' field in the node_limit_role table:
mysql> ALTER TABLE node_limit_role ADD inclusive integer AFTER rid;
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> SHOW COLUMNS FROM node_limit_role;
+-----------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+------------------+------+-----+---------+----------------+
| lid | int(11) | NO | PRI | NULL | |
| rid | int(10) unsigned | NO | PRI | NULL | auto_increment |
| inclusive | int(11) | YES | | NULL | |
+-----------+------------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)
I also have a problem in line with comment 11, after rolling the patch it seems that any authenticated user still works as inclusively as it would have without the patch.
I am using Drupal-6.13 and the patched version of Node Limit 6.x-0.3, however I am also applying a time limit (what I am aiming to do is have any authenticated user post only a limited amount of posts in a limited amount of time) along with the role limit. I'll perform some tests at the moment, but any advice is very welcome.
Does this piece of code at approximately line 30 in the node_limit_role.module have anything to do with it?
After looking around it looks like this piece of code at approximately line 30 may be influencing the authenticated user role.
// Have to do something different for DRUPAL_AUTHENTICATED_RID,
// DRUPAL_ANONYMOUS_RID, and everything else.
if ($limit['node_limit_role']['rid'] == DRUPAL_AUTHENTICATED_RID) {
return array(
'where' => array(
'n.uid > 0'
)
);
}
This is what MySQL presents. Thank you for your time!
mysql> SELECT * FROM node_limit_interval;
+-----+----------+------+
| lid | interval | unit |
+-----+----------+------+
| 2 | 24 | 3600 |
| 1 | 24 | 3600 |
+-----+----------+------+
2 rows in set (0.00 sec)
mysql> SELECT * FROM node_limit_role;
+-----+-----+-----------+
| lid | rid | inclusive |
+-----+-----+-----------+
| 2 | 2 | 0 |
| 1 | 2 | 0 |
+-----+-----+-----------+
2 rows in set (0.00 sec)
mysql> SELECT * FROM node_limit;
+-----+-------+-------+-------+--------+
| lid | type | limit | title | weight |
+-----+-------+-------+-------+--------+
| 2 | --- | 2 | ---- | -9 |
| 1 | --- | 5 | ---- | -10 |
+-----+-------+-------+-------+--------+
2 rows in set (0.00 sec)
Comment #13
Turkish Delight commented// Have to do something different for DRUPAL_AUTHENTICATED_RID,
// DRUPAL_ANONYMOUS_RID, and everything else.
Commenting out or deleting the lines below will allow the new inclusive rule to apply to authenticated users.
if ($limit['node_limit_role']['rid'] == DRUPAL_AUTHENTICATED_RID) {
return array(
'where' => array(
'n.uid > 0'
)
);
}
else (the if function below was on this line. The "if" must be separated from the "else" so that it can start a new function for drupal's anonymous role.)
Do not comment out what will be the new "if" function, separated from the "else if" function above.
if ($limit['node_limit_role']['rid'] == DRUPAL_ANONYMOUS_RID) {
return array(
'where' => array(
'n.uid = 0'
)
);
}
What I have done (in commented form)
// Have to do something different for DRUPAL_AUTHENTICATED_RID,
// DRUPAL_ANONYMOUS_RID, and everything else.
// the lines commented out below influence authenticated user if ($limit['node_limit_role']['rid'] == DRUPAL_AUTHENTICATED_RID) {
// return array(
// 'where' => array(
// 'n.uid > 0'
// )
// );
// }
// else the if function below was on this line
if ($limit['node_limit_role']['rid'] == DRUPAL_ANONYMOUS_RID) {
return array(
'where' => array(
'n.uid = 0'
)
);
}
Comment #14
drupalninja99 commentedi agree it only makes sense to limit for a user of a role, not for all users in a role
Comment #15
mairav commentedI'm despairing. Dave has dissapeared and this is the only module that does or is supposed to do what I need, but it's not working just fine in some things.
I don't understand programming to make it work myself :( and I should be launching a site that needs this, or to be right, the site should alredy be online. :(
Did anyone solved what I posted before in this issue?
@mrtoner, any posibility you can help me with this? I'll be forever grateful!
Comment #16
andraeray commentedneed a little help getting this up and running.
I installed the patch to the 6.x.03 version, and now when i view the settings through admin I see a new option that says inclusive.
I added a new field to my nod_limit_role table entitled "inclusive" using phpmyadmin. Now when i change check and uncheck the inclusive in admins, it changing the 1 to a 0.
However, the problem is still happening, it is taking the post count for the entire user role instead of individual user.
How can i get this working?
(Here are my fields settings
Field: Inclusive , Type: INT, Null: Not Null)
Comment #17
andraeray commentedThanks Turkish Delight,
I commented out those fields you did, and now it works like a charm.
Comment #18
mairav commented@Turkish Delight you wrote
My problem is that if I have a rule for authenticated users, but a user has another role with an specific limit, the authenticated user overwrites the limit given to the other role. This happens with or without the changes in the code you proposed or with them. I created a "registered" role that is assign automatically to registered users and assign the limits to that role, as I explained it in http://drupal.org/node/457426
But I still have the problem that the more restrictive limit is applyed instead of the less restrictive. For example, I have authenticated or registered users (1 limit), designers (5 limit), and supervisors (unlimited), and some users have the three roles. If they are supervisors along with authenticated or registered users they should be able to post unlimited nodes, but they are given just one node.
I'm working with a time frame too.
Any idea to solve this?
Comment #19
andraeray commentedHow about removing them from the lower roles. So instead of a person being all 3, they are just labeled a supervisor.
Comment #20
mairav commentedThe problem is that the roles are also used to list the users in special sectors of the web. If a users has the rol Designer is listed in the designer page, and if the same user has supervisor, its also listed in the Members page.
I haven't try it again, if I assign limits to authenticated users, which is a role I can't remove, that "role" overwrites all other roles limits. Thats why I made no rule for authenticated users, but for a new "registered" role, that is automatically assigned when a user registers.
Comment #21
Turkish Delight commentedI am working on a development site and will tinker with this a little and will post results. Help with this is appreciated.
Comment #22
mairav commentedCan anyone ask drupal to be the new mainteiner of this project, as Dave seems to be missing for 18 weeks now.
Drupal explains how to do it in Dealing with abandoned projects
Doing this maybe we can make Dave to come back and assign somone as a comainteiner. As I said before, this is a great module, but there are some issues. With someone comainteining it, all the patchs will be applied!!!
I hope someone wants to do this.
Comment #23
duaelfrAt this point, this issue is going to be marked as won't fix. This is either not in the direction of the project, or too out of the project scope.
However this have been done in the 7.x version.