function workflow_cleanup_form in Workflow 7
Same name and namespace in other branches
- 7.2 workflow_cleanup/workflow_cleanup.pages.inc \workflow_cleanup_form()
The main cleanup page.
1 string reference to 'workflow_cleanup_form'
- workflow_cleanup_menu in workflow_cleanup/
workflow_cleanup.module - Implements hook_menu().
File
- workflow_cleanup/
workflow_cleanup.module, line 56 - Cleans up Workflow cruft that may build up over time.
Code
function workflow_cleanup_form($form, $form_state) {
$bc = array(
l(t('Home'), '<front>'),
);
$bc[] = l(t('Configuration'), 'admin/config');
$bc[] = l(t('Workflow'), 'admin/config/workflow');
$bc[] = l(t('Workflow'), 'admin/config/workflow/workflow');
drupal_set_breadcrumb($bc);
$form = array();
// Get all of the states, indexed by sid.
$states = $orphans = $inactive = array();
foreach ($states = WorkflowState::getStates() as $state) {
// Does the associated workflow exist?
if (!$state
->getWorkflow()) {
$orphans[$state->sid] = $state
->getName();
}
else {
// Is the state still active?
if (!$state
->isActive()) {
$inactive[$state->sid] = $state
->getName();
}
}
}
// Deal with no orphan states.
if (!$orphans) {
$orphans[0] = t('None');
}
// Deal with no inactive states.
if (!$inactive) {
$inactive[0] = $states[0] = t('None');
}
$form['#workflow_states'] = $states;
$form['no_workflow'] = array(
'#type' => 'container',
'#title' => t('Orphaned States'),
'#description' => t('These states no longer belong to an existing workflow.'),
'#tree' => TRUE,
);
foreach ($orphans as $sid => $name) {
$form['no_workflow'][$sid]['check'] = array(
'#type' => 'checkbox',
'#return_value' => $sid,
);
$form['no_workflow'][$sid]['name'] = array(
'#type' => 'markup',
'#markup' => check_plain($name),
);
}
$form['inactive'] = array(
'#type' => 'container',
'#title' => t('Inactive (Deleted) States'),
'#description' => t('These states belong to a workflow, but have been marked inactive (deleted).'),
'#tree' => TRUE,
);
foreach ($inactive as $sid => $name) {
$form['inactive'][$sid]['check'] = array(
'#type' => 'checkbox',
'#return_value' => $sid,
);
$form['inactive'][$sid]['name'] = array(
'#type' => 'markup',
'#markup' => check_plain($name),
);
$form['inactive'][$sid]['wf'] = array(
'#type' => 'markup',
'#markup' => !empty($sid) ? check_plain($states[$sid]
->getName()) : '',
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Delete selected states'),
);
return $form;
}