You are here

function privatemsg_undo_action in Privatemsg 7.2

Same name and namespace in other branches
  1. 6.2 privatemsg.pages.inc \privatemsg_undo_action()
  2. 6 privatemsg.module \privatemsg_undo_action()
  3. 7 privatemsg.pages.inc \privatemsg_undo_action()

Menu callback for messages/undo/action.

This function will test if an undo callback is stored in SESSION and execute it.

1 string reference to 'privatemsg_undo_action'
privatemsg_menu in ./privatemsg.module
Implements hook_menu().

File

./privatemsg.pages.inc, line 741
User menu callbacks for Privatemsg.

Code

function privatemsg_undo_action() {

  // Check if a undo callback for that user exists.
  if (isset($_SESSION['privatemsg']['undo callback']) && is_array($_SESSION['privatemsg']['undo callback'])) {
    $undo = $_SESSION['privatemsg']['undo callback'];

    // If the defined undo callback exists, execute it
    if (isset($undo['function']) && isset($undo['args'])) {

      // Load the user object.
      if (isset($undo['args']['account']) && $undo['args']['account'] > 0) {
        $undo['args']['account'] = user_load((int) $undo['args']['account']);
      }
      call_user_func_array($undo['function'], $undo['args']);
    }
  }

  // Return back to the site defined by the destination GET param.
  drupal_goto();
}