You are here

function theme_workflow_edit_form in Workflow 5

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

File

./workflow.module, line 813

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) {
      if ($name != t('(creation)')) {

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

          // don't allow transition TO (creation)
        }
        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]);

            //$cell .= drupal_render($form['transitions']["transitions][$from][$to][$rid"]);
          }
          $row[] = array(
            'data' => $cell,
          );
        }
        else {
          $row[] = array(
            'data' => '',
          );
        }
      }
      $rows[] = $row;
    }
    $output .= theme('table', $header, $rows);
  }
  else {
    $output = 'There are no states defined for this workflow.';
  }
  $output .= drupal_render($form);
  return $output;
}