/ Published in: PHP
This snippet can be called in every controller, all you need to do is to specify the form name, the model name and the data.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function quick_actions($form, $model, $data) { $action = $this->data[$form]['actions']; App::Import('Model', $model); $this->DynamicModel = new $form; if ($action == 'delete') { foreach ($this->data[$form]['id'] as $key => $value) { if ($value != 0) { $this->DynamicModel->delete($key); $this->Session->setFlash('Items permanent verwijderd', 'notifications/tray_top'); $return = true; } } } if ($action == 'return') { foreach ($this->data[$form]['id'] as $key => $value) { if ($value != 0) { $this->Session->setFlash('Items teruggezet', 'notifications/tray_top'); $return = true; } } } } if ($action == 'remove') { foreach ($this->data[$form]['id'] as $key => $value) { if ($value != 0) { $this->Session->setFlash('Items verwijderd naar prullenbak', 'notifications/tray_top'); $return = true; } } } } if ($action == 'publish') { foreach ($this->data[$form]['id'] as $key => $value) { if ($value != 0) { $this->Session->setFlash('Items gepubliceerd', 'notifications/tray_top'); $return = true; } } } } if ($action == 'unpublish') { foreach ($this->data[$form]['id'] as $key => $value) { if ($value != 0) { $this->Session->setFlash('Items geweigerd', 'notifications/tray_top'); $return = true; } } } } $this->redirect($this->referer()); $this->Session->setFlash('Er is een fout opgetreden, probeer opnieuw','notifications/error'); $this->redirect($this->referer()); } }