Hello all,
I am using userpoints, flags, flag_abuse, and rules to create a homespun SPAM control system. Basically, every time a user's post get marked as SPAM via a flag, a rule also catches the action and decrements his userpoints. If any single user has been complained about 5 times in any combination of posts, the userpoint rating drops to -5, and and a rule sets the user to "blocked". This is working very well. But I am concerned that we might eventually get some new, spiteful users who will try to get people blocked. So I want to limit the number of times a user can flag in a day. What would be the cleanest way to implement the following:
Every time a user flags a post, somewhere a "number_of_flagged_posts" variable gets incremented. If it reaches say "3", the user can no longer flag until it resets the next day. But I'm not sure how to implement the "number_of_flagged_posts" variable. I'd prefer to not code it with tokens.
Thanks for your help!
Comments
Comment #1
Bilmar commentedHello,
I see you use the "Action: Grant points to a user" to deduct userpoints but for limiting the flagging per day I think this should be asked in the Flag issue queue?
Comment #2
joecanti commentedHi,
Did you come up with a solution for this?
This functionality would be great,
Thanks, joe
Comment #3
Bilmar commentedrouting to Flag module to see if anyone there can help you with your question about limiting the number of flagging per day
Comment #4
quicksketchYou can do this through hook_flag_access() and hook_flag_access_multiple() in the 2.x version of Flag, but it would require custom coding to accomplish such specific behavior.
Comment #5
joecanti commentedThanks for the reply Quicksketch,
Now this has been moved across to the flag issue queue I notice a similar posting of mine here - http://drupal.org/node/812372 - where you detail how to begin... I will look in to this further..
to the first poster sb56637 - would you know how to add this functionality to the Flag code give quicksketch's starting point??
Many thanks, Joe
Comment #6
joecanti commentedJust as more a reminder to me really - Im also looking into this happening at the rules end since my flags trigger votes using rules...a global token would be a good idea here to output in the message - eg - 'Thanks for voting - you have 5 votes remaining' or 'you have reached your maximum number of votes for the day, your vote has not been counted'
The extra voting forms module implements a similar system which it calls an anti abuse system - it limits votes per user per day/hour etc to a given number.
This isnt really in the scope of flag because flags default behaviour is 'no multiple flagging on any one node' which means that abuse of voting is not such an issue. Maybe rules will be a better place to put this fail safe as it is acting as a sort of gate to the voting system. It also has conditions for actions happening, so maybe it would be easier to add a time based condition to Rules to work in the same way as the Extra voting forms abuse system.
Joe
Comment #7
rahim123 commentedNo, sorry, my coding skills are about nil. I am still interested in this functionality though.
Comment #8
mooffie commentedWhy use this complicated scheme?
Why don't you just ask "how to limit the number of times a user can flag in a day?"
Well,
to find out how many times a user has flagged in the last 24 hours, and assuming the flag isn't 'global', you need to issue a relatively simple SQL query:
SELECT COUNT(*) FROM {flag_content} WHERE uid = 12 AND fid = 6 AND timestamp > ...now() - 24hours....Now, the problem is what to do next.
Nate suggested implementing hook_flag_access(). The problem is that this hook has some disadvantages: the links will be gone for a user who used up his alloted flaggings for that day, and he may not understand why. You'll have to turn off AJAX for this flag (to make the page refresh itself --for the other links to disappear). (But maybe you don't care about these disadvantages.)
There's a proposal for a new hook, #952114: Have hook_flag_validate(), which will make it [relatively] easy to implement this feature.
Comment #9
mooffie commentedI wrote a handbook page that answers your question:
Coding example: Limiting the number of flaggings per day
(One reason for this page is to demonstrate the use of hook_flag_access().)