Closed (fixed)
Project:
Flag
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
27 Nov 2008 at 21:45 UTC
Updated:
13 Dec 2008 at 23:21 UTC
It would be great if flagging an item could result in a userpoint gain. For example, if there was a flag called "great blog!" then flagging a blog post as a "great blog" would give the blog's author userpoints.
This would probably require an extra setting per flag type, and a call to userpoints_userpointsapi('points', $points, $uid, 'flag-'. $flag_title) when an item is flagged.
Comments
Comment #1
quicksketchI'm not interested in providing userpoints hooks within Flag module. However, there is nothing preventing a userpoints-flag integration module from being written separate or part of userpoints itself. Flag module provides a
hook_flag()that could call the appropriate userpoints functions to register new points upon flagging or unflagging a piece of content.Comment #2
icecreamyou commentedI can't find any documentation on hook_flag. I need to know these things to write the module you're suggesting:
So for my hook_flag implementation I would want to do something like:
Comment #3
quicksketchThe call to hook_flag() looks like this (currently line 401 of flag.inc):
In other words, your module would implement it as:
There isn't yet documentation on this hook (hey, we're still in beta ;) and it has changed in the past between betas. However, I feel that we're pretty solid on the hook flag implementation, so I don't think you need to worry about it changing. You might take a look at the flag_actions.module which is included with flag, as it implements the flag hooks to perform actions.
Comment #4
icecreamyou commentedNice. One last question--how do I get the name of the flag? Is it something like $flag->name or $flag->title?
Thanks for your help so far.
Comment #5
quicksketchYep, the "machine name" of the flag is $flag->name. The human readable name is $flag->title. When grabbing the $flag->title though, you should use $flag->get_label('title'), which will run it through the translation system.
Comment #6
icecreamyou commentedGreat, thanks. I should be set to go now... I just have to install Flag and test!