You are here

function privatemsg_list_submit in Privatemsg 6

Same name and namespace in other branches
  1. 6.2 privatemsg.pages.inc \privatemsg_list_submit()
  2. 7.2 privatemsg.pages.inc \privatemsg_list_submit()
  3. 7 privatemsg.pages.inc \privatemsg_list_submit()

Process privatemsg_list form submissions.

Execute the chosen action on the selected messages. This function is based on node_admin_nodes_submit().

1 string reference to 'privatemsg_list_submit'
_privatemsg_action_form in ./privatemsg.module
Returns a form which handles and displays thread actions.

File

./privatemsg.module, line 2372
Allows users to send private messages to other users.

Code

function privatemsg_list_submit($form, &$form_state) {

  // Load all available operation definitions.
  $operations = module_invoke_all('privatemsg_thread_operations');

  // Default "default" operation, which won't do anything.
  $operation = array(
    'callback' => 0,
  );

  // Check if a valid operation has been submitted.
  if (isset($form_state['values']['operation']) && isset($operations[$form_state['values']['operation']])) {
    $operation = $operations[$form_state['values']['operation']];
  }

  // Load all keys where the value is the current op.
  $keys = array_keys($form_state['values'], $form_state['values']['op']);

  // The first one is op itself, we need to use the second.
  if (isset($keys[1]) && isset($operations[$keys[1]])) {
    $operation = $operations[$keys[1]];
  }

  // Only execute something if we have a valid callback and at least one checked thread.
  if (!empty($operation['callback'])) {
    privatemsg_operation_execute($operation, $form_state['values']['threads'], $form_state['values']['account']);
  }
}