From 89b649e124f078310c1b6dc41bf4ce3f28f03f64 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Tue, 6 Oct 2015 11:30:09 -0400
Subject: [PATCH] Rolled back non-working feature (problems due to library
 limitations).

Revert "Add UserComments as an option for Captcha protection. Closes VUFIND-526."

This reverts commit dae50b1118555088150f0187daf35065554a0f1e.
---
 config/vufind/config.ini                                 | 5 ++---
 module/VuFind/src/VuFind/Controller/AbstractRecord.php   | 6 ------
 module/VuFind/src/VuFind/Controller/AjaxController.php   | 7 -------
 themes/bootstrap3/templates/RecordTab/usercomments.phtml | 6 ------
 4 files changed, 2 insertions(+), 22 deletions(-)

diff --git a/config/vufind/config.ini b/config/vufind/config.ini
index f2af7aeba5d..973a708cabd 100644
--- a/config/vufind/config.ini
+++ b/config/vufind/config.ini
@@ -1003,7 +1003,7 @@ era             = true      ; allow browsing of era subdivisions
 ; <result_limit> most popular entries -- it only affects display order.
 ;alphabetical_order = true
 
-; This section controls the availability of export methods.
+; This section controls the availability of export methods. 
 ;
 ; Each entry may be a comma-separated list of contexts in which the export
 ; option will be presented. Valid options:
@@ -1259,8 +1259,7 @@ treeSearchLimit = 100
 ;secretKey = "https://www.google.com/recaptcha/admin/create"
 ; Valid theme values: dark, light
 ;theme      = light
-; Valid forms values: changePassword, email, newAccount,
-;                     passwordRecovery, sms, UserComments
+; Valid forms values: changePassword, email, newAccount, passwordRecovery, sms
 ; Use * for all supported forms
 ;forms = changePassword, email, newAccount, passwordRecovery, sms
 
diff --git a/module/VuFind/src/VuFind/Controller/AbstractRecord.php b/module/VuFind/src/VuFind/Controller/AbstractRecord.php
index 38498c5e0f9..7c3cc7aa35f 100644
--- a/module/VuFind/src/VuFind/Controller/AbstractRecord.php
+++ b/module/VuFind/src/VuFind/Controller/AbstractRecord.php
@@ -113,12 +113,6 @@ class AbstractRecord extends AbstractBase
             );
         }
 
-        $captcha = $this->recaptcha()->active('UserComments');
-        if (!$this->formWasSubmitted('comment', $captcha)) {
-            $this->flashMessenger()->addMessage('recaptcha_not_passed', 'error');
-            return $this->redirectToRecord('', 'UserComments');
-        }
-
         // Obtain the current record object:
         $driver = $this->loadRecord();
 
diff --git a/module/VuFind/src/VuFind/Controller/AjaxController.php b/module/VuFind/src/VuFind/Controller/AjaxController.php
index f729e95218a..d8ccc7db0f6 100644
--- a/module/VuFind/src/VuFind/Controller/AjaxController.php
+++ b/module/VuFind/src/VuFind/Controller/AjaxController.php
@@ -969,13 +969,6 @@ class AjaxController extends AbstractBase
 
         $id = $this->params()->fromPost('id');
         $comment = $this->params()->fromPost('comment');
-
-        $captcha = $this->recaptcha()->active('UserComments');
-        if (!$this->formWasSubmitted('comment', $captcha)) {
-            return $this->output(
-                $this->translate('recaptcha_not_passed'), self::STATUS_ERROR
-            );
-        }
         if (empty($id) || empty($comment)) {
             return $this->output(
                 $this->translate('An error has occurred'), self::STATUS_ERROR
diff --git a/themes/bootstrap3/templates/RecordTab/usercomments.phtml b/themes/bootstrap3/templates/RecordTab/usercomments.phtml
index b1215d1a478..4ec13a48f4a 100644
--- a/themes/bootstrap3/templates/RecordTab/usercomments.phtml
+++ b/themes/bootstrap3/templates/RecordTab/usercomments.phtml
@@ -17,15 +17,9 @@
       <? $user = $this->auth()->isLoggedIn() ?>
       <? if($user): ?>
         <textarea id="comment" name="comment" class="form-control" rows="3" required></textarea><br/>
-        <? if ($this->recaptcha()->active('UserComments')): ?>
-          <?=$this->recaptcha()->html(true) ?><br/>
-        <? endif; ?>
         <input class="btn btn-primary" data-loading-text="<?=$this->transEsc('Submitting') ?>..." type="submit" value="<?=$this->transEsc("Add your comment")?>"/>
       <? else: ?>
         <textarea id="comment" name="comment" class="form-control" rows="3" disabled></textarea><br/>
-        <? if ($this->recaptcha()->active('UserComments')): ?>
-          <?=$this->recaptcha()->html(true) ?><br/>
-        <? endif; ?>
         <input onClick="Lightbox.get('MyResearch', 'UserLogin'); return false;" class="btn btn-primary" type="submit" value="<?=$this->transEsc("You must be logged in first")?>"/>
       <? endif; ?>
     </div>
-- 
GitLab