function spam_filter_custom_admin_settings in Spam 6
Adminsitrative interface for configuring custom spam filter rules.
1 string reference to 'spam_filter_custom_admin_settings'
- spam_filter_custom_menu in filters/
spam_filter_custom/ spam_filter_custom.module - Drupal _menu() hook.
File
- filters/
spam_filter_custom/ spam_filter_custom.module, line 105 - Custom spam filter module Copyright(c) 2007-2009 Jeremy Andrews <jeremy@tag1consulting.com>.
Code
function spam_filter_custom_admin_settings() {
$form = array();
$form['options'] = array(
'#type' => 'fieldset',
'#title' => t('Options'),
'#prefix' => '<div class="container-inline">',
'#suffix' => '</div>',
);
$options = array();
foreach (module_invoke_all('spam_filter_custom_operations') as $operation => $op) {
$options[$operation] = $op['label'];
}
$form['options']['operation'] = array(
'#type' => 'select',
'#options' => $options,
'#default_value' => 'scan',
);
$form['options']['submit'] = array(
'#type' => 'submit',
'#value' => t('Execute'),
);
$rows = array();
$result = pager_query('SELECT * FROM {spam_filter_custom} ORDER BY weight ASC');
while ($spam_filter_custom = db_fetch_object($result)) {
$all[$spam_filter_custom->cid] = '';
// The filter text.
$form['filter'][$spam_filter_custom->cid] = array(
'#value' => $spam_filter_custom->filter,
);
// What style of filter.
if ($spam_filter_custom->style == SPAM_FILTER_CUSTOM_STYLE_PLAIN) {
$form['style'][$spam_filter_custom->cid] = array(
'#value' => t('Plain text'),
);
}
else {
if ($spam_filter_custom->style == SPAM_FILTER_CUSTOM_STYLE_REGEX) {
$form['style'][$spam_filter_custom->cid] = array(
'#value' => t('Regular expression'),
);
}
}
// What to scan.
$scan = array();
if ($spam_filter_custom->scan & SPAM_FILTER_CUSTOM_SCAN_CONTENT) {
$scan[] = t('Content');
}
if ($spam_filter_custom->scan & SPAM_FILTER_CUSTOM_SCAN_REFERRER) {
$scan[] = t('Referrer');
}
if ($spam_filter_custom->scan & SPAM_FILTER_CUSTOM_SCAN_USERAGENT) {
$scan[] = t('User agent');
}
$form['scan'][$spam_filter_custom->cid] = array(
'#value' => implode(', ', $scan),
);
// What status to apply.
switch ($spam_filter_custom->status) {
case SPAM_FILTER_CUSTOM_STATUS_NOTSPAM:
$status = t('Mark as not spam');
break;
case SPAM_FILTER_CUSTOM_STATUS_PROBABLYNOT:
$status = t('Mark as probably not spam');
break;
case SPAM_FILTER_CUSTOM_STATUS_DISABLED:
$status = t('Disabled');
break;
case SPAM_FILTER_CUSTOM_STATUS_PROBABLY:
$status = t('Mark as probably spam');
break;
case SPAM_FILTER_CUSTOM_STATUS_SPAM:
$status = t('Mark as spam');
break;
default:
$status = t('Unknown');
break;
}
$form['status'][$spam_filter_custom->cid] = array(
'#value' => $status,
);
// How many times this filter has been matched.
$form['matches'][$spam_filter_custom->cid] = array(
'#value' => $spam_filter_custom->matches,
);
// The last time this filter was matched.
$last = $spam_filter_custom->last ? t('@time ago', array(
'@time' => format_interval(time() - $spam_filter_custom->last),
)) : t('Never');
$form['last'][$spam_filter_custom->cid] = array(
'#value' => $last,
);
// Link to edit the filter.
$form['edit'][$spam_filter_custom->cid] = array(
'#value' => l(t('edit'), "admin/settings/spam/filters/custom/{$spam_filter_custom->cid}/edit"),
);
$rows[] = $row;
}
$form['create2'] = array(
'#value' => '[' . l(t('create custom filter'), 'admin/settings/spam/filters/custom/create') . ']',
'#prefix' => '<div class="container-inline">',
'#suffix' => '</div>',
);
$form['spam_filter_custom'] = array(
'#type' => 'checkboxes',
'#options' => $all,
);
$form['pager'] = array(
'#value' => theme('pager', NULL, 50, 0),
);
return $form;
}