It would be great if you can include this features in the drupal 6 version.

- we can assign limits by role that can be applyed to each user of that role (each user can creat 5 nodes of certain type) or to the complete role ( the 5 node limit is between all the nodes created by the users that belong to that role), for example, making an "inclusive" checkbox that makes the second option work.
- we can assign limits by content type with the posibility of multiple content type selection, with an "inclusive" checkbox, so we can define if the specified limit is for each content type or shared by them.
- we can assign time frame limits, for example, create x nodes in one month.
- we can combine all of this limits in one, for example. I create a rule to limit my painters to create 5 nodes of news OR paintings (the inclusive checkbox unchecked) in one month.
- define if the more restrictive o permissive rule is applyed, or order the rules and that the order defines which rule wins.
- that we can define in a multilanguage site if the translations count as a node or not.
- that we can see somewhere (as admins or the user trying to create nodes) how many left nodes can a user create.

This is what I remember now that would be helpful, for me and for a lot of people that is waiting for some good module to limit nodes (as this was just for drupal 5 and node_limit is almost abandoned).

If you think you can make this, I offer myself to test it, and help you remove bugs. In that case please tell me which of this features you think you can make work, and how long would it take. You can contact me through the contact form.

Comments

mairav’s picture

I forgot another one:

- that we can enable or disable a certain limit, instead of having to delete it to now work anymore.
- that in the list of the rules, we can see al the features, to know how a certain rule is made and how its working

jdwfly’s picture

First thing I am going to add is the per user limit ability. This will allow a certain user limit regardless of role.

EX
User role Contributor is limited to 5 posts
User johnny is limited to 3 posts
johnny can only post 3 times

If his limit was over 5 he would be able to post how many his limit is.

Dries Arnolds’s picture

And I've got another one (that I already requested on the old module):

Limit the number of times a taxonomy term may be used in a timeframe. This is especially useful for limiting the number of posts per user in a specific subforum.

00110000’s picture

I have a minor request. Of course nothing big or a priority, but:

You can't create more content of type xxxx, sorry.

Perhaps different wording than that?

Something more along the lines:

You have reached the allowed maximum limit for the xxxx content type. Please delete ( or remove?) past submissions in order to be able to contribute ( or create?) new content.

or perhaps just:

You have reached the allowed maximum limit for the xxxx content type.

Otherwise, I think the wording seems as if some penalty has been placed over your user for post-whoring/spamming or rather certain actions have been revoked indefinately due to possibly doing something wrong. Or perhaps that's just me getting this vibe off the wording.

If you don't believe this is the case, then by all means, please ignore this.

mairav’s picture

Yes, I think it's true, and it would be nice to say the ammount, like "You have reached the allowed maximum limit of 'n' nodes for the xxxx content type." (n would be the ammount of the limit)(I don't know if that is the correct way to say it, but that is the general idea).

mairav’s picture

Hi jdwfly! thanks for the new release! I posted a problem I have with it in #588144: Make sure that the uninstall schema function is being called

I saw that you also posted that for version 2 you will add:

* Per user limits
* Time limits (daily, weekly, monthly, annually, forever)
* New User Interface
* Enable/Disable Limits

Have you decided in which order of priority you'll add this things? and how long would it take? I ask cause I'm soon to launch a site that needs this, and is actually using node limit, which is not working well, and I have to decide what to do, or how to solve my problems.

Thanks again!!!

jdwfly’s picture

First priority is the per user limits, but I have found that I will need to change the UI to do that. Not to mention some database changes that will take place. The list is sort of in order as far as how I am going to work it, and the suggestions here will be put on as upcoming features as soon as I figure out what is feasible or not.

mairav’s picture

I'm watching at the interface, and i got a dbout.
I have some users with two or more roles.
For example the role designer, colaborador and supervisor. The role designer has limits, that shouldn't be applied to the other two. So, there shoul be an option like 0 or -1 that means "unlimited" to overwrite the limit given to the designer role. what do you think about this?

jdwfly’s picture

I have been thinking about how these limits are being used and I have come to a conclusion that if I were to program this as is I would be duplicating a lot of code. By that I mean that with very little code I could integrate this module with rules. This would give us all the power of rules as well. In fact in parts of the code and in posts on this issue queue we have used limits and rules interchangeably. Limits are very similar to rules and I think the best course for the 2.0 version of this module is integration with rules.

This would mean that to make a limit one would start by making a rule. This would need a special event to be created. In that event you could add your conditions: Node is type Page, User role is Authenticated, etc... Then there would be a special condition that would set the limit. You can then do whatever actions you want, redirect to a page, show a configurable message etc. I have actually already coded this and tested it out. I think it is the way to go, but I want to know what everybody else thinks.

mairav’s picture

That will allow us all the features we asked in number in the first comment? timeframe, roles, combined or separate limits, etc?
I don't really care the way it's done internally, I just want the limits to be applyed by role, content type and timeframe simultaneously.

Maybe it would be great to have some tutorial with the way to configure limits, or to import some predefined limits, that we can easily modify. Or a way to clone existing limits, so if we have a base limit, we can clone it and make small changes.

mairav’s picture

I got a dbout, with the integration with rules, if a user has several roles, and we create rules for all this roles, how can we define if the more restrictive or permissive rule will be applied?

jdwfly’s picture

Rules can be very complex especially in your case. You could set up the rule so that their role must "match against any or all of the selected roles:" So basically you would want your rules to be very specific so that your user doesn't get locked down. I've looked through all of the features that you suggested and others and I believe that all the expectations will be met. The only one that I am thinking will be tough will be to create a page where admins can see how many nodes a user can still create.

mairav’s picture

It's not so importante for admins to look how many can still be created, but it's important for each user to know how many can she or he still create.
What is important is that admins can clearly see the important features of each rule, so they know which one they should modify, cause, now, to give you an example in node_limit I don't have information about the rules, so I don't know which is the limit, if it has a timeframe rule, to which roles it's applied, etc.

I'm happy about your comment that almost everything can be achieved with this, cause is an important feature of the site I should be launghing in some days, and I'm still stuck with problems in that area.
How can I test this?

jdwfly’s picture

I'm waiting on the bot to package the dev version. Very soon there will be a dev version to use.

I'm not promising the world though. Basically anything that can be done with rules could be used to create the limits. I'll probably need to create a good screencast with how to use the 2.0 version. In the meantime you can try your hand with changing a few example rules that I created.

mairav’s picture

Great! I see the dev version, I'll check it tomorrow cause its 3AM here and I'm really tired. Thanks for the version. I'll try it and let you know if I have any dbout, I need help or if everything is ok (crossing fingers) :D
Thank you!!

mairav’s picture

I couldn't wait!!! I installed it and it seems just what I need!!!! I'm really happy, you've got a great idea!
Tomorrow I'll make more rules and check how they work together! Thanks, thanks, thanks!

00110000’s picture

This sounds like a great idea, will be implementing this on my test site in the coming days.

mairav’s picture

It's the first time I work with rules, and I can't make it work when a user has two roles.
For example, my user has the roles designer and supervisor.

Designer has this limit:
- node type is image
- AND user has role designer
- AND se limit 1 monthly

Supervisor has this limit:
- node type is image
- AND user has role supervisor
- AND se limit 10 monthly

I can't give the order to apply the supervisor rule instead of the designer rule.

I tried creating two independent rules and giving them different weights. I also tryied to create only one rule, and playing with indented conditions with OR and AND, but it didn't work either.
Any tips on how to make it?

mairav’s picture

I managed to make it work all in one rule (thanks to my fiance that si a programmer).
I have a multilanguage site, and for example, a user can create 5 nodes of certain type per month, and the rule works fine.
But, the user should be able to create a new node, even when he had reached the limit, if the new node is a translation of an existing one. Do you think this can be sorted in some way with rules?

This should be the same to apply the limit for a node type that is a content profile, so a user can have his profile translated.

jdwfly’s picture

Hmm, this is an interesting problem. As far as I know when you make a translation of one node you are actually creating another node which would go against their limit. You could try to implement the rule against a certain language only. That should be possible within rules. So basically you would have a limit for english nodes, spanish nodes, etc. Let me know if you can do that using rules. If you can't we may need to make a patch for another module.

Which module(s) are you using for translation? I am assuming the internationalization module.

mairav’s picture

Yes, I'm using i18n.
The problem is that if I allow 5 nodes in spanish and 5 nodes in english, they can't be any node, they should be only 5 more in another language, only if they're translations of existing ones.

Or should be unlimited if they are translations of existing nodes, cause maybe the user created 5 spanish nodes last month, but didn't translate any of them. This month he creates the other five nodes in spanish, and now he wants to translate this month and last month nodes. If we apply the same limit to translations, he will never be able to translate old untranslated nodes.

I was looking in rules the way to set a language, but didn't find anything.

As I see in the database, in node table, every node has a tnid row, where it says the nid of the original node. If the original node nid is 115, the tnid of that node also 115. If the node 120 is the translation of the node 115, then in tnid I find 115. What I mean is that the original and translation node have the nid number of the original node in the tnid row. And if a node has no translations, that node has a 0 value on tnid row.

I don't know if that can be useful, is just something I found :)

jdwfly’s picture

Add a Custom PHP code to your rule.

if (isset($node->translation_source)) {
  return FALSE;
}
return TRUE;

This will allow your users to make unlimited translations. I checked out the i18n module and it doesn't look like they are integrated with rules. It would be nice if they were because they could simply add a condition that checks if the node is a translation or not. I thought about adding it myself as a patch, but I don't know that it would get in. Either way you should be able to use the custom php field with that code I supplied.

mairav’s picture

WOW! That did the trick! Now the user can add new nodes if they're translations of old ones! Really thanks!
Node limit allowed a -1 value that mean unlimited, as this doesn't exist in node limit number, for supervisors I set a 1000000 limit per month, which is imposible to reach, so they have "unlimited" permission.
Is it posible to create an unlimited limit, or I keep the limit as 1000000?

Thanks for your help, It's a lot better what can be done with this integration with rules, but it's also not that easy to accomplish. Maybe you should give more example rules for different scenarios, or create some place where people can upload they're exported rules, so others can import them and start with something.

Thanks again.

jdwfly’s picture

I am not sure why I would need an unlimited status. If you don't want them to have a limit then don't include them into the rule. Maybe I am not understanding your setup (probably true).

Setting up the rules is going to be as complex or as simple as your needs dictate. Documentation of the new features is lacking though. I probably need to create a book page on drupal.org that will help new users integrate this into their site. I'll get a good tutorial and maybe a screencast up before I make the 2.0 release.

mairav’s picture

You know, I was writing this comment, and then, I realice that my line of thought was wrong. It worked, but it was wrong. I was thinking in the way that node limit worked, where if you assigned a limit to a role, and if a that user had another role, I should create a rule that overwrites the first one.

I edited my rule, and now it's a lot simpler. I just say that the limit of 5 nodes is applyed if users are designers, and are NOT supervisors, and that's all.

I had 12 rules in node limit and I was missing another 8, and now with two rules I made the same thing!!

So, checking the original features list:

- we can assign limits by role that can be applyed to each user of that role (each user can creat 5 nodes of certain type) ... DONE
- or to the complete role ( the 5 node limit is between all the nodes created by the users that belong to that role), for example, making an "inclusive" checkbox that makes the second option work. NOT DONE. I don't need this, but some people use that.
- we can assign limits by content type with the posibility of multiple content type selection... DONE
- with an "inclusive" checkbox, so we can define if the specified limit is for each content type or shared by them. NOT DONE, IT MAY BE USEFUL
- we can assign time frame limits, for example, create x nodes in one month. DONE (I don't know where to change the timeframe, as I only see monthly
- we can combine all of this limits in one, for example. I create a rule to limit my painters to create 5 nodes of news OR paintings (the inclusive checkbox unchecked) in one month. DONE
- define if the more restrictive o permissive rule is applyed, or order the rules and that the order defines which rule wins. DONE. It can be applyed with a correct assignment of the rules (a little difficult)
- that we can define in a multilanguage site if the translations count as a node or not. DONE with your code in #586064-22: Node Limit Number for Drupal 6 - FEATURES REQUEST
- that we can see somewhere (as admins or the user trying to create nodes) how many left nodes can a user create. NOT DONE. I tried to customize the message saying how many nodes are left, but couldn't.
- that we can enable or disable a certain limit, instead of having to delete it to now work anymore. DONE
- that in the list of the rules, we can see al the features, to know how a certain rule is made and how its working NOT DONE, but it's not necessary, as we don't need so many rules with node limit number

I really appreciate your work! Now I'm a bit closer to publish the site!

Dries Arnolds’s picture

jdwfly, I'm curious what you think of my feature-request in #3. I think it is the only way to limit the number of topics in a certain subforum.

jdwfly’s picture

@Pixelstyle

This can be easily done with rules and tokens. You could create a textual comparison condition and then use tokens to get the right taxonomy term that you want to limit.

Milan0’s picture

@jdwfly I am interested in doing this aswel, i want to limit to 1 node per user per term, but am kinda oblivious how to do the token comparison in rules.
Could you give an example?

jdwfly’s picture

Status: Active » Closed (fixed)

I think this can be closed now. Any feature requests that have not already been addressed please create a separate issue.

Anticosti’s picture

Subscribing...

serguitus’s picture

How do I add that custom php code to my rule from #23.... I cant find where to add it to make it work
could some one help me?

thanks in advance

mortician’s picture

Same problem - where to add code #22 it to make it work. Please give me advice step by step.

serguitus’s picture

mortician:
Just add a new condition to your rule with "evaluate php condition" (or something like that) and use code in #22 inside the code area