diff --git a/README.md b/README.md
index 2eb498a..8b7e97a 100644
--- a/README.md
+++ b/README.md
@@ -56,10 +56,6 @@ By Composer:
* Clear cache
* re-enable compilation
-By Magento Connect 1:
----------------------
-
-Check version number available via connect against what is in GIT. It is most likely that the connect package is dated, and it is prefered to install via composer or direct from git.
Disabling:
==========
@@ -224,6 +220,23 @@ Product Review Captcha
getChildHtml('recaptcha'); ?>
+Customer Wishlist Sharing Captcha
+-------------------------
+
+* Enable in admin under Customer Configuration by selecting 'Wishlist Sharing' in available forms list
+* Unfortunately the core wishlist sharing form does not have an after form elements block, so you will need to adjust your reviews form to display the captcha.
+
+ Edit the wishlist sharing form located here:
+
+ app/design/frontend/[rwd|base|your package]/[default|your theme]/template/wishlist/sharing.phtml
+
+ place the following line into the form, anywhere within the ```
``` element.
+ a good place will be just before the closing ```
``` tag
+
+ getChildHtml('recaptcha'); ?>
+
+ Entered values will be retained upon incorrect captcha entry
+
Captcha is still not appearing, even after I did the steps above!
-----------------------------------------------------------------
diff --git a/app/code/community/ProxiBlue/ReCaptcha/Model/Observer.php b/app/code/community/ProxiBlue/ReCaptcha/Model/Observer.php
index b6d9b98..285670d 100644
--- a/app/code/community/ProxiBlue/ReCaptcha/Model/Observer.php
+++ b/app/code/community/ProxiBlue/ReCaptcha/Model/Observer.php
@@ -160,5 +160,37 @@ protected function _isUrlInternal($url)
return false;
}
+ /**
+ * Check Captcha On Whislist Sharing
+ *
+ * @param Varien_Event_Observer $observer
+ *
+ * @return Mage_Captcha_Model_Observer
+ */
+ public function checkWishlist($observer)
+ {
+ $formId = 'user_wishlist';
+ $captchaModel = Mage::helper('captcha')->getCaptcha($formId);
+ if ($captchaModel->isRequired()) {
+ $controller = $observer->getControllerAction();
+ if (!$captchaModel->isCorrect($this->_getCaptchaString($controller->getRequest(), $formId))) {
+ $request = $controller->getRequest();
+ $isAjax = $request->getParam('json');
+ // insert form data to session, allowing to re-populate the contact us form
+ $data = $controller->getRequest()->getPost();
+ Mage::getSingleton('wishlist/session')->setData('sharing_form', $data);
+ $controller->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
+ if($isAjax) {
+ $controller->getResponse()->setBody(Zend_Json::encode(array('error'=>Mage::helper('captcha')->__('Incorrect CAPTCHA.'))));
+ } else {
+ Mage::getSingleton('customer/session')->addError(Mage::helper('captcha')->__('Incorrect CAPTCHA.'));
+ $controller->getResponse()->setRedirect(Mage::getUrl('*/*/share'));
+ }
+ }
+ }
+
+ return $this;
+ }
+
}
diff --git a/app/code/community/ProxiBlue/ReCaptcha/Model/Recaptcha.php b/app/code/community/ProxiBlue/ReCaptcha/Model/Recaptcha.php
index bffdfaf..b604d3b 100755
--- a/app/code/community/ProxiBlue/ReCaptcha/Model/Recaptcha.php
+++ b/app/code/community/ProxiBlue/ReCaptcha/Model/Recaptcha.php
@@ -11,6 +11,13 @@
class ProxiBlue_ReCaptcha_Model_Recaptcha extends Mage_Captcha_Model_Zend implements Mage_Captcha_Model_Interface
{
+ /**
+ * @var array
+ *
+ * normally recaptcha will not show for logged in users. Form ids listed here will also appear when logged in
+ *
+ */
+ protected $_alwaysShow = array('user_wishlist');
/**
* Key in session for captcha code
*/
@@ -163,4 +170,25 @@ public function getElementId($type = 'input')
{
return 'captcha-' . $type . '-box-' . trim($this->_formId);
}
+
+ /**
+ * Whether captcha is required to be inserted to this form
+ *
+ * @param null|string $login
+ * @return bool
+ */
+ public function isRequired($login = null)
+ {
+ if (in_array($this->_formId, $this->_alwaysShow)) {
+ return true;
+ }
+
+ if ($this->_isUserAuth() || !$this->_isEnabled() || !in_array($this->_formId, $this->_getTargetForms())) {
+ return false;
+ }
+
+ return ($this->_isShowAlways() || $this->_isOverLimitAttempts($login)
+ || $this->getSession()->getData($this->_getFormIdKey('show_captcha'))
+ );
+ }
}
diff --git a/app/code/community/ProxiBlue/ReCaptcha/etc/config.xml b/app/code/community/ProxiBlue/ReCaptcha/etc/config.xml
index 5d9e82e..3a446b5 100755
--- a/app/code/community/ProxiBlue/ReCaptcha/etc/config.xml
+++ b/app/code/community/ProxiBlue/ReCaptcha/etc/config.xml
@@ -2,7 +2,7 @@
- 1.4.1
+ 1.5.0
@@ -46,6 +46,14 @@
+
+
+
+ proxiblue_recaptcha/observer
+ checkWishlist
+
+
+
@@ -115,6 +123,9 @@
+
+
+
diff --git a/app/design/frontend/base/default/layout/proxiblue_recaptcha.xml b/app/design/frontend/base/default/layout/proxiblue_recaptcha.xml
index b0bb829..c2b2d95 100644
--- a/app/design/frontend/base/default/layout/proxiblue_recaptcha.xml
+++ b/app/design/frontend/base/default/layout/proxiblue_recaptcha.xml
@@ -27,4 +27,13 @@
+
+
+
+
+ user_wishlist
+
+
+
+