This module is a great addition! A couple of suggestions:
- actions.module not listed as a project for 4.5?
- would be good if you could control which roles could change each state (or each transition) so you could control hand-off of the item between roles. This allows requires different users to be able to 'edit' the node of course.
- why not show the workflow name instead of just 'workflow' on the form_select pulldown?
- could workflow be a separate tab, similar to 'outline'? Seems wrong to think of 'editing' the node just to change it's state. also would allow users to change workflow state without having node edit permissions?
- I added a little feature where it adds a comment whenever the state changes. This can't quite be implemented as an 'action' since it needs a text-area input box beside the workflow pulldown on the node edit page. Ie. user selects new state, types why they made the change in the 'workflow change reason' area, and when they submit the form, a new comment is added to the node - it includes the user's name, timestmp, a title like 'workflow: draft --> done" and a body that includes the change reason. Maybe this should be a configurable feature of workflow module (ie. whether or not to include an audit trail by prompting for change reasons and adding such comments).
My change was to add a new text area after the form_select in workflow.module:
$output .= form_textarea( //PDS - collect reason
t('Workflow change reason'),'_workflow_reason',
null,null,3,'If you change the state, explain why');
and then to add a workflow hook to add the comment:
function quadstone_workflow($op, $old_state, $new_state, $node) {
switch ($op) {
case 'transition pre':
break;
case 'transition post':
// maybe we need to temporarily switch to an admin user here?
// or make sure users who change workflow have comment permission,
// and types with workflows allow comments
$wid = workflow_get_workflow_for_type($node->type);
$states = workflow_get_states($wid);
$comment->nid = $node->nid;
$comment->subject = 'Workflow: ' . $states[$old_state] . ' → ' . $states[$new_state];
$comment->comment = $_POST['edit']['_workflow_reason'];
if (!$comment->comment) $comment->comment = 'No reason given';
comment_post(object2array($comment));
break;
}
}
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | workflow-comment_logging.patch | 1.66 KB | hystrix |
Comments
Comment #1
jvandyk commentedExcellent suggestions.
Regarding roles, that is in the works. mathias is preparing a node role access module that hooks into workflow.
Regarding workflow name, I will make that change.
Regarding workflow history, I've been thinking about that. We need to move carefully here and work together with revisions (which is currently under revision by killes for 4.6). But yet, we need this -- the ability to see who did what to a node and when (and why!).
Good use of the workflow callback.
Comment #2
hystrix commentedThank you so much Patrick for your workflow comment logging code. Combined with node_privacy_by_role it works out well for a something we are attempting to track with the workflow module. We absolutely needed a history of items completed that could be seen by persons participating in the workflow.
I have attached a patch to make it easier for the next person to apply if needed.
Comment #3
samo commentedI really like these enhancements and hope to see them integrated into workflow at some point. I modified the patch a bit because of a need to have private, editorial comments about a node instead of public comments. I also created a separate "workflow" tab to handle the display of comments.
A few of the relevant pieces of code:
I created a new table workflow_comments. Here is the insert function:
Add workflow tab to workflow_menu function:
Render editorial comments:
Comment #4
moshe weitzman commentednow that revisions patch has landed, perhaps we can properly implement this audit log ... also, would be nice to give docs on restructuring actions by role (we might have the docs by now - not sure)
Comment #5
moshe weitzman commentedthis has been implemented
Comment #6
(not verified) commented