/**
  * Declares an association between this object and a Libro object.
  *
  * @param      Libro $v
  * @return     Slider_mae The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setLibro(Libro $v = null)
 {
     if ($v === null) {
         $this->setId_libro(NULL);
     } else {
         $this->setId_libro($v->getId());
     }
     $this->aLibro = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Libro object, it will not be re-added.
     if ($v !== null) {
         $v->addSlider_mae($this);
     }
     return $this;
 }
 /**
  * Filter the query by a related Libro object
  *
  * @param     Libro|PropelCollection $libro The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return    Libro_colaboradorQuery The current query, for fluid interface
  */
 public function filterByLibro($libro, $comparison = null)
 {
     if ($libro instanceof Libro) {
         return $this->addUsingAlias(Libro_colaboradorPeer::IDLIBRO, $libro->getId(), $comparison);
     } elseif ($libro instanceof PropelCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(Libro_colaboradorPeer::IDLIBRO, $libro->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByLibro() only accepts arguments of type Libro or PropelCollection');
     }
 }
     break;
 case "n":
     //New
     include 'notificacion_data.php';
     $libroObj = new Libro();
     //$libroObj->setNombre($datos->nombre);
     $libroObj->setNombre($_POST["nombrelibro"]);
     $libroObj->setId_genero($_POST["vinculogenero"]);
     $libroObj->setFecha(date('Y-m-d'));
     $libroObj->setAutor($_POST["autor"]);
     $libroObj->setEs_editable("n");
     $libroObj->setSinopsis($_POST["sinopsis"]);
     $libroObj->setId_privacidad($_POST["privacidad"]);
     $libroObj->setId_usuario($_SESSION["userid"]);
     $libroObj->save();
     $idImage = $libroObj->getId();
     $mesajeNotificacion = "<span onclick=\"refreshDivs('cuerpocentro','pages/layout/perfillibro.php?id=" . $idImage . "')\">El usuario '" . UsuarioQuery::create()->findOneById($_SESSION["userid"])->getNombre() . "' ha subido un libro.</span>";
     guardarNotificacion(ID_ADMIN_USER, $mesajeNotificacion, 6);
     // obtenemos los datos del archivo
     //$tamano = $_FILES["image"]['size'];
     //$tipo = $_FILES["image"]['type'];
     $archivo = $_FILES["image"]['name'];
     if ($archivo != "") {
         //$nom=date('Y-m-d H:i:s');
         //$hasharchivo = hash('md5',$nom);
         // $audiolibroObj->setHash($datosaudio->hasharchivo);
         //echo $hasharchivo;
         // guardamos el archivo a la carpeta files
         $destino = "../../portadas/" . $idImage . '.jpg';
         if (copy($_FILES['image']['tmp_name'], $destino)) {
             //$status = "Archivo subido: ".$archivo."";
     } else {
         $libroObj = LibroQuery::create()->findOneById($datos->idlibro);
         $libroObj->setNombre($datos->nombrelibro);
         //$libroObj->setTexto($datos->texto);
         $libroObj->save();
         file_put_contents(SITE_PATH . "/libros/libro_" . $datos->idlibro . ".txt", $datos->texto);
         echo json_encode(array('msg' => "Libro guardado correctamente", 'idlibro' => $datos->idlibro));
     }
     break;
 case "version":
     //diff -y  -T --suppress-common-lines -a --strip-trailing-cr indexold.php index.php
     if ($datos->idlibro == "") {
         $libroObj = new Libro();
         $libroObj->setNombre($datos->nombrelibro);
         $libroObj->save();
         $idLibro = $libroObj->getId();
     } else {
         $idLibro = $datos->idlibro;
     }
     $libroVersion = new Libro_version();
     $libroVersion->setIdlibro($idLibro);
     $libroVersion->setFecha(date("Y-m-d"));
     $libroVersion->setHora(date("H:i:s"));
     $libroVersion->setIdusuario($_SESSION['userid']);
     $libroVersion->save();
     file_put_contents(SITE_PATH . "/libros_version/libro_" . $idLibro . "_" . $libroVersion->getId() . ".txt", base64_decode($datos->texto));
     echo json_encode(array('msg' => "Libro guardado correctamente", 'idlibro' => $idLibro));
     break;
 case "marcarActividad":
     $fecha = date("Y-m-d");
     $hora = date("h:i:s");
 /**
  * Exclude object from result
  *
  * @param     Libro $libro Object to remove from the list of results
  *
  * @return    LibroQuery The current query, for fluid interface
  */
 public function prune($libro = null)
 {
     if ($libro) {
         $this->addUsingAlias(LibroPeer::ID, $libro->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }