Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If the limit has been reached by the added material, the user is shown the error page 403. This patch adds the ability to choose to display the material in the activation limit.
Comment | File | Size | Author |
---|---|---|---|
#3 | node_limit-selectnode-2032833-3.patch | 7.34 KB | sanchiz |
#1 | node_limit-selectnode-2032833-1.patch | 6.73 KB | sanchiz |
node_limit_with_arrow.png | 21.16 KB | sanchiz |
Comments
Comment #1
sanchiz CreditAttribution: sanchiz commentedInitial patch
Comment #2
Liliplanet CreditAttribution: Liliplanet commentedThank you Sanchiz, I've patched the code correctly and 'select nid' shows up fine, but now the limits are not being respected anymore.
In other words, the 'user of role' can now add more nodes even when restricted. It worked before the patch with access denied.
Have you perhaps discovered the same? Would most most appreciate any updates on your patch please :)
Comment #3
sanchiz CreditAttribution: sanchiz commentedHey there! Sorry for delay, not had enough time for creating new patch.
So here patch what works on one of my projects.
There uses Node Limit and Node Limit User of Role modules. You should apply patch and run update.php for apply changes in database, then this should work.
Comment #4
System Lord CreditAttribution: System Lord commentedIf I understand correctly
Patch #3 wont work for Node Limit Content Type?
In other words can this patch work when I need to select "Users of Role" AND "Content Type?" Or, is this patch only for admins that need to check "Users of Role" only.
Comment #5
sillygwailoThe patch in #3 seems to work if you select "Users of Role" and "Content Type". That is, if you assign a node ID in the config, it redirects to that node instead of showing the Access Denied message. It initially didn't work, but did when I cleared the site's cache.
Comment #6
thoughtcat CreditAttribution: thoughtcat commentedI attempted to install the patch in #3 and got some errors. (See pasted Cygwin dialogue below.) I ignored these and ran update.php and cleared cache. Now in the Node Limits interface I do get the "node if access is denied" box but the limit isn't being respected. My limit is 1 of a particular content type for all authenticated users - whether I also select a role from "role" or "users of role" or leave both of those unticked, the users are still able to create multiple nodes of the content type and never get sent to the "nid" page I've entered.
Here's my Cygwin dialogue. This is actually the first patch I've tried to run using Cygwin so I may have done it wrong - I was following the instructions at https://www.drupal.org/node/620014
Comment #7
sillygwailo@thoughtcat what happens if you apply the patch to the dev version? I had the same error when trying to patch the official release and corrected it by taking the function declaration from the patch and manually changing it.
Patches should generally be made against the dev versions of modules, and in this case, the patch in #3 applied cleanly to the dev version of Node Limit.
Comment #8
thoughtcat CreditAttribution: thoughtcat commented@sillygwailo Sorry, I didn't get a notification of your reply! Thanks, I will look into that.
Comment #9
thoughtcat CreditAttribution: thoughtcat commentedInstead of using the module to redirect to a specific node, I created a custom "access denied" page with the following code to display certain messages depending on the URL the user is trying to access when they get "access denied":
NB: This isn't perfect PHP ;-) It's only meant to show the last message for all other cases of "access denied" i.e. if the first two tests fail, but instead if the user is coming from /node/add/form they see the first message as well as the last one.
Comment #10
brunomolica CreditAttribution: brunomolica commented#3 working fully in dev version
Comment #11
JordanMagnuson CreditAttribution: JordanMagnuson commentedPatch applied fine to dev release, and seems to work as desired.
Comment #12
sillygwailoComment #13
JordanMagnuson CreditAttribution: JordanMagnuson commentedDiscovered a problem with this patch: the node limit gets triggered and an ajax error is displayed if the user attempts to remove/upload a file to a fielfield when editing an already existing node. See screenshot: https://c4.staticflickr.com/8/7757/18026420939_60b59beda7_b.jpg
Can be fixed by adding a check for arg(0) != 'file' in _node_limit_violates_limit() in node_limit.module:
Comment #14
abhinaba9 CreditAttribution: abhinaba9 at Valuebound commentedThis issue has been solved in the dev version. Whenever a limit is reached we are showing an error message. Check out using the node_limit 7.x-1.x-dev version
Comment #15
JordanMagnuson CreditAttribution: JordanMagnuson commentedThe patch that has been applied to dev is not adequate. Custom error message and/or redirect needs to be configurable per limit (as the patch in this issue provides)--not per node type. (Either that, or we need access to more placeholders in the error message: such as the timeframe of the limit, and the actual node limit number for the timeframe).
It's quite possible to have a limit of say 1 forum topic per day, and 10 forum topics per week, and want to show a different message when each of these limits is hit. The patch from https://www.drupal.org/project/node_limit/issues/1364410 does not allow for this.
Comment #16
JordanMagnuson CreditAttribution: JordanMagnuson commentedThe patch in #3 no longer applies cleanly to latest dev.