Version Notes
Auto approves product reviews based on customer type.
Download this release
Release Info
Developer | BrainSINS |
Extension | Auto_Reviews |
Version | 2.0.0 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 2.0.0
- app/code/community/Exinent/Autoapprovereviews/Model/Adminhtml/System/Config/Source/Customer/Group/Multiselect.php~ +0 -16
- app/code/community/Exinent/Autoapprovereviews/controllers/AutoController.php~ +0 -279
- app/code/community/Exinent/Autoapprovereviews/controllers/ProductController.php~ +0 -288
- app/code/community/Exinent/Autoapprovereviews/etc/config.xml~ +0 -74
- app/code/community/Exinent/Autoapprovereviews/etc/system.xml~ +0 -70
- package.xml +10 -10
app/code/community/Exinent/Autoapprovereviews/Model/Adminhtml/System/Config/Source/Customer/Group/Multiselect.php~
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Exinent_Autoapprovereviews_Model_Adminhtml_System_Config_Source_Customer_Group_Multiselect
|
3 |
-
{
|
4 |
-
protected $_options;
|
5 |
-
|
6 |
-
public function toOptionArray() {
|
7 |
-
if (!$this->_options) {
|
8 |
-
$this->_options = Mage::getResourceModel('customer/group_collection')
|
9 |
-
->setRealGroupsFilter()
|
10 |
-
->loadData()->toOptionArray();
|
11 |
-
array_unshift($this->_options, array('value' => '', 'label' => Mage::helper('adminhtml')->__('No Group Selected')));
|
12 |
-
}
|
13 |
-
return $this->_options;
|
14 |
-
}
|
15 |
-
|
16 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Exinent/Autoapprovereviews/controllers/AutoController.php~
DELETED
@@ -1,279 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Exinent_Autoapprovereviews_AutoController extends Mage_Core_Controller_Front_Action {
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Action list where need check enabled cookie
|
6 |
-
*
|
7 |
-
* @var array
|
8 |
-
*/
|
9 |
-
protected $_cookieCheckActions = array('post');
|
10 |
-
|
11 |
-
public function preDispatch()
|
12 |
-
{
|
13 |
-
parent::preDispatch();
|
14 |
-
|
15 |
-
$allowGuest = Mage::helper('review')->getIsGuestAllowToWrite();
|
16 |
-
if (!$this->getRequest()->isDispatched()) {
|
17 |
-
return;
|
18 |
-
}
|
19 |
-
|
20 |
-
$action = $this->getRequest()->getActionName();
|
21 |
-
if (!$allowGuest && $action == 'post' && $this->getRequest()->isPost()) {
|
22 |
-
if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
|
23 |
-
$this->setFlag('', self::FLAG_NO_DISPATCH, true);
|
24 |
-
Mage::getSingleton('customer/session')->setBeforeAuthUrl(Mage::getUrl('*/*/*', array('_current' => true)));
|
25 |
-
Mage::getSingleton('review/session')->setFormData($this->getRequest()->getPost())
|
26 |
-
->setRedirectUrl($this->_getRefererUrl());
|
27 |
-
$this->_redirectUrl(Mage::helper('customer')->getLoginUrl());
|
28 |
-
}
|
29 |
-
}
|
30 |
-
|
31 |
-
return $this;
|
32 |
-
}
|
33 |
-
/**
|
34 |
-
* Initialize and check product
|
35 |
-
*
|
36 |
-
* @return Mage_Catalog_Model_Product
|
37 |
-
*/
|
38 |
-
protected function _initProduct()
|
39 |
-
{
|
40 |
-
Mage::dispatchEvent('review_controller_product_init_before', array('controller_action'=>$this));
|
41 |
-
$categoryId = (int) $this->getRequest()->getParam('category', false);
|
42 |
-
$productId = (int) $this->getRequest()->getParam('id');
|
43 |
-
|
44 |
-
$product = $this->_loadProduct($productId);
|
45 |
-
if (!$product) {
|
46 |
-
return false;
|
47 |
-
}
|
48 |
-
|
49 |
-
if ($categoryId) {
|
50 |
-
$category = Mage::getModel('catalog/category')->load($categoryId);
|
51 |
-
Mage::register('current_category', $category);
|
52 |
-
}
|
53 |
-
|
54 |
-
try {
|
55 |
-
Mage::dispatchEvent('review_controller_product_init', array('product'=>$product));
|
56 |
-
Mage::dispatchEvent('review_controller_product_init_after', array(
|
57 |
-
'product' => $product,
|
58 |
-
'controller_action' => $this
|
59 |
-
));
|
60 |
-
} catch (Mage_Core_Exception $e) {
|
61 |
-
Mage::logException($e);
|
62 |
-
return false;
|
63 |
-
}
|
64 |
-
|
65 |
-
return $product;
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Load product model with data by passed id.
|
70 |
-
* Return false if product was not loaded or has incorrect status.
|
71 |
-
*
|
72 |
-
* @param int $productId
|
73 |
-
* @return bool|Mage_Catalog_Model_Product
|
74 |
-
*/
|
75 |
-
protected function _loadProduct($productId)
|
76 |
-
{
|
77 |
-
if (!$productId) {
|
78 |
-
return false;
|
79 |
-
}
|
80 |
-
|
81 |
-
$product = Mage::getModel('catalog/product')
|
82 |
-
->setStoreId(Mage::app()->getStore()->getId())
|
83 |
-
->load($productId);
|
84 |
-
/* @var $product Mage_Catalog_Model_Product */
|
85 |
-
if (!$product->getId() || !$product->isVisibleInCatalog() || !$product->isVisibleInSiteVisibility()) {
|
86 |
-
return false;
|
87 |
-
}
|
88 |
-
|
89 |
-
Mage::register('current_product', $product);
|
90 |
-
Mage::register('product', $product);
|
91 |
-
|
92 |
-
return $product;
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Load review model with data by passed id.
|
97 |
-
* Return false if review was not loaded or review is not approved.
|
98 |
-
*
|
99 |
-
* @param int $productId
|
100 |
-
* @return bool|Mage_Review_Model_Review
|
101 |
-
*/
|
102 |
-
protected function _loadReview($reviewId)
|
103 |
-
{
|
104 |
-
if (!$reviewId) {
|
105 |
-
return false;
|
106 |
-
}
|
107 |
-
|
108 |
-
$review = Mage::getModel('review/review')->load($reviewId);
|
109 |
-
/* @var $review Mage_Review_Model_Review */
|
110 |
-
if (!$review->getId() || !$review->isApproved() || !$review->isAvailableOnStore(Mage::app()->getStore())) {
|
111 |
-
return false;
|
112 |
-
}
|
113 |
-
|
114 |
-
Mage::register('current_review', $review);
|
115 |
-
|
116 |
-
return $review;
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Submit new review action
|
121 |
-
*
|
122 |
-
*/
|
123 |
-
public function postAction()
|
124 |
-
{
|
125 |
-
|
126 |
-
echo "phani";
|
127 |
-
if (!$this->_validateFormKey()) {
|
128 |
-
// returns to the product item page
|
129 |
-
$this->_redirectReferer();
|
130 |
-
return;
|
131 |
-
}
|
132 |
-
|
133 |
-
if ($data = Mage::getSingleton('review/session')->getFormData(true)) {
|
134 |
-
$rating = array();
|
135 |
-
if (isset($data['ratings']) && is_array($data['ratings'])) {
|
136 |
-
$rating = $data['ratings'];
|
137 |
-
}
|
138 |
-
} else {
|
139 |
-
$data = $this->getRequest()->getPost();
|
140 |
-
$rating = $this->getRequest()->getParam('ratings', array());
|
141 |
-
}
|
142 |
-
|
143 |
-
if (($product = $this->_initProduct()) && !empty($data)) {
|
144 |
-
$session = Mage::getSingleton('core/session');
|
145 |
-
/* @var $session Mage_Core_Model_Session */
|
146 |
-
$review = Mage::getModel('review/review')->setData($data);
|
147 |
-
/* @var $review Mage_Review_Model_Review */
|
148 |
-
|
149 |
-
$validate = $review->validate();
|
150 |
-
if ($validate === true) {
|
151 |
-
try {
|
152 |
-
$review->setEntityId($review->getEntityIdByCode(Mage_Review_Model_Review::ENTITY_PRODUCT_CODE))
|
153 |
-
->setEntityPkValue($product->getId())
|
154 |
-
->setStatusId(Mage_Review_Model_Review::STATUS_PENDING)
|
155 |
-
->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId())
|
156 |
-
->setStoreId(Mage::app()->getStore()->getId())
|
157 |
-
->setStores(array(Mage::app()->getStore()->getId()))
|
158 |
-
->save();
|
159 |
-
|
160 |
-
foreach ($rating as $ratingId => $optionId) {
|
161 |
-
Mage::getModel('rating/rating')
|
162 |
-
->setRatingId($ratingId)
|
163 |
-
->setReviewId($review->getId())
|
164 |
-
->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId())
|
165 |
-
->addOptionVote($optionId, $product->getId());
|
166 |
-
}
|
167 |
-
|
168 |
-
$review->aggregate();
|
169 |
-
$session->addSuccess($this->__('Your review has been accepted for moderation.'));
|
170 |
-
}
|
171 |
-
catch (Exception $e) {
|
172 |
-
$session->setFormData($data);
|
173 |
-
$session->addError($this->__('Unable to post the review.'));
|
174 |
-
}
|
175 |
-
}
|
176 |
-
else {
|
177 |
-
$session->setFormData($data);
|
178 |
-
if (is_array($validate)) {
|
179 |
-
foreach ($validate as $errorMessage) {
|
180 |
-
$session->addError($errorMessage);
|
181 |
-
}
|
182 |
-
}
|
183 |
-
else {
|
184 |
-
$session->addError($this->__('Unable to post the review.'));
|
185 |
-
}
|
186 |
-
}
|
187 |
-
}
|
188 |
-
|
189 |
-
if ($redirectUrl = Mage::getSingleton('review/session')->getRedirectUrl(true)) {
|
190 |
-
$this->_redirectUrl($redirectUrl);
|
191 |
-
return;
|
192 |
-
}
|
193 |
-
$this->_redirectReferer();
|
194 |
-
}
|
195 |
-
|
196 |
-
/**
|
197 |
-
* Show list of product's reviews
|
198 |
-
*
|
199 |
-
*/
|
200 |
-
public function listAction()
|
201 |
-
{
|
202 |
-
if ($product = $this->_initProduct()) {
|
203 |
-
Mage::register('productId', $product->getId());
|
204 |
-
|
205 |
-
$design = Mage::getSingleton('catalog/design');
|
206 |
-
$settings = $design->getDesignSettings($product);
|
207 |
-
if ($settings->getCustomDesign()) {
|
208 |
-
$design->applyCustomDesign($settings->getCustomDesign());
|
209 |
-
}
|
210 |
-
$this->_initProductLayout($product);
|
211 |
-
|
212 |
-
// update breadcrumbs
|
213 |
-
if ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs')) {
|
214 |
-
$breadcrumbsBlock->addCrumb('product', array(
|
215 |
-
'label' => $product->getName(),
|
216 |
-
'link' => $product->getProductUrl(),
|
217 |
-
'readonly' => true,
|
218 |
-
));
|
219 |
-
$breadcrumbsBlock->addCrumb('reviews', array('label' => Mage::helper('review')->__('Product Reviews')));
|
220 |
-
}
|
221 |
-
|
222 |
-
$this->renderLayout();
|
223 |
-
} elseif (!$this->getResponse()->isRedirect()) {
|
224 |
-
$this->_forward('noRoute');
|
225 |
-
}
|
226 |
-
}
|
227 |
-
|
228 |
-
/**
|
229 |
-
* Show details of one review
|
230 |
-
*
|
231 |
-
*/
|
232 |
-
public function viewAction()
|
233 |
-
{
|
234 |
-
$review = $this->_loadReview((int) $this->getRequest()->getParam('id'));
|
235 |
-
if (!$review) {
|
236 |
-
$this->_forward('noroute');
|
237 |
-
return;
|
238 |
-
}
|
239 |
-
|
240 |
-
$product = $this->_loadProduct($review->getEntityPkValue());
|
241 |
-
if (!$product) {
|
242 |
-
$this->_forward('noroute');
|
243 |
-
return;
|
244 |
-
}
|
245 |
-
|
246 |
-
$this->loadLayout();
|
247 |
-
$this->_initLayoutMessages('review/session');
|
248 |
-
$this->_initLayoutMessages('catalog/session');
|
249 |
-
$this->renderLayout();
|
250 |
-
}
|
251 |
-
|
252 |
-
/**
|
253 |
-
* Load specific layout handles by product type id
|
254 |
-
*
|
255 |
-
*/
|
256 |
-
protected function _initProductLayout($product)
|
257 |
-
{
|
258 |
-
$update = $this->getLayout()->getUpdate();
|
259 |
-
|
260 |
-
$update->addHandle('default');
|
261 |
-
$this->addActionLayoutHandles();
|
262 |
-
|
263 |
-
|
264 |
-
$update->addHandle('PRODUCT_TYPE_'.$product->getTypeId());
|
265 |
-
|
266 |
-
if ($product->getPageLayout()) {
|
267 |
-
$this->getLayout()->helper('page/layout')
|
268 |
-
->applyHandle($product->getPageLayout());
|
269 |
-
}
|
270 |
-
|
271 |
-
$this->loadLayoutUpdates();
|
272 |
-
if ($product->getPageLayout()) {
|
273 |
-
$this->getLayout()->helper('page/layout')
|
274 |
-
->applyTemplate($product->getPageLayout());
|
275 |
-
}
|
276 |
-
$update->addUpdate($product->getCustomLayoutUpdate());
|
277 |
-
$this->generateLayoutXml()->generateLayoutBlocks();
|
278 |
-
}
|
279 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Exinent/Autoapprovereviews/controllers/ProductController.php~
DELETED
@@ -1,288 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Exinent_Autoapprovereviews_ProductController extends Mage_Core_Controller_Front_Action {
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Action list where need check enabled cookie
|
6 |
-
*
|
7 |
-
* @var array
|
8 |
-
*/
|
9 |
-
protected $_cookieCheckActions = array('post');
|
10 |
-
|
11 |
-
public function preDispatch()
|
12 |
-
{
|
13 |
-
parent::preDispatch();
|
14 |
-
|
15 |
-
$allowGuest = Mage::helper('review')->getIsGuestAllowToWrite();
|
16 |
-
if (!$this->getRequest()->isDispatched()) {
|
17 |
-
return;
|
18 |
-
}
|
19 |
-
|
20 |
-
$action = $this->getRequest()->getActionName();
|
21 |
-
if (!$allowGuest && $action == 'post' && $this->getRequest()->isPost()) {
|
22 |
-
if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
|
23 |
-
$this->setFlag('', self::FLAG_NO_DISPATCH, true);
|
24 |
-
Mage::getSingleton('customer/session')->setBeforeAuthUrl(Mage::getUrl('*/*/*', array('_current' => true)));
|
25 |
-
Mage::getSingleton('review/session')->setFormData($this->getRequest()->getPost())
|
26 |
-
->setRedirectUrl($this->_getRefererUrl());
|
27 |
-
$this->_redirectUrl(Mage::helper('customer')->getLoginUrl());
|
28 |
-
}
|
29 |
-
}
|
30 |
-
|
31 |
-
return $this;
|
32 |
-
}
|
33 |
-
/**
|
34 |
-
* Initialize and check product
|
35 |
-
*
|
36 |
-
* @return Mage_Catalog_Model_Product
|
37 |
-
*/
|
38 |
-
protected function _initProduct()
|
39 |
-
{
|
40 |
-
Mage::dispatchEvent('review_controller_product_init_before', array('controller_action'=>$this));
|
41 |
-
$categoryId = (int) $this->getRequest()->getParam('category', false);
|
42 |
-
$productId = (int) $this->getRequest()->getParam('id');
|
43 |
-
|
44 |
-
$product = $this->_loadProduct($productId);
|
45 |
-
if (!$product) {
|
46 |
-
return false;
|
47 |
-
}
|
48 |
-
|
49 |
-
if ($categoryId) {
|
50 |
-
$category = Mage::getModel('catalog/category')->load($categoryId);
|
51 |
-
Mage::register('current_category', $category);
|
52 |
-
}
|
53 |
-
|
54 |
-
try {
|
55 |
-
Mage::dispatchEvent('review_controller_product_init', array('product'=>$product));
|
56 |
-
Mage::dispatchEvent('review_controller_product_init_after', array(
|
57 |
-
'product' => $product,
|
58 |
-
'controller_action' => $this
|
59 |
-
));
|
60 |
-
} catch (Mage_Core_Exception $e) {
|
61 |
-
Mage::logException($e);
|
62 |
-
return false;
|
63 |
-
}
|
64 |
-
|
65 |
-
return $product;
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Load product model with data by passed id.
|
70 |
-
* Return false if product was not loaded or has incorrect status.
|
71 |
-
*
|
72 |
-
* @param int $productId
|
73 |
-
* @return bool|Mage_Catalog_Model_Product
|
74 |
-
*/
|
75 |
-
protected function _loadProduct($productId)
|
76 |
-
{
|
77 |
-
if (!$productId) {
|
78 |
-
return false;
|
79 |
-
}
|
80 |
-
|
81 |
-
$product = Mage::getModel('catalog/product')
|
82 |
-
->setStoreId(Mage::app()->getStore()->getId())
|
83 |
-
->load($productId);
|
84 |
-
/* @var $product Mage_Catalog_Model_Product */
|
85 |
-
if (!$product->getId() || !$product->isVisibleInCatalog() || !$product->isVisibleInSiteVisibility()) {
|
86 |
-
return false;
|
87 |
-
}
|
88 |
-
|
89 |
-
Mage::register('current_product', $product);
|
90 |
-
Mage::register('product', $product);
|
91 |
-
|
92 |
-
return $product;
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Load review model with data by passed id.
|
97 |
-
* Return false if review was not loaded or review is not approved.
|
98 |
-
*
|
99 |
-
* @param int $productId
|
100 |
-
* @return bool|Mage_Review_Model_Review
|
101 |
-
*/
|
102 |
-
protected function _loadReview($reviewId)
|
103 |
-
{
|
104 |
-
if (!$reviewId) {
|
105 |
-
return false;
|
106 |
-
}
|
107 |
-
|
108 |
-
$review = Mage::getModel('review/review')->load($reviewId);
|
109 |
-
/* @var $review Mage_Review_Model_Review */
|
110 |
-
if (!$review->getId() || !$review->isApproved() || !$review->isAvailableOnStore(Mage::app()->getStore())) {
|
111 |
-
return false;
|
112 |
-
}
|
113 |
-
|
114 |
-
Mage::register('current_review', $review);
|
115 |
-
|
116 |
-
return $review;
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Submit new review action
|
121 |
-
*
|
122 |
-
*/
|
123 |
-
public function postAction()
|
124 |
-
{
|
125 |
-
|
126 |
-
|
127 |
-
if (!$this->_validateFormKey()) {
|
128 |
-
// returns to the product item page
|
129 |
-
$this->_redirectReferer();
|
130 |
-
return;
|
131 |
-
}
|
132 |
-
|
133 |
-
if ($data = Mage::getSingleton('review/session')->getFormData(true)) {
|
134 |
-
$rating = array();
|
135 |
-
if (isset($data['ratings']) && is_array($data['ratings'])) {
|
136 |
-
$rating = $data['ratings'];
|
137 |
-
}
|
138 |
-
} else {
|
139 |
-
$data = $this->getRequest()->getPost();
|
140 |
-
$rating = $this->getRequest()->getParam('ratings', array());
|
141 |
-
}
|
142 |
-
|
143 |
-
if (($product = $this->_initProduct()) && !empty($data)) {
|
144 |
-
$session = Mage::getSingleton('core/session');
|
145 |
-
/* @var $session Mage_Core_Model_Session */
|
146 |
-
$review = Mage::getModel('review/review')->setData($data);
|
147 |
-
/* @var $review Mage_Review_Model_Review */
|
148 |
-
|
149 |
-
//$notAllowRegisterd = Mage::helper('review')->IsAutoApproveEnabled();
|
150 |
-
|
151 |
-
$regulerLogin = Mage::helper('autoapprovereviews')->IsAutoApproveEnabled();
|
152 |
-
if(!$regulerLogin) {
|
153 |
-
$validate = $review->validate();
|
154 |
-
if ($validate === true) {
|
155 |
-
try {
|
156 |
-
$review->setEntityId($review->getEntityIdByCode(Mage_Review_Model_Review::ENTITY_PRODUCT_CODE))
|
157 |
-
->setEntityPkValue($product->getId())
|
158 |
-
->setStatusId(Mage_Review_Model_Review::STATUS_PENDING)
|
159 |
-
->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId())
|
160 |
-
->setStoreId(Mage::app()->getStore()->getId())
|
161 |
-
->setStores(array(Mage::app()->getStore()->getId()))
|
162 |
-
->save();
|
163 |
-
|
164 |
-
foreach ($rating as $ratingId => $optionId) {
|
165 |
-
Mage::getModel('rating/rating')
|
166 |
-
->setRatingId($ratingId)
|
167 |
-
->setReviewId($review->getId())
|
168 |
-
->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId())
|
169 |
-
->addOptionVote($optionId, $product->getId());
|
170 |
-
}
|
171 |
-
|
172 |
-
$review->aggregate();
|
173 |
-
$session->addSuccess($this->__('Your review has been accepted for moderation.'));
|
174 |
-
}
|
175 |
-
catch (Exception $e) {
|
176 |
-
$session->setFormData($data);
|
177 |
-
$session->addError($this->__('Unable to post the review.'));
|
178 |
-
}
|
179 |
-
}
|
180 |
-
else {
|
181 |
-
$session->setFormData($data);
|
182 |
-
if (is_array($validate)) {
|
183 |
-
foreach ($validate as $errorMessage) {
|
184 |
-
$session->addError($errorMessage);
|
185 |
-
}
|
186 |
-
}
|
187 |
-
else {
|
188 |
-
$session->addError($this->__('Unable to post the review.'));
|
189 |
-
}
|
190 |
-
}
|
191 |
-
}
|
192 |
-
}
|
193 |
-
else if (1) {
|
194 |
-
|
195 |
-
echo "phani";die();
|
196 |
-
}
|
197 |
-
|
198 |
-
if ($redirectUrl = Mage::getSingleton('review/session')->getRedirectUrl(true)) {
|
199 |
-
$this->_redirectUrl($redirectUrl);
|
200 |
-
return;
|
201 |
-
}
|
202 |
-
$this->_redirectReferer();
|
203 |
-
}
|
204 |
-
|
205 |
-
/**
|
206 |
-
* Show list of product's reviews
|
207 |
-
*
|
208 |
-
*/
|
209 |
-
public function listAction()
|
210 |
-
{
|
211 |
-
if ($product = $this->_initProduct()) {
|
212 |
-
Mage::register('productId', $product->getId());
|
213 |
-
|
214 |
-
$design = Mage::getSingleton('catalog/design');
|
215 |
-
$settings = $design->getDesignSettings($product);
|
216 |
-
if ($settings->getCustomDesign()) {
|
217 |
-
$design->applyCustomDesign($settings->getCustomDesign());
|
218 |
-
}
|
219 |
-
$this->_initProductLayout($product);
|
220 |
-
|
221 |
-
// update breadcrumbs
|
222 |
-
if ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs')) {
|
223 |
-
$breadcrumbsBlock->addCrumb('product', array(
|
224 |
-
'label' => $product->getName(),
|
225 |
-
'link' => $product->getProductUrl(),
|
226 |
-
'readonly' => true,
|
227 |
-
));
|
228 |
-
$breadcrumbsBlock->addCrumb('reviews', array('label' => Mage::helper('review')->__('Product Reviews')));
|
229 |
-
}
|
230 |
-
|
231 |
-
$this->renderLayout();
|
232 |
-
} elseif (!$this->getResponse()->isRedirect()) {
|
233 |
-
$this->_forward('noRoute');
|
234 |
-
}
|
235 |
-
}
|
236 |
-
|
237 |
-
/**
|
238 |
-
* Show details of one review
|
239 |
-
*
|
240 |
-
*/
|
241 |
-
public function viewAction()
|
242 |
-
{
|
243 |
-
$review = $this->_loadReview((int) $this->getRequest()->getParam('id'));
|
244 |
-
if (!$review) {
|
245 |
-
$this->_forward('noroute');
|
246 |
-
return;
|
247 |
-
}
|
248 |
-
|
249 |
-
$product = $this->_loadProduct($review->getEntityPkValue());
|
250 |
-
if (!$product) {
|
251 |
-
$this->_forward('noroute');
|
252 |
-
return;
|
253 |
-
}
|
254 |
-
|
255 |
-
$this->loadLayout();
|
256 |
-
$this->_initLayoutMessages('review/session');
|
257 |
-
$this->_initLayoutMessages('catalog/session');
|
258 |
-
$this->renderLayout();
|
259 |
-
}
|
260 |
-
|
261 |
-
/**
|
262 |
-
* Load specific layout handles by product type id
|
263 |
-
*
|
264 |
-
*/
|
265 |
-
protected function _initProductLayout($product)
|
266 |
-
{
|
267 |
-
$update = $this->getLayout()->getUpdate();
|
268 |
-
|
269 |
-
$update->addHandle('default');
|
270 |
-
$this->addActionLayoutHandles();
|
271 |
-
|
272 |
-
|
273 |
-
$update->addHandle('PRODUCT_TYPE_'.$product->getTypeId());
|
274 |
-
|
275 |
-
if ($product->getPageLayout()) {
|
276 |
-
$this->getLayout()->helper('page/layout')
|
277 |
-
->applyHandle($product->getPageLayout());
|
278 |
-
}
|
279 |
-
|
280 |
-
$this->loadLayoutUpdates();
|
281 |
-
if ($product->getPageLayout()) {
|
282 |
-
$this->getLayout()->helper('page/layout')
|
283 |
-
->applyTemplate($product->getPageLayout());
|
284 |
-
}
|
285 |
-
$update->addUpdate($product->getCustomLayoutUpdate());
|
286 |
-
$this->generateLayoutXml()->generateLayoutBlocks();
|
287 |
-
}
|
288 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Exinent/Autoapprovereviews/etc/config.xml~
DELETED
@@ -1,74 +0,0 @@
|
|
1 |
-
<config>
|
2 |
-
<modules>
|
3 |
-
<Exinent_Autoapprovereviews>
|
4 |
-
<version>0.1.0</version>
|
5 |
-
</Exinent_Autoapprovereviews>
|
6 |
-
</modules>
|
7 |
-
<frontend>
|
8 |
-
<routers>
|
9 |
-
<autoapprovereviews>
|
10 |
-
<use>standard</use>
|
11 |
-
<args>
|
12 |
-
<module>Exinent_Autoapprovereviews</module>
|
13 |
-
<frontName>autoapprovereviews</frontName>
|
14 |
-
</args>
|
15 |
-
</autoapprovereviews>
|
16 |
-
</routers>
|
17 |
-
</frontend>
|
18 |
-
<global>
|
19 |
-
<helpers>
|
20 |
-
<autoapprovereviews>
|
21 |
-
<class>Exinent_Autoapprovereviews_Helper</class>
|
22 |
-
</autoapprovereviews>
|
23 |
-
</helpers>
|
24 |
-
<models>
|
25 |
-
<autoapprovereviews>
|
26 |
-
<class>Exinent_Autoapprovereviews_Model</class>
|
27 |
-
<resourceModel>autoapprovereviews_resource</resourceModel>
|
28 |
-
</autoapprovereviews>
|
29 |
-
<autoapprovereviews_resource>
|
30 |
-
<class>Exinent_Autoapprovereviews_Model_Resource</class>
|
31 |
-
</autoapprovereviews_resource>
|
32 |
-
</models>
|
33 |
-
</global>
|
34 |
-
|
35 |
-
<!-- This rewrite rule could be added to the database instead -->
|
36 |
-
<rewrite>
|
37 |
-
<!-- This is an identifier for your rewrite that should be unique -->
|
38 |
-
<!-- THIS IS THE CLASSNAME IN YOUR OWN CONTROLLER -->
|
39 |
-
<customcontactsunique>
|
40 |
-
<from><![CDATA[#^/review/product/#]]></from>
|
41 |
-
<!--
|
42 |
-
- mymodule matches the router frontname below
|
43 |
-
- matches the path to your controller
|
44 |
-
|
45 |
-
Considering the router below, "/customcontacts/index/" will be
|
46 |
-
"translated" to "app/code/local/Amit/Customcontacts/controllers/IndexController.php" (?)
|
47 |
-
-->
|
48 |
-
<to>/autoapprovereviews/product/</to>
|
49 |
-
</customcontactsunique>
|
50 |
-
</rewrite>
|
51 |
-
|
52 |
-
- See more at: http://www.amitbera.com/how-to-override-a-controller-in-magento/#sthash.bNyssa8b.dpuf
|
53 |
-
<adminhtml>
|
54 |
-
<acl>
|
55 |
-
<resources>
|
56 |
-
<admin>
|
57 |
-
<children>
|
58 |
-
<system>
|
59 |
-
<children>
|
60 |
-
<config>
|
61 |
-
<children>
|
62 |
-
<autoapprovereviews_settings>
|
63 |
-
<title>Review Settings</title>
|
64 |
-
</autoapprovereviews_settings>
|
65 |
-
</children>
|
66 |
-
</config>
|
67 |
-
</children>
|
68 |
-
</system>
|
69 |
-
</children>
|
70 |
-
</admin>
|
71 |
-
</resources>
|
72 |
-
</acl>
|
73 |
-
</adminhtml>
|
74 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Exinent/Autoapprovereviews/etc/system.xml~
DELETED
@@ -1,70 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* Magento
|
5 |
-
*
|
6 |
-
* NOTICE OF LICENSE
|
7 |
-
*
|
8 |
-
* This source file is subject to the Academic Free License (AFL 3.0)
|
9 |
-
* that is bundled with this package in the file LICENSE_AFL.txt.
|
10 |
-
* It is also available through the world-wide-web at this URL:
|
11 |
-
* http://opensource.org/licenses/afl-3.0.php
|
12 |
-
* If you did not receive a copy of the license and are unable to
|
13 |
-
* obtain it through the world-wide-web, please send an email
|
14 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
-
*
|
16 |
-
* DISCLAIMER
|
17 |
-
*
|
18 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
-
* versions in the future. If you wish to customize Magento for your
|
20 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
-
*
|
22 |
-
* @category Mage
|
23 |
-
* @package Mage_Sendfriend
|
24 |
-
* @copyright Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
|
25 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
26 |
-
*/
|
27 |
-
-->
|
28 |
-
<config>
|
29 |
-
<sections>
|
30 |
-
<autoapprovereviews_settings translate="label" module="autoapprovereviews">
|
31 |
-
<label>Product Review Settings</label>
|
32 |
-
<tab>catalog</tab>
|
33 |
-
<frontend_type>text</frontend_type>
|
34 |
-
<sort_order>120</sort_order>
|
35 |
-
<show_in_default>1</show_in_default>
|
36 |
-
<show_in_website>1</show_in_website>
|
37 |
-
<show_in_store>1</show_in_store>
|
38 |
-
<groups>
|
39 |
-
<autoapprovegroup translate="label">
|
40 |
-
<label>Review Settings for logged in Users</label>
|
41 |
-
<frontend_type>text</frontend_type>
|
42 |
-
<sort_order>1</sort_order>
|
43 |
-
<show_in_default>1</show_in_default>
|
44 |
-
<show_in_website>1</show_in_website>
|
45 |
-
<show_in_store>1</show_in_store>
|
46 |
-
<fields>
|
47 |
-
<autoapprove_enabled translate="label">
|
48 |
-
<label>Enabled</label>
|
49 |
-
<frontend_type>select</frontend_type>
|
50 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
51 |
-
<sort_order>1</sort_order>
|
52 |
-
<show_in_default>1</show_in_default>
|
53 |
-
<show_in_website>1</show_in_website>
|
54 |
-
<show_in_store>1</show_in_store>
|
55 |
-
</autoapprove_enabled>
|
56 |
-
<login_review>
|
57 |
-
<label>Require Activation for Groups</label>
|
58 |
-
<frontend_type>multiselect</frontend_type>
|
59 |
-
<source_model>adminhtml/system_config_source_customer_group_multiselect</source_model>
|
60 |
-
<sort_order>12</sort_order>
|
61 |
-
<show_in_default>1</show_in_default>
|
62 |
-
<show_in_website>1</show_in_website>
|
63 |
-
<show_in_store>1</show_in_store>
|
64 |
-
</login_review>
|
65 |
-
</fields>
|
66 |
-
</autoapprovegroup>
|
67 |
-
</groups>
|
68 |
-
</autoapprovereviews_settings>
|
69 |
-
</sections>
|
70 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Auto_Reviews</name>
|
4 |
-
<version>
|
5 |
<stability>stable</stability>
|
6 |
-
<license>Open Software License</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>
|
10 |
-
<description>
|
11 |
-
<notes>
|
12 |
-
<authors><author><name>Exinent
|
13 |
-
<date>2015-04-
|
14 |
-
<time>
|
15 |
-
<contents><target name="magecommunity"><dir name="Exinent"><dir name="Autoapprovereviews"><dir name="
|
16 |
<compatible/>
|
17 |
-
<dependencies><required><php><min>5.
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Auto_Reviews</name>
|
4 |
+
<version>2.0.0</version>
|
5 |
<stability>stable</stability>
|
6 |
+
<license>Open Software License (OSL)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>Auto approves product reviews based on customer type.</summary>
|
10 |
+
<description>Auto approves product reviews based on customer type.</description>
|
11 |
+
<notes>Auto approves product reviews based on customer type.</notes>
|
12 |
+
<authors><author><name>Exinent </name><user>Developer</user><email>developer@exinent.com</email></author></authors>
|
13 |
+
<date>2015-04-29</date>
|
14 |
+
<time>06:07:50</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Exinent"><dir name="Autoapprovereviews"><dir name="Helper"><file name="Data.php" hash="c066b27a7d0c243ef6910e0d11ee9a05"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Source"><dir name="Customer"><dir name="Group"><file name="Multiselect.php" hash="a77f750f58703d8c551c9ec95cf3a154"/></dir></dir></dir></dir></dir></dir></dir><dir name="controllers"><file name="ProductController.php" hash="4c157fedaa9882fc7f1c599b967228d6"/></dir><dir name="etc"><file name="config.xml" hash="f50c98a0dc06526d87a9e6c53be0a767"/><file name="system.xml" hash="5748381712c0c4cd285b3f54a2360519"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Exinent_Autoapprovereviews.xml" hash="b468d55a398b1dd70240269b4bae9997"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|