protected function cargaVariables($modulo)
 {
     // Variables de entorno del modulo
     $variables = new CpanVariables('Mod', 'Env', $modulo);
     $this->varEnvMod = $variables->getValores();
     $this->values['varEnvMod'] = $this->varEnvMod;
     if (count($this->values['varEnvMod']) == 0) {
         $this->values['errores'][] = "No se han definido las variables de entorno del módulo '{$modulo}'";
     }
 }
 /**
  * Edita, actualiza o borrar un registro
  *
  * Viene siempre por POST
  * Actualiza o Borrar según el valor de $this->request['accion']
  *
  * @return array con el template y valores a renderizar
  */
 public function editAction()
 {
     switch ($this->request['accion']) {
         case 'G':
             //GUARDAR DATOS
             if ($this->values['permisos']['permisosModulo']['UP']) {
                 $variables = new CpanVariables('Mod', 'Env', $this->request[$this->entity]['Entity']);
                 $this->varEnvMod = $variables->getValores();
                 unset($variables);
                 $this->values['varEnvMod'] = $this->varEnvMod;
                 $id = $this->request[$this->entity]['Id'];
                 $entidad = $this->request[$this->entity]['Entity'];
                 $idEntidad = $this->request[$this->entity]['IdEntity'];
                 $tipo = $this->request[$this->entity]['Type'];
                 $title = $this->request[$this->entity]['Title'];
                 $slug = $this->request[$this->entity]['Name'];
                 $showCaption = $this->request[$this->entity]['ShowCaption'];
                 $publicar = $this->request[$this->entity]['Publish'];
                 $documento = $this->request['FILES']['documento'];
                 $documento['maxWidth'] = $this->varEnvMod['galery']['maxWidthImage'];
                 $documento['maxHeight'] = $this->varEnvMod['galery']['maxHeightImage'];
                 $documento['modoRecortar'] = $this->request['modoRecortar'];
                 $rules = $this->getRules($this->request[$this->entity]['Type']);
                 // Para que deje actualizar aunque estemos en el límite del
                 // número máximo de documentos
                 if ($rules['numMaxDocs'] > 0) {
                     $rules['numMaxDocs']++;
                 }
                 $doc = new CpanDocs($id);
                 $doc->setTitle($title);
                 $doc->setName($slug);
                 $doc->setShowCaption($showCaption);
                 $doc->setPublish($publicar);
                 if ($documento['name'] != '') {
                     $doc->setArrayDoc($documento);
                 }
                 $doc->setIsThumbnail(0);
                 if ($doc->valida($rules)) {
                     $ok = $doc->actualiza();
                     // Subir Miniatura
                     if ($ok and $this->varEnvMod['galery']['generateThumbnail'] == '1') {
                         $thumbNail = $doc->getThumbNail();
                         $thumbNail->setTitle($title);
                         $thumbNail->setName($slug);
                         $thumbNail->setShowCaption($showCaption);
                         $thumbNail->setPublish($publicar);
                         $thumbNail->setIsThumbnail(1);
                         if ($documento['name'] != '') {
                             $documento['maxWidth'] = $this->varEnvMod['galery']['widthThumbnail'];
                             $documento['maxHeight'] = $this->varEnvMod['galery']['heightThumbnail'];
                             $thumbNail->setArrayDoc($documento);
                         }
                         if ($thumbNail->valida($rules)) {
                             $ok = $thumbNail->actualiza();
                         }
                         unset($thumbNail);
                     }
                 }
                 $this->values['errores'] = $doc->getErrores();
                 $this->values['alertas'] = $doc->getAlertas();
                 unset($doc);
                 return $this->listPopupAction($entidad, $idEntidad, $tipo, $this->request['formato']);
             } else {
                 return array('template' => '_global/forbiden.html.twig');
             }
             break;
         case 'B':
             //BORRAR DATOS
             if ($this->values['permisos']['permisosModulo']['DE']) {
                 $id = $this->request[$this->entity]['Id'];
                 $entidad = $this->request[$this->entity]['Entity'];
                 $idEntidad = $this->request[$this->entity]['IdEntity'];
                 $tipo = $this->request[$this->entity]['Type'];
                 $datos = new CpanDocs($id);
                 if ($datos->erase()) {
                     // Borro los eventuales hijos del documento ( los thumbnails)
                     $thumbNail = new CpanDocs();
                     $rows = $thumbNail->cargaCondicion('Id', "BelongsTo='{$id}'");
                     foreach ($rows as $row) {
                         $thumbNail = new CpanDocs($row['Id']);
                         $thumbNail->erase();
                     }
                     unset($thumbNail);
                     //$this->values['datos'] = $datos;
                     $this->values['errores'] = $datos->getErrores();
                 }
                 unset($datos);
                 return $this->listPopupAction($entidad, $idEntidad, $tipo, $this->request['formato']);
             } else {
                 return array('template' => '_global/forbiden.html.twig');
             }
             break;
     }
 }
Пример #3
0
 /**
  * Carga en la sesión las variables de entorno y web del proyecto
  */
 protected function cargaVariables()
 {
     // Variables de entorno del proyecto
     if (!isset($_SESSION['VARIABLES']['EnvPro'])) {
         $variables = new CpanVariables('Pro', 'Env');
         $this->varEnvPro = $variables->getValores();
         $_SESSION['VARIABLES']['EnvPro'] = $this->varEnvPro;
     } else {
         $this->varEnvPro = $_SESSION['VARIABLES']['EnvPro'];
     }
     $this->values['varEnvPro'] = $this->varEnvPro;
     // Variables web del proyecto
     if (!isset($_SESSION['VARIABLES']['WebPro'])) {
         $variables = new CpanVariables('Pro', 'Web');
         $this->varWebPro = $variables->getValores();
         $_SESSION['VARIABLES']['WebPro'] = $this->varWebPro;
     } else {
         $this->varWebPro = $_SESSION['VARIABLES']['WebPro'];
     }
     $this->values['varWebPro'] = $this->varWebPro;
     unset($variables);
 }
Пример #4
0
 /**
  * Valida el objeto
  *
  * También compruebo que el titulo y el nombre no están vacios.
  * 
  * Si el título está vacío, pongo el valor de la columna indicado en la variable de entorno 'fieldGeneratorUrlFriendly'
  * Si el nombre está vacío, pongo el valor del título
  *
  * @param array $rules
  * @return boolean TRUE si el objeto completo pasa la validación
  */
 public function valida(array $rules)
 {
     if ($this->validaArchivo($rules)) {
         // Validar que se haya indicado título y nombre, en su defecto
         // se toma el indicado por la variable de entorno
         if ($this->Title == '' or $this->Name == '') {
             $variables = new CpanVariables('Mod', 'Env', $this->getEntity());
             $varEnv = $variables->getValores();
             unset($variables);
             $datos = new $this->Entity($this->IdEntity);
             $columnaSlug = $varEnv['fieldGeneratorUrlFriendly'];
             $slug = $datos->{"get{$columnaSlug}"}();
             unset($datos);
             if ($this->Title == '') {
                 $this->Title = $slug;
             }
             if ($this->Name == '') {
                 $this->Name = $this->Title;
             }
         }
         $slug = $this->Name;
         if ($slug == '') {
             $this->_errores[] = "No se ha indicado el título";
         }
     }
     return count($this->_errores) == 0;
 }
Пример #5
0
 /**
  * Carga las variables web y de entorno del proyecto, app y módulo
  * @return void
  */
 protected function cargaVariables()
 {
     // Variables de entorno del proyecto
     if (!isset($_SESSION['VARIABLES']['EnvPro'])) {
         $variables = new CpanVariables('Pro', 'Env');
         $this->varEnvPro = $variables->getValores();
         $_SESSION['VARIABLES']['EnvPro'] = $this->varEnvPro;
     } else {
         $this->varEnvPro = $_SESSION['VARIABLES']['EnvPro'];
     }
     $this->values['varEnvPro'] = $this->varEnvPro;
     if (count($this->values['varEnvPro']) == 0 and $_SESSION['usuarioPortal']['IdPerfil'] == '1') {
         $this->values['errores'][] = "No se han definido las variables de entorno del proyecto";
     }
     // Variables web del proyecto
     if (!isset($_SESSION['VARIABLES']['WebPro'])) {
         $variables = new CpanVariables('Pro', 'Web');
         $this->varWebPro = $variables->getValores();
         $_SESSION['VARIABLES']['WebPro'] = $this->varWebPro;
     } else {
         $this->varWebPro = $_SESSION['VARIABLES']['WebPro'];
     }
     $this->values['varWebPro'] = $this->varWebPro;
     if (count($this->values['varWebPro']) == 0 and $_SESSION['usuarioPortal']['IdPerfil'] == '1') {
         $this->values['errores'][] = "No se han definido las variables web del proyecto";
     }
     // Variables de entorno del modulo
     $variables = new CpanVariables('Mod', 'Env', $this->entity);
     $this->varEnvMod = $variables->getValores();
     $this->values['varEnvMod'] = $this->varEnvMod;
     $_SESSION['VARIABLES']['EnvMod'] = $this->varEnvMod;
     if (count($this->values['varEnvMod']) == 0 and $_SESSION['usuarioPortal']['IdPerfil'] == '1') {
         $this->values['errores'][] = "No se han definido las variables de entorno del módulo '{$this->entity}'";
     }
     // Variables web del modulo
     if (!isset($_SESSION['VARIABLES']['WebMod'])) {
         $variables = new CpanVariables('Mod', 'Web', $this->entity);
         $this->varWebMod = $variables->getValores();
         $_SESSION['VARIABLES']['WebMod'] = $this->varWebMod;
     } else {
         $this->varWebMod = $_SESSION['VARIABLES']['WebMod'];
     }
     $this->values['varWebMod'] = $this->varWebMod;
     if (count($this->values['varWebMod']) == 0 and $_SESSION['usuarioPortal']['IdPerfil'] == '1') {
         $this->values['errores'][] = "No se han definido las variables web del módulo '{$this->entity}'";
     }
     // Variables de entorno de la app
     if (!isset($_SESSION['VARIABLES']['EnvApp'])) {
         $variables = new CpanVariables('App', 'Env', $this->app);
         $this->varEnvApp = $variables->getValores();
         $_SESSION['VARIABLES']['EnvApp'] = $this->varEnvApp;
     } else {
         $this->varEnvApp = $_SESSION['VARIABLES']['EnvApp'];
     }
     $this->values['varEnvApp'] = $this->varEnvApp;
     //if ((count($this->values['varEnvApp']) == 0) and ($_SESSION['usuarioPortal']['IdPerfil'] == '1'))
     //    $this->values['errores'][] = "No se han definido las variables de entorno de la App '{$this->app}'";
     // Variables web de la app
     if (!isset($_SESSION['VARIABLES']['WebApp'])) {
         $variables = new CpanVariables('App', 'Web', $this->app);
         $this->varWebApp = $variables->getValores();
         $_SESSION['VARIABLES']['WebApp'] = $this->varWebApp;
     } else {
         $this->varWebApp = $_SESSION['VARIABLES']['WebApp'];
     }
     $this->values['varWebApp'] = $this->varWebApp;
     //if ((count($this->values['varWebApp']) == 0) and ($_SESSION['usuarioPortal']['IdPerfil'] == '1'))
     //    $this->values['errores'][] = "No se han definido las variables web de la App '{$this->app}'";
     unset($variables);
 }