/**
  * Sube al servidor el archivo de plantilla a la carpeta
  * docs/docsXXX/circulares/plantillas.
  * 
  * Debe existir la carpeta docs/docsXXX/circulares.
  * Se sube usando ftp.
  * 
  * @return type
  */
 public function SubirPlantillaAction()
 {
     $fichero = $this->request['FILES']['filePlantilla'];
     if (in_array($fichero['type'], $this->tiposPermitidos)) {
         $carpetaPlantillas = $_SESSION['appPath'] . "/docs/docs{$_SESSION['emp']}/circulares/plantillas";
         Archivo::creaCarpeta($carpetaPlantillas);
         if (is_uploaded_file($fichero['tmp_name'])) {
             $ftp = new Ftp($_SESSION['project']['ftp']);
             if ($ftp) {
                 $ok = $ftp->upLoad($carpetaPlantillas, $fichero['tmp_name'], $fichero['name']);
                 $this->_errores = $ftp->getErrores();
                 $ftp->close();
             } else {
                 $this->_errores[] = "Fallo al conectar vía FTP";
                 foreach ($_SESSION['project']['ftp'] as $item) {
                     $this->_errores[] = $item;
                 }
             }
         }
     } else {
         $this->_errores[] = "Tipo de archivo no permitido. Sólo se admiten archivos rtf,txt y html";
     }
     $this->values['errores'] = $this->_errores;
     return $this->IndexAction();
 }
Exemple #2
0
 /**
  * Cambia el nombre de una imagen existente
  *
  * Actualiza el nombre nuevo en la tabla de imagenes y cambia
  * el nombre al archivo físico
  *
  * @param string $titulo El titulo de la imagen
  * @param string $slug El nombre de la imagen sin limpiar
  * @param booelan $mostrarPieFoto TRUE si se quiere mostrar el titulo en el pie de la imagen
  * @param array $documento Array con los parametros del documento
  * @param booelan $idThumbnail
  * @param integer $orden
  * @return boolean TRUE si se cambió con Exito
  */
 public function actualiza()
 {
     $ok = TRUE;
     // Cargo los datos del objeto antes de cambiarlos
     $doc = new CpanDocs($this->getId());
     $pathName = $doc->getPathName();
     $nombreAnterior = $doc->getName();
     unset($doc);
     // Si el nombre propuesto es distinto al que ya tiene y no es Thumbnail
     // recalculo el nombre amigable, cambio el path y renombro el archivo
     $this->actualizaNombreAmigable();
     $nombreNuevo = $this->getName();
     $pathInfo = pathinfo($pathName);
     $carpetaDestino = $this->_prePath . $pathInfo['dirname'];
     $ftp = new Ftp($_SESSION['project']['ftp']);
     $ok = $ftp->rename($carpetaDestino, $nombreAnterior, $nombreNuevo);
     $this->_errores = $ftp->getErrores();
     $ftp->close();
     unset($ftp);
     if ($this->_ArrayDoc['tmp_name'] != '') {
         $ok = $this->subeDocumento();
     }
     // Si todo ha ido bien, actualizo el objeto
     if ($ok) {
         $this->save();
     }
     unset($this);
     return $ok;
 }