You are here

function theme_workflow_edit_form in Workflow 5.2

Same name and namespace in other branches
  1. 5 workflow.module \theme_workflow_edit_form()

File

./workflow.module, line 1049

Code

function theme_workflow_edit_form($form) {
  $output = drupal_render($form['wf_name']);
  $wid = $form['wid']['#value'];
  $states = workflow_get_states($wid);
  drupal_set_title(t('Edit workflow %name', array(
    '%name' => workflow_get_name($wid),
  )));
  if ($states) {
    $roles = workflow_get_roles();
    $header = array(
      array(
        'data' => t('From / To ') . ' ' . WORKFLOW_ARROW,
      ),
    );
    $rows = array();
    foreach ($states as $state_id => $name) {

      // Don't allow transition TO (creation).
      if ($name != t('(creation)')) {
        $header[] = array(
          'data' => t($name),
        );
      }
      $row = array(
        array(
          'data' => $name,
        ),
      );
      foreach ($states as $nested_state_id => $nested_name) {
        if ($nested_name == t('(creation)')) {

          // Don't allow transition TO (creation).
          continue;
        }
        if ($nested_state_id != $state_id) {

          // Need to render checkboxes for transition from $state to $nested_state.
          $from = $state_id;
          $to = $nested_state_id;
          $cell = '';
          foreach ($roles as $rid => $role_name) {
            $cell .= drupal_render($form['transitions'][$from][$to][$rid]);
          }
          $row[] = array(
            'data' => $cell,
          );
        }
        else {
          $row[] = array(
            'data' => '',
          );
        }
      }
      $rows[] = $row;
    }
    $output .= theme('table', $header, $rows);
  }
  else {
    $output = t('There are no states defined for this workflow.');
  }
  $output .= drupal_render($form);
  return $output;
}