function workflow_extensions_change_state_form in Workflow Extensions 7
Same name and namespace in other branches
- 6 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()
- workflow_extensions_block_view in ./
workflow_extensions.module - Implements hook_block_view().
- workflow_extensions_handler_field_state_change_form::render in views/
workflow_extensions_handler_field_state_change_form.inc - Render the field.
File
- ./
workflow_extensions.module, line 440 - UI-related improvements to the Workflow module and tokens for Rules.
Code
function workflow_extensions_change_state_form($node) {
if (empty($node)) {
return '';
}
$workflow_type = workflow_get_workflow_type_map_by_type($node->type);
if (empty($workflow_type)) {
return '';
}
$wid = $workflow_type->wid;
$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
$workflow = workflow_get_workflows_by_wid($wid);
return drupal_get_form('workflow_extensions_single_state_form', $workflow->name, $choices);
}
return '';
// not allowed to view workflow state
}
$result = db_query("SELECT sid, state FROM {workflow_states} WHERE status = :status ORDER BY sid", array(
':status' => 1,
));
while ($row = $result
->fetchObject()) {
$workflow_states[$row->sid] = check_plain(t($row->state));
}
$sid_current = workflow_node_current_state($node);
@(include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'workflow') . '/workflow.pages.inc');
$form = drupal_get_form('workflow_tab_form_nid_' . $node->nid, $node, $wid, $workflow_states, $sid_current);
return $form;
}