You are here

function privatemsg_forward_form_validate in Privatemsg 6.2

Validate function for forward form.

1 string reference to 'privatemsg_forward_form_validate'
privatemsg_forward_form_privatemsg_form_reply_alter in privatemsg_forward/privatemsg_forward.module
Implements hook_form_FORM_ID_alter().

File

privatemsg_forward/privatemsg_forward.module, line 73
Module file for privatemsg_forward.module.

Code

function privatemsg_forward_form_validate($form, &$form_state) {
  global $user;

  // Parse user string.
  list($new_recipients, $invalid) = _privatemsg_parse_userstring($form_state['values']['to']);

  // Display invalid names.
  if (!empty($invalid)) {
    drupal_set_message(t('The following users will not receive this private message: @invalid.', array(
      '@invalid' => implode(', ', $invalid),
    )), 'error');
  }

  // Remove blocked participants.
  if (!empty($new_recipients)) {
    foreach (module_invoke_all('privatemsg_block_message', $user, $new_recipients) as $blocked) {
      unset($new_recipients[$blocked['recipient']]);
      drupal_set_message($blocked['message'], 'warning');
    }
  }
  $form_state['new_recipients'] = $new_recipients;
}