@define('PLUGIN_EVENT_SPAMBLOCK_REASON_CHECKMAIL', 'Invalid e-mail address');
@define('PLUGIN_EVENT_SPAMBLOCK_CHECKMAIL', 'Check e-mail addresses?');
+@define('PLUGIN_EVENT_SPAMBLOCK_REQUIRED_FIELDS', 'Required comment fields');
+@define('PLUGIN_EVENT_SPAMBLOCK_REQUIRED_FIELDS_DESC', 'Enter a list of required fields that need to be filled when a user comments. Seperate multiple fields with a ",". Available keys are: name, email, url, replyTo, comment');
+@define('PLUGIN_EVENT_SPAMBLOCK_REASON_REQUIRED_FIELD', 'You did not specify the %s field!');
class serendipity_event_spamblock extends serendipity_event
{
'smarty' => '2.6.7',
'php' => '4.1.0'
));
- $propbag->add('version', '1.23');
+ $propbag->add('version', '1.24');
$propbag->add('event_hooks', array(
'frontend_saveComment' => true,
'external_plugin' => true,
'frontend_comment' => true,
'fetchcomments' => true
));
- $propbag->add('configuration', array('killswitch', 'bodyclone', 'ipflood', 'captchas', 'captchas_ttl', 'captcha_color', 'forcemoderation', 'disable_api_comments', 'links_moderate', 'links_reject', 'contentfilter_activate', 'contentfilter_urls', 'contentfilter_authors', 'hide_email', 'checkmail', 'logtype', 'logfile'));
+ $propbag->add('configuration', array('killswitch', 'bodyclone', 'ipflood', 'captchas', 'captchas_ttl', 'captcha_color', 'forcemoderation', 'disable_api_comments', 'links_moderate', 'links_reject', 'contentfilter_activate', 'contentfilter_urls', 'contentfilter_authors', 'hide_email', 'checkmail', 'required_fields', 'logtype', 'logfile'));
$propbag->add('groups', array('ANTISPAM'));
$this->filter_defaults = array(
$propbag->add('default', false);
break;
+ case 'required_fields':
+ $propbag->add('type', 'string');
+ $propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_REQUIRED_FIELDS);
+ $propbag->add('description', PLUGIN_EVENT_SPAMBLOCK_REQUIRED_FIELDS_DESC);
+ $propbag->add('default', '');
+ break;
+
case 'bodyclone':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_BODYCLONE);
$serendipity['csuccess'] = 'true';
$logfile = $this->get_config('logfile', $serendipity['serendipityPath'] . 'spamblock.log');
+ $required_fields = $this->get_config('required_fields', '');
+
+ // Check required fields
+ if ($addData['type'] == 'NORMAL' && !empty($required_fields)) {
+ $required_field_list = explode(',', $required_fields);
+ foreach($required_field_list as $required_field) {
+ $required_field = trim($required_field);
+ if (empty($addData[$required_field])) {
+ $this->log($logfile, $eventData['id'], 'REJECTED', PLUGIN_EVENT_SPAMBLOCK_REASON_REQUIRED_FIELD, $addData);
+ $eventData = array('allow_comments' => false);
+ $serendipity['messagestack']['comments'][] = sprintf(PLUGIN_EVENT_SPAMBLOCK_REASON_REQUIRED_FIELD, $required_field);
+ return false;
+ }
+ }
+ }
// Check for global emergency moderation
if ( $this->get_config('killswitch', false) === true ) {