コード例 #1
0
ファイル: perfil.php プロジェクト: ocidfigueroa/sice
 /**
  * Método para crear/modificar un objeto de base de datos
  * 
  * @param string $medthod: create, update
  * @param array $data: Data para autocargar el modelo
  * @param array $optData: Data adicional para autocargar
  * 
  * return object ActiveRecord
  */
 public static function setPerfil($method, $data, $optData = null)
 {
     $obj = new Perfil($data);
     //Se carga los datos con los de las tablas
     if ($optData) {
         //Se carga información adicional al objeto
         $obj->dump_result_self($optData);
     }
     //Verifico que no exista otro perfil, y si se encuentra inactivo lo active
     $conditions = empty($obj->id) ? "perfil = '{$obj->perfil}'" : "perfil = '{$obj->perfil}' AND id != '{$obj->id}'";
     $old = new Perfil();
     if ($old->find_first($conditions)) {
         //Si existe y se intenta crear pero si no se encuentra activo lo activa
         if ($method == 'create' && $old->estado != Perfil::ACTIVO) {
             $obj->id = $old->id;
             $obj->estado = Perfil::ACTIVO;
             $method = 'update';
         } else {
             Flash::info('Ya existe un perfil registrado bajo ese nombre.');
             return FALSE;
         }
     }
     return $obj->{$method}() ? $obj : FALSE;
 }
コード例 #2
0
 /**
  * Método para ver
  */
 public function ver($key, $order = 'order.perfil.asc', $page = 'pag.1')
 {
     $page = Filter::get($page, 'page') > 0 ? Filter::get($page, 'page') : 1;
     if (!($id = DwSecurity::isValidKey($key, 'show_perfil', 'int'))) {
         return DwRedirect::toAction('listar');
     }
     $perfil = new Perfil();
     if (!$perfil->find_first($id)) {
         DwMessage::get('id_no_found');
         return DwRedirect::toAction('listar');
     }
     $usuario = new Usuario();
     $this->usuarios = $usuario->getUsuarioPorPerfil($perfil->id, $order, $page);
     $this->perfil = $perfil;
     $this->order = $order;
     $this->page_title = 'Información del Perfil';
     $this->key = $key;
 }
コード例 #3
0
 /**
  * Método para ver
  */
 public function ver($key, $order = 'order.perfil.asc', $page = 'page.1')
 {
     $page = Filter::get($page, 'page') > 0 ? Filter::get($page, 'page') : 1;
     if (!($id = Security::getKey($key, 'show_perfil', 'int'))) {
         return Redirect::toAction('listar');
     }
     $perfil = new Perfil();
     if (!$perfil->find_first($id)) {
         Flash::error('Lo sentimos, no se pudo establecer la información del perfil');
         return Redirect::toAction('listar');
     }
     $usuario = new Usuario();
     $this->usuarios = $usuario->getUsuarioPorPerfil($perfil->id, $order, $page);
     $this->perfil = $perfil;
     $this->order = $order;
     $this->page_title = 'Información del Perfil';
     $this->key = $key;
 }