You are here

function workflow_revert_form in Workflow 7

Same name and namespace in other branches
  1. 7.2 workflow_revert/workflow_revert.pages.inc \workflow_revert_form()

Menu callback to do the revert function.

1 string reference to 'workflow_revert_form'
workflow_revert_menu in workflow_revert/workflow_revert.module
Implements hook_menu().

File

workflow_revert/workflow_revert.module, line 39
Adds an 'Revert' link to the first workflow history row.

Code

function workflow_revert_form($form, $form_state, $nid = NULL, $sid = NULL) {
  if (drupal_valid_token($_GET['token'], 'workflow_revert ' . $sid)) {
    $state = WorkflowState::load($sid);
    $entity_type = 'node';
    $node = node_load($nid);
    $args['#sid'] = $sid;
    $args['#nid'] = $nid;
    $args['#node'] = $node;
    $question = t('Are you sure you want to revert %title to the "@state" state?', array(
      '@state' => $state
        ->label(),
      '%title' => $node->title,
    ));
    return confirm_form($args, $question, "node/{$nid}", t('The workflow state will be changed.'));
  }
  else {
    watchdog('workflow_revert', 'Invalid token', array(), WATCHDOG_ERROR);
    drupal_set_message(t('Invalid token. Your information has been recorded.'), 'error');
    drupal_goto("node/{$nid}");
  }
}