I installed, and activated the module, but I don't understand when it should block a user from creating a node.
In the module source I find the following lines:
function userpoints_nodelimit_check($nodetype) {
global $user;
$current_points = userpoints_get_current_points($user->uid);
$node_points = variable_get(USERPOINTS_POST . $nodetype, 0);
if (($current_points + $node_points) < 0) {
return FALSE;
}
else {
return TRUE;
}
}
That means the user will be blocked only when the sum of $current_points, and $node_points is negative, which turns to be true only when one of the values is negative, and its absolute value is greater than the other value; because $node_points is generally positive (we don't want to take off points to users who contribute by creating a node, do we?), then the module will take actions only when a user has negative points.
If a Drupal installation uses also userpoints_no_negative.module, that will never happen.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | userpoints_nodelimit_module.patch | 3.04 KB | avpaderno |
| #4 | userpoints_nodelimit_module.patch | 1.44 KB | avpaderno |
Comments
Comment #1
jredding commentedI believe this module was created such that a node creation is a "charge" so yes when a node is created it would subtract points. Then when the user has no more points they can't create any more nodes.
The use case would be a job posting/classified ads (i.e. you pay for so many points and can use them however you want).
This should be better documented in the module or flipped around so that the number can be post or negative "nodes can't be created with a point value higher/lower than X "
Comment #2
avpadernoI change the title of the issue.
The module should better document how to use it. I activated it thinking it would limit the number of nodes a user could create, but because normally one give points for the creation of a node,
userpoints_nodelimit.modulewill never take actions.Comment #3
kbahey commentedPlease create a patch with the appropriate help and/or README that would describe this.
Comment #4
avpadernoThe objective of the module should also be better described in the project page too.
Comment #5
jredding commentedyes.. I'll be sure to update the project page.
I agree documentation is best for this but why not simply adding a setting to the module to configure a point value wherein the node limit kicks in?
The only difference would be on that line of code, instead of 0 it'd be $limit_value.
This way you could use it the way you though it'd work (when I user reached a certain height of points) or in the way it was originally intended (i.e. they couldn't dip below 0).
just a thought.
Comment #6
avpadernoThat is a good idea.
-- Kiam@AVPnet
Comment #7
kbahey commentedSetting this to CNW.
Kiam, if you can roll a patch to do what jredding said, that would be good.
Comment #8
avpadernoDone.
The implementation in the patch uses a value which is unique for every kind of node, that avoids to pass to
userpoints_nodelimit_check()the kind of node being created.The new patch also fixes a little "bug" present in the previous one (I forgot to call
userpoints_translation()), and it optimizes a littleuserpoints_nodelimit_check()(the lastifinstruction has been replaced by a singlereturninstruction). It also changes the line:to:
Comment #9
kbahey commentedThe patch fails to apply.
Please reroll it against what is in CVS now.
Comment #10
avpadernoDone.
Comment #11
avpadernoI forgot to change the issue status.
Comment #12
kbahey commentedIt we better if we had a patch attached.
Comment #13
avpadernoOops.
May I suggest to close this issue, and continue on #265677: userpoints_nodelimit.module needs cleanup? In that way I can put a global patch for both the issues.
Comment #14
kbahey commented