/**
  * Returns a new CalificacionQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param     Criteria $criteria Optional Criteria to build the query from
  *
  * @return    CalificacionQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof CalificacionQuery) {
         return $criteria;
     }
     $query = new CalificacionQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
Exemplo n.º 2
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this Usuario is new, it will return
  * an empty collection; or if this Usuario has previously
  * been saved, it will retrieve related Calificacions from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in Usuario.
  *
  * @param      Criteria $criteria optional Criteria object to narrow the query
  * @param      PropelPDO $con optional connection object
  * @param      string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
  * @return     PropelCollection|array Calificacion[] List of Calificacion objects
  */
 public function getCalificacionsJoinLibro($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $query = CalificacionQuery::create(null, $criteria);
     $query->joinWith('Libro', $join_behavior);
     return $this->getCalificacions($query, $con);
 }
Exemplo n.º 3
0
if ($libro->getDebaja() != NULL) {
    echo "<h1>El libro al que esta intentando acceder se encuentra bloqueado por el administrador</h1>";
    die;
}
$audiolibros = AudiolibroQuery::create()->filterByIdlibro($idLibro)->find();
//obtengo la puntuación del libro
$puntaje = 0;
$calificacionLibro = CalificacionQuery::create()->filterById_libro($idLibro)->find();
foreach ($calificacionLibro as $reg) {
    $puntaje += $reg->getPuntuacion();
}
$cantidadVotos = $calificacionLibro->count();
if ($cantidadVotos != 0) {
    $promedioPuntaje = round($puntaje / $cantidadVotos, 1);
}
$votoPropio = CalificacionQuery::create()->filterById_libro($idLibro)->filterById_usuario($idusuario)->find()->count();
//echo $libro->getEs_editable();
//$options = "<option value = ''>Seleccione un libro</option> ";
$listaaudios = "";
//$arr=array();
foreach ($audiolibros as $reg) {
    //if(!array_key_exists($reg->getId(), $arr)){
    //$arr[$reg->getId()] = "";
    $listaaudios .= "<li>" . $reg->getNombre() . "</li>";
    //$options .= "<option value = '".$reg->getId()."'>".$reg->getNombre()."</option> ";
    //$options .= "<option value = '".$reg->getId()."'>".$reg->getNombre()."</option> ";
    //$options .= "<option value = '".$reg->getId()."'>".$reg->getNombre()."</option> ";
    //
}
//echo $listaLibros;
//$listaLibros = "";
Exemplo n.º 4
0
ini_set("display_errors", 1);
include_once "../../data/config.php";
//echo "<pre>";print_r(json_decode($_POST['json']));  echo "</pre>";
$datos = json_decode($_POST['json']);
//$libros = LibroQuery::create()->find();
//$usuarios = UsuarioQuery::create()->find();
switch ($datos->accion) {
    case "votar":
        $calificacion = new Calificacion();
        $calificacion->setPuntuacion($datos->puntos);
        $calificacion->setId_libro($datos->libro);
        $calificacion->setId_usuario($_SESSION['userid']);
        $calificacion->save();
        //obtengo la puntuación del libro
        $puntaje = 0;
        $calificacionLibro = CalificacionQuery::create()->filterById_libro($datos->libro)->find();
        foreach ($calificacionLibro as $reg) {
            $puntaje += $reg->getPuntuacion();
        }
        $promedioPuntaje = round($puntaje / $calificacionLibro->count(), 1);
        $html = "<b>Puntaje actual: " . $promedioPuntaje . " <a href='#' title='Puntaje actual " . $promedioPuntaje . "'>&#9733;</a></b>";
        echo json_encode(array('html' => $html));
        break;
    case "bloquear":
        $libro = LibroQuery::create()->findOneById($datos->libro);
        $libro->setDebaja("s");
        include 'notificacion_data.php';
        $mesajeNotificacion = "Tu libro '" . $libro->getNombre() . "' ha sido bloqueado por el administrador.";
        guardarNotificacion($libro->getId_usuario(), $mesajeNotificacion, 9);
        $libro->save();
        echo json_encode(array('msg' => "Libro bloqueado correctamente."));
Exemplo n.º 5
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param      PropelPDO $con
  * @return     void
  * @throws     PropelException
  * @see        BaseObject::setDeleted()
  * @see        BaseObject::isDeleted()
  */
 public function delete(PropelPDO $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(CalificacionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = CalificacionQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }