magebuzz-product-question - Version 0.1.6

Version Notes

- Update SUPEE-6788
- Convert to free extension

Download this release

Release Info

Developer Magebuzz
Extension magebuzz-product-question
Version 0.1.6
Comparing to
See all releases


Version 0.1.6

Files changed (63) hide show
  1. app/code/local/Magebuzz/Productquestion/Block/Adminhtml/Catalog/Product/Edit/Tab/Question.php +39 -0
  2. app/code/local/Magebuzz/Productquestion/Block/Adminhtml/Catalog/Product/Edit/Tabs.php +20 -0
  3. app/code/local/Magebuzz/Productquestion/Block/Adminhtml/Productquestion.php +16 -0
  4. app/code/local/Magebuzz/Productquestion/Block/Adminhtml/Productquestion/Edit.php +48 -0
  5. app/code/local/Magebuzz/Productquestion/Block/Adminhtml/Productquestion/Edit/Form.php +22 -0
  6. app/code/local/Magebuzz/Productquestion/Block/Adminhtml/Productquestion/Edit/Tab/Form.php +92 -0
  7. app/code/local/Magebuzz/Productquestion/Block/Adminhtml/Productquestion/Edit/Tab/Product.php +119 -0
  8. app/code/local/Magebuzz/Productquestion/Block/Adminhtml/Productquestion/Edit/Tabs.php +33 -0
  9. app/code/local/Magebuzz/Productquestion/Block/Adminhtml/Productquestion/Grid.php +140 -0
  10. app/code/local/Magebuzz/Productquestion/Block/Adminhtml/Renderer/Productname.php +22 -0
  11. app/code/local/Magebuzz/Productquestion/Block/Captcha.php +12 -0
  12. app/code/local/Magebuzz/Productquestion/Block/Productquestion.php +106 -0
  13. app/code/local/Magebuzz/Productquestion/Block/Productquestionoutpage.php +90 -0
  14. app/code/local/Magebuzz/Productquestion/Helper/Data.php +54 -0
  15. app/code/local/Magebuzz/Productquestion/Model/Mysql4/Productquestion.php +13 -0
  16. app/code/local/Magebuzz/Productquestion/Model/Mysql4/Productquestion/Collection.php +13 -0
  17. app/code/local/Magebuzz/Productquestion/Model/Mysql4/Productquestionproduct.php +13 -0
  18. app/code/local/Magebuzz/Productquestion/Model/Mysql4/Productquestionproduct/Collection.php +13 -0
  19. app/code/local/Magebuzz/Productquestion/Model/Mysql4/Productquestionstore.php +13 -0
  20. app/code/local/Magebuzz/Productquestion/Model/Mysql4/Productquestionstore/Collection.php +13 -0
  21. app/code/local/Magebuzz/Productquestion/Model/Productquestion.php +50 -0
  22. app/code/local/Magebuzz/Productquestion/Model/Productquestionproduct.php +13 -0
  23. app/code/local/Magebuzz/Productquestion/Model/Productquestionstore.php +58 -0
  24. app/code/local/Magebuzz/Productquestion/Model/Session.php +12 -0
  25. app/code/local/Magebuzz/Productquestion/Model/Status.php +18 -0
  26. app/code/local/Magebuzz/Productquestion/Model/System/Config/Source/Dropdown/Lang.php +49 -0
  27. app/code/local/Magebuzz/Productquestion/Model/System/Config/Source/Dropdown/Theme.php +21 -0
  28. app/code/local/Magebuzz/Productquestion/controllers/Adminhtml/ProductquestionController.php +241 -0
  29. app/code/local/Magebuzz/Productquestion/controllers/IndexController.php +235 -0
  30. app/code/local/Magebuzz/Productquestion/etc/adminhtml.xml +59 -0
  31. app/code/local/Magebuzz/Productquestion/etc/config.xml +157 -0
  32. app/code/local/Magebuzz/Productquestion/etc/system.xml +172 -0
  33. app/code/local/Magebuzz/Productquestion/sql/productquestion_setup/mysql4-install-0.1.0.php +25 -0
  34. app/code/local/Magebuzz/Productquestion/sql/productquestion_setup/mysql4-upgrade-0.1.0-0.1.1.php +23 -0
  35. app/code/local/Magebuzz/Productquestion/sql/productquestion_setup/mysql4-upgrade-0.1.3-0.1.4.php +33 -0
  36. app/design/adminhtml/default/default/layout/productquestion.xml +15 -0
  37. app/design/adminhtml/default/default/template/productquestion/catalog/product/edit/question.phtml +68 -0
  38. app/design/frontend/base/default/layout/productquestion.xml +46 -0
  39. app/design/frontend/base/default/template/productquestion/checkinpage.phtml +36 -0
  40. app/design/frontend/base/default/template/productquestion/link.phtml +50 -0
  41. app/design/frontend/base/default/template/productquestion/questioninpage.phtml +193 -0
  42. app/design/frontend/base/default/template/productquestion/questionoutpage.phtml +185 -0
  43. app/etc/modules/Magebuzz_Productquestion.xml +9 -0
  44. app/locale/en_US/Magebuzz_Productquestion.csv +67 -0
  45. app/locale/en_US/template/email/productquestion/new_question_confirmation.html +10 -0
  46. app/locale/en_US/template/email/productquestion/new_question_notification.html +10 -0
  47. app/locale/en_US/template/email/productquestion/new_reply_notification.html +1 -0
  48. lib/reCaptcha/recaptchalib.php +140 -0
  49. package.xml +20 -0
  50. skin/adminhtml/default/default/magebuzz/productquestion/images/Thumbs.db +0 -0
  51. skin/adminhtml/default/default/magebuzz/productquestion/images/bkg_block-layered-dt.gif +0 -0
  52. skin/adminhtml/default/default/magebuzz/productquestion/images/bkg_block-layered-label.gif +0 -0
  53. skin/adminhtml/default/default/magebuzz/productquestion/images/bullet.png +0 -0
  54. skin/adminhtml/default/default/magebuzz/productquestion/images/refresh.png +0 -0
  55. skin/adminhtml/default/default/magebuzz/productquestion/productquestion.css +23 -0
  56. skin/frontend/base/default/magebuzz/productquestion/css/productquestion.css +115 -0
  57. skin/frontend/base/default/magebuzz/productquestion/images/Thumbs.db +0 -0
  58. skin/frontend/base/default/magebuzz/productquestion/images/bkg_block-layered-dt.gif +0 -0
  59. skin/frontend/base/default/magebuzz/productquestion/images/bkg_block-layered-label.gif +0 -0
  60. skin/frontend/base/default/magebuzz/productquestion/images/bullet.png +0 -0
  61. skin/frontend/base/default/magebuzz/productquestion/images/refresh.png +0 -0
  62. skin/frontend/base/default/magebuzz/productquestion/images/votedown.png +0 -0
  63. skin/frontend/base/default/magebuzz/productquestion/images/voteup.png +0 -0
app/code/local/Magebuzz/Productquestion/Block/Adminhtml/Catalog/Product/Edit/Tab/Question.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Block_Adminhtml_Catalog_Product_Edit_Tab_Question extends Mage_Adminhtml_Block_Widget
7
+ {
8
+ public function __construct()
9
+ {
10
+ parent::__construct();
11
+ $product = $this->_getProduct();
12
+ $productId = $product->getEntityId();
13
+ $questions = Mage::getModel('productquestion/productquestion')->getCollection();
14
+
15
+ $productQuestions = Mage::getModel('productquestion/productquestionproduct')->getCollection()->addFieldToFilter('product_id', $productId)->getData();
16
+ if (!empty($productQuestions)) {
17
+ foreach ($productQuestions as $pid) {
18
+ $listQuestionIds[] = $pid['productquestion_id'];
19
+ }
20
+ $questions->addFieldToFilter('productquestion_id', $listQuestionIds);
21
+ }
22
+
23
+ $this->setCollection($questions);
24
+ $this->setTemplate('productquestion/catalog/product/edit/question.phtml');
25
+ }
26
+
27
+ protected function _getProduct()
28
+ {
29
+ $id = $this->getRequest()->getParam('id');
30
+ $productCollection = Mage::getModel('catalog/product')->load($id);
31
+ return $productCollection;
32
+ }
33
+
34
+ public function getProductName()
35
+ {
36
+ $product = $this->_getProduct();
37
+ return $product->getName();
38
+ }
39
+ }
app/code/local/Magebuzz/Productquestion/Block/Adminhtml/Catalog/Product/Edit/Tabs.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Block_Adminhtml_Catalog_Product_Edit_Tabs extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs
7
+ {
8
+ private $parent;
9
+
10
+ protected function _prepareLayout()
11
+ {
12
+ parent::_prepareLayout();
13
+ $this->addTab('question', array(
14
+ 'label' => Mage::helper('productquestion')->__('Product Questions'),
15
+ 'content' => $this->_translateHtml($this->getLayout()
16
+ ->createBlock('productquestion/adminhtml_catalog_product_edit_tab_question')->toHtml()),
17
+ ));
18
+ return $this;
19
+ }
20
+ }
app/code/local/Magebuzz/Productquestion/Block/Adminhtml/Productquestion.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Block_Adminhtml_Productquestion extends Mage_Adminhtml_Block_Widget_Grid_Container
7
+ {
8
+ public function __construct()
9
+ {
10
+ $this->_controller = 'adminhtml_productquestion';
11
+ $this->_blockGroup = 'productquestion';
12
+ $this->_headerText = Mage::helper('productquestion')->__('Product Questions');
13
+ $this->_addButtonLabel = Mage::helper('productquestion')->__('Add Question');
14
+ parent::__construct();
15
+ }
16
+ }
app/code/local/Magebuzz/Productquestion/Block/Adminhtml/Productquestion/Edit.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Block_Adminhtml_Productquestion_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
7
+ {
8
+ public function __construct()
9
+ {
10
+ parent::__construct();
11
+
12
+ $this->_objectId = 'id';
13
+ $this->_blockGroup = 'productquestion';
14
+ $this->_controller = 'adminhtml_productquestion';
15
+
16
+ $this->_updateButton('save', 'label', Mage::helper('productquestion')->__('Save'));
17
+ $this->_updateButton('delete', 'label', Mage::helper('productquestion')->__('Delete'));
18
+
19
+ $this->_addButton('saveandcontinue', array(
20
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
21
+ 'onclick' => 'saveAndContinueEdit()',
22
+ 'class' => 'save',
23
+ ), -100);
24
+
25
+ $this->_formScripts[] = "
26
+ function toggleEditor() {
27
+ if (tinyMCE.getInstanceById('productquestion_content') == null) {
28
+ tinyMCE.execCommand('mceAddControl', false, 'productquestion_content');
29
+ } else {
30
+ tinyMCE.execCommand('mceRemoveControl', false, 'productquestion_content');
31
+ }
32
+ }
33
+
34
+ function saveAndContinueEdit(){
35
+ editForm.submit($('edit_form').action+'back/edit/');
36
+ }
37
+ ";
38
+ }
39
+
40
+ public function getHeaderText()
41
+ {
42
+ if (Mage::registry('productquestion_data') && Mage::registry('productquestion_data')->getId()) {
43
+ return Mage::helper('productquestion')->__("Reply question from %s (%s) ", $this->htmlEscape(Mage::registry('productquestion_data')->getData('author_name')), $this->htmlEscape(Mage::registry('productquestion_data')->getData('author_email')));
44
+ } else {
45
+ return Mage::helper('productquestion')->__('Add Question');
46
+ }
47
+ }
48
+ }
app/code/local/Magebuzz/Productquestion/Block/Adminhtml/Productquestion/Edit/Form.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Block_Adminhtml_Productquestion_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
7
+ {
8
+ protected function _prepareForm()
9
+ {
10
+ $form = new Varien_Data_Form(array(
11
+ 'id' => 'edit_form',
12
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
13
+ 'method' => 'post',
14
+ 'enctype' => 'multipart/form-data'
15
+ )
16
+ );
17
+
18
+ $form->setUseContainer(TRUE);
19
+ $this->setForm($form);
20
+ return parent::_prepareForm();
21
+ }
22
+ }
app/code/local/Magebuzz/Productquestion/Block/Adminhtml/Productquestion/Edit/Tab/Form.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Block_Adminhtml_Productquestion_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
7
+ {
8
+ protected function _prepareForm()
9
+ {
10
+ $form = new Varien_Data_Form();
11
+ $this->setForm($form);
12
+ $fieldset = $form->addFieldset('productquestion_form', array('legend' => Mage::helper('productquestion')->__('Question details')));
13
+ $id = $this->getRequest()->getParam('id');
14
+ $storeList = Mage::getSingleton('productquestion/productquestionstore')->getCollection()->AddFieldToFilter('productquestion_id', $id)->getData();
15
+ $stores = array();
16
+ if ($storeList) {
17
+ foreach ($storeList as $store) {
18
+ $stores[] = $store['store_id'];
19
+ }
20
+ }
21
+
22
+ $fieldset->addField('date', 'date', array(
23
+ 'label' => Mage::helper('productquestion')->__('Asked on'),
24
+ 'name' => 'date',
25
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
26
+ 'format' => 'dd-MM-yyyy',
27
+ ));
28
+
29
+ $fieldset->addField('author_name', 'text', array(
30
+ 'label' => Mage::helper('productquestion')->__('Author Name'),
31
+ 'class' => 'required-entry',
32
+ 'required' => TRUE,
33
+ 'name' => 'author_name',
34
+ ));
35
+
36
+ $fieldset->addField('author_email', 'text', array(
37
+ 'label' => Mage::helper('productquestion')->__('Author Email'),
38
+ 'class' => 'required-entry',
39
+ 'required' => TRUE,
40
+ 'name' => 'author_email',
41
+ ));
42
+
43
+ $fieldset->addField('question', 'editor', array(
44
+ 'name' => 'question',
45
+ 'label' => Mage::helper('productquestion')->__('Question'),
46
+ 'title' => Mage::helper('productquestion')->__('Question'),
47
+ 'required' => TRUE,
48
+ ));
49
+
50
+ $field = $fieldset->addField('store_id', 'multiselect', array(
51
+ 'name' => 'stores[]',
52
+ 'label' => Mage::helper('productquestion')->__('Store View'),
53
+ 'title' => Mage::helper('productquestion')->__('Store View'),
54
+ 'required' => TRUE,
55
+ 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(FALSE, TRUE),
56
+ ));
57
+ $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
58
+ $field->setRenderer($renderer);
59
+
60
+ $fieldset->addField('visibility', 'select', array(
61
+ 'label' => Mage::helper('productquestion')->__('Visibility'),
62
+ 'name' => 'visibility',
63
+ 'values' => array(
64
+ array(
65
+ 'value' => 1,
66
+ 'label' => Mage::helper('productquestion')->__('Public'),
67
+ ),
68
+
69
+ array(
70
+ 'value' => 0,
71
+ 'label' => Mage::helper('productquestion')->__('Private'),
72
+ ),
73
+ ),
74
+ ));
75
+
76
+ $fieldset->addField('answer', 'editor', array(
77
+ 'name' => 'answer',
78
+ 'label' => Mage::helper('productquestion')->__('Answer'),
79
+ 'title' => Mage::helper('productquestion')->__('Answer'),
80
+ 'required' => TRUE,
81
+ ));
82
+
83
+ if (Mage::getSingleton('adminhtml/session')->getProductquestionData()) {
84
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getProductquestionData());
85
+ Mage::getSingleton('adminhtml/session')->setProductquestionData(null);
86
+ } elseif (Mage::registry('productquestion_data')) {
87
+ Mage::registry('productquestion_data')->setStoreId($stores);
88
+ $form->setValues(Mage::registry('productquestion_data')->getData());
89
+ }
90
+ return parent::_prepareForm();
91
+ }
92
+ }
app/code/local/Magebuzz/Productquestion/Block/Adminhtml/Productquestion/Edit/Tab/Product.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Block_Adminhtml_Productquestion_Edit_Tab_Product extends Mage_Adminhtml_Block_Widget_Grid
7
+ {
8
+ public function __construct()
9
+ {
10
+ parent::__construct();
11
+ $this->setId('entity_id');
12
+ $this->setDefaultSort('entity_id');
13
+ $this->setDefaultDir('DESC');
14
+ $this->setSaveParametersInSession(TRUE);
15
+ $this->setUseAjax(TRUE);
16
+ }
17
+
18
+ protected function _prepareCollection()
19
+ {
20
+ $collection = Mage::getModel('catalog/product')->getCollection();
21
+ $collection->setOrder('entity_id', 'DESC')
22
+ ->addAttributeToSelect('sku')
23
+ ->addAttributeToSelect('name')
24
+ ->addAttributeToSelect('attribute_set_id')
25
+ ->addAttributeToSelect('type_id');
26
+ $this->setCollection($collection);
27
+ return parent::_prepareCollection();
28
+ }
29
+
30
+ protected function _addColumnFilterToCollection($column) {
31
+ if ($column->getId() == 'entity_id') {
32
+ $productIds = $this->getProductIds();
33
+ if (empty($productIds)) {
34
+ $productIds = 0;
35
+ }
36
+
37
+ if ($column->getFilter()->getValue()) {
38
+ $this->getCollection()->addFieldToFilter('entity_id', array('in' => $productIds));
39
+ }
40
+ else {
41
+ if ($productIds) {
42
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin' => $productIds));
43
+ }
44
+ }
45
+ }
46
+ else {
47
+ parent::_addColumnFilterToCollection($column);
48
+ }
49
+ return $this;
50
+ }
51
+
52
+ protected function _prepareColumns()
53
+ {
54
+
55
+ $this->addColumn('entity_id', array(
56
+ 'header_css_class' => 'a-center',
57
+ 'header' => Mage::helper('productquestion')->__('ID'),
58
+ 'field_name' => 'productIds[]',
59
+ 'align' => 'center',
60
+ 'type' => 'checkbox',
61
+ 'width' => '50px',
62
+ 'index' => 'entity_id',
63
+ 'values' => $this->getProductIds()
64
+ ));
65
+
66
+ $this->addColumn('name', array(
67
+ 'header' => Mage::helper('productquestion')->__('Name'),
68
+ 'align' => 'left',
69
+ 'index' => 'name',
70
+ 'type' => 'text',
71
+ ));
72
+
73
+ $this->addColumn('type',
74
+ array(
75
+ 'header' => Mage::helper('catalog')->__('Product Type'),
76
+ 'width' => '60px',
77
+ 'index' => 'type_id',
78
+ 'type' => 'options',
79
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
80
+ ));
81
+
82
+ $this->addColumn('sku', array(
83
+ 'header' => Mage::helper('productquestion')->__('Sku'),
84
+ 'align' => 'left',
85
+ 'index' => 'sku',
86
+ ));
87
+ return parent::_prepareColumns();
88
+ }
89
+
90
+ public function getProductIds()
91
+ {
92
+ //$data = Mage::registry('productquestion_data')->getData();
93
+ $params = $this->getRequest()->getParams();
94
+ $questionId = 0;
95
+ /* if (isset($data['productquestion_id'])) {
96
+ $questionId = $data['productquestion_id'];
97
+ } */
98
+ if (isset($params['id'])) {
99
+ $questionId = $params['id'];
100
+ }
101
+ if ($questionId > 0) {
102
+ $questionModel = Mage::getSingleton('productquestion/productquestionproduct')->getCollection()
103
+ ->AddFieldToFilter('productquestion_id', $questionId)->getData();
104
+ if($questionModel) {
105
+ foreach ($questionModel as $question) {
106
+ $productIds[] = $question['product_id'];
107
+ }
108
+ return $productIds;
109
+ }
110
+ } else {
111
+ return;
112
+ }
113
+ }
114
+
115
+ public function getGridUrl() {
116
+ return $this->getData('grid_url') ? $this->getData('grid_url') : $this->getUrl('*/*/productGrid', array('_current' => TRUE));
117
+ }
118
+
119
+ }
app/code/local/Magebuzz/Productquestion/Block/Adminhtml/Productquestion/Edit/Tabs.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Block_Adminhtml_Productquestion_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
7
+ {
8
+
9
+ public function __construct()
10
+ {
11
+ parent::__construct();
12
+ $this->setId('productquestion_tabs');
13
+ $this->setDestElementId('edit_form');
14
+ $this->setTitle(Mage::helper('productquestion')->__('Question'));
15
+ }
16
+
17
+ protected function _beforeToHtml()
18
+ {
19
+ $question = Mage::registry('productquestion_data')->getData();
20
+ $this->addTab('form_section', array(
21
+ 'label' => Mage::helper('productquestion')->__('Details'),
22
+ 'title' => Mage::helper('productquestion')->__('Details'),
23
+ 'content' => $this->getLayout()->createBlock('productquestion/adminhtml_productquestion_edit_tab_form')->toHtml(),
24
+ ));
25
+
26
+ $this->addTab('product_section', array(
27
+ 'label' => Mage::helper('productquestion')->__('Product'),
28
+ 'title' => Mage::helper('productquestion')->__('Product'),
29
+ 'content' => $this->getLayout()->createBlock('productquestion/adminhtml_productquestion_edit_tab_product')->toHtml(),
30
+ ));
31
+ return parent::_beforeToHtml();
32
+ }
33
+ }
app/code/local/Magebuzz/Productquestion/Block/Adminhtml/Productquestion/Grid.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Block_Adminhtml_Productquestion_Grid extends Mage_Adminhtml_Block_Widget_Grid
7
+ {
8
+ public function __construct()
9
+ {
10
+ parent::__construct();
11
+ $this->setId('productquestionGrid');
12
+ $this->setDefaultSort('productquestion_id');
13
+ $this->setDefaultDir('DESC');
14
+ $this->setSaveParametersInSession(TRUE);
15
+ }
16
+
17
+ protected function _prepareCollection()
18
+ {
19
+ $collection = Mage::getModel('productquestion/productquestion')->getCollection();
20
+ $collection->setOrder('productquestion_id', 'DESC');
21
+ $this->setCollection($collection);
22
+ return parent::_prepareCollection();
23
+ }
24
+
25
+ protected function _prepareColumns()
26
+ {
27
+ $this->addColumn('date', array(
28
+ 'header' => Mage::helper('productquestion')->__('Date'),
29
+ 'align' => 'left',
30
+ 'type' => 'date',
31
+ 'index' => 'date',
32
+ ));
33
+
34
+ $this->addColumn('replied', array(
35
+ 'header' => Mage::helper('productquestion')->__('Replied'),
36
+ 'align' => 'left',
37
+ 'width' => '80px',
38
+ 'index' => 'replied',
39
+ 'type' => 'options',
40
+ 'options' => array(
41
+ 0 => 'No',
42
+ 1 => 'Yes',
43
+ ),
44
+ ));
45
+
46
+ $this->addColumn('author_name', array(
47
+ 'header' => Mage::helper('productquestion')->__('Author Name'),
48
+ 'align' => 'left',
49
+ 'index' => 'author_name',
50
+ ));
51
+
52
+ $this->addColumn('author_email', array(
53
+ 'header' => Mage::helper('productquestion')->__('Author Email'),
54
+ 'align' => 'left',
55
+ 'index' => 'author_email',
56
+ ));
57
+
58
+ $this->addColumn('question', array(
59
+ 'header' => Mage::helper('productquestion')->__('Questions List'),
60
+ 'align' => 'left',
61
+ 'index' => 'question',
62
+ ));
63
+ $this->addColumn('product_name', array(
64
+ 'header' => Mage::helper('productquestion')->__('Product Name'),
65
+ 'align' => 'left',
66
+ 'renderer' => 'productquestion/adminhtml_renderer_productname',
67
+ 'filter' => false,
68
+ ));
69
+
70
+ $this->addColumn('visibility', array(
71
+ 'header' => Mage::helper('productquestion')->__('Visibility'),
72
+ 'align' => 'left',
73
+ 'width' => '80px',
74
+ 'index' => 'visibility',
75
+ 'type' => 'options',
76
+ 'options' => array(
77
+ 0 => 'Private',
78
+ 1 => 'Public',
79
+ ),
80
+ ));
81
+
82
+ $this->addColumn('action',
83
+ array(
84
+ 'header' => Mage::helper('productquestion')->__('Action'),
85
+ 'width' => '100',
86
+ 'type' => 'action',
87
+ 'getter' => 'getId',
88
+ 'actions' => array(
89
+ array(
90
+ 'caption' => Mage::helper('productquestion')->__('Reply'),
91
+ 'url' => array('base' => '*/*/edit'),
92
+ 'field' => 'id'
93
+ )
94
+ ),
95
+ 'filter' => FALSE,
96
+ 'sortable' => FALSE,
97
+ 'index' => 'stores',
98
+ 'is_system' => TRUE,
99
+ ));
100
+
101
+ $this->addExportType('*/*/exportCsv', Mage::helper('productquestion')->__('CSV'));
102
+ $this->addExportType('*/*/exportXml', Mage::helper('productquestion')->__('XML'));
103
+
104
+ return parent::_prepareColumns();
105
+ }
106
+
107
+ protected function _prepareMassaction()
108
+ {
109
+ $this->setMassactionIdField('productquestion_id');
110
+ $this->getMassactionBlock()->setFormFieldName('productquestion');
111
+
112
+ $this->getMassactionBlock()->addItem('delete', array(
113
+ 'label' => Mage::helper('productquestion')->__('Delete'),
114
+ 'url' => $this->getUrl('*/*/massDelete'),
115
+ 'confirm' => Mage::helper('productquestion')->__('Are you sure?')
116
+ ));
117
+
118
+ $statuses = Mage::getSingleton('productquestion/status')->getOptionArray();
119
+ $this->getMassactionBlock()->addItem('status', array(
120
+ 'label' => Mage::helper('productquestion')->__('Change visibility status'),
121
+ 'url' => $this->getUrl('*/*/massStatus', array('_current' => TRUE)),
122
+ 'additional' => array(
123
+ 'visibility' => array(
124
+ 'name' => 'status',
125
+ 'type' => 'select',
126
+ 'class' => 'required-entry',
127
+ 'label' => Mage::helper('productquestion')->__('Status'),
128
+ 'values' => $statuses
129
+ )
130
+ )
131
+ ));
132
+ return $this;
133
+ }
134
+
135
+ public function getRowUrl($row)
136
+ {
137
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
138
+ }
139
+
140
+ }
app/code/local/Magebuzz/Productquestion/Block/Adminhtml/Renderer/Productname.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Block_Adminhtml_Renderer_Productname extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
7
+ {
8
+ public function render(Varien_Object $row)
9
+ {
10
+ $productquestionId = $row->getProductquestionId();
11
+ $productquestionProduct = Mage::getModel('productquestion/productquestionproduct')->getCollection()
12
+ ->addFieldToFilter('productquestion_id', $productquestionId);
13
+ $productName = '';
14
+ if (count($productquestionProduct)) {
15
+ foreach ($productquestionProduct as $_productquestionProduct) {
16
+ $productId = $_productquestionProduct->getProductId();
17
+ $productName .= Mage::getModel('catalog/product')->load($productId)->getName();
18
+ }
19
+ }
20
+ return $productName;
21
+ }
22
+ }
app/code/local/Magebuzz/Productquestion/Block/Captcha.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Block_Captcha extends Mage_Core_Block_Template
7
+ {
8
+ public function __construct()
9
+ {
10
+ parent::__construct();
11
+ }
12
+ }
app/code/local/Magebuzz/Productquestion/Block/Productquestion.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Block_Productquestion extends Mage_Core_Block_Template
7
+ {
8
+ public function __construct()
9
+ {
10
+ parent::__construct();
11
+ $_product = $this->getProduct()->getData();
12
+ $storeId[] = Mage::app()->getStore()->getId();
13
+ $storeId[] = 0;
14
+
15
+ $questionProduct = Mage::getModel('productquestion/productquestionproduct')->getCollection()->addFieldToFilter('product_id', $_product['entity_id'])->getData();
16
+ $questIds = array();
17
+ $questId = '';
18
+ if($questionProduct) {
19
+ foreach ($questionProduct as $quest) {
20
+ $questIds[] = $quest['productquestion_id'];
21
+ }
22
+ }
23
+ if($questIds) {
24
+ $listQuestionStore = Mage::getModel('productquestion/productquestionstore')->getCollection()
25
+ ->addFieldToFilter('productquestion_id', $questIds)
26
+ ->addFieldToFilter('store_id', $storeId);
27
+ if(isset($listQuestionStore)) {
28
+ foreach ($listQuestionStore as $listquest) {
29
+ $questId[] = $listquest->getProductquestionId();
30
+ }
31
+ }
32
+ }
33
+ $collection = Mage::getModel('productquestion/productquestion')->getCollection();
34
+ $collection->setOrder('productquestion_id', 'DESC');
35
+ $collection->addFieldToFilter('visibility', 1);
36
+ $collection->addFieldToFilter('replied', 1);
37
+ $collection->addFieldToFilter('productquestion_id', $questId);
38
+ $this->setQuestion($collection);
39
+ }
40
+
41
+ protected function _prepareLayout()
42
+ {
43
+ parent::_prepareLayout();
44
+ $pager = $this->getLayout()->createBlock('page/html_pager', 'productquestion.pager');
45
+ $pager->setAvailableLimit(array(3 => 3, 6 => 6, 9 => 9, 'all' => 'all'));
46
+ $pager->setCollection($this->getQuestion());
47
+ $this->setChild('pager', $pager);
48
+ return $this;
49
+ }
50
+
51
+ public function getPostUrl()
52
+ {
53
+ return $this->getUrl('productquestion/index/post', array());
54
+ }
55
+
56
+ public function isCustomerLoggedIn()
57
+ {
58
+ return Mage::getSingleton('customer/session')->isLoggedIn();
59
+ }
60
+
61
+ public function getCurrentCustomer()
62
+ {
63
+ return Mage::getSingleton('customer/session')->getCustomer();
64
+ }
65
+
66
+ public function getProduct()
67
+ {
68
+ if (!Mage::registry('product') && $this->getProductId()) {
69
+ $product = Mage::getModel('catalog/product')->load($this->getProductId());
70
+ Mage::register('product', $product);
71
+ }
72
+ return Mage::registry('product');
73
+ }
74
+
75
+ public function getPagerHtml()
76
+ {
77
+ return $this->getChildHtml('pager');
78
+
79
+ }
80
+
81
+ public function getProductQuestionUrl()
82
+ {
83
+ return Mage::getUrl('productquestion/index/index', array(
84
+ 'id' => $this->getProduct()->getId(),
85
+ 'category' => $this->getProduct()->getCategoryId()
86
+ ));
87
+ }
88
+
89
+ public function getFormData()
90
+ {
91
+ return Mage::getSingleton('productquestion/session')->getFormData(TRUE);
92
+ }
93
+
94
+ public function getCookie($name)
95
+ {
96
+ return Mage::getModel('core/cookie')->get($name);
97
+ }
98
+
99
+ public function isShownInProductDetail() {
100
+ return Mage::getStoreConfig('productquestion/general/show_in_product_detail', Mage::app()->getStore());
101
+ }
102
+
103
+ public function isGuestAllowedToAsk() {
104
+ return Mage::getStoreConfig('productquestion/general/allow_guest_ask_question', Mage::app()->getStore());
105
+ }
106
+ }
app/code/local/Magebuzz/Productquestion/Block/Productquestionoutpage.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Block_Productquestionoutpage extends Mage_Catalog_Block_Product_View
7
+ {
8
+ public function __construct()
9
+ {
10
+ parent::__construct();
11
+ $params = $this->getRequest()->getParams();
12
+ $storeId[] = Mage::app()->getStore()->getId();
13
+ $storeId[] = 0;
14
+ $questions = Mage::getModel('productquestion/productquestionproduct')->getCollection()->addFieldToFilter('product_id', $params['id'])->getData();
15
+
16
+ $collection = Mage::getModel('productquestion/productquestion')->getCollection();
17
+ $collection->setOrder('productquestion_id', 'DESC');
18
+ $collection->addFieldToFilter('visibility', 1);
19
+ $collection->addFieldToFilter('replied', 1);
20
+
21
+ if (!empty($questions)) {
22
+ foreach ($questions as $question) {
23
+ $questIds[] = $question['productquestion_id'];
24
+ }
25
+
26
+ $questionStoreLists = Mage::getModel('productquestion/productquestionstore')->getCollection()
27
+ ->addFieldToFilter('productquestion_id', $questIds)
28
+ ->addFieldToFilter('store_id', $storeId);
29
+
30
+ foreach ($questionStoreLists as $list) {
31
+ $questId[] = $list->getProductquestionId();
32
+ }
33
+
34
+ $collection->addFieldToFilter('productquestion_id', $questId);
35
+ } else {
36
+ $collection->addFieldToFilter('productquestion_id', 0);
37
+ }
38
+
39
+ $this->setQuestion($collection);
40
+ }
41
+
42
+ protected function _prepareLayout()
43
+ {
44
+ parent::_prepareLayout();
45
+ $this->getLayout()->getBlock('head')->setTitle(Mage::helper('productquestion')->__('Product Question'));
46
+ $pager = $this->getLayout()->createBlock('page/html_pager', 'productquestionoutpage.pager');
47
+ $pager->setAvailableLimit(array(3 => 3, 6 => 6, 9 => 9, 'all' => 'all'));
48
+ $pager->setCollection($this->getQuestion());
49
+ $this->setChild('pager', $pager);
50
+ return $this;
51
+ }
52
+
53
+ public function getPostUrl()
54
+ {
55
+ return $this->getUrl('productquestion/index/post', array());
56
+ }
57
+
58
+ public function isCustomerLoggedIn()
59
+ {
60
+ return Mage::getSingleton('customer/session')->isLoggedIn();
61
+ }
62
+
63
+ public function getCurrentCustomer()
64
+ {
65
+ return Mage::getSingleton('customer/session')->getCustomer();
66
+ }
67
+
68
+ public function getProduct()
69
+ {
70
+ $params = $this->getRequest()->getParams();
71
+ $product = Mage::getModel('catalog/product')->load($params['id']);
72
+
73
+ return $product;
74
+ }
75
+
76
+ public function getPagerHtml()
77
+ {
78
+ return $this->getChildHtml('pager');
79
+ }
80
+
81
+ public function getFormData()
82
+ {
83
+ return Mage::getSingleton('productquestion/session')->getFormData(TRUE);
84
+ }
85
+
86
+ public function getCookie($name)
87
+ {
88
+ return Mage::getModel('core/cookie')->get($name);
89
+ }
90
+ }
app/code/local/Magebuzz/Productquestion/Helper/Data.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Helper_Data extends Mage_Core_Helper_Abstract
7
+ {
8
+ public function isEnabled()
9
+ {
10
+ return Mage::getStoreConfig('productquestion/general/enabled');
11
+ }
12
+
13
+ public function getPercentVote($requestId)
14
+ {
15
+ $requestModel = Mage::getSingleton('productquestion/productquestion')->load($requestId);
16
+ $voteup = $requestModel->getCountup();
17
+ $votedown = $requestModel->getCountdown();
18
+
19
+ if ($voteup == 0 && $votedown == 0) {
20
+ return 0;
21
+ } else {
22
+
23
+ return $voteup / ($voteup + $votedown) * 100;
24
+ }
25
+ }
26
+
27
+ public function getCountVote($requestId)
28
+ {
29
+ $requestModel = Mage::getSingleton('productquestion/productquestion')->load($requestId);
30
+ $voteup = $requestModel->getCountup();
31
+ $votedown = $requestModel->getCountdown();
32
+ return $votedown + $voteup;
33
+ }
34
+
35
+ public function getCaptchaLanguage()
36
+ {
37
+ return Mage::getStoreConfig('productquestion/general/lang', Mage::app()->getStore());;
38
+ }
39
+
40
+ public function getCaptchaTheme()
41
+ {
42
+ return Mage::getStoreConfig('productquestion/general/theme',Mage::app()->getStore());
43
+ }
44
+
45
+ public function getPublicKey()
46
+ {
47
+ return Mage::getStoreConfig('productquestion/general/public_key');
48
+ }
49
+
50
+ public function isCaptchaEnabled()
51
+ {
52
+ return Mage::getStoreConfig('productquestion/general/enable_question_captcha', Mage::app()->getStore());
53
+ }
54
+ }
app/code/local/Magebuzz/Productquestion/Model/Mysql4/Productquestion.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Model_Mysql4_Productquestion extends Mage_Core_Model_Mysql4_Abstract
7
+ {
8
+ protected function _construct()
9
+ {
10
+ $this->_init('productquestion/productquestion', 'productquestion_id');
11
+ }
12
+
13
+ }
app/code/local/Magebuzz/Productquestion/Model/Mysql4/Productquestion/Collection.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Model_Mysql4_Productquestion_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
7
+ {
8
+ protected function _construct()
9
+ {
10
+ parent::_construct();
11
+ $this->_init('productquestion/productquestion');
12
+ }
13
+ }
app/code/local/Magebuzz/Productquestion/Model/Mysql4/Productquestionproduct.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Model_Mysql4_Productquestionproduct extends Mage_Core_Model_Mysql4_Abstract
7
+ {
8
+ protected function _construct()
9
+ {
10
+ $this->_init('productquestion/productquestionproduct', 'id');
11
+ }
12
+
13
+ }
app/code/local/Magebuzz/Productquestion/Model/Mysql4/Productquestionproduct/Collection.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Model_Mysql4_Productquestionproduct_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
7
+ {
8
+ protected function _construct()
9
+ {
10
+ parent::_construct();
11
+ $this->_init('productquestion/productquestionproduct');
12
+ }
13
+ }
app/code/local/Magebuzz/Productquestion/Model/Mysql4/Productquestionstore.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Model_Mysql4_Productquestionstore extends Mage_Core_Model_Mysql4_Abstract
7
+ {
8
+ protected function _construct()
9
+ {
10
+ $this->_init('productquestion/productquestionstore', 'productquestion_id');
11
+ }
12
+
13
+ }
app/code/local/Magebuzz/Productquestion/Model/Mysql4/Productquestionstore/Collection.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Model_Mysql4_Productquestionstore_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
7
+ {
8
+ protected function _construct()
9
+ {
10
+ parent::_construct();
11
+ $this->_init('productquestion/productquestionstore');
12
+ }
13
+ }
app/code/local/Magebuzz/Productquestion/Model/Productquestion.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Model_Productquestion extends Mage_Core_Model_Abstract
7
+ {
8
+ protected function _construct()
9
+ {
10
+ parent::_construct();
11
+ $this->_init('productquestion/productquestion');
12
+ }
13
+
14
+ public function compareProductList($newArray, $oldArray, $questionId)
15
+ {
16
+ $productModle = Mage::getModel('catalog/product');
17
+ $insert = array_diff($newArray, $oldArray);
18
+ $delete = array_diff($oldArray, $newArray);
19
+ $resource = Mage::getSingleton('core/resource');
20
+ $writeConnection = $resource->getConnection('core_write');
21
+ if (isset($newArray)) {
22
+ if ($delete) {
23
+ foreach ($delete as $del) {
24
+ $where = 'productquestion_product.productquestion_id = ' . $questionId . ' AND productquestion_product.product_id = ' . $del;
25
+ $writeConnection->delete('productquestion_product', $where);
26
+ }
27
+ }
28
+ if ($insert) {
29
+ $data = array();
30
+ foreach ($insert as $pid) {
31
+
32
+ $data[] = array(
33
+ 'productquestion_id' => $questionId,
34
+ 'product_id' => $pid,
35
+ );
36
+ }
37
+ if (count($data) > 0) {
38
+ $writeConnection->insertMultiple('productquestion_product', $data);
39
+ }
40
+ }
41
+ } else {
42
+ if ($oldArray) {
43
+ foreach ($oldArray as $del) {
44
+ $where = 'productquestion_product.productquestion_id = ' . $questionId . ' AND productquestion_product.product_id = ' . $del;
45
+ $writeConnection->delete('productquestion_product', $where);
46
+ }
47
+ }
48
+ }
49
+ }
50
+ }
app/code/local/Magebuzz/Productquestion/Model/Productquestionproduct.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Model_Productquestionproduct extends Mage_Core_Model_Abstract
7
+ {
8
+ protected function _construct()
9
+ {
10
+ parent::_construct();
11
+ $this->_init('productquestion/productquestionproduct');
12
+ }
13
+ }
app/code/local/Magebuzz/Productquestion/Model/Productquestionstore.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Model_Productquestionstore extends Mage_Core_Model_Abstract
7
+ {
8
+ protected function _construct()
9
+ {
10
+ parent::_construct();
11
+ $this->_init('productquestion/productquestionstore');
12
+ }
13
+
14
+ public function saveStoreView($stores, $questionId)
15
+ {
16
+
17
+ $questionStoreModel = Mage::getModel('productquestion/productquestionstore');
18
+ $listQuestionOld = $questionStoreModel->getCollection()->AddFieldToFilter('productquestion_id', $questionId)->getData();
19
+ $listStoreOld = array();
20
+ foreach ($listQuestionOld as $quest) {
21
+ $listStoreOld[] = $quest['store_id'];
22
+ }
23
+ $insert = array_diff($stores, $listStoreOld);
24
+ $delete = array_diff($listStoreOld, $stores);
25
+ $resource = Mage::getSingleton('core/resource');
26
+ $writeConnection = $resource->getConnection('core_write');
27
+ if (isset($stores)) {
28
+ if (count($delete) > 0) {
29
+ foreach ($delete as $del) {
30
+ $where = 'productquestion_store.productquestion_id = ' . $questionId . ' AND productquestion_store.store_id = ' . $del;
31
+ $writeConnection->delete('productquestion_store', $where);
32
+ }
33
+ }
34
+ if (count($insert) > 0) {
35
+ $data = array();
36
+ foreach ($insert as $store) {
37
+ $data[] = array(
38
+ 'productquestion_id' => $questionId,
39
+ 'store_id' => $store,
40
+ );
41
+ }
42
+ if (count($data) > 0) {
43
+ $writeConnection->insertMultiple('productquestion_store', $data);
44
+ }
45
+ }
46
+ }
47
+ }
48
+
49
+ public function saveStoreId($data)
50
+ {
51
+ if (count($data) > 0) {
52
+ $resource = Mage::getSingleton('core/resource');
53
+ $table = Mage::getSingleton('core/resource')->getTableName('productquestion/productquestionstore');
54
+ $writeConnection = $resource->getConnection('core_write');
55
+ $writeConnection->insertMultiple($table, $data);
56
+ }
57
+ }
58
+ }
app/code/local/Magebuzz/Productquestion/Model/Session.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Model_Session extends Mage_Core_Model_Session_Abstract
7
+ {
8
+ public function __construct()
9
+ {
10
+ $this->init('productquestion');
11
+ }
12
+ }
app/code/local/Magebuzz/Productquestion/Model/Status.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Model_Status extends Varien_Object
7
+ {
8
+ const STATUS_PUBLIC = 1;
9
+ const STATUS_PRIVATE = 0;
10
+
11
+ static public function getOptionArray()
12
+ {
13
+ return array(
14
+ self::STATUS_PUBLIC => Mage::helper('productquestion')->__('Public'),
15
+ self::STATUS_PRIVATE => Mage::helper('productquestion')->__('Private')
16
+ );
17
+ }
18
+ }
app/code/local/Magebuzz/Productquestion/Model/System/Config/Source/Dropdown/Lang.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Model_System_Config_Source_Dropdown_Lang
7
+ {
8
+ public function toOptionArray()
9
+ {
10
+ return array(
11
+ array(
12
+ 'value' => 'en',
13
+ 'label' => 'English (default)',
14
+ ),
15
+ array(
16
+ 'value' => 'nl',
17
+ 'label' => 'Dutch',
18
+ ),
19
+ array(
20
+ 'value' => 'fr',
21
+ 'label' => 'French',
22
+ ),
23
+ array(
24
+ 'value' => 'de',
25
+ 'label' => 'German',
26
+ ),
27
+ array(
28
+ 'value' => 'pt',
29
+ 'label' => 'Portuguese',
30
+ ),
31
+ array(
32
+ 'value' => 'ru',
33
+ 'label' => 'Russian',
34
+ ),
35
+ array(
36
+ 'value' => 'es',
37
+ 'label' => 'Spanish',
38
+ ),
39
+ array(
40
+ 'value' => 'tr',
41
+ 'label' => 'Turkish',
42
+ ),
43
+ array(
44
+ 'value' => 'vi',
45
+ 'label' => 'Vietnamese'
46
+ ),
47
+ );
48
+ }
49
+ }
app/code/local/Magebuzz/Productquestion/Model/System/Config/Source/Dropdown/Theme.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Model_System_Config_Source_Dropdown_Theme
7
+ {
8
+ public function toOptionArray()
9
+ {
10
+ return array(
11
+ array(
12
+ 'value' => 'light',
13
+ 'label' => 'Light (default)',
14
+ ),
15
+ array(
16
+ 'value' => 'dark',
17
+ 'label' => 'Dark',
18
+ ),
19
+ );
20
+ }
21
+ }
app/code/local/Magebuzz/Productquestion/controllers/Adminhtml/ProductquestionController.php ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+
6
+ class Magebuzz_Productquestion_Adminhtml_ProductquestionController extends Mage_Adminhtml_Controller_action
7
+ {
8
+ const XML_PATH_EMAIL_RECIPIENT = 'productquestion/email/send_email_to_admin';
9
+ const XML_PATH_EMAIL_SENDER = 'productquestion/email/email_sender';
10
+ const XML_PATH_EMAIL_TEMPLATE = 'productquestion/email/email_customer_template';
11
+
12
+ protected function _initAction()
13
+ {
14
+ $this->loadLayout()
15
+ ->_setActiveMenu('productquestion/items')
16
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
17
+ return $this;
18
+ }
19
+
20
+ public function indexAction()
21
+ {
22
+ $this->_initAction()
23
+ ->renderLayout();
24
+ }
25
+
26
+ public function editAction()
27
+ {
28
+ $id = $this->getRequest()->getParam('id');
29
+ $model = Mage::getModel('productquestion/productquestion')->load($id);
30
+ $product_data = $model->getData();
31
+ $productName = '';
32
+ if (isset($product_data['product_id'])) {
33
+ $product = Mage::getModel('catalog/product')->load($product_data['product_id'])->getData();
34
+ $productName = $product['name'];
35
+ }
36
+ $model->setData('product_name', $productName);
37
+ if ($model->getId() || $id == 0) {
38
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(TRUE);
39
+ if (!empty($data)) {
40
+ $model->setData($data);
41
+ }
42
+ Mage::register('productquestion_data', $model);
43
+ $this->loadLayout();
44
+ $this->_setActiveMenu('productquestion/items');
45
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
46
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
47
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(TRUE);
48
+ $this->_addContent($this->getLayout()->createBlock('productquestion/adminhtml_productquestion_edit'));
49
+ $this->_addLeft($this->getLayout()->createBlock('productquestion/adminhtml_productquestion_edit_tabs'));
50
+ $this->renderLayout();
51
+ } else {
52
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('productquestion')->__('Item does not exist'));
53
+ $this->_redirect('*/*/');
54
+ }
55
+ }
56
+
57
+ public function newAction()
58
+ {
59
+ $this->_forward('edit');
60
+ }
61
+
62
+ public function saveAction()
63
+ {
64
+ if ($data = $this->getRequest()->getPost()) {
65
+ $model = Mage::getModel('productquestion/productquestion');
66
+ $productModel = Mage::getModel('productquestion/productquestionproduct');
67
+ $storeModel = Mage::getModel('productquestion/productquestionstore');
68
+ $model->setData($data)
69
+ ->setId($this->getRequest()->getParam('id'));
70
+ try {
71
+ $id = $this->getRequest()->getParam('id');
72
+ $collection = Mage::getModel('productquestion/productquestion')->load($id);
73
+ $replied_before = $collection->getData('replied');
74
+ $model->setReplied(1);
75
+ $productIds = array();
76
+ if(isset($data['productIds'])) {
77
+ $productIds = $data['productIds'];
78
+ }
79
+ if ($data['date'] == '') {
80
+ $model->setDate(Mage::getModel('core/date')->gmtTimestamp());
81
+ }
82
+ $model->save();
83
+ $productquestionId = $model->getProductquestionId();
84
+ $productCollection = $productModel->getCollection()->AddFieldToFilter('productquestion_id', $productquestionId)->getData();
85
+ $productIdsOld = array();
86
+ foreach ($productCollection as $pro) {
87
+ $productIdsOld[] = $pro['product_id'];
88
+ }
89
+ $model->compareProductList($productIds, $productIdsOld, $productquestionId);
90
+ $storeModel->saveStoreView($data['stores'], $productquestionId);
91
+ if ($replied_before == '0') {
92
+ //send email to customer
93
+ foreach ($productIdsOld as $product) {
94
+ $_product = Mage::getModel('catalog/product')->load($product);
95
+ $translate = Mage::getSingleton('core/translate');
96
+ $translate->setTranslateInline(FALSE);
97
+ $postObject = new Varien_Object();
98
+ $postObject->setData($data);
99
+ $product_url = '';
100
+ $product_url .= '<a href="' . $_product->getProductUrl() . '">' . $_product->getProductUrl() . '</a>';
101
+ $mailTemplate = Mage::getModel('core/email_template');
102
+ $mailTemplate->setDesignConfig(array('area' => 'frontend'))
103
+ ->setReplyTo(Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT))
104
+ ->sendTransactional(
105
+ Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE),
106
+ Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),
107
+ $data['author_email'],
108
+ null,
109
+ array('data' => $postObject,
110
+ 'product_name' => $_product->getName(),
111
+ 'product_url' => $product_url,
112
+ ));
113
+ $translate->setTranslateInline(TRUE);
114
+ }
115
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('productquestion')->__('Question was successfully replied'));
116
+ } else {
117
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('productquestion')->__('Question was successfully saved'));
118
+ }
119
+ Mage::getSingleton('adminhtml/session')->setFormData(FALSE);
120
+
121
+ if ($this->getRequest()->getParam('back')) {
122
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
123
+ return;
124
+ }
125
+ $this->_redirect('*/*/');
126
+ return;
127
+ } catch (Exception $e) {
128
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
129
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
130
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
131
+ return;
132
+ }
133
+ }
134
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('productquestion')->__('Unable to find item to reply'));
135
+ $this->_redirect('*/*/');
136
+ }
137
+
138
+ public function deleteAction()
139
+ {
140
+ if ($this->getRequest()->getParam('id') > 0) {
141
+ try {
142
+ $model = Mage::getModel('productquestion/productquestion');
143
+ $model->setId($this->getRequest()->getParam('id'))
144
+ ->delete();
145
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
146
+ $this->_redirect('*/*/');
147
+ } catch (Exception $e) {
148
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
149
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
150
+ }
151
+ }
152
+ $this->_redirect('*/*/');
153
+ }
154
+
155
+ public function massDeleteAction()
156
+ {
157
+ $productquestionIds = $this->getRequest()->getParam('productquestion');
158
+ if (!is_array($productquestionIds)) {
159
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
160
+ } else {
161
+ try {
162
+ foreach ($productquestionIds as $productquestionId) {
163
+ $productquestion = Mage::getModel('productquestion/productquestion')->load($productquestionId);
164
+ $productquestion->delete();
165
+ }
166
+ Mage::getSingleton('adminhtml/session')->addSuccess(
167
+ Mage::helper('adminhtml')->__(
168
+ 'Total of %d record(s) were successfully deleted', count($productquestionIds)
169
+ )
170
+ );
171
+ } catch (Exception $e) {
172
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
173
+ }
174
+ }
175
+ $this->_redirect('*/*/index');
176
+ }
177
+
178
+ public function massStatusAction()
179
+ {
180
+ $productquestionIds = $this->getRequest()->getParam('productquestion');
181
+ if (!is_array($productquestionIds)) {
182
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
183
+ } else {
184
+ try {
185
+ foreach ($productquestionIds as $productquestionId) {
186
+ $productquestion = Mage::getSingleton('productquestion/productquestion')
187
+ ->load($productquestionId)
188
+ ->setVisibility($this->getRequest()->getParam('status'))
189
+ ->setIsMassupdate(TRUE)
190
+ ->save();
191
+ }
192
+ $this->_getSession()->addSuccess(
193
+ $this->__('Total of %d record(s) were successfully updated', count($productquestionIds))
194
+ );
195
+ } catch (Exception $e) {
196
+ $this->_getSession()->addError($e->getMessage());
197
+ }
198
+ }
199
+ $this->_redirect('*/*/index');
200
+ }
201
+
202
+ public function exportCsvAction()
203
+ {
204
+ $fileName = 'productquestion.csv';
205
+ $content = $this->getLayout()->createBlock('productquestion/adminhtml_productquestion_grid')
206
+ ->getCsv();
207
+ //$this->_sendUploadResponse($fileName, $content);
208
+ $this->_prepareDownloadResponse($fileName, $content);
209
+ }
210
+
211
+ public function exportXmlAction()
212
+ {
213
+ $fileName = 'productquestion.xml';
214
+ $content = $this->getLayout()->createBlock('productquestion/adminhtml_productquestion_grid')
215
+ ->getXml();
216
+ //$this->_sendUploadResponse($fileName, $content);
217
+ $this->_prepareDownloadResponse($fileName, $content);
218
+ }
219
+
220
+ protected function _sendUploadResponse($fileName, $content, $contentType = 'application/octet-stream')
221
+ {
222
+ $response = $this->getResponse();
223
+ $response->setHeader('HTTP/1.1 200 OK', '');
224
+ $response->setHeader('Pragma', 'public', TRUE);
225
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', TRUE);
226
+ $response->setHeader('Content-Disposition', 'attachment; filename=' . $fileName);
227
+ $response->setHeader('Last-Modified', date('r'));
228
+ $response->setHeader('Accept-Ranges', 'bytes');
229
+ $response->setHeader('Content-Length', strlen($content));
230
+ $response->setHeader('Content-type', $contentType);
231
+ $response->setBody($content);
232
+ $response->sendResponse();
233
+ }
234
+
235
+ public function productGridAction(){
236
+ $this->loadLayout();
237
+ $this->getResponse()->setBody(
238
+ $this->getLayout()->createBlock('productquestion/adminhtml_productquestion_edit_tab_product')->toHtml()
239
+ );
240
+ }
241
+ }
app/code/local/Magebuzz/Productquestion/controllers/IndexController.php ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+ class Magebuzz_Productquestion_IndexController extends Mage_Core_Controller_Front_Action {
6
+ const XML_PATH_EMAIL_RECIPIENT = 'productquestion/email/send_email_to_admin';
7
+ const XML_PATH_EMAIL_SENDER = 'productquestion/email/email_sender';
8
+ const XML_PATH_EMAIL_TEMPLATE = 'productquestion/email/email_admin_template';
9
+ const XML_PATH_EMAIL_CONFIRMATION_TEMPLATE = 'productquestion/email/email_confirmation';
10
+ const XML_PATH_PRIVATE_KEY = 'productquestion/general/private_key';
11
+
12
+ public function indexAction() {
13
+ if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
14
+ if (Mage::getStoreConfig('productquestion/general/allow_guest_ask_question', Mage::app()->getStore()) == "0") {
15
+ Mage::getSingleton('customer/session')->authenticate($this);
16
+ }
17
+ }
18
+ $product = $this->_initProduct();
19
+
20
+ if (!$product) {
21
+ Mage::app()->getResponse()->setRedirect(Mage::getUrl());
22
+ return false;
23
+ }
24
+
25
+ $this->loadLayout();
26
+ if ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs')) {
27
+ $breadcrumbsBlock->addCrumb('product', array(
28
+ 'label' => $product->getName(),
29
+ 'link' => $product->getProductUrl(),
30
+ 'readonly' => TRUE,
31
+ ));
32
+ $breadcrumbsBlock->addCrumb('productquestion', array('label' => Mage::helper('productquestion')->__('Product Questions')));
33
+ }
34
+ $this->_initLayoutMessages('productquestion/session');
35
+ $this->renderLayout();
36
+ }
37
+
38
+ protected function _initProduct() {
39
+ Mage::dispatchEvent('review_controller_product_init_before', array('controller_action' => $this));
40
+ $categoryId = (int)$this->getRequest()->getParam('category', FALSE);
41
+ $productId = (int)$this->getRequest()->getParam('id');
42
+
43
+ $product = $this->_loadProduct($productId);
44
+
45
+ if ($categoryId) {
46
+ $category = Mage::getModel('catalog/category')->load($categoryId);
47
+ Mage::register('current_category', $category);
48
+ }
49
+
50
+ try {
51
+ Mage::dispatchEvent('review_controller_product_init', array('product' => $product));
52
+ Mage::dispatchEvent('review_controller_product_init_after', array('product' => $product, 'controller_action' => $this));
53
+ } catch (Mage_Core_Exception $e) {
54
+ Mage::logException($e);
55
+ return FALSE;
56
+ }
57
+
58
+ return $product;
59
+ }
60
+
61
+ protected function _loadProduct($productId) {
62
+ if (!$productId) {
63
+ return FALSE;
64
+ }
65
+
66
+ $product = Mage::getModel('catalog/product')
67
+ ->setStoreId(Mage::app()->getStore()->getId())
68
+ ->load($productId);
69
+ /**
70
+ * @var $product Mage_Catalog_Model_Product
71
+ */
72
+ if (!$product->getId() || !$product->isVisibleInCatalog() || !$product->isVisibleInSiteVisibility()) {
73
+ return FALSE;
74
+ }
75
+
76
+ Mage::register('current_product', $product);
77
+ Mage::register('product', $product);
78
+
79
+ return $product;
80
+ }
81
+
82
+ protected function _save() {
83
+ $post = $this->getRequest()->getPost();
84
+ $_product = Mage::getModel('catalog/product')->load($post['product_id']);
85
+ $storeId = Mage::app()->getStore()->getId();
86
+ if ($post) {
87
+ try {
88
+ $model = Mage::getModel('productquestion/productquestion');
89
+ $modelProduct = Mage::getModel('productquestion/productquestionproduct');
90
+ $storeModel = Mage::getModel('productquestion/productquestionstore');
91
+ //save question
92
+ $model->setData($post);
93
+ $now = Mage::getModel('core/date')->gmtTimestamp();
94
+ $model->setDate(date('Y-m-d H:i:s', $now));
95
+ $model->save();
96
+ //save product
97
+ $productQuestionId = $model->getProductquestionId();
98
+ $modelProduct->setProductquestionId($productQuestionId);
99
+ $modelProduct->setProductId($post['product_id']);
100
+ $modelProduct->save();
101
+ //save store
102
+ $dataStore = array('productquestion_id' => $productQuestionId, 'store_id' => $storeId);
103
+ $storeModel->saveStoreId($dataStore);
104
+ //send mail
105
+ $translate = Mage::getSingleton('core/translate');
106
+ $translate->setTranslateInline(FALSE);
107
+ $postObject = new Varien_Object();
108
+ $postObject->setData($post);
109
+ $productUrl = '';
110
+ $productUrl .= '<a href="' . $_product->getProductUrl() . '">' . $_product->getProductUrl() . '</a>';
111
+ $mailTemplateAdmin = Mage::getModel('core/email_template');
112
+ $mailTemplateAdmin->setDesignConfig(array('area' => 'frontend'))
113
+ ->setReplyTo($post['author_email'])
114
+ ->sendTransactional(
115
+ Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE),
116
+ Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),
117
+ Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT),
118
+ null,
119
+ array('data' => $postObject,
120
+ 'product_name' => $_product->getName(),
121
+ 'product_url' => $productUrl,
122
+ ));
123
+
124
+ if (Mage::getStoreConfig('productquestion/general/enable_email_confirmation')) {
125
+ $replyto = Mage::getStoreConfig('productquestion/email/send_email_to_admin');
126
+ $mailTemplateCustomer = Mage::getModel('core/email_template');
127
+ $mailTemplateCustomer->setDesignConfig(array('area' => 'frontend'))
128
+ ->setReplyTo($replyto)
129
+ ->sendTransactional(
130
+ Mage::getStoreConfig(self::XML_PATH_EMAIL_CONFIRMATION_TEMPLATE),
131
+ Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),
132
+ $post['author_email'],
133
+ null,
134
+ array('data' => $postObject,
135
+ 'product_name' => $_product->getName(),
136
+ 'product_url' => $productUrl,
137
+ ));
138
+ }
139
+
140
+ $translate->setTranslateInline(TRUE);
141
+ Mage::getSingleton('core/session')->addSuccess('Your question has been submitted!');
142
+ Mage::getSingleton('productquestion/session')->setFormData(FALSE);
143
+ return;
144
+ } catch (Exception $e) {
145
+ Mage::getSingleton('core/session')->addError('An error has occured. Please try again later!');
146
+ Mage::app()->getResponse()->setRedirect($post['current_url']);
147
+ return;
148
+ }
149
+ } else {
150
+ Mage::getSingleton('core/session')->addError('Please try again later!');
151
+ Mage::app()->getResponse()->setRedirect($post['current_url']);
152
+ return;
153
+ }
154
+ }
155
+
156
+ public function postAction() {
157
+ $post = $this->getRequest()->getPost();
158
+ if (Mage::getStoreConfig('productquestion/general/enable_question_captcha', Mage::app()->getStore()) == "1") {
159
+ if (!isset($post['g-recaptcha-response'])) {
160
+ $this->_redirect('*/');
161
+ return;
162
+ }
163
+
164
+ require_once(Mage::getBaseDir('lib') . DS . 'reCaptcha' . DS . 'recaptchalib.php');
165
+ $privatekey = Mage::getStoreConfig(self::XML_PATH_PRIVATE_KEY);
166
+
167
+ $resp = null;
168
+ $error = null;
169
+
170
+ $reCaptcha = new ReCaptcha($privatekey);
171
+ $remote_addr = $this->getRequest()->getServer('REMOTE_ADDR');
172
+
173
+ $resp = $reCaptcha->verifyResponse(
174
+ $remote_addr,
175
+ $post['g-recaptcha-response']
176
+ );
177
+
178
+ if ($resp->errorCodes == "missing-input") {
179
+ Mage::getSingleton('core/session')->addError('Please check the reCaptcha');
180
+ $this->_redirectReferer();
181
+ return;
182
+ }
183
+
184
+ if ($resp != null && $resp->success) {
185
+ $this->_save();
186
+ $this->_redirectReferer();
187
+ return;
188
+ } else {
189
+ Mage::getSingleton('core/session')->addError('An error has occured because of reCaptcha. Please try again later!');
190
+ Mage::getSingleton('productquestion/session')->setFormData($post);
191
+ $this->_redirectReferer();
192
+ return;
193
+ }
194
+ } else {
195
+ $this->_save();
196
+ $this->_redirectReferer();
197
+ return;
198
+ }
199
+ }
200
+
201
+ public function voteAction() {
202
+ $params = $this->getRequest()->getParams();
203
+ if ($params) {
204
+ $requestModel = Mage::getModel('productquestion/productquestion');
205
+ $request = $requestModel->load($params['requestid']);
206
+ $helper = Mage::helper('productquestion');
207
+
208
+ try {
209
+ if ($params['vote'] == 'voteup') {
210
+ $vote = $request->getCountup() + 1;
211
+ $request->setCountup($vote);
212
+ $request->save();
213
+ } else if ($params['vote'] == 'votedown') {
214
+ $vote = $request->getCountdown() + 1;
215
+ $request->setCountdown($vote);
216
+ $request->save();
217
+ }
218
+ } catch (Exception $e) {
219
+ Mage::log($e->getMessage());
220
+ $this->_redirectReferer();
221
+ return;
222
+ }
223
+
224
+ $requestCookieName = 'request_' . $params['requestid'] . '_' . $request->getProductId();
225
+ $requestCookieValue = 'request_' . $params['requestid'] . '_' . $request->getProductId();
226
+ $period = 31536000;
227
+ Mage::getModel('core/cookie')->set($requestCookieName, $requestCookieValue, $period);
228
+ $this->_redirectReferer();
229
+ return;
230
+ } else {
231
+ $this->_redirectReferer();
232
+ return;
233
+ }
234
+ }
235
+ }
app/code/local/Magebuzz/Productquestion/etc/adminhtml.xml ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <productquestion>
5
+ <title>Product Question</title>
6
+ <sort_order>89</sort_order>
7
+ <children>
8
+ <manage_question module="productquestion">
9
+ <title>Manage Questions</title>
10
+ <sort_order>1</sort_order>
11
+ <action>adminhtml/productquestion</action>
12
+ </manage_question>
13
+ <setting_question module="productquestion">
14
+ <title>Setting</title>
15
+ <sort_order>2</sort_order>
16
+ <action>adminhtml/system_config/edit/section/productquestion</action>
17
+ </setting_question>
18
+ </children>
19
+ </productquestion>
20
+ </menu>
21
+ <acl>
22
+ <resources>
23
+ <all>
24
+ <title>Allow Everything</title>
25
+ </all>
26
+ <admin>
27
+ <children>
28
+ <system>
29
+ <children>
30
+ <config>
31
+ <children>
32
+ <productquestion translate="label" module="productquestion">
33
+ <title>Product Question</title>
34
+ </productquestion>
35
+ </children>
36
+ </config>
37
+ </children>
38
+ </system>
39
+ <productquestion>
40
+ <title>Product Question</title>
41
+ <sort_order>89</sort_order>
42
+ <children>
43
+ <manage_question module="productquestion">
44
+ <title>Manage Questions</title>
45
+ <sort_order>1</sort_order>
46
+ <action>adminhtml/productquestion</action>
47
+ </manage_question>
48
+ <setting_question module="productquestion">
49
+ <title>Setting</title>
50
+ <sort_order>2</sort_order>
51
+ <action>adminhtml/system_config/edit/section/productquestion</action>
52
+ </setting_question>
53
+ </children>
54
+ </productquestion>
55
+ </children>
56
+ </admin>
57
+ </resources>
58
+ </acl>
59
+ </config>
app/code/local/Magebuzz/Productquestion/etc/config.xml ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Magebuzz_Productquestion>
5
+ <version>0.1.6</version>
6
+ </Magebuzz_Productquestion>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <productquestion>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Magebuzz_Productquestion</module>
14
+ <frontName>productquestion</frontName>
15
+ </args>
16
+ </productquestion>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <productquestion>
21
+ <file>productquestion.xml</file>
22
+ </productquestion>
23
+ </updates>
24
+ </layout>
25
+ <translate>
26
+ <modules>
27
+ <Magebuzz_productquestion>
28
+ <files>
29
+ <default>Magebuzz_Productquestion.csv</default>
30
+ </files>
31
+ </Magebuzz_productquestion>
32
+ </modules>
33
+ </translate>
34
+ </frontend>
35
+ <default>
36
+ <productquestion>
37
+ <general>
38
+ <enabled>1</enabled>
39
+ <show_in_product_detail>0</show_in_product_detail>
40
+ <allow_guest_ask_question>1</allow_guest_ask_question>
41
+ <enable_question_captcha>1</enable_question_captcha>
42
+ <enable_email_confirmation>1</enable_email_confirmation>
43
+ <public_key>your_site_key_here</public_key>
44
+ <private_key>your_secret_key_here</private_key>
45
+ </general>
46
+ <email>
47
+ <send_email_to_admin>hello@magebuzz.com</send_email_to_admin>
48
+ <email_admin_template>productquestion_email_email_admin_template</email_admin_template>
49
+ <email_customer_template>productquestion_email_email_customer_template</email_customer_template>
50
+ <email_confirmation>productquestion_email_email_confirmation</email_confirmation>
51
+ </email>
52
+ </productquestion>
53
+ </default>
54
+ <admin>
55
+ <routers>
56
+ <adminhtml>
57
+ <args>
58
+ <modules><Magebuzz_Productquestion after="Mage_Adminhtml">Magebuzz_Productquestion_Adminhtml</Magebuzz_Productquestion></modules>
59
+ </args>
60
+ </adminhtml>
61
+ </routers>
62
+ </admin>
63
+ <adminhtml>
64
+ <translate>
65
+ <modules>
66
+ <Magebuzz_productquestion>
67
+ <files>
68
+ <default>Magebuzz_Productquestion.csv</default>
69
+ </files>
70
+ </Magebuzz_productquestion>
71
+ </modules>
72
+ </translate>
73
+ <layout>
74
+ <updates>
75
+ <productquestion>
76
+ <file>productquestion.xml</file>
77
+ </productquestion>
78
+ </updates>
79
+ </layout>
80
+ </adminhtml>
81
+ <global>
82
+ <models>
83
+ <productquestion>
84
+ <class>Magebuzz_Productquestion_Model</class>
85
+ <resourceModel>productquestion_mysql4</resourceModel>
86
+ </productquestion>
87
+ <productquestion_mysql4>
88
+ <class>Magebuzz_Productquestion_Model_Mysql4</class>
89
+ <entities>
90
+ <productquestion>
91
+ <table>productquestion</table>
92
+ </productquestion>
93
+ <productquestionproduct>
94
+ <table>productquestion_product</table>
95
+ </productquestionproduct>
96
+ <productquestionstore>
97
+ <table>productquestion_store</table>
98
+ </productquestionstore>
99
+ </entities>
100
+ </productquestion_mysql4>
101
+ </models>
102
+ <resources>
103
+ <productquestion_setup>
104
+ <setup>
105
+ <module>Magebuzz_Productquestion</module>
106
+ </setup>
107
+ <connection>
108
+ <use>core_setup</use>
109
+ </connection>
110
+ </productquestion_setup>
111
+ <productquestion_write>
112
+ <connection>
113
+ <use>core_write</use>
114
+ </connection>
115
+ </productquestion_write>
116
+ <productquestion_read>
117
+ <connection>
118
+ <use>core_read</use>
119
+ </connection>
120
+ </productquestion_read>
121
+ </resources>
122
+ <blocks>
123
+ <productquestion>
124
+ <class>Magebuzz_Productquestion_Block</class>
125
+ </productquestion>
126
+ <adminhtml>
127
+ <rewrite>
128
+ <catalog_product_edit_tabs>Magebuzz_Productquestion_Block_Adminhtml_Catalog_Product_Edit_Tabs</catalog_product_edit_tabs>
129
+ </rewrite>
130
+ </adminhtml>
131
+ </blocks>
132
+ <helpers>
133
+ <productquestion>
134
+ <class>Magebuzz_Productquestion_Helper</class>
135
+ </productquestion>
136
+ </helpers>
137
+ <template>
138
+ <email>
139
+ <productquestion_email_email_admin_template translate="label" module="productquestion">
140
+ <label>New Question Notification</label>
141
+ <file>new_question_notification.html</file>
142
+ <type>html</type>
143
+ </productquestion_email_email_admin_template>
144
+ <productquestion_email_email_customer_template translate="label" module="productquestion">
145
+ <label>New Reply Notification</label>
146
+ <file>new_reply_notification.html</file>
147
+ <type>html</type>
148
+ </productquestion_email_email_customer_template>
149
+ <productquestion_email_email_confirmation translate="label" module="productquestion">
150
+ <label>New Question Confirmation</label>
151
+ <file>new_question_confirmation.html</file>
152
+ <type>html</type>
153
+ </productquestion_email_email_confirmation>
154
+ </email>
155
+ </template>
156
+ </global>
157
+ </config>
app/code/local/Magebuzz/Productquestion/etc/system.xml ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <config>
3
+ <tabs>
4
+ <magebuzz translate="label" module="productquestion">
5
+ <label>MAGEBUZZ ADD-ONS</label>
6
+ <sort_order>1000</sort_order>
7
+ </magebuzz>
8
+ </tabs>
9
+ <sections>
10
+ <productquestion translate="label" module="productquestion">
11
+ <label>Product Question</label>
12
+ <tab>magebuzz</tab>
13
+ <sort_order>1</sort_order>
14
+ <show_in_default>1</show_in_default>
15
+ <show_in_website>1</show_in_website>
16
+ <show_in_store>1</show_in_store>
17
+ <groups>
18
+ <general translate="label">
19
+ <label>General</label>
20
+ <frontend_type>text</frontend_type>
21
+ <sort_order>1</sort_order>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>1</show_in_website>
24
+ <show_in_store>1</show_in_store>
25
+ <fields>
26
+ <enabled translate="label comment">
27
+ <label>Enable Product Question</label>
28
+ <frontend_type>select</frontend_type>
29
+ <sort_order>1</sort_order>
30
+ <source_model>adminhtml/system_config_source_yesno</source_model>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>0</show_in_store>
34
+ </enabled>
35
+ <show_in_product_detail translate="label">
36
+ <label>Show Product Question in Product Detail</label>
37
+ <comment>Select 'No' will display Question in a seperate page</comment>
38
+ <frontend_type>select</frontend_type>
39
+ <source_model>adminhtml/system_config_source_yesno</source_model>
40
+ <sort_order>1</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ <depends><enabled>1</enabled></depends>
45
+ </show_in_product_detail>
46
+ <allow_guest_ask_question translate="label">
47
+ <label>Allow guest to ask the question</label>
48
+ <frontend_type>select</frontend_type>
49
+ <source_model>adminhtml/system_config_source_yesno</source_model>
50
+ <sort_order>2</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>1</show_in_website>
53
+ <show_in_store>1</show_in_store>
54
+ <depends><enabled>1</enabled></depends>
55
+ </allow_guest_ask_question>
56
+ <enable_email_confirmation translate="label">
57
+ <label>Enable Email Confirmation</label>
58
+ <frontend_type>select</frontend_type>
59
+ <source_model>adminhtml/system_config_source_yesno</source_model>
60
+ <sort_order>3</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
+ </enable_email_confirmation>
65
+ <enable_question_captcha translate="label">
66
+ <label>Enable captcha</label>
67
+ <frontend_type>select</frontend_type>
68
+ <source_model>adminhtml/system_config_source_yesno</source_model>
69
+ <sort_order>4</sort_order>
70
+ <show_in_default>1</show_in_default>
71
+ <show_in_website>0</show_in_website>
72
+ <show_in_store>0</show_in_store>
73
+ </enable_question_captcha>
74
+ <public_key translate="label">
75
+ <label>Public Key</label>
76
+ <comment>You got this from the signup page: https://www.google.com/recaptcha/admin/create</comment>
77
+ <frontend_type>text</frontend_type>
78
+ <sort_order>20</sort_order>
79
+ <show_in_default>1</show_in_default>
80
+ <show_in_website>0</show_in_website>
81
+ <show_in_store>0</show_in_store>
82
+ </public_key>
83
+ <private_key translate="label">
84
+ <label>Private Key</label>
85
+ <comment>You got this from the signup page: https://www.google.com/recaptcha/admin/create</comment>
86
+ <frontend_type>text</frontend_type>
87
+ <sort_order>30</sort_order>
88
+ <show_in_default>1</show_in_default>
89
+ <show_in_website>1</show_in_website>
90
+ <show_in_store>1</show_in_store>
91
+ </private_key>
92
+ <theme translate="label">
93
+ <label>reCaptcha Theme</label>
94
+ <comment>Customizing the Look of CAPTCHA</comment>
95
+ <frontend_type>select</frontend_type>
96
+ <source_model>productquestion/system_config_source_dropdown_theme</source_model>
97
+ <sort_order>40</sort_order>
98
+ <show_in_default>1</show_in_default>
99
+ <show_in_website>1</show_in_website>
100
+ <show_in_store>1</show_in_store>
101
+ </theme>
102
+ <lang translate="label">
103
+ <label>reCaptcha Language</label>
104
+ <comment>Which language is used in the Captcha interface</comment>
105
+ <frontend_type>select</frontend_type>
106
+ <source_model>productquestion/system_config_source_dropdown_lang</source_model>
107
+ <sort_order>50</sort_order>
108
+ <show_in_default>1</show_in_default>
109
+ <show_in_website>1</show_in_website>
110
+ <show_in_store>1</show_in_store>
111
+ </lang>
112
+ </fields>
113
+ </general>
114
+ <email translate="label">
115
+ <label>Email</label>
116
+ <frontend_type>text</frontend_type>
117
+ <sort_order>2</sort_order>
118
+ <show_in_default>1</show_in_default>
119
+ <show_in_website>1</show_in_website>
120
+ <show_in_store>1</show_in_store>
121
+ <fields>
122
+ <send_email_to_admin translate="label">
123
+ <label>Send emails to:</label>
124
+ <frontend_type>text</frontend_type>
125
+ <sort_order>1</sort_order>
126
+ <show_in_default>1</show_in_default>
127
+ <show_in_website>1</show_in_website>
128
+ <show_in_store>1</show_in_store>
129
+ </send_email_to_admin>
130
+ <email_sender translate="label">
131
+ <label>Email Sender</label>
132
+ <frontend_type>select</frontend_type>
133
+ <source_model>adminhtml/system_config_source_email_identity</source_model>
134
+ <sort_order>2</sort_order>
135
+ <show_in_default>1</show_in_default>
136
+ <show_in_website>1</show_in_website>
137
+ <show_in_store>1</show_in_store>
138
+ </email_sender>
139
+ <email_customer_template translate="label">
140
+ <label>Email template sent to customer</label>
141
+ <frontend_type>select</frontend_type>
142
+ <source_model>adminhtml/system_config_source_email_template</source_model>
143
+ <sort_order>3</sort_order>
144
+ <show_in_default>1</show_in_default>
145
+ <show_in_website>1</show_in_website>
146
+ <show_in_store>1</show_in_store>
147
+ </email_customer_template>
148
+ <email_admin_template translate="label">
149
+ <label>Email template sent to admin</label>
150
+ <frontend_type>select</frontend_type>
151
+ <source_model>adminhtml/system_config_source_email_template</source_model>
152
+ <sort_order>4</sort_order>
153
+ <show_in_default>1</show_in_default>
154
+ <show_in_website>1</show_in_website>
155
+ <show_in_store>1</show_in_store>
156
+ </email_admin_template>
157
+ <email_confirmation translate="label">
158
+ <label>Email confirmation template</label>
159
+ <comment>Sent to customer after posting the question</comment>
160
+ <frontend_type>select</frontend_type>
161
+ <source_model>adminhtml/system_config_source_email_template</source_model>
162
+ <sort_order>5</sort_order>
163
+ <show_in_default>1</show_in_default>
164
+ <show_in_website>1</show_in_website>
165
+ <show_in_store>1</show_in_store>
166
+ </email_confirmation>
167
+ </fields>
168
+ </email>
169
+ </groups>
170
+ </productquestion>
171
+ </sections>
172
+ </config>
app/code/local/Magebuzz/Productquestion/sql/productquestion_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+ $installer = $this;
6
+
7
+ $installer->startSetup();
8
+
9
+ $installer->run("
10
+ CREATE TABLE IF NOT EXISTS {$this->getTable('productquestion')} (
11
+ `productquestion_id` int(11) unsigned NOT NULL auto_increment,
12
+ `question` text NOT NULL default '',
13
+ `author_name` varchar(255) NOT NULL default '',
14
+ `author_email` varchar(255) NOT NULL default '',
15
+ `answer` text NOT NULL default '',
16
+ `countup` INT(11) UNSIGNED NOT NULL default '0',
17
+ `countdown` INT(11) UNSIGNED NOT NULL default '0',
18
+ `replied` smallint(6) NOT NULL default '0',
19
+ `visibility` smallint(6) NOT NULL default '0',
20
+ `date` datetime NULL,
21
+ PRIMARY KEY (`productquestion_id`)
22
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
23
+ ");
24
+
25
+ $installer->endSetup();
app/code/local/Magebuzz/Productquestion/sql/productquestion_setup/mysql4-upgrade-0.1.0-0.1.1.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+ $installer = $this;
6
+
7
+ $installer->startSetup();
8
+
9
+ $installer->run("
10
+ CREATE TABLE IF NOT EXISTS {$this->getTable('productquestion_product')} (
11
+ `id` int(11) unsigned NOT NULL auto_increment,
12
+ `productquestion_id` int(11) NOT NULL ,
13
+ `product_id` int(11) NOT NULL ,
14
+ PRIMARY KEY (`id`)
15
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
16
+
17
+ CREATE TABLE IF NOT EXISTS {$this->getTable('productquestion_store')} (
18
+ `productquestion_id` int(11) NOT NULL ,
19
+ `store_id` int(11) NOT NULL
20
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
21
+ ");
22
+
23
+ $installer->endSetup();
app/code/local/Magebuzz/Productquestion/sql/productquestion_setup/mysql4-upgrade-0.1.3-0.1.4.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+ $installer = $this;
6
+
7
+ $installer->startSetup();
8
+
9
+ $installer->run("
10
+ ALTER TABLE {$this->getTable('productquestion_product')}
11
+ ADD INDEX(`productquestion_id`);
12
+
13
+ ALTER TABLE {$this->getTable('productquestion_product')}
14
+ CHANGE `productquestion_id` `productquestion_id` INT(11) UNSIGNED NOT NULL;
15
+
16
+ ALTER TABLE {$this->getTable('productquestion_product')}
17
+ ADD CONSTRAINT `fk_questionid_productid`
18
+ FOREIGN KEY (`productquestion_id`)
19
+ REFERENCES {$this->getTable('productquestion')}(`productquestion_id`)
20
+ ON DELETE CASCADE;
21
+
22
+ ALTER TABLE {$this->getTable('productquestion_store')}
23
+ ADD PRIMARY KEY(`productquestion_id`),
24
+ CHANGE `productquestion_id` `productquestion_id` INT(11) UNSIGNED NOT NULL;
25
+
26
+ ALTER TABLE {$this->getTable('productquestion_store')}
27
+ ADD CONSTRAINT `fk_questionid_storeid`
28
+ FOREIGN KEY (`productquestion_id`)
29
+ REFERENCES {$this->getTable('productquestion')}(`productquestion_id`)
30
+ ON DELETE CASCADE;
31
+ ");
32
+
33
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/productquestion.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <adminhtml_catalog_product_edit>
4
+ <reference name="head">
5
+ <action method="addCss">
6
+ <stylesheet>magebuzz/productquestion/productquestion.css</stylesheet>
7
+ </action>
8
+ </reference>
9
+ </adminhtml_catalog_product_edit>
10
+ <adminhtml_productquestion_index>
11
+ <reference name="content">
12
+ <block type="productquestion/adminhtml_productquestion" name="productquestion"/>
13
+ </reference>
14
+ </adminhtml_productquestion_index>
15
+ </layout>
app/design/adminhtml/default/default/template/productquestion/catalog/product/edit/question.phtml ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ * @var $this Magebuzz_Productquestion_Block_Adminhtml_Productquestion
5
+ */
6
+ ?>
7
+ <?php $collection = $this->getCollection() ?>
8
+ <?php $questions = $collection->getData() ?>
9
+ <?php $product_name = $this->getProductName() ?>
10
+ <div class="productquestion_tabs_form_section_content" style="">
11
+ <div class="entry-edit">
12
+ <div class="entry-edit-head">
13
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Questions on ') . $product_name ?></h4>
14
+
15
+ <div class="form-buttons"></div>
16
+ </div>
17
+ <div id="group_fields51" class="fieldset fieldset-wide">
18
+ <div class="hor-scroll">
19
+ <table class="form-list" cellspacing="0">
20
+ <tbody>
21
+ <?php if (!empty($questions)): ?>
22
+ <?php foreach ($questions as $question): ?>
23
+ <tr>
24
+ <td>
25
+ <a id="question_<?php echo $question['productquestion_id'] ?>"
26
+ onclick="showanswer('<?php echo $question['productquestion_id'] ?>')"
27
+ href="javascript://"><?php echo $question['question'] ?></a>
28
+
29
+ <div class="answer" id="answer_<?php echo $question['productquestion_id'] ?>" style="display:none;">
30
+ <?php echo $question['answer'] ?>
31
+ <br/>
32
+ <cite class="question-source">
33
+ <span class="question-author"><?php echo 'by' ?>
34
+ &nbsp;<span><? echo $question['author_name'] ?></span></span>
35
+ <span class="question-date">
36
+ <?php echo ' at ' . date('F d, Y H:i:s', Mage::getModel('core/date')->gmtTimestamp($question['date'])) ?>
37
+ </span>
38
+ </cite>
39
+ </div>
40
+ </td>
41
+ </tr>
42
+ <?php endforeach ?>
43
+ <?php else: ?>
44
+ <?php echo $this->__('No questions asked yet') ?>
45
+ <?php endif ?>
46
+ </tbody>
47
+ </table>
48
+ </div>
49
+ </div>
50
+ </div>
51
+ </div>
52
+ <script type="text/javascript">
53
+ function showanswer(question_id) {
54
+ $$('div.answer').each(
55
+ function (e) {
56
+ if (e.id != 'answer_' + question_id) {
57
+ e.hide();
58
+ }
59
+ }
60
+ );
61
+ if ($('answer_' + question_id).getStyle('display') == 'none') {
62
+ $('answer_' + question_id).show();
63
+ }
64
+ else {
65
+ $('answer_' + question_id).hide();
66
+ }
67
+ }
68
+ </script>
app/design/frontend/base/default/layout/productquestion.xml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <catalog_product_view>
4
+ <reference name="head">
5
+ <action method="addCss">
6
+ <stylesheet>magebuzz/productquestion/css/productquestion.css</stylesheet>
7
+ </action>
8
+ </reference>
9
+ <reference name="alert.urls">
10
+ <block type="productquestion/productquestion" name="question-link" template="productquestion/link.phtml"/>
11
+ </reference>
12
+ <reference name="product.info">
13
+ <block type="productquestion/productquestion" name="check-in-page" template="productquestion/checkinpage.phtml">
14
+ <block type="productquestion/productquestion" name="product-question-in-page"
15
+ template="productquestion/questioninpage.phtml">
16
+ <action method="addToParentGroup">
17
+ <group>detailed_info</group>
18
+ </action>
19
+ </block>
20
+ <action method="setTitle" ifconfig="productquestion/general/show_in_product_detail" translate="value">
21
+ <value helper="productquestion/isEnabled">Product Question</value>
22
+ </action>
23
+ <action method="addToParentGroup">
24
+ <group>detailed_info</group>
25
+ </action>
26
+ </block>
27
+ </reference>
28
+ </catalog_product_view>
29
+ <productquestion_index_index>
30
+ <reference name="head">
31
+ <action method="addCss">
32
+ <stylesheet>magebuzz/productquestion/css/productquestion.css</stylesheet>
33
+ </action>
34
+ </reference>
35
+ <reference name="root">
36
+ <action method="setTemplate">
37
+ <template>page/2columns-right.phtml</template>
38
+ </action>
39
+ </reference>
40
+ <reference name="content">
41
+ <block type="productquestion/productquestionoutpage" name="product-question-out-page"
42
+ template="productquestion/questionoutpage.phtml">
43
+ </block>
44
+ </reference>
45
+ </productquestion_index_index>
46
+ </layout>
app/design/frontend/base/default/template/productquestion/checkinpage.phtml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ */
5
+ ?>
6
+
7
+ <?php $_helper = Mage::helper('productquestion') ?>
8
+ <?php $isGuestAllowedToAsk = $this->isGuestAllowedToAsk() ?>
9
+ <?php $isCustomerLoggedIn = $this->isCustomerLoggedIn() ?>
10
+ <?php $isShownInProductDetail = $this->isShownInProductDetail() ?>
11
+
12
+ <?php if ($_helper->isEnabled()): ?>
13
+ <?php if ($isGuestAllowedToAsk && $isShownInProductDetail): ?>
14
+ <?php echo $this->getChildHtml('product-question-in-page') ?>
15
+ <?php endif; ?>
16
+
17
+ <?php if ($isGuestAllowedToAsk && !$isShownInProductDetail): ?>
18
+ <?php $this->getLayout()->unsetBlock('product-question-in-page') ?>
19
+ <?php endif; ?>
20
+
21
+ <?php if (!$isGuestAllowedToAsk && $isShownInProductDetail): ?>
22
+ <?php if ($isCustomerLoggedIn): ?>
23
+ <?php echo $this->getChildHtml('product-question-in-page') ?>
24
+ <?php else: ?>
25
+ <?php $this->getLayout()->unsetBlock('product-question-in-page') ?>
26
+ <?php endif ?>
27
+ <?php endif ?>
28
+
29
+ <?php if (!$isGuestAllowedToAsk && !$isShownInProductDetail): ?>
30
+ <?php if ($isCustomerLoggedIn): ?>
31
+ <?php echo $this->getChildHtml('product-question-in-page') ?>
32
+ <?php else: ?>
33
+ <?php $this->getLayout()->unsetBlock('product-question-in-page') ?>
34
+ <?php endif; ?>
35
+ <?php endif; ?>
36
+ <?php endif; ?>
app/design/frontend/base/default/template/productquestion/link.phtml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ * @var $this Magebuzz_Productquestion_Block_Productquestion
5
+ */
6
+ ?>
7
+ <?php $_product = $this->getProduct()->getData() ?>
8
+ <?php $currentUrl = $this->helper('core/url')->getCurrentUrl() ?>
9
+ <?php $_helper = Mage::helper('productquestion') ?>
10
+ <?php $isGuestAllowedToAsk = $this->isGuestAllowedToAsk() ?>
11
+ <?php $isCustomerLoggedIn = $this->isCustomerLoggedIn() ?>
12
+ <?php $isShownInProductDetail = $this->isShownInProductDetail() ?>
13
+
14
+ <?php if ($_helper->isEnabled()): ?>
15
+ <?php if ($isGuestAllowedToAsk && $isShownInProductDetail): ?>
16
+ <div class="question-link">
17
+ <a href="#question-in-page"><?php echo $this->__('Submit your question') ?></a>
18
+ </div>
19
+ <?php endif; ?>
20
+
21
+ <?php if ($isGuestAllowedToAsk && !$isShownInProductDetail): ?>
22
+ <div class="question-link">
23
+ <a href="<?php echo $this->getProductQuestionUrl() ?>"><?php echo $this->__('Submit your question') ?></a>
24
+ </div>
25
+ <?php endif; ?>
26
+
27
+ <?php if (!$isGuestAllowedToAsk && $isShownInProductDetail): ?>
28
+ <?php if ($isCustomerLoggedIn): ?>
29
+ <div class="question-link">
30
+ <a href="#question-in-page"><?php echo $this->__('Submit your question') ?></a>
31
+ </div>
32
+ <?php else: ?>
33
+ <div class="question-link">
34
+ <a href="<?php echo $this->getUrl().'customer/account/login/' ?>"><?php echo $this->__('Log in to Submit your question') ?></a>
35
+ </div>
36
+ <?php endif ?>
37
+ <?php endif ?>
38
+
39
+ <?php if (!$isGuestAllowedToAsk && !$isShownInProductDetail): ?>
40
+ <?php if ($isCustomerLoggedIn): ?>
41
+ <div class="question-link">
42
+ <a href="<?php echo $this->getProductQuestionUrl() ?>"><?php echo $this->__('Submit your question') ?></a>
43
+ </div>
44
+ <?php else: ?>
45
+ <div class="question-link">
46
+ <a href="<?php echo $this->getUrl().'customer/account/login/' ?>"><?php echo $this->__('Log in to Submit your question') ?></a>
47
+ </div>
48
+ <?php endif; ?>
49
+ <?php endif; ?>
50
+ <?php endif; ?>
app/design/frontend/base/default/template/productquestion/questioninpage.phtml ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ * @var $this Magebuzz_Productquestion_Block_Productquestion
5
+ */
6
+ ?>
7
+ <?php $data = $this->getFormData() ?>
8
+ <?php $_helper = Mage::helper('productquestion') ?>
9
+ <div id="question-in-page">
10
+ <?php $_product = $this->getProduct()->getData() ?>
11
+ <?php $current_url = $this->helper('core/url')->getCurrentUrl() ?>
12
+ <?php $collection = $this->getQuestion() ?>
13
+ <?php $questions = $collection->getData() ?>
14
+ <div class="product-question-list">
15
+ <div class="question-page-title">
16
+ <h2><?php echo $this->__('Questions on ') . $_product['name'] ?></h2>
17
+ </div>
18
+ <div class="pager-question">
19
+ <?php echo $this->getPagerHtml()?>
20
+ </div>
21
+ <div class="question-list">
22
+ <?php if (!empty($questions)): ?>
23
+ <ul>
24
+ <?php foreach ($questions as $question): ?>
25
+ <?php
26
+ $productId = '';
27
+ if (isset($question['product_id'])) {
28
+ $productId = $question['product_id'];
29
+ }
30
+ ?>
31
+ <li>
32
+ <a id="question_<?php echo $question['productquestion_id'] ?>"
33
+ onclick="showanswer('<?php echo $question['productquestion_id'] ?>')"
34
+ href="javascript://"><?php echo $question['question'] ?></a>
35
+
36
+ <div class="answer" id="answer_<?php echo $question['productquestion_id'] ?>" style="display:none">
37
+ <?php echo $question['answer'] ?>
38
+ <br/>
39
+ <cite class="question-source">
40
+ <span class="question-author"><?php echo 'by' ?>&nbsp;<span><?php echo $question['author_name'] ?></span></span>
41
+ <span class="question-date">
42
+ <?php echo ' on ' ?>
43
+ <span><?php echo date('F j, Y', Mage::getModel('core/date')->gmtTimestamp($question['date'])) ?></span>
44
+ </span>
45
+ </cite>
46
+
47
+ <div class="productquestion-vote">
48
+ <div class="productquestion-ratings">
49
+ <div class="rating-box" style="float: left;">
50
+ <div class="rating"
51
+ style="width:<?php echo $_helper->getPercentVote($question['productquestion_id']); ?>%;"></div>
52
+ </div>
53
+ <p><?php echo $_helper->getCountVote($question['productquestion_id']); ?>
54
+ vote(s)</p>
55
+ </div>
56
+ <?php $requestCookieName = 'request_' . $question['productquestion_id'] . '_' . $productId; ?>
57
+ <?php
58
+ if (!$this->getCookie($requestCookieName) || $this->getCookie($requestCookieName) != $requestCookieName):
59
+ ?>
60
+ <div class="productquestion-rating-helpful"
61
+ onclick="actionVote('voteup',<?php echo $question['productquestion_id']; ?>);">helpful</div>
62
+ <div class="productquestion-rating-helpful"
63
+ onclick="actionVote('votedown',<?php echo $question['productquestion_id']; ?>);">not helpful</div>
64
+ <?php endif ?>
65
+ </div>
66
+ </div>
67
+ <div style="clear: both;"></div>
68
+ </li>
69
+ <?php endforeach ?>
70
+ </ul>
71
+ <?php else: ?>
72
+ <?php echo $this->__('No questions asked yet') ?>
73
+ <?php endif ?>
74
+ </div>
75
+ </div>
76
+ <div class="product-question-form">
77
+ <div class="page-form-title">
78
+ <h2><?php echo $this->__('Ask Your Own Question') ?></h2>
79
+ </div>
80
+ <form id="productquestionForm" method="post" action="<?php echo $this->getPostUrl() ?>">
81
+ <div class="fieldset">
82
+ <ul class="form-list">
83
+ <li class="fields">
84
+ <div class="field">
85
+ <label class="required" for="author_name"><em>*</em><?php echo $this->__('Your Name') ?></label>
86
+
87
+ <div class="input-box">
88
+ <input id="author_name" class="input-text required-entry" type="text"
89
+ value="<?php if ($this->isCustomerLoggedIn()): ?><?php echo $this->getCurrentCustomer()->getName() ?><?php else: ?><?php if (isset($data['author_name'])): ?><?php echo $data['author_name'] ?><?php endif ?><?php endif ?>"
90
+ title="<?php echo $this->__('Your Name') ?>" name="author_name">
91
+ </div>
92
+ </div>
93
+ </li>
94
+ <li class="fields">
95
+ <div class="field">
96
+ <label class="required" for="author_email"><em>*</em><?php echo $this->__('Email') ?></label>
97
+
98
+ <div class="input-box">
99
+ <input id="author_email" class="input-text required-entry" type="email"
100
+ value="<?php if ($this->isCustomerLoggedIn()): ?><?php echo $this->getCurrentCustomer()->getEmail() ?><?php else: ?><?php if (isset($data['author_email'])): ?><?php echo $data['author_email'] ?><?php endif ?><?php endif ?>"
101
+ title="<?php echo $this->__('Email') ?>" name="author_email">
102
+ </div>
103
+ </div>
104
+ </li>
105
+ <li class="wide">
106
+ <label class="required" for="question"><em>*</em><?php echo $this->__('Question') ?></label>
107
+
108
+ <div class="input-box">
109
+ <textarea id="question" class="required-entry input-text" rows="3" cols="5"
110
+ title="<?php echo $this->__('Question') ?>"
111
+ name="question"><?php if (isset($data['question'])): ?><?php echo $data['question'] ?><?php endif ?></textarea>
112
+ </div>
113
+ </li>
114
+ <li>
115
+ <div class="field">
116
+ <label for="visibility" ><?php echo $this->__('Visibility')?></label>
117
+ <div class="input-box">
118
+ <select name="visibility" id="visibility" class="input-text">
119
+ <option value="0"><?php echo $this->__('Private')?></option>
120
+ <option value="1"><?php echo $this->__('Public')?></option>
121
+ </select>
122
+ </div>
123
+ </div>
124
+ </li>
125
+ <li class="product_id">
126
+ <input name="product_id" type="hidden" value="<?php echo $_product['entity_id'] ?>">
127
+ </li>
128
+ <li class="current-url">
129
+ <input name="current_url" type="hidden" value="<?php echo $current_url ?>">
130
+ </li>
131
+ </ul>
132
+ </div>
133
+ <?php if ($_helper->isCaptchaEnabled()): ?>
134
+ <script src="https://www.google.com/recaptcha/api.js?hl=<?php echo $_helper->getCaptchaLanguage() ?>" async defer></script>
135
+ <div class="g-recaptcha" data-sitekey="<?php echo $_helper->getPublicKey() ?>" data-theme="<?php echo $_helper->getCaptchaTheme() ?>"></div>
136
+ <?php endif ?>
137
+ <div class="buttons-set">
138
+ <button class="button" title="<?php echo $this->__('Submit') ?>" type="submit">
139
+ <span><span><?php echo $this->__('Submit') ?></span></span>
140
+ </button>
141
+ <button class="button" onclick="resetFields();" title="<?php echo $this->__('Reset') ?>" type="button">
142
+ <span><span><?php echo $this->__('Reset') ?></span></span>
143
+ </button>
144
+ <p class="back-link">
145
+ <a href="<?php echo $this->getUrl($_product['url_path']) ?>">
146
+ <small>&laquo; </small>
147
+ <?php echo $this->__('Back to the product page') ?>
148
+ </a>
149
+ </p>
150
+ </div>
151
+ </form>
152
+ </div>
153
+ </div>
154
+ <script type="text/javascript">
155
+ function showanswer(question_id) {
156
+ $$('div.answer').each(
157
+ function (e) {
158
+ if (e.id != 'answer_' + question_id) {
159
+ e.hide();
160
+ }
161
+ }
162
+ );
163
+
164
+ if ($('answer_' + question_id).getStyle('display') == 'none') {
165
+ $('answer_' + question_id).show();
166
+ }
167
+ else {
168
+ $('answer_' + question_id).hide();
169
+ }
170
+ }
171
+ //<![CDATA[
172
+ var productquestionForm = new VarienForm('productquestionForm', false);
173
+
174
+ function resetFields() {
175
+ Form.reset('productquestionForm');
176
+ }
177
+
178
+ function actionVote(vote, requestId) {
179
+ var ajaxurl = "<?php echo Mage::getBaseUrl() . 'productquestion/index/vote'?>";
180
+ new Ajax.Request(ajaxurl, {
181
+ method: 'post',
182
+ parameters: {requestid: requestId, vote: vote},
183
+ onSuccess: function (forgot_success_give) {
184
+
185
+ if (forgot_success_give.responseText) {
186
+ document.location.reload(true);
187
+ }
188
+ }
189
+ });
190
+ }
191
+
192
+ //]]>
193
+ </script>
app/design/frontend/base/default/template/productquestion/questionoutpage.phtml ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2015 www.magebuzz.com
4
+ * @var $this Magebuzz_Productquestion_Block_Productquestionoutpage
5
+ */
6
+ ?>
7
+ <?php $data = $this->getFormData(TRUE) ?>
8
+ <?php $_helper = Mage::helper('productquestion') ?>
9
+ <div id="question-out-page">
10
+ <?php $_product = $this->getProduct()->getData() ?>
11
+ <?php $current_url = $this->helper('core/url')->getCurrentUrl() ?>
12
+ <?php $collection = $this->getQuestion() ?>
13
+ <?php $questions = $collection->getData() ?>
14
+ <div class="product-question-list">
15
+ <div class="question-page-title">
16
+ <h2><?php echo $this->__('Questions on ') . $_product['name'] ?></h2>
17
+ </div>
18
+ <div class="pager-question">
19
+ <?php echo $this->getPagerHtml()?>
20
+ </div>
21
+ <div class="question-list">
22
+ <?php if (!empty($questions)): ?>
23
+ <ul>
24
+ <?php foreach ($questions as $question): ?>
25
+ <li>
26
+ <a id="question_<?php echo $question['productquestion_id'] ?>"
27
+ onclick="showanswer('<?php echo $question['productquestion_id'] ?>')"
28
+ href="javascript://"><?php echo $question['question'] ?></a>
29
+
30
+ <div class="answer" id="answer_<?php echo $question['productquestion_id'] ?>" style="display:none">
31
+ <?php echo $question['answer'] ?>
32
+ <br/>
33
+ <cite class="question-source">
34
+ <span class="question-author"><?php echo 'by' ?>&nbsp;<span><? echo $question['author_name'] ?></span></span>
35
+ <span class="question-date">
36
+ <?php echo ' on ' ?>
37
+ <span><?php echo date('F j, Y H:i:s', Mage::getModel('core/date')->gmtTimestamp($question['date'])) ?></span>
38
+ </span>
39
+ </cite>
40
+
41
+ <div class="productquestion-vote">
42
+ <div class="productquestion-ratings">
43
+ <div class="rating-box" style="float: left;">
44
+ <div class="rating"
45
+ style="width:<?php echo Mage::helper('productquestion')->getPercentVote($question['productquestion_id']); ?>%;"></div>
46
+ </div>
47
+ <p><?php echo Mage::helper('productquestion')->getCountVote($question['productquestion_id']); ?>
48
+ vote(s)</p>
49
+ </div>
50
+ <?php $requestCookieName = 'request_' . $question['productquestion_id'] . '_' . $question['product_id']; ?>
51
+ <?php
52
+ if (!$this->getCookie($requestCookieName) || $this->getCookie($requestCookieName) != $requestCookieName):
53
+ ?>
54
+ <div class="productquestion-rating-helpful"
55
+ onclick="actionVote('voteup',<?php echo $question['productquestion_id']; ?>);">helpful</div>
56
+ <div class="productquestion-rating-helpful"
57
+ onclick="actionVote('votedown',<?php echo $question['productquestion_id']; ?>);">not helpful</div>
58
+ <?php endif ?>
59
+ </div>
60
+ </div>
61
+ <div style="clear: both;"></div>
62
+ </li>
63
+ <?php endforeach ?>
64
+ </ul>
65
+ <?php else: ?>
66
+ <?php echo $this->__('No questions asked yet') ?>
67
+ <?php endif ?>
68
+ </div>
69
+ </div>
70
+ <div class="product-question-form">
71
+ <div class="page-form-title">
72
+ <h2><?php echo $this->__('Ask Your Own Question') ?></h2>
73
+ </div>
74
+ <form id="productquestionForm" method="post" action="<?php echo $this->getPostUrl() ?>">
75
+ <div class="fieldset">
76
+ <ul class="form-list">
77
+ <li class="fields">
78
+ <div class="field">
79
+ <label class="required" for="author_name"><em>*</em><?php echo $this->__('Your Name') ?></label>
80
+
81
+ <div class="input-box">
82
+ <input id="author_name" class="input-text required-entry" type="text"
83
+ value="<?php if ($this->isCustomerLoggedIn()): ?><?php echo $this->getCurrentCustomer()->getName() ?><?php else: ?><?php if (isset($data['author_name'])): ?><?php echo $data['author_name'] ?><?php endif ?><?php endif ?>"
84
+ title="<?php echo $this->__('Your Name') ?>" name="author_name">
85
+ </div>
86
+ </div>
87
+ </li>
88
+ <li class="fields">
89
+ <div class="field">
90
+ <label class="required" for="author_email"><em>*</em><?php echo $this->__('Email') ?></label>
91
+
92
+ <div class="input-box">
93
+ <input id="author_email" class="input-text required-entry" type="email"
94
+ value="<?php if ($this->isCustomerLoggedIn()): ?><?php echo $this->getCurrentCustomer()->getEmail() ?><?php else: ?><?php if (isset($data['author_email'])): ?><?php echo $data['author_email'] ?><?php endif ?><?php endif ?>"
95
+ title="<?php echo $this->__('Email') ?>" name="author_email">
96
+ </div>
97
+ </div>
98
+ </li>
99
+ <li class="wide">
100
+ <label class="required" for="question"><em>*</em><?php echo $this->__('Question') ?></label>
101
+
102
+ <div class="input-box">
103
+ <textarea id="question" class="required-entry input-text" type="text" rows="3" cols="5"
104
+ title="<?php echo $this->__('Question') ?>"
105
+ name="question"><?php if (isset($data['question'])): ?><?php echo $data['question'] ?><?php endif ?></textarea>
106
+ </div>
107
+ </li>
108
+ <li>
109
+ <div class="field">
110
+ <label for="visibility" ><?php echo Mage::helper('productquestion')->__('Visibility')?></label>
111
+ <div class="input-box">
112
+ <select name="visibility" id="visibility" class="input-text">
113
+ <option value="0"><?php echo Mage::helper('productquestion')->__('Private')?></option>
114
+ <option value="1"><?php echo Mage::helper('productquestion')->__('Public')?></option>
115
+ </select>
116
+ </div>
117
+ </div>
118
+ </li>
119
+ <li class="product_id">
120
+ <input name="product_id" type="hidden" value="<?php echo $_product['entity_id'] ?>">
121
+ </li>
122
+ <li class="current-url">
123
+ <input name="current_url" type="hidden" value="<?php echo $current_url ?>">
124
+ </li>
125
+ </ul>
126
+ </div>
127
+ <?php if ($_helper->isCaptchaEnabled()): ?>
128
+ <script src="https://www.google.com/recaptcha/api.js?hl=<?php echo $_helper->getCaptchaLanguage() ?>" async defer></script>
129
+ <div class="g-recaptcha" data-sitekey="<?php echo $_helper->getPublicKey() ?>" data-theme="<?php echo $_helper->getCaptchaTheme() ?>"></div>
130
+ <?php endif ?>
131
+ <div class="buttons-set">
132
+ <button class="button" title="<?php echo $this->__('Submit') ?>" type="submit">
133
+ <span><span><?php echo $this->__('Submit') ?></span></span>
134
+ </button>
135
+ <button class="button" onclick="resetFields();" title="<?php echo $this->__('Reset') ?>" type="button">
136
+ <span><span><?php echo $this->__('Reset') ?></span></span>
137
+ </button>
138
+ <p class="back-link">
139
+ <a href="<?php echo $this->getUrl($_product['url_path']) ?>">
140
+ <small>&laquo; </small>
141
+ <?php echo $this->__('Back to the product page') ?>
142
+ </a>
143
+ </p>
144
+ </div>
145
+ </form>
146
+ </div>
147
+ </div>
148
+ <script type="text/javascript">
149
+ function showanswer(question_id) {
150
+ $$('div.answer').each(
151
+ function (e) {
152
+ if (e.id != 'answer_' + question_id) {
153
+ e.hide();
154
+ }
155
+ }
156
+ );
157
+
158
+ if ($('answer_' + question_id).getStyle('display') == 'none') {
159
+ $('answer_' + question_id).show();
160
+ }
161
+ else {
162
+ $('answer_' + question_id).hide();
163
+ }
164
+ }
165
+ //<![CDATA[
166
+ var productquestionForm = new VarienForm('productquestionForm', false);
167
+
168
+ function resetFields() {
169
+ Form.reset('productquestionForm');
170
+ }
171
+ function actionVote(vote, requestId) {
172
+ var ajaxurl = "<?php echo Mage::getBaseUrl() . 'productquestion/index/vote'?>";
173
+ new Ajax.Request(ajaxurl, {
174
+ method: 'post',
175
+ parameters: {requestid: requestId, vote: vote},
176
+ onSuccess: function (forgot_success_give) {
177
+
178
+ if (forgot_success_give.responseText) {
179
+ document.location.reload(true);
180
+ }
181
+ }
182
+ });
183
+ }
184
+ //]]>
185
+ </script>
app/etc/modules/Magebuzz_Productquestion.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Magebuzz_Productquestion>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Magebuzz_Productquestion>
8
+ </modules>
9
+ </config>
app/locale/en_US/Magebuzz_Productquestion.csv ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Ask Your Own Question","Ask Your Own Question"
2
+ "Your Name","Your Name"
3
+ "Reset","Reset"
4
+ "Submit","Submit"
5
+ "Back to the product page","Back to the product page"
6
+ "Submit your question","Submit your question"
7
+ "Questions on","Questions on"
8
+ "No questions asked yet","No questions asked yet"
9
+ "'Ask Your Own Question","'Ask Your Own Question"
10
+ "Copy the text in the image above","Copy the text in the image above"
11
+ "Product Questions","Product Questions"
12
+ "Product","Product"
13
+ "Asked on","Asked on"
14
+ "Author Name","Author Name"
15
+ "Author Email","Author Email"
16
+ "Question","Question"
17
+ "Visibility","Visibility"
18
+ "Public","Public"
19
+ "Private","Private"
20
+ "Answer","Answer"
21
+ "Details","Details"
22
+ "Save","Save"
23
+ "Delete","Delete"
24
+ "Save And Continue Edit","Save And Continue Edit"
25
+ "Reply question from","Reply question from"
26
+ "Add Item","Add Item"
27
+ "Date","Date"
28
+ "Replied","Replied"
29
+ "Questions List","Questions List"
30
+ "Product Name","Product Name"
31
+ "Action","Action"
32
+ "Reply","Reply"
33
+ "Are you sure?","Are you sure?"
34
+ "Change visibility status","Change visibility status"
35
+ "Status","Status"
36
+ "Product Questions","Product Questions"
37
+ "Add Item","Add Item"
38
+ "Item Manager","Item Manager"
39
+ "Item News","Item News"
40
+ "Item does not exist","Item does not exist"
41
+ "Question was successfully replied","Question was successfully replied"
42
+ "Question was successfully saved","Question was successfully saved"
43
+ "Unable to find item to reply","Unable to find item to reply"
44
+ "Item was successfully deleted","Item was successfully deleted"
45
+ "Please select item(s)","Please select item(s)"
46
+ "Total of %d record(s) were successfully deleted","Total of %d record(s) were successfully deleted"
47
+ "Please select item(s)","Please select item(s)"
48
+ "Total of %d record(s) were successfully updated","Total of %d record(s) were successfully updated"
49
+ "Your question has been submitted!","Your question has been submitted!"
50
+ "The security code entered was incorrect. Please try again!","The security code entered was incorrect. Please try again!"
51
+ "New Question Notification","New Question Notification"
52
+ "New Reply Notification","New Reply Notification"
53
+ "New Question Confirmation","New Question Confirmation"
54
+ "MAGEBUZZ ADD-ONS","MAGEBUZZ ADD-ONS"
55
+ "General","General"
56
+ "Show Product Question in Product Detail","Show Product Question in Product Detail"
57
+ "Allow guest to ask the question","Allow guest to ask the question"
58
+ "Enable captcha","Enable captcha"
59
+ "Enable Email Confirmation","Enable Email Confirmation"
60
+ "Email","Email"
61
+ "Send emails to:","Send emails to:"
62
+ "Email Sender","Email Sender"
63
+ "Email template sent to customer","Email template sent to customer"
64
+ "Email template sent to admin","Email template sent to admin"
65
+ "Email confirmation template","Email confirmation template"
66
+ "Public","Public"
67
+ "Private","Private"
app/locale/en_US/template/email/productquestion/new_question_confirmation.html ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject New Question Confirmation@-->
2
+
3
+ <p>Thanks for your question. We will respond to you soon. Following is the information:</p>
4
+ <p>
5
+ Customer Name: {{var data.author_name}} <br/>
6
+ E-mail: {{var data.author_email}} <br/>
7
+ Product: {{var product_name}} <br/>
8
+ Question: {{var data.question}} <br/>
9
+ Product Url: {{var product_url}}<br/>
10
+ </p>
app/locale/en_US/template/email/productquestion/new_question_notification.html ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject Product Question Form@-->
2
+
3
+ <p>A customer just sent you question about a product. Following is the information.</p>
4
+ <p>
5
+ Customer Name: {{var data.author_name}} <br/>
6
+ E-mail: {{var data.author_email}} <br/>
7
+ Product: {{var product_name}} <br/>
8
+ Question: {{var data.question}} <br/>
9
+ Product Url: {{var product_url}}<br/>
10
+ </p>
app/locale/en_US/template/email/productquestion/new_reply_notification.html ADDED
@@ -0,0 +1 @@
 
0
  Product: {{var product_name}} <br/>
1
  Question: {{var data.question}} <br/>
2
  Answer: {{var data.answer}}<br/>
3
  You can visit our product for more information:<br/>
4
  {{var product_url}}<br/>
1
+ <!--@subject New Answer for Product Question@-->
2
  Product: {{var product_name}} <br/>
3
  Question: {{var data.question}} <br/>
4
  Answer: {{var data.answer}}<br/>
5
  You can visit our product for more information:<br/>
6
  {{var product_url}}<br/>
lib/reCaptcha/recaptchalib.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This is a PHP library that handles calling reCAPTCHA.
4
+ * - Documentation and latest version
5
+ * https://developers.google.com/recaptcha/docs/php
6
+ * - Get a reCAPTCHA API Key
7
+ * https://www.google.com/recaptcha/admin/create
8
+ * - Discussion group
9
+ * http://groups.google.com/group/recaptcha
10
+ *
11
+ * @copyright Copyright (c) 2014, Google Inc.
12
+ * @link http://www.google.com/recaptcha
13
+ *
14
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ * of this software and associated documentation files (the "Software"), to deal
16
+ * in the Software without restriction, including without limitation the rights
17
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ * copies of the Software, and to permit persons to whom the Software is
19
+ * furnished to do so, subject to the following conditions:
20
+ *
21
+ * The above copyright notice and this permission notice shall be included in
22
+ * all copies or substantial portions of the Software.
23
+ *
24
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30
+ * THE SOFTWARE.
31
+ */
32
+
33
+ /**
34
+ * A ReCaptchaResponse is returned from checkAnswer().
35
+ */
36
+ class ReCaptchaResponse
37
+ {
38
+ public $success;
39
+ public $errorCodes;
40
+ }
41
+
42
+ class ReCaptcha
43
+ {
44
+ private static $_signupUrl = "https://www.google.com/recaptcha/admin";
45
+ private static $_siteVerifyUrl =
46
+ "https://www.google.com/recaptcha/api/siteverify?";
47
+ private $_secret;
48
+ private static $_version = "php_1.0";
49
+
50
+ /**
51
+ * Constructor.
52
+ *
53
+ * @param string $secret shared secret between site and ReCAPTCHA server.
54
+ */
55
+ function ReCaptcha($secret)
56
+ {
57
+ if ($secret == null || $secret == "") {
58
+ die("To use reCAPTCHA you must get an API key from <a href='"
59
+ . self::$_signupUrl . "'>" . self::$_signupUrl . "</a>");
60
+ }
61
+ $this->_secret=$secret;
62
+ }
63
+
64
+ /**
65
+ * Encodes the given data into a query string format.
66
+ *
67
+ * @param array $data array of string elements to be encoded.
68
+ *
69
+ * @return string - encoded request.
70
+ */
71
+ private function _encodeQS($data)
72
+ {
73
+ $req = "";
74
+ foreach ($data as $key => $value) {
75
+ $req .= $key . '=' . urlencode(stripslashes($value)) . '&';
76
+ }
77
+
78
+ // Cut the last '&'
79
+ $req=substr($req, 0, strlen($req)-1);
80
+ return $req;
81
+ }
82
+
83
+ /**
84
+ * Submits an HTTP GET to a reCAPTCHA server.
85
+ *
86
+ * @param string $path url path to recaptcha server.
87
+ * @param array $data array of parameters to be sent.
88
+ *
89
+ * @return array response
90
+ */
91
+ private function _submitHTTPGet($path, $data)
92
+ {
93
+ $req = $this->_encodeQS($data);
94
+ $response = file_get_contents($path . $req);
95
+ return $response;
96
+ }
97
+
98
+ /**
99
+ * Calls the reCAPTCHA siteverify API to verify whether the user passes
100
+ * CAPTCHA test.
101
+ *
102
+ * @param string $remoteIp IP address of end user.
103
+ * @param string $response response string from recaptcha verification.
104
+ *
105
+ * @return ReCaptchaResponse
106
+ */
107
+ public function verifyResponse($remoteIp, $response)
108
+ {
109
+ // Discard empty solution submissions
110
+ if ($response == null || strlen($response) == 0) {
111
+ $recaptchaResponse = new ReCaptchaResponse();
112
+ $recaptchaResponse->success = false;
113
+ $recaptchaResponse->errorCodes = 'missing-input';
114
+ return $recaptchaResponse;
115
+ }
116
+
117
+ $getResponse = $this->_submitHttpGet(
118
+ self::$_siteVerifyUrl,
119
+ array (
120
+ 'secret' => $this->_secret,
121
+ 'remoteip' => $remoteIp,
122
+ 'v' => self::$_version,
123
+ 'response' => $response
124
+ )
125
+ );
126
+ $answers = json_decode($getResponse, true);
127
+ $recaptchaResponse = new ReCaptchaResponse();
128
+
129
+ if (trim($answers ['success']) == true) {
130
+ $recaptchaResponse->success = true;
131
+ } else {
132
+ $recaptchaResponse->success = false;
133
+ $recaptchaResponse->errorCodes = $answers [error-codes];
134
+ }
135
+
136
+ return $recaptchaResponse;
137
+ }
138
+ }
139
+
140
+ ?>
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>magebuzz-product-question</name>
4
+ <version>0.1.6</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Magento Product Questions</summary>
10
+ <description>Allows customers to create questions for products. Show questions and answers on product page. &#xD;
11
+ </description>
12
+ <notes>- Update SUPEE-6788&#xD;
13
+ - Convert to free extension</notes>
14
+ <authors><author><name>Magebuzz</name><user>magebuzz</user><email>magebuzz@gmail.com</email></author></authors>
15
+ <date>2016-02-05</date>
16
+ <time>08:15:48</time>
17
+ <contents><target name="magelocal"><dir name="Magebuzz"><dir name="Productquestion"><dir name="Block"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><dir name="Edit"><dir name="Tab"><file name="Question.php" hash="0b0de73c9432cc9cdd7829bb5177c235"/></dir><file name="Tabs.php" hash="ff3781ea6a01b6abcd3c0d551b77f999"/></dir></dir></dir><dir name="Productquestion"><dir name="Edit"><file name="Form.php" hash="c8d2491537d7bd1d526cdcd1f970a2f9"/><dir name="Tab"><file name="Form.php" hash="277878ed83a4d4784b99e4674774360e"/><file name="Product.php" hash="07b2ba51fd460d61800d373158d43b2e"/></dir><file name="Tabs.php" hash="94a5c4bfb375f095ac65e561b2b988ec"/></dir><file name="Edit.php" hash="8aabceedd90cfdba2e736e2ba5391de4"/><file name="Grid.php" hash="6265b72442ca489616f09cafc3994e58"/></dir><file name="Productquestion.php" hash="973919f650f532d5932e85a58521840a"/><dir name="Renderer"><file name="Productname.php" hash="811efea8f783d69a99e35d37936e808a"/></dir></dir><file name="Captcha.php" hash="0a4ae49916d9da5cf76f5d5ab79313eb"/><file name="Productquestion.php" hash="58b8906ac67f0462e8c403a6ec02e07f"/><file name="Productquestionoutpage.php" hash="66757d5004e45c573e5014e1994cbf28"/></dir><dir name="Helper"><file name="Data.php" hash="932c7d8c22400244e8cfad5affb1d524"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Productquestion"><file name="Collection.php" hash="a618e87318a28d78ca2375b4a7845f19"/></dir><file name="Productquestion.php" hash="63bf0581417e3d3c5ead1106abfd0b85"/><dir name="Productquestionproduct"><file name="Collection.php" hash="5354315e6144847ff54191db842d80e2"/></dir><file name="Productquestionproduct.php" hash="85281d33154a957792c09b06d6fbc1a2"/><dir name="Productquestionstore"><file name="Collection.php" hash="2a518d0a26c97548d22904394c1d745f"/></dir><file name="Productquestionstore.php" hash="f1a6f692963365f7e2b711dc1249ac70"/></dir><file name="Productquestion.php" hash="b81263c07706d45a468a3349da27c1aa"/><file name="Productquestionproduct.php" hash="db10b01435767f4e67871bc2a5b3911a"/><file name="Productquestionstore.php" hash="7050176bc73722d2d4936106b94d65bf"/><file name="Session.php" hash="908da8a0d55f20f69179e4fae0a127db"/><file name="Status.php" hash="9eaa2e8b3d98dae075f55b330486b5db"/><dir name="System"><dir name="Config"><dir name="Source"><dir name="Dropdown"><file name="Lang.php" hash="46e2e1620aefa3b80b18d54ffe18d011"/><file name="Theme.php" hash="2214050d293c9c064f4405fc0a195e82"/></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ProductquestionController.php" hash="7afef607e2c24890b0491c283f5c32e5"/></dir><file name="IndexController.php" hash="41d800d7afb01df3f0c8e279de099730"/></dir><dir name="etc"><file name="adminhtml.xml" hash="f68d2e28ffc5271bd10b1a28b15aa6fd"/><file name="config.xml" hash="359e290e4c4d0d08f5c830cb082c029c"/><file name="system.xml" hash="32ea3232f182ba75b9145960dfb2dbd7"/></dir><dir name="sql"><dir name="productquestion_setup"><file name="mysql4-install-0.1.0.php" hash="1e6f7327291ec22b63d3b1cae07926cb"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="c24587db8a5611be57be31cfa08544ad"/><file name="mysql4-upgrade-0.1.3-0.1.4.php" hash="d2186c6f7f72d8d5a11c8efb42d375dc"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="productquestion.xml" hash="d1d6864fe26dffaa9be13eeebf2b65ed"/></dir><dir name="template"><dir name="productquestion"><file name="checkinpage.phtml" hash="d7c57e504e3edb6ed4bcc55658c81168"/><file name="link.phtml" hash="3fe0aa4973745cca780274d1c3269d94"/><file name="questioninpage.phtml" hash="612fccb860c9a4210258fb02f457381f"/><file name="questionoutpage.phtml" hash="45c936115f32699415b12e70d3c1fd79"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="productquestion.xml" hash="8207c95dbc759b87af7bcaf43dc4b2eb"/></dir><dir name="template"><dir name="productquestion"><dir name="catalog"><dir name="product"><dir name="edit"><file name="question.phtml" hash="46afbe43d770e2a0f30b16a17e80b19c"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Magebuzz_Productquestion.csv" hash="ebc7b55a5079075f516fca60c9a53036"/><dir name="template"><dir name="email"><dir name="productquestion"><file name="new_question_confirmation.html" hash="23f8bb1ede7841a619e423c667ff6787"/><file name="new_question_notification.html" hash="3f700a50d89be720c4bda8a51ed36c33"/><file name="new_reply_notification.html" hash="3bd7347e92e6d56f28ea6053c9a0f5a8"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magebuzz_Productquestion.xml" hash="69a0a704f484f30f6f5bea2d72f23ca6"/></dir></target><target name="magelib"><dir name="reCaptcha"><file name="recaptchalib.php" hash="4e3f9cad8c639f0923b0ef54f32145fa"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="magebuzz"><dir name="productquestion"><dir name="css"><file name="productquestion.css" hash="1819ac736723f795e5459e74026ce9b5"/></dir><dir name="images"><file name="Thumbs.db" hash="d09c2ae475dc318756a2925efd03ee0f"/><file name="bkg_block-layered-dt.gif" hash="ba8229068657b80f2c42111c5a1a307e"/><file name="bkg_block-layered-label.gif" hash="14687dfa3921cfd12d2149c1497d9765"/><file name="bullet.png" hash="b84409666190ec9e5d7016a0dca3aa35"/><file name="refresh.png" hash="1f7a435f2a3a0a1be324239536e270d8"/><file name="votedown.png" hash="b6cb67a98f9711484068f0d280d86934"/><file name="voteup.png" hash="db2cad28b0893f530b3d328eacc6d052"/></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="magebuzz"><dir name="productquestion"><dir name="images"><file name="Thumbs.db" hash="d09c2ae475dc318756a2925efd03ee0f"/><file name="bkg_block-layered-dt.gif" hash="ba8229068657b80f2c42111c5a1a307e"/><file name="bkg_block-layered-label.gif" hash="14687dfa3921cfd12d2149c1497d9765"/><file name="bullet.png" hash="b84409666190ec9e5d7016a0dca3aa35"/><file name="refresh.png" hash="1f7a435f2a3a0a1be324239536e270d8"/></dir><file name="productquestion.css" hash="ad7b7169349d1b135921e58f7a6ee0db"/></dir></dir></dir></dir></dir></target></contents>
18
+ <compatible/>
19
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
20
+ </package>
skin/adminhtml/default/default/magebuzz/productquestion/images/Thumbs.db ADDED
Binary file
skin/adminhtml/default/default/magebuzz/productquestion/images/bkg_block-layered-dt.gif ADDED
Binary file
skin/adminhtml/default/default/magebuzz/productquestion/images/bkg_block-layered-label.gif ADDED
Binary file
skin/adminhtml/default/default/magebuzz/productquestion/images/bullet.png ADDED
Binary file
skin/adminhtml/default/default/magebuzz/productquestion/images/refresh.png ADDED
Binary file
skin/adminhtml/default/default/magebuzz/productquestion/productquestion.css ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .form-list a {
2
+ background: url("../../magebuzz/productquestion/images/bkg_block-layered-label.gif") no-repeat scroll left center transparent;
3
+ color: #363636;
4
+ font-size: 13px;
5
+ font-weight: normal;
6
+ padding-left: 20px;
7
+ text-decoration: none;
8
+ margin-left: 15px;
9
+ }
10
+
11
+ .form-list .answer {
12
+ padding: 5px 0 5px 45px;
13
+ color: #2F2F2F;
14
+ }
15
+
16
+ .form-list .answer .question-source .question-author span {
17
+ font-weight: bold;
18
+ text-transform: capitalize;
19
+ }
20
+
21
+ .form-list .answer .question-source .question-date {
22
+ text-transform: lowercase;
23
+ }
skin/frontend/base/default/magebuzz/productquestion/css/productquestion.css ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* @copyright Copyright (c) 2015 www.magebuzz.com */
2
+
3
+ #question-out-page {
4
+ background: url("../images/bkg_product_collateral.gif") repeat-x scroll 0 0 #FAF7EE;
5
+ border: 1px solid #C4C6C8;
6
+ list-style-type: none;
7
+ margin: 0;
8
+ padding: 25px;
9
+ text-align: left;
10
+ }
11
+
12
+ .product-question-list .question-page-title h2 {
13
+ border-bottom: 1px solid #E5DCC3;
14
+ color: #E26703;
15
+ font-size: 15px;
16
+ font-weight: bold;
17
+ margin: 0 0 15px;
18
+ padding: 0 0 1px;
19
+ }
20
+
21
+ .product-question-list .pager-question {
22
+ margin-bottom: 15px;
23
+ }
24
+
25
+ .product-question-list .question-list ul li {
26
+ color: #737373;
27
+ font-size: 12px;
28
+ text-decoration: none;
29
+ /*text-transform:capitalize;*/
30
+ font-weight: normal;
31
+ line-height: 20px;
32
+ padding-bottom: 5px;
33
+ margin-bottom: 10px;
34
+ width: 90%;
35
+ }
36
+
37
+ .product-question-list .question-list ul li a {
38
+ background: url("../images/bkg_block-layered-label.gif") no-repeat scroll left center transparent;
39
+ color: #363636;
40
+ font-size: 13px;
41
+ font-weight: normal;
42
+ padding-left: 20px;
43
+ text-decoration: none;
44
+ margin-left: 15px;
45
+ }
46
+
47
+ .product-question-list .question-list ul li .answer {
48
+ padding: 5px 0 5px 45px;
49
+ color: #2F2F2F;
50
+ }
51
+
52
+ .product-question-list .question-list ul li .answer .question-source {
53
+ font-style: italic;
54
+ font-size: 11px;
55
+ }
56
+
57
+ .product-question-list .question-list ul li .answer .question-source .question-author span {
58
+ font-weight: bold;
59
+ text-transform: capitalize;
60
+ }
61
+
62
+ .product-question-list .question-list ul li .answer .question-source .question-date {
63
+ text-transform: lowercase;
64
+ }
65
+
66
+ .product-question-list .question-list ul li .answer .question-source .question-date span {
67
+ text-transform: capitalize;
68
+ }
69
+
70
+ .product-question-form .page-form-title h2 {
71
+ color: #E26703;
72
+ font-size: 15px;
73
+ font-weight: bold;
74
+ margin: 0 0 15px;
75
+ padding: 0 0 1px;
76
+ margin-top: 15px;
77
+ border-bottom: 1px solid #E5DCC3;
78
+ }
79
+
80
+ .productquestion-rating-helpful {
81
+ background-attachment: scroll;
82
+ background-color: transparent;
83
+ background-image: url("../images/voteup.png");
84
+ background-position: 0 1px;
85
+ background-repeat: no-repeat no-repeat;
86
+ cursor: pointer;
87
+ float: left;
88
+ padding: 7px 0 0 25px;
89
+ width: 15%;
90
+ }
91
+
92
+ .productquestion-rating-nothelpful {
93
+ background-attachment: scroll;
94
+ background-color: transparent;
95
+ background-image: url("../images/votedown.png");
96
+ background-position: 0 1px;
97
+ background-repeat: no-repeat no-repeat;
98
+ cursor: pointer;
99
+ float: left;
100
+ padding: 7px 0 0 25px;
101
+ width: 15%;
102
+ }
103
+
104
+ .productquestion-vote {
105
+ width: 100%;
106
+ float: left;
107
+ }
108
+
109
+ .productquestion-ratings {
110
+ float: left;
111
+ width: 30%;
112
+ font-size: 11px;
113
+ line-height: 1.25;
114
+ margin: 7px 0;
115
+ }
skin/frontend/base/default/magebuzz/productquestion/images/Thumbs.db ADDED
Binary file
skin/frontend/base/default/magebuzz/productquestion/images/bkg_block-layered-dt.gif ADDED
Binary file
skin/frontend/base/default/magebuzz/productquestion/images/bkg_block-layered-label.gif ADDED
Binary file
skin/frontend/base/default/magebuzz/productquestion/images/bullet.png ADDED
Binary file
skin/frontend/base/default/magebuzz/productquestion/images/refresh.png ADDED
Binary file
skin/frontend/base/default/magebuzz/productquestion/images/votedown.png ADDED
Binary file
skin/frontend/base/default/magebuzz/productquestion/images/voteup.png ADDED
Binary file