Use this file to discover all available pages before exploring further.
The messaging module (modules/mensajes/) provides a fully internal, database-backed communication layer. There is no email integration — all messages live in the mensajes table and are consumed through the portal’s own inbox and conversation views. Role-based rules govern who can talk to whom, preventing unsolicited contact between unrelated clients and advisors.
Endpoint:POST modules/mensajes/enviar.phpenviar.php validates the recipient exists, enforces messaging-permission rules by role, and inserts the message row.Required fields:
The system enforces role-based restrictions on who each user type may contact:
Admin (ROL_ADMIN)
Unrestricted. May message any user on the platform.
Asesor (ROL_ASESOR)
May message admins, other asesores, or clients actively assigned to them in cliente_asesor.
Cliente (ROL_CLIENTE)
May only message their own assigned asesor. The assignment must be in estado = 'activo'.
if ($id_rol_remitente == ROL_CLIENTE) { if ($id_rol_destino != ROL_ASESOR) { sendResponse(403, "Solo puedes enviar mensajes a tu asesor asignado"); } $checkAsign = $conexion->prepare(" SELECT id_asignacion FROM cliente_asesor WHERE id_cliente = ? AND id_asesor = ? AND estado = 'activo' "); $checkAsign->execute([$id_remitente, $id_destinatario]); if (!$checkAsign->fetch()) { sendResponse(403, "No tienes un asesor asignado activo"); }}
Endpoint:GET modules/mensajes/listar.phpReturns all messages where the logged-in user is either the sender or the recipient, ordered by fecha_envio DESC. Each row includes a computed otro_usuario_correo field that resolves to the email of the other party in the conversation:
Endpoint:GET modules/mensajes/conversacion.phpRetrieves the chronological message thread between the logged-in user and a specified second user. Use this endpoint to render a chat-style view:
Endpoint:GET modules/mensajes/contactos.phpReturns the list of users the logged-in user is allowed to contact, respecting the role permission rules described above.
Endpoint:POST modules/mensajes/enviar_masivo.phpOnly ROL_ADMIN may call this endpoint. It inserts an identical 'Chat interno' message from the admin to every user matching the target role list in a single database transaction. The sending admin is excluded from the recipient list.Required fields:
Field
Type
Description
titulo
string
Subject / title prepended to the message
contenido
string
Body text of the broadcast
Optional fields:
Field
Type
Description
roles
int[]
Array of role IDs to target (default: [1, 2, 3] — all roles)
Request
Success Response (200)
{ "titulo": "Mantenimiento programado", "contenido": "El sistema estará en mantenimiento el sábado de 02:00 a 06:00 hrs.", "roles": [2, 3]}
{ "status": 200, "message": "Mensaje enviado a 18 usuarios"}
The stored message body is formatted as:
📢 {titulo}{contenido}
enviar_masivo.php wraps all inserts in a database transaction (beginTransaction / commit). If any insert fails, a rollBack() is performed and no partial messages are saved.