Skip to content

Commit

Permalink
added a default mass action for things like add edit etc [#67]
Browse files Browse the repository at this point in the history
  • Loading branch information
dogmatic69 committed Jan 4, 2010
1 parent 97d87aa commit 4862ef2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
24 changes: 23 additions & 1 deletion app_controller.php
Expand Up @@ -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 )
{
Expand All @@ -377,7 +386,7 @@ protected function __massGetIds( $data )
return $ids;
}

function __massGetAction( $form )
protected function __massGetAction( $form )
{
if ( isset( $form['action'] ) )
{
Expand Down Expand Up @@ -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 ) );
}
}
}
?>
1 change: 1 addition & 0 deletions plugins/newsletter/views/newsletters/admin_index.ctp
Expand Up @@ -22,6 +22,7 @@
$massActions = $this->Letter->massActionButtons(
array(
'add',
'edit',
'copy',
'toggle',
'send',
Expand Down

0 comments on commit 4862ef2

Please sign in to comment.