swad-core/swad_notification.c

2151 lines
78 KiB
C
Raw Normal View History

2016-11-16 23:19:52 +01:00
// swad_notification.c: notifications about events, sent by email
2014-12-01 23:55:08 +01:00
/*
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.
2019-01-07 21:52:19 +01:00
Copyright (C) 1999-2019 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 ***********************************/
/*****************************************************************************/
#include <linux/stddef.h> // For NULL
#include <stdlib.h> // For system
#include <string.h>
#include <sys/wait.h> // For the macro WEXITSTATUS
#include <unistd.h> // For unlink
#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_config.h"
#include "swad_database.h"
2017-03-30 11:20:06 +02:00
#include "swad_enrolment.h"
2014-12-01 23:55:08 +01:00
#include "swad_exam.h"
2015-03-24 00:01:40 +01:00
#include "swad_follow.h"
2018-11-09 20:47:39 +01:00
#include "swad_form.h"
2014-12-01 23:55:08 +01:00
#include "swad_global.h"
2019-10-23 19:05:05 +02:00
#include "swad_HTML.h"
2014-12-01 23:55:08 +01:00
#include "swad_mark.h"
#include "swad_notice.h"
#include "swad_notification.h"
#include "swad_parameter.h"
2019-03-12 21:25:55 +01:00
#include "swad_timeline.h"
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl;
/*****************************************************************************/
/****************************** Public constants *****************************/
/*****************************************************************************/
2017-03-07 19:55:29 +01:00
// strings are limited to Ntf_MAX_BYTES_NOTIFY_EVENT characters
2017-01-15 18:02:52 +01:00
2014-12-01 23:55:08 +01:00
const char *Ntf_WSNotifyEvents[Ntf_NUM_NOTIFY_EVENTS] =
{
2019-11-20 01:47:22 +01:00
[Ntf_EVENT_UNKNOWN ] = "unknown",
/* Start tab */
[Ntf_EVENT_TIMELINE_COMMENT ] = "timelineComment",
[Ntf_EVENT_TIMELINE_FAV ] = "timelineFav",
[Ntf_EVENT_TIMELINE_SHARE ] = "timelineShare",
[Ntf_EVENT_TIMELINE_MENTION ] = "timelineMention",
[Ntf_EVENT_FOLLOWER ] = "follower",
/* System tab */
/* Country tab */
/* Institution tab */
/* Centre tab */
/* Degree tab */
2014-12-01 23:55:08 +01:00
/* Course tab */
/* Assessment tab */
2019-11-20 01:47:22 +01:00
[Ntf_EVENT_ASSIGNMENT ] = "assignment",
[Ntf_EVENT_SURVEY ] = "survey",
[Ntf_EVENT_EXAM_ANNOUNCEMENT] = "examAnnouncement",
/* Files tab */
[Ntf_EVENT_DOCUMENT_FILE ] = "documentFile",
[Ntf_EVENT_TEACHERS_FILE ] = "teachersFile",
[Ntf_EVENT_SHARED_FILE ] = "sharedFile",
[Ntf_EVENT_MARKS_FILE ] = "marksFile",
2014-12-01 23:55:08 +01:00
2016-01-22 01:47:28 +01:00
/* Users tab */
2019-11-20 01:47:22 +01:00
[Ntf_EVENT_ENROLMENT_STD ] = "enrollmentStudent",
[Ntf_EVENT_ENROLMENT_NET ] = "enrolmentNonEditingTeacher",
[Ntf_EVENT_ENROLMENT_TCH ] = "enrollmentTeacher",
[Ntf_EVENT_ENROLMENT_REQUEST] = "enrollmentRequest",
2014-12-01 23:55:08 +01:00
/* Messages tab */
2019-11-20 01:47:22 +01:00
[Ntf_EVENT_NOTICE ] = "notice",
[Ntf_EVENT_FORUM_POST_COURSE] = "forumPostCourse",
[Ntf_EVENT_FORUM_REPLY ] = "forumReply",
[Ntf_EVENT_MESSAGE ] = "message",
2014-12-01 23:55:08 +01:00
2019-11-20 01:47:22 +01:00
/* Analytics tab */
2015-03-24 00:01:40 +01:00
/* Profile tab */
2014-12-01 23:55:08 +01:00
};
static const Act_Action_t Ntf_DefaultActions[Ntf_NUM_NOTIFY_EVENTS] =
{
2019-11-20 01:47:22 +01:00
[Ntf_EVENT_UNKNOWN ] = ActUnk,
/* Start tab */
[Ntf_EVENT_TIMELINE_COMMENT ] = ActSeeSocTmlGbl,
[Ntf_EVENT_TIMELINE_FAV ] = ActSeeSocTmlGbl,
[Ntf_EVENT_TIMELINE_SHARE ] = ActSeeSocTmlGbl,
[Ntf_EVENT_TIMELINE_MENTION ] = ActSeeSocTmlGbl,
[Ntf_EVENT_FOLLOWER ] = ActSeeFlr,
/* System tab */
/* Country tab */
/* Institution tab */
/* Centre tab */
/* Degree tab */
2014-12-01 23:55:08 +01:00
/* Course tab */
/* Assessment tab */
2019-11-20 01:47:22 +01:00
[Ntf_EVENT_ASSIGNMENT ] = ActSeeAsg,
[Ntf_EVENT_SURVEY ] = ActSeeAllSvy,
[Ntf_EVENT_EXAM_ANNOUNCEMENT] = ActSeeAllExaAnn,
/* Files tab */
[Ntf_EVENT_DOCUMENT_FILE ] = ActSeeAdmDocCrsGrp,
[Ntf_EVENT_TEACHERS_FILE ] = ActAdmTchCrsGrp,
[Ntf_EVENT_SHARED_FILE ] = ActAdmShaCrsGrp,
[Ntf_EVENT_MARKS_FILE ] = ActSeeAdmMrk,
2014-12-01 23:55:08 +01:00
/* Users tab */
2019-11-20 01:47:22 +01:00
[Ntf_EVENT_ENROLMENT_STD ] = ActReqAccEnrStd,
[Ntf_EVENT_ENROLMENT_NET ] = ActReqAccEnrNET,
[Ntf_EVENT_ENROLMENT_TCH ] = ActReqAccEnrTch,
[Ntf_EVENT_ENROLMENT_REQUEST] = ActSeeSignUpReq,
2015-12-30 20:11:50 +01:00
2014-12-01 23:55:08 +01:00
/* Messages tab */
2019-11-20 01:47:22 +01:00
[Ntf_EVENT_NOTICE ] = ActSeeOneNot,
[Ntf_EVENT_FORUM_POST_COURSE] = ActSeeFor,
[Ntf_EVENT_FORUM_REPLY ] = ActSeeFor,
[Ntf_EVENT_MESSAGE ] = ActExpRcvMsg,
2014-12-01 23:55:08 +01:00
2019-11-20 01:47:22 +01:00
/* Analytics tab */
2015-03-24 00:01:40 +01:00
/* Profile tab */
2014-12-01 23:55:08 +01:00
};
/*****************************************************************************/
/***************************** Private constants *****************************/
/*****************************************************************************/
// Notify me notification events
static const char *Ntf_ParamNotifMeAboutNotifyEvents[Ntf_NUM_NOTIFY_EVENTS] =
{
2019-11-20 01:47:22 +01:00
[Ntf_EVENT_UNKNOWN ] = "NotifyNtfEventUnknown",
/* Start tab */
[Ntf_EVENT_TIMELINE_COMMENT ] = "NotifyNtfEventTimelineComment",
[Ntf_EVENT_TIMELINE_FAV ] = "NotifyNtfEventTimelineFav",
[Ntf_EVENT_TIMELINE_SHARE ] = "NotifyNtfEventTimelineShare",
[Ntf_EVENT_TIMELINE_MENTION ] = "NotifyNtfEventTimelineMention",
[Ntf_EVENT_FOLLOWER ] = "NotifyNtfEventFollower",
/* System tab */
/* Country tab */
/* Institution tab */
/* Centre tab */
/* Degree tab */
2014-12-01 23:55:08 +01:00
/* Course tab */
/* Assessment tab */
2019-11-20 01:47:22 +01:00
[Ntf_EVENT_ASSIGNMENT ] = "NotifyNtfEventAssignment",
[Ntf_EVENT_SURVEY ] = "NotifyNtfEventSurvey",
[Ntf_EVENT_EXAM_ANNOUNCEMENT] = "NotifyNtfEventExamAnnouncement",
2014-12-01 23:55:08 +01:00
2019-11-20 01:47:22 +01:00
/* Files tab */
[Ntf_EVENT_DOCUMENT_FILE ] = "NotifyNtfEventDocumentFile",
[Ntf_EVENT_TEACHERS_FILE ] = "NotifyNtfEventTeachersFile",
[Ntf_EVENT_SHARED_FILE ] = "NotifyNtfEventSharedFile",
[Ntf_EVENT_MARKS_FILE ] = "NotifyNtfEventMarksFile",
2014-12-01 23:55:08 +01:00
/* Messages tab */
2019-11-20 01:47:22 +01:00
[Ntf_EVENT_NOTICE ] = "NotifyNtfEventNotice",
[Ntf_EVENT_FORUM_POST_COURSE] = "NotifyNtfEventForumPostCourse",
[Ntf_EVENT_FORUM_REPLY ] = "NotifyNtfEventForumReply",
[Ntf_EVENT_MESSAGE ] = "NotifyNtfEventMessage",
2014-12-01 23:55:08 +01:00
2019-11-20 01:47:22 +01:00
/* Users tab */
[Ntf_EVENT_ENROLMENT_STD ] = "NotifyNtfEventEnrolmentStudent",
[Ntf_EVENT_ENROLMENT_NET ] = "NotifyNtfEventEnrolmentNonEditingTeacher",
[Ntf_EVENT_ENROLMENT_TCH ] = "NotifyNtfEventEnrolmentTeacher",
[Ntf_EVENT_ENROLMENT_REQUEST] = "NotifyNtfEventEnrolmentRequest",
2015-03-24 00:01:40 +01:00
2019-11-20 01:47:22 +01:00
/* Analytics tab */
2017-05-23 18:15:59 +02:00
2019-11-20 01:47:22 +01:00
/* Profile tab */
2014-12-01 23:55:08 +01:00
};
// Email me about notification events
static const char *Ntf_ParamEmailMeAboutNotifyEvents[Ntf_NUM_NOTIFY_EVENTS] =
{
2019-11-20 01:47:22 +01:00
[Ntf_EVENT_UNKNOWN ] = "EmailNtfEventUnknown",
/* Start tab */
[Ntf_EVENT_TIMELINE_COMMENT ] = "EmailNtfEventTimelineComment",
[Ntf_EVENT_TIMELINE_FAV ] = "EmailNtfEventTimelineFav",
[Ntf_EVENT_TIMELINE_SHARE ] = "EmailNtfEventTimelineShare",
[Ntf_EVENT_TIMELINE_MENTION ] = "EmailNtfEventTimelineMention",
[Ntf_EVENT_FOLLOWER ] = "EmailNtfEventSocialFollower",
/* System tab */
/* Country tab */
/* Institution tab */
/* Centre tab */
/* Degree tab */
2014-12-01 23:55:08 +01:00
/* Course tab */
/* Assessment tab */
2019-11-20 01:47:22 +01:00
[Ntf_EVENT_ASSIGNMENT ] = "EmailNtfEventAssignment",
[Ntf_EVENT_SURVEY ] = "EmailNtfEventSurvey",
[Ntf_EVENT_EXAM_ANNOUNCEMENT] = "EmailNtfEventExamAnnouncement",
2014-12-01 23:55:08 +01:00
2019-11-20 01:47:22 +01:00
/* Files tab */
[Ntf_EVENT_DOCUMENT_FILE ] = "EmailNtfEventDocumentFile",
[Ntf_EVENT_TEACHERS_FILE ] = "EmailNtfEventTeachersFile",
[Ntf_EVENT_SHARED_FILE ] = "EmailNtfEventSharedFile",
[Ntf_EVENT_MARKS_FILE ] = "EmailNtfEventMarksFile",
2014-12-01 23:55:08 +01:00
/* Messages tab */
2019-11-20 01:47:22 +01:00
[Ntf_EVENT_NOTICE ] = "EmailNtfEventNotice",
[Ntf_EVENT_FORUM_POST_COURSE] = "EmailNtfEventForumPostCourse",
[Ntf_EVENT_FORUM_REPLY ] = "EmailNtfEventForumReply",
[Ntf_EVENT_MESSAGE ] = "EmailNtfEventMessage",
/* Users tab */
[Ntf_EVENT_ENROLMENT_STD ] = "EmailNtfEventEnrolmentStudent",
[Ntf_EVENT_ENROLMENT_NET ] = "EmailNtfEventEnrolmentNonEditingTeacher",
[Ntf_EVENT_ENROLMENT_TCH ] = "EmailNtfEventEnrolmentTeacher",
[Ntf_EVENT_ENROLMENT_REQUEST] = "EmailNtfEventEnrolmentRequest",
2014-12-01 23:55:08 +01:00
/* Statistics tab */
2015-03-24 00:01:40 +01:00
/* Profile tab */
2014-12-01 23:55:08 +01:00
};
// Icons for notification events
static const char *Ntf_Icons[Ntf_NUM_NOTIFY_EVENTS] =
{
2019-11-20 01:47:22 +01:00
[Ntf_EVENT_UNKNOWN ] = "question.svg",
/* Start tab */
[Ntf_EVENT_TIMELINE_COMMENT ] = "comment-dots.svg",
[Ntf_EVENT_TIMELINE_FAV ] = "star.svg",
[Ntf_EVENT_TIMELINE_SHARE ] = "share-alt.svg",
[Ntf_EVENT_TIMELINE_MENTION ] = "at.svg",
[Ntf_EVENT_FOLLOWER ] = "user-plus.svg",
/* System tab */
/* Country tab */
/* Institution tab */
/* Centre tab */
/* Degree tab */
2014-12-01 23:55:08 +01:00
/* Course tab */
/* Assessment tab */
2019-11-20 01:47:22 +01:00
[Ntf_EVENT_ASSIGNMENT ] = "edit.svg",
[Ntf_EVENT_SURVEY ] = "poll.svg",
[Ntf_EVENT_EXAM_ANNOUNCEMENT] = "bullhorn.svg",
2014-12-01 23:55:08 +01:00
2019-11-20 01:47:22 +01:00
/* Files tab */
[Ntf_EVENT_DOCUMENT_FILE ] = "file.svg",
[Ntf_EVENT_TEACHERS_FILE ] = "file.svg",
[Ntf_EVENT_SHARED_FILE ] = "file.svg",
[Ntf_EVENT_MARKS_FILE ] = "clipboard-list.svg",
2016-01-22 01:47:28 +01:00
/* Messages tab */
2019-11-20 01:47:22 +01:00
[Ntf_EVENT_NOTICE ] = "sticky-note.svg",
[Ntf_EVENT_FORUM_POST_COURSE] = "comments.svg",
[Ntf_EVENT_FORUM_REPLY ] = "comments.svg",
[Ntf_EVENT_MESSAGE ] = "envelope.svg",
/* Users tab */
[Ntf_EVENT_ENROLMENT_STD ] = "user.svg",
[Ntf_EVENT_ENROLMENT_NET ] = "user-tie.svg",
[Ntf_EVENT_ENROLMENT_TCH ] = "user-tie.svg",
[Ntf_EVENT_ENROLMENT_REQUEST] = "hand-point-up.svg",
2014-12-01 23:55:08 +01:00
/* Statistics tab */
2015-03-24 00:01:40 +01:00
/* Profile tab */
2014-12-01 23:55:08 +01:00
};
/*****************************************************************************/
/***************************** Private prototypes ****************************/
/*****************************************************************************/
2016-11-07 14:24:44 +01:00
static void Ntf_PutIconsNotif (void);
2014-12-01 23:55:08 +01:00
static void Ntf_WriteFormAllNotifications (bool AllNotifications);
static bool Ntf_GetAllNotificationsFromForm (void);
2016-01-25 14:40:57 +01:00
2016-01-03 01:13:57 +01:00
static bool Ntf_StartFormGoToAction (Ntf_NotifyEvent_t NotifyEvent,
2016-01-25 14:40:57 +01:00
long CrsCod,struct UsrData *UsrDat,long Cod);
static void Ntf_PutHiddenParamNotifyEvent (Ntf_NotifyEvent_t NotifyEvent);
2014-12-01 23:55:08 +01:00
static void Ntf_UpdateMyLastAccessToNotifications (void);
static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsigned *NumNotif,unsigned *NumMails);
static void Ntf_GetNumNotifSent (long DegCod,long CrsCod,
Ntf_NotifyEvent_t NotifyEvent,
unsigned *NumEvents,unsigned *NumMails);
static void Ntf_UpdateNumNotifSent (long DegCod,long CrsCod,
Ntf_NotifyEvent_t NotifyEvent,
unsigned NumEvents,unsigned NumMails);
2016-11-07 14:12:15 +01:00
2014-12-01 23:55:08 +01:00
static void Ntf_GetParamsNotifyEvents (void);
static unsigned Ntf_GetNumberOfAllMyUnseenNtfs (void);
static unsigned Ntf_GetNumberOfMyNewUnseenNtfs (void);
/*****************************************************************************/
/*************************** Show my notifications ***************************/
/*****************************************************************************/
void Ntf_ShowMyNotifications (void)
{
2019-03-12 21:25:55 +01:00
extern const char *Hlp_START_Notifications;
2019-01-10 03:04:30 +01:00
extern const char *Txt_Settings;
2017-03-24 19:27:45 +01:00
extern const char *Txt_Domains;
2016-11-22 10:19:10 +01:00
extern const char *Txt_Mark_all_NOTIFICATIONS_as_read;
2014-12-01 23:55:08 +01:00
extern const char *Txt_Notifications;
extern const char *Txt_Date;
extern const char *Txt_Event;
extern const char *Txt_Location;
extern const char *Txt_MSG_From;
extern const char *Txt_Email;
extern const char *Txt_NOTIFY_EVENTS_SINGULAR[Ntf_NUM_NOTIFY_EVENTS];
extern const char *Txt_Forum;
extern const char *Txt_Course;
extern const char *Txt_Degree;
extern const char *Txt_Centre;
extern const char *Txt_Institution;
extern const char *Txt_NOTIFICATION_STATUS[Ntf_NUM_STATUS_TXT];
2016-11-26 17:40:48 +01:00
extern const char *Txt_You_have_no_notifications;
extern const char *Txt_You_have_no_unread_notifications;
2014-12-01 23:55:08 +01:00
char SubQuery[128];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumNotif;
unsigned long NumNotifications;
bool AllNotifications;
Ntf_NotifyEvent_t NotifyEvent = (Ntf_NotifyEvent_t) 0; // Initialized to avoid warning
struct UsrData UsrDat;
2016-10-28 10:03:37 +02:00
struct Instit Ins;
2014-12-01 23:55:08 +01:00
struct Centre Ctr;
struct Degree Deg;
struct Course Crs;
long Cod;
2017-01-13 10:49:56 +01:00
char ForumName[For_MAX_BYTES_FORUM_NAME + 1];
2015-10-24 20:12:03 +02:00
time_t DateTimeUTC; // Date-time of the event
2014-12-01 23:55:08 +01:00
Ntf_Status_t Status;
Ntf_StatusTxt_t StatusTxt;
2017-03-08 14:12:33 +01:00
char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1];
2014-12-01 23:55:08 +01:00
char *ContentStr;
const char *ClassBackground;
2019-11-18 17:59:02 +01:00
const char *ClassText;
const char *ClassLink;
2014-12-01 23:55:08 +01:00
const char *ClassAuthorBg;
bool PutLink;
/***** Get my notifications from database *****/
AllNotifications = Ntf_GetAllNotificationsFromForm ();
if (AllNotifications)
SubQuery[0] = '\0';
else
sprintf (SubQuery," AND (Status&%u)=0",
Ntf_STATUS_BIT_READ |
Ntf_STATUS_BIT_REMOVED);
2018-11-01 13:03:25 +01:00
NumNotifications = DB_QuerySELECT (&mysql_res,"can not get your notifications",
"SELECT NotifyEvent,FromUsrCod,InsCod,CtrCod,DegCod,CrsCod,"
"Cod,UNIX_TIMESTAMP(TimeNotif),Status"
" FROM notif"
" WHERE ToUsrCod=%ld%s"
" ORDER BY TimeNotif DESC",
Gbl.Usrs.Me.UsrDat.UsrCod,SubQuery);
2014-12-01 23:55:08 +01:00
2019-10-24 09:46:20 +02:00
/***** Contextual menu *****/
Mnu_ContextMenuBegin ();
Ntf_WriteFormAllNotifications (AllNotifications); // Show all notifications
2016-11-26 20:58:12 +01:00
if (NumNotifications) // TODO: Show message only when I don't have notificacions at all
2019-01-12 03:00:59 +01:00
Lay_PutContextualLinkIconText (ActMrkNtfSee,NULL,NULL,
"eye.svg",
2019-10-24 09:46:20 +02:00
Txt_Mark_all_NOTIFICATIONS_as_read); // Mark notifications as read
2019-03-26 11:53:21 +01:00
Lay_PutContextualLinkIconText (ActReqEdiSet,Ntf_NOTIFICATIONS_ID,NULL,
2019-01-12 03:00:59 +01:00
"cog.svg",
2019-10-24 09:46:20 +02:00
Txt_Settings); // Change notification settings
2019-01-12 03:00:59 +01:00
Lay_PutContextualLinkIconText (ActSeeMai,NULL,NULL,
"envelope.svg",
2019-10-24 09:46:20 +02:00
Txt_Domains); // View allowed mail domains
Mnu_ContextMenuEnd ();
2014-12-01 23:55:08 +01:00
2019-10-26 02:19:42 +02:00
/***** Begin box *****/
2019-10-25 22:48:34 +02:00
Box_BoxBegin (NULL,Txt_Notifications,Ntf_PutIconsNotif,
2019-03-12 21:25:55 +01:00
Hlp_START_Notifications,Box_NOT_CLOSABLE);
2016-11-26 17:40:48 +01:00
2014-12-01 23:55:08 +01:00
/***** List my notifications *****/
if (NumNotifications) // Notifications found
{
/***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat);
2019-10-20 22:00:28 +02:00
/***** Begin table *****/
2019-10-23 19:05:05 +02:00
HTM_TABLE_BeginWideMarginPadding (2);
HTM_TR_Begin (NULL);
2019-10-12 00:07:52 +02:00
2019-10-23 19:05:05 +02:00
HTM_TH (1,2,"LM",Txt_Event);
HTM_TH (1,1,"LM",Txt_MSG_From);
HTM_TH (1,1,"LM",Txt_Location);
HTM_TH (1,1,"CM",Txt_Date);
HTM_TH (1,1,"LM",Txt_Email);
2019-10-12 00:07:52 +02:00
2019-10-23 19:05:05 +02:00
HTM_TR_End ();
2014-12-01 23:55:08 +01:00
/***** List notifications one by one *****/
for (NumNotif = 0;
NumNotif < NumNotifications;
NumNotif++)
{
/***** Get next notification *****/
row = mysql_fetch_row (mysql_res);
/* Get event type (row[0]) */
NotifyEvent = Ntf_GetNotifyEventFromDB ((const char *) row[0]);
/* Get (from) user code (row[1]) */
UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[1]);
2019-03-19 13:22:14 +01:00
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS); // Get user's data from the database
2014-12-01 23:55:08 +01:00
/* Get institution code (row[2]) */
Ins.InsCod = Str_ConvertStrCodToLongCod (row[2]);
2015-12-09 19:51:17 +01:00
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
2014-12-01 23:55:08 +01:00
/* Get centre code (row[3]) */
Ctr.CtrCod = Str_ConvertStrCodToLongCod (row[3]);
Ctr_GetDataOfCentreByCod (&Ctr);
/* Get degree code (row[4]) */
Deg.DegCod = Str_ConvertStrCodToLongCod (row[4]);
Deg_GetDataOfDegreeByCod (&Deg);
/* Get course code (row[5]) */
Crs.CrsCod = Str_ConvertStrCodToLongCod (row[5]);
Crs_GetDataOfCourseByCod (&Crs);
/* Get message/post/... code (row[6]) */
Cod = Str_ConvertStrCodToLongCod (row[6]);
/* Get forum type of the post */
if (NotifyEvent == Ntf_EVENT_FORUM_POST_COURSE ||
NotifyEvent == Ntf_EVENT_FORUM_REPLY)
{
2017-04-18 01:25:44 +02:00
For_GetForumTypeAndLocationOfAPost (Cod,&Gbl.Forum.ForumSelected);
For_SetForumName (&Gbl.Forum.ForumSelected,
2017-04-17 11:57:55 +02:00
ForumName,Gbl.Prefs.Language,false); // Set forum name in recipient's language
2014-12-01 23:55:08 +01:00
}
/* Get time of the event (row[7]) */
2015-10-24 20:12:03 +02:00
DateTimeUTC = Dat_GetUNIXTimeFromStr (row[7]);
2014-12-01 23:55:08 +01:00
/* Get status (row[8]) */
if (sscanf (row[8],"%u",&Status) != 1)
Lay_ShowErrorAndExit ("Wrong notification status.");
StatusTxt = Ntf_GetStatusTxtFromStatusBits (Status);
if (Status & Ntf_STATUS_BIT_REMOVED) // The source of the notification was removed
{
ClassBackground = "MSG_TIT_BG_REM";
2019-11-18 17:59:02 +01:00
ClassText = "MSG_TIT_REM";
ClassLink = "BT_LINK MSG_TIT_REM";
2014-12-01 23:55:08 +01:00
ClassAuthorBg = "MSG_AUT_BG_REM";
PutLink = false;
}
else if (Status & Ntf_STATUS_BIT_READ) // I have already seen the source of the notification
{
ClassBackground = "MSG_TIT_BG";
2019-11-18 17:59:02 +01:00
ClassText = "MSG_TIT";
2019-11-19 11:03:05 +01:00
ClassLink = "BT_LINK LT MSG_TIT";
2014-12-01 23:55:08 +01:00
ClassAuthorBg = "MSG_AUT_BG";
PutLink = true;
}
else // I have not seen the source of the notification
{
ClassBackground = "MSG_TIT_BG_NEW";
2019-11-18 17:59:02 +01:00
ClassText = "MSG_TIT_NEW";
2019-11-19 11:03:05 +01:00
ClassLink = "BT_LINK LT MSG_TIT_NEW";
2014-12-01 23:55:08 +01:00
ClassAuthorBg = "MSG_AUT_BG_NEW";
PutLink = true;
}
/***** Write row for this notification *****/
/* Write event icon */
2019-10-23 19:05:05 +02:00
HTM_TR_Begin (NULL);
2019-10-09 17:38:50 +02:00
2019-10-23 19:05:05 +02:00
HTM_TD_Begin ("class=\"%s LT\" style=\"width:25px;\"",ClassBackground);
2016-01-03 01:13:57 +01:00
if (PutLink)
2016-01-25 14:40:57 +01:00
PutLink = Ntf_StartFormGoToAction (NotifyEvent,Crs.CrsCod,&UsrDat,Cod);
2016-01-03 01:13:57 +01:00
2014-12-01 23:55:08 +01:00
if (PutLink)
{
2019-01-12 03:00:59 +01:00
Ico_PutIconLink (Ntf_Icons[NotifyEvent],
Txt_NOTIFY_EVENTS_SINGULAR[NotifyEvent]);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2014-12-01 23:55:08 +01:00
}
else
2019-01-12 03:00:59 +01:00
Ico_PutIconOff (Ntf_Icons[NotifyEvent],
Txt_NOTIFY_EVENTS_SINGULAR[NotifyEvent]);
2019-10-23 19:05:05 +02:00
HTM_TD_End ();
2014-12-01 23:55:08 +01:00
/* Write event type */
2019-10-23 19:05:05 +02:00
HTM_TD_Begin ("class=\"%s LT\"",ClassBackground);
2014-12-01 23:55:08 +01:00
if (PutLink)
{
2019-11-18 17:59:02 +01:00
PutLink = Ntf_StartFormGoToAction (NotifyEvent,Crs.CrsCod,&UsrDat,Cod);
2019-11-20 10:17:42 +01:00
HTM_BUTTON_SUBMIT_Begin (Txt_NOTIFY_EVENTS_SINGULAR[NotifyEvent],ClassLink,NULL);
2019-11-10 12:36:37 +01:00
HTM_Txt (Txt_NOTIFY_EVENTS_SINGULAR[NotifyEvent]);
2019-11-18 17:59:02 +01:00
HTM_BUTTON_End ();
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2014-12-01 23:55:08 +01:00
}
else
2019-11-07 10:24:00 +01:00
{
2019-11-18 17:59:02 +01:00
HTM_SPAN_Begin ("class=\"%s\"",ClassText);
2019-11-10 12:36:37 +01:00
HTM_Txt (Txt_NOTIFY_EVENTS_SINGULAR[NotifyEvent]);
2019-11-07 10:24:00 +01:00
HTM_SPAN_End ();
}
2019-10-23 19:05:05 +02:00
HTM_TD_End ();
2014-12-01 23:55:08 +01:00
/* Write user (from) */
2019-10-23 19:05:05 +02:00
HTM_TD_Begin ("class=\"%s LT\"",ClassAuthorBg);
2017-05-02 01:16:06 +02:00
Msg_WriteMsgAuthor (&UsrDat,true,NULL);
2019-10-23 19:05:05 +02:00
HTM_TD_End ();
2014-12-01 23:55:08 +01:00
/* Write location */
2019-10-23 19:05:05 +02:00
HTM_TD_Begin ("class=\"%s LT\"",ClassBackground);
2014-12-01 23:55:08 +01:00
if (NotifyEvent == Ntf_EVENT_FORUM_POST_COURSE ||
NotifyEvent == Ntf_EVENT_FORUM_REPLY)
{
if (PutLink)
2016-01-25 14:40:57 +01:00
PutLink = Ntf_StartFormGoToAction (NotifyEvent,Crs.CrsCod,&UsrDat,Cod);
2016-01-03 01:13:57 +01:00
if (PutLink)
2019-11-20 10:17:42 +01:00
HTM_BUTTON_SUBMIT_Begin (Txt_NOTIFY_EVENTS_SINGULAR[NotifyEvent],ClassLink,NULL);
2014-12-01 23:55:08 +01:00
else
2019-11-18 17:59:02 +01:00
HTM_SPAN_Begin ("class=\"%s\"",ClassText);
2019-11-11 10:59:24 +01:00
HTM_TxtF ("%s:&nbsp;%s",Txt_Forum,ForumName);
2015-03-13 00:16:02 +01:00
if (PutLink)
{
2019-11-18 17:59:02 +01:00
HTM_BUTTON_End ();
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2015-03-13 00:16:02 +01:00
}
else
2019-11-07 10:24:00 +01:00
HTM_SPAN_End ();
2014-12-01 23:55:08 +01:00
}
2016-06-27 22:51:57 +02:00
else
2014-12-01 23:55:08 +01:00
{
if (PutLink)
2016-01-25 14:40:57 +01:00
PutLink = Ntf_StartFormGoToAction (NotifyEvent,Crs.CrsCod,&UsrDat,Cod);
2016-01-03 01:13:57 +01:00
if (PutLink)
2019-11-20 10:17:42 +01:00
HTM_BUTTON_SUBMIT_Begin (Txt_NOTIFY_EVENTS_SINGULAR[NotifyEvent],ClassLink,NULL);
2014-12-01 23:55:08 +01:00
else
2019-11-18 17:59:02 +01:00
HTM_SPAN_Begin ("class=\"%s\"",ClassText);
2016-06-27 22:51:57 +02:00
if (Crs.CrsCod > 0)
2019-11-11 10:59:24 +01:00
HTM_TxtF ("%s:&nbsp;%s",Txt_Course,Crs.ShrtName);
2016-06-27 22:51:57 +02:00
else if (Deg.DegCod > 0)
2019-11-11 10:59:24 +01:00
HTM_TxtF ("%s:&nbsp;%s",Txt_Degree,Deg.ShrtName);
2016-06-27 22:51:57 +02:00
else if (Ctr.CtrCod > 0)
2019-11-11 10:59:24 +01:00
HTM_TxtF ("%s:&nbsp;%s",Txt_Centre,Ctr.ShrtName);
2016-06-27 22:51:57 +02:00
else if (Ins.InsCod > 0)
2019-11-11 10:59:24 +01:00
HTM_TxtF ("%s:&nbsp;%s",Txt_Institution,Ins.ShrtName);
2016-06-27 22:51:57 +02:00
else
2019-11-11 10:59:24 +01:00
HTM_Hyphen ();
2016-06-27 22:51:57 +02:00
2015-03-13 00:16:02 +01:00
if (PutLink)
{
2019-11-18 17:59:02 +01:00
HTM_BUTTON_End ();
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2015-03-13 00:16:02 +01:00
}
else
2019-11-07 10:24:00 +01:00
HTM_SPAN_End ();
2014-12-01 23:55:08 +01:00
}
2019-10-23 19:05:05 +02:00
HTM_TD_End ();
2014-12-01 23:55:08 +01:00
2015-12-28 19:22:56 +01:00
/* Write date and time */
2015-10-24 20:12:03 +02:00
Msg_WriteMsgDate (DateTimeUTC,ClassBackground);
2014-12-01 23:55:08 +01:00
/* Write status (sent by email / pending to be sent by email) */
2019-10-23 19:05:05 +02:00
HTM_TD_Begin ("class=\"%s LT\"",ClassBackground);
2019-11-10 12:36:37 +01:00
HTM_Txt (Txt_NOTIFICATION_STATUS[StatusTxt]);
2019-10-23 19:05:05 +02:00
HTM_TD_End ();
2019-10-07 17:36:41 +02:00
2019-10-23 19:05:05 +02:00
HTM_TR_End ();
2014-12-01 23:55:08 +01:00
/***** Write content of the event *****/
if (PutLink)
{
ContentStr = NULL;
Ntf_GetNotifSummaryAndContent (SummaryStr,&ContentStr,NotifyEvent,
2016-01-22 12:05:25 +01:00
Cod,Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod,
2017-03-06 13:01:16 +01:00
false);
2019-10-07 17:36:41 +02:00
2019-10-23 19:05:05 +02:00
HTM_TR_Begin (NULL);
2019-10-07 17:36:41 +02:00
2019-10-23 19:05:05 +02:00
HTM_TD_Begin ("colspan=\"2\"");
HTM_TD_End ();
2019-10-07 17:36:41 +02:00
2019-10-23 19:05:05 +02:00
HTM_TD_Begin ("colspan=\"4\" class=\"DAT LT\" style=\"padding-bottom:12px;\"");
2019-11-10 12:36:37 +01:00
HTM_Txt (SummaryStr);
2019-10-23 19:05:05 +02:00
HTM_TD_End ();
2019-10-07 17:36:41 +02:00
2019-10-23 19:05:05 +02:00
HTM_TR_End ();
2019-10-07 17:36:41 +02:00
2014-12-01 23:55:08 +01:00
if (ContentStr != NULL)
{
2019-11-06 19:45:20 +01:00
free (ContentStr);
2014-12-01 23:55:08 +01:00
ContentStr = NULL;
}
}
}
2016-03-20 13:47:46 +01:00
/***** End table *****/
2019-10-23 19:05:05 +02:00
HTM_TABLE_End ();
2014-12-01 23:55:08 +01:00
/***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat);
}
else
2019-02-16 18:11:52 +01:00
Ale_ShowAlert (Ale_INFO,AllNotifications ? Txt_You_have_no_notifications :
2016-11-26 17:40:48 +01:00
Txt_You_have_no_unread_notifications);
2017-06-12 14:16:33 +02:00
/***** End box *****/
2019-10-25 22:48:34 +02:00
Box_BoxEnd ();
2014-12-01 23:55:08 +01:00
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
/***** Reset to 0 the number of new notifications *****/
Ntf_UpdateMyLastAccessToNotifications ();
}
2016-11-07 14:24:44 +01:00
/*****************************************************************************/
/****************** Put contextual icons in notifications ********************/
/*****************************************************************************/
static void Ntf_PutIconsNotif (void)
{
/***** Put icon to show a figure *****/
2019-02-12 14:46:14 +01:00
Gbl.Figures.FigureType = Fig_NOTIFY_EVENTS;
Fig_PutIconToShowFigure ();
2016-11-07 14:24:44 +01:00
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/********** Write a form to select whether show all notifications ************/
/*****************************************************************************/
static void Ntf_WriteFormAllNotifications (bool AllNotifications)
{
extern const char *Txt_Show_all_notifications;
2016-11-22 10:19:10 +01:00
extern const char *Txt_Show_all_NOTIFICATIONS;
2014-12-01 23:55:08 +01:00
2016-11-22 12:07:29 +01:00
Lay_PutContextualCheckbox (ActSeeNtf,NULL,
2017-05-22 12:23:08 +02:00
"All",
AllNotifications,false,
2016-11-22 10:44:58 +01:00
Txt_Show_all_notifications,
Txt_Show_all_NOTIFICATIONS);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************* Get whether to show all notifications from form ***************/
/*****************************************************************************/
static bool Ntf_GetAllNotificationsFromForm (void)
{
2017-01-28 20:32:50 +01:00
return Par_GetParToBool ("All");
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
2015-12-29 13:18:25 +01:00
/*********** Put form to go to an action depending on the event **************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-01-14 10:31:09 +01:00
// Return the value of Gbl.Form.Inside (true if form is started)
2014-12-01 23:55:08 +01:00
2016-01-03 01:13:57 +01:00
static bool Ntf_StartFormGoToAction (Ntf_NotifyEvent_t NotifyEvent,
2016-01-25 14:40:57 +01:00
long CrsCod,struct UsrData *UsrDat,long Cod)
2014-12-01 23:55:08 +01:00
{
extern const Act_Action_t For_ActionsSeeFor[For_NUM_TYPES_FORUM];
struct FileMetadata FileMetadata;
2016-01-02 17:07:58 +01:00
long InsCod = -1L;
long CtrCod = -1L;
long DegCod = -1L;
2014-12-01 23:55:08 +01:00
long GrpCod = -1L;
Act_Action_t Action = ActUnk; // Initialized to avoid warning
/***** Parameters depending on the type of event *****/
switch (NotifyEvent)
{
case Ntf_EVENT_DOCUMENT_FILE:
2016-04-22 09:47:25 +02:00
case Ntf_EVENT_TEACHERS_FILE:
2014-12-01 23:55:08 +01:00
case Ntf_EVENT_SHARED_FILE:
case Ntf_EVENT_MARKS_FILE:
2016-01-03 15:36:46 +01:00
Action = ActUnk;
2016-01-03 01:13:57 +01:00
FileMetadata.FilCod = Cod;
if (FileMetadata.FilCod > 0)
2014-12-01 23:55:08 +01:00
Brw_GetFileMetadataByCod (&FileMetadata);
2016-01-03 15:36:46 +01:00
if (FileMetadata.FilCod > 0)
2016-01-03 01:13:57 +01:00
{
2016-01-03 15:36:46 +01:00
Brw_GetCrsGrpFromFileMetadata (FileMetadata.FileBrowser,FileMetadata.Cod,
&InsCod,&CtrCod,&DegCod,&CrsCod,&GrpCod);
switch (NotifyEvent)
{
case Ntf_EVENT_DOCUMENT_FILE:
Action = (GrpCod > 0 ? ActReqDatSeeDocGrp :
(CrsCod > 0 ? ActReqDatSeeDocCrs :
(DegCod > 0 ? ActReqDatSeeDocDeg :
(CtrCod > 0 ? ActReqDatSeeDocCtr :
ActReqDatSeeDocIns))));
break;
2016-04-22 09:47:25 +02:00
case Ntf_EVENT_TEACHERS_FILE:
Action = (GrpCod > 0 ? ActReqDatTchGrp :
ActReqDatTchCrs);
break;
2016-01-03 15:36:46 +01:00
case Ntf_EVENT_SHARED_FILE:
Action = (GrpCod > 0 ? ActReqDatShaGrp :
(CrsCod > 0 ? ActReqDatShaCrs :
(DegCod > 0 ? ActReqDatShaDeg :
(CtrCod > 0 ? ActReqDatShaCtr :
ActReqDatShaIns))));
break;
case Ntf_EVENT_MARKS_FILE:
Action = (GrpCod > 0 ? ActReqDatSeeMrkGrp :
ActReqDatSeeMrkCrs);
break;
default: // Not aplicable here
break;
}
2018-11-09 20:47:39 +01:00
Frm_StartForm (Action);
2016-01-03 01:13:57 +01:00
if (GrpCod > 0)
Grp_PutParamGrpCod (GrpCod);
2016-01-03 15:36:46 +01:00
Brw_PutHiddenParamFilCod (FileMetadata.FilCod);
2016-01-03 01:13:57 +01:00
}
2014-12-01 23:55:08 +01:00
break;
2016-01-23 19:11:07 +01:00
case Ntf_EVENT_TIMELINE_COMMENT:
case Ntf_EVENT_TIMELINE_FAV:
case Ntf_EVENT_TIMELINE_SHARE:
case Ntf_EVENT_TIMELINE_MENTION:
2016-01-23 01:38:55 +01:00
// Cod is the code of the social publishing
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActSeeSocTmlGbl);
2019-03-12 21:25:55 +01:00
TL_PutHiddenParamPubCod (Cod);
2016-01-25 14:40:57 +01:00
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Ntf_PutHiddenParamNotifyEvent (NotifyEvent);
2016-01-22 12:42:43 +01:00
break;
2016-01-23 19:11:07 +01:00
case Ntf_EVENT_FOLLOWER:
2016-01-25 14:40:57 +01:00
if (UsrDat->EncryptedUsrCod[0]) // User's code found ==>
2016-01-20 21:18:38 +01:00
// go to user's public profile
{
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActSeeOthPubPrf);
2016-01-20 21:18:38 +01:00
/* Put param to go to follower's profile */
2016-01-25 14:40:57 +01:00
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
2016-01-20 21:18:38 +01:00
}
else // No user's code found ==> go to see my followers
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActSeeFlr);
2015-12-29 13:18:25 +01:00
break;
2014-12-01 23:55:08 +01:00
case Ntf_EVENT_FORUM_POST_COURSE:
case Ntf_EVENT_FORUM_REPLY:
2018-11-09 20:47:39 +01:00
Frm_StartForm (For_ActionsSeeFor[Gbl.Forum.ForumSelected.Type]);
2017-04-18 16:44:44 +02:00
For_PutAllHiddenParamsForum (1, // Page of threads = first
1, // Page of posts = first
Gbl.Forum.ForumSet,
2017-04-18 13:17:40 +02:00
Gbl.Forum.ThreadsOrder,
2017-04-18 01:25:44 +02:00
Gbl.Forum.ForumSelected.Location,
Gbl.Forum.ForumSelected.ThrCod,
-1L);
2014-12-01 23:55:08 +01:00
break;
2016-01-20 21:18:38 +01:00
case Ntf_EVENT_NOTICE:
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActSeeOneNot);
2016-01-20 21:18:38 +01:00
Not_PutHiddenParamNotCod (Cod);
break;
2014-12-01 23:55:08 +01:00
case Ntf_EVENT_MESSAGE:
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActExpRcvMsg);
2014-12-01 23:55:08 +01:00
Msg_PutHiddenParamMsgCod (Cod);
break;
default:
2018-11-09 20:47:39 +01:00
Frm_StartForm (Ntf_DefaultActions[NotifyEvent]);
2014-12-01 23:55:08 +01:00
break;
}
2016-01-02 17:07:58 +01:00
/***** Parameter to go to another course/degree/centre/institution *****/
2016-01-14 10:31:09 +01:00
if (Gbl.Form.Inside)
2016-01-02 17:07:58 +01:00
{
2017-10-24 11:26:01 +02:00
if (CrsCod > 0) // Course specified
2016-01-03 01:13:57 +01:00
{
2019-04-04 10:45:15 +02:00
if (CrsCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course
2016-01-03 01:13:57 +01:00
Crs_PutParamCrsCod (CrsCod); // Go to another course
}
else if (DegCod > 0) // Degree specified
{
2019-04-03 20:57:04 +02:00
if (DegCod != Gbl.Hierarchy.Deg.DegCod) // Not the current degree
2016-01-03 01:13:57 +01:00
Deg_PutParamDegCod (DegCod); // Go to another degree
}
else if (CtrCod > 0) // Centre specified
{
2019-04-03 20:57:04 +02:00
if (CtrCod != Gbl.Hierarchy.Ctr.CtrCod) // Not the current centre
2016-01-03 01:13:57 +01:00
Ctr_PutParamCtrCod (CtrCod); // Go to another centre
}
else if (InsCod > 0) // Institution specified
{
2019-04-03 20:57:04 +02:00
if (InsCod != Gbl.Hierarchy.Ins.InsCod) // Not the current institution
2016-01-03 01:13:57 +01:00
Ins_PutParamInsCod (InsCod); // Go to another institution
}
2016-01-02 17:07:58 +01:00
}
2016-01-03 01:13:57 +01:00
2016-01-14 10:31:09 +01:00
return Gbl.Form.Inside;
2014-12-01 23:55:08 +01:00
}
2016-01-25 14:40:57 +01:00
/*****************************************************************************/
/******************* Get parameter with notify event type ********************/
/*****************************************************************************/
static void Ntf_PutHiddenParamNotifyEvent (Ntf_NotifyEvent_t NotifyEvent)
{
2019-11-03 13:19:32 +01:00
Par_PutHiddenParamUnsigned (NULL,"NotifyEvent",(unsigned) NotifyEvent);
2016-01-25 14:40:57 +01:00
}
/*****************************************************************************/
/******************* Get parameter with notify event type ********************/
/*****************************************************************************/
Ntf_NotifyEvent_t Ntf_GetParamNotifyEvent (void)
{
2017-01-29 21:41:08 +01:00
return (Ntf_NotifyEvent_t)
Par_GetParToUnsignedLong ("NotifyEvent",
0,
Ntf_NUM_NOTIFY_EVENTS - 1,
(unsigned long) Ntf_EVENT_UNKNOWN);
2016-01-25 14:40:57 +01:00
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/****************** Set StatusTxt depending on status bits *******************/
/*****************************************************************************/
// Ntf_STATUS_NO_EMAIL = 0, // --0 !(Status & Ntf_STATUS_BIT_EMAIL)
// Ntf_STATUS_EMAIL_PENDING = 1, // 001 (Status & Ntf_STATUS_BIT_EMAIL) && !(Status & Ntf_STATUS_BIT_SENT) && !(Status & Ntf_STATUS_BIT_READ)
// Ntf_STATUS_EMAIL_CANCELLED = 2, // 101 (Status & Ntf_STATUS_BIT_EMAIL) && !(Status & Ntf_STATUS_BIT_SENT) && (Status & Ntf_STATUS_BIT_READ)
// Ntf_STATUS_EMAIL_SENT = 3, // -11 (Status & Ntf_STATUS_BIT_EMAIL) && (Status & Ntf_STATUS_BIT_SENT)
Ntf_StatusTxt_t Ntf_GetStatusTxtFromStatusBits (Ntf_Status_t Status)
{
if (!(Status & Ntf_STATUS_BIT_EMAIL))
return Ntf_STATUS_NO_EMAIL;
if ( (Status & Ntf_STATUS_BIT_SENT))
return Ntf_STATUS_EMAIL_SENT;
if ( (Status & (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED)))
return Ntf_STATUS_EMAIL_CANCELLED;
return Ntf_STATUS_EMAIL_PENDING;
}
/*****************************************************************************/
2015-12-28 19:22:56 +01:00
/******************* Get notification summary and content ********************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2017-03-08 14:12:33 +01:00
void Ntf_GetNotifSummaryAndContent (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
2017-01-13 10:49:56 +01:00
char **ContentStr,
2016-01-22 12:05:25 +01:00
Ntf_NotifyEvent_t NotifyEvent,
long Cod,long CrsCod,long UsrCod,
2017-03-06 13:01:16 +01:00
bool GetContent)
2014-12-01 23:55:08 +01:00
{
SummaryStr[0] = '\0';
switch (NotifyEvent)
{
case Ntf_EVENT_UNKNOWN:
break;
case Ntf_EVENT_DOCUMENT_FILE:
2016-04-22 09:47:25 +02:00
case Ntf_EVENT_TEACHERS_FILE:
2014-12-01 23:55:08 +01:00
case Ntf_EVENT_SHARED_FILE:
2017-03-06 13:01:16 +01:00
Brw_GetSummaryAndContentOfFile (SummaryStr,ContentStr,Cod,GetContent);
2014-12-01 23:55:08 +01:00
break;
case Ntf_EVENT_ASSIGNMENT:
2017-03-06 13:01:16 +01:00
Asg_GetNotifAssignment (SummaryStr,ContentStr,Cod,GetContent);
2014-12-01 23:55:08 +01:00
break;
case Ntf_EVENT_EXAM_ANNOUNCEMENT:
2017-03-06 13:01:16 +01:00
Exa_GetSummaryAndContentExamAnnouncement (SummaryStr,ContentStr,Cod,GetContent);
2014-12-01 23:55:08 +01:00
break;
case Ntf_EVENT_MARKS_FILE:
2017-03-06 13:01:16 +01:00
Mrk_GetNotifMyMarks (SummaryStr,ContentStr,Cod,UsrCod,GetContent);
2014-12-01 23:55:08 +01:00
break;
2017-05-21 18:08:35 +02:00
case Ntf_EVENT_ENROLMENT_STD:
2017-06-04 18:18:54 +02:00
case Ntf_EVENT_ENROLMENT_NET:
2017-05-21 18:08:35 +02:00
case Ntf_EVENT_ENROLMENT_TCH:
2017-03-30 11:20:06 +02:00
Enr_GetNotifEnrolment (SummaryStr,CrsCod,UsrCod);
2014-12-01 23:55:08 +01:00
break;
2017-03-30 11:20:06 +02:00
case Ntf_EVENT_ENROLMENT_REQUEST:
Enr_GetNotifEnrolmentRequest (SummaryStr,ContentStr,Cod,GetContent);
2014-12-01 23:55:08 +01:00
break;
2016-01-23 19:11:07 +01:00
case Ntf_EVENT_TIMELINE_COMMENT:
case Ntf_EVENT_TIMELINE_FAV:
case Ntf_EVENT_TIMELINE_SHARE:
case Ntf_EVENT_TIMELINE_MENTION:
2016-01-23 01:38:55 +01:00
// Cod is the code of the social publishing
2019-03-12 21:25:55 +01:00
TL_GetNotifPublication (SummaryStr,ContentStr,Cod,GetContent);
2016-01-22 01:47:28 +01:00
break;
2016-01-23 19:11:07 +01:00
case Ntf_EVENT_FOLLOWER:
2016-01-22 01:47:28 +01:00
Fol_GetNotifFollower (SummaryStr,ContentStr);
2014-12-01 23:55:08 +01:00
break;
case Ntf_EVENT_FORUM_POST_COURSE:
case Ntf_EVENT_FORUM_REPLY:
2017-03-06 13:01:16 +01:00
For_GetSummaryAndContentForumPst (SummaryStr,ContentStr,Cod,GetContent);
2014-12-01 23:55:08 +01:00
break;
2016-01-22 01:47:28 +01:00
case Ntf_EVENT_NOTICE:
2017-03-06 13:01:16 +01:00
Not_GetSummaryAndContentNotice (SummaryStr,ContentStr,Cod,GetContent);
2016-01-22 01:47:28 +01:00
break;
2014-12-01 23:55:08 +01:00
case Ntf_EVENT_MESSAGE:
2017-03-06 13:01:16 +01:00
Msg_GetNotifMessage (SummaryStr,ContentStr,Cod,GetContent);
2014-12-01 23:55:08 +01:00
if (Gbl.WebService.IsWebService)
/* Set the message as open by me, because I can read it in an extern application */
Msg_SetReceivedMsgAsOpen (Cod,UsrCod);
break;
case Ntf_EVENT_SURVEY:
2017-03-06 13:01:16 +01:00
Svy_GetNotifSurvey (SummaryStr,ContentStr,Cod,GetContent);
2014-12-01 23:55:08 +01:00
break;
}
}
/*****************************************************************************/
/********************** Set possible notification as seen ********************/
/*****************************************************************************/
2016-01-20 21:18:38 +01:00
void Ntf_MarkNotifAsSeen (Ntf_NotifyEvent_t NotifyEvent,long Cod,long CrsCod,long ToUsrCod)
2014-12-01 23:55:08 +01:00
{
/***** Set notification as seen by me *****/
if (ToUsrCod > 0) // If the user code is specified
{
2018-11-03 12:16:40 +01:00
if (Cod > 0) // Set only one notification
// for the user as seen
DB_QueryUPDATE ("can not set notification(s) as seen",
"UPDATE notif SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld AND NotifyEvent=%u AND Cod=%ld",
(unsigned) Ntf_STATUS_BIT_READ,
ToUsrCod,(unsigned) NotifyEvent,Cod);
else if (CrsCod > 0) // Set all notifications of this type
// in the current course for the user as seen
DB_QueryUPDATE ("can not set notification(s) as seen",
"UPDATE notif SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld AND NotifyEvent=%u AND CrsCod=%ld",
(unsigned) Ntf_STATUS_BIT_READ,
2019-04-04 10:45:15 +02:00
ToUsrCod,(unsigned) NotifyEvent,Gbl.Hierarchy.Crs.CrsCod);
2018-11-03 12:16:40 +01:00
else // Set all notifications of this type
// for the user as seen
DB_QueryUPDATE ("can not set notification(s) as seen",
"UPDATE notif SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld AND NotifyEvent=%u",
(unsigned) Ntf_STATUS_BIT_READ,
ToUsrCod,(unsigned) NotifyEvent);
2014-12-01 23:55:08 +01:00
}
}
/*****************************************************************************/
/******************* Set possible notifications as removed *******************/
/*****************************************************************************/
2016-01-04 01:56:28 +01:00
void Ntf_MarkNotifAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod)
2014-12-01 23:55:08 +01:00
{
/***** Set notification as removed *****/
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not set notification(s) as removed",
"UPDATE notif SET Status=(Status | %u)"
" WHERE NotifyEvent=%u AND Cod=%ld",
(unsigned) Ntf_STATUS_BIT_REMOVED,
(unsigned) NotifyEvent,Cod);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******************** Set possible notification as removed *******************/
/*****************************************************************************/
2016-01-04 01:56:28 +01:00
void Ntf_MarkNotifToOneUsrAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod,long ToUsrCod)
2014-12-01 23:55:08 +01:00
{
/***** Set notification as removed *****/
if (Cod > 0) // Set only one notification as removed
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not set notification(s) as removed",
"UPDATE notif SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld AND NotifyEvent=%u AND Cod=%ld",
(unsigned) Ntf_STATUS_BIT_REMOVED,
ToUsrCod,(unsigned) NotifyEvent,
Cod);
else // Set all notifications of this type,
// in the current course for the user, as removed
DB_QueryUPDATE ("can not set notification(s) as removed",
"UPDATE notif SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld AND NotifyEvent=%u AND CrsCod=%ld",
(unsigned) Ntf_STATUS_BIT_REMOVED,
ToUsrCod,(unsigned) NotifyEvent,
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.CrsCod);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/*********** Set possible notifications from a course as removed *************/
/*****************************************************************************/
// This function should be called when a course is removed
// because notifications from this course will not be available after course removing.
// However, notifications about new messages should not be removed
// because the messages will remain available
2016-12-28 18:18:24 +01:00
void Ntf_MarkNotifInCrsAsRemoved (long ToUsrCod,long CrsCod)
2014-12-01 23:55:08 +01:00
{
/***** Set all notifications from the course as removed,
except notifications about new messages *****/
if (ToUsrCod > 0) // If the user code is specified
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not set notification(s) as removed",
"UPDATE notif SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld"
" AND CrsCod=%ld"
" AND NotifyEvent<>%u", // messages will remain available
(unsigned) Ntf_STATUS_BIT_REMOVED,
ToUsrCod,
CrsCod,(unsigned) Ntf_EVENT_MESSAGE);
2016-12-28 18:18:24 +01:00
else // User code not specified ==> any user
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not set notification(s) as removed",
"UPDATE notif SET Status=(Status | %u)"
" WHERE CrsCod=%ld"
" AND NotifyEvent<>%u", // messages will remain available
(unsigned) Ntf_STATUS_BIT_REMOVED,
CrsCod,(unsigned) Ntf_EVENT_MESSAGE);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
2016-01-04 01:56:28 +01:00
/*********** Mark possible notifications of one file as removed **************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-01-04 01:56:28 +01:00
void Ntf_MarkNotifOneFileAsRemoved (const char *Path)
2014-12-01 23:55:08 +01:00
{
2016-01-04 01:02:07 +01:00
extern const Brw_FileBrowser_t Brw_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
Brw_FileBrowser_t FileBrowser = Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type];
long FilCod;
2014-12-01 23:55:08 +01:00
Ntf_NotifyEvent_t NotifyEvent;
switch (FileBrowser)
{
2017-10-08 00:51:49 +02:00
case Brw_ADMI_DOC_CRS:
case Brw_ADMI_DOC_GRP:
case Brw_ADMI_TCH_CRS:
case Brw_ADMI_TCH_GRP:
case Brw_ADMI_SHR_CRS:
case Brw_ADMI_SHR_GRP:
case Brw_ADMI_MRK_CRS:
case Brw_ADMI_MRK_GRP:
2016-01-04 01:02:07 +01:00
/***** Get file code *****/
FilCod = Brw_GetFilCodByPath (Path,false); // Any file, public or not
if (FilCod > 0)
{
/***** Set notification as removed *****/
switch (FileBrowser)
{
2017-10-08 00:51:49 +02:00
case Brw_ADMI_DOC_CRS:
case Brw_ADMI_DOC_GRP:
2016-01-04 01:02:07 +01:00
NotifyEvent = Ntf_EVENT_DOCUMENT_FILE;
break;
2017-10-08 00:51:49 +02:00
case Brw_ADMI_TCH_CRS:
case Brw_ADMI_TCH_GRP:
2016-04-22 09:47:25 +02:00
NotifyEvent = Ntf_EVENT_TEACHERS_FILE;
break;
2017-10-08 00:51:49 +02:00
case Brw_ADMI_SHR_CRS:
case Brw_ADMI_SHR_GRP:
2016-01-04 01:02:07 +01:00
NotifyEvent = Ntf_EVENT_SHARED_FILE;
break;
2017-10-08 00:51:49 +02:00
case Brw_ADMI_MRK_CRS:
case Brw_ADMI_MRK_GRP:
2016-01-04 01:02:07 +01:00
NotifyEvent = Ntf_EVENT_MARKS_FILE;
break;
default:
2016-01-04 01:56:28 +01:00
return;
2016-01-04 01:02:07 +01:00
}
2016-01-04 01:56:28 +01:00
Ntf_MarkNotifAsRemoved (NotifyEvent,FilCod);
2016-01-04 01:02:07 +01:00
}
break;
2014-12-01 23:55:08 +01:00
default:
2016-01-04 01:02:07 +01:00
break;
2014-12-01 23:55:08 +01:00
}
2016-01-04 01:02:07 +01:00
}
/*****************************************************************************/
2016-01-04 01:56:28 +01:00
/*** Mark possible notifications involving children of a folder as removed ***/
2016-01-04 01:02:07 +01:00
/*****************************************************************************/
2016-01-04 01:56:28 +01:00
void Ntf_MarkNotifChildrenOfFolderAsRemoved (const char *Path)
2016-01-04 01:02:07 +01:00
{
extern const Brw_FileBrowser_t Brw_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
Brw_FileBrowser_t FileBrowser = Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type];
2016-01-04 01:56:28 +01:00
long Cod = Brw_GetCodForFiles ();
2014-12-01 23:55:08 +01:00
Ntf_NotifyEvent_t NotifyEvent;
switch (FileBrowser)
{
2017-10-08 00:51:49 +02:00
case Brw_ADMI_DOC_CRS:
case Brw_ADMI_DOC_GRP:
case Brw_ADMI_TCH_CRS:
case Brw_ADMI_TCH_GRP:
case Brw_ADMI_SHR_CRS:
case Brw_ADMI_SHR_GRP:
case Brw_ADMI_MRK_CRS:
case Brw_ADMI_MRK_GRP:
2016-01-04 01:56:28 +01:00
/***** Set notification as removed *****/
switch (FileBrowser)
{
2017-10-08 00:51:49 +02:00
case Brw_ADMI_DOC_CRS:
case Brw_ADMI_DOC_GRP:
2016-01-04 01:56:28 +01:00
NotifyEvent = Ntf_EVENT_DOCUMENT_FILE;
break;
2017-10-08 00:51:49 +02:00
case Brw_ADMI_TCH_CRS:
case Brw_ADMI_TCH_GRP:
2016-04-22 09:47:25 +02:00
NotifyEvent = Ntf_EVENT_TEACHERS_FILE;
break;
2017-10-08 00:51:49 +02:00
case Brw_ADMI_SHR_CRS:
case Brw_ADMI_SHR_GRP:
2016-01-04 01:56:28 +01:00
NotifyEvent = Ntf_EVENT_SHARED_FILE;
break;
2017-10-08 00:51:49 +02:00
case Brw_ADMI_MRK_CRS:
case Brw_ADMI_MRK_GRP:
2016-01-04 01:56:28 +01:00
NotifyEvent = Ntf_EVENT_MARKS_FILE;
break;
default:
return;
}
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not set notification(s) as removed",
"UPDATE notif SET Status=(Status | %u)"
" WHERE NotifyEvent=%u AND Cod IN"
" (SELECT FilCod FROM files"
" WHERE FileBrowser=%u AND Cod=%ld"
" AND Path LIKE '%s/%%')",
(unsigned) Ntf_STATUS_BIT_REMOVED,
(unsigned) NotifyEvent,
(unsigned) FileBrowser,Cod,
Path);
2014-12-01 23:55:08 +01:00
break;
default:
break;
}
}
/*****************************************************************************/
/******* Set all possible notifications of files in a group as removed *******/
/*****************************************************************************/
2016-01-04 01:56:28 +01:00
void Ntf_MarkNotifFilesInGroupAsRemoved (long GrpCod)
2014-12-01 23:55:08 +01:00
{
/***** Set notifications as removed *****/
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not set notification(s) as removed",
"UPDATE notif SET Status=(Status | %u)"
" WHERE NotifyEvent IN (%u,%u,%u,%u) AND Cod IN"
" (SELECT FilCod FROM files"
" WHERE FileBrowser IN (%u,%u,%u,%u) AND Cod=%ld)",
(unsigned) Ntf_STATUS_BIT_REMOVED,
(unsigned) Ntf_EVENT_DOCUMENT_FILE,
(unsigned) Ntf_EVENT_TEACHERS_FILE,
(unsigned) Ntf_EVENT_SHARED_FILE,
(unsigned) Ntf_EVENT_MARKS_FILE,
(unsigned) Brw_ADMI_DOC_GRP,
(unsigned) Brw_ADMI_TCH_GRP,
(unsigned) Brw_ADMI_SHR_GRP,
(unsigned) Brw_ADMI_MRK_GRP,
GrpCod);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
2016-01-22 12:42:43 +01:00
/********** Get a list with user's codes of all users to be notified *********/
/********** about an event, and notify them *********/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-11-16 23:19:52 +01:00
// Return the number of users notified by email
2014-12-01 23:55:08 +01:00
unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRow;
2018-11-01 13:03:25 +01:00
unsigned long NumRows = 0; // Initialized to avoid warning
2014-12-01 23:55:08 +01:00
struct UsrData UsrDat;
2017-04-18 01:25:44 +02:00
struct Forum ForumSelected;
2014-12-01 23:55:08 +01:00
unsigned NumUsrsToBeNotifiedByEMail = 0;
unsigned NotifyEventMask = (1 << NotifyEvent);
/***** Get users who want to be notified from database ******/
switch (NotifyEvent)
{
case Ntf_EVENT_UNKNOWN: // This function should not be called in this case
return 0;
case Ntf_EVENT_DOCUMENT_FILE:
2016-04-22 09:47:25 +02:00
case Ntf_EVENT_TEACHERS_FILE:
2014-12-01 23:55:08 +01:00
case Ntf_EVENT_SHARED_FILE:
case Ntf_EVENT_MARKS_FILE:
switch (Gbl.FileBrowser.Type)
{
2017-10-08 00:51:49 +02:00
case Brw_ADMI_DOC_CRS:
case Brw_ADMI_SHR_CRS:
case Brw_ADMI_MRK_CRS: // Notify all users in course except me
2018-11-01 13:03:25 +01:00
NumRows = DB_QuerySELECT (&mysql_res,"can not get users"
" to be notified",
"SELECT UsrCod FROM crs_usr"
" WHERE CrsCod=%ld"
" AND UsrCod<>%ld",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.CrsCod,
2018-11-01 13:03:25 +01:00
Gbl.Usrs.Me.UsrDat.UsrCod);
2014-12-01 23:55:08 +01:00
break;
2017-10-08 00:51:49 +02:00
case Brw_ADMI_TCH_CRS: // Notify all teachers in course except me
2018-11-01 13:03:25 +01:00
NumRows = DB_QuerySELECT (&mysql_res,"can not get users"
" to be notified",
"SELECT UsrCod FROM crs_usr"
" WHERE CrsCod=%ld"
" AND UsrCod<>%ld"
" AND Role=%u", // Notify teachers only
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.CrsCod,
2018-11-01 13:03:25 +01:00
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) Rol_TCH);
2016-04-22 09:47:25 +02:00
break;
2017-10-08 00:51:49 +02:00
case Brw_ADMI_DOC_GRP:
case Brw_ADMI_SHR_GRP:
case Brw_ADMI_MRK_GRP: // Notify all users in group except me
2018-11-01 13:03:25 +01:00
NumRows = DB_QuerySELECT (&mysql_res,"can not get users"
" to be notified",
"SELECT UsrCod FROM crs_grp_usr"
" WHERE crs_grp_usr.GrpCod=%ld"
" AND crs_grp_usr.UsrCod<>%ld",
2019-04-04 10:45:15 +02:00
Gbl.Crs.Grps.GrpCod,
2018-11-01 13:03:25 +01:00
Gbl.Usrs.Me.UsrDat.UsrCod);
2014-12-01 23:55:08 +01:00
break;
2017-10-08 00:51:49 +02:00
case Brw_ADMI_TCH_GRP: // Notify all teachers in group except me
2018-11-01 13:03:25 +01:00
NumRows = DB_QuerySELECT (&mysql_res,"can not get users"
" to be notified",
"SELECT crs_grp_usr.UsrCod"
" FROM crs_grp_usr,crs_grp,crs_grp_types,crs_usr"
" WHERE crs_grp_usr.GrpCod=%ld"
" AND crs_grp_usr.UsrCod<>%ld"
" AND crs_grp_usr.GrpCod=crs_grp.GrpCod"
" AND crs_grp.GrpTypCod=crs_grp_types.GrpTypCod"
" AND crs_grp_types.CrsCod=crs_usr.CrsCod"
" AND crs_usr.Role=%u", // Notify teachers only
2019-04-04 10:45:15 +02:00
Gbl.Crs.Grps.GrpCod,
2018-11-01 13:03:25 +01:00
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) Rol_TCH);
2016-04-22 09:47:25 +02:00
break;
2014-12-01 23:55:08 +01:00
default: // This function should not be called in other cases
return 0;
}
break;
case Ntf_EVENT_ASSIGNMENT:
2017-03-30 11:20:06 +02:00
// 1. If the assignment is available for the whole course ==> get all users enroled in the course except me
2014-12-01 23:55:08 +01:00
// 2. If the assignment is available only for some groups ==> get all users who belong to any of the groups except me
// Cases 1 and 2 are mutually exclusive, so the union returns the case 1 or 2
2018-11-01 13:03:25 +01:00
NumRows = DB_QuerySELECT (&mysql_res,"can not get users"
" to be notified",
"(SELECT crs_usr.UsrCod"
" FROM assignments,crs_usr"
" WHERE assignments.AsgCod=%ld"
" AND assignments.AsgCod NOT IN"
" (SELECT AsgCod FROM asg_grp WHERE AsgCod=%ld)"
" AND assignments.CrsCod=crs_usr.CrsCod"
" AND crs_usr.UsrCod<>%ld)"
" UNION "
"(SELECT DISTINCT crs_grp_usr.UsrCod"
" FROM asg_grp,crs_grp_usr"
" WHERE asg_grp.AsgCod=%ld"
" AND asg_grp.GrpCod=crs_grp_usr.GrpCod"
" AND crs_grp_usr.UsrCod<>%ld)",
Cod,Cod,Gbl.Usrs.Me.UsrDat.UsrCod,
Cod,Gbl.Usrs.Me.UsrDat.UsrCod);
2014-12-01 23:55:08 +01:00
break;
case Ntf_EVENT_EXAM_ANNOUNCEMENT:
case Ntf_EVENT_NOTICE:
2018-11-01 13:03:25 +01:00
NumRows = DB_QuerySELECT (&mysql_res,"can not get users"
" to be notified",
"SELECT UsrCod FROM crs_usr"
" WHERE CrsCod=%ld AND UsrCod<>%ld",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.CrsCod,
2018-11-01 13:03:25 +01:00
Gbl.Usrs.Me.UsrDat.UsrCod);
2014-12-01 23:55:08 +01:00
break;
2017-05-21 18:08:35 +02:00
case Ntf_EVENT_ENROLMENT_STD: // This function should not be called in this case
2017-06-04 18:18:54 +02:00
case Ntf_EVENT_ENROLMENT_NET: // This function should not be called in this case
2017-05-21 18:08:35 +02:00
case Ntf_EVENT_ENROLMENT_TCH: // This function should not be called in this case
2014-12-01 23:55:08 +01:00
return 0;
2017-03-30 11:20:06 +02:00
case Ntf_EVENT_ENROLMENT_REQUEST:
2019-04-04 10:45:15 +02:00
if (Gbl.Hierarchy.Crs.NumUsrs[Rol_TCH])
2018-10-24 01:01:16 +02:00
{
2014-12-01 23:55:08 +01:00
// If this course has teachers ==> send notification to teachers
2018-11-01 13:03:25 +01:00
NumRows = DB_QuerySELECT (&mysql_res,"can not get users"
" to be notified",
"SELECT UsrCod FROM crs_usr"
" WHERE CrsCod=%ld"
" AND UsrCod<>%ld"
" AND Role=%u", // Notify teachers only
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.CrsCod,
2018-11-01 13:03:25 +01:00
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) Rol_TCH);
2018-10-24 01:01:16 +02:00
}
2014-12-01 23:55:08 +01:00
else // Course without teachers
2018-10-24 01:01:16 +02:00
{
2014-12-01 23:55:08 +01:00
// If this course has no teachers
// and I want to be a teacher (checked before calling this function
// to not send requests to be a student to admins)
// ==> send notification to administrators or superusers
2018-11-01 13:03:25 +01:00
NumRows = DB_QuerySELECT (&mysql_res,"can not get users"
" to be notified",
"SELECT UsrCod FROM admin"
" WHERE (Scope='%s'"
" OR (Scope='%s' AND Cod=%ld)"
" OR (Scope='%s' AND Cod=%ld)"
" OR (Scope='%s' AND Cod=%ld))"
" AND UsrCod<>%ld",
2019-04-03 20:57:04 +02:00
Sco_GetDBStrFromScope (Hie_SYS),
Sco_GetDBStrFromScope (Hie_INS),Gbl.Hierarchy.Ins.InsCod,
Sco_GetDBStrFromScope (Hie_CTR),Gbl.Hierarchy.Ctr.CtrCod,
Sco_GetDBStrFromScope (Hie_DEG),Gbl.Hierarchy.Deg.DegCod,
2018-11-01 13:03:25 +01:00
Gbl.Usrs.Me.UsrDat.UsrCod);
2018-10-24 01:01:16 +02:00
}
2014-12-01 23:55:08 +01:00
break;
2016-01-23 19:11:07 +01:00
case Ntf_EVENT_TIMELINE_COMMENT: // New comment to one of my social notes or comments
2016-01-23 01:38:55 +01:00
// Cod is the code of the social publishing
2018-11-01 13:03:25 +01:00
NumRows = DB_QuerySELECT (&mysql_res,"can not get users"
" to be notified",
"SELECT DISTINCT(PublisherCod) FROM social_pubs"
" WHERE NotCod ="
" (SELECT NotCod FROM social_pubs"
" WHERE PubCod=%ld)"
" AND PublisherCod<>%ld",
Cod,Gbl.Usrs.Me.UsrDat.UsrCod);
2016-01-22 01:47:28 +01:00
break;
2016-01-23 19:11:07 +01:00
case Ntf_EVENT_TIMELINE_FAV: // New favourite to one of my social notes or comments
case Ntf_EVENT_TIMELINE_SHARE: // New sharing of one of my social notes
case Ntf_EVENT_TIMELINE_MENTION:
case Ntf_EVENT_FOLLOWER:
2016-01-23 01:38:55 +01:00
// This function should not be called in these cases
2016-01-22 01:47:28 +01:00
return 0;
2014-12-01 23:55:08 +01:00
case Ntf_EVENT_FORUM_POST_COURSE:
// Check if forum is for users or for all users in the course
2017-04-18 01:25:44 +02:00
For_GetForumTypeAndLocationOfAPost (Cod,&ForumSelected);
switch (ForumSelected.Type)
2014-12-01 23:55:08 +01:00
{
case For_FORUM_COURSE_USRS:
2018-11-01 13:03:25 +01:00
NumRows = DB_QuerySELECT (&mysql_res,"can not get users"
" to be notified",
"SELECT UsrCod FROM crs_usr"
" WHERE CrsCod=%ld AND UsrCod<>%ld",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.CrsCod,
2018-11-01 13:03:25 +01:00
Gbl.Usrs.Me.UsrDat.UsrCod);
2014-12-01 23:55:08 +01:00
break;
case For_FORUM_COURSE_TCHS:
2018-11-01 13:03:25 +01:00
NumRows = DB_QuerySELECT (&mysql_res,"can not get users"
" to be notified",
"SELECT UsrCod FROM crs_usr"
" WHERE CrsCod=%ld AND Role=%u AND UsrCod<>%ld",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.CrsCod,
2018-11-01 13:03:25 +01:00
(unsigned) Rol_TCH,
Gbl.Usrs.Me.UsrDat.UsrCod);
2014-12-01 23:55:08 +01:00
break;
default:
return 0;
}
break;
case Ntf_EVENT_FORUM_REPLY:
2018-11-01 13:03:25 +01:00
NumRows = DB_QuerySELECT (&mysql_res,"can not get users"
" to be notified",
"SELECT DISTINCT(UsrCod) FROM forum_post"
" WHERE ThrCod = (SELECT ThrCod FROM forum_post"
" WHERE PstCod=%ld)"
" AND UsrCod<>%ld",
Cod,Gbl.Usrs.Me.UsrDat.UsrCod);
2014-12-01 23:55:08 +01:00
break;
case Ntf_EVENT_MESSAGE: // This function should not be called in this case
return 0;
case Ntf_EVENT_SURVEY: // Only surveys for a course are notified, not surveys for a degree or global
2017-03-30 11:20:06 +02:00
// 1. If the survey is available for the whole course ==> get users enroled in the course whose role is available in survey, except me
2014-12-01 23:55:08 +01:00
// 2. If the survey is available only for some groups ==> get users who belong to any of the groups and whose role is available in survey, except me
// Cases 1 and 2 are mutually exclusive, so the union returns the case 1 or 2
2018-11-01 13:03:25 +01:00
NumRows = DB_QuerySELECT (&mysql_res,"can not get users"
" to be notified",
"(SELECT crs_usr.UsrCod"
" FROM surveys,crs_usr"
" WHERE surveys.SvyCod=%ld"
" AND surveys.SvyCod NOT IN"
" (SELECT SvyCod FROM svy_grp WHERE SvyCod=%ld)"
" AND surveys.Scope='%s' AND surveys.Cod=crs_usr.CrsCod"
" AND crs_usr.UsrCod<>%ld"
" AND (surveys.Roles&(1<<crs_usr.Role))<>0)"
" UNION "
"(SELECT DISTINCT crs_grp_usr.UsrCod"
" FROM svy_grp,crs_grp_usr,surveys,crs_usr"
" WHERE svy_grp.SvyCod=%ld"
" AND svy_grp.GrpCod=crs_grp_usr.GrpCod"
" AND crs_grp_usr.UsrCod=crs_usr.UsrCod"
" AND crs_grp_usr.UsrCod<>%ld"
" AND svy_grp.SvyCod=surveys.SvyCod"
" AND surveys.Scope='%s' AND surveys.Cod=crs_usr.CrsCod"
" AND (surveys.Roles&(1<<crs_usr.Role))<>0)",
Cod,
Cod,
2019-04-03 20:57:04 +02:00
Sco_GetDBStrFromScope (Hie_CRS),
2018-11-01 13:03:25 +01:00
Gbl.Usrs.Me.UsrDat.UsrCod,
Cod,
Gbl.Usrs.Me.UsrDat.UsrCod,
2019-04-03 20:57:04 +02:00
Sco_GetDBStrFromScope (Hie_CRS));
2014-12-01 23:55:08 +01:00
break;
}
2018-11-01 13:03:25 +01:00
if (NumRows) // Users found
2014-12-01 23:55:08 +01:00
{
/***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat);
/***** Notify the users one by one *****/
for (NumRow = 0;
NumRow < NumRows;
NumRow++)
{
/* Get next user */
row = mysql_fetch_row (mysql_res);
/* Get user code */
UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
2019-03-19 13:22:14 +01:00
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS)) // Get user's data from the database
if ((UsrDat.NtfEvents.CreateNotif & NotifyEventMask)) // Create notification
2014-12-01 23:55:08 +01:00
{
2019-03-19 13:22:14 +01:00
if ((UsrDat.NtfEvents.SendEmail & NotifyEventMask)) // Send notification by email
2014-12-01 23:55:08 +01:00
{
Ntf_StoreNotifyEventToOneUser (NotifyEvent,&UsrDat,Cod,
(Ntf_Status_t) Ntf_STATUS_BIT_EMAIL);
NumUsrsToBeNotifiedByEMail++;
}
else // Don't send notification by email
Ntf_StoreNotifyEventToOneUser (NotifyEvent,&UsrDat,Cod,(Ntf_Status_t) 0);
}
}
/***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat);
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
return NumUsrsToBeNotifiedByEMail;
}
/*****************************************************************************/
/************** Store a notify event to one user into database ***************/
/*****************************************************************************/
void Ntf_StoreNotifyEventToOneUser (Ntf_NotifyEvent_t NotifyEvent,
struct UsrData *UsrDat,
long Cod,Ntf_Status_t Status)
{
long InsCod;
long CtrCod;
long DegCod;
long CrsCod;
if (NotifyEvent == Ntf_EVENT_FORUM_POST_COURSE ||
NotifyEvent == Ntf_EVENT_FORUM_REPLY)
{
2017-04-16 23:48:05 +02:00
InsCod = CtrCod = DegCod = CrsCod = -1L;
2017-04-18 01:25:44 +02:00
switch (Gbl.Forum.ForumSelected.Type)
2017-04-16 23:48:05 +02:00
{
case For_FORUM_INSTIT_USRS:
case For_FORUM_INSTIT_TCHS:
2017-04-18 01:25:44 +02:00
InsCod = Gbl.Forum.ForumSelected.Location;
2017-04-16 23:48:05 +02:00
break;
case For_FORUM_CENTRE_USRS:
case For_FORUM_CENTRE_TCHS:
2017-04-18 01:25:44 +02:00
CtrCod = Gbl.Forum.ForumSelected.Location;
2017-04-16 23:48:05 +02:00
break;
case For_FORUM_DEGREE_USRS:
case For_FORUM_DEGREE_TCHS:
2017-04-18 01:25:44 +02:00
DegCod = Gbl.Forum.ForumSelected.Location;
2017-04-16 23:48:05 +02:00
break;
case For_FORUM_COURSE_USRS:
case For_FORUM_COURSE_TCHS:
2017-04-18 01:25:44 +02:00
CrsCod = Gbl.Forum.ForumSelected.Location;
2017-04-16 23:48:05 +02:00
break;
default:
break;
}
2014-12-01 23:55:08 +01:00
}
else
{
2019-04-03 20:57:04 +02:00
InsCod = Gbl.Hierarchy.Ins.InsCod;
CtrCod = Gbl.Hierarchy.Ctr.CtrCod;
DegCod = Gbl.Hierarchy.Deg.DegCod;
2019-04-04 10:45:15 +02:00
CrsCod = Gbl.Hierarchy.Crs.CrsCod;
2014-12-01 23:55:08 +01:00
}
/***** Store notify event *****/
2018-11-02 19:37:11 +01:00
DB_QueryINSERT ("can not create new notification event",
"INSERT INTO notif"
" (NotifyEvent,ToUsrCod,FromUsrCod,"
"InsCod,CtrCod,DegCod,CrsCod,Cod,TimeNotif,Status)"
" VALUES"
" (%u,%ld,%ld,"
"%ld,%ld,%ld,%ld,%ld,NOW(),%u)",
(unsigned) NotifyEvent,
UsrDat->UsrCod,Gbl.Usrs.Me.UsrDat.UsrCod,
InsCod,CtrCod,DegCod,CrsCod,Cod,(unsigned) Status);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
2019-04-01 11:15:38 +02:00
/*************** Reset my number of new notifications to 0 *******************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
static void Ntf_UpdateMyLastAccessToNotifications (void)
{
2019-04-01 11:15:38 +02:00
/***** Reset to 0 my number of new notifications *****/
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not update last access to notifications",
"UPDATE usr_last SET LastAccNotif=NOW()"
" WHERE UsrCod=%ld",
Gbl.Usrs.Me.UsrDat.UsrCod);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
2016-11-16 23:19:52 +01:00
/***************** Send all pending notifications by email *******************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
void Ntf_SendPendingNotifByEMailToAllUsrs (void)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
2019-11-07 14:34:03 +01:00
unsigned long NumRows;
unsigned long NumRow;
2014-12-01 23:55:08 +01:00
struct UsrData UsrDat;
unsigned NumNotif;
unsigned NumTotalNotif = 0;
unsigned NumMails;
unsigned NumTotalMails = 0;
/***** Get users who must be notified from database ******/
2018-11-01 13:03:25 +01:00
// (Status & Ntf_STATUS_BIT_EMAIL) &&
// !(Status & Ntf_STATUS_BIT_SENT) &&
// !(Status & (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED))
if ((NumRows = DB_QuerySELECT (&mysql_res,"can not get users"
" who must be notified",
"SELECT DISTINCT ToUsrCod FROM notif"
2019-02-13 13:32:11 +01:00
" WHERE TimeNotif<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)"
2018-11-01 13:03:25 +01:00
" AND (Status & %u)<>0"
" AND (Status & %u)=0"
" AND (Status & %u)=0",
Cfg_TIME_TO_SEND_PENDING_NOTIF,
(unsigned) Ntf_STATUS_BIT_EMAIL,
(unsigned) Ntf_STATUS_BIT_SENT,
(unsigned) (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED)))) // Events found
2014-12-01 23:55:08 +01:00
{
/***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat);
/***** Notify the users one by one *****/
for (NumRow = 0;
NumRow < NumRows;
NumRow++)
{
/* Get next user */
row = mysql_fetch_row (mysql_res);
/* Get user code */
UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
/* Get user's data */
2019-03-19 13:22:14 +01:00
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS)) // Get user's data from the database
2014-12-01 23:55:08 +01:00
{
/* Send one email to this user */
Ntf_SendPendingNotifByEMailToOneUsr (&UsrDat,&NumNotif,&NumMails);
NumTotalNotif += NumNotif;
NumTotalMails += NumMails;
}
}
/***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat);
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
/***** Delete old notifications ******/
2018-11-02 22:00:31 +01:00
DB_QueryDELETE ("can not remove old notifications",
"DELETE LOW_PRIORITY FROM notif"
2019-02-13 13:32:11 +01:00
" WHERE TimeNotif<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)",
2018-11-02 22:00:31 +01:00
Cfg_TIME_TO_DELETE_OLD_NOTIF);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
2016-11-16 23:19:52 +01:00
/************ Send pending notifications of one user by email ****************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsigned *NumNotif,unsigned *NumMails)
{
2018-12-08 16:43:13 +01:00
extern const char *Txt_NOTIFY_EVENTS_There_is_a_new_event_NO_HTML[1 + Lan_NUM_LANGUAGES];
extern const char *Txt_NOTIFY_EVENTS_There_are_X_new_events_NO_HTML[1 + Lan_NUM_LANGUAGES];
extern const char *Txt_NOTIFY_EVENTS_SINGULAR_NO_HTML[Ntf_NUM_NOTIFY_EVENTS][1 + Lan_NUM_LANGUAGES];
extern const char *Txt_Course_NO_HTML[1 + Lan_NUM_LANGUAGES];
extern const char *Txt_Forum_NO_HTML[1 + Lan_NUM_LANGUAGES];
extern const char *Txt_MSG_From_NO_HTML[1 + Lan_NUM_LANGUAGES];
extern const char *Txt_Go_to_NO_HTML[1 + Lan_NUM_LANGUAGES];
extern const char *Txt_TAB_Messages_NO_HTML[1 + Lan_NUM_LANGUAGES];
extern const char *Txt_Notifications_NO_HTML[1 + Lan_NUM_LANGUAGES];
extern const char *Txt_If_you_no_longer_wish_to_receive_email_notifications_NO_HTML[1 + Lan_NUM_LANGUAGES];
2014-12-01 23:55:08 +01:00
MYSQL_RES *mysql_res;
MYSQL_ROW row;
2015-12-07 23:13:08 +01:00
unsigned long NumRow;
unsigned long NumRows;
2018-12-08 16:43:13 +01:00
Lan_Language_t ToUsrLanguage;
2014-12-01 23:55:08 +01:00
struct UsrData FromUsrDat;
Ntf_NotifyEvent_t NotifyEvent = (Ntf_NotifyEvent_t) 0; // Initialized to avoid warning
2016-10-28 10:03:37 +02:00
struct Instit Ins;
2014-12-01 23:55:08 +01:00
struct Centre Ctr;
struct Degree Deg;
struct Course Crs;
long Cod;
2017-04-18 01:25:44 +02:00
struct Forum ForumSelected;
2017-01-13 10:49:56 +01:00
char ForumName[For_MAX_BYTES_FORUM_NAME + 1];
2018-10-04 21:57:25 +02:00
char Command[2048 +
Cfg_MAX_BYTES_SMTP_PASSWORD +
Cns_MAX_BYTES_EMAIL_ADDRESS +
PATH_MAX]; // Command to execute for sending an email
2014-12-01 23:55:08 +01:00
int ReturnCode;
/***** Return 0 notifications and 0 mails when error *****/
*NumNotif = *NumMails = 0;
2016-10-12 14:02:56 +02:00
if (Mai_CheckIfUsrCanReceiveEmailNotif (ToUsrDat))
2014-12-01 23:55:08 +01:00
{
/***** Get pending notifications of this user from database ******/
2018-11-01 13:03:25 +01:00
NumRows = DB_QuerySELECT (&mysql_res,"can not get pending notifications"
" of a user",
"SELECT NotifyEvent,"
"FromUsrCod,"
"InsCod,"
"CtrCod,"
"DegCod,"
"CrsCod,"
"Cod"
" FROM notif WHERE ToUsrCod=%ld"
" AND (Status & %u)<>0"
" AND (Status & %u)=0"
" AND (Status & %u)=0"
" ORDER BY TimeNotif,NotifyEvent",
ToUsrDat->UsrCod,
(unsigned) Ntf_STATUS_BIT_EMAIL,
(unsigned) Ntf_STATUS_BIT_SENT,
(unsigned) (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED));
2014-12-01 23:55:08 +01:00
if (NumRows) // Events found
{
2015-12-07 23:13:08 +01:00
/***** If user has no language, set it to current language *****/
ToUsrLanguage = ToUsrDat->Prefs.Language;
2018-12-08 16:43:13 +01:00
if (ToUsrLanguage == Lan_LANGUAGE_UNKNOWN)
2015-12-07 23:13:08 +01:00
ToUsrLanguage = Gbl.Prefs.Language;
2014-12-01 23:55:08 +01:00
/***** Create temporary file for mail content *****/
Mai_CreateFileNameMail ();
/***** Welcome note *****/
Mai_WriteWelcomeNoteEMail (ToUsrDat);
if (NumRows == 1)
2015-12-07 23:13:08 +01:00
fprintf (Gbl.Msg.FileMail,Txt_NOTIFY_EVENTS_There_is_a_new_event_NO_HTML[ToUsrLanguage],
2014-12-01 23:55:08 +01:00
Cfg_PLATFORM_SHORT_NAME);
else
2015-12-07 23:13:08 +01:00
fprintf (Gbl.Msg.FileMail,Txt_NOTIFY_EVENTS_There_are_X_new_events_NO_HTML[ToUsrLanguage],
2014-12-01 23:55:08 +01:00
(unsigned) NumRows,Cfg_PLATFORM_SHORT_NAME);
fprintf (Gbl.Msg.FileMail,": \n");
/***** Initialize structure with origin user's data *****/
Usr_UsrDataConstructor (&FromUsrDat);
/***** Inform about the events one by one *****/
for (NumRow = 0;
NumRow < NumRows;
NumRow++)
{
/* Get next event */
row = mysql_fetch_row (mysql_res);
/* Get event type (row[0]) */
NotifyEvent = Ntf_GetNotifyEventFromDB ((const char *) row[0]);
/* Get origin user code (row[1]) */
FromUsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[1]);
2019-03-19 13:22:14 +01:00
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&FromUsrDat,Usr_DONT_GET_PREFS); // Get origin user's data from the database
2014-12-01 23:55:08 +01:00
/* Get institution code (row[2]) */
Ins.InsCod = Str_ConvertStrCodToLongCod (row[2]);
2015-12-09 19:51:17 +01:00
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
2014-12-01 23:55:08 +01:00
/* Get centre code (row[3]) */
Ctr.CtrCod = Str_ConvertStrCodToLongCod (row[3]);
Ctr_GetDataOfCentreByCod (&Ctr);
/* Get degree code (row[4]) */
Deg.DegCod = Str_ConvertStrCodToLongCod (row[4]);
Deg_GetDataOfDegreeByCod (&Deg);
/* Get course code (row[5]) */
Crs.CrsCod = Str_ConvertStrCodToLongCod (row[5]);
Crs_GetDataOfCourseByCod (&Crs);
/* Get message/post/... code (row[6]) */
Cod = Str_ConvertStrCodToLongCod (row[6]);
/* Get forum type */
if (NotifyEvent == Ntf_EVENT_FORUM_POST_COURSE ||
2016-10-12 14:02:56 +02:00
NotifyEvent == Ntf_EVENT_FORUM_REPLY)
2017-04-18 01:25:44 +02:00
For_GetForumTypeAndLocationOfAPost (Cod,&ForumSelected);
2014-12-01 23:55:08 +01:00
/* Information about the type of this event */
2015-12-07 23:13:08 +01:00
fprintf (Gbl.Msg.FileMail,Txt_NOTIFY_EVENTS_SINGULAR_NO_HTML[NotifyEvent][ToUsrLanguage],
2014-12-01 23:55:08 +01:00
Cfg_PLATFORM_SHORT_NAME);
fprintf (Gbl.Msg.FileMail,"\n");
/* Course/forum: */
switch (NotifyEvent)
{
case Ntf_EVENT_UNKNOWN:
2016-01-23 19:11:07 +01:00
case Ntf_EVENT_TIMELINE_COMMENT:
case Ntf_EVENT_TIMELINE_FAV:
case Ntf_EVENT_TIMELINE_SHARE:
case Ntf_EVENT_TIMELINE_MENTION:
case Ntf_EVENT_FOLLOWER:
2014-12-01 23:55:08 +01:00
break;
case Ntf_EVENT_DOCUMENT_FILE:
2016-04-22 09:47:25 +02:00
case Ntf_EVENT_TEACHERS_FILE:
2014-12-01 23:55:08 +01:00
case Ntf_EVENT_SHARED_FILE:
case Ntf_EVENT_ASSIGNMENT:
case Ntf_EVENT_EXAM_ANNOUNCEMENT:
case Ntf_EVENT_MARKS_FILE:
2017-05-21 18:08:35 +02:00
case Ntf_EVENT_ENROLMENT_STD:
2017-06-04 18:18:54 +02:00
case Ntf_EVENT_ENROLMENT_NET:
2017-05-21 18:08:35 +02:00
case Ntf_EVENT_ENROLMENT_TCH:
2017-03-30 11:20:06 +02:00
case Ntf_EVENT_ENROLMENT_REQUEST:
2014-12-01 23:55:08 +01:00
case Ntf_EVENT_NOTICE:
case Ntf_EVENT_MESSAGE:
case Ntf_EVENT_SURVEY:
if (Crs.CrsCod > 0)
fprintf (Gbl.Msg.FileMail,"%s: %s\n",
2015-12-07 23:13:08 +01:00
Txt_Course_NO_HTML[ToUsrLanguage],
2014-12-01 23:55:08 +01:00
Crs.FullName);
break;
case Ntf_EVENT_FORUM_POST_COURSE:
case Ntf_EVENT_FORUM_REPLY:
2017-04-18 01:25:44 +02:00
For_SetForumName (&ForumSelected,
2015-12-07 23:13:08 +01:00
ForumName,ToUsrLanguage,false); // Set forum name in recipient's language
2014-12-01 23:55:08 +01:00
fprintf (Gbl.Msg.FileMail,"%s: %s\n",
2015-12-07 23:13:08 +01:00
Txt_Forum_NO_HTML[ToUsrLanguage],
2014-12-01 23:55:08 +01:00
ForumName);
break;
}
/* From: */
fprintf (Gbl.Msg.FileMail,"%s: %s\n",
2015-12-07 23:13:08 +01:00
Txt_MSG_From_NO_HTML[ToUsrLanguage],
2014-12-01 23:55:08 +01:00
FromUsrDat.FullName);
}
/***** Free memory used for origin user's data *****/
Usr_UsrDataDestructor (&FromUsrDat);
/* Go to: */
fprintf (Gbl.Msg.FileMail,"%s: %s/ > %s > %s\n",
2015-12-07 23:13:08 +01:00
Txt_Go_to_NO_HTML[ToUsrLanguage],
2016-07-08 12:43:48 +02:00
Cfg_URL_SWAD_CGI,
2015-12-07 23:13:08 +01:00
Txt_TAB_Messages_NO_HTML[ToUsrLanguage],
Txt_Notifications_NO_HTML[ToUsrLanguage]);
2014-12-01 23:55:08 +01:00
/* Disclaimer */
fprintf (Gbl.Msg.FileMail,"\n%s\n",
2015-12-07 23:13:08 +01:00
Txt_If_you_no_longer_wish_to_receive_email_notifications_NO_HTML[ToUsrLanguage]);
2014-12-01 23:55:08 +01:00
/* Footer note */
2015-12-07 23:13:08 +01:00
Mai_WriteFootNoteEMail (ToUsrLanguage);
2014-12-01 23:55:08 +01:00
fclose (Gbl.Msg.FileMail);
2016-11-16 23:19:52 +01:00
/***** Call the command to send an email *****/
2018-10-18 02:02:32 +02:00
snprintf (Command,sizeof (Command),
"%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"[%s] %s\" \"%s\"",
Cfg_COMMAND_SEND_AUTOMATIC_EMAIL,
Cfg_AUTOMATIC_EMAIL_SMTP_SERVER,
Cfg_AUTOMATIC_EMAIL_SMTP_PORT,
Cfg_AUTOMATIC_EMAIL_FROM,
Gbl.Config.SMTPPassword,
ToUsrDat->Email,
Cfg_PLATFORM_SHORT_NAME,
Txt_Notifications_NO_HTML[ToUsrLanguage],
Gbl.Msg.FileNameMail);
2014-12-01 23:55:08 +01:00
ReturnCode = system (Command);
if (ReturnCode == -1)
2016-11-16 23:19:52 +01:00
Lay_ShowErrorAndExit ("Error when running script to send email.");
2014-12-01 23:55:08 +01:00
/***** Remove temporary file *****/
unlink (Gbl.Msg.FileNameMail);
/***** Update number of notifications, number of mails and statistics *****/
ReturnCode = WEXITSTATUS(ReturnCode);
if (ReturnCode == 0) // Message sent successfully
{
*NumNotif = (unsigned) NumRows;
*NumMails = 1;
/* Update statistics about notifications */
Ntf_UpdateNumNotifSent (Deg.DegCod,Crs.CrsCod,NotifyEvent,*NumNotif,*NumMails);
}
/***** Mark all the pending notifications of this user as 'sent' *****/
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not set pending notifications of a user as sent",
"UPDATE notif SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld"
" AND (Status & %u)<>0 AND (Status & %u)=0 AND (Status & %u)=0",
(unsigned) Ntf_STATUS_BIT_SENT,ToUsrDat->UsrCod,
(unsigned) Ntf_STATUS_BIT_EMAIL,
(unsigned) Ntf_STATUS_BIT_SENT,
(unsigned) (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED));
2014-12-01 23:55:08 +01:00
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
}
/*****************************************************************************/
/****** Get notify event type from string number coming from database ********/
/*****************************************************************************/
Ntf_NotifyEvent_t Ntf_GetNotifyEventFromDB (const char *Str)
{
unsigned UnsignedNum;
if (sscanf (Str,"%u",&UnsignedNum) == 1)
if (UnsignedNum < Ntf_NUM_NOTIFY_EVENTS)
return (Ntf_NotifyEvent_t) UnsignedNum;
return Ntf_EVENT_UNKNOWN;
}
/*****************************************************************************/
2016-11-16 23:19:52 +01:00
/************* Get number of events notified and emails sent *****************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
static void Ntf_GetNumNotifSent (long DegCod,long CrsCod,
Ntf_NotifyEvent_t NotifyEvent,
unsigned *NumEvents,unsigned *NumMails)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRows;
2016-11-16 23:19:52 +01:00
/***** Get number of notifications sent by email from database *****/
2018-11-01 13:03:25 +01:00
NumRows = DB_QuerySELECT (&mysql_res,"can not get number of notifications"
" sent by email",
"SELECT NumEvents,NumMails FROM sta_notif"
" WHERE DegCod=%ld AND CrsCod=%ld"
" AND NotifyEvent=%u",
DegCod,CrsCod,(unsigned) NotifyEvent);
2014-12-01 23:55:08 +01:00
/***** Get number of rows *****/
if (NumRows)
{
row = mysql_fetch_row (mysql_res);
if (sscanf (row[0],"%u",NumEvents) != 1)
2016-11-16 23:19:52 +01:00
Lay_ShowErrorAndExit ("Error when getting number of notifications sent by email.");
2014-12-01 23:55:08 +01:00
if (sscanf (row[1],"%u",NumMails) != 1)
2016-11-16 23:19:52 +01:00
Lay_ShowErrorAndExit ("Error when getting number of notifications sent by email.");
2014-12-01 23:55:08 +01:00
}
else
*NumEvents = *NumMails = 0;
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
2016-11-16 23:19:52 +01:00
/******************** Update number of notify emails sent ********************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
static void Ntf_UpdateNumNotifSent (long DegCod,long CrsCod,
Ntf_NotifyEvent_t NotifyEvent,
unsigned NumEvents,unsigned NumMails)
{
unsigned CurrentNumEvents;
unsigned CurrentNumMails;
/***** Get number of events notified and number of mails sent *****/
Ntf_GetNumNotifSent (DegCod,CrsCod,NotifyEvent,&CurrentNumEvents,&CurrentNumMails);
/***** Update number of users notified *****/
2018-11-02 16:39:35 +01:00
DB_QueryREPLACE ("can not update the number of sent notifications",
"REPLACE INTO sta_notif"
" (DegCod,CrsCod,NotifyEvent,NumEvents,NumMails)"
" VALUES"
" (%ld,%ld,%u,%u,%u)",
DegCod,CrsCod,(unsigned) NotifyEvent,
CurrentNumEvents + NumEvents,
CurrentNumMails + NumMails);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******************** Mark all my notifications as seen **********************/
/*****************************************************************************/
void Ntf_MarkAllNotifAsSeen (void)
{
/***** Set all my notifications as seen *****/
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not set notification(s) as seen",
"UPDATE notif SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld",
(unsigned) Ntf_STATUS_BIT_READ,
Gbl.Usrs.Me.UsrDat.UsrCod);
2014-12-01 23:55:08 +01:00
/***** Show my notifications again *****/
Ntf_ShowMyNotifications ();
}
/*****************************************************************************/
2016-11-16 23:19:52 +01:00
/*** Activate the sending of email to notify me that I have new messages *****/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
void Ntf_PutFormChangeNotifSentByEMail (void)
{
2019-03-26 11:53:21 +01:00
extern const char *Hlp_PROFILE_Settings_notifications;
2019-02-22 21:47:50 +01:00
extern const char *The_ClassFormInBox[The_NUM_THEMES];
2015-01-01 19:39:46 +01:00
extern const char *Txt_Save_changes;
2014-12-01 23:55:08 +01:00
extern const char *Txt_Notifications;
extern const char *Txt_Create_BR_notification;
2016-11-16 23:19:52 +01:00
extern const char *Txt_Notify_me_BR_by_email;
2014-12-01 23:55:08 +01:00
extern const char *Txt_NOTIFY_EVENTS_PLURAL[Ntf_NUM_NOTIFY_EVENTS];
Ntf_NotifyEvent_t NotifyEvent;
2019-03-26 11:53:21 +01:00
/***** Start section with settings on privacy *****/
2019-10-26 01:56:36 +02:00
HTM_SECTION_Begin (Ntf_NOTIFICATIONS_ID);
2019-03-17 19:37:41 +01:00
2019-10-26 02:19:42 +02:00
/***** Begin box *****/
2019-10-25 22:48:34 +02:00
Box_BoxBegin (NULL,Txt_Notifications,Ntf_PutIconsNotif,
2019-03-26 11:53:21 +01:00
Hlp_PROFILE_Settings_notifications,Box_NOT_CLOSABLE);
2016-11-07 14:12:15 +01:00
2019-10-20 22:00:28 +02:00
/***** Begin form *****/
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActChgNtfPrf);
2015-04-11 23:46:21 +02:00
2016-11-16 23:19:52 +01:00
/***** Warning if I can not receive email notifications *****/
2016-10-12 14:02:56 +02:00
if (!Mai_CheckIfUsrCanReceiveEmailNotif (&Gbl.Usrs.Me.UsrDat))
Mai_WriteWarningEmailNotifications ();
/***** List of notifications *****/
2019-10-23 19:05:05 +02:00
HTM_TABLE_BeginCenterPadding (2);
HTM_TR_Begin (NULL);
2019-10-12 00:07:52 +02:00
2019-10-23 19:05:05 +02:00
HTM_TH_Empty (1);
2019-10-12 00:07:52 +02:00
2019-10-23 19:05:05 +02:00
HTM_TH (1,1,"CM",Txt_Create_BR_notification);
HTM_TH (1,1,"CM",Txt_Notify_me_BR_by_email);
2019-10-12 00:07:52 +02:00
2019-10-23 19:05:05 +02:00
HTM_TR_End ();
2014-12-01 23:55:08 +01:00
2016-12-24 14:33:27 +01:00
/***** Checkbox to activate internal notifications and email notifications
about events *****/
2014-12-01 23:55:08 +01:00
for (NotifyEvent = (Ntf_NotifyEvent_t) 1;
NotifyEvent < Ntf_NUM_NOTIFY_EVENTS;
NotifyEvent++) // O is reserved for Ntf_EVENT_UNKNOWN
{
2019-10-23 19:05:05 +02:00
HTM_TR_Begin (NULL);
2019-10-07 17:36:41 +02:00
2019-10-23 19:05:05 +02:00
HTM_TD_Begin ("class=\"%s RM\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
2019-11-11 10:59:24 +01:00
HTM_TxtF ("%s:",Txt_NOTIFY_EVENTS_PLURAL[NotifyEvent]);
2019-10-23 19:05:05 +02:00
HTM_TD_End ();
2019-10-07 17:36:41 +02:00
2019-10-23 19:05:05 +02:00
HTM_TD_Begin ("class=\"CM\"");
2019-11-04 20:41:35 +01:00
HTM_INPUT_CHECKBOX (Ntf_ParamNotifMeAboutNotifyEvents[NotifyEvent],false,
"value=\"Y\"%s",
(Gbl.Usrs.Me.UsrDat.NtfEvents.CreateNotif &
(1 << NotifyEvent)) ? " checked=\"checked\"" : "");
2019-10-23 19:05:05 +02:00
HTM_TD_End ();
2019-10-07 17:36:41 +02:00
2019-10-23 19:05:05 +02:00
HTM_TD_Begin ("class=\"CM\"");
2019-11-04 20:41:35 +01:00
HTM_INPUT_CHECKBOX (Ntf_ParamEmailMeAboutNotifyEvents[NotifyEvent],false,
"value=\"Y\"%s",
(Gbl.Usrs.Me.UsrDat.NtfEvents.SendEmail &
(1 << NotifyEvent)) ? " checked=\"checked\"" : "");
2019-10-23 19:05:05 +02:00
HTM_TD_End ();
2019-10-07 17:36:41 +02:00
2019-10-23 19:05:05 +02:00
HTM_TR_End ();
2014-12-01 23:55:08 +01:00
}
2019-10-23 19:05:05 +02:00
HTM_TABLE_End ();
2016-10-12 14:02:56 +02:00
2016-11-07 14:12:15 +01:00
/***** Button to save changes *****/
2017-06-11 19:02:40 +02:00
Btn_PutConfirmButton (Txt_Save_changes);
2015-04-11 23:46:21 +02:00
2014-12-01 23:55:08 +01:00
/***** End form *****/
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2016-11-07 14:12:15 +01:00
2017-06-12 14:16:33 +02:00
/***** End box *****/
2019-10-25 22:48:34 +02:00
Box_BoxEnd ();
2019-03-17 19:37:41 +01:00
2019-03-26 11:53:21 +01:00
/***** End section with settings about notifications *****/
2019-10-26 01:56:36 +02:00
HTM_SECTION_End ();
2016-11-07 14:12:15 +01:00
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-11-16 23:19:52 +01:00
/** Get parameter with the sending of email to notify me that I have msgs. ***/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
static void Ntf_GetParamsNotifyEvents (void)
{
Ntf_NotifyEvent_t NotifyEvent;
bool CreateNotifForThisEvent;
2019-03-19 13:22:14 +01:00
Gbl.Usrs.Me.UsrDat.NtfEvents.CreateNotif = 0;
Gbl.Usrs.Me.UsrDat.NtfEvents.SendEmail = 0;
2014-12-01 23:55:08 +01:00
for (NotifyEvent = (Ntf_NotifyEvent_t) 1;
NotifyEvent < Ntf_NUM_NOTIFY_EVENTS;
NotifyEvent++) // 0 is reserved for Ntf_EVENT_UNKNOWN
{
2017-01-28 20:32:50 +01:00
if ((CreateNotifForThisEvent = Par_GetParToBool (Ntf_ParamNotifMeAboutNotifyEvents[NotifyEvent])))
2019-03-19 13:22:14 +01:00
Gbl.Usrs.Me.UsrDat.NtfEvents.CreateNotif |= (1 << NotifyEvent);
2014-12-01 23:55:08 +01:00
if (CreateNotifForThisEvent)
{
2017-01-28 20:32:50 +01:00
Par_GetParToBool (Ntf_ParamEmailMeAboutNotifyEvents[NotifyEvent]);
if (Par_GetParToBool (Ntf_ParamEmailMeAboutNotifyEvents[NotifyEvent]))
2019-03-19 13:22:14 +01:00
Gbl.Usrs.Me.UsrDat.NtfEvents.SendEmail |= (1 << NotifyEvent);
2014-12-01 23:55:08 +01:00
}
}
}
/*****************************************************************************/
2019-03-26 11:53:21 +01:00
/******* Change my setting about sending me notify emails about events *******/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
void Ntf_ChangeNotifyEvents (void)
{
2019-03-26 11:53:21 +01:00
extern const char *Txt_Your_settings_about_notifications_have_changed;
2014-12-01 23:55:08 +01:00
/***** Get param with whether notify me about events *****/
Ntf_GetParamsNotifyEvents ();
2019-03-26 11:53:21 +01:00
/***** Store settings about notify events *****/
DB_QueryUPDATE ("can not update user's settings",
2018-11-03 12:16:40 +01:00
"UPDATE usr_data"
" SET NotifNtfEvents=%u,EmailNtfEvents=%u"
" WHERE UsrCod=%ld",
2019-03-19 13:22:14 +01:00
Gbl.Usrs.Me.UsrDat.NtfEvents.CreateNotif,
Gbl.Usrs.Me.UsrDat.NtfEvents.SendEmail,
2018-11-03 12:16:40 +01:00
Gbl.Usrs.Me.UsrDat.UsrCod);
2014-12-01 23:55:08 +01:00
/***** Show message *****/
2019-03-26 11:53:21 +01:00
Ale_ShowAlert (Ale_SUCCESS,Txt_Your_settings_about_notifications_have_changed);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************************ Write number of notifications **********************/
/*****************************************************************************/
void Ntf_WriteNumberOfNewNtfs (void)
{
extern const char *The_ClassNotif[The_NUM_THEMES];
extern const char *Txt_See_notifications;
extern const char *Txt_notification;
extern const char *Txt_notifications;
2015-07-22 13:32:56 +02:00
extern const char *Txt_Notifications;
2014-12-01 23:55:08 +01:00
extern const char *Txt_NOTIF_new_SINGULAR;
extern const char *Txt_NOTIF_new_PLURAL;
unsigned NumUnseenNtfs;
unsigned NumNewNtfs = 0;
/***** Get my number of unseen notifications *****/
2015-11-27 14:54:46 +01:00
if ((NumUnseenNtfs = Ntf_GetNumberOfAllMyUnseenNtfs ()))
2014-12-01 23:55:08 +01:00
NumNewNtfs = Ntf_GetNumberOfMyNewUnseenNtfs ();
2019-10-20 22:00:28 +02:00
/***** Begin form *****/
2018-11-09 20:47:39 +01:00
Frm_StartFormId (ActSeeNewNtf,"form_ntf");
2019-11-20 10:17:42 +01:00
HTM_BUTTON_SUBMIT_Begin (Txt_See_notifications,The_ClassNotif[Gbl.Prefs.Theme],NULL);
2014-12-01 23:55:08 +01:00
/***** Number of unseen notifications *****/
2019-11-07 10:24:00 +01:00
HTM_SPAN_Begin ("id=\"notif_all\"");
2019-11-11 10:59:24 +01:00
HTM_TxtF ("%u&nbsp;%s",NumUnseenNtfs,NumUnseenNtfs == 1 ? Txt_notification :
Txt_notifications);
2019-11-07 10:24:00 +01:00
HTM_SPAN_End ();
2014-12-01 23:55:08 +01:00
2015-11-27 14:54:46 +01:00
/***** Icon and number of new notifications *****/
2014-12-01 23:55:08 +01:00
if (NumNewNtfs)
2019-10-28 21:24:07 +01:00
{
2019-11-18 09:20:44 +01:00
HTM_BR ();
2019-10-30 00:42:01 +01:00
HTM_IMG (Gbl.Prefs.URLTheme,"bell.svg",Txt_Notifications,
2019-10-30 22:31:03 +01:00
"class=\"ICO16x16\"");
2019-11-11 00:15:44 +01:00
HTM_TxtF ("&nbsp;%u",NumNewNtfs);
2019-11-07 10:24:00 +01:00
HTM_SPAN_Begin ("id=\"notif_new\"");
2019-11-11 10:59:24 +01:00
HTM_TxtF ("&nbsp;%s",NumNewNtfs == 1 ? Txt_NOTIF_new_SINGULAR :
Txt_NOTIF_new_PLURAL);
2019-11-07 10:24:00 +01:00
HTM_SPAN_End ();
2019-10-28 21:24:07 +01:00
}
2014-12-01 23:55:08 +01:00
2015-04-11 17:33:14 +02:00
/***** End form *****/
2019-11-18 09:20:44 +01:00
HTM_BUTTON_End ();
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************* Get the number of (all) my unseen notifications ***************/
/*****************************************************************************/
static unsigned Ntf_GetNumberOfAllMyUnseenNtfs (void)
{
/***** Get number of places with a name from database *****/
2018-11-03 20:52:00 +01:00
return DB_QueryCOUNT ("can not get number of unseen notifications",
"SELECT COUNT(*) FROM notif"
" WHERE ToUsrCod=%ld AND (Status & %u)=0",
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED));
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************** Get the number of my new unseen notifications ****************/
/*****************************************************************************/
static unsigned Ntf_GetNumberOfMyNewUnseenNtfs (void)
{
/***** Get number of places with a name from database *****/
2018-11-03 20:52:00 +01:00
return DB_QueryCOUNT ("can not get number of unseen notifications",
"SELECT COUNT(*) FROM notif"
" WHERE ToUsrCod=%ld AND (Status & %u)=0"
" AND TimeNotif>FROM_UNIXTIME(%ld)",
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED),
Gbl.Usrs.Me.UsrLast.LastAccNotif);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/**************** Remove all notifications made to a user ********************/
/*****************************************************************************/
void Ntf_RemoveUsrNtfs (long ToUsrCod)
{
/***** Delete notifications of a user ******/
2018-11-02 22:00:31 +01:00
DB_QueryDELETE ("can not remove notifications of a user",
"DELETE LOW_PRIORITY FROM notif WHERE ToUsrCod=%ld",
ToUsrCod);
2014-12-01 23:55:08 +01:00
}