Permalink
Browse files

FEATURE: added extension for new comments module

  • Loading branch information...
1 parent feddb2c commit 237d08d5dd2b3a5f37bce3a0ae43b3513473ff18 Will Rossiter committed Dec 13, 2010
Showing with 39 additions and 1 deletion.
  1. +16 −1 _config.php
  2. +23 −0 code/extensions/CommentSpamProtection.php
View
@@ -1,3 +1,18 @@
<?php
-?>
+/**
+ * Default configuration settings for the Spam Protection module.
+ *
+ * You should not put your own configuration in here rather use your
+ * mysite/_config.php file
+ *
+ * @package spamprotection
+ */
+
+if(class_exists('Comment')) {
+ /**
+ * If the comments module is installed then add the spam protection module
+ * to the comments form via this extension
+ */
+ Object::add_extension('CommentingController', 'CommentSpamProtection');
+}
@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * Apply the spam protection to the comments module if it is installed
+ *
+ * @package spamprotection
+ */
+
+class CommentSpamProtection extends Extension {
+
+ /**
+ * Disable the AJAX commenting and update the form
+ * with the {@link SpamProtectorField} which is enabled
+ */
+ function alterCommentForm(&$form) {
+ SpamProtectorManager::update_form($form, null, array(
+ 'Name' => 'author_name',
+ 'CommenterURL' => 'author_url',
+ 'Comment' => 'post_body',
+ 'Email' => 'author_email'
+ ));
+ }
+}

0 comments on commit 237d08d

Please sign in to comment.