I'm working on a module that needs to save a bit of extra data anytime a node is flagged or unflagged so I was looking at how you handle the list flagging in your code. This seems to be the relevant block:
// Perform the flagging or unflagging of this flag. We invoke hook_flag here
// because we do our own flagging.
$flagged = _flag_lists_is_flagged($flag, $entity_id, $uid, $sid);
if ($action == 'unflag') {
if ($flagged) {
$fcid = _flag_lists_unflag($flag, $entity_id, $uid, $sid);
module_invoke_all('flag', 'unflag', $flag, $entity_id, $account, $fcid);
return TRUE;
}
}
elseif ($action == 'flag') {
if (!$flagged) {
$fcid = _flag_lists_flag($flag, $entity_id, $uid, $sid);
module_invoke_all('flag', $flag, $entity_id, $account, $fcid);
return TRUE;
}
}
I'm not sure if this is deliberate. But in the first instance you invoke module_invoke_all('flag', 'unflag', $flag, $entity_id, $account, $fcid);, setting the $op parameter to "unflag". In the second though, there is no $op parameter.
Also, in the flag 3.x API which I think the latest version of flag_lists supports they've replaced hook_flag with hook_flag_flag and hook_flag_unflag. I'd be happy to write a patch for this if it's not deliberate.
Cheers,
- Scott
Comments
Comment #1
hadsie commentedWell this is embarrassing :). I'd been screwing around with the code last night and forgot to revert. The second module_invoke_all instance actually does have the $op parameter.
So ya, that answers my first question. The second is still there though, do you want to actually be calling module_invoke_all on 'flag_flag' and 'flag_unflag'?
Comment #2
sl27257Hi,
thanks for your comments on this!
The easy answer is that I have not done anything with this from the previous version, i.e. the version for earlier versions of the flag module. If the flag module changed their hooks I think we should definitely do it in the flag_lists as well. So please provide a patch for it!
/Thomas
Comment #3
hadsie commentedAttached is a patch for the hook_flag_flag call against the latest dev code.
Cheers!
Comment #4
sl27257Thanks for the patch!
I think this is a relatively simple patch to test. So if I patch my code, check it out, I think I can then mark it as "Reviewed & tested by the community". Given that the patch is OK. Is that OK with you?
Comment #5
sl27257This is a change in the API of the flag_lists. But given that the flag module has change it, I think it will be easier in the future if we align with them!
Comment #7
sl27257