function workflow_field_choices in Workflow 5
Same name and namespace in other branches
- 5.2 workflow.module \workflow_field_choices()
- 6.2 workflow.module \workflow_field_choices()
- 6 workflow.module \workflow_field_choices()
- 7.2 workflow.deprecated.inc \workflow_field_choices()
- 7 workflow.node.inc \workflow_field_choices()
Get the states one can move to for a given node.
Parameters
object $node:
Return value
array
4 calls to workflow_field_choices()
- action_workflow_execute_transition in ./
workflow.module - Implementation of a Drupal action. Changes the workflow state of a node to the next state of the workflow.
- workflow_form_alter in ./
workflow.module - Generate a forms API compliant workflow field.
- workflow_nodeapi in ./
workflow.module - Implementation of hook_nodeapi(). Summary of nodeapi ops we can see (Drupal 4.7):
- workflow_tab_form in ./
workflow.module
File
- ./
workflow.module, line 554
Code
function workflow_field_choices($node) {
global $user;
$wid = workflow_get_workflow_for_type($node->type);
if (!$wid) {
// no workflow for this type
return array();
}
$states = workflow_get_states($wid);
$roles = array_keys($user->roles);
$current_sid = workflow_node_current_state($node);
// if the node author or this is a new page, give the authorship role
if ($user->uid == $node->uid && $node->uid > 0 || arg(0) == 'node' && arg(1) == 'add') {
$roles += array(
'author' => 'author',
);
}
if ($user->uid == 1) {
// if the superuser
$roles = 'ALL';
}
$transitions = workflow_allowable_transitions($current_sid, 'to', $roles);
if ($current_sid == _workflow_creation_state($wid)) {
// include current state if not (creation)
unset($transitions[$current_sid]);
}
return $transitions;
}