/** * Returns a new MensajeQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * * @return MensajeQuery */ public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof MensajeQuery) { return $criteria; } $query = new MensajeQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
/** * Returns the number of related Mensaje objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related Mensaje objects. * @throws PropelException */ public function countMensajesRelatedById_usuario_remitente(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { if (null === $this->collMensajesRelatedById_usuario_remitente || null !== $criteria) { if ($this->isNew() && null === $this->collMensajesRelatedById_usuario_remitente) { return 0; } else { $query = MensajeQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByUsuarioRelatedById_usuario_remitente($this)->count($con); } } else { return count($this->collMensajesRelatedById_usuario_remitente); } }
<?php error_reporting(E_ALL); ini_set("display_errors", 1); include_once "../../data/config.php"; $mensaje = MensajeQuery::create()->filterById_usuario_destinatario($_SESSION['userid'])->find(); //$mensaje = MensajeQuery::create() ->findOneById(0); //$mensaje->getUsuarioRelatedById_usuario_remitente()->getNick(); //'<li class="header">You have 5 messages</li>' $salida = '<li>' . '<ul class="menu">'; $cont = 0; foreach ($mensaje as $reg) { //$listaLibros .= "<li>".$reg->getNombre()."</li>"; if ($reg->getleido() != "s") { $cont++; $salida .= '<li><!-- start message --> <a href="#" onclick="vermensajeseleccionado(' . $reg->getId() . ');"> <div class="pull-left"> ' . '</div> <h4><span> Mensaje de ' . $reg->getUsuarioRelatedById_usuario_remitente()->getNombre() . ' </span>' . '</h4><p><span id="mensaje">' . $reg->getmensaje() . '</span></p>' . '</a> </li>'; } /*echo "<tr>" . "<td>".$reg->getId()."</td>" . "<td id = \"descripcion_".$reg->getId()."\">".$reg->getDescripcion()."</td>" . "</tr>";*/
$salida .= '<div class="form-group"> <input type="hidden" id="leido" value="s"/> De: <span id="id_usuario_destinatario"> ' . $remitente . '</span> </div> <div class="form-group"> <textarea id="mensaje" class="form-control" style="height: 300px">' . $texto . '</textarea> </div> </div><!-- /.box-body -->'; $mensaje->setLeido("s"); $mensaje->save(); echo json_encode(array('error' => 0, 'html' => $salida)); break; case "r": //responder mensajes $mensaje = MensajeQuery::create()->findOneById($datos->id); //$texto = $mensaje->getMensaje(); //en la respuesta el remitente es el destinatario $remitente = $mensaje->getUsuarioRelatedById_usuario_remitente()->getNombre(); //en remitente deberia enviar el id en lugar del nombre $salida .= '<div id="respuesta" class="form-group"> <input type="hidden" id="leido" value="n"/> <input type="hidden" disabled id="id"> <input type="hidden" id="id_usuario_remitente" value="' . $_SESSION["userid"] . '"/> <input type="hidden" id="id_usuario_destinatario" value="' . $mensaje->getId_usuario_remitente() . '"/> Para: <span > ' . $remitente . '</span> </div> <div id="respuesta" class="form-group"> <textarea id="mensaje" class="form-control" style="height: 300px"></textarea> </div>
/** * 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(MensajePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = MensajeQuery::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; } }
<?php error_reporting(E_ALL); ini_set("display_errors", 1); include_once "../../data/config.php"; $mensaje = MensajeQuery::create()->find(); //$mensaje = MensajeQuery::create()->findOneById($datos->id); foreach ($mensaje as $reg) { $salida .= '.<tr>.' . '<td><input type="checkbox" id="select_mensaje"></td>' . '<td class="mailbox-name"><a onclick="mostrar_panel_enviado(' . $reg->getId() . ')" href="#">' . $reg->getUsuarioRelatedById_usuario_destinatario()->getNombre() . '</td></a>' . '<td class="mailbox-subject"><a onclick="mostrar_panel_enviado(' . $reg->getId() . ')" href="#">' . $reg->getMensaje() . '</td></a>' . '.</tr>.'; } // echo json_encode(array( 'error' => 0, 'salida' => $salida, 'cantidad' => $cont)); //muestra el array concatenado ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Proyecto Lectura</title> <!-- Tell the browser to be responsive to screen width --> <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"> <!-- Bootstrap 3.3.5 --> <link rel="stylesheet" href="../../bootstrap/css/bootstrap.min.css"> <!-- Font Awesome --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"> <!-- Ionicons --> <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"> <!-- fullCalendar 2.2.5--> <link rel="stylesheet" href="../../plugins/fullcalendar/fullcalendar.min.css"> <link rel="stylesheet" href="../../plugins/fullcalendar/fullcalendar.print.css" media="print"> <!-- Theme style -->
<?php error_reporting(E_ALL); ini_set("display_errors", 1); include_once "../../data/config.php"; //$usuario = MensajeQuery::create()->find(); $usuario = MensajeQuery::create()->findOneById($_POST["id"]); foreach ($usuario as $reg) { //$listaLibros .= "<li>".$reg->getNombre()."</li>"; $nombre_usuario .= $reg->getUsuarioRelatedById_usuario_remitente()->getNombre(); } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Proyecto Lectura</title> <!-- Tell the browser to be responsive to screen width --> <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"> <!-- Bootstrap 3.3.5 --> <link rel="stylesheet" href="../../bootstrap/css/bootstrap.min.css"> <!-- Font Awesome --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"> <!-- Ionicons --> <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"> <!-- fullCalendar 2.2.5--> <link rel="stylesheet" href="../../plugins/fullcalendar/fullcalendar.min.css"> <link rel="stylesheet" href="../../plugins/fullcalendar/fullcalendar.print.css" media="print"> <!-- Theme style -->