function privatemsg_new_form_submit in Privatemsg 5.3
Same name and namespace in other branches
- 5 privatemsg.module \privatemsg_new_form_submit()
File
- ./
privatemsg.module, line 1568
Code
function privatemsg_new_form_submit($form_id, $form_values) {
global $user;
static $seen = array();
if ($form_values['op'] != t('Send private message')) {
return FALSE;
}
$recipients = explode(',', $form_values['recipient']);
$sent = FALSE;
foreach ($recipients as $recipient) {
$recipient = trim($recipient);
if (isset($seen[$recipient])) {
continue;
}
$seen[$recipient] = TRUE;
$recipient = user_load(array(
'name' => $recipient,
));
$message_id = _privatemsg_send($user, $recipient, $form_values['subject'], $form_values['privatemsgbody'], $form_values['format'], $form_values['thread']);
if ($message_id) {
// Load the message for consistency.
$message = privatemsg_load($message_id);
// Tell the other modules a new private message has been sent.
privatemsg_invoke_privatemsg($message, 'sent');
$sent = TRUE;
}
}
if ($sent) {
drupal_set_message(t('Message sent.'));
}
drupal_goto($user->uid ? 'privatemsg' : '');
}