function simplenews_node_tab_send_form_validate in Simplenews 7.2
Same name and namespace in other branches
- 6.2 simplenews.module \simplenews_node_tab_send_form_validate()
- 7 includes/simplenews.admin.inc \simplenews_node_tab_send_form_validate()
@todo
File
- includes/
simplenews.admin.inc, line 1929 - Newsletter admin, subscription admin, simplenews settings
Code
function simplenews_node_tab_send_form_validate($form, &$form_state) {
$values = $form_state['values'];
$node = node_load($values['nid']);
// Validate recipient handler settings.
if (!empty($form['simplenews']['recipient_handler_settings'])) {
ctools_include('plugins');
$handler = $values['simplenews']['recipient_handler'];
$handler = ctools_get_plugins('simplenews', 'recipient_handlers', $handler);
$class = $handler['class'];
if (method_exists($class, 'settingsFormValidate')) {
$class::settingsFormValidate($form['simplenews']['recipient_handler_settings'], $form_state);
}
}
$default_address = variable_get('simplenews_test_address', variable_get('site_mail', ini_get('sendmail_from')));
$mails = array(
$default_address,
);
if (isset($values['simplenews']['send']) && $values['simplenews']['send'] == SIMPLENEWS_COMMAND_SEND_TEST && variable_get('simplenews_test_address_override', 0)) {
// @todo Can we simplify and use only two kind of messages?
if (!empty($values['simplenews']['test_address'])) {
$mails = explode(',', $values['simplenews']['test_address']);
foreach ($mails as $mail) {
$mail = trim($mail);
if ($mail == '') {
form_set_error('simplenews][test_address', t('Test email address is empty.'));
}
elseif (!valid_email_address($mail)) {
form_set_error('simplenews][test_address', t('Invalid email address "%mail".', array(
'%mail' => $mail,
)));
}
}
}
else {
form_set_error('simplenews][test_address', t('Missing test email address.'));
}
}
$form_state['test_addresses'] = $mails;
}