--- /dev/null
+<?php
+ class WarningsController extends AppController {
+ public $helpers = array('Html', 'Form');
+ public $components = array('RequestHandler');
+
+ public function index() {
+ $warnings = $this->Warning->find('all');
+ $this->set(array(
+ 'warnings' => $warnings,
+ '_serialize' => array('warnings')
+ ));
+ }
+
+ public function view($id = null) {
+ if (!$id) {
+ throw new NotFoundException(__('Mauvaise alerte'));
+ }
+
+ $warning = $this->Warning->findById($id);
+ if (!$warning) {
+ throw new NotFoundException(__('Mauvaise alerte'));
+ }
+ $this->set('warning', $warning);
+ }
+
+ public function add() {
+ if ($this->request->is('warning')) {
+ $this->Warning->create();
+ if ($this->Warning->save($this->request->data)) {
+ $this->Session->setFlash(__("L'alerte a été enregistrée."));
+ $this->redirect(array('action' => 'index'));
+ }
+ $this->Session->setFlash(__("Enregistrement de l'alerte impossible."));
+ }
+ }
+
+ public function edit($id = null) {
+ if (!$id) {
+ throw new NotFoundException(__('Alerte introuvable'));
+ }
+
+ $warning = $this->Warning->findById($id);
+ if (!$warning) {
+ throw new NotFoundException(__('Alerte introuvable'));
+ }
+ $this->set('warning', $warning);
+
+ if ($this->request->is(array('warning', 'put'))) {
+ $this->Warning->id = $id;
+ if ($this->Warning->save($this->request->data)) {
+ $this->Session->setFlash(__("L'alerte a été mise à jour."));
+ $this->redirect(array('action' => 'index'));
+ }
+ $this->Session->setFlash(__("Mise à jour de l'alerte impossible."));
+ }
+
+ if (!$this->request->data) {
+ $this->request->data = $warning;
+ }
+ }
+
+ public function delete($id) {
+ if ($this->request->is('get')) {
+ throw new MethodNotAllowedException();
+ }
+
+ if ($this->Warning->delete($id)) {
+ $this->Session->setFlash(
+ __("L'alerte d'id: %s a été supprimée.", h($id))
+ );
+ $this->redirect(array('action' => 'index'));
+ }
+ }
+ }
+?>