function disable_messages_settings_form_validate in Disable Messages 6
Same name and namespace in other branches
- 7 disable_messages.module \disable_messages_settings_form_validate()
Validation function for disable_messages_settings_form.
File
- ./
disable_messages.module, line 280
Code
function disable_messages_settings_form_validate($form, &$form_state) {
global $_disable_messages_error, $_disable_messages_error_no;
$patterns = explode("\n", $form_state['values']['disable_messages_ignore_patterns']);
// Override drupal error handler to handle the preg error here
set_error_handler('_disable_messages_error_handler');
foreach ($patterns as $pattern) {
$pattern = preg_replace(array(
'/^\\s*/',
'/\\s*$/',
), '', $pattern);
try {
preg_match('/' . $pattern . '/', "This is a test string");
} catch (Exception $e) {
}
if ($_disable_messages_error) {
form_set_error('disable_messages_ignore_patterns', t('"@pattern" is not a valid regular expression. Preg error (@error_no) - @error', array(
'@pattern' => $pattern,
'@error_no' => $_disable_messages_error_no,
'@error' => $_disable_messages_error,
)));
restore_error_handler();
return;
}
}
}