Skip to content

Commit f51ab22

Browse files
authored
Added confirm dialog to critical massactions (#2814)
1 parent 37c4481 commit f51ab22

File tree

19 files changed

+182
-66
lines changed

19 files changed

+182
-66
lines changed

app/code/core/Mage/Adminhtml/Block/Backup/Grid.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
2020
*/
2121

22+
use Mage_Adminhtml_Block_Widget_Grid_Massaction_Abstract as MassAction;
23+
2224
/**
2325
* Adminhtml backups grid block
2426
*
@@ -56,7 +58,7 @@ protected function _prepareMassaction()
5658
$this->setMassactionIdField('id');
5759
$this->getMassactionBlock()->setFormFieldName('ids');
5860

59-
$this->getMassactionBlock()->addItem('delete', [
61+
$this->getMassactionBlock()->addItem(MassAction::DELETE, [
6062
'label' => Mage::helper('adminhtml')->__('Delete'),
6163
'url' => $this->getUrl('*/*/massDelete'),
6264
'confirm' => Mage::helper('backup')->__('Are you sure you want to delete the selected backup(s)?')

app/code/core/Mage/Adminhtml/Block/Cache/Grid.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
2020
*/
2121

22+
use Mage_Adminhtml_Block_Widget_Grid_Massaction_Abstract as MassAction;
23+
2224
/**
2325
* @category Mage
2426
* @package Mage_Adminhtml
@@ -63,7 +65,7 @@ protected function _afterLoadCollection()
6365
}
6466

6567
/**
66-
* Prepare grid columns
68+
* @inheritDoc
6769
*/
6870
protected function _prepareColumns()
6971
{
@@ -136,6 +138,8 @@ public function getRowUrl($row)
136138

137139
/**
138140
* Add mass-actions to grid
141+
*
142+
* @return $this
139143
*/
140144
protected function _prepareMassaction()
141145
{
@@ -144,15 +148,15 @@ protected function _prepareMassaction()
144148

145149
$modeOptions = Mage::getModel('index/process')->getModesOptions();
146150

147-
$this->getMassactionBlock()->addItem('enable', [
148-
'label' => Mage::helper('index')->__('Enable'),
149-
'url' => $this->getUrl('*/*/massEnable'),
151+
$this->getMassactionBlock()->addItem(MassAction::ENABLE, [
152+
'label' => Mage::helper('index')->__('Enable'),
153+
'url' => $this->getUrl('*/*/massEnable'),
150154
]);
151-
$this->getMassactionBlock()->addItem('disable', [
155+
$this->getMassactionBlock()->addItem(MassAction::DISABLE, [
152156
'label' => Mage::helper('index')->__('Disable'),
153157
'url' => $this->getUrl('*/*/massDisable'),
154158
]);
155-
$this->getMassactionBlock()->addItem('refresh', [
159+
$this->getMassactionBlock()->addItem(MassAction::REFRESH, [
156160
'label' => Mage::helper('index')->__('Refresh'),
157161
'url' => $this->getUrl('*/*/massRefresh'),
158162
'selected' => true,

app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
2020
*/
2121

22+
use Mage_Adminhtml_Block_Widget_Grid_Massaction_Abstract as MassAction;
23+
2224
/**
2325
* Adminhtml customer grid block
2426
*
@@ -310,16 +312,15 @@ protected function _prepareMassaction()
310312
$this->setMassactionIdField('entity_id');
311313
$this->getMassactionBlock()->setFormFieldName('product');
312314

313-
$this->getMassactionBlock()->addItem('delete', [
315+
$this->getMassactionBlock()->addItem(MassAction::DELETE, [
314316
'label' => Mage::helper('catalog')->__('Delete'),
315-
'url' => $this->getUrl('*/*/massDelete'),
316-
'confirm' => Mage::helper('catalog')->__('Are you sure?')
317+
'url' => $this->getUrl('*/*/massDelete')
317318
]);
318319

319320
$statuses = Mage::getSingleton('catalog/product_status')->getOptionArray();
320321

321322
array_unshift($statuses, ['label' => '', 'value' => '']);
322-
$this->getMassactionBlock()->addItem('status', [
323+
$this->getMassactionBlock()->addItem(MassAction::STATUS, [
323324
'label' => Mage::helper('catalog')->__('Change status'),
324325
'url' => $this->getUrl('*/*/massStatus', ['_current' => true]),
325326
'additional' => [
@@ -334,7 +335,7 @@ protected function _prepareMassaction()
334335
]);
335336

336337
if (Mage::getSingleton('admin/session')->isAllowed('catalog/update_attributes')) {
337-
$this->getMassactionBlock()->addItem('attributes', [
338+
$this->getMassactionBlock()->addItem(MassAction::ATTRIBUTES, [
338339
'label' => Mage::helper('catalog')->__('Update Attributes'),
339340
'url' => $this->getUrl('*/catalog_product_action_attribute/edit', ['_current' => true])
340341
]);

app/code/core/Mage/Adminhtml/Block/Catalog/Search/Grid.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
2020
*/
2121

22+
use Mage_Adminhtml_Block_Widget_Grid_Massaction_Abstract as MassAction;
23+
2224
/**
2325
* @category Mage
2426
* @category Mage
@@ -152,10 +154,9 @@ protected function _prepareMassaction()
152154
$this->setMassactionIdField('query_id');
153155
$this->getMassactionBlock()->setFormFieldName('search');
154156

155-
$this->getMassactionBlock()->addItem('delete', [
157+
$this->getMassactionBlock()->addItem(MassAction::DELETE, [
156158
'label' => Mage::helper('catalog')->__('Delete'),
157-
'url' => $this->getUrl('*/*/massDelete'),
158-
'confirm' => Mage::helper('catalog')->__('Are you sure?')
159+
'url' => $this->getUrl('*/*/massDelete')
159160
]);
160161

161162
return parent::_prepareMassaction();

app/code/core/Mage/Adminhtml/Block/Customer/Grid.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
2020
*/
2121

22+
use Mage_Adminhtml_Block_Widget_Grid_Massaction_Abstract as MassAction;
23+
2224
/**
2325
* Adminhtml customer grid block
2426
*
@@ -178,18 +180,17 @@ protected function _prepareMassaction()
178180
$this->setMassactionIdField('entity_id');
179181
$this->getMassactionBlock()->setFormFieldName('customer');
180182

181-
$this->getMassactionBlock()->addItem('delete', [
183+
$this->getMassactionBlock()->addItem(MassAction::DELETE, [
182184
'label' => Mage::helper('customer')->__('Delete'),
183-
'url' => $this->getUrl('*/*/massDelete'),
184-
'confirm' => Mage::helper('customer')->__('Are you sure?')
185+
'url' => $this->getUrl('*/*/massDelete')
185186
]);
186187

187-
$this->getMassactionBlock()->addItem('newsletter_subscribe', [
188+
$this->getMassactionBlock()->addItem(MassAction::NEWSLETTER_SUBSCRIBE, [
188189
'label' => Mage::helper('customer')->__('Subscribe to Newsletter'),
189190
'url' => $this->getUrl('*/*/massSubscribe')
190191
]);
191192

192-
$this->getMassactionBlock()->addItem('newsletter_unsubscribe', [
193+
$this->getMassactionBlock()->addItem(MassAction::NEWSLETTER_UNSUBSCRIBE, [
193194
'label' => Mage::helper('customer')->__('Unsubscribe from Newsletter'),
194195
'url' => $this->getUrl('*/*/massUnsubscribe')
195196
]);
@@ -199,7 +200,7 @@ protected function _prepareMassaction()
199200
$groups = $helper->getGroups()->toOptionArray();
200201

201202
array_unshift($groups, ['label' => '', 'value' => '']);
202-
$this->getMassactionBlock()->addItem('assign_group', [
203+
$this->getMassactionBlock()->addItem(MassAction::ASSIGN_GROUP, [
203204
'label' => Mage::helper('customer')->__('Assign a Customer Group'),
204205
'url' => $this->getUrl('*/*/massAssignGroup'),
205206
'additional' => [

app/code/core/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
2020
*/
2121

22+
use Mage_Adminhtml_Block_Widget_Grid_Massaction_Abstract as MassAction;
23+
2224
/**
2325
* Adminhtml newsletter subscribers grid block
2426
*
@@ -201,12 +203,12 @@ protected function _prepareMassaction()
201203
$this->getMassactionBlock()->setFormFieldName('subscriber');
202204
$this->getMassactionBlock()->setUseSelectAll(false);
203205

204-
$this->getMassactionBlock()->addItem('unsubscribe', [
206+
$this->getMassactionBlock()->addItem(MassAction::UNSUBSCRIBE, [
205207
'label' => Mage::helper('newsletter')->__('Unsubscribe'),
206208
'url' => $this->getUrl('*/*/massUnsubscribe')
207209
]);
208210

209-
$this->getMassactionBlock()->addItem('delete', [
211+
$this->getMassactionBlock()->addItem(MassAction::DELETE, [
210212
'label' => Mage::helper('newsletter')->__('Delete'),
211213
'url' => $this->getUrl('*/*/massDelete')
212214
]);

app/code/core/Mage/Adminhtml/Block/Notification/Grid.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
2020
*/
2121

22+
use Mage_Adminhtml_Block_Widget_Grid_Massaction_Abstract as MassAction;
23+
2224
/**
2325
* Adminhtml AdminNotification inbox grid
2426
*
@@ -95,15 +97,14 @@ protected function _prepareMassaction()
9597
$this->setMassactionIdField('notification_id');
9698
$this->getMassactionBlock()->setFormFieldName('notification');
9799

98-
$this->getMassactionBlock()->addItem('mark_as_read', [
100+
$this->getMassactionBlock()->addItem(MassAction::MARK_AS_READ, [
99101
'label' => Mage::helper('adminnotification')->__('Mark as Read'),
100102
'url' => $this->getUrl('*/*/massMarkAsRead', ['_current' => true]),
101103
]);
102104

103-
$this->getMassactionBlock()->addItem('remove', [
105+
$this->getMassactionBlock()->addItem(MassAction::REMOVE, [
104106
'label' => Mage::helper('adminnotification')->__('Remove'),
105-
'url' => $this->getUrl('*/*/massRemove'),
106-
'confirm' => Mage::helper('adminnotification')->__('Are you sure?')
107+
'url' => $this->getUrl('*/*/massRemove')
107108
]);
108109

109110
return $this;

app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Grid.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
2020
*/
2121

22+
use Mage_Adminhtml_Block_Widget_Grid_Massaction_Abstract as MassAction;
23+
2224
/**
2325
* Coupon codes grid
2426
*
@@ -38,7 +40,7 @@ public function __construct()
3840
/**
3941
* Prepare collection for grid
4042
*
41-
* @return Mage_Adminhtml_Block_Widget_Grid
43+
* @inheritDoc
4244
*/
4345
protected function _prepareCollection()
4446
{
@@ -114,10 +116,10 @@ protected function _prepareMassaction()
114116
$this->getMassactionBlock()->setUseAjax(true);
115117
$this->getMassactionBlock()->setHideFormElement(true);
116118

117-
$this->getMassactionBlock()->addItem('delete', [
118-
'label' => Mage::helper('adminhtml')->__('Delete'),
119-
'url' => $this->getUrl('*/*/couponsMassDelete', ['_current' => true]),
120-
'confirm' => Mage::helper('salesrule')->__('Are you sure you want to delete the selected coupon(s)?'),
119+
$this->getMassactionBlock()->addItem(MassAction::DELETE, [
120+
'label' => Mage::helper('adminhtml')->__('Delete'),
121+
'url' => $this->getUrl('*/*/couponsMassDelete', ['_current' => true]),
122+
'confirm' => Mage::helper('salesrule')->__('Are you sure you want to delete the selected coupon(s)?'),
121123
'complete' => 'refreshCouponCodesGrid'
122124
]);
123125

app/code/core/Mage/Adminhtml/Block/Report/Refresh/Statistics/Grid.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
2020
*/
2121

22+
use Mage_Adminhtml_Block_Widget_Grid_Massaction_Abstract as MassAction;
23+
2224
/**
2325
* Adminhtml sales report grid block
2426
*
@@ -36,6 +38,11 @@ public function __construct()
3638
$this->setUseAjax(false);
3739
}
3840

41+
/**
42+
* @param string $reportCode
43+
* @return string
44+
* @throws Zend_Date_Exception
45+
*/
3946
protected function _getUpdatedAt($reportCode)
4047
{
4148
$flag = Mage::getModel('reports/flag')->setReportFlagCode($reportCode)->loadSelf();
@@ -48,6 +55,9 @@ protected function _getUpdatedAt($reportCode)
4855
: '';
4956
}
5057

58+
/**
59+
* @inheritDoc
60+
*/
5161
protected function _prepareCollection()
5262
{
5363
$collection = new Varien_Data_Collection();
@@ -114,6 +124,9 @@ protected function _prepareCollection()
114124
return parent::_prepareCollection();
115125
}
116126

127+
/**
128+
* @inheritDoc
129+
*/
117130
protected function _prepareColumns()
118131
{
119132
$this->addColumn('report', [
@@ -142,18 +155,21 @@ protected function _prepareColumns()
142155
return parent::_prepareColumns();
143156
}
144157

158+
/**
159+
* @return $this
160+
*/
145161
protected function _prepareMassaction()
146162
{
147163
$this->setMassactionIdField('id');
148164
$this->getMassactionBlock()->setFormFieldName('code');
149165

150-
$this->getMassactionBlock()->addItem('refresh_lifetime', [
166+
$this->getMassactionBlock()->addItem(MassAction::REFRESH_LIFETIME, [
151167
'label' => Mage::helper('reports')->__('Refresh Lifetime Statistics'),
152168
'url' => $this->getUrl('*/*/refreshLifetime'),
153169
'confirm' => Mage::helper('reports')->__('Are you sure you want to refresh lifetime statistics? There can be performance impact during this operation.')
154170
]);
155171

156-
$this->getMassactionBlock()->addItem('refresh_recent', [
172+
$this->getMassactionBlock()->addItem(MassAction::REFRESH_RECENT, [
157173
'label' => Mage::helper('reports')->__('Refresh Statistics for the Last Day'),
158174
'url' => $this->getUrl('*/*/refreshRecent'),
159175
'confirm' => Mage::helper('reports')->__('Are you sure?'),

0 commit comments

Comments
 (0)