function workflow_get_workflow_state_names in Workflow 7.2
Same name and namespace in other branches
- 8 workflow.module \workflow_get_workflow_state_names()
Get an options list for workflow states (to show in a widget).
To be used in non-OO modules, like workflow_rules.
Parameters
mixed $wid: The Workflow ID.
bool $grouped: Indicates if the value must be grouped per workflow. This influence the rendering of the select_list options.
bool $all: Indicates to return all (TRUE) or active (FALSE) states of a workflow.
Return value
array $options An array of $sid => state->label(), grouped per Workflow.
7 calls to workflow_get_workflow_state_names()
- workflowfield_i18n_field_translate_allowed_values in workflow_field/
workflowfield.field.inc - Returns the array of translated allowed values for a workflow (list) field.
- WorkflowItem::getAllowedValues in includes/
Field/ WorkflowItem.php - Helper function for list.module formatter.
- WorkflowTransitionForm::buildForm in includes/
Form/ WorkflowTransitionForm.php - _state
- workflow_admin_ui_states_form in workflow_admin_ui/
workflow_admin_ui.page.states.inc - Menu callback.
- workflow_get_workflow_states_all in ./
workflow.deprecated.inc - Get all active states in the system.
File
- ./
workflow.module, line 609 - Support workflows made up of arbitrary states.
Code
function workflow_get_workflow_state_names($wid = 0, $grouped = FALSE, $all = FALSE) {
$options = array();
// Get the (user-dependent) options.
// Since this function is only used in UI, it is save to use the global $user.
global $user;
/* @var $workflows Workflow[] */
$workflows = workflow_load_multiple($wid ? array(
$wid,
) : FALSE);
// Do not group if only 1 Workflow is configured or selected.
$grouped = count($workflows) == 1 ? FALSE : $grouped;
foreach ($workflows as $workflow) {
$state = new WorkflowState(array(
'wid' => $workflow->wid,
));
$workflow_options = $state
->getOptions('', NULL, '', $user, FALSE);
if (!$grouped) {
$options += $workflow_options;
}
else {
// Make a group for each Workflow.
$options[$workflow
->label()] = $workflow_options;
}
}
return $options;
}