Browse files

ENHANCEMENT batchactions can now implement confirmationDialog() to pr…

…ovide a custom confirmation dialog to the front end.

MINOR added above confiration to batch setting expiry (from r97215) (from r98211)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@111603 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent 81a6ebf commit 201e6a5d7c541ea420e98d8b415c142a9d6113f5 @sminnee sminnee committed Oct 4, 2010
Showing with 22 additions and 0 deletions.
  1. +22 −0 code/CMSBatchActionHandler.php
View
22 code/CMSBatchActionHandler.php
@@ -10,6 +10,7 @@ class CMSBatchActionHandler extends RequestHandler {
static $url_handlers = array(
'$BatchAction/applicablepages' => 'handleApplicablePages',
+ '$BatchAction/confirmation' => 'handleConfirmation',
'$BatchAction' => 'handleAction',
);
@@ -134,6 +135,27 @@ function handleApplicablePages($request) {
return $response;
}
+ function handleConfirmation($request) {
+ // Find the action handler
+ $actions = Object::get_static($this->class, 'batch_actions');
+ $actionClass = $actions[$request->param('BatchAction')];
+ $actionHandler = new $actionClass();
+
+ // Sanitise ID list and query the database for apges
+ $ids = split(' *, *', trim($request->requestVar('csvIDs')));
+ foreach($ids as $k => $id) $ids[$k] = (int)$id;
+ $ids = array_filter($ids);
+
+ if($actionHandler->hasMethod('confirmationDialog')) {
+ $response = new HTTPResponse(json_encode($actionHandler->confirmationDialog($ids)));
+ } else {
+ $response = new HTTPResponse(json_encode(array('alert' => false)));
+ }
+
+ $response->addHeader("Content-type", "application/json");
+ return $response;
+ }
+
/**
* Return a DataObjectSet of ArrayData objects containing the following pieces of info
* about each batch action:

0 comments on commit 201e6a5

Please sign in to comment.