Version Notes
Allow admin to add CAPTCHA on contact us page. And Manage from admin.
Download this release
Release Info
Developer | Envision Ecommerce |
Extension | Eecom_Addcaptcha |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/local/Eecom/Addcaptcha/Model/Observer.php +41 -0
- app/code/local/Eecom/Addcaptcha/etc/config.xml +64 -0
- app/design/frontend/base/default/layout/eecom_addcaptcha.xml +30 -0
- app/design/frontend/base/default/template/addcaptcha/contacts/form.phtml +77 -0
- app/etc/modules/Eecom_Addcaptcha.xml +21 -0
- package.xml +18 -0
app/code/local/Eecom/Addcaptcha/Model/Observer.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Easy Contacts Form Captcha Extension
|
4 |
+
*
|
5 |
+
* @category Extension
|
6 |
+
* @copyright Copyright © 2015 Envision Ecommerce (http://www.envisionecommerce.com/store/)
|
7 |
+
* @author Envision Ecommerce
|
8 |
+
* @terms of use http://www.envisionecommerce.com/store/terms-of-use
|
9 |
+
* @version Release: 1.0.0
|
10 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
11 |
+
*/
|
12 |
+
class Eecom_Addcaptcha_Model_Observer
|
13 |
+
{
|
14 |
+
public function checkContacts($observer){
|
15 |
+
$formId = 'contacts';
|
16 |
+
$captchaModel = Mage::helper('captcha')->getCaptcha($formId);
|
17 |
+
if ($captchaModel->isRequired()) {
|
18 |
+
$controller = $observer->getControllerAction();
|
19 |
+
$word = $this->_getCaptchaString($controller->getRequest(), $formId);
|
20 |
+
if (!$captchaModel->isCorrect($word)) {
|
21 |
+
Mage::getSingleton('customer/session')->addError(Mage::helper('captcha')->__('Incorrect CAPTCHA.'));
|
22 |
+
$controller->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
|
23 |
+
$url = Mage::getUrl('contacts');
|
24 |
+
$controller->getResponse()->setRedirect($url);
|
25 |
+
}
|
26 |
+
}
|
27 |
+
return $this;
|
28 |
+
}
|
29 |
+
/**
|
30 |
+
* Get Captcha String
|
31 |
+
*
|
32 |
+
* @param Varien_Object $request
|
33 |
+
* @param string $formId
|
34 |
+
* @return string
|
35 |
+
*/
|
36 |
+
protected function _getCaptchaString($request, $formId)
|
37 |
+
{
|
38 |
+
$captchaParams = $request->getPost(Mage_Captcha_Helper_Data::INPUT_NAME_FIELD_VALUE);
|
39 |
+
return $captchaParams[$formId];
|
40 |
+
}
|
41 |
+
}
|
app/code/local/Eecom/Addcaptcha/etc/config.xml
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Easy Contacts Form Captcha Extension
|
5 |
+
*
|
6 |
+
* @category Extension
|
7 |
+
* @copyright Copyright © 2015 Envision Ecommerce (http://www.envisionecommerce.com/store/)
|
8 |
+
* @author Envision Ecommerce
|
9 |
+
* @terms of use http://www.envisionecommerce.com/store/terms-of-use
|
10 |
+
* @version Release: 1.0.0
|
11 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
12 |
+
*/
|
13 |
+
-->
|
14 |
+
<config>
|
15 |
+
<modules>
|
16 |
+
<Eecom_Addcaptcha>
|
17 |
+
<version>1.1.0</version>
|
18 |
+
</Eecom_Addcaptcha>
|
19 |
+
</modules>
|
20 |
+
<frontend>
|
21 |
+
<layout>
|
22 |
+
<updates>
|
23 |
+
<addcaptcha>
|
24 |
+
<file>eecom_addcaptcha.xml</file>
|
25 |
+
</addcaptcha>
|
26 |
+
</updates>
|
27 |
+
</layout>
|
28 |
+
</frontend>
|
29 |
+
<global>
|
30 |
+
<models>
|
31 |
+
<addcaptcha>
|
32 |
+
<class>Eecom_Addcaptcha_Model</class>
|
33 |
+
</addcaptcha>
|
34 |
+
</models>
|
35 |
+
<events>
|
36 |
+
<controller_action_predispatch_contacts_index_post>
|
37 |
+
<observers>
|
38 |
+
<addcaptcha>
|
39 |
+
<class>addcaptcha/observer</class>
|
40 |
+
<method>checkContacts</method>
|
41 |
+
</addcaptcha>
|
42 |
+
</observers>
|
43 |
+
</controller_action_predispatch_contacts_index_post>
|
44 |
+
</events>
|
45 |
+
</global>
|
46 |
+
<default>
|
47 |
+
<captcha>
|
48 |
+
<frontend>
|
49 |
+
<areas>
|
50 |
+
<contacts>
|
51 |
+
<label>Contacts Page</label>
|
52 |
+
</contacts>
|
53 |
+
</areas>
|
54 |
+
</frontend>
|
55 |
+
</captcha>
|
56 |
+
<customer>
|
57 |
+
<captcha>
|
58 |
+
<always_for>
|
59 |
+
<contacts>1</contacts>
|
60 |
+
</always_for>
|
61 |
+
</captcha>
|
62 |
+
</customer>
|
63 |
+
</default>
|
64 |
+
</config>
|
app/design/frontend/base/default/layout/eecom_addcaptcha.xml
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Easy Contacts Form Captcha Extension
|
5 |
+
*
|
6 |
+
* @category Extension
|
7 |
+
* @copyright Copyright © 2015 Envision Ecommerce (http://www.envisionecommerce.com/store/)
|
8 |
+
* @author Envision Ecommerce
|
9 |
+
* @terms of use http://www.envisionecommerce.com/store/terms-of-use
|
10 |
+
* @version Release: 1.0.0
|
11 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
12 |
+
*/
|
13 |
+
-->
|
14 |
+
<layout version="0.1.0">
|
15 |
+
<contacts_index_index>
|
16 |
+
<reference name="contactForm">
|
17 |
+
<action method="setTemplate"><template>addcaptcha/contacts/form.phtml</template></action>
|
18 |
+
<block type="core/text_list" name="form.additional.info">
|
19 |
+
<block type="captcha/captcha" name="captcha">
|
20 |
+
<reference name="head">
|
21 |
+
<action method="addJs"><file>mage/captcha.js</file></action>
|
22 |
+
</reference>
|
23 |
+
<action method="setFormId"><formId>contacts</formId></action>
|
24 |
+
<action method="setImgWidth"><width>230</width></action>
|
25 |
+
<action method="setImgHeight"><width>50</width></action>
|
26 |
+
</block>
|
27 |
+
</block>
|
28 |
+
</reference>
|
29 |
+
</contacts_index_index>
|
30 |
+
</layout>
|
app/design/frontend/base/default/template/addcaptcha/contacts/form.phtml
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magento.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magento.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright © 2015 Envision Ecommerce (http://www.envisionecommerce.com/store/)
|
24 |
+
* @author Envision Ecommerce
|
25 |
+
* @terms of use http://www.envisionecommerce.com/store/terms-of-use
|
26 |
+
* @version Release: 1.0.0
|
27 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
28 |
+
*/
|
29 |
+
?>
|
30 |
+
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->toHtml() ?></div>
|
31 |
+
<div class="page-title">
|
32 |
+
<h1><?php echo Mage::helper('contacts')->__('Contact Us') ?></h1>
|
33 |
+
</div>
|
34 |
+
<form action="<?php echo $this->getFormAction(); ?>" id="contactForm" method="post">
|
35 |
+
<div class="fieldset">
|
36 |
+
<h2 class="legend"><?php echo Mage::helper('contacts')->__('Contact Information') ?></h2>
|
37 |
+
<ul class="form-list">
|
38 |
+
<li class="fields">
|
39 |
+
<div class="field">
|
40 |
+
<label for="name" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Name') ?></label>
|
41 |
+
<div class="input-box">
|
42 |
+
<input name="name" id="name" title="<?php echo Mage::helper('contacts')->__('Name') ?>" value="<?php echo $this->escapeHtml($this->helper('contacts')->getUserName()) ?>" class="input-text required-entry" type="text" />
|
43 |
+
</div>
|
44 |
+
</div>
|
45 |
+
<div class="field">
|
46 |
+
<label for="email" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Email') ?></label>
|
47 |
+
<div class="input-box">
|
48 |
+
<input name="email" id="email" title="<?php echo Mage::helper('contacts')->__('Email') ?>" value="<?php echo $this->escapeHtml($this->helper('contacts')->getUserEmail()) ?>" class="input-text required-entry validate-email" type="text" />
|
49 |
+
</div>
|
50 |
+
</div>
|
51 |
+
</li>
|
52 |
+
<li>
|
53 |
+
<label for="telephone"><?php echo Mage::helper('contacts')->__('Telephone') ?></label>
|
54 |
+
<div class="input-box">
|
55 |
+
<input name="telephone" id="telephone" title="<?php echo Mage::helper('contacts')->__('Telephone') ?>" value="" class="input-text" type="text" />
|
56 |
+
</div>
|
57 |
+
</li>
|
58 |
+
<li class="wide">
|
59 |
+
<label for="comment" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Comment') ?></label>
|
60 |
+
<div class="input-box">
|
61 |
+
<textarea name="comment" id="comment" title="<?php echo Mage::helper('contacts')->__('Comment') ?>" class="required-entry input-text" cols="5" rows="3"></textarea>
|
62 |
+
</div>
|
63 |
+
<?php echo $this->getChildHtml('form.additional.info'); ?>
|
64 |
+
</li>
|
65 |
+
</ul>
|
66 |
+
</div>
|
67 |
+
<div class="buttons-set">
|
68 |
+
<p class="required"><?php echo Mage::helper('contacts')->__('* Required Fields') ?></p>
|
69 |
+
<input type="text" name="hideit" id="hideit" value="" style="display:none !important;" />
|
70 |
+
<button type="submit" title="<?php echo Mage::helper('contacts')->__('Submit') ?>" class="button"><span><span><?php echo Mage::helper('contacts')->__('Submit') ?></span></span></button>
|
71 |
+
</div>
|
72 |
+
</form>
|
73 |
+
<script type="text/javascript">
|
74 |
+
//<![CDATA[
|
75 |
+
var contactForm = new VarienForm('contactForm', true);
|
76 |
+
//]]>
|
77 |
+
</script>
|
app/etc/modules/Eecom_Addcaptcha.xml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Easy Contacts Form Captcha Extension
|
5 |
+
*
|
6 |
+
* @category Extension
|
7 |
+
* @copyright Copyright © 2015 Envision Ecommerce (http://www.envisionecommerce.com/store/)
|
8 |
+
* @author Envision Ecommerce
|
9 |
+
* @terms of use http://www.envisionecommerce.com/store/terms-of-use
|
10 |
+
* @version Release: 1.0.0
|
11 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
12 |
+
*/
|
13 |
+
-->
|
14 |
+
<config>
|
15 |
+
<modules>
|
16 |
+
<Eecom_Addcaptcha>
|
17 |
+
<active>true</active>
|
18 |
+
<codePool>local</codePool>
|
19 |
+
</Eecom_Addcaptcha>
|
20 |
+
</modules>
|
21 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Eecom_Addcaptcha</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSLv3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Allow admin to add CAPTCHA on contact us page. </summary>
|
10 |
+
<description>Allow admin to add CAPTCHA on contact us page. And Manage from admin. </description>
|
11 |
+
<notes>Allow admin to add CAPTCHA on contact us page. And Manage from admin. </notes>
|
12 |
+
<authors><author><name>Envision Ecommerce</name><user>Envisionecom</user><email>magento@envisionecommerce.com</email></author></authors>
|
13 |
+
<date>2015-03-24</date>
|
14 |
+
<time>17:17:16</time>
|
15 |
+
<contents><target name="magelocal"><dir name="Eecom"><dir name="Addcaptcha"><dir name="Model"><file name="Observer.php" hash="68fec73fb382728755df0891eac7bd48"/></dir><dir name="etc"><file name="config.xml" hash="feb31557b6391cf196b14d0f3a5ec3dc"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="eecom_addcaptcha.xml" hash="27d7c75549476bb7a2855511820e907d"/></dir><dir name="template"><dir name="addcaptcha"><dir name="contacts"><file name="form.phtml" hash="eda91d4e644fe83ebdc25d3d129a72fa"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Eecom_Addcaptcha.xml" hash="e408ddcac5d2680b2ce8eefe62ebbd4e"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.5.0</min><max>1.9.0.1</max></package></required></dependencies>
|
18 |
+
</package>
|