I'm trying to use both the moderation module and the workflow module. The moderation modules creates a nice little menu/interface for content administrators to quickly look at all pending comments and content nodes. They can quickly look at the pending queue, view the actual content/comment, click publish, and click moderate all without leaving the existing view. This works great.
I have workflow module setup so that when a user creates a new event node, the event is not published and they are redirected to a URL of a page that says that the administrator has to approve the event before it will show up on the site.
To make it easy for the content admins, I'm not going to add an extra step to make them edit the node, then go to the workflow section and change the state to publish in addition to the normal node publish.
However, I would like to generate an email to the %author when the node is published. There is not a default trigger for "A node is published"
I'm trying to write one myself, and here is what I've come up with so far.
<?php
/
* Implementation of hook_hook_info().
*/
function eventpublish_hook_info() {
$info['eventpublish'] = array(
'nodeapi' => array(
'eventpublish' => array(
'runs when' => t('After Publishing an event node'),
),
),
);
return $info;
}
/
* Implementation of hook_nodeapi().
*/
function eventpublish_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
switch ($op) {
case 'update':
if ($node->type == 'event' && $node->status = '1') {
module_invoke_all('eventpublish', 'update', $node);
}
break;
}
}
/**
* Implementation of hook_script().
*/
function eventpublish_script($op, $node) {
$aids = _trigger_get_hook_aids('nodeapi', $op);
$context = array(
'hook' => 'nodeapi',
'op' => $op,
'node' => $node,
);
actions_do(array_keys($aids), $node, $context);
}1) Does this trigger look like it will work?
2) Is there a better way to do what I'm trying to do?
3) Is there any way to change the state of several nodes at once or from a single view like you can do with the moderation module? Having to require the content admins to edit the node to change the status seems quite tedious.
Thanks!!!
Comments
Just saw a small bug in your
Just saw a small bug in your code:
$node->status = '1'should be:
$node->status == '1'I'm currently using a similar if statement which fires whenever you publish or re-publish a node of that particular type, which is good enough for my implementation.
Revisioning module
It appears as though the Revisioning module provides these:
We're using Revisioning anyway, so I'll give it a try.