"Content is going to be viewed" doesn't serve when trying to capture an edit event.

Comments

amitaibu’s picture

Status: Active » Needs review
StatusFileSize
new1.44 KB

I gave it shot, please review.

amitaibu’s picture

StatusFileSize
new1.52 KB

Small fix

amitaibu’s picture

amitaibu’s picture

Title: Add "Content is going to be Edited" event » Add content related events
StatusFileSize
new2.77 KB

I've added also node revision revert, and node revision delete

fago’s picture

Status: Needs review » Needs work

great ideas.. :)

@strpos:
Why are you using strpos the compare the formids of the revision forms? Just check for $form_id == 'node_revision_revert_confirm' ?

In drupal, the coding style is to use
else if, not elseif

+ '#description' => t('Note that if drupal\'s page cache is enabled, this event won\'t be generated for pages served from cache.'),

that doesn't apply to these events.. just remove it. Furthermore the label "viewed content" doesn't suit to your events.
A problem, that might confuse people, is that this works only if the node is reverted using the drupal form to do so. If other modules, or e.g. a workflow-ng action reverts a form, it's not fired.

I'm not sure if it is possible to this in a way it works in any case. Perhaps it works to do a node_load() after the node is already saved, to get the cached copy of the old node, compare the nodes and fire the event if the revision flag has changed...

So as this doesn't work in general, I think it's not a good idea to add it to workflow-ng. Thinks get to complicated if they don't work in any case.. People just don't expect that. Perhaps, it makes sense to start a new module "workflow-ng bonus", which adds more workflow-ng stuff that is useful, but that doesn't fit to workflow-ng itself. What do you think?

Anyway, the node edit event works in any case - so I suggest we add only this one to worklfow-ng.

amitaibu’s picture

1. strpos - I saw it in other modules. I assumed other modules might change the form name, but anyway next time I'll do it.
2. I'll try to find a more generic way for the revision. As you see I'm a beginer, but getting my ways :)
3. Good idea - kind of Workflow-ng bonous pack. It can have also a configuration of the node lock for example.
4. Yes, only the 'node is going to be edited' should be currently commited

Fago,
Should I create a new patch, or your going to edit the patch and commit?

fago’s picture

please create a new patch, only containing the edit event.. So you get into rolling patches :)

@3: I'll look after creating one in the next days.

amitaibu’s picture

Title: Add content related events » Add "Content is going to be Edited" event
Status: Needs work » Needs review
StatusFileSize
new1.38 KB

1. Removed description.
2. Changed label to 'edited content'
3. reverted the form_alter to check only for node edit.

mitchell’s picture

Project: Workflow-ng » Rules
Version: 5.x-1.x-dev » 6.x-1.x-dev
Component: Code » Rules Engine

@Amitaibu: is this still worth pursuing?

There are "after updating existing content" and "content is going to be saved" events, but that doesn't seem like the same thing.

fago’s picture

Title: Add "Content is going to be Edited" event » forms support
Status: Needs review » Needs work

This would be possible once there is form-api support, see http://groups.drupal.org/node/20487.

mitchell’s picture

I believe this feature is necessary for the "Populate a node title" action to work. "Content is going to be saved" occurs too late, for instance, to replace automatic node titles. Is hook_validate the right event for this?

fago’s picture

hm, Content is going to be saved shouldn't be too late, however autonodetitle probably overwrites your title if you use it together. Perhaps we could fix that by adding

$node->auto_nodetitle_applied = TRUE;

to the rules action?

mitchell’s picture

@fago: The problem isn't auto_nodetitle, it wasn't even installed. "Content is going to be saved" requires the form passes validation. From hook_nodeapi:

"presave": The node passed validation and is about to be saved. Modules may use this to make changes to the node before it is saved to the database.

fago’s picture

ah so you want to set the title for previewing? For doing that properly you would need forms support yeah (validation). You might be able to do it currently by detecting a "preview" with the view event somehow.

mitchell’s picture

Issue tags: +rules forms support

Interesting idea, fago. 'When content is going to be previewed' would work consistently, as long as you required the user to preview the node before submitting.

This issue seems like it needs to be broken up, so I'm adding a 'rules forms support' tag.

intent’s picture

mitchell, this sounds like exactly what I'm looking for. In my case, I need to validate a date entry prior to saving. I'm forcing a preview, so a rule triggered on preview would seem to allow me to perform a validation before saving - perfect.

klausi’s picture

Status: Needs work » Fixed

This should be fixed with the new Forms Support submodule, have a look at the dev version of rules.

Status: Fixed » Closed (fixed)
Issue tags: -rules forms support

Automatically closed -- issue fixed for 2 weeks with no activity.