Criteek_Reviewsystem - Version 1.0.0

Version Notes

Customer Review video content

Download this release

Release Info

Developer Criteek
Extension Criteek_Reviewsystem
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (41) hide show
  1. app/code/community/Criteek/.DS_Store +0 -0
  2. app/code/community/Criteek/Reviewsystem/.DS_Store +0 -0
  3. app/code/community/Criteek/Reviewsystem/Block/Adminhtml/Analytics.php +23 -0
  4. app/code/community/Criteek/Reviewsystem/Block/Adminhtml/Analytics/Grid.php +98 -0
  5. app/code/community/Criteek/Reviewsystem/Block/Adminhtml/Analytics/Grid/Renderer/Reopened.php +30 -0
  6. app/code/community/Criteek/Reviewsystem/Block/Adminhtml/Analytics/Grid/Renderer/Status.php +54 -0
  7. app/code/community/Criteek/Reviewsystem/Block/Adminhtml/Category.php +36 -0
  8. app/code/community/Criteek/Reviewsystem/Block/Adminhtml/Category/Edit.php +43 -0
  9. app/code/community/Criteek/Reviewsystem/Block/Adminhtml/Category/Edit/Form.php +43 -0
  10. app/code/community/Criteek/Reviewsystem/Block/Adminhtml/Category/Grid.php +130 -0
  11. app/code/community/Criteek/Reviewsystem/Helper/Data.php +388 -0
  12. app/code/community/Criteek/Reviewsystem/Model/.DS_Store +0 -0
  13. app/code/community/Criteek/Reviewsystem/Model/Category.php +20 -0
  14. app/code/community/Criteek/Reviewsystem/Model/Cron.php +65 -0
  15. app/code/community/Criteek/Reviewsystem/Model/EmailQueue.php +19 -0
  16. app/code/community/Criteek/Reviewsystem/Model/Mysql4/.DS_Store +0 -0
  17. app/code/community/Criteek/Reviewsystem/Model/Mysql4/Category.php +25 -0
  18. app/code/community/Criteek/Reviewsystem/Model/Mysql4/Category/Collection.php +26 -0
  19. app/code/community/Criteek/Reviewsystem/Model/Mysql4/EmailQueue.php +25 -0
  20. app/code/community/Criteek/Reviewsystem/Model/Mysql4/EmailQueue/Collection.php +55 -0
  21. app/code/community/Criteek/Reviewsystem/Model/Observer.php +168 -0
  22. app/code/community/Criteek/Reviewsystem/Model/Order/Status.php +29 -0
  23. app/code/community/Criteek/Reviewsystem/controllers/Adminhtml/AnalyticsController.php +172 -0
  24. app/code/community/Criteek/Reviewsystem/controllers/Adminhtml/CategoryController.php +128 -0
  25. app/code/community/Criteek/Reviewsystem/controllers/Adminhtml/DashboardController.php +30 -0
  26. app/code/community/Criteek/Reviewsystem/data/.DS_Store +0 -0
  27. app/code/community/Criteek/Reviewsystem/data/reviewsystem_setup/data-install-1.0.0.php +28 -0
  28. app/code/community/Criteek/Reviewsystem/etc/adminhtml.xml +58 -0
  29. app/code/community/Criteek/Reviewsystem/etc/config.xml +181 -0
  30. app/code/community/Criteek/Reviewsystem/etc/system.xml +112 -0
  31. app/code/community/Criteek/Reviewsystem/sql/.DS_Store +0 -0
  32. app/code/community/Criteek/Reviewsystem/sql/reviewsystem_setup/mysql4-install-1.0.0.php +72 -0
  33. app/design/adminhtml/default/default/layout/reviewsystem.xml +34 -0
  34. app/design/adminhtml/default/default/template/reviewsystem/emailanalytics.phtml +295 -0
  35. app/design/adminhtml/default/default/template/reviewsystem/grid.phtml +213 -0
  36. app/design/adminhtml/default/default/template/reviewsystem/grid/container.phtml +45 -0
  37. app/design/frontend/base/default/template/reviewsystem/reviewcode.phtml +23 -0
  38. app/etc/modules/Criteek_Reviewsystem.xml +10 -0
  39. app/locale/en_US/template/email/account_new_confirmation.html +50 -0
  40. js/reviewsystem/widgetcode.js +26 -0
  41. package.xml +20 -0
app/code/community/Criteek/.DS_Store ADDED
Binary file
app/code/community/Criteek/Reviewsystem/.DS_Store ADDED
Binary file
app/code/community/Criteek/Reviewsystem/Block/Adminhtml/Analytics.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ *
7
+ * @category Criteek
8
+ * @package Criteek_Reviewsystem
9
+ * @copyright Copyright (c) 2016 Criteek Comm LLC.
10
+ * @author Criteek Developer
11
+ * @license https://www.criteek.tv/terms-of-use CRITEEK TERMS OF USE
12
+ */
13
+
14
+ class Criteek_Reviewsystem_Block_Adminhtml_Analytics extends Mage_Adminhtml_Block_Widget_Grid_Container {
15
+
16
+ public function __construct() {
17
+ $this->_blockGroup = 'reviewsystem';
18
+ $this->_controller = 'adminhtml_analytics';
19
+ $this->_headerText = Mage::helper('reviewsystem')->__('Email Analytics');
20
+ parent::__construct();
21
+ $this->_removeButton('add');
22
+ }
23
+ }
app/code/community/Criteek/Reviewsystem/Block/Adminhtml/Analytics/Grid.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ *
7
+ * @category Criteek
8
+ * @package Criteek_Reviewsystem
9
+ * @copyright Copyright (c) 2016 Criteek Comm LLC.
10
+ * @author Criteek Developer
11
+ * @license https://www.criteek.tv/terms-of-use CRITEEK TERMS OF USE
12
+ */
13
+
14
+ class Criteek_Reviewsystem_Block_Adminhtml_Analytics_Grid extends Mage_Adminhtml_Block_Report_Grid
15
+ {
16
+
17
+ public function __construct()
18
+ {
19
+ parent::__construct();
20
+ $this->setId('gridAnalytics');
21
+ $this->setTemplate('reviewsystem/grid.phtml');
22
+ $this->setDefaultSort('id');
23
+
24
+ }
25
+
26
+ protected function _prepareCollection()
27
+ {
28
+ parent::_prepareCollection();
29
+ $this->_prepareTotals('customer_name,reopened');
30
+ return $this->getCollection()->initReport('reviewsystem/emailQueue_collection');
31
+
32
+ }
33
+
34
+ protected function _prepareColumns()
35
+ {
36
+ $this->addColumn('product_name', array(
37
+ 'header' =>Mage::helper('reviewsystem')->__('Product Name'),
38
+ 'index' =>'product_name',
39
+ 'sortable' => false,
40
+ 'filter' => false,
41
+ ));
42
+
43
+ $this->addColumn('customer_name', array(
44
+ 'header' =>Mage::helper('reviewsystem')->__('Customern Name'),
45
+ 'index' =>'customer_name',
46
+ 'sortable' => false,
47
+ 'filter' => false,
48
+ ));
49
+
50
+ $this->addColumn('customer_email', array(
51
+ 'header' =>Mage::helper('reviewsystem')->__('Email received'),
52
+ 'index' =>'customer_email',
53
+ 'sortable' => false,
54
+ 'filter' => false,
55
+ ));
56
+
57
+ $this->addColumn('reopened', array(
58
+ 'header' =>Mage::helper('reviewsystem')->__('Responded by Customer'),
59
+ 'index' =>'reopened',
60
+ 'sortable' => false,
61
+ 'renderer' => 'Criteek_Reviewsystem_Block_Adminhtml_Analytics_Grid_Renderer_Reopened',
62
+ 'filter' => false,
63
+ ));
64
+
65
+ $this->addColumn('status', array(
66
+ 'header' =>Mage::helper('reviewsystem')->__('Review Uploaded by Customer'),
67
+ 'index' =>'status',
68
+ 'renderer' => 'Criteek_Reviewsystem_Block_Adminhtml_Analytics_Grid_Renderer_Status',
69
+ ));
70
+
71
+ $this->addExportType('*/*/exportSimpleCsv', Mage::helper('reviewsystem')->__('CSV'));
72
+
73
+ return parent::_prepareColumns();
74
+ }
75
+
76
+ protected function _prepareTotals($columns = null){
77
+ $columns=explode(',',$columns);
78
+ if(!$columns){
79
+ return;
80
+ }
81
+ $this->_countTotals = true;
82
+ $totals = new Varien_Object();
83
+ $fields = array();
84
+ foreach($columns as $column){
85
+ $fields[$column] = 0;
86
+ }
87
+ foreach ($this->getCollection() as $item) {
88
+ foreach($fields as $field=>$value){
89
+ $fields[$field]+=$item->getData($field);
90
+ }
91
+ }
92
+ $totals->setData($fields);
93
+ $this->setTotals($totals);
94
+ return;
95
+ }
96
+
97
+
98
+ }
app/code/community/Criteek/Reviewsystem/Block/Adminhtml/Analytics/Grid/Renderer/Reopened.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ *
7
+ * @category Criteek
8
+ * @package Criteek_Reviewsystem
9
+ * @copyright Copyright (c) 2016 Criteek Comm LLC.
10
+ * @author Criteek Developer
11
+ * @license https://www.criteek.tv/terms-of-use CRITEEK TERMS OF USE
12
+ */
13
+
14
+ class Criteek_Reviewsystem_Block_Adminhtml_Analytics_Grid_Renderer_Reopened extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
15
+ {
16
+ public function render(Varien_Object $row)
17
+ {
18
+ return $this->_getValue($row);
19
+ }
20
+ protected function _getValue(Varien_Object $row)
21
+ {
22
+ $val = $row->getData($this->getColumn()->getIndex());
23
+ if($val==1)
24
+ {$val="Yes";
25
+ }else{
26
+ $val="No";
27
+ }
28
+ return $val;
29
+ }
30
+ }
app/code/community/Criteek/Reviewsystem/Block/Adminhtml/Analytics/Grid/Renderer/Status.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ *
7
+ * @category Criteek
8
+ * @package Criteek_Reviewsystem
9
+ * @copyright Copyright (c) 2016 Criteek Comm LLC.
10
+ * @author Criteek Developer
11
+ * @license https://www.criteek.tv/terms-of-use CRITEEK TERMS OF USE
12
+ */
13
+
14
+ class Criteek_Reviewsystem_Block_Adminhtml_Analytics_Grid_Renderer_Status extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
15
+ {
16
+ public function render(Varien_Object $row)
17
+ {
18
+ return $this->_getValue($row);
19
+ }
20
+ protected function _getValue(Varien_Object $row)
21
+ {
22
+ $val = $row->getData();
23
+ $cutomer_email =$val['customer_email'];
24
+ $customer_time = $val['email_time'];
25
+ $dt = new DateTime($customer_time);
26
+ $date_mail = $dt->format('Y-m-d');
27
+ $product_id = $val['product_id'];
28
+ $customer_name = $val['customer_name'];
29
+ $collection= Mage::getModel('catalog/product')->getCollection()->addFieldToFilter('entity_id', $product_id)->getFirstItem();
30
+ $sku =$collection->getSku();
31
+ if ($col =Mage::getModel('reviewsystem/product')->getCollection()->addFieldToFilter('product_sku', $sku)->getFirstItem())
32
+ {
33
+ $pid =$col->getPid();
34
+ $i=0;
35
+ foreach(Mage::helper('reviewsystem')->fetchReviewersInfo($pid)->message as $info)
36
+ {
37
+
38
+ $reviewerEmail =$info->reviewer_email;
39
+ $reviewerName =$info->reviewer_name;
40
+
41
+ if(strcasecmp($reviewerEmail, $cutomer_email)==0 && (strtotime(substr($info->reviewdate,0,11))>strtotime($date_mail))){
42
+ $i++;
43
+ }
44
+
45
+ }
46
+ if($i>0){
47
+ $value= Mage::helper('reviewsystem')->__('Yes(').$i.")";
48
+ }else{
49
+ $value= Mage::helper('reviewsystem')->__('No(').$i.")";
50
+ }
51
+ }
52
+ return $value;
53
+ }
54
+ }
app/code/community/Criteek/Reviewsystem/Block/Adminhtml/Category.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ *
7
+ * @category Criteek
8
+ * @package Criteek_Reviewsystem
9
+ * @copyright Copyright (c) 2016 Criteek Comm LLC.
10
+ * @author Criteek Developer
11
+ * @license https://www.criteek.tv/terms-of-use CRITEEK TERMS OF USE
12
+ */
13
+
14
+
15
+ class Criteek_Reviewsystem_Block_Adminhtml_Category extends Mage_Adminhtml_Block_Widget_Grid_Container {
16
+
17
+ /**
18
+ * constructor
19
+ *
20
+ */
21
+ public function __construct() {
22
+ $this->_controller = 'adminhtml_category';
23
+ $this->_blockGroup = 'reviewsystem';
24
+ $this->_headerText = 'Top Level Categories';
25
+ $data = array(
26
+ 'label' => 'Back',
27
+ 'onclick' => "goToParent('".$this->getUrl('*/*/grid', array('_current'=>false))."')",
28
+ 'id' => "back-to-parent",
29
+ //'class' => 'back'
30
+ );
31
+ parent::__construct();
32
+ $this->_removeButton('add');
33
+ $this->_removeButton('back');
34
+
35
+ }
36
+ }
app/code/community/Criteek/Reviewsystem/Block/Adminhtml/Category/Edit.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ *
7
+ * @category Criteek
8
+ * @package Criteek_Reviewsystem
9
+ * @copyright Copyright (c) 2016 Criteek Comm LLC.
10
+ * @author Criteek Developer
11
+ * @license https://www.criteek.tv/terms-of-use CRITEEK TERMS OF USE
12
+ */
13
+
14
+ class Criteek_Reviewsystem_Block_Adminhtml_Category_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
15
+ {
16
+ public function __construct()
17
+ {
18
+ parent::__construct();
19
+
20
+ $this->_objectId = 'id';
21
+ $this->_blockGroup = 'reviewsystem';
22
+ $this->_controller = 'adminhtml_category';
23
+ $this->_mode = 'edit';
24
+ $this->_removeButton('delete');
25
+ $this->_updateButton('save', 'label', Mage::helper('reviewsystem')->__('Save Interval for Category'));
26
+
27
+
28
+ }
29
+
30
+ public function getHeaderText()
31
+ { $categoryId =$this->getRequest()->getParam('id');
32
+
33
+ if ($categoryId )
34
+ { $category=Mage::getModel('catalog/category')->load($categoryId);
35
+ return Mage::helper('reviewsystem')->__('Set Interval for category "%s"', $this->htmlEscape($category->getName()));
36
+ } else {
37
+ return Mage::helper('reviewsystem')->__('Set Interval for category');
38
+ }
39
+ }
40
+
41
+
42
+
43
+ }
app/code/community/Criteek/Reviewsystem/Block/Adminhtml/Category/Edit/Form.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ *
7
+ * @category Criteek
8
+ * @package Criteek_Reviewsystem
9
+ * @copyright Copyright (c) 2016 Criteek Comm LLC.
10
+ * @author Criteek Developer
11
+ * @license https://www.criteek.tv/terms-of-use CRITEEK TERMS OF USE
12
+ */
13
+
14
+
15
+ class Criteek_Reviewsystem_Block_Adminhtml_Category_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
16
+ {
17
+ protected function _prepareForm()
18
+ {
19
+ $form = new Varien_Data_Form(array(
20
+ 'id' => 'edit_form',
21
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
22
+ 'method' => 'post'
23
+
24
+ )
25
+ );
26
+
27
+ $fieldset = $form->addFieldset('category_form', array(
28
+ 'legend' =>Mage::helper('reviewsystem')->__('Category information')
29
+ ));
30
+ $fieldset->addField('interval', 'text', array(
31
+ 'label' => Mage::helper('reviewsystem')->__('Set Interval'),
32
+ 'class' => 'required-entry',
33
+ 'required' => true,
34
+ 'name' => 'interval',
35
+ 'value' =>10,
36
+ 'note' => Mage::helper('reviewsystem')->__('Set the interval in days here.'),
37
+ ));
38
+
39
+ $form->setUseContainer(true);
40
+ $this->setForm($form);
41
+ return parent::_prepareForm();
42
+ }
43
+ }
app/code/community/Criteek/Reviewsystem/Block/Adminhtml/Category/Grid.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ *
7
+ * @category Criteek
8
+ * @package Criteek_Reviewsystem
9
+ * @copyright Copyright (c) 2016 Criteek Comm LLC.
10
+ * @author Criteek Developer
11
+ * @license https://www.criteek.tv/terms-of-use CRITEEK TERMS OF USE
12
+ */
13
+
14
+ class Criteek_Reviewsystem_Block_Adminhtml_Category_Grid extends Mage_Adminhtml_Block_Widget_Grid
15
+ {
16
+ /**
17
+ * Constructor
18
+ *
19
+ * @return unknown
20
+ */
21
+ public function __construct()
22
+ {
23
+ parent::__construct();
24
+
25
+ $this->setId('category_grid');
26
+ $this->setUseAjax(true);
27
+ $this->setPagerVisibility(true);
28
+ $this->setFilterVisibility(false);
29
+ }
30
+
31
+ /**
32
+ * prepare collection for grid
33
+ *
34
+ */
35
+ protected function _prepareCollection()
36
+ {
37
+
38
+ $collection = new Varien_Data_Collection();
39
+
40
+ $helper = Mage::helper('reviewsystem');
41
+
42
+ $model = Mage::getModel('reviewsystem/category')->getCollection();
43
+
44
+ if($model){
45
+
46
+ foreach( $model as $category) {
47
+ $categoryCollection=Mage::getModel('catalog/category')->load($category->getCategoryId());
48
+ //$main_cat_title[] = $main_cat['title']; // Main Category title
49
+ $rowObj = new Varien_Object();
50
+ $rowObj->setName($categoryCollection->getName());
51
+
52
+ $rowObj->setId($category->getCategoryId());
53
+ $rowObj->setCategoryinterval($category->getInterval());
54
+ $collection->addItem($rowObj);
55
+ }
56
+ }
57
+
58
+ $this->setCollection($collection);
59
+ return parent::_prepareCollection();
60
+ }
61
+
62
+ /**
63
+ * prepare columns for grid
64
+ *
65
+ * @return object
66
+ */
67
+ protected function _prepareColumns()
68
+ {
69
+
70
+
71
+
72
+ $this->addColumn('id', array(
73
+ 'header' => Mage::helper('reviewsystem')->__('Top Category Id'),
74
+ 'index' => 'id',
75
+ ));
76
+ $this->addColumn('name', array(
77
+ 'header' => Mage::helper('reviewsystem')->__('Top Category Name'),
78
+ 'index' => 'name',
79
+ ));
80
+ $this->addColumn('categoryinterval', array(
81
+ 'header' => Mage::helper('reviewsystem')->__('Interval'),
82
+ 'index' => 'categoryinterval',
83
+ ));
84
+ $this->addColumn('interval',array(
85
+ 'header' => Mage::helper('reviewsystem')->__('edit'),
86
+ 'type' => 'action',
87
+ 'getter' => 'getId',
88
+ 'actions' => array(
89
+ array(
90
+ 'caption' => Mage::helper('reviewsystem')->__('edit'),
91
+ 'url' => array(
92
+ 'base'=>'*/*/edit'),
93
+ 'field' => 'id',
94
+
95
+ )),
96
+ 'filter' => false,
97
+ 'sortable' => false,
98
+ 'index' => 'interval',
99
+ 'is_system' => true,
100
+ ));
101
+ return parent::_prepareColumns();
102
+
103
+ }
104
+
105
+ /**
106
+ * Prepare for mass action for selected rows
107
+ */
108
+ protected function _prepareMassaction()
109
+ {
110
+
111
+ $this->setMassactionIdField('id');
112
+ $this->getMassactionBlock()->setFormFieldName('id');
113
+
114
+ $this->getMassactionBlock()->addItem('interval', array(
115
+ 'label' => Mage::helper('reviewsystem')->__('Add Default Intervel'),
116
+ 'url' => $this->getUrl('*/*/massIntervel', array('id' =>$this->getRequest()->getParam('id'))),
117
+ 'confirm' => Mage::helper('reviewsystem')->__('Are you sure?')
118
+ ));
119
+
120
+
121
+ return $this;
122
+ }
123
+
124
+
125
+ public function getGridUrl() {
126
+ return $this->getUrl('*/*/grid', array('_current' => true));
127
+ }
128
+
129
+
130
+ }
app/code/community/Criteek/Reviewsystem/Helper/Data.php ADDED
@@ -0,0 +1,388 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ *
7
+ * @category Criteek
8
+ * @package Criteek_Reviewsystem
9
+ * @copyright Copyright (c) 2016 Criteek Comm LLC.
10
+ * @author Criteek Developer
11
+ * @license https://www.criteek.tv/terms-of-use CRITEEK TERMS OF USE
12
+ */
13
+
14
+ class Criteek_Reviewsystem_Helper_Data extends Mage_Core_Helper_Abstract
15
+ {
16
+ /**
17
+ * get Api key - Get api key from config
18
+ *
19
+ * @return string
20
+ */
21
+ function getApiUsername(){
22
+ return Mage::getStoreConfig('reviewsystem/product_review_config/api_app_key'); // Api app Key
23
+ }
24
+ function isModuleEnable(){
25
+ if(Mage::getStoreConfig('reviewsystem/product_review_config/criteek_synch'))
26
+ {
27
+ return true;
28
+ }else{
29
+ return false;
30
+ }
31
+ }
32
+
33
+
34
+ /**
35
+ * get Api secret - Get api secret from config
36
+ *
37
+ * @return string
38
+ */
39
+ function getApiPassword(){
40
+ return Mage::getStoreConfig('reviewsystem/product_review_config/api_app_secret'); // Api app seceret
41
+ }
42
+
43
+ /**
44
+ * sendRequest for token - initiate curl request
45
+ *
46
+ *
47
+ *
48
+ * @return token
49
+ */
50
+ function getToken(){
51
+ $json = '';
52
+ $url="http://api.criteek.tv/api/v1/login";
53
+ $curl = curl_init($url);
54
+ $postData= array("apikey" => $this->getApiUsername(), "secretkey" => $this->getApiPassword());
55
+ curl_setopt($curl, CURLOPT_URL, $url);
56
+ curl_setopt($curl, CURLOPT_HEADER, false);
57
+ curl_setopt($curl, CURLOPT_TIMEOUT, 30);
58
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
59
+ curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($postData));
60
+ curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
61
+
62
+ $response = curl_exec($curl);
63
+
64
+ if (empty($response)) {
65
+ throw new Exception(Mage::getSingleton('adminhtml/session')->addError(Mage::helper('reviewsystem')->__('Check API key and API secret again')));
66
+ curl_close($curl); // close cURL handler
67
+ } else {
68
+ $info = curl_getinfo($curl);
69
+
70
+ if (empty($info['http_code'])) {
71
+ Mage::log("No HTTP code was returned", null, 'reviewsystem.log');
72
+
73
+ } else {
74
+ // load the HTTP codes
75
+
76
+ if($info['http_code']!=200){
77
+ Mage::log("HTTP code was not 200", null, 'reviewsystem.log');
78
+
79
+ }
80
+ else{
81
+ $json = json_decode($response);
82
+ }
83
+ }
84
+ }
85
+ //echo $info['http_code'];
86
+ $token =$json->message->token;
87
+ return $token;
88
+ }
89
+ /**
90
+ * getdomainId - Send curl request to Api to get Domain Id
91
+ *
92
+ *
93
+ * @return array
94
+ */
95
+ function getDomainId() {
96
+
97
+ $json = '';
98
+ $token = $this->getToken();
99
+ $url="http://api.criteek.tv/api/v1/mydomain?name=".$_SERVER['HTTP_HOST']."&token=".$token;
100
+ $headers= array("token:".$token);
101
+ $curl = curl_init($url);
102
+ curl_setopt($curl, CURLOPT_URL, $url);
103
+ curl_setopt($curl, CURLOPT_HEADER, false);
104
+ curl_setopt($curl, CURLOPT_TIMEOUT, 30);
105
+ curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
106
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
107
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
108
+ $response = curl_exec($curl);
109
+ if (empty($response)) {
110
+ throw new Exception(Mage::getSingleton('adminhtml/session')->addError(Mage::helper('reviewsystem')->__('Check API key and API secret again')));
111
+
112
+ curl_close($curl); // close cURL handler
113
+ } else {
114
+ $info = curl_getinfo($curl);
115
+
116
+ if (empty($info['http_code'])) {
117
+ Mage::log("No HTTP code was returned", null, 'reviewsystem.log');
118
+
119
+ } else {
120
+ // load the HTTP codes
121
+
122
+ if($info['http_code']!=200){
123
+ Mage::log("HTTP code was not 200", null, 'reviewsystem.log');
124
+ }
125
+ else{
126
+ $json = json_decode($response);
127
+ }
128
+ }
129
+ }
130
+ $domain_id =$json->message->domainid;
131
+ return $domain_id ;
132
+ }
133
+ /**
134
+ * fetchProductsInfo - Send curl request to huuto to fetch products Details
135
+ *
136
+ *
137
+ *
138
+ */
139
+
140
+ function fetchProductInfo() {
141
+ $json = '';
142
+ $token = $this->getToken();
143
+ $doaminId= $this->getDomainId();
144
+ $url="http://api.criteek.tv/api/v1/widgetproduct?domainid=".$doaminId."&token=".$token;
145
+ $headers= array("token:".$token);
146
+ $curl = curl_init($url);
147
+ curl_setopt($curl, CURLOPT_URL, $url);
148
+ curl_setopt($curl, CURLOPT_HEADER, false);
149
+ curl_setopt($curl, CURLOPT_TIMEOUT, 30);
150
+ curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
151
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
152
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
153
+ $response = curl_exec($curl);
154
+ if (empty($response)) {
155
+ throw new Exception(Mage::getSingleton('adminhtml/session')->addError(Mage::helper('reviewsystem')->__('Check API key and API secret again')));
156
+
157
+ curl_close($curl); // close cURL handler
158
+ } else {
159
+ $info = curl_getinfo($curl);
160
+
161
+ if (empty($info['http_code'])) {
162
+ Mage::log("No HTTP code was returned", null, 'reviewsystem.log');
163
+ } else {
164
+ // load the HTTP codes
165
+
166
+ if($info['http_code']!=200){
167
+ Mage::log("HTTP code was not 200", null, 'reviewsystem.log');
168
+ }
169
+ else{
170
+ $json = json_decode($response);
171
+ }
172
+ }
173
+ }
174
+ $productData =$json->message;
175
+ return $productData ;
176
+ }
177
+
178
+ /**
179
+ * setDoamin On Off - Send curl request to huuto to fetch products Details
180
+ *
181
+ * param value for domain value
182
+ *
183
+ */
184
+
185
+ function setDomainOnOff($value) {
186
+ $json = '';
187
+ $token = $this->getToken();
188
+ $doaminId= $this->getDomainId();
189
+ $url="http://api.criteek.tv/api/v1/domain/".$doaminId;
190
+ $putData= array("default"=>$value);
191
+ $headers= array("token:".$token);
192
+ $curl = curl_init($url);
193
+ curl_setopt($curl, CURLOPT_URL, $url);
194
+ curl_setopt($curl, CURLOPT_HEADER, false);
195
+ curl_setopt($curl, CURLOPT_TIMEOUT, 30);
196
+ curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
197
+ // Instead of POST fields use these settings
198
+ curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($putData));
199
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
200
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
201
+ $response = curl_exec($curl);
202
+ if (empty($response)) {
203
+ throw new Exception(Mage::getSingleton('adminhtml/session')->addError(Mage::helper('reviewsystem')->__('Check API key and API secret again')));
204
+ curl_close($curl); // close cURL handler
205
+ } else {
206
+ $info = curl_getinfo($curl);
207
+
208
+ if (empty($info['http_code'])) {
209
+ Mage::log("No HTTP code was returned", null, 'reviewsystem.log');
210
+ } else {
211
+ // load the HTTP codes
212
+
213
+ if($info['http_code']!=200){
214
+ Mage::log("HTTP code was not 200", null, 'reviewsystem.log');
215
+ }
216
+ else{
217
+ $json = json_decode($response);
218
+ }
219
+ }
220
+ }
221
+
222
+ return $json ;
223
+ }
224
+
225
+ /**
226
+ * set product widget On Off - Send curl request to huuto to fetch products Details
227
+ *
228
+ * param value for id and value
229
+ *
230
+ */
231
+ function setProductOnOff($id,$value) {
232
+ $json = '';
233
+ $token = $this->getToken();
234
+ $doaminId= $this->getDomainId();
235
+ $url="http://api.criteek.tv/api/v1/widgetproduct/".$id;
236
+ $putData= array("domainid"=>$doaminId, "widget"=>$value);
237
+ $headers= array("token:".$token);
238
+ $curl = curl_init($url);
239
+ curl_setopt($curl, CURLOPT_URL, $url);
240
+ curl_setopt($curl, CURLOPT_HEADER, false);
241
+ curl_setopt($curl, CURLOPT_TIMEOUT, 30);
242
+ curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
243
+ // Instead of POST fields use these settings
244
+ curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($putData));
245
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
246
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
247
+ $response = curl_exec($curl);
248
+ if (empty($response)) {
249
+ throw new Exception(Mage::getSingleton('adminhtml/session')->addError(Mage::helper('reviewsystem')->__('Check API key and API secret again')));
250
+ curl_close($curl); // close cURL handler
251
+ } else {
252
+ $info = curl_getinfo($curl);
253
+
254
+ if (empty($info['http_code'])) {
255
+ Mage::log("No HTTP code was returned", null, 'reviewsystem.log');
256
+ } else {
257
+ // load the HTTP codes
258
+
259
+ if($info['http_code']!=200){
260
+ Mage::log("HTTP code was not 200", null, 'reviewsystem.log');
261
+ }
262
+ else{
263
+ $json = json_decode($response);
264
+ }
265
+ }
266
+ }
267
+
268
+ return $json ;
269
+ }
270
+
271
+ /**
272
+ * fetchReviwersInfo - Send curl request to huuto to fetch reviews Details
273
+ *
274
+ *
275
+ *
276
+ */
277
+
278
+ function fetchReviewersInfo($productid) {
279
+ $json = '';
280
+ $token = $this->getToken();
281
+ $doaminId= $this->getDomainId();
282
+ $url="http://api.criteek.tv/api/v1/widgetproductreviewers?domainid=".$doaminId."&productid=".$productid;
283
+ $headers= array("token:".$token);
284
+ $curl = curl_init($url);
285
+ curl_setopt($curl, CURLOPT_URL, $url);
286
+ curl_setopt($curl, CURLOPT_HEADER, false);
287
+ curl_setopt($curl, CURLOPT_TIMEOUT, 30);
288
+ curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
289
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
290
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
291
+ $response = curl_exec($curl);
292
+ if (empty($response)) {
293
+ throw new Exception(Mage::getSingleton('adminhtml/session')->addError(Mage::helper('reviewsystem')->__('Check API key and API secret again')));
294
+ curl_close($curl); // close cURL handler
295
+ } else {
296
+ $info = curl_getinfo($curl);
297
+
298
+ if (empty($info['http_code'])) {
299
+ Mage::log("No HTTP code was returned", null, 'reviewsystem.log');
300
+ } else {
301
+ // load the HTTP codes
302
+
303
+ if($info['http_code']!=200){
304
+ Mage::log("HTTP code was not 200", null, 'reviewsystem.log');
305
+ }
306
+ else{
307
+ $json = json_decode($response);
308
+ }
309
+ }
310
+ }
311
+ return $json ;
312
+ }
313
+
314
+ function setProductDeleteArchive($id,$value) {
315
+ $json = '';
316
+ $token = $this->getToken();
317
+ $doaminId= $this->getDomainId();
318
+ $putData= array("productid"=>array($id), "widget"=>$value);
319
+ $url="http://api.criteek.tv/api/v1/widgets?data=".$putData;
320
+
321
+ $headers= array("token:".$token);
322
+ $curl = curl_init($url);
323
+ curl_setopt($curl, CURLOPT_URL, $url);
324
+ curl_setopt($curl, CURLOPT_HEADER, false);
325
+ curl_setopt($curl, CURLOPT_TIMEOUT, 30);
326
+ curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
327
+ // Instead of POST fields use these settings
328
+ curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($putData));
329
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
330
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
331
+ $response = curl_exec($curl);
332
+ if (empty($response)) {
333
+ throw new Exception(Mage::getSingleton('adminhtml/session')->addError(Mage::helper('reviewsystem')->__('Check API key and API secret again')));
334
+ curl_close($curl); // close cURL handler
335
+ } else {
336
+ $info = curl_getinfo($curl);
337
+
338
+ if (empty($info['http_code'])) {
339
+ Mage::log("No HTTP code was returned", null, 'reviewsystem.log');
340
+ } else {
341
+ // load the HTTP codes
342
+
343
+ if($info['http_code']!=200){
344
+ Mage::log("HTTP code was not 200", null, 'reviewsystem.log');
345
+ }
346
+ else{
347
+ $json = json_decode($response);
348
+ }
349
+ }
350
+ }
351
+
352
+ return $json ;
353
+ }
354
+ function fetchReviewersStatus($streamId,$email) {
355
+ $json = '';
356
+ $token = $this->getToken();
357
+ $url="http://api.criteek.tv/api/v1/widgetproductcheckreviewers?streamingid=".$streamId."&emailid=".$email;
358
+ $headers= array("token:".$token);
359
+ $curl = curl_init($url);
360
+ curl_setopt($curl, CURLOPT_URL, $url);
361
+ curl_setopt($curl, CURLOPT_HEADER, false);
362
+ curl_setopt($curl, CURLOPT_TIMEOUT, 30);
363
+ curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
364
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
365
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
366
+ $response = curl_exec($curl);
367
+ if (empty($response)) {
368
+ throw new Exception(Mage::getSingleton('adminhtml/session')->addError(Mage::helper('reviewsystem')->__('Check API key and API secret again')));
369
+ curl_close($curl); // close cURL handler
370
+ } else {
371
+ $info = curl_getinfo($curl);
372
+
373
+ if (empty($info['http_code'])) {
374
+ Mage::log("No HTTP code was returned", null, 'reviewsystem.log');
375
+ } else {
376
+ // load the HTTP codes
377
+
378
+ if($info['http_code']!=200){
379
+ Mage::log("HTTP code was not 200", null, 'reviewsystem.log');
380
+ }
381
+ else{
382
+ $json = json_decode($response);
383
+ }
384
+ }
385
+ }
386
+ return $json ;
387
+ }
388
+ }
app/code/community/Criteek/Reviewsystem/Model/.DS_Store ADDED
Binary file
app/code/community/Criteek/Reviewsystem/Model/Category.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ *
7
+ * @category Criteek
8
+ * @package Criteek_Reviewsystem
9
+ * @copyright Copyright (c) 2016 Criteek Comm LLC.
10
+ * @author Criteek Developer
11
+ * @license https://www.criteek.tv/terms-of-use CRITEEK TERMS OF USE
12
+ */
13
+
14
+
15
+ class Criteek_Reviewsystem_Model_Category extends Mage_Core_Model_Abstract {
16
+ public function _construct() {
17
+ parent::_construct();
18
+ $this->_init('reviewsystem/category');
19
+ }
20
+ }
app/code/community/Criteek/Reviewsystem/Model/Cron.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ *
7
+ * @category Criteek
8
+ * @package Criteek_Reviewsystem
9
+ * @copyright Copyright (c) 2016 Criteek Comm LLC.
10
+ * @author Criteek Developer
11
+ * @license https://www.criteek.tv/terms-of-use CRITEEK TERMS OF USE
12
+ */
13
+
14
+ class Criteek_Reviewsystem_Model_Cron
15
+ {
16
+
17
+ /**
18
+ *
19
+ * Send Email via Cron - Send Email to review product
20
+ *
21
+ */
22
+
23
+ public function sendEmail()
24
+ {
25
+ if(Mage::helper('reviewsystem')->isModuleEnable()){
26
+ $sender_email= Mage::getStoreConfig('trans_email/ident_general/email');
27
+ $sender_name =Mage::getStoreConfig('trans_email/ident_general/name');
28
+
29
+ $collection = Mage::getModel('reviewsystem/emailQueue')->getCollection();
30
+ foreach($collection as $queue)
31
+ {$current_date =Mage::getModel('core/date')->date('Y-m-d');
32
+ $emailtime = $queue->getEmailTime();
33
+ $customer_email= $queue->getCustomerEmail();
34
+ $customerid =$queue->getId();
35
+ $customer_name = $queue->getCustomerName();
36
+ $product_id = $queue->getProductId();
37
+ $date_time = new DateTime($emailtime);
38
+ $date = $date_time->format('Y-m-d');
39
+ $time = $date_time->format('H:i:s');
40
+ $product = Mage::getModel('catalog/product')->load($product_id);
41
+ if( $current_date>= $date ){
42
+ if($queue->getStatus()==0){
43
+ $emailTemplateVariables = array();
44
+ $emailTemplateVariables['product_url'] = Mage::getBaseUrl().Mage::getResourceSingleton('catalog/product')
45
+ ->getAttributeRawValue($product_id, 'url_path', Mage::app()->getStore())."?criteek=".$customerid ;
46
+ $emailTemplateVariables['product_name'] = $product->getName();
47
+ $emailTemplateVariables['customer_name'] = $customer_name;
48
+ $emailTemplate = Mage::getModel('core/email_template')
49
+ ->loadDefault('product_review_email_template');
50
+ $emailTemplate->setSenderName($sender_name);
51
+ $emailTemplate->setSenderEmail($sender_email);
52
+ $processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);
53
+ $emailTemplate->send($customer_email,$customer_name, $emailTemplateVariables);
54
+ $data = array('status'=>1);
55
+ $status= Mage::getModel('reviewsystem/emailQueue')->load($queue->getId())->addData($data)->save();
56
+
57
+
58
+ }
59
+ }
60
+ }
61
+
62
+
63
+ }
64
+ }
65
+ }
app/code/community/Criteek/Reviewsystem/Model/EmailQueue.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ *
7
+ * @category Criteek
8
+ * @package Criteek_Reviewsystem
9
+ * @copyright Copyright (c) 2016 Criteek Comm LLC.
10
+ * @author Criteek Developer
11
+ * @license https://www.criteek.tv/terms-of-use CRITEEK TERMS OF USE
12
+ */
13
+
14
+ class Criteek_Reviewsystem_Model_EmailQueue extends Mage_Core_Model_Abstract {
15
+ public function _construct() {
16
+ parent::_construct();
17
+ $this->_init('reviewsystem/emailQueue');
18
+ }
19
+ }
app/code/community/Criteek/Reviewsystem/Model/Mysql4/.DS_Store ADDED
Binary file
app/code/community/Criteek/Reviewsystem/Model/Mysql4/Category.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ *
7
+ * @category Criteek
8
+ * @package Criteek_Reviewsystem
9
+ * @copyright Copyright (c) 2016 Criteek Comm LLC.
10
+ * @author Criteek Developer
11
+ * @license https://www.criteek.tv/terms-of-use CRITEEK TERMS OF USE
12
+ */
13
+
14
+ class Criteek_Reviewsystem_Model_Mysql4_Category extends Mage_Core_Model_Mysql4_Abstract {
15
+
16
+ /**
17
+ * Constructor
18
+ *
19
+ * @return unknown
20
+ */
21
+ public function _construct() {
22
+ // Note that the category_id refers to the key field in your database table.
23
+ $this->_init('reviewsystem/category', 'id');
24
+ }
25
+ }
app/code/community/Criteek/Reviewsystem/Model/Mysql4/Category/Collection.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ *
7
+ * @category Criteek
8
+ * @package Criteek_Reviewsystem
9
+ * @copyright Copyright (c) 2016 Criteek Comm LLC.
10
+ * @author Criteek Developer
11
+ * @license https://www.criteek.tv/terms-of-use CRITEEK TERMS OF USE
12
+ */
13
+
14
+ class Criteek_Reviewsystem_Model_Mysql4_Category_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
15
+ {
16
+ /**
17
+ * Constructor
18
+ *
19
+ * @return unknown
20
+ */
21
+ public function _construct()
22
+ {
23
+ parent::_construct();
24
+ $this->_init('reviewsystem/category');
25
+ }
26
+ }
app/code/community/Criteek/Reviewsystem/Model/Mysql4/EmailQueue.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ *
7
+ * @category Criteek
8
+ * @package Criteek_Reviewsystem
9
+ * @copyright Copyright (c) 2016 Criteek Comm LLC.
10
+ * @author Criteek Developer
11
+ * @license https://www.criteek.tv/terms-of-use CRITEEK TERMS OF USE
12
+ */
13
+
14
+ class Criteek_Reviewsystem_Model_Mysql4_EmailQueue extends Mage_Core_Model_Mysql4_Abstract {
15
+
16
+ /**
17
+ * Constructor
18
+ *
19
+ * @return unknown
20
+ */
21
+ public function _construct() {
22
+ // Note that the id refers to the key field in your database table.
23
+ $this->_init('reviewsystem/emailQueue','id');
24
+ }
25
+ }
app/code/community/Criteek/Reviewsystem/Model/Mysql4/EmailQueue/Collection.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ *
7
+ * @category Criteek
8
+ * @package Criteek_Reviewsystem
9
+ * @copyright Copyright (c) 2016 Criteek Comm LLC.
10
+ * @author Criteek Developer
11
+ * @license https://www.criteek.tv/terms-of-use CRITEEK TERMS OF USE
12
+ */
13
+
14
+ class Criteek_Reviewsystem_Model_Mysql4_EmailQueue_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
15
+ {
16
+ /**
17
+ * Constructor
18
+ *
19
+ * @return unknown
20
+ */
21
+ public function _construct()
22
+ {
23
+ parent::_construct();
24
+ $this->_init('reviewsystem/emailQueue');
25
+ }
26
+ protected function _joinFields($from = '', $to = '')
27
+ {
28
+ $this->addFieldToFilter('email_time' , array("from" => $from, "to" => $to, "datetime" => true));
29
+ // $this->getSelect()->group('email_time');
30
+ $this->getSelect();
31
+ return $this;
32
+ }
33
+
34
+ public function setDateRange($from, $to)
35
+ {
36
+ $this->_reset()
37
+ ->_joinFields($from, $to);
38
+ return $this;
39
+ }
40
+
41
+ public function load($printQuery = false, $logQuery = false)
42
+ {
43
+ if ($this->isLoaded()) {
44
+ return $this;
45
+ }
46
+ parent::load($printQuery, $logQuery);
47
+ return $this;
48
+ }
49
+
50
+ public function setStoreIds($storeIds)
51
+ {
52
+ return $this;
53
+ }
54
+
55
+ }
app/code/community/Criteek/Reviewsystem/Model/Observer.php ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ *
7
+ * @category Criteek
8
+ * @package Criteek_Reviewsystem
9
+ * @copyright Copyright (c) 2016 Criteek Comm LLC.
10
+ * @author Criteek Developer
11
+ * @license https://www.criteek.tv/terms-of-use CRITEEK TERMS OF USE
12
+ */
13
+
14
+ class Criteek_Reviewsystem_Model_Observer
15
+ {
16
+ public function getOrder(Varien_Event_Observer $observer)
17
+ {
18
+ if(Mage::helper('reviewsystem')->isModuleEnable()){
19
+ $order = $observer->getEvent()->getOrder();
20
+ $orderId= $order->getId();
21
+ $orderStatus = $order->getStatus();
22
+ $status = Mage::getStoreConfig('reviewsystem/product_review_config/allowed_status');
23
+ $customerEmail = $order->getCustomerEmail();
24
+ $customerName = $order->getCustomerName();
25
+
26
+ if($orderStatus == $status ){
27
+ foreach( $order->getAllVisibleItems() as $item ) {
28
+ $itemProductId = $item->getProductId();
29
+ $product = Mage::getModel('catalog/product')->load($itemProductId);
30
+ $cats = $product->getCategoryIds();
31
+ $categoryId =array();
32
+ foreach ($cats as $category_id) {
33
+ $category = Mage::getModel('catalog/category')->load($category_id);
34
+ //each category has a path attribute
35
+ $path = $category->getPath(); //should look like 1/3/14/23/55.
36
+ //split the path by slash
37
+ $pathParts = explode('/', $path);
38
+ if (count($pathParts) == 3) {
39
+ //it means the category is already a top level category
40
+ $categoryname = $category->getName();
41
+ $categoryId[]= $category->getId();
42
+ }
43
+ elseif (isset($pathParts[2])) {
44
+ $topCategory = Mage::getModel('catalog/category')->load($pathParts[2]);
45
+ $categoryname = $topCategory->getName();
46
+ $categoryId[]= $topCategory->getId();
47
+ }
48
+ }
49
+ if(!empty($categoryId)){
50
+ $Interval =array();
51
+ foreach($categoryId as $topId)
52
+ {
53
+ $model = Mage::getModel('reviewsystem/category');
54
+ $model->load($topId, 'category_id');
55
+ $Interval[$topId]= $model->getInterval();
56
+ }
57
+ if(count(array_keys($Interval, min($Interval)))==1)
58
+ {
59
+
60
+ $cat_id=array_keys($Interval, min($Interval));
61
+
62
+ $catModel=Mage::getModel('reviewsystem/category')->getCollection()->addFieldToFilter('category_id', $cat_id[0])->addFieldToSelect('interval')->getData();
63
+
64
+ }else{
65
+ $catModel=Mage::getModel('reviewsystem/category')->getCollection()->addFieldToFilter('category_id', $categoryId[0])->addFieldToSelect('interval')->getData();
66
+ }
67
+ $interval_days = $catModel[0]['interval'];
68
+ $email_date= date('Y-m-d H:i:s', strtotime('+'.$interval_days.' days') );
69
+ $productModel = Mage::getModel('reviewsystem/emailQueue');
70
+ $productModel->setProductId($itemProductId)
71
+ ->setOrderId($orderId)
72
+ ->setStatus(0)
73
+ ->setProductSku($item->getSku())
74
+ ->setProductName($item->getName())
75
+ ->setEmailTime($email_date)
76
+ ->setCustomerEmail($customerEmail)
77
+ ->setCustomerName($customerName)
78
+ ->save();
79
+ }
80
+ }
81
+ }
82
+ }
83
+ return $observer;
84
+ }
85
+
86
+ public function getCategory($observer)
87
+ { if(Mage::helper('reviewsystem')->isModuleEnable()){
88
+ $event = $observer->getEvent();
89
+ $category = $event->getCategory();
90
+ $interval =10;
91
+ $category_id= $category->getId();
92
+ $model = Mage::getModel('reviewsystem/category');
93
+ $categories = Mage::getModel('reviewsystem/category')->getCollection()
94
+ ;
95
+ $catId =array();
96
+ foreach($categories as $category){
97
+ $catId[] = $category->getCategoryId();
98
+
99
+ }
100
+
101
+ if(in_array($category_id,$catId))
102
+ {
103
+
104
+ }else{
105
+ $category = Mage::getModel('catalog/category')->load($category_id);
106
+ $path = $category->getPath(); //should look like 1/3/14/23/55.
107
+ //split the path by slash
108
+ $pathParts = explode('/', $path);
109
+ if (count($pathParts) == 3) {
110
+ $categoryname = $category->getName();
111
+ $category_id= $category->getId();
112
+ $model->setCategoryId($category_id)
113
+ ->setInterval($interval)
114
+ ->save();
115
+ }
116
+ }}
117
+ return $observer;
118
+
119
+ }
120
+ public function adminSystemConfigChangedSection()
121
+ {
122
+ if(Mage::getStoreConfig('manage_widget/manage_widget_config/widget_synch')==1){
123
+ $value="on";
124
+ Mage::helper('reviewsystem')->setDomainOnOff($value);
125
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('reviewsystem')->__('Widget is ON for Domain.'));
126
+ }else{
127
+ $value="off";
128
+ Mage::helper('reviewsystem')->setDomainOnOff($value);
129
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('reviewsystem')->__('Widget is OFF for Domain.'));
130
+ }
131
+ return true;
132
+ }
133
+ public function getproductData($observer)
134
+ {
135
+ if(Mage::helper('reviewsystem')->isModuleEnable()){
136
+ $currentUrl =$_SERVER['REQUEST_URI'];
137
+ if (strpos($currentUrl,'?criteek=') !== false) {
138
+ $customer_email= $_GET['criteek'];
139
+
140
+ $collection =Mage::getModel('reviewsystem/emailQueue')->getCollection()
141
+ ->addFieldToFilter('status', array('eq'=>1))
142
+ ->addFieldToFilter('id', array('eq'=>$customer_email))
143
+ ->addFieldToSelect('*');
144
+ if($collection->getData())
145
+ {
146
+ foreach($collection as $data)
147
+ {
148
+ $data->setReopened(1);
149
+ $data->save();
150
+ }
151
+ }
152
+ }
153
+ }
154
+ return $observer;
155
+ }
156
+
157
+ public function adminSystemConfigApiAuthenticationSection()
158
+ {
159
+
160
+ if(Mage::getStoreConfig('reviewsystem/product_review_config/criteek_synch')==1){
161
+
162
+ if(Mage::helper('reviewsystem')->getToken()==""){
163
+ return Mage::getSingleton('adminhtml/session')->addError(Mage::helper('reviewsystem')->__('Check API key and API secret again'));
164
+ }
165
+ }
166
+ return ;
167
+ }
168
+ }
app/code/community/Criteek/Reviewsystem/Model/Order/Status.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ *
7
+ * @category Criteek
8
+ * @package Criteek_Reviewsystem
9
+ * @copyright Copyright (c) 2016 Criteek Comm LLC.
10
+ * @author Criteek Developer
11
+ * @license https://www.criteek.tv/terms-of-use CRITEEK TERMS OF USE
12
+ */
13
+
14
+ class Criteek_Reviewsystem_Model_Order_Status
15
+ {
16
+ public function toOptionArray()
17
+ {
18
+ $orderStatusCollection = Mage::getModel('sales/order_status')->getResourceCollection()->getData();
19
+ $status = array();
20
+ $status = array('-1'=>'Please Select..');
21
+
22
+ foreach($orderStatusCollection as $orderStatus) {
23
+ $status[] = array (
24
+ 'value' => $orderStatus['status'], 'label' => $orderStatus['label']);
25
+ }
26
+ return $status;
27
+ }
28
+
29
+ }
app/code/community/Criteek/Reviewsystem/controllers/Adminhtml/AnalyticsController.php ADDED
@@ -0,0 +1,172 @@