--- spam\spam.module 2007-09-07 10:49:46.000000000 -0400 +++ spam.module 2007-09-08 14:24:22.984375000 -0400 @@ -1,4 +1,5 @@ '. t('Spam Settings') .''; + $output .= '

'. t('The settings for this module are separated by function with each group of settings represented in the tabs above.') .'

'; +// $output .= '

'. t('') .'

'; +// $output .= '

'. t('') .'

'; + + $tabhdr = array(t('Tab'), t('Description')); + + $tabs = spam_invoke_hook('tab_description'); + $x = ksort($tabs, SORT_REGULAR); + + $rows = array(); + foreach ($tabs as $key => $value) { + $rows[] = array($key, $value); + } + $output .= theme('table', $tabhdr, $rows); + + $output .= '

 

'; + $output .= '

'. t('Note') .': '. t('As with all multi-page settings forms, you must use the "Save configuration" button on each page.') .'

'; + return $output; +} + +function spam_admin_settings_filter() { // general settings $form['filter'] = array( '#type' => 'fieldset', '#title' => 'Filter', ); + $form['filter']['spam_filter_comments'] = array( '#type' => 'checkbox', '#title' => t('Filter comments'), @@ -271,6 +295,7 @@ function spam_admin_settings() { '#default_value' => variable_get('spam_filter_comments', 1), '#description' => t('Enable this option to filter new comments as they are posted, determining whether or not they are spam.'), ); + $node_types = node_get_types(); foreach ($node_types as $type => $properties) { $form['filter']["spam_filter_$type"] = array( @@ -281,6 +306,7 @@ function spam_admin_settings() { '#description' => t("Enable this option to filter new $name content as it is posted, determining whether or not it is spam."), ); } + $form['filter']['spam_filter_urls'] = array( '#type' => 'checkbox', '#title' => t('Filter spam URLs'), @@ -288,17 +314,23 @@ function spam_admin_settings() { '#default_value' => variable_get('spam_filter_urls', 1), '#description' => t('Enabling this option will tell the spam filter to treat URLs embedded within comments and other contents as a special case. When URLs that were found within known spam are found in new content, the new content is automatically considered to be spam. When this option is enabled, a single spam URL found within an otherwise spam-free posting will cause the filter to mark the new content as spam.'), ); + // provide hook for external modules to define custom filter types $hook = spam_invoke_hook('filter_settings'); if ($hook['group']) { $form['filter'] = array_merge($form['filter'], $hook['group']); } + return system_settings_form($form); + +} +function spam_admin_settings_limits() { // limits $form['limits'] = array( '#type' => 'fieldset', '#title' => 'Limits', ); + $limits = array(0 => 'unlimited', 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 15 => 15, 20 => 20, 50 => 50, 100 => 100); $form['limits']['spam_urls_total'] = array( '#type' => 'select', @@ -307,6 +339,7 @@ function spam_admin_settings() { '#options' => $limits, '#description' => t('Specificy the maximum number of URLs that are allowed in a single posting before it is considered to be spam. For example, if you select 5 from the pop down menu, and then a posting to your site has 6 weblinks, the posting will be marked as spam. Some form of filtering must be enabled above for this to have any affect.'), ); + $form['limits']['spam_urls_repeat'] = array( '#type' => 'select', '#title' => t('Maximum repeat URLs'), @@ -314,6 +347,7 @@ function spam_admin_settings() { '#options' => $limits, '#description' => t('Specificy the maximum number of times that the same URL is allowed to appear in a single posting before it is considered to be spam. For example, if you select 5 from the pop down menu, and then a posting has 6 weblinks to the same exact location, the posting will be marked as spam. Some form of filtering must be enabled above for this to have any affect.'), ); + $form['limits']['spam_duplicate_content'] = array( '#type' => 'select', '#title' => t('Maximum duplicate content'), @@ -321,6 +355,7 @@ function spam_admin_settings() { '#options' => $limits, '#description' => t('Specify the maximum number of times the same identical posting will be allowed to your site before all of the duplicate postings are considered spam. Some times a user may accidently hit "submit" multiple times, causing an otherwise acceptible posting to be duplicated. However, other times a spammer may repeatedly post the same spam content to your site.'), ); + $form['limits']['spam_blacklist_ip'] = array( '#type' => 'select', '#title' => t('Detected spam postings before blacklisting IP'), @@ -328,12 +363,16 @@ function spam_admin_settings() { '#options' => $limits, '#description' => t('Select the number of times a single IP address needs to be detected posting probable spam before the IP is blacklisted. If enabled, future attempts to post any content will cause a 25 second delay, after which the user will be redirected to the site\'s front page where they will receive notification that their IP address is currently blacklisted. It is advisable that you configure your site to require all content be previewed if you wish to use this functionality, as that will allow the filter to blacklist a user before the content is posted, minimizing database overhead. If you configure spam to automatically expire, the IP will only be blacklisted until the previous spam from that IP expires. A blacklisted IP is only prevented from posting new content, they are still allowed to view existing content.'), ); + return system_settings_form($form); +} +function spam_admin_settings_actions() { // actions $form['actions'] = array( '#type' => 'fieldset', '#title' => 'Actions', ); + $form['actions']['spam_unpublish'] = array( '#type' => 'checkbox', '#title' => t('Unpublish spam'), @@ -341,6 +380,7 @@ function spam_admin_settings() { '#default_value' => variable_get('spam_unpublish', 1), '#description' => t('When checked, any new content that is detected as spam will be automatically unpublished. This will prevent the content from being displayed, allowing a site administrator a chance to first review it.'), ); + $form['actions']['spam_notify_user'] = array( '#type' => 'checkbox', '#title' => t('Notify user'), @@ -348,6 +388,7 @@ function spam_admin_settings() { '#default_value' => variable_get('spam_notify_user', 1), '#description' => t('If both the above "Unpublish spam" box and this box are checked, users will be notified with a message when the content they post is blocked by the spam filter. This is intended to minimize confusion when the spam filter mistakes a valid posting as spam and the posting doesn\'t immediately apear to the user.'), ); + $form['actions']['spam_notify_admin'] = array( '#type' => 'checkbox', '#title' => t('Email notification'), @@ -355,8 +396,10 @@ function spam_admin_settings() { '#default_value' => variable_get('spam_notify_admin', 1), '#description' => t('Enabling this option will cause an email to be sent to the site administrator whenever the filters detect spam content.'), ); + $period = drupal_map_assoc(array(0, 3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800, 31536000), 'format_interval'); $period[0] = t('never'); + $form['actions']['spam_expire_time'] = array( '#type' => 'select', '#title' => t('Expire spam after'), @@ -364,17 +407,22 @@ function spam_admin_settings() { '#options' => $period, '#description' => t('Content that is marked as spam for more than the selected amount of time will be automatically and permanently deleted. Requires crontab.'), ); + // provide hook for external modules to define actions $updated = spam_invoke_hook('action_settings'); if ($updated['group']) { $form['actions'] = array_merge($form['actions'], $updated['group']); } + return system_settings_form($form); +} +function spam_admin_settings_advanced() { // advanced settings $form['advanced'] = array( '#type' => 'fieldset', '#title' => 'Advanced', ); + $form['advanced']['spam_log_level'] = array( '#type' => 'radios', '#title' => t('Log'), @@ -382,6 +430,10 @@ function spam_admin_settings() { '#options' => array(0 => t('nothing'), SPAM_LOG => t('major events'), SPAM_VERBOSE => t('major and minor events'), SPAM_DEBUG => t('everything')), '#description' => t('By default, the spam module will only log major events. If you are trying to figure out why the spam filter is marking content as spam or not spam, you may want to try logging everything. If you\'re concerned about performance, you may want to disable logging completely.'), ); + + $period = drupal_map_assoc(array(0, 3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800, 31536000), 'format_interval'); + $period[0] = t('never'); + $form['advanced']['spam_flush_log_timer'] = array( '#type' => 'select', '#title' => t('Discard spam logs older than'), @@ -389,6 +441,7 @@ function spam_admin_settings() { '#options' => $period, '#description' => t('Older spam log entries will be automatically discarded. Requires crontab.'), ); + $form['advanced']['spam_display_probability'] = array( '#type' => 'checkbox', '#title' => t('Display probability'), @@ -396,6 +449,7 @@ function spam_admin_settings() { '#default_value' => variable_get('spam_display_probability', 0), '#description' => t('If enabled, the probability that a given piece of content is spam will be displayed by the content. This is useful while you are tuning your spam filter, and will provide a link to the relevant logs showing how that content was determined to be or not to be spam.'), ); + $form['advanced']['spam_report_feedback'] = array( '#type' => 'checkbox', '#title' => t('Require feedback when reporting spam'), @@ -403,6 +457,7 @@ function spam_admin_settings() { '#default_value' => variable_get('spam_report_feedback', TRUE), '#description' => t('If checked, users that are able to report content as spam will be required to leave feedback when reporting spam. If unchecked, users will not be prompted to leave feedback.'), ); + /* If you feel you need to display more than 50 spam comments or spam nodes * at a time, uncomment the following two lines of code. For most people * this will be unnecessary, and potentially confusing, so by default I am @@ -423,9 +478,8 @@ function spam_admin_settings() { $group .= $hook['group']; $form['advanced'] = array_merge($form['advanced'], $hook['group']); } - return system_settings_form($form); -} +} /** * Drupal _cron hook. Provides ability to automatically expired spam content. @@ -594,99 +648,178 @@ function spam_menu($may_cache) { if ($may_cache) { $items[] = array( - 'access' => user_access('administer spam'), - 'callback' => 'spam_logs_overview', + 'path' => 'admin/content/spam', + 'title' => t('Spam filters'), + 'access' => user_access('administer spam'), + 'callback' => 'spam_logs_overview', 'description' => t('Detect and manage spam posts.'), - 'path' => 'admin/content/spam', - 'title' => t('Spam filters'), ); + $items[] = array( - 'access' => user_access('access spam'), - 'callback' => 'spam_logs_overview', - 'path' => 'admin/content/spam/logs', - 'title' => t('Logs'), - 'type' => MENU_DEFAULT_LOCAL_TASK, - 'weight' => -10, + 'path' => 'admin/content/spam/logs', + 'title' => t('Logs'), + 'access' => user_access('access spam'), + 'callback' => 'spam_logs_overview', + 'type' => MENU_DEFAULT_LOCAL_TASK, + 'weight' => -10, ); + $items[] = array( - 'access' => user_access('access spam'), - 'callback' => 'spam_logs_entry', - 'path' => 'admin/content/spam/logs/entry', - 'type' => MENU_LOCAL_CALLBACK, + 'path' => 'admin/content/spam/logs/entry', + 'access' => user_access('access spam'), + 'callback' => 'spam_logs_entry', + 'type' => MENU_LOCAL_CALLBACK, ); + $items[] = array( - 'access' => user_access('administer spam'), - 'callback' => 'spam_custom_filter_overview', - 'path' => 'admin/content/spam/custom', - 'title' => t('Custom filters'), - 'type' => MENU_LOCAL_TASK, + 'path' => 'admin/content/spam/custom', + 'title' => t('Custom filters'), + 'access' => user_access('administer spam'), + 'callback' => 'spam_custom_filter_overview', + 'type' => MENU_LOCAL_TASK, ); + $items[] = array( - 'access' => user_access('administer spam'), - 'callback' => 'spam_url_filter_overview', - 'path' => 'admin/content/spam/url', - 'title' => t('URL filters'), - 'type' => MENU_LOCAL_TASK, + 'path' => 'admin/content/spam/url', + 'title' => t('URL filters'), + 'access' => user_access('administer spam'), + 'callback' => 'spam_url_filter_overview', + 'type' => MENU_LOCAL_TASK, ); + $items[] = array( - 'access' => user_access('administer spam'), - 'callback' => 'drupal_get_form', + 'path' => 'admin/content/comment/list/spam', + 'title' => t('Spam'), + 'access' => user_access('administer spam'), + 'callback' => 'drupal_get_form', 'callback arguments' => array('spam_comment_overview'), - 'path' => 'admin/content/comment/list/spam', - 'title' => t('Spam'), - 'type' => MENU_LOCAL_TASK, + 'type' => MENU_LOCAL_TASK, ); + + // Main module administration page $items[] = array( - 'access' => user_access('administer spam'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('spam_admin_settings'), - 'path' => 'admin/settings/spam', - 'title' => t('Spam'), + 'path' => 'admin/settings/spam', + 'title' => t('Spam'), + 'access' => user_access('administer spam'), +// 'callback' => 'drupal_get_form', +// 'callback arguments' => array('spam_admin_settings'), + 'callback' => 'spam_admin_settings', 'description' => t('Control settings for the spam module.'), +// 'type' => MENU_DEFAULT_LOCAL_TASK, + ); + + $items[] = array( + 'path' => 'admin/settings/spam/filter', + 'title' => t('Filters'), + 'access' => user_access('administer spam'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('spam_admin_settings_filter'), + 'description' => t('Select content type filters for the spam module.'), + 'weight' => 1, + 'type' => MENU_LOCAL_TASK, ); + $items[] = array( - 'access' => user_access('administer spam'), - 'callback' => 'spam_blocked_ips_overview', - 'path' => 'admin/content/spam/blockedips', - 'title' => t('Blocked IPs'), - 'type' => MENU_LOCAL_TASK, + 'path' => 'admin/settings/spam/limits', + 'title' => t('Limits'), + 'access' => user_access('administer spam'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('spam_admin_settings_limits'), + 'description' => t('Set filtering limits for the spam module.'), + 'weight' => 2, + 'type' => MENU_LOCAL_TASK, + ); + + $items[] = array( + 'path' => 'admin/settings/spam/actions', + 'title' => t('Actions'), + 'access' => user_access('administer spam'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('spam_admin_settings_actions'), + 'description' => t('Select actions for the spam module.'), + 'weight' => 3, + 'type' => MENU_LOCAL_TASK, + ); + + $items[] = array( + 'path' => 'admin/settings/spam/advanced', + 'title' => t('Advanced'), + 'access' => user_access('administer spam'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('spam_admin_settings_advanced'), + 'description' => t('Set advanced option for the spam module.'), + 'weight' => 4, + 'type' => MENU_LOCAL_TASK, + ); + + $items[] = array( + 'path' => 'admin/content/spam/blockedips', + 'title' => t('Blocked IPs'), + 'access' => user_access('administer spam'), + 'callback' => 'spam_blocked_ips_overview', + 'type' => MENU_LOCAL_TASK, ); // node admin submenu - $items[] = array('path' => 'admin/content/node/list/spam', 'title' => t('Spam'), + $items[] = array( + 'path' => 'admin/content/node/list/spam', + 'title' => t('Spam'), 'access' => user_access('administer spam'), - 'callback' => 'drupal_get_form', 'callback arguments' => array('spam_node_overview'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('spam_node_overview'), 'type' => MENU_LOCAL_TASK); // spam page - $items[] = array('path' => 'spam', 'title' => t('Spam'), + $items[] = array( + 'path' => 'spam', + 'title' => t('Spam'), 'access' => user_access('administer spam'), - 'callback' => 'spam_page', 'type' => MENU_CALLBACK); + 'callback' => 'spam_page', + 'type' => MENU_CALLBACK); + // report spam page - $items[] = array('path' => 'spam/report', 'title' => t('Spam'), + $items[] = array( + 'path' => 'spam/report', + 'title' => t('Spam'), 'access' => user_access('report spam'), - 'callback' => 'drupal_get_form', 'callback arguments' => array('spam_user_report'), - 'type' => MENU_CALLBACK); + 'callback' => 'drupal_get_form', + 'callback arguments' => array('spam_user_report'), + 'type' => MENU_CALLBACK, + ); // reported comment spam admin submenu - $items[] = array('path' => 'admin/content/comment/list/reported', - 'title' => t('Reported spam'), 'access' => user_access('administer spam'), - 'callback' => 'drupal_get_form', 'callback arguments' => array('spam_reported_comments_overview'), - 'type' => MENU_LOCAL_TASK, 'weight' => 5); + $items[] = array( + 'path' => 'admin/content/comment/list/reported', + 'title' => t('Reported spam'), + 'access' => user_access('administer spam'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('spam_reported_comments_overview'), + 'type' => MENU_LOCAL_TASK, + 'weight' => 5, + ); + // reported node spam admin submenu - $items[] = array('path' => 'admin/content/node/list/reported', - 'title' => t('Reported spam'), 'access' => user_access('administer spam'), - 'callback' => 'drupal_get_form', 'callback arguments' => array('spam_reported_nodes_overview'), - 'type' => MENU_LOCAL_TASK, 'weight' => 5); + $items[] = array( + 'path' => 'admin/content/node/list/reported', + 'title' => t('Reported spam'), + 'access' => user_access('administer spam'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('spam_reported_nodes_overview'), + 'type' => MENU_LOCAL_TASK, + 'weight' => 5, + ); } else if (arg(6) == 'details') { $source = arg(4); $id = arg(5); // reported spam details page - $items[] = array('path' => "admin/content/spam/reported/$source/$id/details", + $items[] = array( + 'path' => "admin/content/spam/reported/$source/$id/details", 'title' => t('Reported spam details'), 'access' => user_access('administer spam'), - 'callback' => 'spam_reported_details', 'type' => MENU_CALLBACK); + 'callback' => 'spam_reported_details', + 'type' => MENU_CALLBACK + ); } return $items; } @@ -869,16 +1002,16 @@ function spam_user_report() { $form['feedback']['message'] = array( '#type' => 'markup', '#value' => $confirm_message, - '#weight' => -1, + '#weight' => -1, ); $form['feedback']['spam_feedback'] = array( '#type' => 'textarea', '#title' => t('Please help us by entering a brief explanation as to why this content is spam'), '#rows' => 10, - '#default_value' => '', + '#default_value' => '', '#weight' => 0, '#required' => variable_get('spam_report_feedback', TRUE), - '#description' => t('It is not always obvious why content should be marked as spam, so please assist our efforts to keep these pages spam free by explaining how you know this content is spam. Your assistance is greatly appreciated. If you got to this page on accident, please press the "back" button on your web browser to return to the original page.') + '#description' => t('It is not always obvious why content should be marked as spam, so please assist our efforts to keep these pages spam free by explaining how you know this content is spam. Your assistance is greatly appreciated. If you got to this page on accident, please press the "back" button on your web browser to return to the original page.') ); $form['feedback']['submit'] = array( @@ -916,6 +1049,26 @@ function spam_invoke_hook($name, $arg1 = return $hook; } +/* Implementation of hook_spam + * This is a sample of the hook code which sets the tab names for the settings intro page. + */ +function spam_spam($name, $arg1, $arg2, $arg3) { + // Do stuff based on the hook type (name). + switch ($name) { + case 'tab_description': + $tabs = array(); + $tabs['Filters'] = t('Select content type filters for the spam module.'); + $tabs['Limits'] = t('Set filtering limits for the spam module.'); + $tabs['Actions'] = t('Select actions for the spam module.'); + $tabs['Advanced'] = t('Set advanced option for the spam module.'); + + return $tabs; + + default: + return array(); + } +} + /** * Divide a string into tokens. * @@ -1411,8 +1564,7 @@ function spam_logs_overview($source = NU $result = pager_query($sql . tablesort_sql($header), 50, 0, NULL, $arguments); while ($log = db_fetch_object($result)) { - $rows[] = array('data' => - array( + $rows[] = array('data' => array( t($log->source), $log->id, format_date($log->timestamp, 'small'), @@ -1477,13 +1629,13 @@ function spam_custom_filter_overview($id drupal_set_title(t('Custom spam filters')); $spam_effects = array( - SPAM_CUSTOM_DISABLED => t('disabled'), - SPAM_CUSTOM_ALWAYS_SPAM => t('always spam'), - SPAM_CUSTOM_USUALLY_SPAM => t('usually spam'), - SPAM_CUSTOM_MAYBE_SPAM => t('maybe spam'), - SPAM_CUSTOM_MAYBE_NOTSPAM => t('maybe not spam'), + SPAM_CUSTOM_DISABLED => t('disabled'), + SPAM_CUSTOM_ALWAYS_SPAM => t('always spam'), + SPAM_CUSTOM_USUALLY_SPAM => t('usually spam'), + SPAM_CUSTOM_MAYBE_SPAM => t('maybe spam'), + SPAM_CUSTOM_MAYBE_NOTSPAM => t('maybe not spam'), SPAM_CUSTOM_USUALLY_NOTSPAM => t('usually not spam'), - SPAM_CUSTOM_NEVER_SPAM => t('never spam'), + SPAM_CUSTOM_NEVER_SPAM => t('never spam'), ); $headers = array( @@ -1554,59 +1706,59 @@ function spam_custom_filter_edit($filter } $form['scid'] = array( - '#type' => 'hidden', - '#value' => (isset($filter) ? $filter->scid : ''), + '#type' => 'hidden', + '#value' => (isset($filter) ? $filter->scid : ''), ); $form['options'] = array( - '#collapsible' => TRUE, - '#title' => t('Custom filter'), - '#type' => 'fieldset', + '#collapsible' => TRUE, + '#title' => t('Custom filter'), + '#type' => 'fieldset', ); $form['options']['filter'] = array( '#default_value' => (isset($filter) ? $filter->filter : ''), - '#description' => t('Enter a custom filter string. You can enter a word, a phrase, or a complete regular expression. All new content that is being scanned for spam will also be tested against your custom filters.'), - '#type' => 'textfield', - '#title' => t('Filter expression'), + '#description' => t('Enter a custom filter string. You can enter a word, a phrase, or a complete regular expression. All new content that is being scanned for spam will also be tested against your custom filters.'), + '#type' => 'textfield', + '#title' => t('Filter expression'), ); $form['options']['style'] = array( - '#description' => t('Select the format of this filter. Note that if you select "regular expression" you need to format the expression as a Perl-compatible regular expression. As a simple example, to do a case-insensitve match on the word "viagra", you would enter "/viagra/i" without the quotes.'), + '#description' => t('Select the format of this filter. Note that if you select "regular expression" you need to format the expression as a Perl-compatible regular expression. As a simple example, to do a case-insensitve match on the word "viagra", you would enter "/viagra/i" without the quotes.'), '#default_value' => (isset($filter) ? $filter->style : ''), - '#options' => array(SPAM_CUSTOM_PLAIN => t('plain text'), SPAM_CUSTOM_REGEX => t('regular expression')), - '#required' => TRUE, - '#type' => 'radios', - '#title' => t('Filter type'), + '#options' => array(SPAM_CUSTOM_PLAIN => t('plain text'), SPAM_CUSTOM_REGEX => t('regular expression')), + '#required' => TRUE, + '#type' => 'radios', + '#title' => t('Filter type'), ); $form['options']['scan'] = array( '#default_value' => $action, - '#description' => t('By default, the custom filter will scan both the header and the body of new content, but you can configure it to only scan the header or only the body of new content. For example, if "header only" is selected, the filter will only attempt to match against the subject of a new comment, and the title of a new node.'), - '#options' => array(t('everything'), SPAM_CUSTOM_ACTION_HEADER => t('header only'), SPAM_CUSTOM_ACTION_BODY => t('body only')), - '#required' => TRUE, - '#type' => 'radios', - '#title' => t('Scan'), + '#description' => t('By default, the custom filter will scan both the header and the body of new content, but you can configure it to only scan the header or only the body of new content. For example, if "header only" is selected, the filter will only attempt to match against the subject of a new comment, and the title of a new node.'), + '#options' => array(t('everything'), SPAM_CUSTOM_ACTION_HEADER => t('header only'), SPAM_CUSTOM_ACTION_BODY => t('body only')), + '#required' => TRUE, + '#type' => 'radios', + '#title' => t('Scan'), ); $form['options']['effect'] = array( '#default_value' => (isset($filter) ? $filter->effect : ''), - '#description' => t('Define the effect when your custom filter matches on new content. If your filter defines "always spam", this increases the chances the new content will be marked spam by 200%. If your filter defines "usually spam", this increases the chances the new content will be marked spam by 50%. If you filter defines "maybe spam", this increases the chances the new content will be marked spam by 20%. If your filter defines "maybe not spam", this decreases the chances the new content will be marked spam by 20%. If your filter defines "usually not spam", this decreases the chances the new content will be marked spam by 50%. And if your filter defines "never spam", this decreases the chances the new content will be marked spam by 200%. Note that it is possible to match both an "always spam" and a "never spam" filter with the same content, and that then the filters will cancel each other out. Additionally, four "usually not spam" matches will cancel out one "always spam" match.'), - '#options' => array(SPAM_CUSTOM_DISABLED => t('disabled'), SPAM_CUSTOM_ALWAYS_SPAM => t('always spam (+200%)'), SPAM_CUSTOM_USUALLY_SPAM => t('usually spam (+50%)'), SPAM_CUSTOM_MAYBE_SPAM => t('maybe spam (+20%)'), SPAM_CUSTOM_MAYBE_NOTSPAM => t('maybe not spam (-20%)'), SPAM_CUSTOM_USUALLY_NOTSPAM => t('usually not spam (-50%)'), SPAM_CUSTOM_NEVER_SPAM => t('never spam (-200%)')), - '#required' => TRUE, - '#title' => t('Match effect'), - '#type' => 'radios', + '#description' => t('Define the effect when your custom filter matches on new content. If your filter defines "always spam", this increases the chances the new content will be marked spam by 200%. If your filter defines "usually spam", this increases the chances the new content will be marked spam by 50%. If you filter defines "maybe spam", this increases the chances the new content will be marked spam by 20%. If your filter defines "maybe not spam", this decreases the chances the new content will be marked spam by 20%. If your filter defines "usually not spam", this decreases the chances the new content will be marked spam by 50%. And if your filter defines "never spam", this decreases the chances the new content will be marked spam by 200%. Note that it is possible to match both an "always spam" and a "never spam" filter with the same content, and that then the filters will cancel each other out. Additionally, four "usually not spam" matches will cancel out one "always spam" match.'), + '#options' => array(SPAM_CUSTOM_DISABLED => t('disabled'), SPAM_CUSTOM_ALWAYS_SPAM => t('always spam (+200%)'), SPAM_CUSTOM_USUALLY_SPAM => t('usually spam (+50%)'), SPAM_CUSTOM_MAYBE_SPAM => t('maybe spam (+20%)'), SPAM_CUSTOM_MAYBE_NOTSPAM => t('maybe not spam (-20%)'), SPAM_CUSTOM_USUALLY_NOTSPAM => t('usually not spam (-50%)'), SPAM_CUSTOM_NEVER_SPAM => t('never spam (-200%)')), + '#required' => TRUE, + '#title' => t('Match effect'), + '#type' => 'radios', ); $form['options']['nomail'] = array( - '#description' => t('Checking this box will cause any new content that matches this filter and ultimately is determined to be spam to not generate a notification email.'), + '#description' => t('Checking this box will cause any new content that matches this filter and ultimately is determined to be spam to not generate a notification email.'), '#default_value' => (isset($filter) ? $filter->action & SPAM_CUSTOM_ACTION_NOMAIL : ''), - '#title' => t('Disable email notification'), - '#type' => 'checkbox', + '#title' => t('Disable email notification'), + '#type' => 'checkbox', ); $form['options']['autodelete'] = array( '#default_value' => (isset($filter) ? $filter->action & SPAM_CUSTOM_ACTION_DELETE : ''), - '#description' => t('Checking this box will cause any new content that matches this filter and ultimately is determined to be spam to be automatically (and silently) deleted. It is not recommended that you enable this option unless you are fully confident that it will never match non-spam content.'), - '#title' => t('Automatically delete spam'), - '#type' => 'checkbox', + '#description' => t('Checking this box will cause any new content that matches this filter and ultimately is determined to be spam to be automatically (and silently) deleted. It is not recommended that you enable this option unless you are fully confident that it will never match non-spam content.'), + '#title' => t('Automatically delete spam'), + '#type' => 'checkbox', ); $form['options']['submit'] = array( - '#type' => 'submit', - '#value' => (isset($filter) ? t('Update filter') : t('Add filter')), + '#type' => 'submit', + '#value' => (isset($filter) ? t('Update filter') : t('Add filter')), ); return $form; @@ -1704,34 +1856,34 @@ function spam_custom_filter_load($scid) */ function spam_custom_filter_scan($filter) { $form['scid'] = array( - '#type' => 'hidden', - '#value' => $filter->scid, + '#type' => 'hidden', + '#value' => $filter->scid, ); $form['scan_help'] = array( - '#type' => 'markup', - '#value' => t('Scan results for filter %filter', array('%filter' => $filter->filter)), - '#weight' => 1, + '#type' => 'markup', + '#value' => t('Scan results for filter %filter', array('%filter' => $filter->filter)), + '#weight' => 1, ); $form['options'] = array( - '#type' => 'fieldset', - '#title' => t('Update options'), - '#prefix' => '
', - '#suffix' => '
', - '#weight' => 2, + '#type' => 'fieldset', + '#title' => t('Update options'), + '#prefix' => '
', + '#suffix' => '
', + '#weight' => 2, ); $form['options']['operation'] = array( '#options' => array( - 'SPAM' => t('Mark the selected comments as spam'), - 'NOT_SPAM' => t('Mark the selected comments as not spam'), + 'SPAM' => t('Mark the selected comments as spam'), + 'NOT_SPAM' => t('Mark the selected comments as not spam'), 'UNPUBLISH' => t('Unpublish the selected comments'), - 'PUBLISH' => t('Publish the selected comments'), - 'DELETE' => t('Delete the selected comments (no confirmation)'), + 'PUBLISH' => t('Publish the selected comments'), + 'DELETE' => t('Delete the selected comments (no confirmation)'), ), '#type' => 'select', ); $form['options']['submit'] = array( - '#type' => 'submit', - '#value' => t('Update'), + '#type' => 'submit', + '#value' => t('Update'), ); $form['header'] = array('#type' => 'value', '#value' => array( theme('table_select_header_cell'), @@ -1914,24 +2066,24 @@ function spam_url_filter_overview($id = */ function spam_url_filter_edit($filter = NULL) { $form['tid'] = array( - '#type' => 'hidden', - '#value' => (isset($filter) ? $filter->tid : ''), + '#type' => 'hidden', + '#value' => (isset($filter) ? $filter->tid : ''), ); $form['options'] = array( - '#collapsible' => TRUE, - '#title' => t('Add new URL filter'), - '#type' => 'fieldset', + '#collapsible' => TRUE, + '#title' => t('Add new URL filter'), + '#type' => 'fieldset', ); $form['options']['url'] = array( '#default_value' => (isset($filter) ? str_replace('URL*', '', $filter->token) : ''), - '#description' => t('Enter a domain name that if found in new site content will cause the content to be marked as spam. For example if you enter "spam.com" as a domain name, a comment containing the URL "http://spam.com/stuff/for/sale" will be automatically marked as spam.'), - '#required' => TRUE, - '#title' => t('Domain'), - '#type' => 'textfield', + '#description' => t('Enter a domain name that if found in new site content will cause the content to be marked as spam. For example if you enter "spam.com" as a domain name, a comment containing the URL "http://spam.com/stuff/for/sale" will be automatically marked as spam.'), + '#required' => TRUE, + '#title' => t('Domain'), + '#type' => 'textfield', ); $form['options']['submit'] = array( - '#type' => 'submit', - '#value' => (isset($filter) ? t('Update filter') : t('Add filter')), + '#type' => 'submit', + '#value' => (isset($filter) ? t('Update filter') : t('Add filter')), ); return $form; @@ -2463,23 +2615,23 @@ function spam_comment_operations($action */ function spam_comment_overview() { $form['options'] = array( - '#prefix' => '
', - '#suffix' => '
', - '#title' => t('Update options'), - '#type' => 'fieldset', + '#prefix' => '
', + '#suffix' => '
', + '#title' => t('Update options'), + '#type' => 'fieldset', ); $form['options']['operation'] = array( '#options' => array( - 'NOT_SPAM' => t('Mark the selected comments as not spam'), + 'NOT_SPAM' => t('Mark the selected comments as not spam'), 'UNPUBLISH' => t('Unpublish the selected comments'), - 'PUBLISH' => t('Publish the selected comments'), - 'DELETE' => t('Delete the selected comments (no confirmation)') + 'PUBLISH' => t('Publish the selected comments'), + 'DELETE' => t('Delete the selected comments (no confirmation)') ), '#type' => 'select', ); $form['options']['submit'] = array( - '#type' => 'submit', - '#value' => t('Update') + '#type' => 'submit', + '#value' => t('Update') ); $form['header'] = array('#type' => 'value', '#value' => array( theme('table_select_header_cell'), @@ -2537,8 +2689,7 @@ function spam_blocked_ips_overview() { $result = pager_query($sql . tablesort_sql($header), 50, 0, $count_sql, $arguments); while ($log = db_fetch_object($result)) { - $rows[] = array('data' => - array( + $rows[] = array('data' => array( $log->hostname, format_date($log->timestamp, 'small'), $log->count @@ -2750,8 +2901,8 @@ function spam_node_overview() { $nodes[$node->nid] = ''; $form['title'][$node->nid] = array('#value' => l($node->title, "node/$node->nid") .' '. (node_last_viewed($node->nid) < $node->changed ? theme_mark() : '')); $form['type'][$node->nid] = array('#value' => node_get_types('name', $node)); - $form['author'][$node->nid] = array('#value' => theme('username', $node)); - $form['hostname'][$node->nid] = array('#value' => $node->hostname); + $form['author'][$node->nid] = array('#value' => theme('username', $node)); + $form['hostname'][$node->nid] = array('#value' => $node->hostname); $form['status'][$node->nid] = array('#value' => ($node->status ? t('published') : t('not published'))); $form['timestamp'][$node->nid] = array('#value' => format_date($node->changed, 'small')); $form['operations'][$node->nid] = array('#value' => l(t('View log'), "admin/content/spam/logs/node/$node->nid") . ' ' . l(t('Edit'), "node/$node->nid/edit") . ' ' . l(t('Delete'), "admin/content/node/delete/$node->nid")); @@ -2977,6 +3128,4 @@ function spam_notspam_node($nid) { */ function spam_donothing_node($nid) { spam_log(SPAM_LOG, t('spam_page: invalid node operation selection made'), 'node', $nid); -} - -?> +} \ No newline at end of file