public function agregarmsj()
 {
     $msj = new Mensaje();
     $msj->Titulo = Input::get('titulo');
     $msj->cuerpo = Input::get('mbody');
     $msj->private = Input::get('private');
     $msj->save();
 }
    public function save_msj()
    {
        $nombre = Input::get('nombre');
        $lastName = Input::get('apellido');
        $email = Input::get('email');
        $country = Input::get('country');
        $mensaje = Input::get('mensaje');
        $contacto = new Mensaje();
        $contacto->nombre = $nombre . ' ' . $lastName;
        $contacto->email = $email;
        $contacto->pais = $country;
        $contacto->mensaje = $mensaje;
        $contacto->fecha = Carbon::now();
        $contacto->leido = 0;
        $contacto->save();
        $destinatario = "vazquezreyes@gmail.com ";
        $asunto = "Mensaje contacto de durangobariatricsurgery.com";
        $cuerpo = ' 
		<html> 
		<head> 
		   <title>Durango Bariatric Surgery</title> 
		</head> 
		<body> 
		<p>' . $mensaje . '</p> 
		<p>Pais:' . $country . '</p>
		</body> 
		</html> 
		';
        //para el envío en formato HTML
        $headers = "MIME-Version: 1.0\r\n";
        $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
        //dirección del remitente
        $headers .= "From:" . $nombre . ' ' . $lastName . "<" . $email . ">\r\n";
        //dirección de respuesta, si queremos que sea distinta que la del remitente
        //$headers .= "Reply-To: mariano@desarrolloweb.com\r\n";
        //ruta del mensaje desde origen a destino
        //$headers .= "Return-path: holahola@desarrolloweb.com\r\n";
        //direcciones que recibián copia
        //$headers .= "Cc: maria@desarrolloweb.com\r\n";
        //direcciones que recibirán copia oculta
        //$headers .= "Bcc: pepe@pepe.com,juan@juan.com\r\n";
        mail($destinatario, $asunto, $cuerpo, $headers);
        return Redirect::to('contact');
    }
Exemple #3
0
 public static function crear($id, $data)
 {
     $body = json_encode($data['body']);
     $message = new Mensaje();
     $message['app_host'] = $data['app_host'];
     $message['app_port'] = $data['app_port'];
     $message['app_url'] = $data['app_url'];
     $message['message_id'] = $data['message_id'];
     $message['company_id'] = $data['company_id'];
     $message['address'] = $data['address'];
     $message['send_to'] = $data['send_to'];
     $message['subject'] = $data['subject'];
     $message['body'] = $body;
     $message['job_id'] = $id;
     try {
         $message->save();
     } catch (Exception $e) {
     }
 }
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aMensaje !== null) {
             if ($this->aMensaje->isModified() || $this->aMensaje->isNew()) {
                 $affectedRows += $this->aMensaje->save($con);
             }
             $this->setMensaje($this->aMensaje);
         }
         if ($this->aUsuario !== null) {
             if ($this->aUsuario->isModified() || $this->aUsuario->isNew()) {
                 $affectedRows += $this->aUsuario->save($con);
             }
             $this->setUsuario($this->aUsuario);
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = MensajeDestinoPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setNew(false);
             } else {
                 $affectedRows += MensajeDestinoPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
<?php

/**
 *
 *	Función: Crear mensaje.
 *	Método: POST.
 *
 *	Se crea un nuevo mensaje.
 *
 */
$app->post('/crearmensaje/:id_destino', function ($id_destino) use($app) {
    $input = $app->request->getBody();
    $id_origen = $input['id_origen'];
    $asunto = $input['asunto'];
    $mensaje = $input['mensaje'];
    if (empty($asunto)) {
        $app->render(500, array('error' => TRUE, 'msg' => 'Por favor, ingrese un asunto del mensaje.'));
    }
    if (empty($mensaje)) {
        $app->render(500, array('error' => TRUE, 'msg' => 'Por favor, ingrese un mensaje.'));
    }
    $msg = new Mensaje();
    $msg->from = $id_origen;
    $msg->to = $id_destino;
    $msg->asunto = $asunto;
    $msg->msj = $mensaje;
    $msg->save();
    $app->render(200);
});
<?php

//die;
error_reporting(E_ALL);
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 "n":
        //New
        $mensajeObj = new Mensaje();
        $mensajeObj->setId_usuario_destinatario($datos->id_usuario_destinatario);
        $mensajeObj->setId_usuario_remitente($datos->id_usuario_remitente);
        $mensajeObj->setMensaje($datos->mensaje);
        $mensajeObj->setLeido($datos->leido);
        $mensajeObj->save();
        echo json_encode(array('error' => 0, 'msg' => "Mensaje enviado"));
        break;
}
	protected function processForm(sfWebRequest $request, sfForm $form)
	{
		$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
		if ($form->isValid())
		{
			$version = $form->save();

			$permisos = $this->getUser()->inicializarPermisos();
			foreach ($permisos as $permiso):
			if ($request->hasParameter($permiso->getNombre())) {

				if ($permiso == Estado::CERRADA and $version->getEstado()->getNombre() == Estado::VERIFICADA) {
					$version->setValidada(true);
					$svn = new subversion();

					foreach ($version->getFicheros() as $fichero) {
						$this->emptyDir(sfConfig::get('sf_root_dir').'/web/uploads2');
						copy(sfConfig::get('sf_root_dir').'/web/uploads/'.$fichero -> getFile(),sfConfig::get('sf_root_dir').'/web/uploads2/'.$fichero -> getFile());
						$this->logMessage(sfConfig::get('sf_root_dir').'/web/uploads/'.$fichero -> getFile(),'err');
						$this->logMessage(sfConfig::get('sf_root_dir').'/web/uploads2/'.$fichero -> getFile(),'err');
						$svn->addFile('proyect', sfConfig::get('sf_root_dir').'/web/uploads2');
						$svn->updateFile('proyect', sfConfig::get('sf_root_dir').'/web/uploads2');
						copy(sfConfig::get('sf_root_dir').'/web/uploads/'.$fichero -> getFile(),sfConfig::get('sf_root_dir').'/web/uploads3/'.$fichero -> getFile());
					}
				}

				$version->setEstado($permiso);
				$version->save();
				$this->getUser()->setFlash('notice', sprintf('Has tramitado con exito a peticion con estado '.$permiso));

				$usuarios = $version->getUsers();


				if (!empty($usuarios)) {
					foreach ($usuarios as $user) {
						$mensaje = new Mensaje();
						$mensaje -> setNombre('Tramitacion');
						$mensaje -> setLeido(false);
						$mensaje -> setSfGuardUser($user);
						$mensaje -> setDescripcion('Se ha tramitado una solicitud de cambio del artefacto '.$version->getArtefacto().' a estado '.$permiso);
						$mensaje -> save();
						sfContext::getInstance()->getUser()->setAttribute('mensajes',Doctrine_Core::getTable('Mensaje')-> mensajesActivos()-> count());
					}
				}


			}
			endforeach;
			//			$this->getUser()->setFlash('notice', sprintf('Has tramitado con exito el cambio'));
			foreach ($version -> getFicheros() as $fichero) {
				//				require_once 'class.subversion.php';
				// Class examples
				if ($fichero -> getDeleted()) {
					$fichero -> delete();
				}
			}

			$this->redirect('version/show?id='.$version->getId().'&artefactoId='.$version->getArtefactoId());
		}
	}
 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;
 }
Exemple #9
0
 public function postActualizargrupo()
 {
     $data = Input::all();
     $grupo_id = $data["id"];
     DB::beginTransaction();
     DB::table("grupos")->where('id', $grupo_id)->update(array('nombre' => array_key_exists('titulo', $data) ? $data['titulo'] : "", 'descripcion' => array_key_exists('descripcion', $data) ? $data['descripcion'] : "", 'fb_url' => array_key_exists('fb_url', $data) ? $data['fb_url'] : "", 'region' => array_key_exists('departamento', $data) ? $data['departamento'] : "", 'provincia' => array_key_exists('provincia', $data) ? $data['provincia'] : "", 'distrito' => array_key_exists('distrito', $data) ? $data['distrito'] : "", 'edad_desde' => array_key_exists('edad_desde', $data) ? $data['edad_desde'] : "", 'edad_hasta' => array_key_exists('edad_hasta', $data) ? $data['edad_hasta'] : "", 'sexo' => array_key_exists('sexo', $data) ? $data['sexo'] : ""));
     DB::table("grupo_pregunta")->where('grupo_id', '=', $grupo_id)->delete();
     foreach ($data['preguntas'] as $pre) {
         DB::table("grupo_pregunta")->insert(array("pregunta_id" => $pre['id'], "grupo_id" => $grupo_id, "respuesta" => array_key_exists('respuesta', $pre) ? $pre['respuesta'] : "", "estado" => array_key_exists('estado', $pre) && $pre['estado'] == "true" ? 1 : ""));
     }
     $mensaje = new Mensaje();
     $mensaje->mensaje = array_key_exists('fb_url', $data) ? $data['fb_url'] : "";
     $mensaje->asunto = "Fan Page Actualizado";
     $mensaje->activista_id = Auth::user()->id;
     $mensaje->estado = 1;
     $mensaje->save();
     $respuesta = new Respuesta();
     $respuesta->mensaje_id = $mensaje->id;
     $respuesta->respondido_por = Auth::user()->id;
     $respuesta->respondido_at = date("Y-m-d H:i:s");
     $respuesta->respuesta = $data['titulo'] . ": " . $data['descripcion'];
     $respuesta->estado = 1;
     $respuesta->url = 1;
     $respuesta->save();
     // @todo manejar errores
     $results = array("code" => "ok", "message" => "Datos correctamente guardados");
     DB::commit();
     return Response::json($results);
 }
 public function postComunicacion()
 {
     $data = Input::all();
     if (!empty($data['envioEnMasa'])) {
         // mensaje enviado por libre para muchos grupos
         DB::beginTransaction();
         for ($i = 0; $i < count($data['nivelesSelecciondos']); $i++) {
             $idMensaje = DB::table("mensajes")->insertGetId(array('activista_id' => $this->userID, 'asunto' => array_key_exists('asunto', $data) ? $data['asunto'] : "", 'mensaje' => array_key_exists('mensaje', $data) ? $data['mensaje'] : "", 'estado' => 1, 'activo' => 1, 'cargo_id' => $data['nivelesSelecciondos'][$i], 'created_at' => date('Y-m-d H:i:s'), 'archivo_id' => array_key_exists('archivo_id', $data) ? $data['archivo_id'] : ""));
         }
         // registra la respuesta automaticamente
         /*$id = DB::table("respuestas")->insertGetId(array(
               'mensaje_id' => $idMensaje,
               'respondido_por' => $this->userID,
               'respondido_at' => date('Y-m-d H:i:s'),
               'respuesta' => $data['respuesta'],
               'cargo_id' => $data['acceso'],
               'estado' => 1,
               'created_at'=> date('Y-m-d H:i:s'),
           ));*/
         DB::commit();
         // @todo : agregar el guardar accesos cuando se haga para paginas , grupo de personas , etc
         // array $data['nivelesSelecciondos'] solo ids
         $results = array("code" => "ok", "message" => "Mensaje Enviado");
     } elseif (!empty($data['editar'])) {
         DB::beginTransaction();
         $id = 0;
         $mensajeAux = "";
         $mensaje = "";
         for ($i = 0; $i < count($data['nivelesSelecciondos']); $i++) {
             if ($i == 0) {
                 $mensajeAux = Mensaje::find($data['id']);
                 $mensajeAux->estado = 1;
                 $mensajeAux->archivo_id = array_key_exists('archivo_id', $data) ? $data['archivo_id'] : "";
                 $mensajeAux->reponsed_at = date('Y-m-d H:i:s');
                 $mensajeAux->updated_at = date('Y-m-d H:i:s');
                 $mensajeAux->cargo_id = $data['nivelesSelecciondos'][$i];
                 $mensajeAux->save();
                 $id = $mensajeAux->id;
             } else {
                 $mensaje = new Mensaje();
                 $mensaje->activista_id = $mensajeAux->activista_id;
                 $mensaje->asunto = $mensajeAux->asunto;
                 $mensaje->mensaje = $mensajeAux->mensaje;
                 $mensaje->estado = 1;
                 $mensaje->activo = 1;
                 $mensaje->archivo_id = array_key_exists('archivo_id', $data) ? $data['archivo_id'] : "";
                 $mensaje->reponsed_at = date('Y-m-d H:i:s');
                 $mensaje->updated_at = date('Y-m-d H:i:s');
                 $mensaje->cargo_id = $data['nivelesSelecciondos'][$i];
                 $mensaje->save();
                 $id = $mensaje->id;
             }
             $id = DB::table("respuestas")->insertGetId(array('mensaje_id' => $id, 'respondido_por' => $this->userID, 'respondido_at' => date('Y-m-d H:i:s'), 'respuesta' => $data['respuesta'], 'cargo_id' => $data['nivelesSelecciondos'][$i], 'archivo_id' => array_key_exists('respuesta_archivo_id', $data) ? $data['respuesta_archivo_id'] : "", 'estado' => 1, 'created_at' => date('Y-m-d H:i:s')));
         }
         DB::commit();
         $results = array("code" => "ok", "message" => "Datos correctamente guardados");
     } else {
         $id = DB::table("mensajes")->insertGetId(array('activista_id' => $this->userID, 'asunto' => array_key_exists('asunto', $data) ? $data['asunto'] : "", 'mensaje' => array_key_exists('mensaje', $data) ? $data['mensaje'] : "", 'estado' => 0, 'activo' => 1, 'created_at' => date('Y-m-d H:i:s'), 'archivo_id' => array_key_exists('archivo_id', $data) ? $data['archivo_id'] : ""));
         if ($id) {
             // @todo manejar errores
             $results = array("code" => "ok", "message" => "Datos correctamente guardados");
         }
     }
     return Response::json($results);
 }