function workflow_tab_form in Workflow 6.2
Same name and namespace in other branches
- 5.2 workflow.module \workflow_tab_form()
- 5 workflow.module \workflow_tab_form()
- 6 workflow.pages.inc \workflow_tab_form()
- 7 workflow.pages.inc \workflow_tab_form()
Form builder. Allow workflow state change and scheduling from workflow tab.
Parameters
$node: Node for which workflow information will be displayed.
$wid: ID of workflow to display.
$states: Array of states for the workflow.
$current: Current workflow state of this node.
Return value
Form definition array.
1 string reference to 'workflow_tab_form'
- workflow_tab_page in ./
workflow.pages.inc - Menu callback. Display workflow summary of a node.
File
- ./
workflow.pages.inc, line 119 - Provide user interface for changing workflow state.
Code
function workflow_tab_form($form_state, $node, $wid, $states, $current) {
$form['#tab'] = TRUE;
$choices = workflow_field_choices($node);
$min = $states[$current] == t('(creation)') ? 1 : 2;
// Only build form if user has possible target state(s).
if (count($choices) >= $min) {
$wid = workflow_get_workflow_for_type($node->type);
$workflow = workflow_load($wid);
$form['#wf'] = $workflow;
$name = check_plain(t($workflow->name));
// See if scheduling information is present.
if ($node->_workflow_scheduled_timestamp && $node->_workflow_scheduled_sid) {
global $user;
if (variable_get('configurable_timezones', 1) && $user->uid && strlen($user->timezone)) {
$timezone = $user->timezone;
}
else {
$timezone = variable_get('date_default_timezone', 0);
}
// The default value should be the upcoming sid.
$current = $node->_workflow_scheduled_sid;
$timestamp = $node->_workflow_scheduled_timestamp;
$comment = $node->_workflow_scheduled_comment;
}
// Include the same form elements here that are included on a
// regular node editing page. $form is modified by reference.
workflow_node_form($form, $form_state, t('Change %s state', array(
'%s' => $name,
)), $name, $current, $choices, $timestamp, $comment);
$form['node'] = array(
'#type' => 'value',
'#value' => $node,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
}
return $form;
}