You are here

function workflow_revert_form in Workflow 7.2

Same name and namespace in other branches
  1. 7 workflow_revert/workflow_revert.module \workflow_revert_form()

Menu callback to do the revert function.

@todo: add support for Field in workflow_revert.

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

File

workflow_revert/workflow_revert.pages.inc, line 12
Contains 'workflow_revert' page.

Code

function workflow_revert_form($form, &$form_state, $entity_type, $id, $field_name, $previous_sid = NULL) {
  $entity = entity_load_single($entity_type, $id);
  $uri = entity_uri($entity_type, $entity);
  $return_uri = $uri['path'] . '/workflow';
  if (drupal_valid_token($_GET['token'], 'workflow_revert ' . $previous_sid)) {
    $state = workflow_state_load_single($previous_sid);
    $args['#previous_sid'] = $previous_sid;
    $args['#entity_id'] = $id;
    $args['#entity'] = $entity;
    $args['#entity_type'] = $entity_type;
    $args['#field_name'] = $field_name;
    $question = t('Are you sure you want to revert %title to the "@state" state?', array(
      '@state' => $state
        ->label(),
      '%title' => entity_label($entity_type, $entity),
    ));
    return confirm_form($args, $question, $return_uri, 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($return_uri);
  }
}