From 4862ef23a9183b018a798999a666dd9c31b916a1 Mon Sep 17 00:00:00 2001 From: dogmatic Date: Mon, 4 Jan 2010 09:08:07 +0200 Subject: [PATCH] added a default mass action for things like add edit etc [#67] --- app_controller.php | 24 ++++++++++++++++++- .../views/newsletters/admin_index.ctp | 1 + 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app_controller.php b/app_controller.php index 31b5608f0..2295b58a5 100644 --- a/app_controller.php +++ b/app_controller.php @@ -348,11 +348,20 @@ protected function admin_mass( ) case 'copy': $this->__massActionCopy( $ids ); break; + + default: + $this->__massActionGeneric( $this->__massGetAction( $this->params['form'] ), $ids ); + break; } // switch } protected function __massGetIds( $data ) { + if ( in_array( $this->__massGetAction( $this->params['form'] ), array( 'add' ) ) ) + { + return null; + } + $ids = array(); foreach( $data as $id => $selected ) { @@ -377,7 +386,7 @@ protected function __massGetIds( $data ) return $ids; } - function __massGetAction( $form ) + protected function __massGetAction( $form ) { if ( isset( $form['action'] ) ) { @@ -464,5 +473,18 @@ protected function __massActionCopy( $ids ) $this->redirect( $this->referer() ); } + + protected function __massActionGeneric( $action, $ids ) + { + if ( !$ids ) + { + $this->redirect( array( 'action' => $action ) ); + } + + foreach( $ids as $id ) + { + $this->redirect( array( 'action' => $action, $id ) ); + } + } } ?> \ No newline at end of file diff --git a/plugins/newsletter/views/newsletters/admin_index.ctp b/plugins/newsletter/views/newsletters/admin_index.ctp index 21c59eae2..20a6e4b8c 100644 --- a/plugins/newsletter/views/newsletters/admin_index.ctp +++ b/plugins/newsletter/views/newsletters/admin_index.ctp @@ -22,6 +22,7 @@ $massActions = $this->Letter->massActionButtons( array( 'add', + 'edit', 'copy', 'toggle', 'send',