function privatemsg_new_form_validate in Privatemsg 5
Same name and namespace in other branches
- 5.3 privatemsg.module \privatemsg_new_form_validate()
File
- ./
privatemsg.module, line 1564
Code
function privatemsg_new_form_validate($form_id, $form_values) {
if (!empty($form_values['recipient'])) {
$recipients = explode(',', $form_values['recipient']);
foreach ($recipients as $recipient) {
$account = user_load(array(
'name' => trim($recipient),
));
if (!$account) {
form_set_error('recipient', t('The recipient %name does not exist.', array(
'%name' => $recipient,
)));
}
else {
if (!$account->status || !$account->privatemsg_allow) {
form_set_error('recipient', t('%name does not accept private messages.', array(
'%name' => $account->name,
)));
}
}
}
}
if (!isset($form_values['format']) || !filter_access($form_values['format'])) {
form_set_error('format', t('The supplied input format is invalid.'));
}
if (empty($form_values['privatemsgbody'])) {
form_set_error('privatemsgbody', t('Message field is required.'));
}
}