A spin-off of #296473: Replace Actions/Trigger Support.
While Workflow-NG/Rules will provide the ultimate flexibility in setting up flagging rules, I want to maintain a simpler approach to actions that leverages the available actions in core without the overhead of the Rules UI. This patch wipes out our current Actions integration, other than flag_hook_info() which remains in flag.actions.inc.
This moves all our Actions integration to a separate module "flag_actions.module". Considering that users will probably use either Flag actions or Rules, it makes sense to move everything to a module that can be turned off in the case that they are going to need Rules. This module provides two "conditions" for firing actions: the event (flag or unflag) and the count threshold.
Screenshots of the UI are attached.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | flag_better_actions5.patch | 38.42 KB | quicksketch |
| #8 | flag_better_actions6.patch | 39.7 KB | quicksketch |
| flag_better_actions.patch | 39.21 KB | quicksketch | |
| flag_actions_list.png | 30.67 KB | quicksketch | |
| flag_actions_edit.png | 35.18 KB | quicksketch |
Comments
Comment #1
quicksketchMooffie: I recalled why the $flag_action variable was an object previously. When performing token replacements, the argument calls for an object. However, this differs from the $context argument needed for Actions (which is an array). The $flag_action object was made for token replacement, but just so happens to work well for the $context argument for actions. This patch switches it back to an object rather than array.
Comment #2
fagoPerhaps I can help you with some notes regarding rules:
rules also supports firing core actions - perhaps you can reuse these actions with rules. (I had no close look at it, so I don't know if it makes sense.) - for more about that see http://drupal.org/node/299055
If your motivation for this is just the better integrated UI - you could also build upon rules, build an own UI and programatically configure the rules. (as you prefer, I just want to let you know.)
Comment #3
mooffie commented(Nate, I'm examining the patch right now.)
Comment #4
webchicksubscribe.
Comment #5
mooffie commentedNate, this is superb!
Much, much better than what we now have.
I have only minor comments (but you can commit the code as-is):
- I wish you worked in E_ALL mode. (There are only about five or six places where the code genrates a warning. None of them because of a bug.)
- flag_actions_check() can be removed.
- The comment flag's get_valid_actions() allows for some node actions too. But only a 'comment' context is passed to the action's callback (in flag_actions_do()). (You may decide to simply discard node actions. The Rules patch has a "give me all contexts" method.)
- FWIW, for PHP4 compatibility, "$context[$action->type] = $object" should be changed to "$context[$action->type] = &$object". Or, simpler, this line could be moved outside of the loop. (So that if two or more actions are registered, and both modify a node, both will get saved.)
- BTW, the "send tokenized e-mail" action doesn't yet exist there.
- Will you make a D5 version of it?
I'm for commiting this right away. Excellent work.
Comment #6
mooffie commented(@fago: Rules is certainly superior to Actions.)
Comment #7
quicksketchFYI, I'm still working on backporting this to Drupal 5.
Comment #8
quicksketchLooks like I was pretty close to finishing this before heading to DrupalCon. It just required a few small changes to get a multistep form working in Drupal 5, but now it's all rolling along just fine.
Moofie: I've addressed the problems you outlined above,
- All notices are now corrected, I'll be sure to work in E_ALL moving forward.
- flag_actions_check() is now removed.
- For PHP4 compatibility... I just replaced "= $object" with "= &$object" as you suggested.
- The "send tokenized e-mail" action is included in the "Token actions" module, it's not provided by Flag.
As for:
- The comment flag's get_valid_actions() allows for some node actions too.
I was aware of this but I didn't account for it yet. Let's take a stab at it in a later patch. I've committed what we've got so we can roll out a new beta.
Comment #9
mooffie commentedGreat. I'll test this later today.
Comment #10
archetwist commentedNot there yet. I've got two problems with the latest dev version.
1) There is no upgrade path. After updating the module all actions created using the beta3 version are lost.
2) The following error message appears when trying to use a flag that has a action assigned to it. Of course, no e-mail message is sent.
Comment #11
mooffie commentedArchetwist, I've just noticed that too. I've opened a new issue:
#305391: beta3 actions still registered
(I'm marking this "fixed". Once a patch got commited it can't go back to "needs work". Instead, new issues must be opened.)
I'd say we shouldn't waste time on this. It could be nice to tend to this, of course, but there are so many other tasks we need to do.
Comment #12
archetwist commentedGood to know. Sorry for messing with this issue ;) .
Comment #13
mooffie commentedThis was fixed in #307250: Make actions get the right object
Comment #14
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.