Ejemplo n.º 1
0
?>

</form>

<?php 
if ($mensaje->getPrimaryKey()) {
    ?>
<ul class="sf_admin_actions">
  <?php 
    $value = "";
    $usuario = Usuario::getUsuarioActual();
    if ($usuario->getPrimaryKey() == $mensaje->getIdUsuario()) {
        $value = "<li class=\"float-left\">";
        $value .= button_to(__('Borrar completamente'), 'mensajes/delete_salida?id_mensaje=' . $mensaje->getPrimaryKey(), array('post' => true, 'confirm' => __('¿Quiere borrar este mensaje? También se borrarán las copias enviadas a los destinatarios'), 'class' => 'sf_admin_action_delete'));
        $value .= "</li>\n";
        $mensaje_destino = MensajeDestinoPeer::retrieveByPk($mensaje->getPrimaryKey(), $usuario->getPrimaryKey());
        if (isset($mensaje_destino)) {
            $value .= "<li class=\"float-left\">";
            $value .= button_to(__('borrar copia recibida'), 'mensajes/delete_entrada?id_mensaje=' . $mensaje->getPrimaryKey(), array('post' => true, 'confirm' => __('¿Quiere borrar esta copia? El mensaje original se mantendrá intacto'), 'class' => 'sf_admin_action_delete'));
            $value .= "</li>\n";
        }
    } else {
        $value = "<li class=\"float-left\">";
        $value .= button_to(__('Borrar'), 'mensajes/delete_entrada?id_mensaje=' . $mensaje->getPrimaryKey(), array('post' => true, 'confirm' => __('¿Quiere borrar este objeto?'), 'class' => 'sf_admin_action_delete'));
        $value .= "</li>\n";
    }
    echo $value;
    ?>
</ul>
<?php 
}
Ejemplo 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 MensajeDestinos 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.
  */
 public function getMensajeDestinosJoinMensaje($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     if ($criteria === null) {
         $criteria = new Criteria(UsuarioPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collMensajeDestinos === null) {
         if ($this->isNew()) {
             $this->collMensajeDestinos = array();
         } else {
             $criteria->add(MensajeDestinoPeer::ID_USUARIO, $this->id_usuario);
             $this->collMensajeDestinos = MensajeDestinoPeer::doSelectJoinMensaje($criteria, $con, $join_behavior);
         }
     } else {
         // the following code is to determine if a new query is
         // called for.  If the criteria is the same as the last
         // one, just return the collection.
         $criteria->add(MensajeDestinoPeer::ID_USUARIO, $this->id_usuario);
         if (!isset($this->lastMensajeDestinoCriteria) || !$this->lastMensajeDestinoCriteria->equals($criteria)) {
             $this->collMensajeDestinos = MensajeDestinoPeer::doSelectJoinMensaje($criteria, $con, $join_behavior);
         }
     }
     $this->lastMensajeDestinoCriteria = $criteria;
     return $this->collMensajeDestinos;
 }
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = MensajeDestinoPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setIdMensaje($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setIdUsuario($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setLeido($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setBorrado($arr[$keys[3]]);
     }
 }
Ejemplo n.º 4
0
 public function executeEnviar_alarmas()
 {
     set_time_limit(0);
     $fecha = new Date();
     $fecha_uno = $fecha->toString(FMT_DATEMYSQL);
     $c1 = new Criteria();
     $crit0 = $c1->getNewCriterion(TareaPeer::FECHA_INICIO, $fecha_uno . " 00:00:00", Criteria::GREATER_EQUAL);
     $crit1 = $c1->getNewCriterion(TareaPeer::FECHA_INICIO, $fecha_uno . " 23:59:59", Criteria::LESS_EQUAL);
     $crit4 = $c1->getNewCriterion(TareaPeer::AVISAR_EMAIL, true, Criteria::EQUAL);
     $crit0->addAnd($crit1);
     $crit0->addAnd($crit4);
     $crit2 = $c1->getNewCriterion(TareaPeer::FECHA_VENCIMIENTO, $fecha_uno . " 00:00:00", Criteria::GREATER_EQUAL);
     $crit3 = $c1->getNewCriterion(TareaPeer::FECHA_VENCIMIENTO, $fecha_uno . " 23:59:59", Criteria::LESS_EQUAL);
     $crit5 = $c1->getNewCriterion(TareaPeer::AVISAR_EMAIL_FIN, true, Criteria::EQUAL);
     $crit2->addAnd($crit3);
     $crit2->addAnd($crit5);
     $crit0->addOr($crit2);
     $c1->add($crit0);
     $c1->setDistinct();
     $tareas_hoy = TareaPeer::doSelect($c1);
     foreach ($tareas_hoy as $tarea) {
         $asunto = $tarea->getResumen();
         $fecha_uno = $tarea->getFechaInicio('d/m/Y');
         $fecha_dos = $tarea->getFechaVencimiento('d/m/Y');
         if ($fecha_uno != $fecha_dos && $fecha_uno == date('d/m/Y')) {
             $cuerpo .= "<strong>Legedia</strong> - Inicio de ";
             $cuerpo .= $tarea->getEsEvento() ? "evento: " : "tarea: ";
         } elseif ($fecha_uno != $fecha_dos && $fecha_dos == date('d/m/Y')) {
             $cuerpo = "<strong>Legedia</strong> - Vencimiento de ";
             $cuerpo .= $tarea->getEsEvento() ? "evento: " : "tarea: ";
         } else {
             $cuerpo = "<strong>Legedia</strong> - " . $tarea->getEsEvento() ? "Evento:" : "Tarea: ";
         }
         $cuerpo .= $tarea->getResumen() . "<br />";
         $cuerpo .= "Inicio: " . $fecha_uno . "<br />";
         $cuerpo .= "Fin: " . $fecha_dos . "<br />";
         $cuerpo .= $tarea->getDescripcion();
         if ($tarea->getIdFormulario() != 0) {
             $form = FormularioPeer::retrieveByPK($tarea->getIdFormulario());
             if ($form instanceof Formulario) {
                 $cuerpo .= "Objeto relacionado: <a href=\"" . UsuarioPeer::getRuta() . "formularios/edit?id_formulario=" . $tarea->getIdFormulario() . "\">" . $form->__toString() . "</a>";
             }
         }
         $cuerpo .= "<br /><br />Muchas gracias<br /><br />Un Saludo<br />Administrador <strong>LEGEDIA</strong>\n";
         $mens = new Mensaje();
         $mens->setAsunto($asunto);
         $mens->setCuerpo($cuerpo);
         $mens->setEmail(true);
         $mens->setFecha(time());
         $mens->save();
         $c = new Criteria();
         $c->addAnd(MensajeDestinoPeer::ID_MENSAJE, $mens->getPrimaryKey());
         MensajeDestinoPeer::doDelete($c);
         $mensajeDestino = new MensajeDestino();
         $mensajeDestino->setIdMensaje($mens->getPrimaryKey());
         $mensajeDestino->setIdUsuario($tarea->getUsuario()->getIdUsuario());
         $mensajeDestino->save();
         echo $tarea->getUsuario()->getEmail() . "::" . $asunto . "<br />" . $cuerpo . "<br /><br />";
         if (trim($tarea->getUsuario()->getEmail()) != "") {
             $enviado = MensajePeer::enviarEmailDefault($tarea->getIdEmpresa(), $asunto, $cuerpo, array($tarea->getUsuario()->getEmail()));
         }
     }
     echo "ENVIADOS: " . $enviado;
     return sfView::NONE;
 }
Ejemplo n.º 5
0
 protected function saveMensaje($mensaje)
 {
     $mensaje->save();
     // Update many-to-many for "mensaje_destino"
     $c = new Criteria();
     $c->add(MensajeDestinoPeer::ID_MENSAJE, $mensaje->getPrimaryKey());
     MensajeDestinoPeer::doDelete($c);
     $ids = $this->getRequestParameter('associated_mensaje_destinos');
     if (is_array($ids)) {
         foreach ($ids as $id) {
             $mensajeDestino = new MensajeDestino();
             $mensajeDestino->setIdMensaje($mensaje->getPrimaryKey());
             $mensajeDestino->setIdUsuario($id);
             $mensajeDestino->save();
         }
     }
 }
 /**
 * Retrieve object using using composite pkey values.
 * @param      int $id_mensaje
   @param      int $id_usuario
   
 * @param      PropelPDO $con
 * @return     MensajeDestino
 */
 public static function retrieveByPK($id_mensaje, $id_usuario, PropelPDO $con = null)
 {
     $key = serialize(array((string) $id_mensaje, (string) $id_usuario));
     if (null !== ($obj = MensajeDestinoPeer::getInstanceFromPool($key))) {
         return $obj;
     }
     if ($con === null) {
         $con = Propel::getConnection(MensajeDestinoPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $criteria = new Criteria(MensajeDestinoPeer::DATABASE_NAME);
     $criteria->add(MensajeDestinoPeer::ID_MENSAJE, $id_mensaje);
     $criteria->add(MensajeDestinoPeer::ID_USUARIO, $id_usuario);
     $v = MensajeDestinoPeer::doSelect($criteria, $con);
     return !empty($v) ? $v[0] : null;
 }