You are here

function workflow_actions_page in Workflow 5

1 string reference to 'workflow_actions_page'
workflow_menu in ./workflow.module
Implementation of hook_menu().

File

./workflow.module, line 1332

Code

function workflow_actions_page($wid) {
  if (!module_exists('actions')) {
    drupal_set_message(t('Before you can assign actions you must install and enable the actions module.'), 'error');
    drupal_goto('admin/build/workflow');
  }
  $options = array(
    t('None'),
  );
  foreach (actions_actions_map(actions_get_all_actions()) as $aid => $action) {
    $options[$action['type']][$aid] = $action['description'];
  }
  $header = array(
    array(
      'data' => t('Transition'),
      'colspan' => '3',
    ),
    array(
      'data' => t('Actions'),
    ),
  );
  $rows = array();
  $states = workflow_get_states($wid);
  foreach ($states as $sid => $state) {

    // we'll create a row for each allowable transition
    $allowable_to = workflow_allowable_transitions($sid);
    foreach ($allowable_to as $to_sid => $name) {

      // Don't allow actions on same state transaction... Should we allow it?
      if ($to_sid == $sid) {
        continue;
      }
      $tid = workflow_get_transition_id($sid, $to_sid);
      $rows[] = array(
        array(
          'data' => $state,
        ),
        array(
          'data' => WORKFLOW_ARROW,
        ),
        array(
          'data' => $name,
        ),
        array(
          'data' => drupal_get_form('workflow_actions_form', $wid, $tid, $options),
        ),
      );
    }
  }
  if (count($rows) == 0) {
    $output = t('You must first <a href="@link">set up transitions</a> before you can assign actions.', array(
      '@link' => url('admin/build/workflow/edit/' . $wid),
    ));
  }
  else {
    $output = theme('table', $header, $rows);
  }
  return $output;
}