Abcnet_CommentBox - Version 1.0.1

Version Notes

Tested on 1.4.1.1 and 1.5.0.1
Please let me know if it works in other versions as well

Download this release

Release Info

Developer Magento Core Team
Extension Abcnet_CommentBox
Version 1.0.1
Comparing to
See all releases


Version 1.0.1

app/code/community/Abcnet/CommentBox/Block/Adminhtml/List.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Abcnet_CommentBox
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Abcnet
12
+ * @package Abcnet_CommentBox
13
+ * @copyright Copyright (c) 2011 Mogos Radu, radu.mogos@pixelplant.ro, radu.mogos@abcnet.ch
14
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
+ */
16
+
17
+ class Abcnet_CommentBox_Block_Adminhtml_List extends Mage_Adminhtml_Block_Widget_Grid_Container
18
+ {
19
+ public function __construct()
20
+ {
21
+ $this->_controller = 'adminhtml_list';
22
+ $this->_blockGroup = 'commentbox';
23
+ //$this->_addBackButton();
24
+ $this->_headerText = Mage::helper('commentbox')->__('Manage messages available for the order comment box');
25
+ parent::__construct();
26
+ }
27
+ }
app/code/community/Abcnet/CommentBox/Block/Adminhtml/List/Edit.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Abcnet_CommentBox
5
+ * www.abcnet.ch | www.pixelplant.ro
6
+ *
7
+ * NOTICE OF LICENSE
8
+ *
9
+ * This source file is subject to the Open Software License (OSL 3.0)
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @category Abcnet
13
+ * @package Abcnet_CommentBox
14
+ * @copyright Copyright (c) 2011 Mogos Radu, radu.mogos@pixelplant.ro, radu.mogos@abcnet.ch
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ class Abcnet_CommentBox_Block_Adminhtml_List_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
19
+ {
20
+ protected function _prepareLayout()
21
+ {
22
+ parent::_prepareLayout();
23
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
24
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
25
+ }
26
+ }
27
+
28
+ public function __construct()
29
+ {
30
+ parent::__construct();
31
+
32
+ $this->_objectId = 'id';
33
+ $this->_blockGroup = 'commentbox';
34
+ $this->_controller = 'adminhtml_list';
35
+
36
+ $comment = Mage::registry('comment_data');
37
+ $id = $comment->getId();
38
+
39
+ /*$this->_addButton('save', array(
40
+ 'label' => Mage::helper('adminhtml')->__('Save'),
41
+ 'onclick' => "editForm.submit(\$('edit_form').action+'back/edit/')",
42
+ 'class' => 'save',
43
+ ), -100);*/
44
+ }
45
+
46
+ public function getHeaderText()
47
+ {
48
+ $comment = Mage::registry('comment_data');
49
+
50
+ if ($comment->getId() > 0)
51
+ return $this->__("Edit comment message '%s'", $comment->title);
52
+ return $this->__("New comment message");
53
+ }
54
+ }
app/code/community/Abcnet/CommentBox/Block/Adminhtml/List/Edit/Form.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Abcnet_CommentBox
5
+ * www.abcnet.ch | www.pixelplant.ro
6
+ *
7
+ * NOTICE OF LICENSE
8
+ *
9
+ * This source file is subject to the Open Software License (OSL 3.0)
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @category Abcnet
13
+ * @package Abcnet_CommentBox
14
+ * @copyright Copyright (c) 2011 Mogos Radu, radu.mogos@pixelplant.ro, radu.mogos@abcnet.ch
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ class Abcnet_CommentBox_Block_Adminhtml_List_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
19
+ {
20
+ protected function _prepareForm()
21
+ {
22
+ $form = new Varien_Data_Form(array(
23
+ 'id' => 'edit_form',
24
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
25
+ 'method' => 'post',
26
+ 'enctype' => 'multipart/form-data'
27
+ ));
28
+
29
+ $form->setUseContainer(true);
30
+ $this->setForm($form);
31
+ $hlp = Mage::helper('commentbox');
32
+
33
+ // add the fields
34
+ $model = Mage::registry('comment_data');
35
+
36
+ $fldInfo = $form->addFieldset('comment_info', array('legend'=> $hlp->__('Comment message')));
37
+ if ($model->getId())
38
+ {
39
+ $fldInfo->addField('comment_id', 'hidden', array(
40
+ 'name' => 'comment_id',
41
+ ));
42
+ }
43
+ // title box
44
+ $fldInfo->addField('title', 'text', array(
45
+ 'label' => $hlp->__('Title'),
46
+ 'class' => 'required-entry',
47
+ 'required' => true,
48
+ 'name' => 'title',
49
+ ));
50
+ // message box
51
+ $fldInfo->addField('message', 'editor', array(
52
+ 'label' => $hlp->__('Message'),
53
+ 'class' => 'required-entry',
54
+ 'required' => true,
55
+ 'wysiwyg' => true,
56
+ 'style' => 'width: 600px; height: 12em',
57
+ 'name' => 'message',
58
+ ));
59
+
60
+ //set form values
61
+ $data = Mage::getSingleton('adminhtml/session')->getFormData();
62
+ if ($data) {
63
+ $form->setValues($data);
64
+ Mage::getSingleton('adminhtml/session')->setFormData(null);
65
+ }
66
+ elseif ($model) {
67
+ $form->setValues($model->getData());
68
+ }
69
+
70
+ return parent::_prepareForm();
71
+ }
72
+ }
app/code/community/Abcnet/CommentBox/Block/Adminhtml/List/Grid.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Abcnet_CommentBox
5
+ * www.abcnet.ch | www.pixelplant.ro
6
+ *
7
+ * NOTICE OF LICENSE
8
+ *
9
+ * This source file is subject to the Open Software License (OSL 3.0)
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @category Abcnet
13
+ * @package Abcnet_CommentBox
14
+ * @copyright Copyright (c) 2011 Mogos Radu, radu.mogos@pixelplant.ro, radu.mogos@abcnet.ch
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ class Abcnet_CommentBox_Block_Adminhtml_List_Grid extends Mage_Adminhtml_Block_Widget_Grid
19
+ {
20
+ public function __construct()
21
+ {
22
+ parent::__construct();
23
+ $this->setId('commentboxListGrid');
24
+ $this->setDefaultSort('sku');
25
+ $this->setDefaultDir('ASC');
26
+ $this->setSaveParametersInProfile(true);
27
+ }
28
+
29
+ protected function _prepareCollection()
30
+ {
31
+ $collection = Mage::getModel('commentbox/comment')->getCollection();
32
+ $this->setCollection($collection);
33
+ parent::_prepareCollection();
34
+ return $this;
35
+ }
36
+
37
+ protected function _prepareColumns()
38
+ {
39
+ $this->addColumn('comment_id', array(
40
+ 'header' => $this->__('ID'),
41
+ 'align' => 'left',
42
+ 'width' => '50px',
43
+ 'index' => 'comment_id',
44
+ 'type' => 'number',
45
+ ));
46
+
47
+ $this->addColumn('title', array(
48
+ 'header' => $this->__('Name'),
49
+ 'align' => 'left',
50
+ 'width' => '200px',
51
+ 'index' => 'title',
52
+ ));
53
+
54
+ $this->addColumn('message', array(
55
+ 'header' => $this->__('Message'),
56
+ 'align' => 'left',
57
+ //'width' => '300px',
58
+ 'index' => 'message',
59
+ ));
60
+
61
+ $this->addColumn('date', array(
62
+ 'header' => $this->__('Created'),
63
+ 'align' => 'left',
64
+ 'width' => '100px',
65
+ 'type' => 'datetime',
66
+ 'index' => 'date',
67
+ ));
68
+
69
+ /*$this->addColumn('type', array(
70
+ 'header' => $this->__('Script type'),
71
+ 'align' => 'left',
72
+ 'index' => 'type',
73
+ 'type' => 'options',
74
+ 'options' => array(
75
+ 'import' => $this->__('Import'),
76
+ 'export' => $this->__('Export'),
77
+ ),
78
+ ));*/
79
+ //$this->addExportType('*/*/exportCsv', Mage::helper('urapidflow')->__('CSV'));
80
+ //$this->addExportType('*/*/exportXml', Mage::helper('urapidflow')->__('XML'));
81
+
82
+ return parent::_prepareColumns();
83
+ }
84
+
85
+ protected function _prepareMassaction()
86
+ {
87
+ $this->setMassactionIdField('comment_id');
88
+ $this->getMassactionBlock()->setFormFieldName('comments');
89
+ $this->getMassactionBlock()->addItem('delete', array(
90
+ 'label' => $this->__('Delete'),
91
+ 'url' => $this->getUrl('*/*/massDelete'),
92
+ 'confirm' => $this->__('Are you sure you want to delete this item?')
93
+ ));
94
+ return $this;
95
+ }
96
+
97
+
98
+ public function getRowUrl($row)
99
+ {
100
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
101
+ }
102
+ }
app/code/community/Abcnet/CommentBox/Block/Adminhtml/Sales/Order/View/History.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Abcnet_CommentBox
5
+ * www.abcnet.ch | www.pixelplant.ro
6
+ *
7
+ * NOTICE OF LICENSE
8
+ *
9
+ * This source file is subject to the Open Software License (OSL 3.0)
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @category Abcnet
13
+ * @package Abcnet_CommentBox
14
+ * @copyright Copyright (c) 2011 Mogos Radu, radu.mogos@pixelplant.ro, radu.mogos@abcnet.ch
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ class Abcnet_CommentBox_Block_Adminhtml_Sales_Order_View_History extends Mage_Adminhtml_Block_Sales_Order_View_History
19
+ {
20
+ protected function _prepareLayout()
21
+ {
22
+ $this->setTemplate('commentbox/history.phtml');
23
+ return parent::_prepareLayout();
24
+ }
25
+
26
+ public function getCommentMessages()
27
+ {
28
+ return Mage::getModel('commentbox/comment')->getCollection();
29
+ }
30
+
31
+ // overwrite the default template so we use our custom template for the comments selector
32
+ public function setTemplate($template)
33
+ {
34
+ $this->_template = 'abcnet/history.phtml';
35
+ return $this;
36
+ }
37
+
38
+ }
app/code/community/Abcnet/CommentBox/Helper/Data.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Abcnet_CommentBox
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Abcnet
12
+ * @package Abcnet_CommentBox
13
+ * @copyright Copyright (c) 2011 Mogos Radu, radu.mogos@pixelplant.ro, radu.mogos@abcnet.ch
14
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
+ */
16
+
17
+ class Abcnet_CommentBox_Helper_Data extends Mage_Core_Helper_Data
18
+ {
19
+ }
app/code/community/Abcnet/CommentBox/Model/Comment.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Abcnet_CommentBox
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Abcnet
11
+ * @package Abcnet_CommentBox
12
+ * @copyright Copyright (c) 2011 Mogos Radu, radu.mogos@pixelplant.ro, radu.mogos@abcnet.ch
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+ class Abcnet_CommentBox_Model_Comment extends Mage_Core_Model_Abstract
17
+ {
18
+ protected $_resourceModel;
19
+
20
+ protected function _construct()
21
+ {
22
+ $this->_init('commentbox/comment');
23
+ }
24
+ }
app/code/community/Abcnet/CommentBox/Model/Mysql4/Comment.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Abcnet_CommentBox
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Abcnet
12
+ * @package Abcnet_CommentBox
13
+ * @copyright Copyright (c) 2011 Mogos Radu, radu.mogos@pixelplant.ro, radu.mogos@abcnet.ch
14
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
+ */
16
+
17
+ class Abcnet_CommentBox_Model_Mysql4_Comment extends Mage_Core_Model_Mysql4_Abstract
18
+ {
19
+ protected function _construct()
20
+ {
21
+ $this->_init('commentbox/comment', 'comment_id');
22
+ }
23
+ }
app/code/community/Abcnet/CommentBox/Model/Mysql4/Comment/Collection.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Abcnet_CommentBox
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Abcnet
12
+ * @package Abcnet_CommentBox
13
+ * @copyright Copyright (c) 2011 Mogos Radu, radu.mogos@pixelplant.ro, radu.mogos@abcnet.ch
14
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
+ */
16
+
17
+ class Abcnet_CommentBox_Model_Mysql4_Comment_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
18
+ {
19
+ protected function _construct()
20
+ {
21
+ $this->_init('commentbox/comment');
22
+ }
23
+ }
app/code/community/Abcnet/CommentBox/Model/Resource/Mysql4/Setup.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Abcnet_CommentBox
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Abcnet
11
+ * @package Abcnet_CommentBox
12
+ * @copyright Copyright (c) 2011 Mogos Radu, radu.mogos@pixelplant.ro, radu.mogos@abcnet.ch
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+
16
+ class Abcnet_CommentBox_Model_Resource_Mysql4_Setup extends Mage_Core_Model_Resource_Setup
17
+ {
18
+ }
app/code/community/Abcnet/CommentBox/controllers/Adminhtml/ListController.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Abcnet_CommentBox
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Abcnet
12
+ * @package Abcnet_CommentBox
13
+ * @copyright Copyright (c) 2011 Mogos Radu, radu.mogos@pixelplant.ro, radu.mogos@abcnet.ch
14
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
+ */
16
+
17
+ class Abcnet_CommentBox_Adminhtml_ListController extends Mage_Adminhtml_Controller_Action
18
+ {
19
+ public function indexAction()
20
+ {
21
+ $this->loadLayout();
22
+ $this->_setActiveMenu('system/commentbox');
23
+ //$this->_addBreadcrumb(Mage::helper('commentbox')->__('ABCnet.ch extensions'), Mage::helper('commentbox')->__('ABCnet.ch extensions'));
24
+ //$this->_addBreadcrumb(Mage::helper('commentbox')->__('New Profile'), Mage::helper('adminhtml')->__('New Profile'));
25
+ $this->_addContent($this->getLayout()->createBlock('commentbox/adminhtml_list'));
26
+ $this->renderLayout();
27
+ }
28
+
29
+ public function editAction()
30
+ {
31
+ $id = $this->getRequest()->getParam('id');
32
+ $model = Mage::getModel('commentbox/comment')->load($id);
33
+ if ($model->getId() || $id == 0)
34
+ {
35
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
36
+ if (!empty($data))
37
+ $model->setData($data);
38
+
39
+ Mage::register('comment_data', $model);
40
+ $this->loadLayout();
41
+ $this->_setActiveMenu('system/commentbox');
42
+ $this->_addContent($this->getLayout()->createBlock('commentbox/adminhtml_list_edit'))
43
+ ->_addLeft($this->getLayout()->createBlock('commentbox/adminhtml_list_edit_tabs'));
44
+ $this->renderLayout();
45
+ }
46
+ else
47
+ {
48
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('commentbox')->__('Specified Script was not found!'));
49
+ $this->_redirect('*/*/');
50
+ }
51
+ }
52
+
53
+ public function newAction()
54
+ {
55
+ $this->_forward('edit');
56
+ }
57
+
58
+ public function saveAction()
59
+ {
60
+ if ($data = $this->getRequest()->getPost())
61
+ {
62
+ try
63
+ {
64
+ $model = Mage::getModel('commentbox/comment');
65
+ // if it exists, load it and update the object
66
+ if (($id = $this->getRequest()->getParam('id')))
67
+ {
68
+ $model->load($id);
69
+ }
70
+ // attach the post data to the object
71
+ $model->addData($data);
72
+
73
+ if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL)
74
+ {
75
+ $model->setCreatedTime(now())
76
+ ->setUpdateTime(now());
77
+ }
78
+ else
79
+ {
80
+ $model->setUpdateTime(now());
81
+ }
82
+
83
+ $model->save();
84
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Comment message was successfully saved'));
85
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
86
+ $this->_redirect('*/*/');
87
+ return;
88
+ }
89
+ catch (Exception $e) {
90
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
91
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
92
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
93
+ return;
94
+ }
95
+ }
96
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Unable to find the comment message to save'));
97
+ $this->_redirect('*/*/');
98
+ }
99
+
100
+ public function messageAction()
101
+ {
102
+ $message = Mage::getModel('commentbox/comment')->load($this->getRequest()->getParam('mid'));
103
+ echo $message->getMessage();
104
+ }
105
+
106
+ protected function _isAllowed()
107
+ {
108
+ return Mage::getSingleton('admin/session')->isAllowed('system/commentbox');
109
+ }
110
+
111
+ public function deleteAction()
112
+ {
113
+ $id = $this->getRequest()->getParam('id');
114
+ $model = Mage::getModel('commentbox/comment')->setId($id)->delete();
115
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Comment message was successfully deleted'));
116
+ $this->_redirect('*/*/');
117
+ }
118
+
119
+ public function massDeleteAction()
120
+ {
121
+ $comments = $this->getRequest()->getParam('comments');
122
+ $total = sizeof($comments);
123
+ if ($total == 0)
124
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('No comment messages ids were specified to be removed'));
125
+ else
126
+ {
127
+ foreach ($comments as $comment_id)
128
+ {
129
+ Mage::getModel('commentbox/comment')->setId($comment_id)->delete();
130
+ }
131
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('%s comment messages were successfully deleted', $total));
132
+ }
133
+ $this->_redirect('*/*/');
134
+ }
135
+ }
app/code/community/Abcnet/CommentBox/controllers/Adminhtml/Sales/OrderController.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Abcnet_CommentBox
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * @category Abcnet
12
+ * @package Abcnet_CommentBox
13
+ * @copyright Copyright (c) 2011 Mogos Radu, radu.mogos@pixelplant.ro, radu.mogos@abcnet.ch
14
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
15
+ */
16
+
17
+ require_once 'Mage/Adminhtml/controllers/Sales/OrderController.php';
18
+
19
+ class Abcnet_CommentBox_Adminhtml_Sales_OrderController extends Mage_Adminhtml_Sales_OrderController
20
+ {
21
+ /**
22
+ * Add order comment action
23
+ */
24
+ public function addCommentAction()
25
+ {
26
+ if ($order = $this->_initOrder()) {
27
+ try {
28
+ $response = false;
29
+ $data = $this->getRequest()->getPost('history');
30
+ $notify = isset($data['is_customer_notified']) ? $data['is_customer_notified'] : false;
31
+ $visible = isset($data['is_visible_on_front']) ? $data['is_visible_on_front'] : false;
32
+
33
+ $order->addStatusHistoryComment($data['comment'], $data['status'])
34
+ ->setIsVisibleOnFront($visible)
35
+ ->setIsCustomerNotified($notify);
36
+
37
+ //$comment = trim(strip_tags($data['comment']));
38
+ $comment = $data['comment'];
39
+
40
+ $order->save();
41
+ $order->sendOrderUpdateEmail($notify, $comment);
42
+
43
+ $this->loadLayout('empty');
44
+ $this->renderLayout();
45
+ }
46
+ catch (Mage_Core_Exception $e) {
47
+ $response = array(
48
+ 'error' => true,
49
+ 'message' => $e->getMessage(),
50
+ );
51
+ }
52
+ catch (Exception $e) {
53
+ $response = array(
54
+ 'error' => true,
55
+ 'message' => $this->__('Cannot add order history.')
56
+ );
57
+ }
58
+ if (is_array($response)) {
59
+ $response = Mage::helper('core')->jsonEncode($response);
60
+ $this->getResponse()->setBody($response);
61
+ }
62
+ }
63
+ }
64
+ }
app/code/community/Abcnet/CommentBox/etc/adminhtml.xml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <system>
5
+ <children>
6
+ <abcnet>
7
+ <title>ABCnet.ch extension</title>
8
+ <sort_order>70</sort_order>
9
+ <children>
10
+ <commentbox translate="title" module="commentbox">
11
+ <title>Order comment messages</title>
12
+ <sort_order>0</sort_order>
13
+ <action>commentboxadmin/adminhtml_list</action>
14
+ </commentbox>
15
+ </children>
16
+ </abcnet>
17
+ </children>
18
+ </system>
19
+ </menu>
20
+
21
+ <acl>
22
+ <resources>
23
+ <admin>
24
+ <children>
25
+ <system>
26
+ <children>
27
+ <commentbox translate="title" module="commentbox">
28
+ <title>Order comment messages</title>
29
+ </commentbox>
30
+ <config>
31
+ <children>
32
+ <commentbox translate="title" module="commentbox">
33
+ <title>Order comment messages</title>
34
+ </commentbox>
35
+ </children>
36
+ </config>
37
+ </children>
38
+ </system>
39
+ </children>
40
+ </admin>
41
+ </resources>
42
+ </acl>
43
+ </config>
app/code/community/Abcnet/CommentBox/etc/config.xml ADDED
@@ -0,0 +1 @@
 
0
  * Abcnet_CommentBox
1
  * www.abcnet.ch
2
  *
3
  * NOTICE OF LICENSE
4
  *
5
  * This source file is subject to the Open Software License (OSL 3.0)
6
  * that is bundled with this package in the file LICENSE.txt.
7
  * It is also available through the world-wide-web at this URL:
8
  * http://opensource.org/licenses/osl-3.0.php
9
  *
10
  * @category Abcnet
11
  * @package Abcnet_CommentBox
12
  * @copyright Copyright (c) 2011 Mogos Radu, radu.mogos@pixelplant.ro, radu.mogos@abcnet.ch
13
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
  */
15
- ->
1
+ <?xml version="1.0"?>
2
  * Abcnet_CommentBox
3
  * www.abcnet.ch
4
  *
5
  * NOTICE OF LICENSE
6
  *
7
  * This source file is subject to the Open Software License (OSL 3.0)
8
  * that is bundled with this package in the file LICENSE.txt.
9
  * It is also available through the world-wide-web at this URL:
10
  * http://opensource.org/licenses/osl-3.0.php
11
  *
12
  * @category Abcnet
13
  * @package Abcnet_CommentBox
14
  * @copyright Copyright (c) 2011 Mogos Radu, radu.mogos@pixelplant.ro, radu.mogos@abcnet.ch
15
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
  */
 
app/code/community/Abcnet/CommentBox/sql/commentbox_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Abcnet_CommentBox
5
+ * www.abcnet.ch
6
+ *
7
+ * NOTICE OF LICENSE
8
+ *
9
+ * This source file is subject to the Open Software License (OSL 3.0)
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @category Abcnet
13
+ * @package Abcnet_CommentBox
14
+ * @copyright Copyright (c) 2011 Mogos Radu, radu.mogos@pixelplant.ro, radu.mogos@abcnet.ch
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+ $installer = $this;
19
+ $installer->startSetup();
20
+
21
+ $installer->run("
22
+ CREATE TABLE `{$installer->getTable('commentbox/comment')}` (
23
+ `comment_id` int(11) NOT NULL auto_increment,
24
+ `title` text,
25
+ `message` text,
26
+ `date` datetime default NULL,
27
+ `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
28
+ PRIMARY KEY (`comment_id`)
29
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
30
+
31
+ ");
32
+ $installer->endSetup();
app/design/adminhtml/default/default/template/abcnet/history.phtml ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Abcnet_CommentBox
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * @category Abcnet
11
+ * @package Abcnet_CommentBox
12
+ * @copyright Copyright (c) 2011 Mogos Radu, radu.mogos@pixelplant.ro, radu.mogos@abcnet.ch
13
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
14
+ */
15
+ ?>
16
+ <div id="order_history_block">
17
+ <?php if ($this->canAddComment()):?>
18
+ <div id="history_form" class="order-history-form">
19
+ <div><?php echo Mage::helper('sales')->__('Add Order Comments') ?></div>
20
+ <span class="field-row">
21
+ <div style="float:right">
22
+ <script type="text/javascript">
23
+
24
+ function getCommentMessage()
25
+ {
26
+ var url = '<?php echo Mage::helper("adminhtml")->getUrl("commentboxadmin/adminhtml_list/message") ?>';
27
+ var pars = 'mid='+$('history_commentbox').getValue();
28
+ new Ajax.Request(url,
29
+ {
30
+ method: 'get',
31
+ parameters: pars,
32
+ onComplete: showMessage
33
+ });
34
+ }
35
+
36
+ function showMessage(request)
37
+ {
38
+ $('history_comment').setValue(request.responseText);
39
+ }
40
+ </script>
41
+ <label class="normal" for="history_commentbox"><?php echo Mage::helper('commentbox')->__('Use predefined message') ?></label><br/>
42
+ <select name="history[commentbox]" class="select" id="history_commentbox" onchange="getCommentMessage()">
43
+ <option value="0"><?php echo Mage::helper('commentbox')->__('-- None --') ?></option>
44
+ <?php foreach ($this->getCommentMessages() as $message): ?>
45
+ <option value="<?php echo $message->getId(); ?>"><?php echo $message->getTitle();?></option>
46
+ <?php endforeach; ?>
47
+ </select>
48
+ </div>
49
+ <label class="normal" for="history_status"><?php echo Mage::helper('sales')->__('Status') ?></label><br/>
50
+ <select name="history[status]" class="select" id="history_status">
51
+ <?php foreach ($this->getStatuses() as $_code=>$_label): ?>
52
+ <option value="<?php echo $_code ?>"<?php if($_code==$this->getOrder()->getStatus()): ?> selected="selected"<?php endif; ?>><?php echo $_label ?></option>
53
+ <?php endforeach; ?>
54
+ </select>
55
+ </span>
56
+ <span class="field-row">
57
+ <label class="normal" for="history_comment"><?php echo Mage::helper('sales')->__('Comment') ?></label>
58
+ <textarea name="history[comment]" rows="3" cols="5" style="height:12em; width:99%;" id="history_comment"></textarea>
59
+ </span>
60
+ <div class="f-left">
61
+ <?php if ($this->canSendCommentEmail()): ?>
62
+ <input name="history[is_customer_notified]" type="checkbox" id="history_notify" value="1" /><label class="normal" for="history_notify"> <?php echo Mage::helper('sales')->__('Notify Customer by Email') ?></label><br />
63
+ <?php endif; ?>
64
+ <input name="history[is_visible_on_front]" type="checkbox" id="history_visible" value="1" /><label class="normal" for="history_visible"> <?php echo Mage::helper('sales')->__('Visible on Frontend') ?></label>
65
+ </div>
66
+ <div class="f-right">
67
+ <?php echo $this->getChildHtml('submit_button') ?>
68
+ </div>
69
+ <div class="clear"></div>
70
+ </div>
71
+ <div class="divider"></div>
72
+ <?php endif;?>
73
+ <ul class="note-list">
74
+ <?php foreach ($this->getOrder()->getStatusHistoryCollection(true) as $_item): ?>
75
+ <li>
76
+ <strong><?php echo $this->helper('core')->formatDate($_item->getCreatedAtDate(), 'medium') ?></strong>
77
+ <?php echo $this->helper('core')->formatTime($_item->getCreatedAtDate(), 'medium') ?><span class="separator">|</span><strong><?php echo $_item->getStatusLabel() ?></strong><br/><small><?php echo $this->helper('sales')->__('Customer') ?>
78
+ <strong class="subdue">
79
+ <?php if ($this->isCustomerNotificationNotApplicable($_item)): ?>
80
+ <?php echo $this->helper('sales')->__('Notification Not Applicable') ?>
81
+ <?php elseif ($_item->getIsCustomerNotified()): ?>
82
+ <?php echo $this->helper('sales')->__('Notified') ?>
83
+ <img src="<?php echo $this->getSkinUrl('images/ico_success.gif') ?>" width="16" height="16" alt="" />
84
+ <?php else: ?>
85
+ <?php echo $this->helper('sales')->__('Not Notified') ?>
86
+ <?php endif; ?>
87
+ </strong></small>
88
+ <?php if ($_item->getComment()): ?>
89
+ <br/><?php
90
+ //echo $this->escapeHtml($_item->getComment(), array('h1','h2','h3','h4','p','div','b','br','strong','i','u', 'em'));
91
+ echo $_item->getComment();
92
+ ?>
93
+ <?php endif; ?>
94
+ </li>
95
+ <?php endforeach; ?>
96
+ </ul>
97
+ <script type="text/javascript">
98
+ if($('order_status'))$('order_status').update('<?php echo $this->getOrder()->getStatusLabel() ?>');
99
+ </script>
100
+ </div>
app/etc/modules/Abcnet_CommentBox.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Abcnet_CommentBox
5
+ * www.abcnet.ch
6
+ *
7
+ * NOTICE OF LICENSE
8
+ *
9
+ * This source file is subject to the Open Software License (OSL 3.0)
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * @category Abcnet
13
+ * @package Abcnet_CommentBox
14
+ * @copyright Copyright (c) 2011 Mogos Radu, radu.mogos@pixelplant.ro, radu.mogos@abcnet.ch
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+ -->
18
+ <config>
19
+ <modules>
20
+ <Abcnet_CommentBox>
21
+ <active>true</active>
22
+ <codePool>community</codePool>
23
+ </Abcnet_CommentBox>
24
+ </modules>
25
+ </config>
package.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Abcnet_CommentBox</name>
4
+ <version>1.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Define a predefined list of comments that you want to show and be able to select in the backend order view page.</summary>
10
+ <description>The extension enables an AJAX powered dropdown box where you can select predefined messages that you want to send as comments for each order. The messages can be customized as you wish using Magento's built in RTE.</description>
11
+ <notes>Tested on 1.4.1.1 and 1.5.0.1&#xD;
12
+ Please let me know if it works in other versions as well</notes>
13
+ <authors><author><name>Mogos Radu</name><user>auto-converted</user><email>radu.mogos@abcnet.ch</email></author></authors>
14
+ <date>2011-09-01</date>
15
+ <time>14:04:25</time>
16
+ <contents><target name="magecommunity"><dir name="Abcnet"><dir name="CommentBox"><dir name="Block"><dir name="Adminhtml"><dir name="List"><dir name="Edit"><file name="Form.php" hash="c75edcf735045e317232aa46871bfc34"/></dir><file name="Edit.php" hash="ec41e2081660bee8f3df86e2fd8f3331"/><file name="Grid.php" hash="5d9d99f624826ab48ede1d2f9b1fe005"/></dir><dir name="Sales"><dir name="Order"><dir name="View"><file name="History.php" hash="b2e0d0fbbd98713296c52c5ea0a86486"/></dir></dir></dir><file name="List.php" hash="b5140a23ad7aa1dac55b3ad47190d72b"/></dir></dir><dir name="Helper"><file name="Data.php" hash="457b355144151ab5db950c5d59ce7dfb"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Comment"><file name="Collection.php" hash="fe291c28191d8c160423c9977c32d6f6"/></dir><file name="Comment.php" hash="e54af9db5b4b33779b17dbc913e27694"/></dir><dir name="Resource"><dir name="Mysql4"><file name="Setup.php" hash="d1fa70fbcefa877d77256795c9e359f3"/></dir></dir><file name="Comment.php" hash="463fbe35b43f0a106b834d06fec44332"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Sales"><file name="OrderController.php" hash="8b2de44141e59d22d38895eb5dfc5d9f"/></dir><file name="ListController.php" hash="40e92716e689bb34a34be6044335784a"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="f7469fc6395c0169aba6d68b5a298588"/><file name="config.xml" hash="01b626194301e2a1cfa91b6f5a8f6ede"/></dir><dir name="sql"><dir name="commentbox_setup"><file name="mysql4-install-0.1.0.php" hash="96264aea4dcf0af15603e550dba8dc01"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Abcnet_CommentBox.xml" hash="7188fa1878eb22c872c66b7b2e2ce245"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="abcnet"><file name="history.phtml" hash="5671fd97c65349592db801a4f9091142"/></dir></dir></dir></dir></dir></target></contents>
17
+ <compatible/>
18
+ <dependencies/>
19
+ </package>