I'm speaking with a developer about creating the following functionality with userpoints
1. points not given if a) node is created in unpublished state b) node created and goes into moderation (with modr8 module, for example)
2. only positive points go into userpoints moderation. If there are negative points, such as for pageviews, downloads, etc, these are not moderated. Otherwise, a user could download/view pages for hours until the negative points are moderated by admin, so there needs to be a separation between positive/negative userpoints.
now, I don't want to create an orphaned version of the module and then fall behind when the userpoints module gets upgraded so my choice is either to commit a patch to this module or create a contrib module (or two) with this functionality.
which is the better path to take? If a working patch with either or both of these functions was added here, would it be accepted?
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | negative_bypass.patch | 2.24 KB | jbrown |
Comments
Comment #1
kbahey commentedI don't have time to examine the details, but yes, patches are normally accepted provided they do not break backwards compatibility, and are configurable. They have to be tested and reviewed by at least 2 people before they can be included.
Comment #2
esllou commentedthanks. I think the "points only if published" is something quite a few have mentioned on here in the past.
Comment #3
jbrown commentedI created a patch for 2. for esllou.
Please review.
Comment #4
kbahey commentedPlease explain what this patch does. Use cases, ...etc.
Comment #5
esllou commentedIt adds a checkbox in the "Moderation" div on the userpoints config page - "Allow negative points to bypass moderation"
when checked, positive points go into moderation (for creating a node, etc) whereas negative points (for pageviews, downloads, etc) come straight off. That prevents someone abusing the moderation system because if negative points need to be moderated too, they can download files or view all the nodes on a site without their userpoints changing.
I've reviewed it and it works as per design.
Comment #6
BillyBoy commentedthis looks interesting. I have negative points for pageviews on a site. I'll test this out tomorrow. Thanks for the patch!
Comment #7
BillyBoy commentedtested this patch this morning. Works fine. Great addition. Ta!
Comment #8
esllou commentedwhen will this patch be added to userpoints?
Comment #9
kbahey commented@esllou
Please don't rush maintainers. Give them time, they are busy people.
@jbrown
I am wondering if this can be done in an external module, rather than the userpoints API itself.
There is the 'moderate' flag, which can be set to true or false. Combine that with the points before, and you probably get what you need, without a modification to userpoints.
Try this, before we cram complexity and cruft to the module itself.
Comment #10
esllou commentedkbahey, I made a custom module, called it mysite and altered the first line of that code to "function mysite_userpoints", etc, etc
gave the module a low weight and when I do something that means negative points, they go into the points moderation queue anyway. Is there something else I need to do? The module is loading fine as I have other stuff in there to alter forms and it's doing everything as planned. Just this mysite_userpoints function (as is currently) doesn't seem to do anything.
Comment #11
kbahey commentedIt could be that the code snippet I mentioned needs some tweeks.
More debugging is needed to see if the 'moderate' modification takes effect or not.
Specifically, this code in userpoints.module:userpoints_userpointsapi()
There is some similar code in the transaction function too.
This is not something I have time for, so someone else needs to confirm it.
Comment #12
berdir$params is currently not passed by reference, so it's not possible to do that :) Just like any other modification.
#668284: hook_userpoints pass $params by reference would change that.
Also, since this patch is actually in the rules integration category, wouldn't it be better to provide Moderate "default/yes/no" as a option when creating a rule? That's much more flexible than a generic negative points are not moderated option.
There are some trailing whitespaces that should be removed when the patch is re-rolled, but depending on the above idea, it might look totally different anyway :)
Powered by Dreditor.
Comment #13
kbahey commentedI still think that a separate module could do this, without the need to over-complicate the API with special cases.
Let us resist this temptation for increased complexity.
Comment #14
berdirNo, it can't, unless you commit the linked issue :)
Currently, modules can not change anything in $params, ever :)
Also, I agree with not adding complexity, that's why I suggested to make this a per-action/rule option for rules integration (only). In my opinion, rules integration should be as feature-complete as possible, allowing control over any setting/field/option that userpoints_userpointsapi() supports.
Comment #15
manuel.adanClosing this as outdated, 6.x version is no longer maintained.