Version Notes
Released new extension.
Download this release
Release Info
Developer | Sitewards Magento Team |
Extension | Sitewards_Captcha |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Sitewards/Captcha/Block/Sendfriend/Send.php +98 -0
- app/code/community/Sitewards/Captcha/Helper/Data.php +24 -0
- app/code/community/Sitewards/Captcha/Model/CaptchaChecker.php +118 -0
- app/code/community/Sitewards/Captcha/Model/Sendfriend.php +153 -0
- app/code/community/Sitewards/Captcha/controllers/ProductController.php +106 -0
- app/code/community/Sitewards/Captcha/etc/config.xml +105 -0
- app/code/community/Sitewards/Captcha/etc/system.xml +51 -0
- app/design/frontend/base/default/layout/sitewards/captcha.xml +38 -0
- app/design/frontend/base/default/template/sitewards/captcha/closepopup.phtml +16 -0
- app/design/frontend/base/default/template/sitewards/captcha/sendfriend/send.phtml +141 -0
- app/etc/modules/Sitewards_Captcha.xml +26 -0
- app/locale/de_DE/Sitewards_Captcha.csv +41 -0
- js/sitewards/captcha.js +41 -0
- package.xml +22 -0
app/code/community/Sitewards/Captcha/Block/Sendfriend/Send.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Sitewards_Captcha_Block_Sendfriend_Send
|
4 |
+
* - update the Mage_Sendfriend_Block_Send to allow customer edit product description and name
|
5 |
+
* - check if captcha required
|
6 |
+
*
|
7 |
+
* @category Sitewards
|
8 |
+
* @package Sitewards_Captcha
|
9 |
+
* @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
|
10 |
+
*/
|
11 |
+
class Sitewards_Captcha_Block_Sendfriend_Send extends Mage_Sendfriend_Block_Send {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Sendfriend product
|
15 |
+
*
|
16 |
+
* @var object Mage_Catalog_Model_Product
|
17 |
+
*/
|
18 |
+
protected $_oProduct = null;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Block id
|
22 |
+
*
|
23 |
+
* @type string
|
24 |
+
*/
|
25 |
+
const CAPTCHA_BLOCK_ID = 'sendfriend';
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Number of emails without captcha config path
|
29 |
+
*
|
30 |
+
* @type string
|
31 |
+
*/
|
32 |
+
const XML_PATH_MAX_TILL_CAPTCHA_TIMES = 'customer/captcha/max_till_captcha_times';
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Captcha Timeout config path
|
36 |
+
*
|
37 |
+
* @type string
|
38 |
+
*/
|
39 |
+
const XML_PATH_MAX_TILL_CAPTCHA_TIMEFRAME_SECONDS = 'customer/captcha/max_till_captcha_timeframe_seconds';
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Load the product object based on the requested Id
|
43 |
+
*/
|
44 |
+
public function _prepareLayout() {
|
45 |
+
$iProductId = $this->getRequest()->getParam('id', null);
|
46 |
+
$this->_oProduct = Mage::getModel('catalog/product')->load($iProductId);
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Load the message getData when it has been set,
|
51 |
+
* Else load the product description.
|
52 |
+
*
|
53 |
+
* @return string
|
54 |
+
*/
|
55 |
+
public function getMessage() {
|
56 |
+
$aFormData = $this->getFormData()->getData();
|
57 |
+
if(!empty($aFormData)) {
|
58 |
+
return $aFormData['sender']['message'];
|
59 |
+
} else {
|
60 |
+
return $this->getProductDescription();
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Retrieve Current Product Description
|
66 |
+
*
|
67 |
+
* @return string
|
68 |
+
*/
|
69 |
+
public function getProductDescription() {
|
70 |
+
return $this->_oProduct->getDescription();
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Retrieve Current Product Name
|
75 |
+
*
|
76 |
+
* @return string
|
77 |
+
*/
|
78 |
+
public function getProductName() {
|
79 |
+
return $this->_oProduct->getName();
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Check whether captcha should be displayed in the form
|
84 |
+
*
|
85 |
+
* @return boolean
|
86 |
+
*/
|
87 |
+
public function isCaptchaRequired(){
|
88 |
+
if (!Mage::helper('captcha')->isSendFriendCaptchaRequired()) {
|
89 |
+
return false;
|
90 |
+
}
|
91 |
+
$oCaptchaChecker = Mage::getModel('captcha/captchachecker');
|
92 |
+
return $oCaptchaChecker->isRequired(
|
93 |
+
self::CAPTCHA_BLOCK_ID,
|
94 |
+
Mage::getStoreConfig(self::XML_PATH_MAX_TILL_CAPTCHA_TIMES),
|
95 |
+
Mage::getStoreConfig(self::XML_PATH_MAX_TILL_CAPTCHA_TIMEFRAME_SECONDS)
|
96 |
+
);
|
97 |
+
}
|
98 |
+
}
|
app/code/community/Sitewards/Captcha/Helper/Data.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Sitewards_Captcha_Helper_Data
|
4 |
+
* - check if captcha is required
|
5 |
+
*
|
6 |
+
* @category Sitewards
|
7 |
+
* @package Sitewards_Captcha
|
8 |
+
* @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
|
9 |
+
*/
|
10 |
+
class Sitewards_Captcha_Helper_Data extends Mage_Captcha_Helper_Data {
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Returns if captcha is set to display for send to friend form
|
14 |
+
*
|
15 |
+
* @return bool
|
16 |
+
*/
|
17 |
+
public function isSendFriendCaptchaRequired() {
|
18 |
+
$oCaptchaModel = Mage::helper('captcha')->getCaptcha(Sitewards_Captcha_Model_Sendfriend::SEND_FRIEND_FORM_ID);
|
19 |
+
if (!$oCaptchaModel->isRequired()) {
|
20 |
+
return false;
|
21 |
+
}
|
22 |
+
return true;
|
23 |
+
}
|
24 |
+
}
|
app/code/community/Sitewards/Captcha/Model/CaptchaChecker.php
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Sitewards_Captcha_Model_CaptchaChecker
|
4 |
+
* - check if captcha is required
|
5 |
+
* - validate captcha
|
6 |
+
* - increment successful form submit
|
7 |
+
*
|
8 |
+
* @category Sitewards
|
9 |
+
* @package Sitewards_Captcha
|
10 |
+
* @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
|
11 |
+
*/
|
12 |
+
class Sitewards_Captcha_Model_CaptchaChecker extends Mage_Core_Model_Abstract {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Customer session
|
16 |
+
*
|
17 |
+
* @var Mage_Core_Model_Abstract
|
18 |
+
*/
|
19 |
+
private $oCustomerSession = null;
|
20 |
+
|
21 |
+
|
22 |
+
public function __construct(){
|
23 |
+
$this->oCustomerSession = Mage::getSingleton('customer/session');
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Checks if the captcha should be displayed in the form
|
28 |
+
*
|
29 |
+
*
|
30 |
+
* @param string $sIdBlock unique string to get the right counter
|
31 |
+
* @param integer $iMaxPerTimeframe max. number of sending the form before captcha should be displayed
|
32 |
+
* @param integer $iTimeframeSeconds timeframe within which the counter should get the max value to make the captcha displayed
|
33 |
+
* @return boolean
|
34 |
+
*/
|
35 |
+
public function isRequired($sIdBlock, $iMaxPerTimeframe, $iTimeframeSeconds){
|
36 |
+
$iTimesInTimeframe = 0;
|
37 |
+
$aCounter = $this->getCounter($sIdBlock);
|
38 |
+
foreach ($aCounter as $iTimestamp){
|
39 |
+
if ($iTimestamp > time() - $iTimeframeSeconds){
|
40 |
+
$iTimesInTimeframe++;
|
41 |
+
}
|
42 |
+
}
|
43 |
+
if ($iTimesInTimeframe >= $iMaxPerTimeframe){
|
44 |
+
return true;
|
45 |
+
} else {
|
46 |
+
return false;
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Gets the counter for a particular block based on the block id
|
52 |
+
* Returns the array of the form
|
53 |
+
* Array(
|
54 |
+
* 'key' => 'timestamp_of_the_counter_inc',
|
55 |
+
* ...
|
56 |
+
* )
|
57 |
+
*
|
58 |
+
* @param string $sIdBlock
|
59 |
+
* @return array
|
60 |
+
*/
|
61 |
+
private function getCounter($sIdBlock){
|
62 |
+
$aCaptchaCheckerSession = $this->oCustomerSession->getData('captchachecker');
|
63 |
+
if (isset($aCaptchaCheckerSession[$sIdBlock])){
|
64 |
+
return $aCaptchaCheckerSession[$sIdBlock];
|
65 |
+
} else {
|
66 |
+
return array();
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Sets the counter
|
72 |
+
* Overwrites the counter for a certain block id with a new counter array
|
73 |
+
*
|
74 |
+
* @param string $sIdBlock
|
75 |
+
* @param array $aCounter
|
76 |
+
* @return Sitewards_Captcha_Model_CaptchaChecker
|
77 |
+
*/
|
78 |
+
private function setCounter($sIdBlock, $aCounter){
|
79 |
+
$aCaptchaCheckerSession = $this->oCustomerSession->getData('captchachecker');
|
80 |
+
$aCaptchaCheckerSession[$sIdBlock] = $aCounter;
|
81 |
+
$this->oCustomerSession->setData('captchachecker', $aCaptchaCheckerSession);
|
82 |
+
return $this;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Increments the counter with a certain block id
|
87 |
+
*
|
88 |
+
* @param string $sIdBlock
|
89 |
+
* @return Sitewards_Captcha_Model_CaptchaChecker
|
90 |
+
*/
|
91 |
+
public function incCounter($sIdBlock){
|
92 |
+
$aCounter = $this->getCounter($sIdBlock);
|
93 |
+
$aCounter[] = time();
|
94 |
+
$this->setCounter($sIdBlock, $aCounter);
|
95 |
+
return $this;
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Checks if the captcha provided in the post form is valid
|
100 |
+
*
|
101 |
+
* @return boolean
|
102 |
+
*/
|
103 |
+
public function isValidCaptcha(){
|
104 |
+
$aCaptchaFormValues = Mage::app()->getRequest()->getParam('captcha');
|
105 |
+
$bValid = true;
|
106 |
+
// for the case that we have more than one captcha
|
107 |
+
// in the form, every captcha should be validated
|
108 |
+
if (is_array($aCaptchaFormValues)){
|
109 |
+
foreach ($aCaptchaFormValues as $sCaptchaName => $sCaptchaValue){
|
110 |
+
$oCaptchaModel = Mage::helper('captcha')->getCaptcha($sCaptchaName);
|
111 |
+
if (!$oCaptchaModel->isCorrect($sCaptchaValue)){
|
112 |
+
$bValid = false;
|
113 |
+
}
|
114 |
+
}
|
115 |
+
}
|
116 |
+
return $bValid;
|
117 |
+
}
|
118 |
+
}
|
app/code/community/Sitewards/Captcha/Model/Sendfriend.php
ADDED
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Sitewards_Captcha_Model_Sendfriend
|
4 |
+
* - override Mage_Sendfriend_Model_Sendfriend
|
5 |
+
* - set the correct product url in the email sent
|
6 |
+
* - send customer modified product name
|
7 |
+
* - validate captcha
|
8 |
+
*
|
9 |
+
* @category Sitewards
|
10 |
+
* @package Sitewards_Captcha
|
11 |
+
* @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
|
12 |
+
*/
|
13 |
+
class Sitewards_Captcha_Model_Sendfriend extends Mage_Sendfriend_Model_Sendfriend {
|
14 |
+
|
15 |
+
const SEND_FRIEND_FORM_ID = 'product_sendtofriend_form_captcha';
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Update the send email function to set the correct product url in the email a friend
|
19 |
+
*
|
20 |
+
* @see Mage_Sendfriend_Model_Sendfriend::send()
|
21 |
+
*/
|
22 |
+
public function send() {
|
23 |
+
|
24 |
+
if ($this->isExceedLimit()){
|
25 |
+
Mage::throwException(Mage::helper('sendfriend')->__('You have exceeded limit of %d sends in an hour', $this->getMaxSendsToFriend()));
|
26 |
+
}
|
27 |
+
|
28 |
+
/* @var $oTranslate Mage_Core_Model_Translate */
|
29 |
+
$oTranslate = Mage::getSingleton('core/translate');
|
30 |
+
$oTranslate->setTranslateInline(false);
|
31 |
+
|
32 |
+
/* @var $oMailTemplate Mage_Core_Model_Email_Template */
|
33 |
+
$oMailTemplate = Mage::getModel('core/email_template');
|
34 |
+
|
35 |
+
$sMessage = nl2br(htmlspecialchars($this->getSender()->getMessage()));
|
36 |
+
$sPName = nl2br(htmlspecialchars($this->getSender()->getProductName()));
|
37 |
+
|
38 |
+
$sSender = array(
|
39 |
+
'name' => $this->_getHelper()->htmlEscape($this->getSender()->getName()),
|
40 |
+
'email' => $this->_getHelper()->htmlEscape($this->getSender()->getEmail())
|
41 |
+
);
|
42 |
+
$aShopSender = array(
|
43 |
+
'name'=> Mage::getStoreConfig('trans_email/ident_general/name'),
|
44 |
+
'email'=> Mage::getStoreConfig('trans_email/ident_general/email')
|
45 |
+
);
|
46 |
+
|
47 |
+
$oMailTemplate->setDesignConfig(array(
|
48 |
+
'area' => 'frontend',
|
49 |
+
'store' => Mage::app()->getStore()->getId()
|
50 |
+
));
|
51 |
+
|
52 |
+
foreach ($this->getRecipients()->getEmails() as $iEmailKey => $sEmail) {
|
53 |
+
$sName = $this->getRecipients()->getNames($iEmailKey);
|
54 |
+
$oMailTemplate->sendTransactional(
|
55 |
+
$this->getTemplate(),
|
56 |
+
$aShopSender,
|
57 |
+
$sEmail,
|
58 |
+
$sName,
|
59 |
+
array(
|
60 |
+
'name' => $sName,
|
61 |
+
'email' => $sEmail,
|
62 |
+
'product_name' => $sPName,
|
63 |
+
'telephone' => Mage::getStoreConfig('general/store_information/phone'),
|
64 |
+
'product_url' => Mage::app()->getStore()->getBaseUrl().$this->getProduct()->getRequestPath().$this->getProduct()->getUrlPath(),
|
65 |
+
'message' => $sMessage,
|
66 |
+
'sender_name' => $sSender['name'],
|
67 |
+
'sender_email' => $sSender['email'],
|
68 |
+
'product_image' => Mage::helper('catalog/image')->init($this->getProduct(),'small_image')->resize(75),
|
69 |
+
)
|
70 |
+
);
|
71 |
+
}
|
72 |
+
|
73 |
+
$oTranslate->setTranslateInline(true);
|
74 |
+
$this->_incrementSentCount();
|
75 |
+
|
76 |
+
return $this;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Additionally checks if the captcha is required for the form and if so, if it is valid
|
81 |
+
*
|
82 |
+
* @see Mage_Sendfriend_Model_Sendfriend::validate()
|
83 |
+
*/
|
84 |
+
public function validate()
|
85 |
+
{
|
86 |
+
$aErrors = array();
|
87 |
+
|
88 |
+
$sName = $this->getSender()->getName();
|
89 |
+
if (empty($sName)) {
|
90 |
+
$aErrors[] = Mage::helper('sendfriend')->__('The sender name cannot be empty.');
|
91 |
+
}
|
92 |
+
|
93 |
+
$sEmail = $this->getSender()->getEmail();
|
94 |
+
if (empty($sEmail) OR !Zend_Validate::is($sEmail, 'EmailAddress')) {
|
95 |
+
$aErrors[] = Mage::helper('sendfriend')->__('Invalid sender email.');
|
96 |
+
}
|
97 |
+
|
98 |
+
if (!$this->getRecipients()->getEmails()) {
|
99 |
+
$aErrors[] = Mage::helper('sendfriend')->__('At least one recipient must be specified.');
|
100 |
+
}
|
101 |
+
|
102 |
+
// validate recipients email addresses
|
103 |
+
foreach ($this->getRecipients()->getEmails() as $sEmail) {
|
104 |
+
if (!Zend_Validate::is($sEmail, 'EmailAddress')) {
|
105 |
+
$aErrors[] = Mage::helper('sendfriend')->__('An invalid email address for recipient was entered.');
|
106 |
+
break;
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
// validate recipients name
|
111 |
+
foreach ($this->getRecipients()->getNames() as $sName) {
|
112 |
+
if (empty($sName)) {
|
113 |
+
$aErrors[] = Mage::helper('sendfriend')->__('At least one recipient must be specified.');
|
114 |
+
break;
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
$sProductName = $this->getProduct()->getName();
|
119 |
+
if(empty($sProductName)) {
|
120 |
+
$aErrors[] = Mage::helper('sendfriend')->__('The product name cannot be empty.');
|
121 |
+
}
|
122 |
+
|
123 |
+
$iMaxRecipients = $this->getMaxRecipients();
|
124 |
+
if (count($this->getRecipients()->getEmails()) > $iMaxRecipients) {
|
125 |
+
$aErrors[] = Mage::helper('sendfriend')->__('No more than %d emails can be sent at a time.', $this->getMaxRecipients());
|
126 |
+
}
|
127 |
+
|
128 |
+
$oCaptchaChecker = Mage::getModel('captcha/captchachecker');
|
129 |
+
$bCaptchaRequired = $oCaptchaChecker->isRequired(
|
130 |
+
Sitewards_Captcha_Block_Sendfriend_Send::CAPTCHA_BLOCK_ID,
|
131 |
+
Sitewards_Captcha_Block_Sendfriend_Send::XML_PATH_MAX_TILL_CAPTCHA_TIMES,
|
132 |
+
Sitewards_Captcha_Block_Sendfriend_Send::XML_PATH_MAX_TILL_CAPTCHA_TIMEFRAME_SECONDS
|
133 |
+
);
|
134 |
+
|
135 |
+
if ($bCaptchaRequired){
|
136 |
+
if (!$oCaptchaChecker->isValidCaptcha()){
|
137 |
+
$sErrorMessage = Mage::helper('captcha')->__('Incorrect Captcha Code');
|
138 |
+
if (!is_array($aErrors)){
|
139 |
+
$aErrors = array( $sErrorMessage );
|
140 |
+
} else {
|
141 |
+
$aErrors[] = $sErrorMessage;
|
142 |
+
}
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
if (empty($aErrors)) {
|
147 |
+
return true;
|
148 |
+
}
|
149 |
+
|
150 |
+
return $aErrors;
|
151 |
+
}
|
152 |
+
|
153 |
+
}
|
app/code/community/Sitewards/Captcha/controllers/ProductController.php
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Sitewards_Captcha_ProductController
|
4 |
+
* Override Mage_Sendfriend_ProductController action sendmailAction to work with the pop up and not the normal form
|
5 |
+
*
|
6 |
+
* @category Sitewards
|
7 |
+
* @package Sitewards_Captcha
|
8 |
+
* @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
|
9 |
+
*/
|
10 |
+
require_once 'Mage/Sendfriend/controllers/ProductController.php';
|
11 |
+
class Sitewards_Captcha_ProductController extends Mage_Sendfriend_ProductController {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Send Email Post Action and increase the counter for the captcha displaying feature
|
15 |
+
* Work with the javascript pop-up and not just the normal form
|
16 |
+
* redirects to the form if the form key is not valid or the fields validation failed.
|
17 |
+
* Otherwise sets body to "success" to reload the page and exit the popup
|
18 |
+
*
|
19 |
+
*
|
20 |
+
* @return void
|
21 |
+
*/
|
22 |
+
public function sendmailAction() {
|
23 |
+
if (!$this->_validateFormKey()) {
|
24 |
+
return $this->_redirect('*/*/send', array('_current' => true));
|
25 |
+
}
|
26 |
+
|
27 |
+
/* @var $oProduct Mage_Catalog_Model_Product */
|
28 |
+
$oProduct = $this->_initProduct();
|
29 |
+
/* @var $oSendToFriendModel Mage_Sendfriend_Model_Sendfriend */
|
30 |
+
$oSendToFriendModel = $this->_initSendToFriendModel();
|
31 |
+
$aFormData = $this->getRequest()->getPost();
|
32 |
+
|
33 |
+
if (!$oProduct || !$aFormData) {
|
34 |
+
$this->_forward('noRoute');
|
35 |
+
return;
|
36 |
+
}
|
37 |
+
|
38 |
+
$iCategoryId = $this->getRequest()->getParam('cat_id', null);
|
39 |
+
if ($iCategoryId) {
|
40 |
+
/* @var $oCategory Mage_Catalog_Model_Category */
|
41 |
+
$oCategory = Mage::getModel('catalog/category')
|
42 |
+
->load($iCategoryId);
|
43 |
+
$oProduct->setCategory($oCategory);
|
44 |
+
Mage::register('current_category', $oCategory);
|
45 |
+
}
|
46 |
+
|
47 |
+
$aSender = $this->getRequest()->getPost('sender');
|
48 |
+
|
49 |
+
$oSendToFriendModel->setSender($aSender);
|
50 |
+
$oSendToFriendModel->setRecipients($this->getRequest()->getPost('recipients'));
|
51 |
+
$oSendToFriendModel->setProduct($oProduct);
|
52 |
+
|
53 |
+
try {
|
54 |
+
$mValidate = $oSendToFriendModel->validate();
|
55 |
+
if ($mValidate === true) {
|
56 |
+
$oSendToFriendModel->send();
|
57 |
+
Mage::getSingleton('catalog/session')->addSuccess($this->__('The link to a friend was sent.'));
|
58 |
+
|
59 |
+
// increase counter for captcha limits
|
60 |
+
if (Mage::helper('captcha')->isSendFriendCaptchaRequired()) {
|
61 |
+
$oCaptchaChecker = Mage::getModel('captcha/captchachecker');
|
62 |
+
$oCaptchaChecker->incCounter(Sitewards_Captcha_Block_Sendfriend_Send::CAPTCHA_BLOCK_ID);
|
63 |
+
}
|
64 |
+
|
65 |
+
$this->_redirect('*/*/closepopup', array('id' => $oProduct->getId()));
|
66 |
+
return;
|
67 |
+
} else {
|
68 |
+
if (is_array($mValidate)) {
|
69 |
+
foreach ($mValidate as $sErrorMessage) {
|
70 |
+
Mage::getSingleton('catalog/session')->addError($sErrorMessage);
|
71 |
+
}
|
72 |
+
} else {
|
73 |
+
Mage::getSingleton('catalog/session')->addError($this->__('There were some problems with the data.'));
|
74 |
+
}
|
75 |
+
}
|
76 |
+
} catch (Mage_Core_Exception $oException) {
|
77 |
+
Mage::getSingleton('catalog/session')->addError($oException->getMessage());
|
78 |
+
} catch (Exception $oException) {
|
79 |
+
Mage::getSingleton('catalog/session')
|
80 |
+
->addException($oException, $this->__('Some emails were not sent.'));
|
81 |
+
}
|
82 |
+
|
83 |
+
// save form data
|
84 |
+
Mage::getSingleton('catalog/session')->setSendfriendFormData($aFormData);
|
85 |
+
|
86 |
+
$this->_redirectError(Mage::getURL('*/*/send', array('_current' => true)));
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Renders html page which contains javascript
|
91 |
+
* to close the popup and redirect to product page
|
92 |
+
*/
|
93 |
+
public function closepopupAction() {
|
94 |
+
/* @var $oProduct Mage_Catalog_Model_Product */
|
95 |
+
$oProduct = $this->_initProduct();
|
96 |
+
$oBlock = $this->getLayout()->createBlock(
|
97 |
+
'Mage_Core_Block_Template',
|
98 |
+
'closepopup',
|
99 |
+
array('template' => 'sitewards/captcha/closepopup.phtml')
|
100 |
+
);
|
101 |
+
$oBlock->setRedirectUrl($oProduct->getProductUrl());
|
102 |
+
$this->getResponse()->setBody(
|
103 |
+
$oBlock->toHtml()
|
104 |
+
);
|
105 |
+
}
|
106 |
+
}
|
app/code/community/Sitewards/Captcha/etc/config.xml
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* The main config file
|
5 |
+
*
|
6 |
+
* @category Sitewards
|
7 |
+
* @package Sitewards_Captcha
|
8 |
+
* @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
|
9 |
+
*/
|
10 |
+
-->
|
11 |
+
<config>
|
12 |
+
<modules>
|
13 |
+
<Sitewards_Captcha>
|
14 |
+
<version>1.0.0</version>
|
15 |
+
</Sitewards_Captcha>
|
16 |
+
</modules>
|
17 |
+
<global>
|
18 |
+
<blocks>
|
19 |
+
<sendfriend>
|
20 |
+
<rewrite>
|
21 |
+
<send>Sitewards_Captcha_Block_Sendfriend_Send</send>
|
22 |
+
</rewrite>
|
23 |
+
</sendfriend>
|
24 |
+
<sitewards_captcha>
|
25 |
+
<class>Sitewards_Captcha_Block</class>
|
26 |
+
</sitewards_captcha>
|
27 |
+
</blocks>
|
28 |
+
<helpers>
|
29 |
+
<captcha>
|
30 |
+
<rewrite>
|
31 |
+
<data>Sitewards_Captcha_Helper_Data</data>
|
32 |
+
</rewrite>
|
33 |
+
</captcha>
|
34 |
+
</helpers>
|
35 |
+
<models>
|
36 |
+
<captcha>
|
37 |
+
<rewrite>
|
38 |
+
<captchachecker>Sitewards_Captcha_Model_CaptchaChecker</captchachecker>
|
39 |
+
</rewrite>
|
40 |
+
</captcha>
|
41 |
+
<sendfriend>
|
42 |
+
<rewrite>
|
43 |
+
<sendfriend>Sitewards_Captcha_Model_Sendfriend</sendfriend>
|
44 |
+
</rewrite>
|
45 |
+
</sendfriend>
|
46 |
+
</models>
|
47 |
+
</global>
|
48 |
+
<frontend>
|
49 |
+
<layout>
|
50 |
+
<updates>
|
51 |
+
<sitewards_productemail>
|
52 |
+
<file>sitewards/captcha.xml</file>
|
53 |
+
</sitewards_productemail>
|
54 |
+
</updates>
|
55 |
+
</layout>
|
56 |
+
<routers>
|
57 |
+
<sendfriend>
|
58 |
+
<args>
|
59 |
+
<modules>
|
60 |
+
<Sitewards_Captcha before="Mage_Sendfriend">Sitewards_Captcha</Sitewards_Captcha>
|
61 |
+
</modules>
|
62 |
+
</args>
|
63 |
+
</sendfriend>
|
64 |
+
</routers>
|
65 |
+
<translate>
|
66 |
+
<modules>
|
67 |
+
<Sitewards_Captcha>
|
68 |
+
<files>
|
69 |
+
<default>Sitewards_Captcha.csv</default>
|
70 |
+
</files>
|
71 |
+
</Sitewards_Captcha>
|
72 |
+
</modules>
|
73 |
+
</translate>
|
74 |
+
</frontend>
|
75 |
+
<default>
|
76 |
+
<sendfriend>
|
77 |
+
<email>
|
78 |
+
<enabled>1</enabled>
|
79 |
+
<template>sendfriend_email_template</template>
|
80 |
+
<allow_guest>1</allow_guest>
|
81 |
+
<max_recipients>5</max_recipients>
|
82 |
+
<max_per_hour>999</max_per_hour>
|
83 |
+
<check_by>0</check_by>
|
84 |
+
</email>
|
85 |
+
</sendfriend>
|
86 |
+
<customer>
|
87 |
+
<captcha>
|
88 |
+
<always_for>
|
89 |
+
<product_sendtofriend_form_captcha>1</product_sendtofriend_form_captcha>
|
90 |
+
</always_for>
|
91 |
+
<max_till_captcha_times>3</max_till_captcha_times>
|
92 |
+
<max_till_captcha_timeframe_seconds>3600</max_till_captcha_timeframe_seconds>
|
93 |
+
</captcha>
|
94 |
+
</customer>
|
95 |
+
<captcha translate="label">
|
96 |
+
<frontend>
|
97 |
+
<areas>
|
98 |
+
<product_sendtofriend_form_captcha>
|
99 |
+
<label>Email to a Friend</label>
|
100 |
+
</product_sendtofriend_form_captcha>
|
101 |
+
</areas>
|
102 |
+
</frontend>
|
103 |
+
</captcha>
|
104 |
+
</default>
|
105 |
+
</config>
|
app/code/community/Sitewards/Captcha/etc/system.xml
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
*
|
5 |
+
* @category Sitewards
|
6 |
+
* @package Sitewards_Captcha
|
7 |
+
* @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<sections>
|
12 |
+
<customer>
|
13 |
+
<groups>
|
14 |
+
<captcha>
|
15 |
+
<fields>
|
16 |
+
<heading_3dsecure translate="label">
|
17 |
+
<label>Email to a Friend</label>
|
18 |
+
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
19 |
+
<sort_order>120</sort_order>
|
20 |
+
<show_in_default>1</show_in_default>
|
21 |
+
<show_in_website>1</show_in_website>
|
22 |
+
<depends><enable>1</enable></depends>
|
23 |
+
</heading_3dsecure>
|
24 |
+
<max_till_captcha_times translate="label">
|
25 |
+
<label>Number of emails without captcha</label>
|
26 |
+
<frontend_type>text</frontend_type>
|
27 |
+
<sort_order>130</sort_order>
|
28 |
+
<show_in_default>1</show_in_default>
|
29 |
+
<show_in_website>1</show_in_website>
|
30 |
+
<show_in_store>0</show_in_store>
|
31 |
+
<depends><enable>1</enable></depends>
|
32 |
+
<frontend_class>required-entry validate-digits</frontend_class>
|
33 |
+
</max_till_captcha_times >
|
34 |
+
<max_till_captcha_timeframe_seconds translate="label">
|
35 |
+
<label>CAPTCHA Timeout (seconds)</label>
|
36 |
+
<frontend_type>text</frontend_type>
|
37 |
+
<sort_order>140</sort_order>
|
38 |
+
<show_in_default>1</show_in_default>
|
39 |
+
<show_in_website>1</show_in_website>
|
40 |
+
<show_in_store>0</show_in_store>
|
41 |
+
<depends><enable>1</enable></depends>
|
42 |
+
<frontend_class>required-entry validate-digits</frontend_class>
|
43 |
+
</max_till_captcha_timeframe_seconds>
|
44 |
+
</fields>
|
45 |
+
</captcha>
|
46 |
+
</groups>
|
47 |
+
</customer>
|
48 |
+
</sections>
|
49 |
+
</config>
|
50 |
+
|
51 |
+
|
app/design/frontend/base/default/layout/sitewards/captcha.xml
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* sitewards/captcha.xml
|
5 |
+
* Layout file for the Sitewards Captcha module
|
6 |
+
*
|
7 |
+
* @category Sitewards
|
8 |
+
* @package Sitewards_Captcha
|
9 |
+
* @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
|
10 |
+
*/
|
11 |
+
-->
|
12 |
+
<layout>
|
13 |
+
<sendfriend_product_send>
|
14 |
+
<reference name="root">
|
15 |
+
<action method="setTemplate"><template>page/popup.phtml</template></action>
|
16 |
+
</reference>
|
17 |
+
<reference name="sendfriend.send">
|
18 |
+
<action method="setTemplate"><template>sitewards/captcha/sendfriend/send.phtml</template></action>
|
19 |
+
</reference>
|
20 |
+
<block type="captcha/captcha" name="captcha.sendtofriend">
|
21 |
+
<reference name="head">
|
22 |
+
<action method="addJs"><file>mage/captcha.js</file></action>
|
23 |
+
</reference>
|
24 |
+
<action method="setFormId"><formId>product_sendtofriend_form_captcha</formId></action>
|
25 |
+
</block>
|
26 |
+
</sendfriend_product_send>
|
27 |
+
<sendfriend_product_closepopup>
|
28 |
+
<block type="page/html" name="root" template="sitewards/captcha/closepopup.phtml"></block>
|
29 |
+
</sendfriend_product_closepopup>
|
30 |
+
<catalog_product_view>
|
31 |
+
<reference name="head">
|
32 |
+
<action method="addItem"><type>js</type><name>prototype/window.js</name></action>
|
33 |
+
<action method="addItem"><type>js_css</type><name>prototype/windows/themes/default.css</name></action>
|
34 |
+
<action method="addCss"><name>lib/prototype/windows/themes/magento.css</name></action>
|
35 |
+
<action method="addItem"><type>js</type><name>sitewards/captcha.js</name></action>
|
36 |
+
</reference>
|
37 |
+
</catalog_product_view>
|
38 |
+
</layout>
|
app/design/frontend/base/default/template/sitewards/captcha/closepopup.phtml
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Close popup window and redirect to product page
|
4 |
+
*
|
5 |
+
* @category Sitewards
|
6 |
+
* @package Sitewards_Captcha
|
7 |
+
* @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
|
8 |
+
*/
|
9 |
+
/* @var $this Mage_Core_Block_Template */
|
10 |
+
?>
|
11 |
+
<script type="text/javascript">
|
12 |
+
// <![CDATA[
|
13 |
+
this.parent.closePopup();
|
14 |
+
window.parent.location.href = '<?php echo $this->getRedirectUrl()?>';
|
15 |
+
// ]]>
|
16 |
+
</script>
|
app/design/frontend/base/default/template/sitewards/captcha/sendfriend/send.phtml
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Send to friend form
|
4 |
+
*
|
5 |
+
* @see Mage_Sendfriend_Block_Send
|
6 |
+
*
|
7 |
+
* @category Sitewards
|
8 |
+
* @package Sitewards_Captcha
|
9 |
+
* @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/)
|
10 |
+
*/
|
11 |
+
/* @var $this Mage_Sendfriend_Block_Send */
|
12 |
+
?>
|
13 |
+
<script type="text/javascript">
|
14 |
+
//<![CDATA[
|
15 |
+
i=0;
|
16 |
+
var recipCount = 1;
|
17 |
+
var maxRecip = <?php echo $this->getMaxRecipients() ?>;
|
18 |
+
function remove_recipient(i){
|
19 |
+
$('recipients_name'+i).up(2).remove();
|
20 |
+
recipCount--;
|
21 |
+
if(recipCount<maxRecip && maxRecip != 0) {
|
22 |
+
$('add_recipient_button').show();
|
23 |
+
$('max_recipient_message').hide();
|
24 |
+
}
|
25 |
+
return false;
|
26 |
+
}
|
27 |
+
|
28 |
+
function add_recipient(){
|
29 |
+
ul = $('recipients_options');
|
30 |
+
var li_mail = Element.extend(document.createElement("LI"));
|
31 |
+
li_mail.addClassName('fields additional-row');
|
32 |
+
li_mail.innerHTML = '<p><a href="delete_email" title="<?php echo $this->__('Remove Email') ?>" onclick="remove_recipient('+i+'); return false" class="btn-remove"><?php echo $this->__('Remove Email') ?>"<\/a><\/p>'
|
33 |
+
li_mail.innerHTML += '<div class="field"><label for="recipients_name'+i+'" class="required"><em>*<\/em><?php echo $this->__('Name:') ?><\/label><div class="input-box"><input name="recipients[name][]" type="text" class="input-text required-entry" id="recipients_name'+i+'" /><\/div>';
|
34 |
+
li_mail.innerHTML += '<div class="field"><label for="recipients_email'+i+'" class="required"><em>*<\/em><?php echo $this->__('Email Address:') ?><\/label><div class="input-box"><input name="recipients[email][]" value="" title="<?php echo $this->__('Email Address') ?>" id="recipients_email'+i+'" type="text" class="input-text required-entry validate-email" /><\/div><\/div>';
|
35 |
+
i++;
|
36 |
+
recipCount++;
|
37 |
+
if(recipCount>=maxRecip && maxRecip != 0) {
|
38 |
+
$('add_recipient_button').hide();
|
39 |
+
$('max_recipient_message').show();
|
40 |
+
}
|
41 |
+
|
42 |
+
ul.appendChild(li_mail);
|
43 |
+
}
|
44 |
+
//]]>
|
45 |
+
</script>
|
46 |
+
|
47 |
+
<div class="send-friend">
|
48 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
49 |
+
<div class="page-title">
|
50 |
+
<h1><?php echo $this->__('Email to a Friend') ?></h1>
|
51 |
+
</div>
|
52 |
+
<form action="<?php echo $this->getSendUrl() ?>" method="post" id="product_sendtofriend_form">
|
53 |
+
<div class="fieldset">
|
54 |
+
<?php echo $this->getBlockHtml('formkey')?>
|
55 |
+
<h2 class="legend"><?php echo $this->__('Sender:') ?></h2>
|
56 |
+
<ul class="form-list" id="sender_options">
|
57 |
+
<li class="fields">
|
58 |
+
<div class="field">
|
59 |
+
<label for="sender_name" class="required"><em>*</em><?php echo $this->__('Name:') ?></label>
|
60 |
+
<div class="input-box">
|
61 |
+
<input name="sender[name]" value="<?php echo $this->htmlEscape($this->getUserName()) ?>" title="<?php echo $this->__('Name') ?>" id="sender_name" type="text" class="input-text required-entry" />
|
62 |
+
</div>
|
63 |
+
</div>
|
64 |
+
<div class="field">
|
65 |
+
<label for="sender_email" class="required"><em>*</em><?php echo $this->__('Email:') ?></label>
|
66 |
+
<div class="input-box">
|
67 |
+
<input name="sender[email]" value="<?php echo $this->htmlEscape($this->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" id="sender_email" type="text" class="input-text required-entry validate-email" />
|
68 |
+
</div>
|
69 |
+
</div>
|
70 |
+
</li>
|
71 |
+
<li>
|
72 |
+
<label for="sender_product_name" class="required"><em>*</em><?php echo $this->__('Product Name:') ?></label>
|
73 |
+
<div class="input-box">
|
74 |
+
<input name="sender[product_name]" value="<?php echo $this->htmlEscape($this->getProductName()) ?>" title="<?php echo $this->__('Product Name') ?>" id="sender_product_name" type="text" class="input-text required-entry" />
|
75 |
+
</div>
|
76 |
+
</li>
|
77 |
+
<li class="wide">
|
78 |
+
<label for="sender_message" class="required"><?php echo $this->__('Message:') ?></label>
|
79 |
+
<div class="input-box">
|
80 |
+
<textarea name="sender[message]" class="input-text" id="sender_message" cols="3" rows="3"><?php echo $this->htmlEscape($this->getMessage())?></textarea>
|
81 |
+
</div>
|
82 |
+
</li>
|
83 |
+
</ul>
|
84 |
+
</div>
|
85 |
+
<div class="fieldset">
|
86 |
+
<h2 class="legend"><?php echo $this->__('Recipient:') ?></h2>
|
87 |
+
<ul class="form-list" id="recipients_options">
|
88 |
+
<li class="fields">
|
89 |
+
<div class="field">
|
90 |
+
<label for="recipients_name" class="required"><em>*</em><?php echo $this->__('Name:') ?></label>
|
91 |
+
<div class="input-box">
|
92 |
+
<input name="recipients[name][]" type="text" class="input-text required-entry" id="recipients_name" />
|
93 |
+
</div>
|
94 |
+
</div>
|
95 |
+
<div class="field">
|
96 |
+
<label for="recipients_email" class="required"><em>*</em><?php echo $this->__('Email Address:') ?></label>
|
97 |
+
<div class="input-box">
|
98 |
+
<input name="recipients[email][]" value="" title="<?php echo $this->__('Email Address') ?>" id="recipients_email" type="text" class="input-text required-entry validate-email" />
|
99 |
+
</div>
|
100 |
+
</div>
|
101 |
+
</li>
|
102 |
+
</ul>
|
103 |
+
</div>
|
104 |
+
<?php if ($this->isCaptchaRequired()):?>
|
105 |
+
<div class="fieldset">
|
106 |
+
<h2 class="legend"><?php echo $this->__('Captcha:') ?></h2>
|
107 |
+
<ul class="form-list" id="recipients_options">
|
108 |
+
<?php
|
109 |
+
$oCaptchaBlock = Mage::getBlockSingleton('captcha/captcha')
|
110 |
+
->setFormId('product_sendtofriend_form_captcha')
|
111 |
+
->setShowCaptcha(true);
|
112 |
+
echo $oCaptchaBlock->toHtml();
|
113 |
+
?>
|
114 |
+
</ul>
|
115 |
+
</div>
|
116 |
+
<?php endif;?>
|
117 |
+
<div class="buttons-set">
|
118 |
+
<button type="submit" class="button<?php if (!$this->canSend()):?> disabled<?php endif ?>"<?php if (!$this->canSend()):?> disabled="disabled"<?php endif ?>><span><span><?php echo $this->__('Send Email') ?></span></span></button>
|
119 |
+
<div id="max_recipient_message" style="display:none;">
|
120 |
+
<?php if ($this->getMaxRecipients()): ?>
|
121 |
+
<p class="limit"><?php echo $this->__('Maximum %d email addresses allowed.', $this->getMaxRecipients()) ?></p>
|
122 |
+
<?php endif; ?>
|
123 |
+
</div>
|
124 |
+
<?php if (1 < $this->getMaxRecipients()): ?>
|
125 |
+
<p id="add_recipient_button">
|
126 |
+
<button type="button" onclick="add_recipient();" class="button"><span><span><?php echo $this->__('Add Recipient') ?></span></span></button>
|
127 |
+
</p>
|
128 |
+
<?php endif; ?>
|
129 |
+
</div>
|
130 |
+
</form>
|
131 |
+
<script type="text/javascript">
|
132 |
+
//<![CDATA[
|
133 |
+
var productSendtofriendForm = new VarienForm('product_sendtofriend_form');
|
134 |
+
productSendtofriendForm.submit = function() {
|
135 |
+
if(this.validator.validate()) {
|
136 |
+
this.form.submit();
|
137 |
+
}
|
138 |
+
}.bind(productSendtofriendForm);
|
139 |
+
//]]>
|
140 |
+
</script>
|
141 |
+
</div>
|
app/etc/modules/Sitewards_Captcha.xml
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Sitewards_Captcha.xml
|
5 |
+
* - Activate module,
|
6 |
+
* - Specify code pool,
|
7 |
+
* - Set-up dependencies
|
8 |
+
*
|
9 |
+
* @category Sitewards
|
10 |
+
* @package Sitewards_Captcha
|
11 |
+
* @copyright Copyright (c) 2013 Sitewards GmbH (http://www.sitewards.com/de/)
|
12 |
+
*/
|
13 |
+
-->
|
14 |
+
<config>
|
15 |
+
<modules>
|
16 |
+
<Sitewards_Captcha>
|
17 |
+
<active>true</active>
|
18 |
+
<codePool>community</codePool>
|
19 |
+
<depends>
|
20 |
+
<Mage_Catalog />
|
21 |
+
<Mage_Sendfriend />
|
22 |
+
<Mage_Captcha />
|
23 |
+
</depends>
|
24 |
+
</Sitewards_Captcha>
|
25 |
+
</modules>
|
26 |
+
</config>
|
app/locale/de_DE/Sitewards_Captcha.csv
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"Add Recipient","Empfänger hinzufügen"
|
2 |
+
"Allow for Guests","Für Gäste erlauben"
|
3 |
+
"Mage_Sendfriend::An invalid email address for recipient was entered.","Sie haben eine ungültige Empfänger E-Mail-Adresse eingegeben."
|
4 |
+
"At least one recipient must be specified.","Es muss mindestens ein Empfänger eingetragen werden."
|
5 |
+
"Back","Zurück"
|
6 |
+
"Catalog Product Email to a Friend","Produkt aus dem Katalog per E-Mail an einen Freund senden"
|
7 |
+
"Email Address","E-Mail-Adresse"
|
8 |
+
"Email Address:","E-Mail-Adresse:"
|
9 |
+
"Email Templates","E-Mail Vorlagen"
|
10 |
+
"Email to a Friend","Diesen Artikel per E-Mail empfehlen"
|
11 |
+
"Email:","E-Mail:"
|
12 |
+
"Enabled","Aktiviert"
|
13 |
+
"Invalid Sender Information","Ungültiger Absender"
|
14 |
+
"Mage_Sendfriend::Invalid sender email.","Sie haben eine ungültige Absender E-Mail-Adresse eingegeben."
|
15 |
+
"Limit Sending By","Senden einschränken auf"
|
16 |
+
"Max Products Sent in 1 Hour","Maximale Anzahl in einer Stunde gesendeter Produkte"
|
17 |
+
"Max Recipients","Maximale Empfängeranzahl"
|
18 |
+
"Maximum %d email addresses allowed.","Maximal %d E-Mail-Adressen erlaubt."
|
19 |
+
"Message:","Nachricht:"
|
20 |
+
"Name","Name"
|
21 |
+
"Name:","Name:"
|
22 |
+
"No more than %d emails can be sent at a time.","Es können nicht mehr als %d E-Mails auf einmal versendet werden."
|
23 |
+
"Please define a correct Cookie instance.","Legen Sie bitte eine korrekte Cookie-Instanz fest."
|
24 |
+
"Please define a correct Product instance.","Legen Sie bitte eine korrekte Produkt-Instanz fest."
|
25 |
+
"Please define the correct Sender information.","Bitte legen Sie korrekte Senderinformationen fest."
|
26 |
+
"Recipient:","Empfänger:"
|
27 |
+
"Remove Email","E-Mail löschen"
|
28 |
+
"Select Email Template","E-Mail-Vorlage wählen"
|
29 |
+
"Send Email","E-Mail senden"
|
30 |
+
"Send product to a friend","Dieses Produkt an einen Freund senden"
|
31 |
+
"Sender:","Absender:"
|
32 |
+
"Some emails were not sent.","Einige E-Mail wurden nicht gesendet."
|
33 |
+
"The link to a friend was sent.","Vielen Dank. Ihre Empfehlung wurde versendet."
|
34 |
+
"The message cannot be empty."," Sie haben keine Nachricht eingegeben."
|
35 |
+
"The messages cannot be sent more than %d times in an hour","Die Nachrichten können nicht öfter als %d mal pro Stunde gesendet werden"
|
36 |
+
"Mage_Sendfriend::The sender name cannot be empty."," Sie haben keinen Absender-Namen eingegeben."
|
37 |
+
"The product name cannot be empty.","Bitte geben Sie den Produktnamen an."
|
38 |
+
"There were some problems with the data.","Es traten Probleme mit den Daten auf."
|
39 |
+
"You have exceeded limit of %d sends in an hour","Sie haben das Limit von %d Nachrichten pro Stunde überschritten"
|
40 |
+
"Product Name:","Produktbezeichnung:"
|
41 |
+
"Message to the recipient:","Nachricht an den Empfänger:"
|
js/sitewards/captcha.js
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Show prototype popup window
|
3 |
+
*
|
4 |
+
* @param string sUrl
|
5 |
+
*/
|
6 |
+
function showPopup(sUrl) {
|
7 |
+
oPopup = new Window({
|
8 |
+
id:'popup_window',
|
9 |
+
className: 'magento',
|
10 |
+
url: sUrl,
|
11 |
+
width: 820,
|
12 |
+
height: 600,
|
13 |
+
minimizable: false,
|
14 |
+
maximizable: false,
|
15 |
+
showEffectOptions: {
|
16 |
+
duration: 0.4
|
17 |
+
},
|
18 |
+
hideEffectOptions:{
|
19 |
+
duration: 0.4
|
20 |
+
},
|
21 |
+
destroyOnClose: true
|
22 |
+
});
|
23 |
+
oPopup.setZIndex(100);
|
24 |
+
oPopup.showCenter(true);
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Close popup window
|
29 |
+
*/
|
30 |
+
function closePopup() {
|
31 |
+
Windows.close('popup_window');
|
32 |
+
}
|
33 |
+
|
34 |
+
document.observe("dom:loaded", function() {
|
35 |
+
$$('p.email-friend a')[0].observe('click', function(oEvent) {
|
36 |
+
showPopup($(this).readAttribute('href'));
|
37 |
+
Event.stop(oEvent);
|
38 |
+
});
|
39 |
+
});
|
40 |
+
|
41 |
+
|
package.xml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Sitewards_Captcha</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.opensource.org/licenses/gpl-license.php">GPL</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Additional functionality for magento captcha extension.</summary>
|
10 |
+
<description>Installation instruction
|
11 |
+
------------------------
|
12 |
+

|
13 |
+
1. Install the extension
|
14 |
+
2. Go to System -> Configuration -> Customers -> Customer Configuration->Captcha and select "Email to a Friend" option in Forms field.</description>
|
15 |
+
<notes>Released new extension.</notes>
|
16 |
+
<authors><author><name>Sitewards Magento Team</name><user>sitewards</user><email>magento@sitewards.com</email></author></authors>
|
17 |
+
<date>2013-09-18</date>
|
18 |
+
<time>04:00:04</time>
|
19 |
+
<contents><target name="magecommunity"><dir name="Sitewards"><dir name="Captcha"><dir name="Block"><dir name="Sendfriend"><file name="Send.php" hash="8875265013ec45ffcfe92be6ad2326da"/></dir></dir><dir name="Helper"><file name="Data.php" hash="a268ddaabc47fcbc323e759c873ae869"/></dir><dir name="Model"><file name="CaptchaChecker.php" hash="c6b275af326acd6f2fb95adceb1a23f1"/><file name="Sendfriend.php" hash="5c56a12b97585752cc04ea42c6207540"/></dir><dir name="controllers"><file name="ProductController.php" hash="164a0aa604fd92e30a49ce27a73424ec"/></dir><dir name="etc"><file name="config.xml" hash="fde3ce84e888c2b3fc049a4a59f78b3f"/><file name="system.xml" hash="b84ba97ea80312adb7f38c2187670aa5"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Sitewards_Captcha.xml" hash="abf4c910ece09269ce5d7fc73c3121a7"/></dir></target><target name="magelocale"><dir name="de_DE"><file name="Sitewards_Captcha.csv" hash="f76b6cded4bd7c78de96685e5cac0519"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="sitewards"><dir name="captcha"><file name="closepopup.phtml" hash="6e963b95e4d7d568b190414fa0c514f6"/><dir name="sendfriend"><file name="send.phtml" hash="a92861c8a260e03a7712ee375be4ffb2"/></dir></dir></dir></dir><dir name="layout"><dir name="sitewards"><file name="captcha.xml" hash="d28bec040715e0de93f469a0b2e16057"/></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="sitewards"><file name="captcha.js" hash="9662f0c2a5ff7f3eb898df7dd6df39a4"/></dir></dir></target></contents>
|
20 |
+
<compatible/>
|
21 |
+
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
22 |
+
</package>
|