2014-12-01 23:55:08 +01:00
|
|
|
|
// swad_message.c: messages between users
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
SWAD (Shared Workspace At a Distance),
|
|
|
|
|
is a web platform developed at the University of Granada (Spain),
|
|
|
|
|
and used to support university teaching.
|
|
|
|
|
|
|
|
|
|
This file is part of SWAD core.
|
2018-04-24 13:21:53 +02:00
|
|
|
|
Copyright (C) 1999-2018 Antonio Ca<EFBFBD>as Vargas
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General Public License as
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************************* Headers ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2018-10-29 14:17:32 +01:00
|
|
|
|
#define _GNU_SOURCE // For asprintf
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <linux/limits.h> // For PATH_MAX
|
|
|
|
|
#include <linux/stddef.h> // For NULL
|
2018-10-29 14:17:32 +01:00
|
|
|
|
#include <stdio.h> // For asprintf
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <stdlib.h> // For free
|
|
|
|
|
#include <string.h> // For string functions
|
|
|
|
|
#include <time.h> // For time
|
|
|
|
|
|
|
|
|
|
#include "swad_action.h"
|
2017-06-10 21:38:10 +02:00
|
|
|
|
#include "swad_box.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_config.h"
|
|
|
|
|
#include "swad_course.h"
|
|
|
|
|
#include "swad_database.h"
|
2018-11-09 20:47:39 +01:00
|
|
|
|
#include "swad_form.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_forum.h"
|
|
|
|
|
#include "swad_global.h"
|
|
|
|
|
#include "swad_group.h"
|
2015-12-23 13:20:58 +01:00
|
|
|
|
#include "swad_ID.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_message.h"
|
|
|
|
|
#include "swad_notification.h"
|
|
|
|
|
#include "swad_parameter.h"
|
|
|
|
|
#include "swad_photo.h"
|
2015-03-14 17:39:04 +01:00
|
|
|
|
#include "swad_profile.h"
|
2017-06-11 20:09:59 +02:00
|
|
|
|
#include "swad_table.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_user.h"
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private constants *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-03-07 19:55:29 +01:00
|
|
|
|
#define Msg_MAX_BYTES_MESSAGES_QUERY (4 * 1024 - 1)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-04-10 14:09:50 +02:00
|
|
|
|
// Forum images will be saved with:
|
|
|
|
|
// - maximum width of Msg_IMAGE_SAVED_MAX_HEIGHT
|
|
|
|
|
// - maximum height of Msg_IMAGE_SAVED_MAX_HEIGHT
|
|
|
|
|
// - maintaining the original aspect ratio (aspect ratio recommended: 3:2)
|
|
|
|
|
#define Msg_IMAGE_SAVED_MAX_WIDTH 768
|
|
|
|
|
#define Msg_IMAGE_SAVED_MAX_HEIGHT 512
|
|
|
|
|
#define Msg_IMAGE_SAVED_QUALITY 75 // 1 to 100
|
|
|
|
|
|
2017-04-13 20:09:22 +02:00
|
|
|
|
static const Pag_WhatPaginate_t Msg_WhatPaginate[Msg_NUM_TYPES_OF_MSGS] =
|
|
|
|
|
{
|
|
|
|
|
Pag_MESSAGES_RECEIVED, // Msg_MESSAGES_RECEIVED
|
|
|
|
|
Pag_MESSAGES_SENT // Msg_MESSAGES_SENT
|
|
|
|
|
};
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************** Private types ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Internal prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-01-17 03:10:43 +01:00
|
|
|
|
static void Msg_PutFormMsgUsrs (char Content[Cns_MAX_BYTES_LONG_TEXT + 1]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-11-07 12:31:14 +01:00
|
|
|
|
static void Msg_ShowSentOrReceivedMessages (void);
|
2014-12-17 23:54:11 +01:00
|
|
|
|
static unsigned long Msg_GetNumUsrsBannedByMe (void);
|
2014-12-17 23:04:35 +01:00
|
|
|
|
static void Msg_PutLinkToViewBannedUsers(void);
|
2018-11-01 01:40:35 +01:00
|
|
|
|
static unsigned long Msg_GetSentOrReceivedMsgs (long UsrCod,
|
|
|
|
|
long FilterCrsCod,
|
|
|
|
|
const char *FilterFromToSubquery,
|
|
|
|
|
MYSQL_RES **mysql_res);
|
2016-03-21 13:41:15 +01:00
|
|
|
|
|
2016-11-07 12:31:14 +01:00
|
|
|
|
static char *Msg_WriteNumMsgs (unsigned NumUnreadMsgs);
|
|
|
|
|
|
|
|
|
|
static void Msg_PutIconsListMsgs (void);
|
2017-05-02 12:13:27 +02:00
|
|
|
|
static void Msg_PutHiddenParamsOneMsg (void);
|
2016-03-21 13:41:15 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Msg_ShowFormToShowOnlyUnreadMessages (void);
|
|
|
|
|
static void Msg_GetParamOnlyUnreadMsgs (void);
|
2016-11-07 12:31:14 +01:00
|
|
|
|
static void Msg_ShowASentOrReceivedMessage (long MsgNum,long MsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Msg_GetStatusOfSentMsg (long MsgCod,bool *Expanded);
|
|
|
|
|
static void Msg_GetStatusOfReceivedMsg (long MsgCod,bool *Open,bool *Replied,bool *Expanded);
|
|
|
|
|
static long Msg_GetParamMsgCod (void);
|
2015-12-23 13:20:58 +01:00
|
|
|
|
static void Msg_PutLinkToShowMorePotentialRecipients (void);
|
2015-12-23 11:05:32 +01:00
|
|
|
|
static void Msg_PutParamsShowMorePotentialRecipients (void);
|
2015-12-23 13:20:58 +01:00
|
|
|
|
static void Msg_ShowOneUniqueRecipient (void);
|
2015-12-22 13:22:35 +01:00
|
|
|
|
static void Msg_WriteFormUsrsIDsOrNicksOtherRecipients (void);
|
2017-01-17 03:10:43 +01:00
|
|
|
|
static void Msg_WriteFormSubjectAndContentMsgToUsrs (char Content[Cns_MAX_BYTES_LONG_TEXT + 1]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Msg_ShowNumMsgsDeleted (unsigned NumMsgs);
|
|
|
|
|
|
2017-03-07 19:55:29 +01:00
|
|
|
|
static void Msg_MakeFilterFromToSubquery (char FilterFromToSubquery[Msg_MAX_BYTES_MESSAGES_QUERY + 1]);
|
2015-04-12 01:40:51 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Msg_ExpandSentMsg (long MsgCod);
|
|
|
|
|
static void Msg_ExpandReceivedMsg (long MsgCod);
|
|
|
|
|
static void Msg_ContractSentMsg (long MsgCod);
|
|
|
|
|
static void Msg_ContractReceivedMsg (long MsgCod);
|
|
|
|
|
|
2016-04-10 19:19:20 +02:00
|
|
|
|
static long Msg_InsertNewMsg (const char *Subject,const char *Content,
|
|
|
|
|
struct Image *Image);
|
2015-03-11 00:36:12 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static unsigned long Msg_DelSomeRecOrSntMsgsUsr (Msg_TypeOfMessages_t TypeOfMessages,long UsrCod,
|
|
|
|
|
long FilterCrsCod,const char *FilterFromToSubquery);
|
|
|
|
|
static void Msg_InsertReceivedMsgIntoDB (long MsgCod,long UsrCod,bool NotifyByEmail);
|
|
|
|
|
static void Msg_SetReceivedMsgAsReplied (long MsgCod);
|
|
|
|
|
static void Msg_MoveReceivedMsgToDeleted (long MsgCod,long UsrCod);
|
|
|
|
|
static void Msg_MoveSentMsgToDeleted (long MsgCod);
|
|
|
|
|
static void Msg_MoveMsgContentToDeleted (long MsgCod);
|
|
|
|
|
static bool Msg_CheckIfSentMsgIsDeleted (long MsgCod);
|
|
|
|
|
static bool Msg_CheckIfReceivedMsgIsDeletedForAllItsRecipients (long MsgCod);
|
|
|
|
|
static unsigned Msg_GetNumUnreadMsgs (long FilterCrsCod,const char *FilterFromToSubquery);
|
|
|
|
|
|
2015-10-24 20:12:03 +02:00
|
|
|
|
static void Msg_GetMsgSntData (long MsgCod,long *CrsCod,long *UsrCod,
|
2017-01-17 03:10:43 +01:00
|
|
|
|
time_t *CreatTimeUTC,
|
|
|
|
|
char Subject[Cns_MAX_BYTES_SUBJECT + 1],
|
|
|
|
|
bool *Deleted);
|
|
|
|
|
static void Msg_GetMsgContent (long MsgCod,char Content[Cns_MAX_BYTES_LONG_TEXT + 1],
|
|
|
|
|
struct Image *Image);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-11-07 12:31:14 +01:00
|
|
|
|
static void Msg_WriteSentOrReceivedMsgSubject (long MsgCod,const char *Subject,bool Open,bool Expanded);
|
2016-07-01 01:21:34 +02:00
|
|
|
|
static void Msg_WriteFormToReply (long MsgCod,long CrsCod,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool ThisCrs,bool Replied,
|
2015-12-24 00:31:45 +01:00
|
|
|
|
const struct UsrData *UsrDat);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Msg_WriteMsgFrom (struct UsrData *UsrDat,bool Deleted);
|
2016-11-07 12:31:14 +01:00
|
|
|
|
static void Msg_WriteMsgTo (long MsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
static void Msg_PutFormToBanSender (struct UsrData *UsrDat);
|
|
|
|
|
static void Msg_PutFormToUnbanSender (struct UsrData *UsrDat);
|
|
|
|
|
static void Msg_UnbanSender (void);
|
|
|
|
|
static bool Msg_CheckIfUsrIsBanned (long FromUsrCod,long ToUsrCod);
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Put a form to write a new message to users ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_FormMsgUsrs (void)
|
|
|
|
|
{
|
2017-01-17 03:10:43 +01:00
|
|
|
|
char Content[Cns_MAX_BYTES_LONG_TEXT + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-07-01 14:40:01 +02:00
|
|
|
|
/***** Get possible hidden subject and content of the message *****/
|
|
|
|
|
Par_GetParToHTML ("HiddenSubject",Gbl.Msg.Subject,Cns_MAX_BYTES_SUBJECT);
|
|
|
|
|
Par_GetParAndChangeFormat ("HiddenContent",Content,Cns_MAX_BYTES_LONG_TEXT,
|
2016-07-01 01:21:34 +02:00
|
|
|
|
Str_TO_TEXT,false);
|
|
|
|
|
|
2017-03-15 11:10:16 +01:00
|
|
|
|
/***** Show a form to compose a message to users *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Msg_PutFormMsgUsrs (Content);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Put a form to write a new message to users ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-01-17 03:10:43 +01:00
|
|
|
|
static void Msg_PutFormMsgUsrs (char Content[Cns_MAX_BYTES_LONG_TEXT + 1])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-11-23 13:55:27 +01:00
|
|
|
|
extern const char *Hlp_MESSAGES_Write;
|
2015-07-28 00:16:09 +02:00
|
|
|
|
extern const char *The_ClassForm[The_NUM_THEMES];
|
2015-12-22 13:22:35 +01:00
|
|
|
|
extern const char *Txt_Reply_message;
|
2015-04-11 13:28:43 +02:00
|
|
|
|
extern const char *Txt_New_message;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_MSG_To;
|
|
|
|
|
extern const char *Txt_Send_message;
|
2016-11-25 09:41:06 +01:00
|
|
|
|
unsigned NumUsrsInCrs = 0; // Initialized to avoid warning
|
2016-07-04 17:52:09 +02:00
|
|
|
|
bool ShowUsrsInCrs = false;
|
2016-11-25 03:21:02 +01:00
|
|
|
|
bool GetUsrsInCrs;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-05-22 14:52:11 +02:00
|
|
|
|
Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs =
|
|
|
|
|
Gbl.Usrs.LstUsrs[Rol_NET].NumUsrs =
|
|
|
|
|
Gbl.Usrs.LstUsrs[Rol_TCH].NumUsrs = 0;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get parameter that indicates if the message is a reply to another message *****/
|
2017-01-28 20:32:50 +01:00
|
|
|
|
if ((Gbl.Msg.Reply.IsReply = Par_GetParToBool ("IsReply")))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/* Get original message code */
|
2016-06-30 21:05:06 +02:00
|
|
|
|
if ((Gbl.Msg.Reply.OriginalMsgCod = Msg_GetParamMsgCod ()) <= 0)
|
|
|
|
|
Lay_ShowErrorAndExit ("Wrong code of message.");
|
2015-12-22 13:22:35 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get user's code of possible preselected recipient *****/
|
2015-12-23 13:20:58 +01:00
|
|
|
|
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ()) // There is a preselected recipient
|
2015-12-22 14:00:36 +01:00
|
|
|
|
/* Get who to show as potential recipients:
|
|
|
|
|
- only the selected recipient
|
|
|
|
|
- any user (default) */
|
2017-01-28 20:32:50 +01:00
|
|
|
|
Gbl.Msg.ShowOnlyOneRecipient = Par_GetParToBool ("ShowOnlyOneRecipient");
|
2016-07-04 17:40:34 +02:00
|
|
|
|
else
|
|
|
|
|
Gbl.Msg.ShowOnlyOneRecipient = false;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-11-25 03:21:02 +01:00
|
|
|
|
GetUsrsInCrs = !Gbl.Msg.ShowOnlyOneRecipient && // Show list of potential recipients
|
|
|
|
|
(Gbl.Usrs.Me.IBelongToCurrentCrs || // If there is a course selected and I belong to it
|
2017-06-04 18:18:54 +02:00
|
|
|
|
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM);
|
2016-11-25 03:21:02 +01:00
|
|
|
|
if (GetUsrsInCrs)
|
|
|
|
|
{
|
|
|
|
|
/***** Get and update type of list,
|
|
|
|
|
number of columns in class photo
|
|
|
|
|
and preference about view photos *****/
|
|
|
|
|
Usr_GetAndUpdatePrefsAboutUsrList ();
|
|
|
|
|
|
|
|
|
|
/***** Get groups to show ******/
|
|
|
|
|
Grp_GetParCodsSeveralGrpsToShowUsrs ();
|
|
|
|
|
|
|
|
|
|
/***** Get and order lists of users from this course *****/
|
2017-05-25 19:57:34 +02:00
|
|
|
|
Usr_GetListUsrs (Sco_SCOPE_CRS,Rol_STD);
|
|
|
|
|
Usr_GetListUsrs (Sco_SCOPE_CRS,Rol_NET);
|
|
|
|
|
Usr_GetListUsrs (Sco_SCOPE_CRS,Rol_TCH);
|
2017-05-22 14:52:11 +02:00
|
|
|
|
NumUsrsInCrs = Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs + // Students
|
|
|
|
|
Gbl.Usrs.LstUsrs[Rol_NET].NumUsrs + // Non-editing teachers
|
|
|
|
|
Gbl.Usrs.LstUsrs[Rol_TCH].NumUsrs; // Teachers
|
2016-11-25 03:21:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** Start box *****/
|
2017-06-11 22:26:40 +02:00
|
|
|
|
Box_StartBox (NULL,Gbl.Msg.Reply.IsReply ? Txt_Reply_message :
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Txt_New_message,NULL,
|
|
|
|
|
Hlp_MESSAGES_Write,Box_NOT_CLOSABLE);
|
2015-10-02 01:04:28 +02:00
|
|
|
|
|
2016-07-04 14:03:04 +02:00
|
|
|
|
if (Gbl.Msg.ShowOnlyOneRecipient)
|
2016-07-04 17:03:02 +02:00
|
|
|
|
/***** Form to show several potential recipients *****/
|
2016-07-04 14:03:04 +02:00
|
|
|
|
Msg_PutLinkToShowMorePotentialRecipients ();
|
2016-07-04 17:40:34 +02:00
|
|
|
|
else
|
2016-07-04 17:03:02 +02:00
|
|
|
|
{
|
2016-07-04 17:40:34 +02:00
|
|
|
|
/***** Get list of users belonging to the current course *****/
|
2016-07-04 18:17:53 +02:00
|
|
|
|
if (GetUsrsInCrs)
|
2016-07-04 17:40:34 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Form to select groups *****/
|
2017-07-02 18:53:35 +02:00
|
|
|
|
Grp_ShowFormToSelectSeveralGroups (ActReqMsgUsr,
|
|
|
|
|
Grp_ALL_GROUPS); // All groups are selectable to send a message
|
2017-05-25 11:04:38 +02:00
|
|
|
|
|
|
|
|
|
/***** Start section with user list *****/
|
2017-05-25 13:43:54 +02:00
|
|
|
|
Lay_StartSection (Usr_USER_LIST_SECTION_ID);
|
2016-07-04 17:40:34 +02:00
|
|
|
|
|
2016-07-04 17:52:09 +02:00
|
|
|
|
if (NumUsrsInCrs)
|
2016-07-04 17:40:34 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Form to select type of list used for select several users *****/
|
|
|
|
|
Usr_ShowFormsToSelectUsrListType (ActReqMsgUsr);
|
|
|
|
|
|
2017-05-29 21:34:43 +02:00
|
|
|
|
/***** Put link to register students *****/
|
|
|
|
|
Enr_CheckStdsAndPutButtonToRegisterStdsInCurrentCrs ();
|
|
|
|
|
|
2016-07-04 17:40:34 +02:00
|
|
|
|
/***** Check if it's a big list *****/
|
2016-07-04 17:52:09 +02:00
|
|
|
|
ShowUsrsInCrs = Usr_GetIfShowBigList (NumUsrsInCrs,"CopyMessageToHiddenFields()");
|
2016-07-04 17:40:34 +02:00
|
|
|
|
|
2016-07-04 17:52:09 +02:00
|
|
|
|
if (ShowUsrsInCrs)
|
2016-07-04 17:40:34 +02:00
|
|
|
|
/***** Get lists of selected users *****/
|
|
|
|
|
Usr_GetListsSelectedUsrsCods ();
|
|
|
|
|
}
|
2017-05-25 11:04:38 +02:00
|
|
|
|
|
|
|
|
|
/***** End section with user list *****/
|
2017-05-25 13:43:54 +02:00
|
|
|
|
Lay_EndSection ();
|
2016-07-04 18:17:53 +02:00
|
|
|
|
}
|
2016-07-04 17:40:34 +02:00
|
|
|
|
|
2016-07-04 18:17:53 +02:00
|
|
|
|
/***** Get list of users' IDs or nicknames written explicitely *****/
|
|
|
|
|
Usr_GetListMsgRecipientsWrittenExplicitelyBySender (false);
|
2016-07-04 17:03:02 +02:00
|
|
|
|
}
|
2015-12-23 11:05:32 +01:00
|
|
|
|
|
2016-07-04 14:03:04 +02:00
|
|
|
|
/***** Start form to select recipients and write the message *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActRcvMsgUsr);
|
2016-07-04 14:03:04 +02:00
|
|
|
|
if (Gbl.Msg.Reply.IsReply)
|
|
|
|
|
{
|
|
|
|
|
Par_PutHiddenParamChar ("IsReply",'Y');
|
|
|
|
|
Msg_PutHiddenParamMsgCod (Gbl.Msg.Reply.OriginalMsgCod);
|
|
|
|
|
}
|
|
|
|
|
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
|
|
|
|
|
{
|
|
|
|
|
Usr_PutParamOtherUsrCodEncrypted ();
|
|
|
|
|
if (Gbl.Msg.ShowOnlyOneRecipient)
|
|
|
|
|
Par_PutHiddenParamChar ("ShowOnlyOneRecipient",'Y');
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-07-04 14:03:04 +02:00
|
|
|
|
/***** Start table *****/
|
2017-06-11 20:09:59 +02:00
|
|
|
|
Tbl_StartTableCenter (2);
|
2015-12-22 14:00:36 +01:00
|
|
|
|
|
2016-07-04 14:03:04 +02:00
|
|
|
|
/***** "To:" section (recipients) *****/
|
2016-07-04 17:52:09 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
|
|
|
|
"<td class=\"%s RIGHT_TOP\">"
|
|
|
|
|
"%s:"
|
|
|
|
|
"</td>"
|
|
|
|
|
"<td class=\"LEFT_TOP\">",
|
|
|
|
|
The_ClassForm[Gbl.Prefs.Theme],Txt_MSG_To);
|
|
|
|
|
if (Gbl.Msg.ShowOnlyOneRecipient)
|
|
|
|
|
/***** Show only one user as recipient *****/
|
|
|
|
|
Msg_ShowOneUniqueRecipient ();
|
|
|
|
|
else
|
2016-07-04 14:03:04 +02:00
|
|
|
|
{
|
2016-07-04 17:52:09 +02:00
|
|
|
|
/***** Show potential recipients *****/
|
2017-06-11 20:09:59 +02:00
|
|
|
|
Tbl_StartTableWide (0);
|
2016-07-04 17:52:09 +02:00
|
|
|
|
if (ShowUsrsInCrs)
|
2016-07-04 17:03:02 +02:00
|
|
|
|
{
|
2017-05-18 19:13:41 +02:00
|
|
|
|
Usr_ListUsersToSelect (Rol_TCH); // All teachers in course
|
2017-05-22 14:52:11 +02:00
|
|
|
|
Usr_ListUsersToSelect (Rol_NET); // All non-editing teachers in course
|
2017-05-18 19:13:41 +02:00
|
|
|
|
Usr_ListUsersToSelect (Rol_STD); // All students in selected groups
|
2016-07-04 17:03:02 +02:00
|
|
|
|
}
|
2016-07-04 17:52:09 +02:00
|
|
|
|
Msg_WriteFormUsrsIDsOrNicksOtherRecipients (); // Other users (nicknames)
|
2017-06-11 20:09:59 +02:00
|
|
|
|
Tbl_EndTable ();
|
2016-07-04 17:03:02 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-07-04 17:52:09 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"</td>"
|
|
|
|
|
"</tr>");
|
|
|
|
|
|
2016-07-04 14:03:04 +02:00
|
|
|
|
/***** Subject and content sections *****/
|
|
|
|
|
Msg_WriteFormSubjectAndContentMsgToUsrs (Content);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-07-04 14:03:04 +02:00
|
|
|
|
/***** End table *****/
|
2017-06-11 20:09:59 +02:00
|
|
|
|
Tbl_EndTable ();
|
2015-04-11 13:28:43 +02:00
|
|
|
|
|
2016-07-04 14:03:04 +02:00
|
|
|
|
/***** Help for text editor and send button *****/
|
|
|
|
|
Lay_HelpPlainEditor ();
|
2016-04-09 18:36:39 +02:00
|
|
|
|
|
2016-07-04 14:03:04 +02:00
|
|
|
|
/***** Attached image (optional) *****/
|
|
|
|
|
Img_PutImageUploader (-1,"MSG_IMG_TIT_URL");
|
2016-04-10 14:09:50 +02:00
|
|
|
|
|
2016-07-04 14:03:04 +02:00
|
|
|
|
/***** Send button *****/
|
2017-06-11 19:02:40 +02:00
|
|
|
|
Btn_PutCreateButton (Txt_Send_message);
|
2015-04-11 13:28:43 +02:00
|
|
|
|
|
2016-07-04 14:03:04 +02:00
|
|
|
|
/***** End form *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2015-10-02 01:04:28 +02:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_EndBox ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free memory used by the list of nicknames *****/
|
|
|
|
|
Usr_FreeListOtherRecipients ();
|
|
|
|
|
|
|
|
|
|
/***** Free memory used for by the lists of users *****/
|
2016-07-04 18:17:53 +02:00
|
|
|
|
if (GetUsrsInCrs)
|
|
|
|
|
{
|
2017-05-18 19:13:41 +02:00
|
|
|
|
Usr_FreeUsrsList (Rol_TCH);
|
2017-05-22 14:52:11 +02:00
|
|
|
|
Usr_FreeUsrsList (Rol_NET);
|
2017-05-18 19:13:41 +02:00
|
|
|
|
Usr_FreeUsrsList (Rol_STD);
|
2016-07-04 18:17:53 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-07-04 14:03:04 +02:00
|
|
|
|
/***** Free memory used by list of selected users' codes *****/
|
|
|
|
|
Usr_FreeListsSelectedUsrsCods ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free memory for list of selected groups *****/
|
|
|
|
|
Grp_FreeListCodSelectedGrps ();
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-23 13:20:58 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********** Put contextual link to show more potential recipients ************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Msg_PutLinkToShowMorePotentialRecipients (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Show_more_recipients;
|
|
|
|
|
|
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">");
|
2017-04-17 19:03:21 +02:00
|
|
|
|
Lay_PutContextualLink (ActReqMsgUsr,NULL,
|
|
|
|
|
Msg_PutParamsShowMorePotentialRecipients,
|
2015-12-23 13:20:58 +01:00
|
|
|
|
"usrs64x64.gif",
|
2016-07-01 16:32:42 +02:00
|
|
|
|
Txt_Show_more_recipients,Txt_Show_more_recipients,
|
2016-07-01 17:13:41 +02:00
|
|
|
|
"CopyMessageToHiddenFields()");
|
2015-12-23 13:20:58 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</div>");
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-23 11:05:32 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************ Put parameters to show more potential recipients ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Msg_PutParamsShowMorePotentialRecipients (void)
|
|
|
|
|
{
|
|
|
|
|
if (Gbl.Msg.Reply.IsReply)
|
|
|
|
|
{
|
|
|
|
|
Par_PutHiddenParamChar ("IsReply",'Y');
|
|
|
|
|
Msg_PutHiddenParamMsgCod (Gbl.Msg.Reply.OriginalMsgCod);
|
|
|
|
|
}
|
2015-12-24 00:31:45 +01:00
|
|
|
|
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
|
|
|
|
|
Usr_PutParamOtherUsrCodEncrypted ();
|
2016-06-30 21:05:06 +02:00
|
|
|
|
|
2016-07-01 14:40:01 +02:00
|
|
|
|
/***** Hidden params to send subject and content *****/
|
|
|
|
|
Msg_PutHiddenParamsSubjectAndContent ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********** Put hidden parameters with message subject and content ***********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_PutHiddenParamsSubjectAndContent (void)
|
|
|
|
|
{
|
2016-07-01 01:21:34 +02:00
|
|
|
|
/***** Hidden params to send subject and content.
|
|
|
|
|
When the user edit the subject or the content,
|
|
|
|
|
they are copied here. *****/
|
2016-07-01 14:40:01 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<input type=\"hidden\" name=\"HiddenSubject\" value=\"\" />"
|
|
|
|
|
"<input type=\"hidden\" name=\"HiddenContent\" value=\"\" />");
|
2015-12-23 11:05:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-23 13:20:58 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************ Put parameters to show more potential recipients ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Msg_ShowOneUniqueRecipient (void)
|
|
|
|
|
{
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char PhotoURL[PATH_MAX + 1];
|
2015-12-23 13:20:58 +01:00
|
|
|
|
bool ShowPhoto;
|
|
|
|
|
|
|
|
|
|
/***** Show user's photo *****/
|
2017-01-28 15:58:46 +01:00
|
|
|
|
ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&Gbl.Usrs.Other.UsrDat,PhotoURL);
|
2015-12-23 13:20:58 +01:00
|
|
|
|
Pho_ShowUsrPhoto (&Gbl.Usrs.Other.UsrDat,ShowPhoto ? PhotoURL :
|
|
|
|
|
NULL,
|
2016-01-14 10:31:09 +01:00
|
|
|
|
"PHOTO21x28",Pho_ZOOM,false);
|
2015-12-23 13:20:58 +01:00
|
|
|
|
|
|
|
|
|
/****** Write user's IDs ******/
|
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"MSG_TO_ONE_RCP %s\">",
|
|
|
|
|
Gbl.Usrs.Other.UsrDat.Accepted ? "DAT_SMALL_NOBR_N" :
|
|
|
|
|
"DAT_SMALL_NOBR");
|
2017-05-09 20:56:02 +02:00
|
|
|
|
ID_WriteUsrIDs (&Gbl.Usrs.Other.UsrDat,NULL);
|
2015-12-23 13:20:58 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</div>");
|
|
|
|
|
|
|
|
|
|
/***** Write user's name *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"MSG_TO_ONE_RCP %s\">%s</div>",
|
|
|
|
|
Gbl.Usrs.Other.UsrDat.Accepted ? "DAT_SMALL_NOBR_N" :
|
|
|
|
|
"DAT_SMALL_NOBR",
|
|
|
|
|
Gbl.Usrs.Other.UsrDat.FullName);
|
2015-12-24 00:31:45 +01:00
|
|
|
|
|
|
|
|
|
/***** Hidden parameter with user's nickname *****/
|
|
|
|
|
Msg_PutHiddenParamAnotherRecipient (&Gbl.Usrs.Other.UsrDat);
|
2015-12-23 13:20:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Nicknames of recipients of a message to users ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-12-22 13:22:35 +01:00
|
|
|
|
static void Msg_WriteFormUsrsIDsOrNicksOtherRecipients (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Other_recipients;
|
|
|
|
|
extern const char *Txt_Recipients;
|
|
|
|
|
extern const char *Txt_nicks_emails_or_IDs_separated_by_commas;
|
2017-03-07 01:56:41 +01:00
|
|
|
|
char Nickname[Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA + 1];
|
2015-12-24 00:31:45 +01:00
|
|
|
|
unsigned Colspan;
|
2016-12-27 13:56:44 +01:00
|
|
|
|
bool StdsAndTchsWritten = Gbl.CurrentCrs.Crs.CrsCod > 0 && // If there is a course selected
|
|
|
|
|
(Gbl.Usrs.Me.IBelongToCurrentCrs || // I belong to it
|
2017-06-04 18:18:54 +02:00
|
|
|
|
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM);
|
2015-12-24 00:31:45 +01:00
|
|
|
|
|
2016-12-27 13:56:44 +01:00
|
|
|
|
/***** How many columns? *****/
|
|
|
|
|
if (StdsAndTchsWritten)
|
2015-12-24 00:31:45 +01:00
|
|
|
|
Colspan = Usr_GetColumnsForSelectUsrs ();
|
2016-12-27 13:56:44 +01:00
|
|
|
|
else
|
|
|
|
|
Colspan = 1;
|
|
|
|
|
|
|
|
|
|
/***** Title *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
|
|
|
|
"<th");
|
|
|
|
|
if (Colspan > 1)
|
|
|
|
|
fprintf (Gbl.F.Out," colspan=\"%u\"",Colspan);
|
|
|
|
|
fprintf (Gbl.F.Out," class=\"LEFT_MIDDLE LIGHT_BLUE\">"
|
|
|
|
|
"<label for=\"OtherRecipients\">%s:</label>"
|
|
|
|
|
"</th>"
|
|
|
|
|
"</tr>",
|
|
|
|
|
StdsAndTchsWritten ? Txt_Other_recipients :
|
|
|
|
|
Txt_Recipients);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-11-16 23:19:52 +01:00
|
|
|
|
/***** Textarea with users' @nicknames, emails or IDs *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2016-04-09 18:36:39 +02:00
|
|
|
|
"<td");
|
2016-12-27 13:56:44 +01:00
|
|
|
|
if (Colspan > 1)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
fprintf (Gbl.F.Out," colspan=\"%u\"",Colspan);
|
2015-08-06 14:16:11 +02:00
|
|
|
|
fprintf (Gbl.F.Out," class=\"LEFT_MIDDLE\">"
|
2016-12-27 13:56:44 +01:00
|
|
|
|
"<textarea id=\"OtherRecipients\" name=\"OtherRecipients\""
|
2017-04-17 14:18:57 +02:00
|
|
|
|
" class=\"MSG_RECIPIENTS\" rows=\"2\""
|
2016-12-27 13:56:44 +01:00
|
|
|
|
" placeholder=\"%s\">",
|
2016-04-09 18:36:39 +02:00
|
|
|
|
Txt_nicks_emails_or_IDs_separated_by_commas);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Gbl.Usrs.ListOtherRecipients[0])
|
|
|
|
|
fprintf (Gbl.F.Out,"%s",Gbl.Usrs.ListOtherRecipients);
|
2015-12-24 00:31:45 +01:00
|
|
|
|
else if (Gbl.Usrs.Other.UsrDat.UsrCod > 0) // If there is a recipient
|
|
|
|
|
// and there's no list of explicit recipients,
|
|
|
|
|
// write @nickname of original sender
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Nck_GetNicknameFromUsrCod (Gbl.Usrs.Other.UsrDat.UsrCod,Nickname))
|
|
|
|
|
fprintf (Gbl.F.Out,"@%s",Nickname);
|
|
|
|
|
fprintf (Gbl.F.Out,"</textarea>"
|
|
|
|
|
"</td>"
|
|
|
|
|
"</tr>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****** Write form fields with subject and content of a message to users *****/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-01-17 03:10:43 +01:00
|
|
|
|
static void Msg_WriteFormSubjectAndContentMsgToUsrs (char Content[Cns_MAX_BYTES_LONG_TEXT + 1])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2015-07-28 00:16:09 +02:00
|
|
|
|
extern const char *The_ClassForm[The_NUM_THEMES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_MSG_Subject;
|
2017-04-19 14:27:52 +02:00
|
|
|
|
extern const char *Txt_MSG_Content;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Original_message;
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned long NumRows;
|
2016-06-30 21:05:06 +02:00
|
|
|
|
long MsgCod;
|
2016-07-01 01:21:34 +02:00
|
|
|
|
bool SubjectAndContentComeFromForm = (Gbl.Msg.Subject[0] || Content[0]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-06-30 21:05:06 +02:00
|
|
|
|
/***** Get possible code (of original message if it's a reply) *****/
|
|
|
|
|
MsgCod = Msg_GetParamMsgCod ();
|
|
|
|
|
|
2016-12-24 14:05:59 +01:00
|
|
|
|
/***** Message subject *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2016-12-24 14:05:59 +01:00
|
|
|
|
"<td class=\"RIGHT_TOP\">"
|
|
|
|
|
"<label for=\"MsgSubject\" class=\"%s\">"
|
2016-12-26 18:35:52 +01:00
|
|
|
|
"%s:"
|
2016-12-24 14:05:59 +01:00
|
|
|
|
"</label>"
|
2014-12-23 17:12:45 +01:00
|
|
|
|
"</td>"
|
2015-08-06 14:16:11 +02:00
|
|
|
|
"<td class=\"LEFT_MIDDLE\">"
|
2016-06-30 21:05:06 +02:00
|
|
|
|
"<textarea id=\"MsgSubject\" name=\"Subject\""
|
2017-04-17 14:18:57 +02:00
|
|
|
|
" class=\"MSG_SUBJECT\" rows=\"2\">",
|
2015-07-28 00:16:09 +02:00
|
|
|
|
The_ClassForm[Gbl.Prefs.Theme],
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Txt_MSG_Subject);
|
|
|
|
|
|
2016-12-24 14:05:59 +01:00
|
|
|
|
/* If message is a reply ==> get original message */
|
2016-06-30 21:05:06 +02:00
|
|
|
|
if (MsgCod > 0) // It's a reply
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-07-01 01:21:34 +02:00
|
|
|
|
if (!SubjectAndContentComeFromForm)
|
|
|
|
|
{
|
2016-12-24 14:05:59 +01:00
|
|
|
|
/* Get subject and content of message from database */
|
2018-11-01 01:40:35 +01:00
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get message content",
|
|
|
|
|
"SELECT Subject,Content FROM msg_content"
|
|
|
|
|
" WHERE MsgCod=%ld",MsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-12-24 14:05:59 +01:00
|
|
|
|
/* Result should have a unique row */
|
2016-07-01 01:21:34 +02:00
|
|
|
|
if (NumRows != 1)
|
|
|
|
|
Lay_ShowErrorAndExit ("Error when getting message.");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-07-01 01:21:34 +02:00
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2016-06-30 21:05:06 +02:00
|
|
|
|
|
2016-07-01 01:21:34 +02:00
|
|
|
|
/* Get subject */
|
2017-01-17 03:10:43 +01:00
|
|
|
|
Str_Copy (Gbl.Msg.Subject,row[0],
|
|
|
|
|
Cns_MAX_BYTES_SUBJECT);
|
2016-07-01 01:21:34 +02:00
|
|
|
|
|
|
|
|
|
/* Get content */
|
2017-01-17 03:10:43 +01:00
|
|
|
|
Str_Copy (Content,row[1],
|
|
|
|
|
Cns_MAX_BYTES_LONG_TEXT);
|
2016-07-01 01:21:34 +02:00
|
|
|
|
|
2016-12-24 14:05:59 +01:00
|
|
|
|
/* Free structure that stores the query result */
|
2016-07-01 01:21:34 +02:00
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-24 14:05:59 +01:00
|
|
|
|
/* Write subject */
|
2016-07-01 01:21:34 +02:00
|
|
|
|
if (!SubjectAndContentComeFromForm)
|
|
|
|
|
fprintf (Gbl.F.Out,"Re: ");
|
|
|
|
|
fprintf (Gbl.F.Out,"%s"
|
|
|
|
|
"</textarea>"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</td>"
|
2016-07-01 01:21:34 +02:00
|
|
|
|
"</tr>",
|
|
|
|
|
Gbl.Msg.Subject);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-12-24 14:05:59 +01:00
|
|
|
|
/***** Message content *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2016-12-24 14:05:59 +01:00
|
|
|
|
"<td class=\"RIGHT_TOP\">"
|
|
|
|
|
"<label for=\"MsgContent\" class=\"%s\">"
|
2016-12-26 18:35:52 +01:00
|
|
|
|
"%s:"
|
2016-12-24 14:05:59 +01:00
|
|
|
|
"</label>"
|
2014-12-23 17:12:45 +01:00
|
|
|
|
"</td>"
|
2015-08-06 14:16:11 +02:00
|
|
|
|
"<td class=\"LEFT_MIDDLE\">"
|
2016-07-01 01:21:34 +02:00
|
|
|
|
"<textarea id=\"MsgContent\" name=\"Content\""
|
2017-04-17 14:18:57 +02:00
|
|
|
|
" class=\"MSG_CONTENT\" rows=\"20\">",
|
2017-04-19 14:27:52 +02:00
|
|
|
|
The_ClassForm[Gbl.Prefs.Theme],Txt_MSG_Content);
|
2016-07-01 12:57:35 +02:00
|
|
|
|
|
|
|
|
|
/* Start textarea with a '\n', that will be not visible in textarea.
|
|
|
|
|
When Content is "\nLorem ipsum" (a white line before "Lorem ipsum"),
|
|
|
|
|
if we don't put the initial '\n' ==> the form will be sent starting
|
|
|
|
|
by "Lorem", without the white line */
|
|
|
|
|
fprintf (Gbl.F.Out,"\n");
|
|
|
|
|
|
2016-07-01 01:21:34 +02:00
|
|
|
|
if (!SubjectAndContentComeFromForm)
|
2016-07-01 12:57:35 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"\n\n----- %s -----\n",
|
2016-07-01 01:21:34 +02:00
|
|
|
|
Txt_Original_message);
|
2016-07-01 12:57:35 +02:00
|
|
|
|
|
2016-07-01 01:21:34 +02:00
|
|
|
|
Msg_WriteMsgContent (Content,Cns_MAX_BYTES_LONG_TEXT,false,true);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else // It's not a reply
|
|
|
|
|
{
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/* End message subject */
|
2014-12-01 23:55:08 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"%s</textarea>"
|
|
|
|
|
"</td>"
|
|
|
|
|
"</tr>",
|
|
|
|
|
Gbl.Msg.Subject);
|
|
|
|
|
|
2016-12-24 14:05:59 +01:00
|
|
|
|
/***** Message content *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2016-12-24 14:05:59 +01:00
|
|
|
|
"<td class=\"RIGHT_TOP\">"
|
|
|
|
|
"<label for=\"MsgContent\" class=\"%s\">"
|
2016-12-26 18:35:52 +01:00
|
|
|
|
"%s:"
|
2016-12-24 14:05:59 +01:00
|
|
|
|
"</label>"
|
|
|
|
|
"</td>"
|
2015-08-06 14:16:11 +02:00
|
|
|
|
"<td class=\"LEFT_MIDDLE\">"
|
2016-07-01 01:21:34 +02:00
|
|
|
|
"<textarea id=\"MsgContent\" name=\"Content\""
|
2017-04-17 14:18:57 +02:00
|
|
|
|
" class=\"MSG_CONTENT\" rows=\"20\">",
|
2015-07-28 00:16:09 +02:00
|
|
|
|
The_ClassForm[Gbl.Prefs.Theme],
|
2017-04-19 14:27:52 +02:00
|
|
|
|
Txt_MSG_Content);
|
2016-07-01 12:57:35 +02:00
|
|
|
|
|
|
|
|
|
/* Start textarea with a '\n', that will be not visible in textarea.
|
|
|
|
|
When Content is "\nLorem ipsum" (a white line before "Lorem ipsum"),
|
|
|
|
|
if we don't put the initial '\n' ==> the form will be sent starting
|
|
|
|
|
by "Lorem", without the white line */
|
|
|
|
|
fprintf (Gbl.F.Out,"\n%s",Content);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
fprintf (Gbl.F.Out,"</textarea>"
|
|
|
|
|
"</td>"
|
|
|
|
|
"</tr>");
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-03 19:21:59 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********* Put hidden parameter for another recipient (one nickname) *********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_PutHiddenParamAnotherRecipient (const struct UsrData *UsrDat)
|
|
|
|
|
{
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char NicknameWithArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
|
2015-03-03 19:21:59 +01:00
|
|
|
|
|
2018-10-18 02:02:32 +02:00
|
|
|
|
snprintf (NicknameWithArroba,sizeof (NicknameWithArroba),
|
|
|
|
|
"@%s",
|
|
|
|
|
UsrDat->Nickname);
|
2015-03-03 19:21:59 +01:00
|
|
|
|
Par_PutHiddenParamString ("OtherRecipients",NicknameWithArroba);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********* Put hidden parameter for another recipient (one nickname) *********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_PutHiddenParamOtherRecipients (void)
|
|
|
|
|
{
|
|
|
|
|
if (Gbl.Usrs.ListOtherRecipients)
|
|
|
|
|
if (Gbl.Usrs.ListOtherRecipients[0])
|
|
|
|
|
Par_PutHiddenParamString ("OtherRecipients",Gbl.Usrs.ListOtherRecipients);
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Receive a new message from a user ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_RecMsgFromUsr (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_You_can_not_send_a_message_to_so_many_recipients_;
|
|
|
|
|
extern const char *Txt_You_must_select_one_ore_more_recipients;
|
|
|
|
|
extern const char *Txt_message_not_sent_to_X;
|
2016-11-16 23:19:52 +01:00
|
|
|
|
extern const char *Txt_message_sent_to_X_notified_by_email;
|
|
|
|
|
extern const char *Txt_message_sent_to_X_not_notified_by_email;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Error_getting_data_from_a_recipient;
|
|
|
|
|
extern const char *Txt_The_message_has_not_been_sent_to_any_recipient;
|
|
|
|
|
extern const char *Txt_The_message_has_been_sent_to_1_recipient;
|
|
|
|
|
extern const char *Txt_The_message_has_been_sent_to_X_recipients;
|
|
|
|
|
extern const char *Txt_There_have_been_X_errors_in_sending_the_message;
|
|
|
|
|
bool IsReply;
|
|
|
|
|
bool RecipientHasBannedMe;
|
|
|
|
|
bool Replied = false;
|
2015-12-22 13:22:35 +01:00
|
|
|
|
long OriginalMsgCod = -1L; // Initialized to avoid warning
|
2014-12-01 23:55:08 +01:00
|
|
|
|
const char *Ptr;
|
|
|
|
|
unsigned NumRecipients;
|
|
|
|
|
unsigned NumRecipientsToBeNotifiedByEMail = 0;
|
|
|
|
|
struct UsrData UsrDstData;
|
|
|
|
|
int NumErrors = 0;
|
2015-12-22 13:22:35 +01:00
|
|
|
|
long NewMsgCod = -1L; // Initiliazed to avoid warning
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool MsgAlreadyInserted = false;
|
|
|
|
|
bool CreateNotif;
|
|
|
|
|
bool NotifyByEmail;
|
2017-01-17 03:10:43 +01:00
|
|
|
|
char Content[Cns_MAX_BYTES_LONG_TEXT + 1];
|
2016-04-10 14:09:50 +02:00
|
|
|
|
struct Image Image;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool Error = false;
|
|
|
|
|
|
|
|
|
|
/***** Get data from form *****/
|
2016-06-30 21:05:06 +02:00
|
|
|
|
/* Get subject */
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Par_GetParToHTML ("Subject",Gbl.Msg.Subject,Cns_MAX_BYTES_SUBJECT);
|
|
|
|
|
|
2016-06-30 21:05:06 +02:00
|
|
|
|
/* Get body */
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Par_GetParAndChangeFormat ("Content",Content,Cns_MAX_BYTES_LONG_TEXT,
|
|
|
|
|
Str_DONT_CHANGE,false);
|
|
|
|
|
|
|
|
|
|
/* Get parameter that indicates if the message is a reply to a previous message */
|
2017-01-28 20:32:50 +01:00
|
|
|
|
if ((IsReply = Par_GetParToBool ("IsReply")))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/* Get original message code */
|
2016-06-30 21:05:06 +02:00
|
|
|
|
if ((OriginalMsgCod = Msg_GetParamMsgCod ()) <= 0)
|
|
|
|
|
Lay_ShowErrorAndExit ("Wrong code of message.");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get user's code of possible preselected recipient */
|
2016-01-25 14:40:57 +01:00
|
|
|
|
Usr_GetParamOtherUsrCodEncryptedAndGetListIDs ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-09-30 23:10:15 +02:00
|
|
|
|
/* Get lists of selected users */
|
2016-07-04 14:03:04 +02:00
|
|
|
|
Usr_GetListsSelectedUsrsCods ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get list of users' IDs or nicknames written explicitely */
|
|
|
|
|
Error = Usr_GetListMsgRecipientsWrittenExplicitelyBySender (true);
|
|
|
|
|
|
2015-12-24 00:31:45 +01:00
|
|
|
|
/***** Check number of recipients *****/
|
2015-09-30 23:10:15 +02:00
|
|
|
|
if ((NumRecipients = Usr_CountNumUsrsInListOfSelectedUsrs ()))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-06-04 18:18:54 +02:00
|
|
|
|
if (Gbl.Usrs.Me.Role.Logged == Rol_STD &&
|
2014-12-01 23:55:08 +01:00
|
|
|
|
NumRecipients > Cfg_MAX_RECIPIENTS)
|
|
|
|
|
{
|
|
|
|
|
/* Write warning message */
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_You_can_not_send_a_message_to_so_many_recipients_);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Error = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // No recipients selected
|
|
|
|
|
{
|
|
|
|
|
/* Write warning message */
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_You_must_select_one_ore_more_recipients);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Error = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** If error in list of recipients, show again the form used to write a message *****/
|
|
|
|
|
if (Error)
|
|
|
|
|
{
|
|
|
|
|
/* Show the form again, with the subject and the message filled */
|
|
|
|
|
Str_ChangeFormat (Str_FROM_FORM,Str_TO_TEXT,
|
|
|
|
|
Content,Cns_MAX_BYTES_LONG_TEXT,true);
|
|
|
|
|
Msg_PutFormMsgUsrs (Content);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Initialize structure with user's data *****/
|
|
|
|
|
Usr_UsrDataConstructor (&UsrDstData);
|
|
|
|
|
|
2016-04-10 14:09:50 +02:00
|
|
|
|
/***** Initialize image *****/
|
|
|
|
|
Img_ImageConstructor (&Image);
|
|
|
|
|
|
|
|
|
|
/***** Get attached image (action, file and title) *****/
|
2016-04-14 19:19:55 +02:00
|
|
|
|
Image.Width = Msg_IMAGE_SAVED_MAX_WIDTH;
|
|
|
|
|
Image.Height = Msg_IMAGE_SAVED_MAX_HEIGHT;
|
|
|
|
|
Image.Quality = Msg_IMAGE_SAVED_QUALITY;
|
2016-04-14 21:33:24 +02:00
|
|
|
|
Img_GetImageFromForm (-1,&Image,NULL);
|
2016-04-10 14:09:50 +02:00
|
|
|
|
|
2017-05-23 18:15:59 +02:00
|
|
|
|
/***** Loop over the list Gbl.Usrs.Select[Rol_UNK], that holds the list of the
|
2014-12-01 23:55:08 +01:00
|
|
|
|
recipients, creating a received message for each recipient *****/
|
|
|
|
|
Str_ChangeFormat (Str_FROM_FORM,Str_TO_RIGOROUS_HTML,
|
|
|
|
|
Content,Cns_MAX_BYTES_LONG_TEXT,false);
|
2017-05-23 18:15:59 +02:00
|
|
|
|
Ptr = Gbl.Usrs.Select[Rol_UNK];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
NumRecipients = 0;
|
|
|
|
|
while (*Ptr)
|
|
|
|
|
{
|
2017-03-13 14:22:36 +01:00
|
|
|
|
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDstData.EncryptedUsrCod,
|
|
|
|
|
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Usr_GetUsrCodFromEncryptedUsrCod (&UsrDstData);
|
|
|
|
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDstData)) // Get recipient's data from the database
|
|
|
|
|
{
|
|
|
|
|
/***** Check if recipient has banned me *****/
|
|
|
|
|
RecipientHasBannedMe = Msg_CheckIfUsrIsBanned (Gbl.Usrs.Me.UsrDat.UsrCod,UsrDstData.UsrCod);
|
|
|
|
|
|
|
|
|
|
if (RecipientHasBannedMe)
|
|
|
|
|
{
|
|
|
|
|
/***** Show an alert indicating that the message has not been sent successfully *****/
|
2018-10-16 23:08:04 +02:00
|
|
|
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
Txt_message_not_sent_to_X,
|
|
|
|
|
UsrDstData.FullName);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/***** Create message *****/
|
|
|
|
|
if (!MsgAlreadyInserted)
|
|
|
|
|
{
|
|
|
|
|
// The message is inserted only once in the table of messages sent
|
2016-04-10 19:19:20 +02:00
|
|
|
|
NewMsgCod = Msg_InsertNewMsg (Gbl.Msg.Subject,Content,&Image);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
MsgAlreadyInserted = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** If this recipient is the original sender of a message been replied, set Replied to true *****/
|
2015-12-22 13:22:35 +01:00
|
|
|
|
Replied = (IsReply &&
|
|
|
|
|
UsrDstData.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-11-16 23:19:52 +01:00
|
|
|
|
/***** This received message must be notified by email? *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
CreateNotif = (UsrDstData.Prefs.NotifNtfEvents & (1 << Ntf_EVENT_MESSAGE));
|
|
|
|
|
NotifyByEmail = CreateNotif &&
|
|
|
|
|
(UsrDstData.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) &&
|
|
|
|
|
(UsrDstData.Prefs.EmailNtfEvents & (1 << Ntf_EVENT_MESSAGE));
|
|
|
|
|
|
|
|
|
|
/***** Create the received message for this recipient
|
2017-01-19 03:15:35 +01:00
|
|
|
|
and increment number of new messages received by this recipient *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Msg_InsertReceivedMsgIntoDB (NewMsgCod,UsrDstData.UsrCod,NotifyByEmail);
|
|
|
|
|
|
|
|
|
|
/***** Create notification for this recipient.
|
2016-11-16 23:19:52 +01:00
|
|
|
|
If this recipient wants to receive notifications by -mail,
|
|
|
|
|
activate the sending of a notification *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (CreateNotif)
|
|
|
|
|
Ntf_StoreNotifyEventToOneUser (Ntf_EVENT_MESSAGE,&UsrDstData,NewMsgCod,
|
|
|
|
|
(Ntf_Status_t) (NotifyByEmail ? Ntf_STATUS_BIT_EMAIL :
|
|
|
|
|
0));
|
|
|
|
|
|
|
|
|
|
/***** Show an alert indicating that the message has been sent successfully *****/
|
2018-10-16 23:08:04 +02:00
|
|
|
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
NotifyByEmail ? Txt_message_sent_to_X_notified_by_email :
|
|
|
|
|
Txt_message_sent_to_X_not_notified_by_email,
|
|
|
|
|
UsrDstData.FullName);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Increment number of recipients *****/
|
|
|
|
|
if (NotifyByEmail)
|
|
|
|
|
NumRecipientsToBeNotifiedByEMail++;
|
|
|
|
|
NumRecipients++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_ERROR,Txt_Error_getting_data_from_a_recipient);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
NumErrors++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-10 14:09:50 +02:00
|
|
|
|
/***** Free image *****/
|
|
|
|
|
Img_ImageDestructor (&Image);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Free memory used for user's data *****/
|
|
|
|
|
Usr_UsrDataDestructor (&UsrDstData);
|
|
|
|
|
|
|
|
|
|
/***** Free memory *****/
|
|
|
|
|
/* Free memory used for list of users */
|
|
|
|
|
Usr_FreeListOtherRecipients ();
|
2016-07-04 14:03:04 +02:00
|
|
|
|
Usr_FreeListsSelectedUsrsCods ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Update received message setting Replied field to true *****/
|
|
|
|
|
if (Replied)
|
2015-12-22 13:22:35 +01:00
|
|
|
|
Msg_SetReceivedMsgAsReplied (OriginalMsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write final message *****/
|
|
|
|
|
if (NumRecipients)
|
|
|
|
|
{
|
|
|
|
|
if (NumRecipients == 1)
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_The_message_has_been_sent_to_1_recipient);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
2018-10-16 23:08:04 +02:00
|
|
|
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
Txt_The_message_has_been_sent_to_X_recipients,
|
|
|
|
|
(unsigned) NumRecipients);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_The_message_has_not_been_sent_to_any_recipient);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show alert about errors on sending message *****/
|
|
|
|
|
if (NumErrors > 1)
|
|
|
|
|
{
|
2018-10-16 23:08:04 +02:00
|
|
|
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
Txt_There_have_been_X_errors_in_sending_the_message,
|
|
|
|
|
(unsigned) NumErrors);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_ERROR,Gbl.Alert.Txt);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Request deletion of all received messages *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_ReqDelAllRecMsgs (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Do_you_really_want_to_delete_the_unread_messages_received_from_USER_X_from_COURSE_Y_related_to_CONTENT_Z;
|
|
|
|
|
extern const char *Txt_any_user;
|
|
|
|
|
extern const char *Txt_Do_you_really_want_to_delete_all_messages_received_from_USER_X_from_COURSE_Y_related_to_CONTENT_Z;
|
|
|
|
|
extern const char *Txt_Do_you_really_want_to_delete_the_unread_messages_received_from_USER_X_from_COURSE_Y;
|
|
|
|
|
extern const char *Txt_Do_you_really_want_to_delete_all_messages_received_from_USER_X_from_COURSE_Y;
|
|
|
|
|
extern const char *Txt_Delete_messages_received;
|
|
|
|
|
|
|
|
|
|
/***** Get parameters *****/
|
|
|
|
|
Msg_GetParamMsgsCrsCod ();
|
|
|
|
|
Msg_GetParamFilterFromTo ();
|
|
|
|
|
Msg_GetParamFilterContent ();
|
|
|
|
|
Msg_GetParamOnlyUnreadMsgs ();
|
|
|
|
|
|
2017-04-28 01:02:44 +02:00
|
|
|
|
/***** Show question and button to remove messages received *****/
|
|
|
|
|
/* Start alert */
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Gbl.Msg.FilterContent[0])
|
|
|
|
|
{
|
|
|
|
|
if (Gbl.Msg.ShowOnlyUnreadMsgs)
|
2018-10-16 23:08:04 +02:00
|
|
|
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
Txt_Do_you_really_want_to_delete_the_unread_messages_received_from_USER_X_from_COURSE_Y_related_to_CONTENT_Z,
|
|
|
|
|
Gbl.Msg.FilterFromTo[0] ? Gbl.Msg.FilterFromTo :
|
|
|
|
|
Txt_any_user,
|
|
|
|
|
Gbl.Msg.FilterCrsShrtName,Gbl.Msg.FilterContent);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
2018-10-16 23:08:04 +02:00
|
|
|
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
Txt_Do_you_really_want_to_delete_all_messages_received_from_USER_X_from_COURSE_Y_related_to_CONTENT_Z,
|
|
|
|
|
Gbl.Msg.FilterFromTo[0] ? Gbl.Msg.FilterFromTo :
|
|
|
|
|
Txt_any_user,
|
|
|
|
|
Gbl.Msg.FilterCrsShrtName,Gbl.Msg.FilterContent);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (Gbl.Msg.ShowOnlyUnreadMsgs)
|
2018-10-16 23:08:04 +02:00
|
|
|
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
Txt_Do_you_really_want_to_delete_the_unread_messages_received_from_USER_X_from_COURSE_Y,
|
|
|
|
|
Gbl.Msg.FilterFromTo[0] ? Gbl.Msg.FilterFromTo :
|
|
|
|
|
Txt_any_user,
|
|
|
|
|
Gbl.Msg.FilterCrsShrtName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
2018-10-16 23:08:04 +02:00
|
|
|
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
Txt_Do_you_really_want_to_delete_all_messages_received_from_USER_X_from_COURSE_Y,
|
|
|
|
|
Gbl.Msg.FilterFromTo[0] ? Gbl.Msg.FilterFromTo :
|
|
|
|
|
Txt_any_user,
|
|
|
|
|
Gbl.Msg.FilterCrsShrtName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlertAndButton1 (Ale_QUESTION,Gbl.Alert.Txt);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-04-28 01:02:44 +02:00
|
|
|
|
/* Show received messages again */
|
|
|
|
|
Gbl.Msg.TypeOfMessages = Msg_MESSAGES_RECEIVED;
|
|
|
|
|
Msg_ShowSentOrReceivedMessages ();
|
2015-10-08 01:06:46 +02:00
|
|
|
|
|
2017-04-28 01:02:44 +02:00
|
|
|
|
/* End alert */
|
2017-05-25 14:25:22 +02:00
|
|
|
|
Ale_ShowAlertAndButton2 (ActDelAllRcvMsg,NULL,NULL,
|
2017-04-28 10:35:41 +02:00
|
|
|
|
Msg_PutHiddenParamsMsgsFilters,
|
2017-06-11 19:02:40 +02:00
|
|
|
|
Btn_REMOVE_BUTTON,Txt_Delete_messages_received);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Request deletion of all sent messages *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_ReqDelAllSntMsgs (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Do_you_really_want_to_delete_all_messages_sent_to_USER_X_from_COURSE_Y_related_to_CONTENT_Z;
|
|
|
|
|
extern const char *Txt_any_user;
|
|
|
|
|
extern const char *Txt_Do_you_really_want_to_delete_all_messages_sent_to_USER_X_from_COURSE_Y;
|
|
|
|
|
extern const char *Txt_Delete_messages_sent;
|
|
|
|
|
|
|
|
|
|
/***** Get parameters *****/
|
|
|
|
|
Msg_GetParamMsgsCrsCod ();
|
|
|
|
|
Msg_GetParamFilterFromTo ();
|
|
|
|
|
Msg_GetParamFilterContent ();
|
|
|
|
|
|
2017-04-28 01:02:44 +02:00
|
|
|
|
/***** Show question and button to remove messages received *****/
|
|
|
|
|
/* Start alert */
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Gbl.Msg.FilterContent[0])
|
2018-10-16 23:08:04 +02:00
|
|
|
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
Txt_Do_you_really_want_to_delete_all_messages_sent_to_USER_X_from_COURSE_Y_related_to_CONTENT_Z,
|
|
|
|
|
Gbl.Msg.FilterFromTo[0] ? Gbl.Msg.FilterFromTo :
|
|
|
|
|
Txt_any_user,
|
|
|
|
|
Gbl.Msg.FilterCrsShrtName,Gbl.Msg.FilterContent);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
2018-10-16 23:08:04 +02:00
|
|
|
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
Txt_Do_you_really_want_to_delete_all_messages_sent_to_USER_X_from_COURSE_Y,
|
|
|
|
|
Gbl.Msg.FilterFromTo[0] ? Gbl.Msg.FilterFromTo :
|
|
|
|
|
Txt_any_user,
|
|
|
|
|
Gbl.Msg.FilterCrsShrtName);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlertAndButton1 (Ale_QUESTION,Gbl.Alert.Txt);
|
2015-10-08 01:06:46 +02:00
|
|
|
|
|
2017-04-28 01:02:44 +02:00
|
|
|
|
/* Show sent messages again */
|
|
|
|
|
Gbl.Msg.TypeOfMessages = Msg_MESSAGES_SENT;
|
|
|
|
|
Msg_ShowSentOrReceivedMessages ();
|
2015-10-08 01:06:46 +02:00
|
|
|
|
|
2017-04-28 01:02:44 +02:00
|
|
|
|
/* End alert */
|
2017-05-25 14:25:22 +02:00
|
|
|
|
Ale_ShowAlertAndButton2 (ActDelAllSntMsg,NULL,NULL,
|
2017-04-28 10:35:41 +02:00
|
|
|
|
Msg_PutHiddenParamsMsgsFilters,
|
2017-06-11 19:02:40 +02:00
|
|
|
|
Btn_REMOVE_BUTTON,Txt_Delete_messages_sent);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Delete all received messages ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_DelAllRecMsgs (void)
|
|
|
|
|
{
|
2017-03-07 19:55:29 +01:00
|
|
|
|
char FilterFromToSubquery[Msg_MAX_BYTES_MESSAGES_QUERY + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned long NumMsgs;
|
|
|
|
|
|
|
|
|
|
/***** Get parameters *****/
|
|
|
|
|
Msg_GetParamMsgsCrsCod ();
|
|
|
|
|
Msg_GetParamFilterFromTo ();
|
|
|
|
|
Msg_GetParamFilterContent ();
|
|
|
|
|
Msg_GetParamOnlyUnreadMsgs ();
|
|
|
|
|
Msg_MakeFilterFromToSubquery (FilterFromToSubquery);
|
|
|
|
|
|
|
|
|
|
/***** Delete messages *****/
|
|
|
|
|
NumMsgs = Msg_DelSomeRecOrSntMsgsUsr (Msg_MESSAGES_RECEIVED,Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Msg.FilterCrsCod,FilterFromToSubquery);
|
|
|
|
|
Msg_ShowNumMsgsDeleted (NumMsgs);
|
|
|
|
|
Msg_ShowRecMsgs ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Delete all sent messages **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_DelAllSntMsgs (void)
|
|
|
|
|
{
|
2017-03-07 19:55:29 +01:00
|
|
|
|
char FilterFromToSubquery[Msg_MAX_BYTES_MESSAGES_QUERY + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned long NumMsgs;
|
|
|
|
|
|
|
|
|
|
/***** Get parameters *****/
|
|
|
|
|
Msg_GetParamMsgsCrsCod ();
|
|
|
|
|
Msg_GetParamFilterFromTo ();
|
|
|
|
|
Msg_GetParamFilterContent ();
|
|
|
|
|
Msg_MakeFilterFromToSubquery (FilterFromToSubquery);
|
|
|
|
|
|
|
|
|
|
/***** Delete messages *****/
|
|
|
|
|
NumMsgs = Msg_DelSomeRecOrSntMsgsUsr (Msg_MESSAGES_SENT,Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Msg.FilterCrsCod,FilterFromToSubquery);
|
|
|
|
|
Msg_ShowNumMsgsDeleted (NumMsgs);
|
|
|
|
|
Msg_ShowSntMsgs ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************* Write number of messages that have been deleted ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Msg_ShowNumMsgsDeleted (unsigned NumMsgs)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_One_message_has_been_deleted;
|
|
|
|
|
extern const char *Txt_X_messages_have_been_deleted;
|
|
|
|
|
|
|
|
|
|
if (NumMsgs == 1)
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_One_message_has_been_deleted);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
2018-10-16 23:08:04 +02:00
|
|
|
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
Txt_X_messages_have_been_deleted,
|
|
|
|
|
NumMsgs);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Get parameter with course origin of messages ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_GetParamMsgsCrsCod (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_any_course;
|
|
|
|
|
struct Course Crs;
|
|
|
|
|
|
2017-01-28 20:32:50 +01:00
|
|
|
|
if ((Gbl.Msg.FilterCrsCod = Par_GetParToLong ("FilterCrsCod")) > 0) // If origin course specified
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/* Get data of course */
|
|
|
|
|
Crs.CrsCod = Gbl.Msg.FilterCrsCod;
|
|
|
|
|
Crs_GetDataOfCourseByCod (&Crs);
|
|
|
|
|
|
2017-01-15 22:58:26 +01:00
|
|
|
|
Str_Copy (Gbl.Msg.FilterCrsShrtName,Crs.ShrtName,
|
2017-03-08 14:12:33 +01:00
|
|
|
|
Hie_MAX_BYTES_SHRT_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2017-01-15 22:58:26 +01:00
|
|
|
|
Str_Copy (Gbl.Msg.FilterCrsShrtName,Txt_any_course,
|
2017-03-08 14:12:33 +01:00
|
|
|
|
Hie_MAX_BYTES_SHRT_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Get parameter with "from"/"to" filter ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_GetParamFilterFromTo (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Get "from"/"to" filter *****/
|
2017-01-28 15:58:46 +01:00
|
|
|
|
Par_GetParToText ("FilterFromTo",Gbl.Msg.FilterFromTo,
|
2017-03-07 19:55:29 +01:00
|
|
|
|
Usr_MAX_BYTES_FULL_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Get parameter with content filter *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_GetParamFilterContent (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Get content filter *****/
|
2017-01-28 15:58:46 +01:00
|
|
|
|
Par_GetParToText ("FilterContent",Gbl.Msg.FilterContent,
|
2017-03-07 19:55:29 +01:00
|
|
|
|
Msg_MAX_BYTES_FILTER_CONTENT);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Make "from"/"to" subquery *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-03-07 19:55:29 +01:00
|
|
|
|
static void Msg_MakeFilterFromToSubquery (char FilterFromToSubquery[Msg_MAX_BYTES_MESSAGES_QUERY + 1])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
const char *Ptr;
|
2017-03-07 19:55:29 +01:00
|
|
|
|
char SearchWord[Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Split "from"/"to" string into words *****/
|
|
|
|
|
if (Gbl.Msg.FilterFromTo[0])
|
|
|
|
|
{
|
|
|
|
|
Ptr = Gbl.Msg.FilterFromTo;
|
2017-01-15 22:58:26 +01:00
|
|
|
|
Str_Copy (FilterFromToSubquery,
|
2017-04-28 03:11:08 +02:00
|
|
|
|
" AND CONCAT(usr_data.FirstName,' ',usr_data.Surname1,' ',usr_data.Surname2) LIKE '",
|
2017-03-07 19:55:29 +01:00
|
|
|
|
Msg_MAX_BYTES_MESSAGES_QUERY);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
while (*Ptr)
|
|
|
|
|
{
|
2017-03-07 19:55:29 +01:00
|
|
|
|
Str_GetNextStringUntilSpace (&Ptr,SearchWord,Usr_MAX_BYTES_FIRSTNAME_OR_SURNAME);
|
|
|
|
|
if (strlen (FilterFromToSubquery) + strlen (SearchWord) + 512 >
|
|
|
|
|
Msg_MAX_BYTES_MESSAGES_QUERY) // Prevent string overflow
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2017-01-17 03:33:05 +01:00
|
|
|
|
Str_Concat (FilterFromToSubquery,"%",
|
2017-03-07 19:55:29 +01:00
|
|
|
|
Msg_MAX_BYTES_MESSAGES_QUERY);
|
2017-01-17 03:33:05 +01:00
|
|
|
|
Str_Concat (FilterFromToSubquery,SearchWord,
|
2017-03-07 19:55:29 +01:00
|
|
|
|
Msg_MAX_BYTES_MESSAGES_QUERY);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2017-01-17 03:33:05 +01:00
|
|
|
|
Str_Concat (FilterFromToSubquery,"%'",
|
2017-03-07 19:55:29 +01:00
|
|
|
|
Msg_MAX_BYTES_MESSAGES_QUERY);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
FilterFromToSubquery[0] = '\0';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Delete a sent message ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_DelSntMsg (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Message_deleted;
|
|
|
|
|
long MsgCod;
|
|
|
|
|
|
|
|
|
|
/***** Get the code of the message to delete *****/
|
2016-06-30 21:05:06 +02:00
|
|
|
|
if ((MsgCod = Msg_GetParamMsgCod ()) <= 0)
|
|
|
|
|
Lay_ShowErrorAndExit ("Wrong code of message.");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Delete the message *****/
|
|
|
|
|
/* Delete the sent message */
|
|
|
|
|
Msg_MoveSentMsgToDeleted (MsgCod);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Message_deleted);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Show the remaining messages */
|
|
|
|
|
Msg_ShowSntMsgs ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Delete a received message *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_DelRecMsg (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Message_deleted;
|
|
|
|
|
long MsgCod;
|
|
|
|
|
|
|
|
|
|
/***** Get the code of the message to delete *****/
|
2016-06-30 21:05:06 +02:00
|
|
|
|
if ((MsgCod = Msg_GetParamMsgCod ()) <= 0)
|
|
|
|
|
Lay_ShowErrorAndExit ("Wrong code of message.");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Delete the message *****/
|
|
|
|
|
/* Delete the received message */
|
|
|
|
|
Msg_MoveReceivedMsgToDeleted (MsgCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Message_deleted);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Show the remaining messages */
|
|
|
|
|
Msg_ShowRecMsgs ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Expand a sent message **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_ExpSntMsg (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Get the code of the message to expand *****/
|
2016-06-30 21:05:06 +02:00
|
|
|
|
if ((Gbl.Msg.ExpandedMsgCod = Msg_GetParamMsgCod ()) <= 0)
|
|
|
|
|
Lay_ShowErrorAndExit ("Wrong code of message.");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Expand the message *****/
|
|
|
|
|
Msg_ExpandSentMsg (Gbl.Msg.ExpandedMsgCod);
|
|
|
|
|
|
|
|
|
|
/***** Show again the messages *****/
|
|
|
|
|
Msg_ShowSntMsgs ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Expand a received message ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_ExpRecMsg (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Get the code of the message to expand *****/
|
2016-06-30 21:05:06 +02:00
|
|
|
|
if ((Gbl.Msg.ExpandedMsgCod = Msg_GetParamMsgCod ()) <= 0)
|
|
|
|
|
Lay_ShowErrorAndExit ("Wrong code of message.");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Expand the message *****/
|
|
|
|
|
Msg_ExpandReceivedMsg (Gbl.Msg.ExpandedMsgCod);
|
|
|
|
|
|
|
|
|
|
/***** Mark possible notification as seen *****/
|
2016-01-04 01:56:28 +01:00
|
|
|
|
Ntf_MarkNotifAsSeen (Ntf_EVENT_MESSAGE,
|
2016-01-20 21:18:38 +01:00
|
|
|
|
Gbl.Msg.ExpandedMsgCod,-1L,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
|
|
|
|
|
|
|
|
|
/***** Show again the messages *****/
|
|
|
|
|
Msg_ShowRecMsgs ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** Contract a sent message *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_ConSntMsg (void)
|
|
|
|
|
{
|
|
|
|
|
long MsgCod;
|
|
|
|
|
|
|
|
|
|
/***** Get the code of the message to contract *****/
|
2016-06-30 21:05:06 +02:00
|
|
|
|
if ((MsgCod = Msg_GetParamMsgCod ()) <= 0)
|
|
|
|
|
Lay_ShowErrorAndExit ("Wrong code of message.");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Contract the message *****/
|
|
|
|
|
Msg_ContractSentMsg (MsgCod);
|
|
|
|
|
|
|
|
|
|
/***** Show again the messages *****/
|
|
|
|
|
Msg_ShowSntMsgs ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Contract a received message ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_ConRecMsg (void)
|
|
|
|
|
{
|
|
|
|
|
long MsgCod;
|
|
|
|
|
|
|
|
|
|
/***** Get the code of the message to contract *****/
|
2016-06-30 21:05:06 +02:00
|
|
|
|
if ((MsgCod = Msg_GetParamMsgCod ()) <= 0)
|
|
|
|
|
Lay_ShowErrorAndExit ("Wrong code of message.");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Contract the message *****/
|
|
|
|
|
Msg_ContractReceivedMsg (MsgCod);
|
|
|
|
|
|
|
|
|
|
/***** Show again the messages *****/
|
|
|
|
|
Msg_ShowRecMsgs ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Expand a sent message **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Msg_ExpandSentMsg (long MsgCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Expand message in sent message table *****/
|
2018-11-03 12:16:40 +01:00
|
|
|
|
DB_QueryUPDATE ("can not expand a sent message",
|
|
|
|
|
"UPDATE msg_snt SET Expanded='Y'"
|
|
|
|
|
" WHERE MsgCod=%ld AND UsrCod=%ld",
|
|
|
|
|
MsgCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Contract all my other messages in sent message table *****/
|
2018-11-03 12:16:40 +01:00
|
|
|
|
DB_QueryUPDATE ("can not contract a sent message",
|
|
|
|
|
"UPDATE msg_snt SET Expanded='N'"
|
|
|
|
|
" WHERE UsrCod=%ld AND MsgCod<>%ld",
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod,MsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Expand a received message *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Msg_ExpandReceivedMsg (long MsgCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Expand message in received message table and mark it as read by me *****/
|
2018-11-03 12:16:40 +01:00
|
|
|
|
DB_QueryUPDATE ("can not expand a received message",
|
|
|
|
|
"UPDATE msg_rcv SET Open='Y',Expanded='Y'"
|
|
|
|
|
" WHERE MsgCod=%ld AND UsrCod=%ld",
|
|
|
|
|
MsgCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Contract all my other messages in received message table *****/
|
2018-11-03 12:16:40 +01:00
|
|
|
|
DB_QueryUPDATE ("can not contract a received message",
|
|
|
|
|
"UPDATE msg_rcv SET Expanded='N'"
|
|
|
|
|
" WHERE UsrCod=%ld AND MsgCod<>%ld",
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod,MsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Contract a sent message **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Msg_ContractSentMsg (long MsgCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Contract message in sent message table *****/
|
2018-11-03 12:16:40 +01:00
|
|
|
|
DB_QueryUPDATE ("can not contract a sent message",
|
|
|
|
|
"UPDATE msg_snt SET Expanded='N'"
|
|
|
|
|
" WHERE MsgCod=%ld AND UsrCod=%ld",
|
|
|
|
|
MsgCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Contract a received message ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Msg_ContractReceivedMsg (long MsgCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Contract message in received message table *****/
|
2018-11-03 12:16:40 +01:00
|
|
|
|
DB_QueryUPDATE ("can not contract a received message",
|
|
|
|
|
"UPDATE msg_rcv SET Expanded='N'"
|
|
|
|
|
" WHERE MsgCod=%ld AND UsrCod=%ld",
|
|
|
|
|
MsgCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Mark a received message as open **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_SetReceivedMsgAsOpen (long MsgCod,long UsrCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Mark message as read by user *****/
|
2018-11-03 12:16:40 +01:00
|
|
|
|
DB_QueryUPDATE ("can not mark a received message as open",
|
|
|
|
|
"UPDATE msg_rcv SET Open='Y'"
|
|
|
|
|
" WHERE MsgCod=%ld AND UsrCod=%ld",
|
|
|
|
|
MsgCod,UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Insert a message in the database *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Return the code of the new inserted message
|
|
|
|
|
|
2016-04-10 19:19:20 +02:00
|
|
|
|
static long Msg_InsertNewMsg (const char *Subject,const char *Content,
|
|
|
|
|
struct Image *Image)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
long MsgCod;
|
|
|
|
|
|
2016-04-11 02:16:27 +02:00
|
|
|
|
/***** Check if image is received and processed *****/
|
|
|
|
|
if (Image->Action == Img_ACTION_NEW_IMAGE && // Upload new image
|
|
|
|
|
Image->Status == Img_FILE_PROCESSED) // The new image received has been processed
|
|
|
|
|
/* Move processed image to definitive directory */
|
|
|
|
|
Img_MoveImageToDefinitiveDirectory (Image);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Insert message subject and content in the database *****/
|
2018-11-03 01:45:36 +01:00
|
|
|
|
MsgCod =
|
|
|
|
|
DB_QueryINSERTandReturnCode ("can not create message",
|
|
|
|
|
"INSERT INTO msg_content"
|
|
|
|
|
" (Subject,Content,ImageName,ImageTitle,ImageURL)"
|
|
|
|
|
" VALUES"
|
|
|
|
|
" ('%s','%s','%s','%s','%s')",
|
|
|
|
|
Subject,Content,
|
|
|
|
|
Image->Name,
|
|
|
|
|
Image->Title ? Image->Title : "",
|
|
|
|
|
Image->URL ? Image->URL : "");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Insert message in sent messages *****/
|
2018-11-02 19:37:11 +01:00
|
|
|
|
DB_QueryINSERT ("can not create message",
|
|
|
|
|
"INSERT INTO msg_snt"
|
|
|
|
|
" (MsgCod,CrsCod,UsrCod,Expanded,CreatTime)"
|
|
|
|
|
" VALUES"
|
|
|
|
|
" (%ld,%ld,%ld,'N',NOW())",
|
|
|
|
|
MsgCod,
|
|
|
|
|
Gbl.CurrentCrs.Crs.CrsCod,
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
2016-04-10 19:19:20 +02:00
|
|
|
|
|
2015-03-11 00:36:12 +01:00
|
|
|
|
/***** Increment number of messages sent by me *****/
|
2015-03-14 17:39:04 +01:00
|
|
|
|
Prf_IncrementNumMsgSntUsr (Gbl.Usrs.Me.UsrDat.UsrCod);
|
2015-03-11 00:36:12 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
return MsgCod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Delete some received or sent messages of a user **************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static unsigned long Msg_DelSomeRecOrSntMsgsUsr (Msg_TypeOfMessages_t TypeOfMessages,long UsrCod,
|
|
|
|
|
long FilterCrsCod,const char *FilterFromToSubquery)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2018-11-01 01:40:35 +01:00
|
|
|
|
unsigned long MsgNum;
|
|
|
|
|
unsigned long NumMsgs;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
long MsgCod;
|
|
|
|
|
|
|
|
|
|
/***** Get some of the messages received or sent by this user from database *****/
|
2018-11-01 01:40:35 +01:00
|
|
|
|
NumMsgs = Msg_GetSentOrReceivedMsgs (UsrCod,
|
|
|
|
|
FilterCrsCod,
|
|
|
|
|
FilterFromToSubquery,
|
|
|
|
|
&mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Delete each message *****/
|
|
|
|
|
for (MsgNum = 0;
|
|
|
|
|
MsgNum < NumMsgs;
|
|
|
|
|
MsgNum++)
|
|
|
|
|
{
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
if (sscanf (row[0],"%ld",&MsgCod) != 1)
|
|
|
|
|
Lay_ShowErrorAndExit ("Wrong code of message.");
|
|
|
|
|
switch (TypeOfMessages)
|
|
|
|
|
{
|
|
|
|
|
case Msg_MESSAGES_RECEIVED:
|
|
|
|
|
Msg_MoveReceivedMsgToDeleted (MsgCod,UsrCod);
|
|
|
|
|
break;
|
|
|
|
|
case Msg_MESSAGES_SENT:
|
|
|
|
|
Msg_MoveSentMsgToDeleted (MsgCod);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free the MySQL result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
return NumMsgs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Delete all received or sent messages of a user **************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_DelAllRecAndSntMsgsUsr (long UsrCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Move messages from msg_rcv to msg_rcv_deleted *****/
|
|
|
|
|
/* Insert messages into msg_rcv_deleted */
|
2018-11-02 19:37:11 +01:00
|
|
|
|
DB_QueryINSERT ("can not remove received messages",
|
|
|
|
|
"INSERT IGNORE INTO msg_rcv_deleted"
|
|
|
|
|
" (MsgCod,UsrCod,Notified,Open,Replied)"
|
|
|
|
|
" SELECT MsgCod,UsrCod,Notified,Open,Replied FROM msg_rcv"
|
|
|
|
|
" WHERE UsrCod=%ld",
|
|
|
|
|
UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Delete messages from msg_rcv *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove received messages",
|
|
|
|
|
"DELETE FROM msg_rcv WHERE UsrCod=%ld",
|
|
|
|
|
UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Move message from msg_snt to msg_snt_deleted *****/
|
|
|
|
|
/* Insert message into msg_snt_deleted */
|
2018-11-02 19:37:11 +01:00
|
|
|
|
DB_QueryINSERT ("can not remove sent messages",
|
|
|
|
|
"INSERT IGNORE INTO msg_snt_deleted"
|
|
|
|
|
" (MsgCod,CrsCod,UsrCod,CreatTime)"
|
|
|
|
|
" SELECT MsgCod,CrsCod,UsrCod,CreatTime"
|
|
|
|
|
" FROM msg_snt WHERE UsrCod=%ld",
|
|
|
|
|
UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Delete message from msg_snt *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove sent messages",
|
|
|
|
|
"DELETE FROM msg_snt WHERE UsrCod=%ld",
|
|
|
|
|
UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**** Insert a message y su destinatario in the table of messages received ***/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Msg_InsertReceivedMsgIntoDB (long MsgCod,long UsrCod,bool NotifyByEmail)
|
|
|
|
|
{
|
|
|
|
|
/***** Insert message received in the database *****/
|
2018-11-02 19:37:11 +01:00
|
|
|
|
DB_QueryINSERT ("can not create received message",
|
|
|
|
|
"INSERT INTO msg_rcv"
|
|
|
|
|
" (MsgCod,UsrCod,Notified,Open,Replied,Expanded)"
|
|
|
|
|
" VALUES"
|
|
|
|
|
" (%ld,%ld,'%c','N','N','N')",
|
|
|
|
|
MsgCod,UsrCod,
|
|
|
|
|
NotifyByEmail ? 'Y' :
|
|
|
|
|
'N');
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******** Update received message by setting Replied field to true ***********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Msg_SetReceivedMsgAsReplied (long MsgCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Update received message by setting Replied field to true *****/
|
2018-11-03 12:16:40 +01:00
|
|
|
|
DB_QueryUPDATE ("can not update a received message",
|
|
|
|
|
"UPDATE msg_rcv SET Replied='Y'"
|
|
|
|
|
" WHERE MsgCod=%ld AND UsrCod=%ld",
|
|
|
|
|
MsgCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************ Delete a message from the received message table ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Msg_MoveReceivedMsgToDeleted (long MsgCod,long UsrCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Move message from msg_rcv to msg_rcv_deleted *****/
|
|
|
|
|
/* Insert message into msg_rcv_deleted */
|
2018-11-02 19:37:11 +01:00
|
|
|
|
DB_QueryINSERT ("can not remove a received message",
|
|
|
|
|
"INSERT IGNORE INTO msg_rcv_deleted"
|
|
|
|
|
" (MsgCod,UsrCod,Notified,Open,Replied)"
|
|
|
|
|
" SELECT MsgCod,UsrCod,Notified,Open,Replied"
|
|
|
|
|
" FROM msg_rcv WHERE MsgCod=%ld AND UsrCod=%ld",
|
|
|
|
|
MsgCod,UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Delete message from msg_rcv *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove a received message",
|
|
|
|
|
"DELETE FROM msg_rcv WHERE MsgCod=%ld AND UsrCod=%ld",
|
|
|
|
|
MsgCod,UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** If message content is not longer necessary, move it to msg_content_deleted *****/
|
|
|
|
|
if (Msg_CheckIfSentMsgIsDeleted (MsgCod))
|
|
|
|
|
if (Msg_CheckIfReceivedMsgIsDeletedForAllItsRecipients (MsgCod))
|
|
|
|
|
Msg_MoveMsgContentToDeleted (MsgCod);
|
|
|
|
|
|
|
|
|
|
/***** Mark possible notifications as removed *****/
|
2016-01-04 01:56:28 +01:00
|
|
|
|
Ntf_MarkNotifToOneUsrAsRemoved (Ntf_EVENT_MESSAGE,MsgCod,UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Delete a message from the sent message table *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Msg_MoveSentMsgToDeleted (long MsgCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Move message from msg_snt to msg_snt_deleted *****/
|
|
|
|
|
/* Insert message into msg_snt_deleted */
|
2018-11-02 19:37:11 +01:00
|
|
|
|
DB_QueryINSERT ("can not remove a sent message",
|
|
|
|
|
"INSERT IGNORE INTO msg_snt_deleted"
|
|
|
|
|
" (MsgCod,CrsCod,UsrCod,CreatTime)"
|
|
|
|
|
" SELECT MsgCod,CrsCod,UsrCod,CreatTime"
|
|
|
|
|
" FROM msg_snt WHERE MsgCod=%ld",
|
|
|
|
|
MsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Delete message from msg_snt *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove a sent message",
|
|
|
|
|
"DELETE FROM msg_snt WHERE MsgCod=%ld",
|
|
|
|
|
MsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** If message content is not longer necessary, move it to msg_content_deleted *****/
|
|
|
|
|
if (Msg_CheckIfReceivedMsgIsDeletedForAllItsRecipients (MsgCod))
|
|
|
|
|
Msg_MoveMsgContentToDeleted (MsgCod);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Delete the subject and content of a message *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Msg_MoveMsgContentToDeleted (long MsgCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Move message from msg_content to msg_content_deleted *****/
|
|
|
|
|
/* Insert message content into msg_content_deleted */
|
2018-11-02 19:37:11 +01:00
|
|
|
|
DB_QueryINSERT ("can not remove the content of a message",
|
|
|
|
|
"INSERT IGNORE INTO msg_content_deleted"
|
|
|
|
|
" (MsgCod,Subject,Content,ImageName,ImageTitle,ImageURL)"
|
|
|
|
|
" SELECT MsgCod,Subject,Content,ImageName,ImageTitle,ImageURL"
|
|
|
|
|
" FROM msg_content WHERE MsgCod=%ld",
|
|
|
|
|
MsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-04-11 09:31:18 +02:00
|
|
|
|
/* TODO: Messages in msg_content_deleted older than a certain time
|
2014-12-01 23:55:08 +01:00
|
|
|
|
should be deleted to ensure the protection of personal data */
|
|
|
|
|
|
|
|
|
|
/* Delete message from msg_content *****/
|
2018-11-03 12:16:40 +01:00
|
|
|
|
DB_QueryUPDATE ("can not remove the content of a message",
|
|
|
|
|
"DELETE FROM msg_content WHERE MsgCod=%ld",
|
|
|
|
|
MsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***** Delete the subject and content of all completely deleted messages *****/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_MoveUnusedMsgsContentToDeleted (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Move messages from msg_content to msg_content_deleted *****/
|
|
|
|
|
/* Insert message content into msg_content_deleted */
|
2018-11-02 19:37:11 +01:00
|
|
|
|
DB_QueryINSERT ("can not remove the content of some messages",
|
|
|
|
|
"INSERT IGNORE INTO msg_content_deleted"
|
|
|
|
|
" (MsgCod,Subject,Content)"
|
|
|
|
|
" SELECT MsgCod,Subject,Content FROM msg_content"
|
|
|
|
|
" WHERE MsgCod NOT IN (SELECT MsgCod FROM msg_snt)"
|
|
|
|
|
" AND MsgCod NOT IN (SELECT DISTINCT MsgCod FROM msg_rcv)");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Messages in msg_content_deleted older than a certain time
|
|
|
|
|
should be deleted to ensure the protection of personal data */
|
|
|
|
|
|
|
|
|
|
/* Delete message from msg_content *****/
|
2018-11-03 12:16:40 +01:00
|
|
|
|
DB_QueryUPDATE ("can not remove the content of some messages",
|
|
|
|
|
"DELETE FROM msg_content"
|
|
|
|
|
" WHERE MsgCod NOT IN (SELECT MsgCod FROM msg_snt)"
|
|
|
|
|
" AND MsgCod NOT IN (SELECT DISTINCT MsgCod FROM msg_rcv)");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Check if a sent message is deleted *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static bool Msg_CheckIfSentMsgIsDeleted (long MsgCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Get if the message code is in table of sent messages not deleted *****/
|
2018-11-03 20:52:00 +01:00
|
|
|
|
return (DB_QueryCOUNT ("can not check if a sent message is deleted",
|
|
|
|
|
"SELECT COUNT(*) FROM msg_snt"
|
|
|
|
|
" WHERE MsgCod=%ld",
|
|
|
|
|
MsgCod) == 0); // The message has been deleted
|
|
|
|
|
// by its author when it is not present
|
|
|
|
|
// in table of sent messages undeleted
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***** Check if a received message has been deleted by all its recipients ****/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static bool Msg_CheckIfReceivedMsgIsDeletedForAllItsRecipients (long MsgCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Get if the message code is in table of received messages not deleted *****/
|
2018-11-03 20:52:00 +01:00
|
|
|
|
return (DB_QueryCOUNT ("can not check if a received message"
|
|
|
|
|
" is deleted by all recipients",
|
|
|
|
|
"SELECT COUNT(*) FROM msg_rcv"
|
|
|
|
|
" WHERE MsgCod=%ld",
|
|
|
|
|
MsgCod) == 0); // The message has been deleted
|
|
|
|
|
// by all its recipients when it is not present
|
|
|
|
|
// in table of received messages undeleted
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******** Get number of received messages that haven't been read by me *******/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static unsigned Msg_GetNumUnreadMsgs (long FilterCrsCod,const char *FilterFromToSubquery)
|
|
|
|
|
{
|
2017-03-07 19:55:29 +01:00
|
|
|
|
char SubQuery[Msg_MAX_BYTES_MESSAGES_QUERY + 1];
|
2018-11-03 20:52:00 +01:00
|
|
|
|
unsigned NumMsgs;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get number of unread messages from database *****/
|
|
|
|
|
if (FilterCrsCod >= 0) // If origin course selected
|
|
|
|
|
{
|
|
|
|
|
if (FilterFromToSubquery[0])
|
|
|
|
|
sprintf (SubQuery,"SELECT msg_rcv.MsgCod FROM msg_rcv,msg_snt,usr_data"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" WHERE msg_rcv.UsrCod=%ld AND msg_rcv.Open='N'"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
" AND msg_rcv.MsgCod=msg_snt.MsgCod"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" AND msg_snt.CrsCod=%ld"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
" AND msg_snt.UsrCod=usr_data.UsrCod%s",
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
|
|
|
|
FilterCrsCod,
|
|
|
|
|
FilterFromToSubquery);
|
|
|
|
|
else
|
|
|
|
|
sprintf (SubQuery,"SELECT msg_rcv.MsgCod FROM msg_rcv,msg_snt"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" WHERE msg_rcv.UsrCod=%ld AND msg_rcv.Open='N'"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
" AND msg_rcv.MsgCod=msg_snt.MsgCod"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" AND msg_snt.CrsCod=%ld",
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
|
|
|
|
FilterCrsCod);
|
|
|
|
|
}
|
|
|
|
|
else // If no origin course selected
|
|
|
|
|
{
|
|
|
|
|
if (FilterFromToSubquery[0])
|
|
|
|
|
sprintf (SubQuery,"SELECT msg_rcv.MsgCod FROM msg_rcv,msg_snt,usr_data"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" WHERE msg_rcv.UsrCod=%ld AND msg_rcv.Open='N'"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
" AND msg_rcv.MsgCod=msg_snt.MsgCod"
|
|
|
|
|
" AND msg_snt.UsrCod=usr_data.UsrCod%s",
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
|
|
|
|
FilterFromToSubquery);
|
|
|
|
|
else
|
|
|
|
|
sprintf (SubQuery,"SELECT MsgCod FROM msg_rcv"
|
2017-03-24 01:09:27 +01:00
|
|
|
|
" WHERE UsrCod=%ld AND Open='N'",
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Gbl.Msg.FilterContent[0])
|
2018-11-03 20:52:00 +01:00
|
|
|
|
NumMsgs =
|
|
|
|
|
(unsigned) DB_QueryCOUNT ("can not get number of unread messages",
|
|
|
|
|
"SELECT COUNT(*) FROM msg_content"
|
|
|
|
|
" WHERE MsgCod IN (%s)"
|
|
|
|
|
" AND MATCH (Subject,Content) AGAINST ('%s')",
|
|
|
|
|
SubQuery,
|
|
|
|
|
Gbl.Msg.FilterContent);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
2018-11-03 20:52:00 +01:00
|
|
|
|
NumMsgs =
|
|
|
|
|
(unsigned) DB_QueryCOUNT ("can not get number of unread messages",
|
|
|
|
|
"SELECT COUNT(*) FROM (%s) AS T",
|
|
|
|
|
SubQuery);
|
|
|
|
|
|
|
|
|
|
return NumMsgs;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-17 23:04:35 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Show messages sent to other users *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_ShowSntMsgs (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Show the sent messages *****/
|
2016-11-07 12:31:14 +01:00
|
|
|
|
Gbl.Msg.TypeOfMessages = Msg_MESSAGES_SENT;
|
|
|
|
|
Msg_ShowSentOrReceivedMessages ();
|
2014-12-17 23:04:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Show messages received from other users *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_ShowRecMsgs (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Link to view banned users *****/
|
2014-12-17 23:54:11 +01:00
|
|
|
|
if (Msg_GetNumUsrsBannedByMe ())
|
|
|
|
|
{
|
2015-04-02 14:22:21 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">");
|
2014-12-17 23:54:11 +01:00
|
|
|
|
Msg_PutLinkToViewBannedUsers ();
|
|
|
|
|
fprintf (Gbl.F.Out,"</div>");
|
|
|
|
|
}
|
2014-12-17 23:04:35 +01:00
|
|
|
|
|
|
|
|
|
/***** Show the received messages *****/
|
2016-11-07 12:31:14 +01:00
|
|
|
|
Gbl.Msg.TypeOfMessages = Msg_MESSAGES_RECEIVED;
|
|
|
|
|
Msg_ShowSentOrReceivedMessages ();
|
2014-12-17 23:04:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Show sent or received messages *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-11-07 12:31:14 +01:00
|
|
|
|
static void Msg_ShowSentOrReceivedMessages (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-11-23 13:55:27 +01:00
|
|
|
|
extern const char *Hlp_MESSAGES_Received;
|
2016-11-24 00:57:25 +01:00
|
|
|
|
extern const char *Hlp_MESSAGES_Received_filter;
|
2016-11-23 13:55:27 +01:00
|
|
|
|
extern const char *Hlp_MESSAGES_Sent;
|
2016-11-24 00:57:25 +01:00
|
|
|
|
extern const char *Hlp_MESSAGES_Sent_filter;
|
2015-07-27 21:25:45 +02:00
|
|
|
|
extern const char *The_ClassFormBold[The_NUM_THEMES];
|
2016-11-23 22:43:27 +01:00
|
|
|
|
extern const char *Txt_Filter;
|
2015-04-03 01:45:57 +02:00
|
|
|
|
extern const char *Txt_Update_messages;
|
2017-03-07 19:55:29 +01:00
|
|
|
|
char FilterFromToSubquery[Msg_MAX_BYTES_MESSAGES_QUERY + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2016-03-21 14:50:23 +01:00
|
|
|
|
unsigned long NumRow;
|
|
|
|
|
unsigned long NumRows;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned long NumMsg = 0; // Initialized to avoid warning
|
2016-11-08 00:58:32 +01:00
|
|
|
|
unsigned NumUnreadMsgs = 0; // Initialized to avoid warning
|
2014-12-01 23:55:08 +01:00
|
|
|
|
struct Pagination Pagination;
|
|
|
|
|
long MsgCod;
|
2016-11-23 13:55:27 +01:00
|
|
|
|
static const Act_Action_t ActionSee[Msg_NUM_TYPES_OF_MSGS] =
|
|
|
|
|
{
|
|
|
|
|
ActSeeRcvMsg,
|
2017-05-02 12:13:27 +02:00
|
|
|
|
ActSeeSntMsg,
|
2016-11-23 13:55:27 +01:00
|
|
|
|
};
|
2016-11-07 12:31:14 +01:00
|
|
|
|
static const Pag_WhatPaginate_t WhatPaginate[Msg_NUM_TYPES_OF_MSGS] =
|
|
|
|
|
{
|
|
|
|
|
Pag_MESSAGES_RECEIVED,
|
2017-05-02 12:13:27 +02:00
|
|
|
|
Pag_MESSAGES_SENT,
|
2016-11-07 12:31:14 +01:00
|
|
|
|
};
|
2016-11-23 13:55:27 +01:00
|
|
|
|
const char *Help[Msg_NUM_TYPES_OF_MSGS] =
|
2016-11-07 12:31:14 +01:00
|
|
|
|
{
|
2016-11-23 13:55:27 +01:00
|
|
|
|
Hlp_MESSAGES_Received,
|
2017-05-02 12:13:27 +02:00
|
|
|
|
Hlp_MESSAGES_Sent,
|
2016-11-07 12:31:14 +01:00
|
|
|
|
};
|
2016-11-24 00:57:25 +01:00
|
|
|
|
const char *HelpFilter[Msg_NUM_TYPES_OF_MSGS] =
|
|
|
|
|
{
|
|
|
|
|
Hlp_MESSAGES_Received_filter,
|
2017-05-02 12:13:27 +02:00
|
|
|
|
Hlp_MESSAGES_Sent_filter,
|
2016-11-24 00:57:25 +01:00
|
|
|
|
};
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the page number *****/
|
2017-04-13 20:09:22 +02:00
|
|
|
|
Gbl.Msg.CurrentPage = Pag_GetParamPagNum (WhatPaginate[Gbl.Msg.TypeOfMessages]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get other parameters *****/
|
|
|
|
|
Msg_GetParamMsgsCrsCod ();
|
|
|
|
|
Msg_GetParamFilterFromTo ();
|
|
|
|
|
Msg_GetParamFilterContent ();
|
|
|
|
|
Msg_MakeFilterFromToSubquery (FilterFromToSubquery);
|
2016-11-07 12:31:14 +01:00
|
|
|
|
Msg_GetDistinctCoursesInMyMessages ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-11-23 14:14:14 +01:00
|
|
|
|
/***** Get number of unread messages *****/
|
|
|
|
|
switch (Gbl.Msg.TypeOfMessages)
|
|
|
|
|
{
|
|
|
|
|
case Msg_MESSAGES_RECEIVED:
|
|
|
|
|
Msg_GetParamOnlyUnreadMsgs ();
|
|
|
|
|
NumUnreadMsgs = Msg_GetNumUnreadMsgs (Gbl.Msg.FilterCrsCod,FilterFromToSubquery);
|
|
|
|
|
break;
|
|
|
|
|
case Msg_MESSAGES_SENT:
|
|
|
|
|
NumUnreadMsgs = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Get messages from database *****/
|
2018-11-01 01:40:35 +01:00
|
|
|
|
NumRows = Msg_GetSentOrReceivedMsgs (Gbl.Usrs.Me.UsrDat.UsrCod,
|
|
|
|
|
Gbl.Msg.FilterCrsCod,
|
|
|
|
|
FilterFromToSubquery,
|
|
|
|
|
&mysql_res);
|
2016-11-23 14:14:14 +01:00
|
|
|
|
Gbl.Msg.NumMsgs = (unsigned) NumRows;
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** Start box with messages *****/
|
2017-06-11 22:26:40 +02:00
|
|
|
|
Box_StartBox ("97%",Msg_WriteNumMsgs (NumUnreadMsgs),Msg_PutIconsListMsgs,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Help[Gbl.Msg.TypeOfMessages],Box_NOT_CLOSABLE);
|
2016-11-23 14:14:14 +01:00
|
|
|
|
|
2016-11-23 14:01:08 +01:00
|
|
|
|
/***** Filter messages *****/
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/* Start box with filter */
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_StartBox (NULL,Txt_Filter,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
HelpFilter[Gbl.Msg.TypeOfMessages],Box_CLOSABLE);
|
2016-11-23 14:01:08 +01:00
|
|
|
|
|
|
|
|
|
/* Form to see messages again */
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActionSee[Gbl.Msg.TypeOfMessages]);
|
2016-11-23 21:06:37 +01:00
|
|
|
|
|
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"CENTER_MIDDLE\">");
|
2016-11-07 12:31:14 +01:00
|
|
|
|
Msg_ShowFormSelectCourseSentOrRecMsgs ();
|
|
|
|
|
if (Gbl.Msg.TypeOfMessages == Msg_MESSAGES_RECEIVED)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Msg_ShowFormToShowOnlyUnreadMessages ();
|
2016-11-23 21:06:37 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</div>");
|
2016-11-23 14:14:14 +01:00
|
|
|
|
Msg_ShowFormToFilterMsgs ();
|
2015-04-03 01:45:57 +02:00
|
|
|
|
|
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_MENU\">");
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_LinkFormSubmitAnimated (Txt_Update_messages,
|
2016-07-01 17:13:41 +02:00
|
|
|
|
The_ClassFormBold[Gbl.Prefs.Theme],
|
|
|
|
|
NULL);
|
2017-06-11 19:13:28 +02:00
|
|
|
|
Ico_PutCalculateIconWithText (Txt_Update_messages,Txt_Update_messages);
|
2015-04-03 01:45:57 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"</div>");
|
|
|
|
|
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/* End box */
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_EndBox ();
|
2016-11-23 14:01:08 +01:00
|
|
|
|
|
2016-11-07 12:31:14 +01:00
|
|
|
|
|
|
|
|
|
if (Gbl.Msg.NumMsgs) // If there are messages...
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-01-17 15:10:54 +01:00
|
|
|
|
if (Gbl.Action.Act == ActExpRcvMsg) // Expanding a message, perhaps it is the result of following a link
|
2014-12-01 23:55:08 +01:00
|
|
|
|
// from a notification of received message, so show the page where the message is inside
|
|
|
|
|
{
|
|
|
|
|
/***** Get the page where the expanded message is inside *****/
|
|
|
|
|
for (NumRow = 0;
|
|
|
|
|
NumRow < NumRows;
|
|
|
|
|
NumRow++)
|
|
|
|
|
{
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
if (sscanf (row[0],"%ld",&MsgCod) != 1)
|
|
|
|
|
Lay_ShowErrorAndExit ("Wrong code of message when searching for a page.");
|
|
|
|
|
|
|
|
|
|
if (MsgCod == Gbl.Msg.ExpandedMsgCod) // Expanded message found
|
|
|
|
|
{
|
2017-04-13 20:09:22 +02:00
|
|
|
|
Gbl.Msg.CurrentPage = (unsigned) (NumRow / Pag_ITEMS_PER_PAGE) + 1;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Compute variables related to pagination *****/
|
2016-11-07 12:31:14 +01:00
|
|
|
|
Pagination.NumItems = Gbl.Msg.NumMsgs;
|
2017-04-13 20:09:22 +02:00
|
|
|
|
Pagination.CurrentPage = (int) Gbl.Msg.CurrentPage;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Pag_CalculatePagination (&Pagination);
|
2017-04-13 20:09:22 +02:00
|
|
|
|
Gbl.Msg.CurrentPage = (unsigned) Pagination.CurrentPage;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Save my current page in order to show it next time I'll view my received/sent messages *****/
|
2016-11-07 12:31:14 +01:00
|
|
|
|
Pag_SaveLastPageMsgIntoSession (WhatPaginate[Gbl.Msg.TypeOfMessages],
|
2017-04-13 20:09:22 +02:00
|
|
|
|
Gbl.Msg.CurrentPage);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write links to pages *****/
|
|
|
|
|
if (Pagination.MoreThanOnePage)
|
2016-11-07 12:31:14 +01:00
|
|
|
|
Pag_WriteLinksToPagesCentered (WhatPaginate[Gbl.Msg.TypeOfMessages],
|
2017-04-17 11:57:55 +02:00
|
|
|
|
0,
|
|
|
|
|
&Pagination);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-04-12 18:01:06 +02:00
|
|
|
|
/***** Show received / sent messages in this page *****/
|
2017-06-11 20:09:59 +02:00
|
|
|
|
Tbl_StartTableWide (2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-10-26 01:23:02 +02:00
|
|
|
|
mysql_data_seek (mysql_res,(my_ulonglong) (Pagination.FirstItemVisible - 1));
|
2014-12-01 23:55:08 +01:00
|
|
|
|
for (NumRow = Pagination.FirstItemVisible;
|
|
|
|
|
NumRow <= Pagination.LastItemVisible;
|
|
|
|
|
NumRow++)
|
|
|
|
|
{
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
if (sscanf (row[0],"%ld",&MsgCod) != 1)
|
|
|
|
|
Lay_ShowErrorAndExit ("Wrong code of message when listing the messages in a page.");
|
|
|
|
|
NumMsg = NumRows - NumRow + 1;
|
2016-11-07 12:31:14 +01:00
|
|
|
|
Msg_ShowASentOrReceivedMessage (NumMsg,MsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-11 20:09:59 +02:00
|
|
|
|
Tbl_EndTable ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write again links to pages *****/
|
|
|
|
|
if (Pagination.MoreThanOnePage)
|
2016-11-07 12:31:14 +01:00
|
|
|
|
Pag_WriteLinksToPagesCentered (WhatPaginate[Gbl.Msg.TypeOfMessages],
|
2017-04-17 11:57:55 +02:00
|
|
|
|
0,
|
|
|
|
|
&Pagination);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_EndBox ();
|
2015-10-08 01:06:46 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-17 23:54:11 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Get number of user I have banned **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static unsigned long Msg_GetNumUsrsBannedByMe (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Get number of users I have banned *****/
|
2018-11-03 20:52:00 +01:00
|
|
|
|
return DB_QueryCOUNT ("can not get number of users you have banned",
|
|
|
|
|
"SELECT COUNT(*) FROM msg_banned"
|
|
|
|
|
" WHERE ToUsrCod=%ld",
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
2014-12-17 23:54:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-17 23:04:35 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Put a link (form) to view banned users *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Msg_PutLinkToViewBannedUsers(void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Banned_users;
|
|
|
|
|
|
2017-04-17 19:03:21 +02:00
|
|
|
|
Lay_PutContextualLink (ActLstBanUsr,NULL,NULL,
|
2016-07-01 16:32:42 +02:00
|
|
|
|
"stop16x16.gif",
|
|
|
|
|
Txt_Banned_users,Txt_Banned_users,
|
|
|
|
|
NULL);
|
2014-12-17 23:04:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********* Generate a query to select messages received or sent **************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2018-11-01 01:40:35 +01:00
|
|
|
|
static unsigned long Msg_GetSentOrReceivedMsgs (long UsrCod,
|
|
|
|
|
long FilterCrsCod,
|
|
|
|
|
const char *FilterFromToSubquery,
|
|
|
|
|
MYSQL_RES **mysql_res)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2018-10-29 14:17:32 +01:00
|
|
|
|
char *SubQuery;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
const char *StrUnreadMsg;
|
2018-11-01 01:40:35 +01:00
|
|
|
|
unsigned long NumMsgs;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-04-12 01:40:51 +02:00
|
|
|
|
if (FilterCrsCod > 0) // If origin course selected
|
2016-11-07 12:31:14 +01:00
|
|
|
|
switch (Gbl.Msg.TypeOfMessages)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
case Msg_MESSAGES_RECEIVED:
|
|
|
|
|
StrUnreadMsg = (Gbl.Msg.ShowOnlyUnreadMsgs ? " AND msg_rcv.Open='N'" :
|
|
|
|
|
"");
|
|
|
|
|
if (FilterFromToSubquery[0])
|
2018-10-29 14:17:32 +01:00
|
|
|
|
{
|
|
|
|
|
if (asprintf (&SubQuery,"(SELECT msg_rcv.MsgCod"
|
|
|
|
|
" FROM msg_rcv,msg_snt,usr_data"
|
|
|
|
|
" WHERE msg_rcv.UsrCod=%ld%s"
|
|
|
|
|
" AND msg_rcv.MsgCod=msg_snt.MsgCod"
|
|
|
|
|
" AND msg_snt.CrsCod=%ld"
|
|
|
|
|
" AND msg_snt.UsrCod=usr_data.UsrCod%s)"
|
|
|
|
|
" UNION "
|
|
|
|
|
"(SELECT msg_rcv.MsgCod"
|
|
|
|
|
" FROM msg_rcv,msg_snt_deleted,usr_data"
|
|
|
|
|
" WHERE msg_rcv.UsrCod=%ld%s"
|
|
|
|
|
" AND msg_rcv.MsgCod=msg_snt_deleted.MsgCod"
|
|
|
|
|
" AND msg_snt_deleted.CrsCod=%ld"
|
|
|
|
|
" AND msg_snt_deleted.UsrCod=usr_data.UsrCod%s)",
|
|
|
|
|
UsrCod,StrUnreadMsg,FilterCrsCod,FilterFromToSubquery,
|
|
|
|
|
UsrCod,StrUnreadMsg,FilterCrsCod,FilterFromToSubquery) < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
2018-10-29 14:17:32 +01:00
|
|
|
|
{
|
|
|
|
|
if (asprintf (&SubQuery,"(SELECT msg_rcv.MsgCod"
|
|
|
|
|
" FROM msg_rcv,msg_snt"
|
|
|
|
|
" WHERE msg_rcv.UsrCod=%ld%s"
|
|
|
|
|
" AND msg_rcv.MsgCod=msg_snt.MsgCod"
|
|
|
|
|
" AND msg_snt.CrsCod=%ld)"
|
|
|
|
|
" UNION "
|
|
|
|
|
"(SELECT msg_rcv.MsgCod"
|
|
|
|
|
" FROM msg_rcv,msg_snt_deleted"
|
|
|
|
|
" WHERE msg_rcv.UsrCod=%ld%s"
|
|
|
|
|
" AND msg_rcv.MsgCod=msg_snt_deleted.MsgCod"
|
|
|
|
|
" AND msg_snt_deleted.CrsCod=%ld)",
|
|
|
|
|
UsrCod,StrUnreadMsg,FilterCrsCod,
|
|
|
|
|
UsrCod,StrUnreadMsg,FilterCrsCod) < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
case Msg_MESSAGES_SENT:
|
|
|
|
|
if (FilterFromToSubquery[0])
|
2018-10-29 14:17:32 +01:00
|
|
|
|
{
|
|
|
|
|
if (asprintf (&SubQuery,"(SELECT DISTINCT msg_snt.MsgCod"
|
|
|
|
|
" FROM msg_snt,msg_rcv,usr_data"
|
|
|
|
|
" WHERE msg_snt.UsrCod=%ld"
|
|
|
|
|
" AND msg_snt.CrsCod=%ld"
|
|
|
|
|
" AND msg_snt.MsgCod=msg_rcv.MsgCod"
|
|
|
|
|
" AND msg_rcv.UsrCod=usr_data.UsrCod%s)"
|
|
|
|
|
" UNION "
|
|
|
|
|
"(SELECT DISTINCT msg_snt.MsgCod"
|
|
|
|
|
" FROM msg_snt,msg_rcv_deleted,usr_data"
|
|
|
|
|
" WHERE msg_snt.UsrCod=%ld"
|
|
|
|
|
" AND msg_snt.CrsCod=%ld"
|
|
|
|
|
" AND msg_snt.MsgCod=msg_rcv_deleted.MsgCod"
|
|
|
|
|
" AND msg_rcv_deleted.UsrCod=usr_data.UsrCod%s)",
|
|
|
|
|
UsrCod,FilterCrsCod,FilterFromToSubquery,
|
|
|
|
|
UsrCod,FilterCrsCod,FilterFromToSubquery) < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
2018-10-29 14:17:32 +01:00
|
|
|
|
{
|
|
|
|
|
if (asprintf (&SubQuery,"SELECT MsgCod"
|
|
|
|
|
" FROM msg_snt"
|
|
|
|
|
" WHERE UsrCod=%ld AND CrsCod=%ld",
|
|
|
|
|
UsrCod,FilterCrsCod) < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
default: // Not aplicable here
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else // If no origin course selected
|
2016-11-07 12:31:14 +01:00
|
|
|
|
switch (Gbl.Msg.TypeOfMessages)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
case Msg_MESSAGES_RECEIVED:
|
|
|
|
|
if (FilterFromToSubquery[0])
|
|
|
|
|
{
|
|
|
|
|
StrUnreadMsg = (Gbl.Msg.ShowOnlyUnreadMsgs ? " AND msg_rcv.Open='N'" :
|
|
|
|
|
"");
|
2018-10-29 14:17:32 +01:00
|
|
|
|
if (asprintf (&SubQuery,"(SELECT msg_rcv.MsgCod"
|
|
|
|
|
" FROM msg_rcv,msg_snt,usr_data"
|
|
|
|
|
" WHERE msg_rcv.UsrCod=%ld%s"
|
|
|
|
|
" AND msg_rcv.MsgCod=msg_snt.MsgCod"
|
|
|
|
|
" AND msg_snt.UsrCod=usr_data.UsrCod%s)"
|
|
|
|
|
" UNION "
|
|
|
|
|
"(SELECT msg_rcv.MsgCod"
|
|
|
|
|
" FROM msg_rcv,msg_snt_deleted,usr_data"
|
|
|
|
|
" WHERE msg_rcv.UsrCod=%ld%s"
|
|
|
|
|
" AND msg_rcv.MsgCod=msg_snt_deleted.MsgCod"
|
|
|
|
|
" AND msg_snt_deleted.UsrCod=usr_data.UsrCod%s)",
|
|
|
|
|
UsrCod,StrUnreadMsg,FilterFromToSubquery,
|
|
|
|
|
UsrCod,StrUnreadMsg,FilterFromToSubquery) < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
StrUnreadMsg = (Gbl.Msg.ShowOnlyUnreadMsgs ? " AND Open='N'" :
|
|
|
|
|
"");
|
2018-10-29 14:17:32 +01:00
|
|
|
|
if (asprintf (&SubQuery,"SELECT MsgCod"
|
|
|
|
|
" FROM msg_rcv"
|
|
|
|
|
" WHERE UsrCod=%ld%s",
|
|
|
|
|
UsrCod,StrUnreadMsg) < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case Msg_MESSAGES_SENT:
|
|
|
|
|
if (FilterFromToSubquery[0])
|
2018-10-29 14:17:32 +01:00
|
|
|
|
{
|
|
|
|
|
if (asprintf (&SubQuery,"(SELECT msg_snt.MsgCod"
|
|
|
|
|
" FROM msg_snt,msg_rcv,usr_data"
|
|
|
|
|
" WHERE msg_snt.UsrCod=%ld"
|
|
|
|
|
" AND msg_snt.MsgCod=msg_rcv.MsgCod"
|
|
|
|
|
" AND msg_rcv.UsrCod=usr_data.UsrCod%s)"
|
|
|
|
|
" UNION "
|
|
|
|
|
"(SELECT msg_snt.MsgCod"
|
|
|
|
|
" FROM msg_snt,msg_rcv_deleted,usr_data"
|
|
|
|
|
" WHERE msg_snt.UsrCod=%ld"
|
|
|
|
|
" AND msg_snt.MsgCod=msg_rcv_deleted.MsgCod"
|
|
|
|
|
" AND msg_rcv_deleted.UsrCod=usr_data.UsrCod%s)",
|
|
|
|
|
UsrCod,FilterFromToSubquery,
|
|
|
|
|
UsrCod,FilterFromToSubquery) < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
2018-10-29 14:17:32 +01:00
|
|
|
|
{
|
|
|
|
|
if (asprintf (&SubQuery,"SELECT MsgCod"
|
|
|
|
|
" FROM msg_snt"
|
|
|
|
|
" WHERE UsrCod=%ld",
|
|
|
|
|
UsrCod) < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
default: // Not aplicable here
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Gbl.Msg.FilterContent[0])
|
2017-04-28 03:11:08 +02:00
|
|
|
|
/* Match against the content written in filter form */
|
2018-11-01 01:40:35 +01:00
|
|
|
|
NumMsgs = DB_QuerySELECT (mysql_res,"can not get messages",
|
|
|
|
|
"SELECT MsgCod"
|
|
|
|
|
" FROM msg_content"
|
|
|
|
|
" WHERE MsgCod IN (SELECT MsgCod FROM (%s) AS M)"
|
|
|
|
|
" AND MATCH (Subject,Content) AGAINST ('%s')"
|
|
|
|
|
" ORDER BY MsgCod DESC", // End the query ordering the result from most recent message to oldest
|
|
|
|
|
SubQuery,Gbl.Msg.FilterContent);
|
2018-10-29 14:17:32 +01:00
|
|
|
|
else
|
2018-11-01 01:40:35 +01:00
|
|
|
|
NumMsgs = DB_QuerySELECT (mysql_res,"can not get messages",
|
|
|
|
|
"%s"
|
|
|
|
|
" ORDER BY MsgCod DESC", // End the query ordering the result from most recent message to oldest
|
|
|
|
|
SubQuery);
|
2018-10-29 14:17:32 +01:00
|
|
|
|
|
|
|
|
|
/***** Free memory used for subquery *****/
|
|
|
|
|
free ((void *) SubQuery);
|
2018-11-01 01:40:35 +01:00
|
|
|
|
|
|
|
|
|
return NumMsgs;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**** Get the number of unique messages sent by any teacher from a course ****/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
unsigned Msg_GetNumMsgsSentByTchsCrs (long CrsCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Get the number of unique messages sent by any teacher from this course *****/
|
2018-11-03 20:52:00 +01:00
|
|
|
|
return
|
|
|
|
|
(unsigned) DB_QueryCOUNT ("can not get the number of messages"
|
|
|
|
|
" sent by teachers",
|
|
|
|
|
"SELECT COUNT(*) FROM msg_snt,crs_usr"
|
|
|
|
|
" WHERE msg_snt.CrsCod=%ld"
|
|
|
|
|
" AND crs_usr.CrsCod=%ld AND crs_usr.Role=%u"
|
|
|
|
|
" AND msg_snt.UsrCod=crs_usr.UsrCod",
|
|
|
|
|
CrsCod,CrsCod,(unsigned) Rol_TCH);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-09 18:39:59 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Get the number of unique messages sent by a user *************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-03-14 02:26:59 +01:00
|
|
|
|
unsigned long Msg_GetNumMsgsSentByUsr (long UsrCod)
|
2015-03-09 18:39:59 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get the number of unique messages sent by any teacher from this course *****/
|
2018-11-03 20:52:00 +01:00
|
|
|
|
return DB_QueryCOUNT ("can not get the number of messages sent by a user",
|
|
|
|
|
"SELECT"
|
2018-11-04 20:51:38 +01:00
|
|
|
|
" (SELECT COUNT(*) FROM msg_snt"
|
|
|
|
|
" WHERE UsrCod=%ld)"
|
2018-11-03 20:52:00 +01:00
|
|
|
|
" +"
|
2018-11-04 20:51:38 +01:00
|
|
|
|
" (SELECT COUNT(*) FROM msg_snt_deleted"
|
|
|
|
|
" WHERE UsrCod=%ld)",
|
2018-11-03 20:52:00 +01:00
|
|
|
|
UsrCod,
|
|
|
|
|
UsrCod);
|
2015-03-09 18:39:59 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******** Get the number of unique messages sent from this location **********/
|
|
|
|
|
/******** (all the platform, current degree or current course) **********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
unsigned Msg_GetNumMsgsSent (Sco_Scope_t Scope,Msg_Status_t MsgStatus)
|
|
|
|
|
{
|
|
|
|
|
const char *Table = "msg_snt";
|
2018-11-03 20:52:00 +01:00
|
|
|
|
unsigned NumMsgs = 0; // Initialized to avoid warning
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the number of messages sent from this location
|
|
|
|
|
(all the platform, current degree or current course) from database *****/
|
|
|
|
|
switch (MsgStatus)
|
|
|
|
|
{
|
|
|
|
|
case Msg_STATUS_ALL:
|
|
|
|
|
case Msg_STATUS_NOTIFIED:
|
|
|
|
|
Table = "msg_snt";
|
|
|
|
|
break;
|
|
|
|
|
case Msg_STATUS_DELETED:
|
|
|
|
|
Table = "msg_snt_deleted";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
switch (Scope)
|
|
|
|
|
{
|
2015-02-01 20:17:24 +01:00
|
|
|
|
case Sco_SCOPE_SYS:
|
2018-11-04 20:51:38 +01:00
|
|
|
|
NumMsgs = (unsigned) DB_GetNumRowsTable (Table);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2015-03-09 01:32:31 +01:00
|
|
|
|
case Sco_SCOPE_CTY:
|
2018-11-03 20:52:00 +01:00
|
|
|
|
NumMsgs =
|
|
|
|
|
(unsigned) DB_QueryCOUNT ("can not get number of sent messages",
|
|
|
|
|
"SELECT COUNT(*)"
|
|
|
|
|
" FROM institutions,centres,degrees,courses,%s"
|
|
|
|
|
" WHERE institutions.CtyCod=%ld"
|
|
|
|
|
" AND institutions.InsCod=centres.InsCod"
|
|
|
|
|
" AND centres.CtrCod=degrees.CtrCod"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.CrsCod=%s.CrsCod",
|
|
|
|
|
Table,
|
|
|
|
|
Gbl.CurrentCty.Cty.CtyCod,
|
|
|
|
|
Table);
|
2015-03-09 01:32:31 +01:00
|
|
|
|
break;
|
2015-02-01 20:17:24 +01:00
|
|
|
|
case Sco_SCOPE_INS:
|
2018-11-03 20:52:00 +01:00
|
|
|
|
NumMsgs =
|
|
|
|
|
(unsigned) DB_QueryCOUNT ("can not get number of sent messages",
|
|
|
|
|
"SELECT COUNT(*)"
|
|
|
|
|
" FROM centres,degrees,courses,%s"
|
|
|
|
|
" WHERE centres.InsCod=%ld"
|
|
|
|
|
" AND centres.CtrCod=degrees.CtrCod"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.CrsCod=%s.CrsCod",
|
|
|
|
|
Table,
|
|
|
|
|
Gbl.CurrentIns.Ins.InsCod,
|
|
|
|
|
Table);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2015-02-01 20:17:24 +01:00
|
|
|
|
case Sco_SCOPE_CTR:
|
2018-11-03 20:52:00 +01:00
|
|
|
|
NumMsgs =
|
|
|
|
|
(unsigned) DB_QueryCOUNT ("can not get number of sent messages",
|
|
|
|
|
"SELECT COUNT(*)"
|
|
|
|
|
" FROM degrees,courses,%s"
|
|
|
|
|
" WHERE degrees.CtrCod=%ld"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.CrsCod=%s.CrsCod",
|
|
|
|
|
Table,
|
|
|
|
|
Gbl.CurrentCtr.Ctr.CtrCod,
|
|
|
|
|
Table);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2015-02-01 20:17:24 +01:00
|
|
|
|
case Sco_SCOPE_DEG:
|
2018-11-03 20:52:00 +01:00
|
|
|
|
NumMsgs =
|
|
|
|
|
(unsigned) DB_QueryCOUNT ("can not get number of sent messages",
|
|
|
|
|
"SELECT COUNT(*)"
|
|
|
|
|
" FROM courses,%s"
|
|
|
|
|
" WHERE courses.DegCod=%ld"
|
|
|
|
|
" AND courses.CrsCod=%s.CrsCod",
|
|
|
|
|
Table,
|
|
|
|
|
Gbl.CurrentDeg.Deg.DegCod,
|
|
|
|
|
Table);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2015-02-01 20:17:24 +01:00
|
|
|
|
case Sco_SCOPE_CRS:
|
2018-11-03 20:52:00 +01:00
|
|
|
|
NumMsgs =
|
|
|
|
|
(unsigned) DB_QueryCOUNT ("can not get number of sent messages",
|
|
|
|
|
"SELECT COUNT(*)"
|
|
|
|
|
" FROM %s"
|
|
|
|
|
" WHERE CrsCod=%ld",
|
|
|
|
|
Table,
|
|
|
|
|
Gbl.CurrentCrs.Crs.CrsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2018-10-24 23:03:11 +02:00
|
|
|
|
Lay_WrongScopeExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
2018-11-03 20:52:00 +01:00
|
|
|
|
|
|
|
|
|
return NumMsgs;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****** Get the number of unique messages received from this location ********/
|
|
|
|
|
/****** (all the platform, current degree or current course) ********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
unsigned Msg_GetNumMsgsReceived (Sco_Scope_t Scope,Msg_Status_t MsgStatus)
|
|
|
|
|
{
|
|
|
|
|
char *Table;
|
2018-11-03 20:52:00 +01:00
|
|
|
|
unsigned NumMsgs = 0; // Initialized to avoid warning
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the number of unique messages sent from this location
|
|
|
|
|
(all the platform, current degree or current course) from database *****/
|
|
|
|
|
switch (MsgStatus)
|
|
|
|
|
{
|
|
|
|
|
case Msg_STATUS_ALL:
|
|
|
|
|
case Msg_STATUS_DELETED:
|
|
|
|
|
Table = (MsgStatus == Msg_STATUS_ALL) ? "msg_rcv" :
|
|
|
|
|
"msg_rcv_deleted";
|
|
|
|
|
switch (Scope)
|
|
|
|
|
{
|
2015-02-01 20:17:24 +01:00
|
|
|
|
case Sco_SCOPE_SYS:
|
2018-11-04 20:51:38 +01:00
|
|
|
|
NumMsgs = (unsigned) DB_GetNumRowsTable (Table);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2015-03-09 01:32:31 +01:00
|
|
|
|
case Sco_SCOPE_CTY:
|
2018-11-03 20:52:00 +01:00
|
|
|
|
NumMsgs =
|
|
|
|
|
(unsigned) DB_QueryCOUNT ("can not get number"
|
|
|
|
|
" of received messages",
|
|
|
|
|
"SELECT COUNT(*)"
|
|
|
|
|
" FROM institutions,centres,degrees,courses,%s,msg_snt"
|
|
|
|
|
" WHERE institutions.CtyCod=%ld"
|
|
|
|
|
" AND institutions.InsCod=centres.InsCod"
|
|
|
|
|
" AND centres.CtrCod=degrees.CtrCod"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.CrsCod=msg_snt.CrsCod"
|
|
|
|
|
" AND msg_snt.MsgCod=%s.MsgCod",
|
|
|
|
|
Table,
|
|
|
|
|
Gbl.CurrentCty.Cty.CtyCod,
|
|
|
|
|
Table);
|
2015-03-09 01:32:31 +01:00
|
|
|
|
break;
|
2015-02-01 20:17:24 +01:00
|
|
|
|
case Sco_SCOPE_INS:
|
2018-11-03 20:52:00 +01:00
|
|
|
|
NumMsgs =
|
|
|
|
|
(unsigned) DB_QueryCOUNT ("can not get number"
|
|
|
|
|
" of received messages",
|
|
|
|
|
"SELECT COUNT(*)"
|
|
|
|
|
" FROM centres,degrees,courses,%s,msg_snt"
|
|
|
|
|
" WHERE centres.InsCod=%ld"
|
|
|
|
|
" AND centres.CtrCod=degrees.CtrCod"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.CrsCod=msg_snt.CrsCod"
|
|
|
|
|
" AND msg_snt.MsgCod=%s.MsgCod",
|
|
|
|
|
Table,
|
|
|
|
|
Gbl.CurrentIns.Ins.InsCod,
|
|
|
|
|
Table);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2015-02-01 20:17:24 +01:00
|
|
|
|
case Sco_SCOPE_CTR:
|
2018-11-03 20:52:00 +01:00
|
|
|
|
NumMsgs =
|
|
|
|
|
(unsigned) DB_QueryCOUNT ("can not get number"
|
|
|
|
|
" of received messages",
|
|
|
|
|
"SELECT COUNT(*)"
|
|
|
|
|
" FROM degrees,courses,%s,msg_snt"
|
|
|
|
|
" WHERE degrees.CtrCod=%ld"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.CrsCod=msg_snt.CrsCod"
|
|
|
|
|
" AND msg_snt.MsgCod=%s.MsgCod",
|
|
|
|
|
Table,
|
|
|
|
|
Gbl.CurrentCtr.Ctr.CtrCod,
|
|
|
|
|
Table);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2015-02-01 20:17:24 +01:00
|
|
|
|
case Sco_SCOPE_DEG:
|
2018-11-03 20:52:00 +01:00
|
|
|
|
NumMsgs =
|
|
|
|
|
(unsigned) DB_QueryCOUNT ("can not get number"
|
|
|
|
|
" of received messages",
|
|
|
|
|
"SELECT COUNT(*)"
|
|
|
|
|
" FROM courses,%s,msg_snt"
|
|
|
|
|
" WHERE courses.DegCod=%ld"
|
|
|
|
|
" AND courses.CrsCod=msg_snt.CrsCod"
|
|
|
|
|
" AND msg_snt.MsgCod=%s.MsgCod",
|
|
|
|
|
Table,
|
|
|
|
|
Gbl.CurrentDeg.Deg.DegCod,
|
|
|
|
|
Table);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2015-02-01 20:17:24 +01:00
|
|
|
|
case Sco_SCOPE_CRS:
|
2018-11-03 20:52:00 +01:00
|
|
|
|
NumMsgs =
|
|
|
|
|
(unsigned) DB_QueryCOUNT ("can not get number"
|
|
|
|
|
" of received messages",
|
|
|
|
|
"SELECT COUNT(*)"
|
|
|
|
|
" FROM msg_snt,%s"
|
|
|
|
|
" WHERE msg_snt.CrsCod=%ld"
|
|
|
|
|
" AND msg_snt.MsgCod=%s.MsgCod",
|
|
|
|
|
Table,
|
|
|
|
|
Gbl.CurrentCrs.Crs.CrsCod,
|
|
|
|
|
Table);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2018-10-24 23:03:11 +02:00
|
|
|
|
Lay_WrongScopeExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case Msg_STATUS_NOTIFIED:
|
|
|
|
|
switch (Scope)
|
|
|
|
|
{
|
2015-02-01 20:17:24 +01:00
|
|
|
|
case Sco_SCOPE_SYS:
|
2018-11-03 20:52:00 +01:00
|
|
|
|
NumMsgs =
|
|
|
|
|
(unsigned) DB_QueryCOUNT ("can not get number"
|
|
|
|
|
" of received messages",
|
|
|
|
|
"SELECT "
|
|
|
|
|
"(SELECT COUNT(*)"
|
|
|
|
|
" FROM msg_rcv"
|
|
|
|
|
" WHERE Notified='Y')"
|
|
|
|
|
" + "
|
|
|
|
|
"(SELECT COUNT(*)"
|
|
|
|
|
" FROM msg_rcv_deleted"
|
|
|
|
|
" WHERE Notified='Y')");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2015-03-09 01:32:31 +01:00
|
|
|
|
case Sco_SCOPE_CTY:
|
2018-11-03 20:52:00 +01:00
|
|
|
|
NumMsgs =
|
|
|
|
|
(unsigned) DB_QueryCOUNT ("can not get number"
|
|
|
|
|
" of received messages",
|
|
|
|
|
"SELECT "
|
|
|
|
|
"(SELECT COUNT(*)"
|
|
|
|
|
" FROM institutions,centres,degrees,courses,msg_snt,msg_rcv"
|
|
|
|
|
" WHERE institutions.CtyCod=%ld"
|
|
|
|
|
" AND institutions.InsCod=centres.InsCod"
|
|
|
|
|
" AND centres.CtrCod=degrees.CtrCod"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.CrsCod=msg_snt.CrsCod"
|
|
|
|
|
" AND msg_snt.MsgCod=msg_rcv.MsgCod"
|
|
|
|
|
" AND msg_rcv.Notified='Y')"
|
|
|
|
|
" + "
|
|
|
|
|
"(SELECT COUNT(*)"
|
|
|
|
|
" FROM institutions,centres,degrees,courses,msg_snt,msg_rcv_deleted"
|
|
|
|
|
" WHERE institutions.CtyCod=%ld"
|
|
|
|
|
" AND institutions.InsCod=centres.InsCod"
|
|
|
|
|
" AND centres.CtrCod=degrees.CtrCod"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.CrsCod=msg_snt.CrsCod"
|
|
|
|
|
" AND msg_snt.MsgCod=msg_rcv_deleted.MsgCod"
|
|
|
|
|
" AND msg_rcv_deleted.Notified='Y')",
|
|
|
|
|
Gbl.CurrentCty.Cty.CtyCod,
|
|
|
|
|
Gbl.CurrentCty.Cty.CtyCod);
|
2015-03-09 01:32:31 +01:00
|
|
|
|
break;
|
2015-02-01 20:17:24 +01:00
|
|
|
|
case Sco_SCOPE_INS:
|
2018-11-03 20:52:00 +01:00
|
|
|
|
NumMsgs =
|
|
|
|
|
(unsigned) DB_QueryCOUNT ("can not get number"
|
|
|
|
|
" of received messages",
|
|
|
|
|
"SELECT "
|
|
|
|
|
"(SELECT COUNT(*)"
|
|
|
|
|
" FROM centres,degrees,courses,msg_snt,msg_rcv"
|
|
|
|
|
" WHERE centres.InsCod=%ld"
|
|
|
|
|
" AND centres.CtrCod=degrees.CtrCod"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.CrsCod=msg_snt.CrsCod"
|
|
|
|
|
" AND msg_snt.MsgCod=msg_rcv.MsgCod"
|
|
|
|
|
" AND msg_rcv.Notified='Y')"
|
|
|
|
|
" + "
|
|
|
|
|
"(SELECT COUNT(*)"
|
|
|
|
|
" FROM centres,degrees,courses,msg_snt,msg_rcv_deleted"
|
|
|
|
|
" WHERE centres.InsCod=%ld"
|
|
|
|
|
" AND centres.CtrCod=degrees.CtrCod"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.CrsCod=msg_snt.CrsCod"
|
|
|
|
|
" AND msg_snt.MsgCod=msg_rcv_deleted.MsgCod"
|
|
|
|
|
" AND msg_rcv_deleted.Notified='Y')",
|
|
|
|
|
Gbl.CurrentIns.Ins.InsCod,
|
|
|
|
|
Gbl.CurrentIns.Ins.InsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2015-02-01 20:17:24 +01:00
|
|
|
|
case Sco_SCOPE_CTR:
|
2018-11-03 20:52:00 +01:00
|
|
|
|
NumMsgs =
|
|
|
|
|
(unsigned) DB_QueryCOUNT ("can not get number"
|
|
|
|
|
" of received messages",
|
|
|
|
|
"SELECT "
|
|
|
|
|
"(SELECT COUNT(*)"
|
|
|
|
|
" FROM degrees,courses,msg_snt,msg_rcv"
|
|
|
|
|
" WHERE degrees.CtrCod=%ld"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.CrsCod=msg_snt.CrsCod"
|
|
|
|
|
" AND msg_snt.MsgCod=msg_rcv.MsgCod"
|
|
|
|
|
" AND msg_rcv.Notified='Y')"
|
|
|
|
|
" + "
|
|
|
|
|
"(SELECT COUNT(*)"
|
|
|
|
|
" FROM degrees,courses,msg_snt,msg_rcv_deleted"
|
|
|
|
|
" WHERE degrees.CtrCod=%ld"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.CrsCod=msg_snt.CrsCod"
|
|
|
|
|
" AND msg_snt.MsgCod=msg_rcv_deleted.MsgCod"
|
|
|
|
|
" AND msg_rcv_deleted.Notified='Y')",
|
|
|
|
|
Gbl.CurrentCtr.Ctr.CtrCod,
|
|
|
|
|
Gbl.CurrentCtr.Ctr.CtrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2015-02-01 20:17:24 +01:00
|
|
|
|
case Sco_SCOPE_DEG:
|
2018-11-03 20:52:00 +01:00
|
|
|
|
NumMsgs =
|
|
|
|
|
(unsigned) DB_QueryCOUNT ("can not get number"
|
|
|
|
|
" of received messages",
|
|
|
|
|
"SELECT "
|
|
|
|
|
"(SELECT COUNT(*)"
|
|
|
|
|
" FROM courses,msg_snt,msg_rcv"
|
|
|
|
|
" WHERE courses.DegCod=%ld"
|
|
|
|
|
" AND courses.CrsCod=msg_snt.CrsCod"
|
|
|
|
|
" AND msg_snt.MsgCod=msg_rcv.MsgCod"
|
|
|
|
|
" AND msg_rcv.Notified='Y')"
|
|
|
|
|
" + "
|
|
|
|
|
"(SELECT COUNT(*)"
|
|
|
|
|
" FROM courses,msg_snt,msg_rcv_deleted"
|
|
|
|
|
" WHERE courses.DegCod=%ld"
|
|
|
|
|
" AND courses.CrsCod=msg_snt.CrsCod"
|
|
|
|
|
" AND msg_snt.MsgCod=msg_rcv_deleted.MsgCod"
|
|
|
|
|
" AND msg_rcv_deleted.Notified='Y')",
|
|
|
|
|
Gbl.CurrentDeg.Deg.DegCod,
|
|
|
|
|
Gbl.CurrentDeg.Deg.DegCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2015-02-01 20:17:24 +01:00
|
|
|
|
case Sco_SCOPE_CRS:
|
2018-11-03 20:52:00 +01:00
|
|
|
|
NumMsgs =
|
|
|
|
|
(unsigned) DB_QueryCOUNT ("can not get number"
|
|
|
|
|
" of received messages",
|
|
|
|
|
"SELECT "
|
|
|
|
|
"(SELECT COUNT(*)"
|
|
|
|
|
" FROM msg_snt,msg_rcv"
|
|
|
|
|
" WHERE msg_snt.CrsCod=%ld"
|
|
|
|
|
" AND msg_snt.MsgCod=msg_rcv.MsgCod"
|
|
|
|
|
" AND msg_rcv.Notified='Y')"
|
|
|
|
|
" + "
|
|
|
|
|
"(SELECT COUNT(*)"
|
|
|
|
|
" FROM msg_snt,msg_rcv_deleted"
|
|
|
|
|
" WHERE msg_snt.CrsCod=%ld"
|
|
|
|
|
" AND msg_snt.MsgCod=msg_rcv_deleted.MsgCod"
|
|
|
|
|
" AND msg_rcv_deleted.Notified='Y')",
|
|
|
|
|
Gbl.CurrentCrs.Crs.CrsCod,
|
|
|
|
|
Gbl.CurrentCrs.Crs.CrsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2018-10-24 23:03:11 +02:00
|
|
|
|
Lay_WrongScopeExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2018-11-03 20:52:00 +01:00
|
|
|
|
|
|
|
|
|
return NumMsgs;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-03-21 14:50:23 +01:00
|
|
|
|
/********* Write number of messages and number of unread messages ************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2016-03-21 14:50:23 +01:00
|
|
|
|
// Fill Gbl.Title
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-11-07 12:31:14 +01:00
|
|
|
|
static char *Msg_WriteNumMsgs (unsigned NumUnreadMsgs)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-03-21 14:50:23 +01:00
|
|
|
|
extern const char *Txt_message_received;
|
|
|
|
|
extern const char *Txt_message_sent;
|
|
|
|
|
extern const char *Txt_messages_received;
|
|
|
|
|
extern const char *Txt_messages_sent;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_unread_MESSAGE;
|
|
|
|
|
extern const char *Txt_unread_MESSAGES;
|
|
|
|
|
|
2016-11-07 12:31:14 +01:00
|
|
|
|
switch (Gbl.Msg.TypeOfMessages)
|
2016-03-21 14:50:23 +01:00
|
|
|
|
{
|
2016-11-07 12:31:14 +01:00
|
|
|
|
case Msg_MESSAGES_RECEIVED:
|
|
|
|
|
if (Gbl.Msg.NumMsgs == 1)
|
|
|
|
|
{
|
|
|
|
|
if (NumUnreadMsgs)
|
2018-10-18 02:02:32 +02:00
|
|
|
|
snprintf (Gbl.Title,sizeof (Gbl.Title),
|
|
|
|
|
"1 %s, 1 %s",
|
|
|
|
|
Txt_message_received,Txt_unread_MESSAGE);
|
2016-11-07 12:31:14 +01:00
|
|
|
|
else
|
2018-10-18 02:02:32 +02:00
|
|
|
|
snprintf (Gbl.Title,sizeof (Gbl.Title),
|
|
|
|
|
"1 %s",
|
|
|
|
|
Txt_message_received);
|
2016-11-07 12:31:14 +01:00
|
|
|
|
}
|
2016-03-21 14:50:23 +01:00
|
|
|
|
else
|
2016-11-07 12:31:14 +01:00
|
|
|
|
{
|
|
|
|
|
if (NumUnreadMsgs == 0)
|
2018-10-18 02:02:32 +02:00
|
|
|
|
snprintf (Gbl.Title,sizeof (Gbl.Title),
|
|
|
|
|
"%u %s",
|
|
|
|
|
Gbl.Msg.NumMsgs,Txt_messages_received);
|
2016-11-07 12:31:14 +01:00
|
|
|
|
else if (NumUnreadMsgs == 1)
|
2018-10-18 02:02:32 +02:00
|
|
|
|
snprintf (Gbl.Title,sizeof (Gbl.Title),
|
|
|
|
|
"%u %s, 1 %s",
|
|
|
|
|
Gbl.Msg.NumMsgs,Txt_messages_received,
|
|
|
|
|
Txt_unread_MESSAGE);
|
2016-11-07 12:31:14 +01:00
|
|
|
|
else
|
2018-10-18 02:02:32 +02:00
|
|
|
|
snprintf (Gbl.Title,sizeof (Gbl.Title),
|
|
|
|
|
"%u %s, %u %s",
|
|
|
|
|
Gbl.Msg.NumMsgs,Txt_messages_received,
|
|
|
|
|
NumUnreadMsgs,Txt_unread_MESSAGES);
|
2016-11-07 12:31:14 +01:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case Msg_MESSAGES_SENT:
|
|
|
|
|
if (Gbl.Msg.NumMsgs == 1)
|
2018-10-18 02:02:32 +02:00
|
|
|
|
snprintf (Gbl.Title,sizeof (Gbl.Title),
|
|
|
|
|
"1 %s",
|
|
|
|
|
Txt_message_sent);
|
2016-03-21 14:50:23 +01:00
|
|
|
|
else
|
2018-10-18 02:02:32 +02:00
|
|
|
|
snprintf (Gbl.Title,sizeof (Gbl.Title),
|
|
|
|
|
"%u %s",
|
|
|
|
|
Gbl.Msg.NumMsgs,Txt_messages_sent);
|
2016-11-07 12:31:14 +01:00
|
|
|
|
break;
|
2016-03-21 14:50:23 +01:00
|
|
|
|
}
|
2016-11-07 12:31:14 +01:00
|
|
|
|
|
|
|
|
|
return Gbl.Title;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Put contextual icons in list of messages ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Msg_PutIconsListMsgs (void)
|
|
|
|
|
{
|
2017-05-02 12:13:27 +02:00
|
|
|
|
static const Act_Action_t ActionReqDelAllMsg[Msg_NUM_TYPES_OF_MSGS] =
|
|
|
|
|
{
|
|
|
|
|
ActReqDelAllRcvMsg,
|
|
|
|
|
ActReqDelAllSntMsg,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/***** Put icon to remove messages *****/
|
2017-06-11 19:13:28 +02:00
|
|
|
|
Ico_PutContextualIconToRemove (ActionReqDelAllMsg[Gbl.Msg.TypeOfMessages],
|
2017-05-02 11:50:58 +02:00
|
|
|
|
Msg_PutHiddenParamsMsgsFilters);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-11-07 12:31:14 +01:00
|
|
|
|
/***** Put icon to show a figure *****/
|
|
|
|
|
Gbl.Stat.FigureType = Sta_MESSAGES;
|
|
|
|
|
Sta_PutIconToShowFigure ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-05-02 12:13:27 +02:00
|
|
|
|
/******* Put hidden parameters to expand, contract or delete a message *******/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Msg_PutHiddenParamsOneMsg (void)
|
|
|
|
|
{
|
|
|
|
|
Pag_PutHiddenParamPagNum (Msg_WhatPaginate[Gbl.Msg.TypeOfMessages],
|
|
|
|
|
Gbl.Msg.CurrentPage);
|
|
|
|
|
Msg_PutHiddenParamMsgCod (Gbl.Msg.MsgCod);
|
|
|
|
|
Msg_PutHiddenParamsMsgsFilters ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Put hidden parameters with filters ***********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_PutHiddenParamsMsgsFilters (void)
|
|
|
|
|
{
|
|
|
|
|
if (Gbl.Msg.FilterCrsCod >= 0)
|
|
|
|
|
Par_PutHiddenParamLong ("FilterCrsCod",Gbl.Msg.FilterCrsCod);
|
|
|
|
|
if (Gbl.Msg.FilterFromTo[0])
|
|
|
|
|
Par_PutHiddenParamString ("FilterFromTo",Gbl.Msg.FilterFromTo);
|
|
|
|
|
if (Gbl.Msg.FilterContent[0])
|
|
|
|
|
Par_PutHiddenParamString ("FilterContent",Gbl.Msg.FilterContent);
|
|
|
|
|
if (Gbl.Msg.ShowOnlyUnreadMsgs)
|
|
|
|
|
Par_PutHiddenParamChar ("OnlyUnreadMsgs",'Y');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Get dictinct courses in my messages *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-11-07 12:31:14 +01:00
|
|
|
|
void Msg_GetDistinctCoursesInMyMessages (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2018-11-01 01:40:35 +01:00
|
|
|
|
unsigned long NumRow;
|
|
|
|
|
unsigned long NumRows = 0; // Initialized to avoid warning
|
2014-12-01 23:55:08 +01:00
|
|
|
|
struct Course Crs;
|
|
|
|
|
|
|
|
|
|
/***** Get distinct courses in my messages from database *****/
|
2016-11-07 12:31:14 +01:00
|
|
|
|
switch (Gbl.Msg.TypeOfMessages)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
case Msg_MESSAGES_RECEIVED:
|
2018-11-01 01:40:35 +01:00
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get distinct courses"
|
|
|
|
|
" in your messages",""
|
|
|
|
|
"SELECT DISTINCT courses.CrsCod,courses.ShortName"
|
|
|
|
|
" FROM msg_rcv,msg_snt,courses"
|
|
|
|
|
" WHERE msg_rcv.UsrCod=%ld"
|
|
|
|
|
" AND msg_rcv.MsgCod=msg_snt.MsgCod"
|
|
|
|
|
" AND msg_snt.CrsCod=courses.CrsCod"
|
|
|
|
|
" ORDER BY courses.ShortName",
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
case Msg_MESSAGES_SENT:
|
2018-11-01 01:40:35 +01:00
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get distinct courses"
|
|
|
|
|
" in your messages",
|
|
|
|
|
"SELECT DISTINCT courses.CrsCod,courses.ShortName"
|
|
|
|
|
" FROM msg_snt,courses"
|
|
|
|
|
" WHERE msg_snt.UsrCod=%ld"
|
|
|
|
|
" AND msg_snt.CrsCod=courses.CrsCod"
|
|
|
|
|
" ORDER BY courses.ShortName",
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
default: // Not aplicable here
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Get distinct courses in messages from database *****/
|
|
|
|
|
Gbl.Msg.NumCourses = 0;
|
|
|
|
|
for (NumRow = 0;
|
|
|
|
|
NumRow < NumRows;
|
|
|
|
|
NumRow++)
|
|
|
|
|
{
|
|
|
|
|
/* Get next course */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
Crs.CrsCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
|
|
|
if (Crs.CrsCod >= 0 && Gbl.Msg.NumCourses < Crs_MAX_COURSES_PER_USR)
|
|
|
|
|
if (Crs_GetDataOfCourseByCod (&Crs))
|
|
|
|
|
{
|
|
|
|
|
Gbl.Msg.Courses[Gbl.Msg.NumCourses].CrsCod = Crs.CrsCod;
|
2017-01-15 22:58:26 +01:00
|
|
|
|
Str_Copy (Gbl.Msg.Courses[Gbl.Msg.NumCourses].ShrtName,Crs.ShrtName,
|
2017-03-08 14:12:33 +01:00
|
|
|
|
Hie_MAX_BYTES_SHRT_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Gbl.Msg.NumCourses++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********* Show form to select course for sent or received messages **********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-11-07 12:31:14 +01:00
|
|
|
|
void Msg_ShowFormSelectCourseSentOrRecMsgs (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2015-07-28 00:16:09 +02:00
|
|
|
|
extern const char *The_ClassForm[The_NUM_THEMES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Messages_received_from_A_COURSE;
|
|
|
|
|
extern const char *Txt_Messages_sent_from_A_COURSE;
|
|
|
|
|
extern const char *Txt_any_course;
|
|
|
|
|
unsigned NumOriginCrs;
|
2016-11-07 12:31:14 +01:00
|
|
|
|
const char *TxtSelector[Msg_NUM_TYPES_OF_MSGS] =
|
|
|
|
|
{
|
|
|
|
|
Txt_Messages_received_from_A_COURSE,
|
|
|
|
|
Txt_Messages_sent_from_A_COURSE
|
|
|
|
|
};
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Course selection *****/
|
2016-12-27 16:45:37 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<label class=\"%s\">%s "
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"<select name=\"FilterCrsCod\">"
|
|
|
|
|
"<option value=\"\"",
|
2015-07-28 00:16:09 +02:00
|
|
|
|
The_ClassForm[Gbl.Prefs.Theme],
|
2016-11-07 12:31:14 +01:00
|
|
|
|
TxtSelector[Gbl.Msg.TypeOfMessages]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Gbl.Msg.FilterCrsCod < 0)
|
|
|
|
|
fprintf (Gbl.F.Out," selected=\"selected\"");
|
|
|
|
|
fprintf (Gbl.F.Out,">%s</option>",Txt_any_course);
|
|
|
|
|
|
|
|
|
|
/***** Write an option for each user's course *****/
|
|
|
|
|
for (NumOriginCrs = 0;
|
|
|
|
|
NumOriginCrs < Gbl.Msg.NumCourses;
|
|
|
|
|
NumOriginCrs++)
|
|
|
|
|
{
|
|
|
|
|
fprintf (Gbl.F.Out,"<option value=\"%ld\"",Gbl.Msg.Courses[NumOriginCrs].CrsCod);
|
|
|
|
|
if (Gbl.Msg.Courses[NumOriginCrs].CrsCod == Gbl.Msg.FilterCrsCod)
|
|
|
|
|
fprintf (Gbl.F.Out," selected=\"selected\""); // Select origin course
|
2016-10-28 10:03:37 +02:00
|
|
|
|
fprintf (Gbl.F.Out,">%s</option>",Gbl.Msg.Courses[NumOriginCrs].ShrtName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2016-12-27 16:45:37 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</select>"
|
|
|
|
|
"</label>");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***** Show form to filter "from" and "to" for received or sent messages *****/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-11-07 12:31:14 +01:00
|
|
|
|
void Msg_ShowFormToFilterMsgs (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2015-07-28 00:16:09 +02:00
|
|
|
|
extern const char *The_ClassForm[The_NUM_THEMES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_MSG_From;
|
|
|
|
|
extern const char *Txt_MSG_To;
|
2017-04-19 14:27:52 +02:00
|
|
|
|
extern const char *Txt_MSG_Content;
|
2016-11-07 12:31:14 +01:00
|
|
|
|
const char *TxtFromTo[Msg_NUM_TYPES_OF_MSGS] =
|
|
|
|
|
{
|
|
|
|
|
Txt_MSG_From,
|
|
|
|
|
Txt_MSG_To
|
|
|
|
|
};
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** Start table *****/
|
2017-06-11 20:09:59 +02:00
|
|
|
|
Tbl_StartTableCenter (2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-12-19 09:39:08 +01:00
|
|
|
|
/***** Filter authors/recipients *****/
|
2017-05-01 12:36:24 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
|
|
|
|
"<td class=\"LEFT_MIDDLE\">"
|
2016-03-29 01:12:43 +02:00
|
|
|
|
"<label class=\"%s\">"
|
2016-12-20 02:18:50 +01:00
|
|
|
|
"%s: "
|
2016-12-19 09:39:08 +01:00
|
|
|
|
"<input type=\"search\" name=\"FilterFromTo\""
|
2016-11-23 22:43:27 +01:00
|
|
|
|
" size=\"20\" maxlength=\"%u\" value=\"%s\" />"
|
2016-12-20 02:18:50 +01:00
|
|
|
|
"</label>"
|
2016-11-23 21:06:37 +01:00
|
|
|
|
"</td>",
|
2015-07-28 00:16:09 +02:00
|
|
|
|
The_ClassForm[Gbl.Prefs.Theme],
|
2016-11-07 12:31:14 +01:00
|
|
|
|
TxtFromTo[Gbl.Msg.TypeOfMessages],
|
2017-03-07 19:55:29 +01:00
|
|
|
|
Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME * 3,Gbl.Msg.FilterFromTo);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-12-19 09:39:08 +01:00
|
|
|
|
/***** Filter message content *****/
|
2016-11-23 21:06:37 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\">"
|
2016-03-29 01:12:43 +02:00
|
|
|
|
"<label class=\"%s\">"
|
2016-12-20 02:18:50 +01:00
|
|
|
|
"%s: "
|
2016-12-19 09:39:08 +01:00
|
|
|
|
"<input type=\"search\" name=\"FilterContent\""
|
2016-11-23 22:43:27 +01:00
|
|
|
|
" size=\"20\" maxlength=\"%u\" value=\"%s\" />"
|
2016-12-20 02:18:50 +01:00
|
|
|
|
"</label>"
|
2017-05-01 12:36:24 +02:00
|
|
|
|
"</td>"
|
|
|
|
|
"</tr>",
|
2015-07-28 00:16:09 +02:00
|
|
|
|
The_ClassForm[Gbl.Prefs.Theme],
|
2017-04-19 14:27:52 +02:00
|
|
|
|
Txt_MSG_Content,
|
2017-03-07 19:55:29 +01:00
|
|
|
|
Msg_MAX_CHARS_FILTER_CONTENT,Gbl.Msg.FilterContent);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-03-20 13:47:46 +01:00
|
|
|
|
/***** End table *****/
|
2017-06-11 20:09:59 +02:00
|
|
|
|
Tbl_EndTable ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**** Show form to select whether to show only unread (received) messages ****/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Msg_ShowFormToShowOnlyUnreadMessages (void)
|
|
|
|
|
{
|
2015-07-28 00:16:09 +02:00
|
|
|
|
extern const char *The_ClassForm[The_NUM_THEMES];
|
2016-11-23 21:06:37 +01:00
|
|
|
|
extern const char *Txt_only_unread_messages;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Put checkbox to select whether to show only unread (received) messages *****/
|
2016-12-24 14:05:59 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<label class=\"%s\">"
|
|
|
|
|
"<input type=\"checkbox\" name=\"OnlyUnreadMsgs\""
|
|
|
|
|
" value=\"Y\"",
|
|
|
|
|
The_ClassForm[Gbl.Prefs.Theme]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Gbl.Msg.ShowOnlyUnreadMsgs)
|
|
|
|
|
fprintf (Gbl.F.Out," checked=\"checked\"");
|
2016-11-23 21:06:37 +01:00
|
|
|
|
fprintf (Gbl.F.Out," />"
|
2016-12-24 14:05:59 +01:00
|
|
|
|
"%s"
|
|
|
|
|
"</label>",
|
2016-11-23 21:06:37 +01:00
|
|
|
|
Txt_only_unread_messages);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********** Get parameter to show only unread (received) messages ***********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Msg_GetParamOnlyUnreadMsgs (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Get parameter to show only unread (received) messages *****/
|
2017-01-28 20:32:50 +01:00
|
|
|
|
Gbl.Msg.ShowOnlyUnreadMsgs = Par_GetParToBool ("OnlyUnreadMsgs");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Get data of a message *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-10-24 20:12:03 +02:00
|
|
|
|
static void Msg_GetMsgSntData (long MsgCod,long *CrsCod,long *UsrCod,
|
2017-01-17 03:10:43 +01:00
|
|
|
|
time_t *CreatTimeUTC,
|
|
|
|
|
char Subject[Cns_MAX_BYTES_SUBJECT + 1],
|
|
|
|
|
bool *Deleted)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned long NumRows;
|
|
|
|
|
|
|
|
|
|
/***** Get data of message from table msg_snt *****/
|
|
|
|
|
*Deleted = false;
|
2018-11-01 12:02:58 +01:00
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get data of a message",
|
|
|
|
|
"SELECT CrsCod,UsrCod,UNIX_TIMESTAMP(CreatTime)"
|
|
|
|
|
" FROM msg_snt WHERE MsgCod=%ld",
|
|
|
|
|
MsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
if (NumRows == 0) // If not result ==> sent message is deleted
|
|
|
|
|
{
|
|
|
|
|
/***** Get data of message from table msg_snt_deleted *****/
|
2018-11-01 12:02:58 +01:00
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get data of a message",
|
|
|
|
|
"SELECT CrsCod,UsrCod,UNIX_TIMESTAMP(CreatTime)"
|
|
|
|
|
" FROM msg_snt_deleted WHERE MsgCod=%ld",
|
|
|
|
|
MsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
*Deleted = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Result should have a unique row */
|
|
|
|
|
if (NumRows != 1)
|
|
|
|
|
Lay_ShowErrorAndExit ("Error when getting data of a message.");
|
|
|
|
|
|
|
|
|
|
/* Get number of rows */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get location (row[0]) */
|
|
|
|
|
*CrsCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
|
|
|
|
|
|
|
|
/* Get author code (row[1]) */
|
|
|
|
|
*UsrCod = Str_ConvertStrCodToLongCod (row[1]);
|
|
|
|
|
|
|
|
|
|
/* Get creation time (row[2]) */
|
2015-10-24 20:12:03 +02:00
|
|
|
|
*CreatTimeUTC = Dat_GetUNIXTimeFromStr (row[2]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Free structure that stores the query result */
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
/***** Get subject of message from database *****/
|
|
|
|
|
Msg_GetMsgSubject (MsgCod,Subject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Get the subject of a message ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-01-17 03:10:43 +01:00
|
|
|
|
void Msg_GetMsgSubject (long MsgCod,char Subject[Cns_MAX_BYTES_SUBJECT + 1])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
|
|
|
|
|
/***** Get subject of message from database *****/
|
2018-11-01 12:02:58 +01:00
|
|
|
|
if (DB_QuerySELECT (&mysql_res,"can not get the subject of a message",
|
|
|
|
|
"SELECT Subject FROM msg_content"
|
|
|
|
|
" WHERE MsgCod=%ld",
|
|
|
|
|
MsgCod) == 1) // Result should have a unique row
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get subject *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2017-01-17 03:10:43 +01:00
|
|
|
|
Str_Copy (Subject,row[0],
|
|
|
|
|
Cns_MAX_BYTES_SUBJECT);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Subject[0] = '\0';
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-04-10 19:19:20 +02:00
|
|
|
|
/*************** Get content and optional image of a message *****************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-01-17 03:10:43 +01:00
|
|
|
|
static void Msg_GetMsgContent (long MsgCod,char Content[Cns_MAX_BYTES_LONG_TEXT + 1],
|
|
|
|
|
struct Image *Image)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned long NumRows;
|
|
|
|
|
|
|
|
|
|
/***** Get content of message from database *****/
|
2018-11-01 12:02:58 +01:00
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get the content of a message",
|
|
|
|
|
"SELECT Content,ImageName,ImageTitle,ImageURL"
|
|
|
|
|
" FROM msg_content WHERE MsgCod=%ld",
|
|
|
|
|
MsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Result should have a unique row *****/
|
|
|
|
|
if (NumRows != 1)
|
|
|
|
|
Lay_ShowErrorAndExit ("Error when getting content of a message.");
|
|
|
|
|
|
|
|
|
|
/***** Get number of rows *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
2015-12-29 23:44:28 +01:00
|
|
|
|
/****** Get content (row[0]) *****/
|
2017-01-17 03:10:43 +01:00
|
|
|
|
Str_Copy (Content,row[0],
|
|
|
|
|
Cns_MAX_BYTES_LONG_TEXT);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-04-15 02:33:16 +02:00
|
|
|
|
/****** Get image name (row[1]), title (row[2]) and URL (row[3]) *****/
|
|
|
|
|
Img_GetImageNameTitleAndURLFromRow (row[1],row[2],row[3],Image);
|
2016-04-10 19:19:20 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Get if a sent message is expanded ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Msg_GetStatusOfSentMsg (long MsgCod,bool *Expanded)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned long NumRows;
|
|
|
|
|
|
|
|
|
|
/***** Get if sent message has been replied/expanded from database *****/
|
2018-11-01 12:02:58 +01:00
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get if a sent message"
|
|
|
|
|
" has been replied/expanded",
|
|
|
|
|
"SELECT Expanded FROM msg_snt"
|
|
|
|
|
" WHERE MsgCod=%ld AND UsrCod=%ld",
|
|
|
|
|
MsgCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Result should have a unique row *****/
|
|
|
|
|
if (NumRows != 1)
|
|
|
|
|
Lay_ShowErrorAndExit ("Error when getting if a sent message has been replied/expanded.");
|
|
|
|
|
|
|
|
|
|
/***** Get number of rows *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/***** Get if message is expanded *****/
|
2016-09-07 18:48:10 +02:00
|
|
|
|
*Expanded = (row[0][0] == 'Y');
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Get if a received message has been replied ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Msg_GetStatusOfReceivedMsg (long MsgCod,bool *Open,bool *Replied,bool *Expanded)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned long NumRows;
|
|
|
|
|
|
|
|
|
|
/***** Get if received message has been replied/expanded from database *****/
|
2018-11-01 12:02:58 +01:00
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get if a received message"
|
|
|
|
|
" has been replied/expanded",
|
|
|
|
|
"SELECT Open,Replied,Expanded FROM msg_rcv"
|
|
|
|
|
" WHERE MsgCod=%ld AND UsrCod=%ld",
|
|
|
|
|
MsgCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Result should have a unique row *****/
|
|
|
|
|
if (NumRows != 1)
|
|
|
|
|
Lay_ShowErrorAndExit ("Error when getting if a received message has been replied/expanded.");
|
|
|
|
|
|
|
|
|
|
/***** Get number of rows *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/***** Get if message has been read by me *****/
|
2016-09-07 18:48:10 +02:00
|
|
|
|
*Open = (row[0][0] == 'Y');
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get if message has been replied *****/
|
2016-09-07 18:48:10 +02:00
|
|
|
|
*Replied = (row[1][0] == 'Y');
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get if message is expanded *****/
|
2016-09-07 18:48:10 +02:00
|
|
|
|
*Expanded = (row[2][0] == 'Y');
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******** Show a sent or a received message (from a user to another) *********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-11-07 12:31:14 +01:00
|
|
|
|
static void Msg_ShowASentOrReceivedMessage (long MsgNum,long MsgCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_MSG_Replied;
|
|
|
|
|
extern const char *Txt_MSG_Not_replied;
|
|
|
|
|
extern const char *Txt_MSG_Unopened;
|
|
|
|
|
extern const char *Txt_MSG_Sent;
|
|
|
|
|
extern const char *Txt_MSG_From;
|
|
|
|
|
extern const char *Txt_MSG_To;
|
2017-04-19 14:27:52 +02:00
|
|
|
|
extern const char *Txt_MSG_Content;
|
2017-05-02 12:13:27 +02:00
|
|
|
|
static const Act_Action_t ActionDelMsg[Msg_NUM_TYPES_OF_MSGS] =
|
|
|
|
|
{
|
|
|
|
|
ActDelRcvMsg,
|
|
|
|
|
ActDelSntMsg,
|
|
|
|
|
};
|
2014-12-01 23:55:08 +01:00
|
|
|
|
struct UsrData UsrDat;
|
2016-11-08 00:58:32 +01:00
|
|
|
|
const char *Title = NULL; // Initialized to avoid warning
|
2015-10-24 20:12:03 +02:00
|
|
|
|
bool FromThisCrs = false; // Initialized to avoid warning
|
|
|
|
|
time_t CreatTimeUTC; // Creation time of a message
|
2014-12-01 23:55:08 +01:00
|
|
|
|
long CrsCod;
|
2017-01-17 03:10:43 +01:00
|
|
|
|
char Subject[Cns_MAX_BYTES_SUBJECT + 1];
|
|
|
|
|
char Content[Cns_MAX_BYTES_LONG_TEXT + 1];
|
2016-04-10 19:19:20 +02:00
|
|
|
|
struct Image Image;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool Deleted;
|
|
|
|
|
bool Open = true;
|
2015-10-24 20:12:03 +02:00
|
|
|
|
bool Replied = false; // Initialized to avoid warning
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool Expanded = false;
|
|
|
|
|
|
|
|
|
|
/***** Initialize structure with user's data *****/
|
|
|
|
|
Usr_UsrDataConstructor (&UsrDat);
|
|
|
|
|
|
|
|
|
|
/***** Get data of message *****/
|
2015-10-24 20:12:03 +02:00
|
|
|
|
Msg_GetMsgSntData (MsgCod,&CrsCod,&UsrDat.UsrCod,&CreatTimeUTC,Subject,&Deleted);
|
2016-11-07 12:31:14 +01:00
|
|
|
|
switch (Gbl.Msg.TypeOfMessages)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
case Msg_MESSAGES_RECEIVED:
|
|
|
|
|
Msg_GetStatusOfReceivedMsg (MsgCod,&Open,&Replied,&Expanded);
|
|
|
|
|
break;
|
|
|
|
|
case Msg_MESSAGES_SENT:
|
|
|
|
|
Msg_GetStatusOfSentMsg (MsgCod,&Expanded);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Put an icon with message status *****/
|
2016-11-07 12:31:14 +01:00
|
|
|
|
switch (Gbl.Msg.TypeOfMessages)
|
|
|
|
|
{
|
|
|
|
|
case Msg_MESSAGES_RECEIVED:
|
|
|
|
|
Title = (Open ? (Replied ? Txt_MSG_Replied :
|
|
|
|
|
Txt_MSG_Not_replied) :
|
|
|
|
|
Txt_MSG_Unopened);
|
|
|
|
|
break;
|
|
|
|
|
case Msg_MESSAGES_SENT:
|
|
|
|
|
Title = Txt_MSG_Sent;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2017-05-02 12:13:27 +02:00
|
|
|
|
"<td class=\"CONTEXT_COL %s\">"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"<img src=\"%s/msg-%s16x16.gif\""
|
2015-07-22 11:56:26 +02:00
|
|
|
|
" alt=\"%s\" title=\"%s\""
|
2016-11-14 10:05:41 +01:00
|
|
|
|
" class=\"ICO20x20\" />",
|
2016-11-07 12:31:14 +01:00
|
|
|
|
Gbl.Msg.TypeOfMessages == Msg_MESSAGES_RECEIVED ? (Open ? "BG_MSG_BLUE" :
|
|
|
|
|
"BG_MSG_GREEN") :
|
|
|
|
|
"BG_MSG_BLUE",
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
Gbl.Prefs.IconsURL,
|
2016-11-07 12:31:14 +01:00
|
|
|
|
Gbl.Msg.TypeOfMessages == Msg_MESSAGES_RECEIVED ? (Open ? (Replied ? "replied" :
|
|
|
|
|
"open") :
|
|
|
|
|
"unread") :
|
|
|
|
|
"fwd",
|
2015-07-22 11:56:26 +02:00
|
|
|
|
Title,Title);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Form to delete message *****/
|
2015-09-06 13:19:12 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<br />");
|
2017-05-02 12:13:27 +02:00
|
|
|
|
Gbl.Msg.MsgCod = MsgCod; // Message to be deleted
|
2017-06-11 19:13:28 +02:00
|
|
|
|
Ico_PutContextualIconToRemove (ActionDelMsg[Gbl.Msg.TypeOfMessages],
|
2017-05-02 12:13:27 +02:00
|
|
|
|
Msg_PutHiddenParamsOneMsg);
|
2015-09-06 13:19:12 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"</td>");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write message number *****/
|
|
|
|
|
Msg_WriteMsgNumber (MsgNum,!Open);
|
|
|
|
|
|
|
|
|
|
/***** Write message author *****/
|
|
|
|
|
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat);
|
2017-05-02 01:05:23 +02:00
|
|
|
|
|
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"%s LEFT_TOP\">",
|
|
|
|
|
Open ? "MSG_AUT_BG" :
|
|
|
|
|
"MSG_AUT_BG_NEW");
|
2017-05-02 01:16:06 +02:00
|
|
|
|
Msg_WriteMsgAuthor (&UsrDat,true,NULL);
|
2017-05-02 01:05:23 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"</td>");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write subject *****/
|
2016-11-07 12:31:14 +01:00
|
|
|
|
Msg_WriteSentOrReceivedMsgSubject (MsgCod,Subject,Open,Expanded);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-10-24 20:12:03 +02:00
|
|
|
|
/***** Write date-time *****/
|
|
|
|
|
Msg_WriteMsgDate (CreatTimeUTC,Open ? "MSG_TIT_BG" :
|
|
|
|
|
"MSG_TIT_BG_NEW");
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</tr>");
|
|
|
|
|
|
|
|
|
|
if (Expanded)
|
|
|
|
|
{
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2017-05-02 01:05:23 +02:00
|
|
|
|
"<td rowspan=\"3\" colspan=\"2\" class=\"LEFT_TOP\">");
|
2017-06-11 20:09:59 +02:00
|
|
|
|
Tbl_StartTable (2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write course origin of message *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2015-08-06 14:16:11 +02:00
|
|
|
|
"<td class=\"LEFT_MIDDLE\">");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
FromThisCrs = Msg_WriteCrsOrgMsg (CrsCod);
|
|
|
|
|
fprintf (Gbl.F.Out,"</td>"
|
|
|
|
|
"</tr>");
|
|
|
|
|
|
|
|
|
|
/***** Form to reply message *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2015-08-06 14:16:11 +02:00
|
|
|
|
"<td class=\"LEFT_MIDDLE\">");
|
2016-11-07 12:31:14 +01:00
|
|
|
|
if (Gbl.Msg.TypeOfMessages == Msg_MESSAGES_RECEIVED &&
|
2017-06-04 18:18:54 +02:00
|
|
|
|
Gbl.Usrs.Me.Role.Logged >= Rol_USR)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
// Guests (users without courses) can read messages but not reply them
|
2016-07-01 01:21:34 +02:00
|
|
|
|
Msg_WriteFormToReply (MsgCod,CrsCod,FromThisCrs,Replied,&UsrDat);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</td>"
|
2017-05-01 21:17:38 +02:00
|
|
|
|
"</tr>");
|
|
|
|
|
|
2017-06-11 20:09:59 +02:00
|
|
|
|
Tbl_EndTable ();
|
2017-05-01 21:17:38 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"</td>");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write "From:" *****/
|
2016-12-20 02:18:50 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"RIGHT_TOP MSG_TIT\">"
|
|
|
|
|
"%s: "
|
2014-12-23 17:12:45 +01:00
|
|
|
|
"</td>"
|
2015-08-06 14:16:11 +02:00
|
|
|
|
"<td colspan=\"2\" class=\"LEFT_TOP\">",
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Txt_MSG_From);
|
|
|
|
|
Msg_WriteMsgFrom (&UsrDat,Deleted);
|
|
|
|
|
fprintf (Gbl.F.Out,"</td>"
|
|
|
|
|
"</tr>");
|
|
|
|
|
|
|
|
|
|
/***** Write "To:" *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2016-12-20 02:18:50 +01:00
|
|
|
|
"<td class=\"RIGHT_TOP MSG_TIT\">"
|
|
|
|
|
"%s: "
|
2014-12-23 17:12:45 +01:00
|
|
|
|
"</td>"
|
2015-08-06 14:16:11 +02:00
|
|
|
|
"<td colspan=\"2\" class=\"LEFT_TOP\">",
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Txt_MSG_To);
|
2016-11-07 12:31:14 +01:00
|
|
|
|
Msg_WriteMsgTo (MsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</td>"
|
|
|
|
|
"</tr>");
|
|
|
|
|
|
2017-04-19 14:27:52 +02:00
|
|
|
|
/***** Write "Content:" *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2016-12-20 02:18:50 +01:00
|
|
|
|
"<td class=\"RIGHT_TOP MSG_TIT\">"
|
|
|
|
|
"%s: "
|
2016-04-10 19:19:20 +02:00
|
|
|
|
"</td>",
|
2017-04-19 14:27:52 +02:00
|
|
|
|
Txt_MSG_Content);
|
2016-04-10 19:19:20 +02:00
|
|
|
|
|
|
|
|
|
/***** Initialize image *****/
|
|
|
|
|
Img_ImageConstructor (&Image);
|
|
|
|
|
|
|
|
|
|
/***** Get message content and optional image *****/
|
|
|
|
|
Msg_GetMsgContent (MsgCod,Content,&Image);
|
|
|
|
|
|
|
|
|
|
/***** Show content and image *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<td colspan=\"2\" class=\"MSG_TXT LEFT_TOP\">");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Content[0])
|
|
|
|
|
Msg_WriteMsgContent (Content,Cns_MAX_BYTES_LONG_TEXT,true,false);
|
2016-04-15 14:30:28 +02:00
|
|
|
|
Img_ShowImage (&Image,"MSG_IMG_CONTAINER","MSG_IMG");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</td>"
|
|
|
|
|
"</tr>");
|
2016-04-10 19:19:20 +02:00
|
|
|
|
|
|
|
|
|
/***** Free image *****/
|
|
|
|
|
Img_ImageDestructor (&Image);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free memory used for user's data *****/
|
|
|
|
|
Usr_UsrDataDestructor (&UsrDat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-01-22 12:05:25 +01:00
|
|
|
|
/******************** Get subject and content of a message *******************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-03-08 14:12:33 +01:00
|
|
|
|
void Msg_GetNotifMessage (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
2017-03-06 13:01:16 +01:00
|
|
|
|
char **ContentStr,long MsgCod,bool GetContent)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_MSG_Subject;
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2017-01-15 22:58:26 +01:00
|
|
|
|
size_t Length;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
SummaryStr[0] = '\0'; // Return nothing on error
|
2018-10-23 01:01:51 +02:00
|
|
|
|
// This function may be called inside a web service, so don't report error
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get subject of message from database *****/
|
2018-11-01 12:02:58 +01:00
|
|
|
|
if (DB_QuerySELECT (&mysql_res,"can not get subject and content"
|
|
|
|
|
" of a message",
|
|
|
|
|
"SELECT Subject,Content FROM msg_content"
|
|
|
|
|
" WHERE MsgCod=%ld",
|
|
|
|
|
MsgCod) == 1) // Result should have a unique row
|
2018-10-23 01:01:51 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Get subject and content of the message *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2018-10-23 01:01:51 +02:00
|
|
|
|
/***** Copy subject *****/
|
|
|
|
|
// TODO: Do only direct copy when Subject will be VARCHAR(255)
|
|
|
|
|
if (strlen (row[0]) > Ntf_MAX_BYTES_SUMMARY)
|
|
|
|
|
{
|
|
|
|
|
strncpy (SummaryStr,row[0],
|
|
|
|
|
Ntf_MAX_BYTES_SUMMARY);
|
|
|
|
|
SummaryStr[Ntf_MAX_BYTES_SUMMARY] = '\0';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Str_Copy (SummaryStr,row[0],
|
|
|
|
|
Ntf_MAX_BYTES_SUMMARY);
|
|
|
|
|
|
|
|
|
|
/***** Copy subject *****/
|
|
|
|
|
if (GetContent)
|
|
|
|
|
{
|
|
|
|
|
Length = strlen (row[1]);
|
|
|
|
|
if ((*ContentStr = (char *) malloc (Length + 1)) == NULL)
|
|
|
|
|
Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
|
|
|
|
|
Str_Copy (*ContentStr,row[1],
|
|
|
|
|
Length);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Write number of message **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_WriteMsgNumber (unsigned long MsgNum,bool NewMsg)
|
|
|
|
|
{
|
2015-09-28 18:28:29 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"%s CENTER_TOP\" style=\"width:45px;\">"
|
2014-12-23 17:12:45 +01:00
|
|
|
|
"%lu:"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</td>",
|
|
|
|
|
NewMsg ? "MSG_TIT_BG_NEW" :
|
|
|
|
|
"MSG_TIT_BG",
|
|
|
|
|
MsgNum);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Write subject of a received message ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-11-07 12:31:14 +01:00
|
|
|
|
static void Msg_WriteSentOrReceivedMsgSubject (long MsgCod,const char *Subject,bool Open,bool Expanded)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Hide_message;
|
|
|
|
|
extern const char *Txt_See_message;
|
|
|
|
|
extern const char *Txt_no_subject;
|
|
|
|
|
|
|
|
|
|
/***** Start cell *****/
|
2015-08-06 14:16:11 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"%s LEFT_TOP\">",
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Open ? "MSG_TIT_BG" :
|
|
|
|
|
"MSG_TIT_BG_NEW");
|
|
|
|
|
|
|
|
|
|
/***** Start form to expand/contract the message *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (Gbl.Msg.TypeOfMessages == Msg_MESSAGES_RECEIVED ? (Expanded ? ActConRcvMsg :
|
2016-11-07 12:31:14 +01:00
|
|
|
|
ActExpRcvMsg) :
|
|
|
|
|
(Expanded ? ActConSntMsg :
|
|
|
|
|
ActExpSntMsg));
|
2017-05-02 12:13:27 +02:00
|
|
|
|
Gbl.Msg.MsgCod = MsgCod; // Message to be contracted/expanded
|
|
|
|
|
Msg_PutHiddenParamsOneMsg ();
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_LinkFormSubmit (Expanded ? Txt_Hide_message :
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Txt_See_message,
|
2015-11-20 21:11:33 +01:00
|
|
|
|
Open ? "MSG_TIT" :
|
2016-07-01 17:13:41 +02:00
|
|
|
|
"MSG_TIT_NEW",NULL);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write subject *****/
|
|
|
|
|
if (Subject[0])
|
|
|
|
|
fprintf (Gbl.F.Out,"%s",Subject);
|
|
|
|
|
else
|
|
|
|
|
fprintf (Gbl.F.Out,"[%s]",Txt_no_subject);
|
|
|
|
|
|
|
|
|
|
/***** End form to expand the message *****/
|
2015-03-13 00:16:02 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</a>");
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** End cell *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"</td>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Write the author of a message **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Input: UsrDat must hold user's data
|
|
|
|
|
|
2017-05-02 01:16:06 +02:00
|
|
|
|
void Msg_WriteMsgAuthor (struct UsrData *UsrDat,bool Enabled,const char *BgColor)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2015-07-22 11:56:26 +02:00
|
|
|
|
extern const char *Txt_Unknown_or_without_photo;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool ShowPhoto = false;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char PhotoURL[PATH_MAX + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool WriteAuthor = false;
|
|
|
|
|
|
2017-05-02 01:16:06 +02:00
|
|
|
|
/***** Start table *****/
|
2017-06-11 20:09:59 +02:00
|
|
|
|
Tbl_StartTable (2);
|
2017-05-02 01:16:06 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Start first column *****/
|
2017-05-02 01:16:06 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
|
|
|
|
"<td class=\"CENTER_TOP");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (BgColor)
|
2015-09-04 17:10:27 +02:00
|
|
|
|
fprintf (Gbl.F.Out," %s",BgColor);
|
2015-09-28 18:28:29 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"\" style=\"width:30px;\">");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write author name or don't write it? *****/
|
|
|
|
|
if (Enabled)
|
|
|
|
|
if (UsrDat->UsrCod > 0)
|
|
|
|
|
WriteAuthor = true;
|
|
|
|
|
|
|
|
|
|
if (WriteAuthor)
|
|
|
|
|
{
|
|
|
|
|
/***** First column with author's photo (if author has a web page, put a link to it) *****/
|
2017-01-28 15:58:46 +01:00
|
|
|
|
ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL);
|
2014-12-30 15:14:43 +01:00
|
|
|
|
Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL :
|
|
|
|
|
NULL,
|
2016-01-14 10:31:09 +01:00
|
|
|
|
"PHOTO30x40",Pho_ZOOM,false);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</td>");
|
|
|
|
|
|
|
|
|
|
/***** Second column with user name (if author has a web page, put a link to it) *****/
|
2017-05-02 01:16:06 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"LEFT_TOP");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (BgColor)
|
2015-09-04 17:10:27 +02:00
|
|
|
|
fprintf (Gbl.F.Out," %s",BgColor);
|
2017-03-04 01:59:27 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"\">"
|
2017-03-05 15:12:48 +01:00
|
|
|
|
"<div class=\"AUTHOR_2_LINES\">"); // Limited width
|
|
|
|
|
Usr_WriteFirstNameBRSurnames (UsrDat);
|
2017-03-04 00:28:04 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</div>");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-07-22 11:56:26 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<img src=\"%s/usr_bl.jpg\""
|
|
|
|
|
" alt=\"%s\" title=\"%s\""
|
2015-12-13 12:51:41 +01:00
|
|
|
|
" class=\"PHOTO30x40\" />"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</td>"
|
2017-05-02 01:16:06 +02:00
|
|
|
|
"<td class=\"LEFT_MIDDLE",
|
2015-07-22 11:56:26 +02:00
|
|
|
|
Gbl.Prefs.IconsURL,
|
2017-05-02 01:05:23 +02:00
|
|
|
|
Txt_Unknown_or_without_photo,Txt_Unknown_or_without_photo);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (BgColor)
|
2015-09-04 17:10:27 +02:00
|
|
|
|
fprintf (Gbl.F.Out," %s",BgColor);
|
2017-03-04 00:28:04 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"\">");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-04 00:28:04 +01:00
|
|
|
|
/***** End second column *****/
|
2017-05-02 01:16:06 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"</td>"
|
|
|
|
|
"</tr>");
|
|
|
|
|
|
|
|
|
|
/***** End table *****/
|
2017-06-11 20:09:59 +02:00
|
|
|
|
Tbl_EndTable ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Write course origin of a message **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Returns true if the origin course is the current course
|
|
|
|
|
|
|
|
|
|
bool Msg_WriteCrsOrgMsg (long CrsCod)
|
|
|
|
|
{
|
2014-12-23 22:47:09 +01:00
|
|
|
|
extern const char *Txt_from_this_course;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Go_to_X;
|
|
|
|
|
extern const char *Txt_no_course_of_origin;
|
|
|
|
|
struct Course Crs;
|
|
|
|
|
bool FromThisCrs = true;
|
|
|
|
|
bool ThereIsOrgCrs = false;
|
|
|
|
|
|
|
|
|
|
if (CrsCod > 0)
|
|
|
|
|
{
|
|
|
|
|
/* Get new course code from old course code */
|
|
|
|
|
Crs.CrsCod = CrsCod;
|
|
|
|
|
|
|
|
|
|
/* Get data of current degree */
|
|
|
|
|
if (Crs_GetDataOfCourseByCod (&Crs))
|
|
|
|
|
{
|
|
|
|
|
ThereIsOrgCrs = true;
|
|
|
|
|
if ((FromThisCrs = (CrsCod == Gbl.CurrentCrs.Crs.CrsCod))) // Message sent from current course
|
2017-03-03 21:34:25 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"AUTHOR_TXT\">"
|
2014-12-26 17:55:42 +01:00
|
|
|
|
"(%s)"
|
|
|
|
|
"</div>",
|
2014-12-23 22:47:09 +01:00
|
|
|
|
Txt_from_this_course);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else // Message sent from another course
|
|
|
|
|
{
|
|
|
|
|
/* Write course, including link */
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartFormGoTo (ActSeeCrsInf);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Crs_PutParamCrsCod (Crs.CrsCod);
|
2017-03-03 21:34:25 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"AUTHOR_TXT\">"
|
2014-12-26 17:55:42 +01:00
|
|
|
|
"(");
|
2018-10-18 02:02:32 +02:00
|
|
|
|
snprintf (Gbl.Title,sizeof (Gbl.Title),
|
|
|
|
|
Txt_Go_to_X,
|
|
|
|
|
Crs.FullName);
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_LinkFormSubmit (Gbl.Title,"AUTHOR_TXT",NULL);
|
2014-12-26 17:55:42 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"%s</a>)"
|
2015-03-13 00:16:02 +01:00
|
|
|
|
"</div>",
|
2016-10-28 10:03:37 +02:00
|
|
|
|
Crs.ShrtName);
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!ThereIsOrgCrs) // It's an old message without origin source specified, or is a message sent from none course
|
2017-03-03 21:34:25 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"AUTHOR_TXT\">"
|
2014-12-26 17:55:42 +01:00
|
|
|
|
"(%s)"
|
|
|
|
|
"</div>",
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Txt_no_course_of_origin);
|
|
|
|
|
|
|
|
|
|
return FromThisCrs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Write form to reply a message *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-07-01 01:21:34 +02:00
|
|
|
|
static void Msg_WriteFormToReply (long MsgCod,long CrsCod,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool FromThisCrs,bool Replied,
|
2015-12-24 00:31:45 +01:00
|
|
|
|
const struct UsrData *UsrDat)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2015-07-27 21:25:45 +02:00
|
|
|
|
extern const char *The_ClassFormBold[The_NUM_THEMES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Reply;
|
|
|
|
|
extern const char *Txt_Reply_again;
|
|
|
|
|
extern const char *Txt_Go_to_course_and_reply;
|
|
|
|
|
extern const char *Txt_Go_to_course_and_reply_again;
|
|
|
|
|
|
|
|
|
|
/***** Form start and parameters *****/
|
|
|
|
|
if (FromThisCrs)
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActReqMsgUsr);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else // Not the current course ==> go to another course
|
|
|
|
|
{
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartFormGoTo (ActReqMsgUsr);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Crs_PutParamCrsCod (CrsCod);
|
|
|
|
|
}
|
|
|
|
|
Grp_PutParamAllGroups ();
|
|
|
|
|
Par_PutHiddenParamChar ("IsReply",'Y');
|
|
|
|
|
Msg_PutHiddenParamMsgCod (MsgCod);
|
2015-12-24 00:31:45 +01:00
|
|
|
|
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
2015-12-22 14:00:36 +01:00
|
|
|
|
Par_PutHiddenParamChar ("ShowOnlyOneRecipient",'Y');
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/****** Link and form end *****/
|
2017-09-11 09:05:26 +02:00
|
|
|
|
Ico_PutIconLink ("reply16x16.gif",
|
|
|
|
|
FromThisCrs ? (Replied ? Txt_Reply_again :
|
|
|
|
|
Txt_Reply) :
|
|
|
|
|
(Replied ? Txt_Go_to_course_and_reply_again :
|
|
|
|
|
Txt_Go_to_course_and_reply),
|
|
|
|
|
NULL,NULL,NULL);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Write author of a message ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Msg_WriteMsgFrom (struct UsrData *UsrDat,bool Deleted)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_MSG_Sent;
|
|
|
|
|
extern const char *Txt_MSG_Sent_and_deleted;
|
2015-03-12 14:45:40 +01:00
|
|
|
|
extern const char *Txt_ROLES_SINGUL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool ShowPhoto;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char PhotoURL[PATH_MAX + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Put an icon to show if user has read the message *****/
|
2014-12-21 19:43:39 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<table>"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"<tr>"
|
2015-09-28 18:28:29 +02:00
|
|
|
|
"<td class=\"LEFT_MIDDLE\" style=\"width:20px;\">"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"<img src=\"%s/%s16x16.gif\""
|
2015-09-05 12:04:30 +02:00
|
|
|
|
" alt=\"%s\" title=\"%s\""
|
2016-11-14 10:05:41 +01:00
|
|
|
|
" class=\"ICO20x20\" />"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</td>",
|
|
|
|
|
Gbl.Prefs.IconsURL,
|
|
|
|
|
Deleted ? "msg-fwd-del" :
|
|
|
|
|
"msg-fwd",
|
2015-07-22 11:56:26 +02:00
|
|
|
|
Deleted ? Txt_MSG_Sent_and_deleted :
|
|
|
|
|
Txt_MSG_Sent,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Deleted ? Txt_MSG_Sent_and_deleted :
|
|
|
|
|
Txt_MSG_Sent);
|
|
|
|
|
|
|
|
|
|
/***** Put user's photo *****/
|
2015-09-28 18:28:29 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\" style=\"width:30px;\">");
|
2017-01-28 15:58:46 +01:00
|
|
|
|
ShowPhoto = (Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL));
|
2014-12-30 15:14:43 +01:00
|
|
|
|
Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL :
|
|
|
|
|
NULL,
|
2016-01-14 10:31:09 +01:00
|
|
|
|
"PHOTO21x28",Pho_ZOOM,false);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write user's name *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"</td>"
|
2017-03-03 21:34:25 +01:00
|
|
|
|
"<td class=\"AUTHOR_TXT LEFT_MIDDLE\">");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (UsrDat->UsrCod > 0)
|
|
|
|
|
{
|
|
|
|
|
fprintf (Gbl.F.Out,"%s",UsrDat->FullName);
|
2018-04-24 13:21:53 +02:00
|
|
|
|
if (Act_GetSuperAction (Gbl.Action.Act) == ActSeeRcvMsg)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
if (Msg_CheckIfUsrIsBanned (UsrDat->UsrCod,Gbl.Usrs.Me.UsrDat.UsrCod))
|
|
|
|
|
// Sender is banned
|
|
|
|
|
Msg_PutFormToUnbanSender (UsrDat);
|
|
|
|
|
else
|
|
|
|
|
// Sender is not banned
|
|
|
|
|
Msg_PutFormToBanSender (UsrDat);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
fprintf (Gbl.F.Out,"[%s]",
|
2017-05-18 19:13:41 +02:00
|
|
|
|
Txt_ROLES_SINGUL_abc[Rol_UNK][Usr_SEX_UNKNOWN]); // User not found, likely an old user who has been removed
|
2014-12-01 23:55:08 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</td>"
|
|
|
|
|
"</tr>"
|
|
|
|
|
"</table>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Write list of recipients of a message ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define Msg_MAX_RECIPIENTS_TO_SHOW 10 // If number of recipients <= Msg_MAX_RECIPIENTS_TO_SHOW, show all recipients
|
|
|
|
|
#define Msg_DEF_RECIPIENTS_TO_SHOW 5 // If number of recipients > Msg_MAX_RECIPIENTS_TO_SHOW, show only Msg_DEF_RECIPIENTS_TO_SHOW
|
|
|
|
|
|
2016-11-07 12:31:14 +01:00
|
|
|
|
static void Msg_WriteMsgTo (long MsgCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_MSG_Open_and_deleted;
|
|
|
|
|
extern const char *Txt_MSG_Open;
|
|
|
|
|
extern const char *Txt_MSG_Deleted_without_opening;
|
|
|
|
|
extern const char *Txt_MSG_Unopened;
|
|
|
|
|
extern const char *Txt_unknown_recipient;
|
|
|
|
|
extern const char *Txt_unknown_recipients;
|
|
|
|
|
extern const char *Txt_View_all_recipients;
|
|
|
|
|
extern const char *Txt_and_X_other_recipients;
|
|
|
|
|
extern const char *Txt_unknown_recipient;
|
|
|
|
|
extern const char *Txt_unknown_recipients;
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumRcp;
|
|
|
|
|
unsigned NumRecipientsTotal;
|
|
|
|
|
unsigned NumRecipientsKnown;
|
|
|
|
|
unsigned NumRecipientsUnknown;
|
|
|
|
|
unsigned NumRecipientsToShow;
|
|
|
|
|
struct UsrData UsrDat;
|
|
|
|
|
bool Deleted;
|
|
|
|
|
bool OpenByDst;
|
|
|
|
|
bool UsrValid;
|
|
|
|
|
bool ShowPhoto;
|
2015-07-22 11:56:26 +02:00
|
|
|
|
const char *Title;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char PhotoURL[PATH_MAX + 1];
|
2016-11-07 12:31:14 +01:00
|
|
|
|
static const Act_Action_t ActionSee[Msg_NUM_TYPES_OF_MSGS] =
|
|
|
|
|
{
|
|
|
|
|
ActSeeRcvMsg,
|
2017-05-02 12:13:27 +02:00
|
|
|
|
ActSeeSntMsg,
|
2016-11-07 12:31:14 +01:00
|
|
|
|
};
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get number of recipients of a message from database *****/
|
2018-11-03 20:52:00 +01:00
|
|
|
|
NumRecipientsTotal =
|
|
|
|
|
(unsigned) DB_QueryCOUNT ("can not get number of recipients",
|
|
|
|
|
"SELECT "
|
2018-11-04 20:51:38 +01:00
|
|
|
|
"(SELECT COUNT(*) FROM msg_rcv"
|
|
|
|
|
" WHERE MsgCod=%ld)"
|
2018-11-03 20:52:00 +01:00
|
|
|
|
" + "
|
2018-11-04 20:51:38 +01:00
|
|
|
|
"(SELECT COUNT(*) FROM msg_rcv_deleted"
|
|
|
|
|
" WHERE MsgCod=%ld)",
|
2018-11-03 20:52:00 +01:00
|
|
|
|
MsgCod,MsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get recipients of a message from database *****/
|
2018-11-01 12:02:58 +01:00
|
|
|
|
NumRecipientsKnown =
|
|
|
|
|
(unsigned) DB_QuerySELECT (&mysql_res,"can not get recipients of a message",
|
|
|
|
|
"(SELECT msg_rcv.UsrCod,"
|
|
|
|
|
"'N',"
|
|
|
|
|
"msg_rcv.Open,"
|
|
|
|
|
"usr_data.Surname1 AS S1,"
|
|
|
|
|
"usr_data.Surname2 AS S2,"
|
|
|
|
|
"usr_data.FirstName AS FN"
|
|
|
|
|
" FROM msg_rcv,usr_data"
|
|
|
|
|
" WHERE msg_rcv.MsgCod=%ld"
|
|
|
|
|
" AND msg_rcv.UsrCod=usr_data.UsrCod)"
|
|
|
|
|
" UNION "
|
|
|
|
|
"(SELECT msg_rcv_deleted.UsrCod,"
|
|
|
|
|
"'Y',"
|
|
|
|
|
"msg_rcv_deleted.Open,"
|
|
|
|
|
"usr_data.Surname1 AS S1,"
|
|
|
|
|
"usr_data.Surname2 AS S2,"
|
|
|
|
|
"usr_data.FirstName AS FN"
|
|
|
|
|
" FROM msg_rcv_deleted,usr_data"
|
|
|
|
|
" WHERE msg_rcv_deleted.MsgCod=%ld"
|
|
|
|
|
" AND msg_rcv_deleted.UsrCod=usr_data.UsrCod)"
|
|
|
|
|
" ORDER BY S1,S2,FN",
|
|
|
|
|
MsgCod,MsgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Check number of recipients *****/
|
|
|
|
|
if (NumRecipientsTotal)
|
|
|
|
|
{
|
|
|
|
|
/***** Start table *****/
|
2014-12-21 19:43:39 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<table>");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** How many recipients will be shown? *****/
|
|
|
|
|
if (NumRecipientsKnown <= Msg_MAX_RECIPIENTS_TO_SHOW)
|
|
|
|
|
NumRecipientsToShow = NumRecipientsKnown;
|
|
|
|
|
else // A lot of recipients
|
|
|
|
|
/***** Get parameter that indicates if I want to see all recipients *****/
|
2017-01-28 20:32:50 +01:00
|
|
|
|
NumRecipientsToShow = Par_GetParToBool ("SeeAllRcpts") ? NumRecipientsKnown :
|
|
|
|
|
Msg_DEF_RECIPIENTS_TO_SHOW;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Initialize structure with user's data *****/
|
|
|
|
|
Usr_UsrDataConstructor (&UsrDat);
|
|
|
|
|
|
|
|
|
|
/***** Write known recipients *****/
|
|
|
|
|
for (NumRcp = 0;
|
|
|
|
|
NumRcp < NumRecipientsToShow;
|
|
|
|
|
NumRcp++)
|
|
|
|
|
{
|
|
|
|
|
/* Get user's code */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
|
|
|
|
|
|
|
|
/* Get if message has been deleted by recipient */
|
2016-09-07 18:48:10 +02:00
|
|
|
|
Deleted = (row[1][0] == 'Y');
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get if message has been read by recipient */
|
2016-09-07 18:48:10 +02:00
|
|
|
|
OpenByDst = (row[2][0] == 'Y');
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get user's data */
|
|
|
|
|
UsrValid = Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat);
|
|
|
|
|
|
|
|
|
|
/* Put an icon to show if user has read the message */
|
2015-07-22 11:56:26 +02:00
|
|
|
|
Title = OpenByDst ? (Deleted ? Txt_MSG_Open_and_deleted :
|
|
|
|
|
Txt_MSG_Open) :
|
|
|
|
|
(Deleted ? Txt_MSG_Deleted_without_opening :
|
|
|
|
|
Txt_MSG_Unopened);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2015-09-28 18:28:29 +02:00
|
|
|
|
"<td class=\"LEFT_MIDDLE\" style=\"width:20px;\">"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"<img src=\"%s/%s16x16.gif\""
|
2015-07-22 11:56:26 +02:00
|
|
|
|
" alt=\"%s\" title=\"%s\""
|
2016-11-14 10:05:41 +01:00
|
|
|
|
" class=\"ICO20x20\" />"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</td>",
|
|
|
|
|
Gbl.Prefs.IconsURL,
|
|
|
|
|
OpenByDst ? (Deleted ? "msg-open-del" :
|
|
|
|
|
"msg-open") :
|
|
|
|
|
(Deleted ? "msg-unread-del" :
|
|
|
|
|
"msg-unread"),
|
2015-07-22 11:56:26 +02:00
|
|
|
|
Title,Title);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Put user's photo */
|
2015-09-28 18:28:29 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"CENTER_TOP\" style=\"width:30px;\">");
|
2017-01-28 15:58:46 +01:00
|
|
|
|
ShowPhoto = (UsrValid ? Pho_ShowingUsrPhotoIsAllowed (&UsrDat,PhotoURL) :
|
2014-12-01 23:55:08 +01:00
|
|
|
|
false);
|
2014-12-30 15:14:43 +01:00
|
|
|
|
Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL :
|
|
|
|
|
NULL,
|
2016-01-14 10:31:09 +01:00
|
|
|
|
"PHOTO21x28",Pho_ZOOM,false);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Write user's name */
|
|
|
|
|
fprintf (Gbl.F.Out,"</td>"
|
2015-08-06 14:16:11 +02:00
|
|
|
|
"<td class=\"%s LEFT_MIDDLE\">",
|
2017-03-03 21:34:25 +01:00
|
|
|
|
OpenByDst ? "AUTHOR_TXT" :
|
|
|
|
|
"AUTHOR_TXT_NEW");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (UsrValid)
|
|
|
|
|
fprintf (Gbl.F.Out,"%s",UsrDat.FullName);
|
|
|
|
|
else
|
|
|
|
|
fprintf (Gbl.F.Out,"[%s]",Txt_unknown_recipient); // User not found, likely a user who has been removed
|
|
|
|
|
fprintf (Gbl.F.Out,"</td>"
|
|
|
|
|
"</tr>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** If any recipients are unknown *****/
|
|
|
|
|
if ((NumRecipientsUnknown = NumRecipientsTotal - NumRecipientsKnown))
|
|
|
|
|
/***** Start form to show all the users *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2017-03-03 21:34:25 +01:00
|
|
|
|
"<td colspan=\"3\" class=\"AUTHOR_TXT LEFT_MIDDLE\">"
|
2014-12-23 17:12:45 +01:00
|
|
|
|
"[%u %s]"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</td>"
|
|
|
|
|
"</tr>",
|
|
|
|
|
NumRecipientsUnknown,
|
|
|
|
|
(NumRecipientsUnknown == 1) ?
|
|
|
|
|
Txt_unknown_recipient :
|
|
|
|
|
Txt_unknown_recipients);
|
|
|
|
|
|
|
|
|
|
/***** If any known recipient is not listed *****/
|
|
|
|
|
if (NumRecipientsToShow < NumRecipientsKnown)
|
|
|
|
|
{
|
|
|
|
|
/***** Start form to show all the users *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2017-03-03 21:34:25 +01:00
|
|
|
|
"<td colspan=\"3\" class=\"AUTHOR_TXT LEFT_MIDDLE\">");
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActionSee[Gbl.Msg.TypeOfMessages]);
|
2017-05-02 12:13:27 +02:00
|
|
|
|
Gbl.Msg.MsgCod = MsgCod; // Message to be expanded with all recipients visible
|
|
|
|
|
Msg_PutHiddenParamsOneMsg ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Par_PutHiddenParamChar ("SeeAllRcpts",'Y');
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_LinkFormSubmit (Txt_View_all_recipients,"AUTHOR_TXT",NULL);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
fprintf (Gbl.F.Out,Txt_and_X_other_recipients,
|
|
|
|
|
NumRecipientsKnown - NumRecipientsToShow);
|
2015-03-13 00:16:02 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</a>");
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2015-03-13 00:16:02 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</td>"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</tr>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free memory used for user's data *****/
|
|
|
|
|
Usr_UsrDataDestructor (&UsrDat);
|
|
|
|
|
|
|
|
|
|
/***** End table *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"</table>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Write the date of creation of a message *****************/
|
|
|
|
|
/*****************************************************************************/
|
2015-10-24 20:12:03 +02:00
|
|
|
|
// TimeUTC holds UTC date and time in UNIX format (seconds since 1970)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-10-24 20:12:03 +02:00
|
|
|
|
void Msg_WriteMsgDate (time_t TimeUTC,const char *ClassBackground)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2015-12-29 11:35:01 +01:00
|
|
|
|
extern const char *Txt_Today;
|
2015-10-24 20:12:03 +02:00
|
|
|
|
static unsigned UniqueId = 0;
|
|
|
|
|
|
|
|
|
|
UniqueId++;
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Start cell *****/
|
2017-04-17 14:18:57 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td id=\"msg_date_%u\" class=\"%s RIGHT_TOP\""
|
2015-10-24 20:12:03 +02:00
|
|
|
|
" style=\"width:106px;\">",
|
|
|
|
|
UniqueId,ClassBackground);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-10-24 20:12:03 +02:00
|
|
|
|
/***** Write date and time *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<script type=\"text/javascript\">"
|
2017-05-04 17:06:26 +02:00
|
|
|
|
"writeLocalDateHMSFromUTC('msg_date_%u',%ld,"
|
2017-05-05 09:41:56 +02:00
|
|
|
|
"%u,', ','%s',true,false,0x6);"
|
2015-10-24 20:12:03 +02:00
|
|
|
|
"</script>",
|
2017-05-04 17:06:26 +02:00
|
|
|
|
UniqueId,(long) TimeUTC,
|
|
|
|
|
(unsigned) Gbl.Prefs.DateFormat,Txt_Today);
|
2015-10-24 20:12:03 +02:00
|
|
|
|
|
|
|
|
|
/***** End cell *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</td>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-07-01 01:21:34 +02:00
|
|
|
|
/********************* Write the text (content) of a message *****************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_WriteMsgContent (char *Content,unsigned long MaxLength,bool InsertLinks,bool ChangeBRToRet)
|
|
|
|
|
{
|
|
|
|
|
/***** Insert links in URLs *****/
|
|
|
|
|
if (InsertLinks)
|
2016-01-25 00:19:21 +01:00
|
|
|
|
Str_InsertLinks (Content,MaxLength,60);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write message to file *****/
|
|
|
|
|
if (ChangeBRToRet)
|
|
|
|
|
Str_FilePrintStrChangingBRToRetAndNBSPToSpace (Gbl.F.Out,Content);
|
|
|
|
|
else
|
|
|
|
|
fprintf (Gbl.F.Out,"%s",Content);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Get parameter with the code of a message ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_PutHiddenParamMsgCod (long MsgCod)
|
|
|
|
|
{
|
|
|
|
|
Par_PutHiddenParamLong ("MsgCod",MsgCod);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Get parameter with the code of a message ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static long Msg_GetParamMsgCod (void)
|
|
|
|
|
{
|
2017-01-28 20:32:50 +01:00
|
|
|
|
/***** Get code of message *****/
|
|
|
|
|
return Par_GetParToLong ("MsgCod");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Put a form to ban the sender of a message *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Msg_PutFormToBanSender (struct UsrData *UsrDat)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Sender_permitted_click_to_ban_him;
|
|
|
|
|
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActBanUsrMsg);
|
2017-04-13 20:09:22 +02:00
|
|
|
|
Pag_PutHiddenParamPagNum (Msg_WhatPaginate[Gbl.Msg.TypeOfMessages],
|
|
|
|
|
Gbl.Msg.CurrentPage);
|
2015-04-02 18:39:49 +02:00
|
|
|
|
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Msg_PutHiddenParamsMsgsFilters ();
|
2016-12-05 01:54:03 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<input type=\"image\" src=\"%s/unlock-on64x64.png\""
|
2015-09-05 12:04:30 +02:00
|
|
|
|
" alt=\"%s\" title=\"%s\""
|
2016-11-14 10:05:41 +01:00
|
|
|
|
" class=\"ICO20x20\" style=\"margin-left:12px;\" />",
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Gbl.Prefs.IconsURL,
|
|
|
|
|
Txt_Sender_permitted_click_to_ban_him,
|
|
|
|
|
Txt_Sender_permitted_click_to_ban_him);
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Put a form to unban the sender of a message ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Msg_PutFormToUnbanSender (struct UsrData *UsrDat)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Sender_banned_click_to_unban_him;
|
|
|
|
|
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActUnbUsrMsg);
|
2017-04-13 20:09:22 +02:00
|
|
|
|
Pag_PutHiddenParamPagNum (Msg_WhatPaginate[Gbl.Msg.TypeOfMessages],
|
|
|
|
|
Gbl.Msg.CurrentPage);
|
2015-04-02 18:39:49 +02:00
|
|
|
|
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Msg_PutHiddenParamsMsgsFilters ();
|
2016-12-24 14:05:59 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<input type=\"image\" src=\"%s/lock-on64x64.png\""
|
2015-09-05 12:04:30 +02:00
|
|
|
|
" alt=\"%s\" title=\"%s\""
|
2016-12-24 14:05:59 +01:00
|
|
|
|
" class=\"ICO20x20\" style=\"margin-left:12px;\" />",
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Gbl.Prefs.IconsURL,
|
|
|
|
|
Txt_Sender_banned_click_to_unban_him,
|
|
|
|
|
Txt_Sender_banned_click_to_unban_him);
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********* Ban a sender of a message when showing received messages **********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_BanSenderWhenShowingMsgs (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_From_this_time_you_will_not_receive_messages_from_X;
|
|
|
|
|
|
|
|
|
|
/***** Get user's code from form *****/
|
2016-01-25 14:40:57 +01:00
|
|
|
|
Usr_GetParamOtherUsrCodEncryptedAndGetListIDs ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get password, user type and user's data from database *****/
|
|
|
|
|
if (!Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat))
|
|
|
|
|
Lay_ShowErrorAndExit ("Sender does not exist.");
|
|
|
|
|
|
|
|
|
|
/***** Insert pair (sender's code - my code) in table of banned senders if not inserted *****/
|
2018-11-02 16:39:35 +01:00
|
|
|
|
DB_QueryREPLACE ("can not ban sender",
|
|
|
|
|
"REPLACE INTO msg_banned"
|
|
|
|
|
" (FromUsrCod,ToUsrCod)"
|
|
|
|
|
" VALUES"
|
|
|
|
|
" (%ld,%ld)",
|
|
|
|
|
Gbl.Usrs.Other.UsrDat.UsrCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show alert with the change made *****/
|
2018-10-16 23:08:04 +02:00
|
|
|
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
Txt_From_this_time_you_will_not_receive_messages_from_X,
|
|
|
|
|
Gbl.Usrs.Other.UsrDat.FullName);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/**** Show received messages again */
|
|
|
|
|
Msg_ShowRecMsgs ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******** Unban a sender of a message when showing received messages *********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_UnbanSenderWhenShowingMsgs (void)
|
|
|
|
|
{
|
|
|
|
|
/**** Unban sender *****/
|
|
|
|
|
Msg_UnbanSender ();
|
|
|
|
|
|
|
|
|
|
/**** Show received messages again */
|
|
|
|
|
Msg_ShowRecMsgs ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********** Unban a sender of a message when listing banned users ************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_UnbanSenderWhenListingUsrs (void)
|
|
|
|
|
{
|
|
|
|
|
/**** Unban sender *****/
|
|
|
|
|
Msg_UnbanSender ();
|
|
|
|
|
|
|
|
|
|
/**** List banned users again */
|
|
|
|
|
Msg_ListBannedUsrs ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Unban a sender of a message ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Msg_UnbanSender (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_From_this_time_you_can_receive_messages_from_X;
|
|
|
|
|
|
|
|
|
|
/***** Get user's code from form *****/
|
2016-01-25 14:40:57 +01:00
|
|
|
|
Usr_GetParamOtherUsrCodEncryptedAndGetListIDs ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get password, user type and user's data from database *****/
|
|
|
|
|
if (!Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat))
|
|
|
|
|
Lay_ShowErrorAndExit ("Sender does not exist.");
|
|
|
|
|
|
|
|
|
|
/***** Remove pair (sender's code - my code) from table of banned senders *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not ban sender",
|
|
|
|
|
"DELETE FROM msg_banned"
|
|
|
|
|
" WHERE FromUsrCod=%ld AND ToUsrCod=%ld",
|
|
|
|
|
Gbl.Usrs.Other.UsrDat.UsrCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show alert with the change made *****/
|
2018-10-16 23:08:04 +02:00
|
|
|
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
Txt_From_this_time_you_can_receive_messages_from_X,
|
|
|
|
|
Gbl.Usrs.Other.UsrDat.FullName);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2014-12-17 23:54:11 +01:00
|
|
|
|
/**************** Chech if a user is banned by another user ******************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static bool Msg_CheckIfUsrIsBanned (long FromUsrCod,long ToUsrCod)
|
|
|
|
|
{
|
2014-12-17 23:54:11 +01:00
|
|
|
|
/***** Get if FromUsrCod is banned by ToUsrCod *****/
|
2018-11-03 20:52:00 +01:00
|
|
|
|
return (DB_QueryCOUNT ("can not check if a user is banned",
|
|
|
|
|
"SELECT COUNT(*) FROM msg_banned"
|
|
|
|
|
" WHERE FromUsrCod=%ld AND ToUsrCod=%ld",
|
|
|
|
|
FromUsrCod,ToUsrCod) != 0);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Remove user from banned table **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_RemoveUsrFromBanned (long UsrCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Remove pair (sender's code - my code)
|
|
|
|
|
from table of banned senders *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove user from table of banned users",
|
|
|
|
|
"DELETE FROM msg_banned"
|
|
|
|
|
" WHERE FromUsrCod=%ld OR ToUsrCod=%ld",
|
|
|
|
|
UsrCod,UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********** List banned users, who can not sent messages to me **************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Msg_ListBannedUsrs (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_You_have_not_banned_any_sender;
|
|
|
|
|
extern const char *Txt_Banned_users;
|
|
|
|
|
extern const char *Txt_Sender_banned_click_to_unban_him;
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumUsr,NumUsrs;
|
|
|
|
|
struct UsrData UsrDat;
|
|
|
|
|
bool ShowPhoto;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char PhotoURL[PATH_MAX + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get my banned users *****/
|
2018-11-01 12:02:58 +01:00
|
|
|
|
NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get banned users",
|
|
|
|
|
"SELECT msg_banned.FromUsrCod"
|
|
|
|
|
" FROM msg_banned,usr_data"
|
|
|
|
|
" WHERE msg_banned.ToUsrCod=%ld"
|
|
|
|
|
" AND msg_banned.FromUsrCod=usr_data.UsrCod"
|
|
|
|
|
" ORDER BY usr_data.Surname1,"
|
|
|
|
|
"usr_data.Surname2,"
|
|
|
|
|
"usr_data.FirstName",
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
if (NumUsrs == 0) // If not result ==> sent message is deleted
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_You_have_not_banned_any_sender);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/***** Initialize structure with user's data *****/
|
|
|
|
|
Usr_UsrDataConstructor (&UsrDat);
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** Start box and table *****/
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_StartBoxTable (NULL,Txt_Banned_users,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
NULL,Box_NOT_CLOSABLE,2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** List users *****/
|
|
|
|
|
for (NumUsr = 1;
|
|
|
|
|
NumUsr <= NumUsrs;
|
|
|
|
|
NumUsr++)
|
|
|
|
|
{
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get user's code (row[0]) */
|
|
|
|
|
UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
|
|
|
|
|
|
|
|
/* Get user's data from database */
|
|
|
|
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat))
|
|
|
|
|
{
|
|
|
|
|
/* Put form to unban user */
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
|
|
|
|
"<td class=\"BM\">");
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActUnbUsrLst);
|
2015-04-02 18:39:49 +02:00
|
|
|
|
Usr_PutParamUsrCodEncrypted (UsrDat.EncryptedUsrCod);
|
2015-01-04 01:51:07 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<input type=\"image\""
|
2016-12-05 01:54:03 +01:00
|
|
|
|
" src=\"%s/lock-on64x64.png\""
|
2015-09-05 12:04:30 +02:00
|
|
|
|
" alt=\"%s\" title=\"%s\""
|
2016-11-14 10:05:41 +01:00
|
|
|
|
" class=\"ICO20x20\" />",
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Gbl.Prefs.IconsURL,
|
|
|
|
|
Txt_Sender_banned_click_to_unban_him,
|
|
|
|
|
Txt_Sender_banned_click_to_unban_him);
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2015-03-13 00:16:02 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</td>");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Show photo */
|
2015-08-06 14:16:11 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\""
|
2015-09-28 18:28:29 +02:00
|
|
|
|
" style=\"width:30px;\">");
|
2017-01-28 15:58:46 +01:00
|
|
|
|
ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&UsrDat,PhotoURL);
|
2014-12-30 15:14:43 +01:00
|
|
|
|
Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL :
|
|
|
|
|
NULL,
|
2016-01-14 10:31:09 +01:00
|
|
|
|
"PHOTO21x28",Pho_ZOOM,false);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</td>");
|
|
|
|
|
|
|
|
|
|
/* Write user's full name */
|
2015-08-06 14:16:11 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"DAT LEFT_MIDDLE\">"
|
2014-12-23 17:12:45 +01:00
|
|
|
|
"%s"
|
|
|
|
|
"</td>"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</tr>",
|
|
|
|
|
UsrDat.FullName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End table and box *****/
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_EndBoxTable ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free memory used for user's data *****/
|
|
|
|
|
Usr_UsrDataDestructor (&UsrDat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|