1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27:
28: 29: 30: 31: 32: 33: 34:
35: class Mage_Adminhtml_Block_Notification_Grid extends Mage_Adminhtml_Block_Widget_Grid
36: {
37: protected function _construct()
38: {
39: $this->setSaveParametersInSession(true);
40: $this->setId('notificationGrid');
41: $this->setIdFieldName('notification_id');
42: $this->setDefaultSort('date_added', 'desc');
43: $this->setFilterVisibility(false);
44: }
45:
46: 47: 48:
49: protected function _prepareCollection()
50: {
51: $collection = Mage::getModel('adminnotification/inbox')
52: ->getCollection()
53: ->addRemoveFilter();
54: $this->setCollection($collection);
55: return parent::_prepareCollection();
56: }
57:
58: 59: 60:
61: protected function _prepareColumns()
62: {
63: $this->addColumn('severity', array(
64: 'header' => Mage::helper('adminnotification')->__('Severity'),
65: 'width' => '60px',
66: 'index' => 'severity',
67: 'renderer' => 'adminhtml/notification_grid_renderer_severity',
68: ));
69:
70: $this->addColumn('date_added', array(
71: 'header' => Mage::helper('adminnotification')->__('Date Added'),
72: 'index' => 'date_added',
73: 'width' => '150px',
74: 'type' => 'datetime'
75: ));
76:
77: $this->addColumn('title', array(
78: 'header' => Mage::helper('adminnotification')->__('Message'),
79: 'index' => 'title',
80: 'renderer' => 'adminhtml/notification_grid_renderer_notice',
81: ));
82:
83: $this->addColumn('actions', array(
84: 'header' => Mage::helper('adminnotification')->__('Actions'),
85: 'width' => '250px',
86: 'sortable' => false,
87: 'renderer' => 'adminhtml/notification_grid_renderer_actions',
88: ));
89:
90: return parent::_prepareColumns();
91: }
92:
93: 94: 95:
96: protected function _prepareMassaction()
97: {
98: $this->setMassactionIdField('notification_id');
99: $this->getMassactionBlock()->setFormFieldName('notification');
100:
101: $this->getMassactionBlock()->addItem('mark_as_read', array(
102: 'label' => Mage::helper('adminnotification')->__('Mark as Read'),
103: 'url' => $this->getUrl('*/*/massMarkAsRead', array('_current'=>true)),
104: ));
105:
106: $this->getMassactionBlock()->addItem('remove', array(
107: 'label' => Mage::helper('adminnotification')->__('Remove'),
108: 'url' => $this->getUrl('*/*/massRemove'),
109: 'confirm' => Mage::helper('adminnotification')->__('Are you sure?')
110: ));
111:
112:
113:
114: return $this;
115: }
116:
117: public function getRowClass(Varien_Object $row) {
118: return $row->getIsRead() ? 'read' : 'unread';
119: }
120:
121: public function getRowClickCallback()
122: {
123: return false;
124: }
125: }
126: