Advertisement
Guest User

Untitled

a guest
Sep 29th, 2011
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.15 KB | None | 0 0
  1. <?php
  2.  
  3. class ModalidadesController extends CentralAppController {
  4.  
  5.     /**
  6.      * Representa el nombre de este controller
  7.      * @var string $name
  8.      */
  9.     var $name = 'Modalidades';
  10.  
  11.     /**
  12.      * Conjunto de Modelos que han de cargarse para este controller
  13.      * @var array $uses
  14.      */
  15.     var $uses = array('Central.Modalidad');
  16.  
  17.     /**
  18.      * Helpers adicionales que se deben cargar
  19.      * @var array $helpers
  20.      */
  21.     var $helpers = array('Html', 'Form');
  22.  
  23.     /**
  24.      * @var string $singularName Nombre humano que representa este controller, en singular
  25.      */
  26.     public static $singularName = 'Modalidad';
  27.  
  28.     /**
  29.      * @var string $pluralName Nombre humano que representa este controller, en plural
  30.      */
  31.     public static $pluralName = 'Modalidades';
  32.  
  33.     /**
  34.      * Funcion para listar todas las modalidades existentes
  35.      * @return void
  36.      */
  37.     public function index() {
  38.         $this->set('data', $this->Modalidad->find('all'));
  39.     }
  40.  
  41.     /**
  42.      * Funcion para crear una nueva modalidad
  43.      * @return void
  44.      */
  45.     function crear() {
  46.         $this->set('title_for_layout', 'Adicionar Modalidades');
  47.  
  48.         if (!empty($this->data)) {
  49.             if ($this->Modalidad->save($this->data)) {
  50.                 // logic goes here
  51.             } else {
  52.                 $this->Session->setFlash('Ocurrieron errores salvando los datos', 'default', array('class' => 'example_class'));
  53.             }
  54.         } else {
  55.             $this->render();
  56.         }
  57.     }
  58.  
  59.     /**
  60.      * Funcion para crear una editar una modalidad existente
  61.      * @return void
  62.      */
  63.     function editar($id_modalidad = null) {
  64.         $this->set('title_for_layout', 'Editar modalidad');
  65.         $this->Modalidad->cmodal_006 = $id_modalidad;
  66.  
  67.         if (empty($this->data)) {
  68.             $this->data = $this->Modalidad->read();
  69.         } else {
  70.             if ($this->Modalidad->save()) {
  71.                 $this->Session->setFlash('La modalidad ha sido actualizada satisfactoriamente');
  72.                 $this->redirect(array('action' => 'index'));
  73.             }
  74.         }
  75.  
  76.         $this->render();
  77.     }
  78.  
  79. }
  80.  
  81. ?>
  82.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement