function workflow_extensions_change_state_form in Workflow Extensions 6
Same name and namespace in other branches
- 7 workflow_extensions.module \workflow_extensions_change_state_form()
Use this function in a code-snippet to output a workflow state change form on any page. May be used multiple times on the same page (for different nodes), e.g. using the 'Views PHP' module, as a unique form_id is generated for each occurrence of the form.
Parameters
$node:
2 calls to workflow_extensions_change_state_form()
File
- ./
workflow_extensions.module, line 406 - UI-related improvements to the Workflow module and tokens for Rules.
Code
function workflow_extensions_change_state_form($node) {
if (!$node || !($wid = workflow_get_workflow_for_type($node->type))) {
return '';
}
$choices = workflow_field_choices($node);
if (count($choices) == 1) {
if (user_access('view workflow state change block even when state cannot be changed')) {
// Generate single-option form without Submit button
return drupal_get_form('workflow_extensions_single_state_form', workflow_get_name($wid), $choices);
}
return '';
// not allowed to view state
}
$result = db_query("SELECT sid, state FROM {workflow_states} WHERE status = 1 ORDER BY sid");
while ($row = db_fetch_object($result)) {
$workflow_states[$row->sid] = check_plain(t($row->state));
}
$sid_current = workflow_node_current_state($node);
require_once drupal_get_path('module', 'workflow') . '/workflow.pages.inc';
$output = drupal_get_form('workflow_tab_form_nid_' . $node->nid, $node, $wid, $workflow_states, $sid_current);
return $output;
}