function workflow_admin_ui_transitions_form_validate in Workflow 7.2
Same name and namespace in other branches
- 7 workflow_admin_ui/workflow_admin_ui.pages.inc \workflow_admin_ui_transitions_form_validate()
Validate the workflow editing form.
See also
workflow_edit_form()
File
- workflow_admin_ui/
workflow_admin_ui.page.transitions.inc, line 160 - Provides an Admin UI page for the Workflow Transitions.
Code
function workflow_admin_ui_transitions_form_validate($form, $form_state) {
$workflow = $form_state['values']['workflow'];
$wid = $workflow->wid;
// Make sure 'author' is checked for (creation) -> [something].
$creation_state = $workflow
->getCreationState();
$creation_sid = $creation_state->sid;
if (isset($form_state['values']['transitions'][$creation_sid]) && is_array($form_state['values']['transitions'][$creation_sid])) {
foreach ($form_state['values']['transitions'][$creation_sid] as $roles) {
if ($roles[WORKFLOW_ROLE_AUTHOR_RID]) {
$author_has_permission = TRUE;
break;
}
}
}
$state_count = db_query('SELECT COUNT(sid) FROM {workflow_states} WHERE wid = :wid', array(
':wid' => $wid,
))
->fetchField();
if (empty($author_has_permission) && $state_count > 1) {
form_set_error('transitions', t('Please give the author permission to go from %creation to at least one state!', array(
'%creation' => $creation_state
->label(),
)));
}
}