function spam_filter_custom_admin_filter_validate in Spam 6
Be sure that the custom filter is valid.
File
- filters/
spam_filter_custom/ spam_filter_custom.module, line 379 - Custom spam filter module Copyright(c) 2007-2009 Jeremy Andrews <jeremy@tag1consulting.com>.
Code
function spam_filter_custom_admin_filter_validate($form, &$form_state) {
if ($form_state['values']['style'] == SPAM_FILTER_CUSTOM_STYLE_REGEX) {
if (preg_match($form_state['values']['filter'], 'test') === FALSE) {
form_set_error('filter', t('Failed to validate your filter\'s regular expression. It must be properly formatted as a <a href="http://www.php.net/manual/en/ref.pcre.php">Perl-compatible regular expression</a>. Review the above error for details on the specific problem with your expression.'));
}
}
if (isset($form_state['values']['cid'])) {
// update
$cid = db_result(db_query("SELECT cid FROM {spam_filter_custom} WHERE filter = '%s' AND cid <> %d", $form_state['values']['filter'], $form_state['values']['cid']));
if ($cid) {
form_set_error($cid, t('Custom filter %filter already exists', array(
'%filter' => $form_state['values']['filter'],
)));
}
}
else {
// create
$cid = db_result(db_query("SELECT cid FROM {spam_filter_custom} WHERE filter = '%s'", $form_state['values']['filter']));
if ($cid) {
form_set_error($cid, t('Custom filter %filter already exists', array(
'%filter' => $form_state['values']['filter'],
)));
}
}
}