Make delete handler respect canDelete (#142)

This commit is contained in:
Rob Ingram 2017-06-29 18:33:22 +12:00 committed by Thierry François
parent 3aad957a69
commit c7a275a7a6

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* Bulk action handler for deleting records. * Bulk action handler for deleting records.
* *
* @author colymba * @author colymba
*/ */
class GridFieldBulkActionDeleteHandler extends GridFieldBulkActionHandler class GridFieldBulkActionDeleteHandler extends GridFieldBulkActionHandler
@ -24,7 +24,7 @@ class GridFieldBulkActionDeleteHandler extends GridFieldBulkActionHandler
/** /**
* Delete the selected records passed from the delete bulk action. * Delete the selected records passed from the delete bulk action.
* *
* @param SS_HTTPRequest $request * @param SS_HTTPRequest $request
* *
* @return SS_HTTPResponse List of deleted records ID * @return SS_HTTPResponse List of deleted records ID
@ -34,8 +34,10 @@ class GridFieldBulkActionDeleteHandler extends GridFieldBulkActionHandler
$ids = array(); $ids = array();
foreach ($this->getRecords() as $record) { foreach ($this->getRecords() as $record) {
array_push($ids, $record->ID); if ($record->canDelete()) {
$record->delete(); array_push($ids, $record->ID);
$record->delete();
}
} }
$response = new SS_HTTPResponse(Convert::raw2json(array( $response = new SS_HTTPResponse(Convert::raw2json(array(