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