ET_Reviewnotify - Version 1.1.0

Version Notes

stable release

Download this release

Release Info

Developer Magento Core Team
Extension ET_Reviewnotify
Version 1.1.0
Comparing to
See all releases


Code changes from version 1.0.2 to 1.1.0

app/code/community/ET/Reviewnotify/Block/Adminhtml/Support.php CHANGED
@@ -17,18 +17,40 @@
17
  * @license http://shop.etwebsolutions.com/etws-license-free-v1/ ETWS Free License (EFL1)
18
  */
19
 
 
 
 
20
  class ET_Reviewnotify_Block_Adminhtml_Support
21
  extends Mage_Adminhtml_Block_Abstract
22
- implements Varien_Data_Form_Element_Renderer_Interface
23
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  /**
25
  * Support tab
26
- * version 2.0.0
 
 
27
  */
28
  public function render(Varien_Data_Form_Element_Abstract $element)
29
  {
30
- $helper = Mage::helper('reviewnotify');
31
- $moduleNameId = 'ET_Reviewnotify';
32
 
33
  $moduleVersion = $this->_getConfigValue($moduleNameId, 'version');
34
  $moduleName = $this->_getConfigValue($moduleNameId, 'name');
@@ -63,18 +85,18 @@ class ET_Reviewnotify_Block_Adminhtml_Support
63
  <tr>
64
  <td class="developer-label">' . $helper->__('Extension:') . '</td>
65
  <td class="developer-text">' . $helper->__(
66
- '<strong>%s</strong> (version %s)',
67
- $moduleName,
68
- $moduleVersion
69
- ) . '</td>
70
  </tr>
71
  <tr>
72
  <td class="developer-label">' . $helper->__('License:') . '</td>
73
  <td class="developer-text">' . $helper->__(
74
- '<a href="%s" target="_blank">%s</a>',
75
- $moduleLicenseLink,
76
- $moduleLicense
77
- ) . '</td>
78
  </tr>
79
  <tr>
80
  <td class="developer-label">' . $helper->__('Short Description:') . '</td>
@@ -83,26 +105,26 @@ class ET_Reviewnotify_Block_Adminhtml_Support
83
  <tr>
84
  <td class="developer-label">' . $helper->__('Documentation:') . '</td>
85
  <td class="developer-text">' . $helper->__(
86
- 'You can see description of extension features and answers to the ' .
87
  'frequently asked questions on <a href="%s" target="_blank">our website</a>.',
88
- $moduleLink) . '</td>
89
  </tr>
90
  <tr>
91
  <td class="developer-label line">' . $helper->__('Support:') . '</td>
92
  <td class="developer-text line">' . $helper->__(
93
- 'Extension support is available through <a href="%s" target="_blank">issue tracking system' .
94
  '</a>.<br>You can see information freely, but you will have to sign up to open a ticket.<br>' .
95
  '<br>Please, report all bugs and feature requests that are related to this extension.<br>' .
96
  '<br>If by some reason you can not submit a question, bug report or feature request to our ' .
97
  'ticket system, you can write us an email - support@etwebsolutions.com.',
98
- $moduleSupportLink) . '</td>
99
  </tr>
100
  <tr>
101
  <td class="developer-label line"><img src="' . $logoLink . '" width="100px" height="34px"> </td>
102
  <td class="developer-text line">' . $helper->__(
103
- 'You can hire our team to customize the extension. E-mail us on sales@etwebsolutions.com.<br>' .
104
  '<br>You can see a list of provided services on <a href="%s" target="_blank">our website</a>.',
105
- $servicesLink) . '</td>
106
  </tr>
107
  </table>';
108
 
@@ -110,6 +132,13 @@ class ET_Reviewnotify_Block_Adminhtml_Support
110
  return $html;
111
  }
112
 
 
 
 
 
 
 
 
113
  protected function _getConfigValue($module, $config)
114
  {
115
  $locale = Mage::app()->getLocale()->getLocaleCode();
@@ -128,61 +157,28 @@ class ET_Reviewnotify_Block_Adminhtml_Support
128
  }
129
  }
130
 
131
- const PLATFORM_CE = 'ce';
132
- const PLATFORM_PE = 'pe';
133
- const PLATFORM_EE = 'ee';
134
- const PLATFORM_GO = 'go';
135
- const PLATFORM_UNKNOWN = 'unknown';
136
-
137
- protected static $_platformCode = self::PLATFORM_UNKNOWN;
138
-
139
  /**
140
  * Get edition code
141
  * @return string
142
  */
143
  protected function _getPlatform()
144
  {
145
- if (self::$_platformCode == self::PLATFORM_UNKNOWN) {
146
- // from Magento CE version 1.7. we can get platform from Mage class
147
- if (property_exists('Mage', '_currentEdition')) {
148
- switch (Mage::getEdition()) {
149
- case Mage::EDITION_COMMUNITY:
150
- self::$_platformCode = self::PLATFORM_CE;
151
- break;
152
- case Mage::EDITION_PROFESSIONAL:
153
- self::$_platformCode = self::PLATFORM_PE;
154
- break;
155
- case Mage::EDITION_ENTERPRISE:
156
- self::$_platformCode = self::PLATFORM_EE;
157
- break;
158
- case Mage::EDITION_ENTERPRISE:
159
- self::$_platformCode = self::PLATFORM_EE;
160
- break;
161
- default:
162
- self::$_platformCode = self::PLATFORM_UNKNOWN;
163
- }
164
- }
165
-
166
- // if platform still unknown
167
- if (self::$_platformCode == self::PLATFORM_UNKNOWN) {
168
- $modulesArray = (array)Mage::getConfig()->getNode('modules')->children();
169
- $isEnterprise = array_key_exists('Enterprise_Enterprise', $modulesArray);
170
-
171
- $isProfessional = false; // TODO: how determine?
172
- $isGo = false; // TODO: how?
173
-
174
- if ($isEnterprise) {
175
- self::$_platformCode = self::PLATFORM_EE;
176
- } elseif ($isProfessional) {
177
- self::$_platformCode = self::PLATFORM_PE;
178
- } elseif ($isGo) {
179
- self::$_platformCode = self::PLATFORM_GO;
180
- } else {
181
- self::$_platformCode = self::PLATFORM_CE;
182
- }
183
- }
184
  }
185
- return self::$_platformCode;
186
- }
187
 
 
 
 
 
 
 
 
 
188
  }
17
  * @license http://shop.etwebsolutions.com/etws-license-free-v1/ ETWS Free License (EFL1)
18
  */
19
 
20
+ /**
21
+ * Class ET_Reviewnotify_Block_Adminhtml_Support
22
+ */
23
  class ET_Reviewnotify_Block_Adminhtml_Support
24
  extends Mage_Adminhtml_Block_Abstract
25
+ implements Varien_Data_Form_Element_Renderer_Interface
26
  {
27
+
28
+ protected $_helperName = 'reviewnotify';
29
+
30
+ const PLATFORM_CE = 'ce';
31
+ const PLATFORM_PE = 'pe';
32
+ const PLATFORM_EE = 'ee';
33
+ const PLATFORM_UNKNOWN = 'unknown';
34
+
35
+ protected $_platformCode = self::PLATFORM_UNKNOWN;
36
+
37
+ protected $_platformNames = array(
38
+ Mage::EDITION_COMMUNITY => self::PLATFORM_CE,
39
+ Mage::EDITION_PROFESSIONAL => self::PLATFORM_PE,
40
+ Mage::EDITION_ENTERPRISE => self::PLATFORM_EE,
41
+ );
42
+
43
+
44
  /**
45
  * Support tab
46
+ * version 2.2.2
47
+ *
48
+ * @inheritdoc
49
  */
50
  public function render(Varien_Data_Form_Element_Abstract $element)
51
  {
52
+ $helper = Mage::helper($this->_helperName);
53
+ $moduleNameId = $this->getModuleName();
54
 
55
  $moduleVersion = $this->_getConfigValue($moduleNameId, 'version');
56
  $moduleName = $this->_getConfigValue($moduleNameId, 'name');
85
  <tr>
86
  <td class="developer-label">' . $helper->__('Extension:') . '</td>
87
  <td class="developer-text">' . $helper->__(
88
+ '<strong>%s</strong> (version %s)',
89
+ $moduleName,
90
+ $moduleVersion
91
+ ) . '</td>
92
  </tr>
93
  <tr>
94
  <td class="developer-label">' . $helper->__('License:') . '</td>
95
  <td class="developer-text">' . $helper->__(
96
+ '<a href="%s" target="_blank">%s</a>',
97
+ $moduleLicenseLink,
98
+ $moduleLicense
99
+ ) . '</td>
100
  </tr>
101
  <tr>
102
  <td class="developer-label">' . $helper->__('Short Description:') . '</td>
105
  <tr>
106
  <td class="developer-label">' . $helper->__('Documentation:') . '</td>
107
  <td class="developer-text">' . $helper->__(
108
+ 'You can see description of extension features and answers to the ' .
109
  'frequently asked questions on <a href="%s" target="_blank">our website</a>.',
110
+ $moduleLink) . '</td>
111
  </tr>
112
  <tr>
113
  <td class="developer-label line">' . $helper->__('Support:') . '</td>
114
  <td class="developer-text line">' . $helper->__(
115
+ 'Extension support is available through <a href="%s" target="_blank">issue tracking system' .
116
  '</a>.<br>You can see information freely, but you will have to sign up to open a ticket.<br>' .
117
  '<br>Please, report all bugs and feature requests that are related to this extension.<br>' .
118
  '<br>If by some reason you can not submit a question, bug report or feature request to our ' .
119
  'ticket system, you can write us an email - support@etwebsolutions.com.',
120
+ $moduleSupportLink) . '</td>
121
  </tr>
122
  <tr>
123
  <td class="developer-label line"><img src="' . $logoLink . '" width="100px" height="34px"> </td>
124
  <td class="developer-text line">' . $helper->__(
125
+ 'You can hire our team to customize the extension. E-mail us on sales@etwebsolutions.com.<br>' .
126
  '<br>You can see a list of provided services on <a href="%s" target="_blank">our website</a>.',
127
+ $servicesLink) . '</td>
128
  </tr>
129
  </table>';
130
 
132
  return $html;
133
  }
134
 
135
+ /**
136
+ * Retrieve value from configuration
137
+ *
138
+ * @param string $module
139
+ * @param string $config
140
+ * @return Mage_Core_Model_Config_Element|SimpleXMLElement[]
141
+ */
142
  protected function _getConfigValue($module, $config)
143
  {
144
  $locale = Mage::app()->getLocale()->getLocaleCode();
157
  }
158
  }
159
 
 
 
 
 
 
 
 
 
160
  /**
161
  * Get edition code
162
  * @return string
163
  */
164
  protected function _getPlatform()
165
  {
166
+ if ($this->_platformCode != self::PLATFORM_UNKNOWN) {
167
+ return $this->_platformCode;
168
+ }
169
+
170
+ // from Magento CE version 1.7. we can get platform from Mage class
171
+ if (property_exists('Mage', '_currentEdition') && isset($this->_platformNames[Mage::getEdition()])) {
172
+ $this->_platformCode = $this->_platformNames[Mage::getEdition()];
173
+ return $this->_platformCode;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  }
 
 
175
 
176
+ // if platform still unknown
177
+ $modulesArray = (array)Mage::getConfig()->getNode('modules')->children();
178
+ $isEnterprise = array_key_exists('Enterprise_Enterprise', $modulesArray);
179
+
180
+ $this->_platformCode = $isEnterprise ? self::PLATFORM_EE : self::PLATFORM_CE;
181
+
182
+ return $this->_platformCode;
183
+ }
184
  }
app/code/community/ET/Reviewnotify/Block/Adminhtml/System/Config/Form/Field/Heading.php CHANGED
@@ -20,20 +20,32 @@
20
  //if (!class_exists('Mage_Adminhtml_Block_System_Config_Form_Field_Heading')) {
21
  // https://bugs.php.net/bug.php?id=52339
22
  if (version_compare(Mage::getVersion(), '1.4.1', '<')) {
 
 
 
 
23
  class ET_Reviewnotify_Block_Adminhtml_System_Config_Form_Field_Heading
24
  extends Mage_Adminhtml_Block_Abstract
25
  implements Varien_Data_Form_Element_Renderer_Interface
26
  {
27
 
 
 
 
 
28
  public function render(Varien_Data_Form_Element_Abstract $element)
29
  {
30
  return sprintf(
31
  '<tr class="system-fieldset-sub-head" id="row_%s"><td colspan="5"><h4 id="%s">%s</h4></td></tr>',
32
- $element->getHtmlId(), $element->getHtmlId(), $element->getLabel()
33
  );
34
  }
35
  }
36
  } else {
 
 
 
 
37
  class ET_Reviewnotify_Block_Adminhtml_System_Config_Form_Field_Heading
38
  extends Mage_Adminhtml_Block_System_Config_Form_Field_Heading
39
  {
20
  //if (!class_exists('Mage_Adminhtml_Block_System_Config_Form_Field_Heading')) {
21
  // https://bugs.php.net/bug.php?id=52339
22
  if (version_compare(Mage::getVersion(), '1.4.1', '<')) {
23
+ /**
24
+ * Class ET_Reviewnotify_Block_Adminhtml_System_Config_Form_Field_Heading
25
+ * for old Magento versions
26
+ */
27
  class ET_Reviewnotify_Block_Adminhtml_System_Config_Form_Field_Heading
28
  extends Mage_Adminhtml_Block_Abstract
29
  implements Varien_Data_Form_Element_Renderer_Interface
30
  {
31
 
32
+ /**
33
+ * @param Varien_Data_Form_Element_Abstract $element
34
+ * @return string
35
+ */
36
  public function render(Varien_Data_Form_Element_Abstract $element)
37
  {
38
  return sprintf(
39
  '<tr class="system-fieldset-sub-head" id="row_%s"><td colspan="5"><h4 id="%s">%s</h4></td></tr>',
40
+ $element->getHtmlId(), $element->getHtmlId(), $element->getData('label')
41
  );
42
  }
43
  }
44
  } else {
45
+ /**
46
+ * Class ET_Reviewnotify_Block_Adminhtml_System_Config_Form_Field_Heading
47
+ * for new versions
48
+ */
49
  class ET_Reviewnotify_Block_Adminhtml_System_Config_Form_Field_Heading
50
  extends Mage_Adminhtml_Block_System_Config_Form_Field_Heading
51
  {
app/code/community/ET/Reviewnotify/Block/Adminhtml/System/Config/Form/Field/Linktoinfo.php CHANGED
@@ -17,13 +17,25 @@
17
  * @license http://shop.etwebsolutions.com/etws-license-free-v1/ ETWS Free License (EFL1)
18
  */
19
 
 
 
 
20
  class ET_Reviewnotify_Block_Adminhtml_System_Config_Form_Field_Linktoinfo
21
  extends Mage_Adminhtml_Block_System_Config_Form_Field
22
  {
 
 
 
 
 
 
23
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
24
  {
25
- return '<a href="' . $this->getUrl('*/system_config/edit', array('section' => 'reviewnotify')) . '">' .
26
- Mage::helper('reviewnotify')->__('Extension information') .
27
- '</a>';
 
 
 
28
  }
29
- }
17
  * @license http://shop.etwebsolutions.com/etws-license-free-v1/ ETWS Free License (EFL1)
18
  */
19
 
20
+ /**
21
+ * Class ET_Reviewnotify_Block_Adminhtml_System_Config_Form_Field_Linktoinfo
22
+ */
23
  class ET_Reviewnotify_Block_Adminhtml_System_Config_Form_Field_Linktoinfo
24
  extends Mage_Adminhtml_Block_System_Config_Form_Field
25
  {
26
+ /**
27
+ * @param Varien_Data_Form_Element_Abstract $element
28
+ * @return string
29
+ *
30
+ * @inheritdoc
31
+ */
32
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
33
  {
34
+ /** @var ET_Reviewnotify_Helper_Data $helper */
35
+ $helper = Mage::helper('etpaymentrobokassa');
36
+
37
+ $html = '<a href="' . $this->getUrl('*/system_config/edit', array('section' => 'reviewnotify')) . '">' .
38
+ $helper->__('Extension information') . '</a>';
39
+ return $html;
40
  }
41
+ }
app/code/community/ET/Reviewnotify/Block/Adminhtml/System/Config/Form/Field/Linktooptions.php CHANGED
@@ -17,13 +17,25 @@
17
  * @license http://shop.etwebsolutions.com/etws-license-free-v1/ ETWS Free License (EFL1)
18
  */
19
 
20
- class ET_Reviewnotify_Block_Adminhtml_System_Config_Form_Field_Linktooptions
 
 
 
21
  extends Mage_Adminhtml_Block_System_Config_Form_Field
22
  {
 
 
 
 
 
 
23
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
24
  {
25
- return '<a href="' . $this->getUrl('*/system_config/edit', array('section' => 'catalog')) . '">' .
26
- Mage::helper('reviewnotify')->__('Go to Catalog settings section') .
27
- '</a>';
 
 
 
28
  }
29
- }
17
  * @license http://shop.etwebsolutions.com/etws-license-free-v1/ ETWS Free License (EFL1)
18
  */
19
 
20
+ /**
21
+ * Class ET_Reviewnotify_Block_Adminhtml_System_Config_Form_Field_Linktooptions
22
+ */
23
+ class ET_Reviewnotify_Block_Adminhtml_System_Config_Form_Field_Linktooptions
24
  extends Mage_Adminhtml_Block_System_Config_Form_Field
25
  {
26
+ /**
27
+ * @param Varien_Data_Form_Element_Abstract $element
28
+ * @return string
29
+ *
30
+ * @inheritdoc
31
+ */
32
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
33
  {
34
+ /** @var ET_Reviewnotify_Helper_Data $helper */
35
+ $helper = Mage::helper('etpaymentrobokassa');
36
+
37
+ $html = '<a href="' . $this->getUrl('*/system_config/edit', array('section' => 'catalog')) . '">' .
38
+ $helper->__('Go to Catalog settings section') . '</a>';
39
+ return $html;
40
  }
41
+ }
app/code/community/ET/Reviewnotify/Block/Toolbar.php CHANGED
@@ -17,6 +17,9 @@
17
  * @license http://shop.etwebsolutions.com/etws-license-free-v1/ ETWS Free License (EFL1)
18
  */
19
 
 
 
 
20
  class ET_Reviewnotify_Block_Toolbar extends Mage_Adminhtml_Block_Template
21
  {
22
  /**
@@ -55,7 +58,7 @@ class ET_Reviewnotify_Block_Toolbar extends Mage_Adminhtml_Block_Template
55
  */
56
  public function getReviewUrl($product)
57
  {
58
- $params = array('id'=>$product->getReviewId());
59
  return $this->getUrl('*/catalog_product_review/edit', $params);
60
  }
61
 
17
  * @license http://shop.etwebsolutions.com/etws-license-free-v1/ ETWS Free License (EFL1)
18
  */
19
 
20
+ /**
21
+ * Class ET_Reviewnotify_Block_Toolbar
22
+ */
23
  class ET_Reviewnotify_Block_Toolbar extends Mage_Adminhtml_Block_Template
24
  {
25
  /**
58
  */
59
  public function getReviewUrl($product)
60
  {
61
+ $params = array('id' => $product->getData('review_id'));
62
  return $this->getUrl('*/catalog_product_review/edit', $params);
63
  }
64
 
app/code/community/ET/Reviewnotify/Helper/Data.php CHANGED
@@ -17,6 +17,9 @@
17
  * @license http://shop.etwebsolutions.com/etws-license-free-v1/ ETWS Free License (EFL1)
18
  */
19
 
 
 
 
20
  class ET_Reviewnotify_Helper_Data extends Mage_Core_Helper_Abstract
21
  {
22
  }
17
  * @license http://shop.etwebsolutions.com/etws-license-free-v1/ ETWS Free License (EFL1)
18
  */
19
 
20
+ /**
21
+ * Class ET_Reviewnotify_Helper_Data
22
+ */
23
  class ET_Reviewnotify_Helper_Data extends Mage_Core_Helper_Abstract
24
  {
25
  }
app/code/community/ET/Reviewnotify/Model/Observer.php CHANGED
@@ -17,47 +17,99 @@
17
  * @license http://shop.etwebsolutions.com/etws-license-free-v1/ ETWS Free License (EFL1)
18
  */
19
 
 
 
 
20
  class ET_Reviewnotify_Model_Observer
21
  {
22
- public function __construct()
 
 
 
 
 
 
 
 
 
23
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  }
25
 
26
- public function send_nofificatin_mail($observer)
 
 
 
 
 
 
 
 
27
  {
28
- $this->needSend = Mage::getStoreConfig('catalog/review/need_send');
29
- $this->eventEmail = Mage::getStoreConfig('catalog/review/email_to');
30
- $this->emailTemplate = Mage::getStoreConfig('catalog/review/email_template');
31
- $this->emailIdentity = Mage::getStoreConfig('catalog/review/email_identity');
32
-
33
- if (($this->needSend) && (strlen(trim($this->eventEmail))>0)) {
34
- $product = Mage::getModel('catalog/product')->load($observer->object->getEntityPkValue());
35
- $emailTemplate = Mage::getModel('core/email_template');
36
-
37
- $recipients = explode(",", $this->eventEmail);
38
- foreach ($recipients as $k => $recipient) {
39
- $sendresult = $emailTemplate->setDesignConfig(array('area' => 'backend'))
40
- ->sendTransactional(
41
- $this->emailTemplate,
42
- $this->emailIdentity,
43
- trim($recipient),
44
- trim($recipient),
45
- array(
46
- "product" => $product->getName()." (sku: ".$product->getsku().")",
47
- "title" => $observer->object->getTitle(),
48
- "nickname" => $observer->object->getNickname(),
49
- "details" => $observer->object->getDetail(),
50
- "id" => $observer->object->getId(),
51
- 'date' => Mage::app()->getLocale()->date(
52
- date("Y-m-d H:i:s"),
53
- Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM),
54
- null,
55
- true
56
- )
57
- )
58
- );
59
- }
60
  }
61
  }
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  }
17
  * @license http://shop.etwebsolutions.com/etws-license-free-v1/ ETWS Free License (EFL1)
18
  */
19
 
20
+ /**
21
+ * Class ET_Reviewnotify_Model_Observer
22
+ */
23
  class ET_Reviewnotify_Model_Observer
24
  {
25
+
26
+ const ANTI_SPAM = 'default/catalog/review/antispam';
27
+
28
+ /**
29
+ * Send notification email about now product review
30
+ *
31
+ * @param Varien_Event_Observer $observer
32
+ * @throws Zend_Date_Exception
33
+ */
34
+ public function sendNotificationEmail($observer)
35
  {
36
+ $needSend = Mage::getStoreConfig('catalog/review/need_send');
37
+ $mailTo = Mage::getStoreConfig('catalog/review/email_to');
38
+ $emailTemplate = Mage::getStoreConfig('catalog/review/email_template');
39
+ $emailIdentity = Mage::getStoreConfig('catalog/review/email_identity');
40
+
41
+ /** @var Mage_Review_Model_Review $review */
42
+ $review = $observer->getData('object');
43
+
44
+ if (($needSend) && (strlen(trim($mailTo)) > 0)) {
45
+ /** @var Mage_Catalog_Model_Product $product */
46
+ $product = Mage::getModel('catalog/product')->load($review->getEntityPkValue());
47
+ /** @var Mage_Core_Model_Email_Template $templateModel */
48
+ $templateModel = Mage::getModel('core/email_template')->setDesignConfig(array('area' => 'backend'));
49
+
50
+ $recipients = explode(",", $mailTo);
51
+ foreach ($recipients as $recipient) {
52
+ $datetime = Zend_Date::now();
53
+ $datetime->setLocale(Mage::getStoreConfig(
54
+ Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE))
55
+ ->setTimezone(Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE));
56
+
57
+ $templateModel->sendTransactional(
58
+ $emailTemplate,
59
+ $emailIdentity,
60
+ trim($recipient),
61
+ trim($recipient),
62
+ array(
63
+ "product" => $product->getName() . " (sku: " . $product->getSku() . ")",
64
+ "title" => $review->getData('title'),
65
+ "nickname" => $review->getData('nickname'),
66
+ "details" => $review->getData('detail'),
67
+ "id" => $review->getId(),
68
+ 'date' => $datetime->get(Zend_Date::DATETIME_MEDIUM)
69
+ )
70
+ );
71
+ }
72
+ }
73
  }
74
 
75
+ /**
76
+ * Review model rewrite for old Magento version.
77
+ *
78
+ * Event: review_save_after
79
+ * @param Varien_Event_Observer $observer
80
+ *
81
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
82
+ */
83
+ public function rewriteReviewModel(Varien_Event_Observer $observer)
84
  {
85
+ if (version_compare(Mage::getVersion(), '1.4', '<')) {
86
+ Mage::getConfig()->setNode(
87
+ 'global/models/review/rewrite/review',
88
+ 'ET_Reviewnotify_Model_Review'
89
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  }
91
  }
92
 
93
+ /**
94
+ * Dynamic controller rewrite Mage_Review_ProductController
95
+ *
96
+ * @param Varien_Event_Observer $observer
97
+ *
98
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
99
+ */
100
+ public function rewriteReviewProductController(Varien_Event_Observer $observer)
101
+ {
102
+ $isFixEnabled = (int)Mage::getConfig()->getNode(self::ANTI_SPAM);
103
+
104
+ if ($isFixEnabled) {
105
+ Mage::getConfig()->setNode('global/rewrite/review/from',
106
+ '#^/review/product/#');
107
+
108
+ Mage::getConfig()->setNode('global/rewrite/review/to',
109
+ '/etreviewnotify/product/');
110
+
111
+ }
112
+
113
+ }
114
+
115
  }
app/code/community/ET/Reviewnotify/Model/Review.php CHANGED
@@ -17,7 +17,12 @@
17
  * @license http://shop.etwebsolutions.com/etws-license-free-v1/ ETWS Free License (EFL1)
18
  */
19
 
 
 
 
 
 
20
  class ET_Reviewnotify_Model_Review extends Mage_Review_Model_Review
21
  {
22
- protected $_eventPrefix = 'review_review';
23
  }
17
  * @license http://shop.etwebsolutions.com/etws-license-free-v1/ ETWS Free License (EFL1)
18
  */
19
 
20
+ /**
21
+ * In old Magento versions no prefix available for class Mage_Review_Model_Review
22
+ *
23
+ * Class ET_Reviewnotify_Model_Review
24
+ */
25
  class ET_Reviewnotify_Model_Review extends Mage_Review_Model_Review
26
  {
27
+ protected $_eventPrefix = 'review';
28
  }
app/code/community/ET/Reviewnotify/controllers/ProductController.php CHANGED
@@ -18,18 +18,33 @@
18
  */
19
 
20
  require_once 'Mage/Review/controllers/ProductController.php';
 
 
 
 
21
  class ET_Reviewnotify_ProductController extends Mage_Review_ProductController
22
  {
23
  const SECRET_KEY = "ET_Special_Codes_String";
24
 
 
 
 
 
 
 
 
25
  public function prepostAction()
26
  {
27
- $result = array("sequence"=>$this->_calculateCode($this->getRequest()->getPost()));
28
  $this->getResponse()->setBody(
29
- '<script>window.parent.postReviewRestoreData("'.$result["sequence"].'")</script>'
30
  );
31
  }
32
 
 
 
 
 
33
  public function postAction()
34
  {
35
  $data = $this->getRequest()->getPost();
@@ -38,6 +53,7 @@ class ET_Reviewnotify_ProductController extends Mage_Review_ProductController
38
  $data["sequence"] = "";
39
  }
40
  if (strcmp($data["sequence"], $this->_calculateCode($data)) != 0) {
 
41
  $session = Mage::getSingleton('core/session');
42
  $session->setFormData($data);
43
  $session->addError($this->__('Unable to post the review.'));
@@ -52,12 +68,18 @@ class ET_Reviewnotify_ProductController extends Mage_Review_ProductController
52
  return parent::postAction();
53
  }
54
 
 
 
 
 
 
 
55
  protected function _calculateCode($data)
56
  {
57
  $allKeys = array("title", "nickname", "detail");
58
  $allForGen = array(self::SECRET_KEY);
59
  foreach ($allKeys as $oneKey) {
60
- $allForGen[] = isset($data[$oneKey])?$data[$oneKey]:rand();
61
  }
62
  return md5(implode("|", $allForGen));
63
  }
18
  */
19
 
20
  require_once 'Mage/Review/controllers/ProductController.php';
21
+
22
+ /**
23
+ * Class ET_Reviewnotify_ProductController
24
+ */
25
  class ET_Reviewnotify_ProductController extends Mage_Review_ProductController
26
  {
27
  const SECRET_KEY = "ET_Special_Codes_String";
28
 
29
+ /**
30
+ * Prepost Action, that is called before Post Action
31
+ * if Anti Spam function is enabled and our JS has changed URLS
32
+ *
33
+ * if bots are not used JS or our JS in not loaded this action
34
+ * if not called and no secure data is added to form
35
+ */
36
  public function prepostAction()
37
  {
38
+ $result = array("sequence" => $this->_calculateCode($this->getRequest()->getPost()));
39
  $this->getResponse()->setBody(
40
+ '<script>window.parent.postReviewRestoreData("' . $result["sequence"] . '")</script>'
41
  );
42
  }
43
 
44
+ /**
45
+ * Submit new review action if anti spam function is enabled
46
+ * In no secure data in form we do not post review and show error
47
+ */
48
  public function postAction()
49
  {
50
  $data = $this->getRequest()->getPost();
53
  $data["sequence"] = "";
54
  }
55
  if (strcmp($data["sequence"], $this->_calculateCode($data)) != 0) {
56
+ /** @var Mage_Catalog_Model_Session $session */
57
  $session = Mage::getSingleton('core/session');
58
  $session->setFormData($data);
59
  $session->addError($this->__('Unable to post the review.'));
68
  return parent::postAction();
69
  }
70
 
71
+ /**
72
+ * Prepare secret string from from data
73
+ *
74
+ * @param array $data
75
+ * @return string
76
+ */
77
  protected function _calculateCode($data)
78
  {
79
  $allKeys = array("title", "nickname", "detail");
80
  $allForGen = array(self::SECRET_KEY);
81
  foreach ($allKeys as $oneKey) {
82
+ $allForGen[] = isset($data[$oneKey]) ? $data[$oneKey] : rand();
83
  }
84
  return md5(implode("|", $allForGen));
85
  }
app/code/community/ET/Reviewnotify/etc/config.xml CHANGED
@@ -23,7 +23,7 @@
23
  <modules>
24
  <ET_Reviewnotify>
25
  <name>ET Review Notify</name>
26
- <version>1.0.2</version>
27
  <descr>
28
  <ru_RU><![CDATA[Модуль добавляет функцию оповещения владельца сайта о появлении новых отзывов и затрудняет спам-ботам автоматическое размещение отзывов.]]>
29
  </ru_RU>
@@ -50,22 +50,28 @@
50
  </ET_Reviewnotify>
51
  </modules>
52
  <global>
53
- <rewrite>
54
- <review>
55
- <from><![CDATA[#^/review/product/#]]></from>
56
- <to>/etreviewnotify/product/</to>
57
- </review>
58
- </rewrite>
 
 
 
 
 
 
 
 
 
 
 
59
 
60
  <models>
61
  <reviewnotify>
62
  <class>ET_Reviewnotify_Model</class>
63
  </reviewnotify>
64
- <review>
65
- <rewrite>
66
- <review>ET_Reviewnotify_Model_Review</review>
67
- </rewrite>
68
- </review>
69
  </models>
70
 
71
  <helpers>
@@ -104,15 +110,15 @@
104
 
105
  <frontend>
106
  <events>
107
- <review_review_save_after>
108
  <observers>
109
  <et_reviewnotify_observer>
110
  <type>singleton</type>
111
  <class>reviewnotify/observer</class>
112
- <method>send_nofificatin_mail</method>
113
  </et_reviewnotify_observer>
114
  </observers>
115
- </review_review_save_after>
116
  </events>
117
 
118
  <routers>
23
  <modules>
24
  <ET_Reviewnotify>
25
  <name>ET Review Notify</name>
26
+ <version>1.1.0</version>
27
  <descr>
28
  <ru_RU><![CDATA[Модуль добавляет функцию оповещения владельца сайта о появлении новых отзывов и затрудняет спам-ботам автоматическое размещение отзывов.]]>
29
  </ru_RU>
50
  </ET_Reviewnotify>
51
  </modules>
52
  <global>
53
+
54
+ <events>
55
+ <controller_front_init_before>
56
+ <observers>
57
+ <et_reviewnotify_model_rewrite>
58
+ <type>model</type>
59
+ <class>reviewnotify/observer</class>
60
+ <method>rewriteReviewModel</method>
61
+ </et_reviewnotify_model_rewrite>
62
+ <et_reviewnotify_controller_rewrite>
63
+ <type>model</type>
64
+ <class>reviewnotify/observer</class>
65
+ <method>rewriteReviewProductController</method>
66
+ </et_reviewnotify_controller_rewrite>
67
+ </observers>
68
+ </controller_front_init_before>
69
+ </events>
70
 
71
  <models>
72
  <reviewnotify>
73
  <class>ET_Reviewnotify_Model</class>
74
  </reviewnotify>
 
 
 
 
 
75
  </models>
76
 
77
  <helpers>
110
 
111
  <frontend>
112
  <events>
113
+ <review_save_after>
114
  <observers>
115
  <et_reviewnotify_observer>
116
  <type>singleton</type>
117
  <class>reviewnotify/observer</class>
118
+ <method>sendNotificationEmail</method>
119
  </et_reviewnotify_observer>
120
  </observers>
121
+ </review_save_after>
122
  </events>
123
 
124
  <routers>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>ET_Reviewnotify</name>
4
- <version>1.0.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://shop.etwebsolutions.com/eng/etws-license-free-v1">ETWS Free License (EFL1)</license>
7
  <channel>community</channel>
@@ -10,9 +10,9 @@
10
  <description>Reviewnotify not only notifies store owner by email about new reviews, but also reminds him about pending review until someone will change their status (in status bar - under main menu in admin panel). As a bonus, we offer a feature that will complicate writing reviews for bots and spammers.</description>
11
  <notes>stable release</notes>
12
  <authors><author><name>Jurij</name><user>auto-converted</user><email>support@etwebsolutions.com</email></author><author><name>Andrej</name><user>auto-converted</user><email>support@etwebsolutions.com</email></author></authors>
13
- <date>2015-02-19</date>
14
- <time>08:15:22</time>
15
- <contents><target name="magecommunity"><dir name="ET"><dir name="Reviewnotify"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Heading.php" hash="43457dd0142c8db981413fd1fb05458a"/><file name="Linktoinfo.php" hash="ebbf82a8d096387dab5eec7000d2b854"/><file name="Linktooptions.php" hash="da8fcd047fe31d4f9cdce9d301f0a6a2"/></dir></dir></dir></dir><file name="Support.php" hash="740be5e99beca75dc438da17b239f017"/></dir><file name="Toolbar.php" hash="aa5df39e647b7aba667f1866b9435688"/></dir><dir name="Helper"><file name="Data.php" hash="0ee34776e52fc3bcfe92be81082dbe62"/></dir><dir name="Model"><file name="Observer.php" hash="c6323be9e43bd964ce5626f0112ed9b9"/><file name="Review.php" hash="29189fbcbe721baf0a3561d72df95112"/></dir><dir name="controllers"><file name="ProductController.php" hash="f9f6c8416119e5bf2cc03a665942f71d"/></dir><dir name="etc"><file name="config.xml" hash="5b09cfca1fb4e6e705f37e3b41175b88"/><file name="system.xml" hash="170c3d599bb872c34b7d8a1824c0ff7d"/></dir></dir></dir></target><target name="magelocale"><dir name="ru_RU"><dir name="template"><dir name="email"><file name="et_reviewnotify.html" hash="dc715adcb9e2d271d206c246af29920d"/></dir></dir><file name="ET_Reviewnotify.csv" hash="3f2535867244f156e4abd87e74d10ff9"/></dir><dir name="en_US"><dir name="template"><dir name="email"><file name="et_reviewnotify.html" hash="c3d8b0a804d721cb17271448ef7cf56b"/></dir></dir><file name="ET_Reviewnotify.csv" hash="fc0b8c0c8a2472410ea86e45253bd162"/></dir></target><target name="mageetc"><dir name="modules"><file name="ET_Reviewnotify.xml" hash="47e1448c262ce7a004b23db1e1528cd6"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="reviewnotify"><file name="toolbar.phtml" hash="720b5d875c17cb27bb62822787b5e548"/></dir></dir><dir name="layout"><file name="et_reviewnotify.xml" hash="3aec74e6a34932a3601e83cb0bdf67d1"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="et_reviewnotify.xml" hash="0d561861b19836a6dd5b3f4ea9f30cfc"/></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="et_reviewnotify"><file name="reviewnotify.js" hash="e8ca066378d6077202127b0f8b9a6ba7"/></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>ET_Reviewnotify</name>
4
+ <version>1.1.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://shop.etwebsolutions.com/eng/etws-license-free-v1">ETWS Free License (EFL1)</license>
7
  <channel>community</channel>
10
  <description>Reviewnotify not only notifies store owner by email about new reviews, but also reminds him about pending review until someone will change their status (in status bar - under main menu in admin panel). As a bonus, we offer a feature that will complicate writing reviews for bots and spammers.</description>
11
  <notes>stable release</notes>
12
  <authors><author><name>Jurij</name><user>auto-converted</user><email>support@etwebsolutions.com</email></author><author><name>Andrej</name><user>auto-converted</user><email>support@etwebsolutions.com</email></author></authors>
13
+ <date>2015-11-30</date>
14
+ <time>10:38:18</time>
15
+ <contents><target name="magecommunity"><dir name="ET"><dir name="Reviewnotify"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Heading.php" hash="94bd440631e9fb1663c6d5f99ce3e157"/><file name="Linktoinfo.php" hash="0db63a23b2e02382a658f7d73c33c710"/><file name="Linktooptions.php" hash="7677589b83f16b19d27ede5256163868"/></dir></dir></dir></dir><file name="Support.php" hash="74401d2bc963cb97ace63efe3829e7df"/></dir><file name="Toolbar.php" hash="d45d4b620d4082f0e24bb80607077a66"/></dir><dir name="Helper"><file name="Data.php" hash="f06f55ce8b206b1bfd030e2c4c2236a9"/></dir><dir name="Model"><file name="Observer.php" hash="6687761af580dd6edb045f11809b84b1"/><file name="Review.php" hash="ea6df8dce82a17a62f1e5abd74130c2d"/></dir><dir name="controllers"><file name="ProductController.php" hash="0ac5a508beec1b1e4b5d4ada392463d6"/></dir><dir name="etc"><file name="config.xml" hash="0926c37d8a8c43ca5ee4222877e965d8"/><file name="system.xml" hash="170c3d599bb872c34b7d8a1824c0ff7d"/></dir></dir></dir></target><target name="magelocale"><dir name="ru_RU"><dir name="template"><dir name="email"><file name="et_reviewnotify.html" hash="dc715adcb9e2d271d206c246af29920d"/></dir></dir><file name="ET_Reviewnotify.csv" hash="3f2535867244f156e4abd87e74d10ff9"/></dir><dir name="en_US"><dir name="template"><dir name="email"><file name="et_reviewnotify.html" hash="c3d8b0a804d721cb17271448ef7cf56b"/></dir></dir><file name="ET_Reviewnotify.csv" hash="fc0b8c0c8a2472410ea86e45253bd162"/></dir></target><target name="mageetc"><dir name="modules"><file name="ET_Reviewnotify.xml" hash="47e1448c262ce7a004b23db1e1528cd6"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="reviewnotify"><file name="toolbar.phtml" hash="720b5d875c17cb27bb62822787b5e548"/></dir></dir><dir name="layout"><file name="et_reviewnotify.xml" hash="3aec74e6a34932a3601e83cb0bdf67d1"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="et_reviewnotify.xml" hash="0d561861b19836a6dd5b3f4ea9f30cfc"/></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="et_reviewnotify"><file name="reviewnotify.js" hash="e8ca066378d6077202127b0f8b9a6ba7"/></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>