swad-core/swad_notification.h

142 lines
5.9 KiB
C
Raw Normal View History

2016-11-16 23:19:52 +01:00
// swad_notification.h: notifications about events, sent by email
2014-12-01 23:55:08 +01:00
#ifndef _SWAD_NTF
#define _SWAD_NTF
/*
SWAD (Shared Workspace At a Distance in Spanish),
is a web platform developed at the University of Granada (Spain),
and used to support university teaching.
This file is part of SWAD core.
Copyright (C) 1999-2023 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 "swad_user.h"
/*****************************************************************************/
/****************************** Public constants *****************************/
/*****************************************************************************/
2017-03-08 14:12:33 +01:00
#define Ntf_MAX_BYTES_NOTIFY_EVENT (32 - 1) // 31
2017-01-15 18:02:52 +01:00
2017-03-08 14:12:33 +01:00
#define Ntf_MAX_CHARS_NOTIFY_LOCATION (128 - 1) // 127
#define Ntf_MAX_BYTES_NOTIFY_LOCATION (2048 + (Ntf_MAX_CHARS_NOTIFY_LOCATION + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 4095
#define Ntf_MAX_CHARS_SUMMARY (256 - 1) // 255
#define Ntf_MAX_BYTES_SUMMARY ((Ntf_MAX_CHARS_SUMMARY + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 4095
2017-01-15 18:02:52 +01:00
2019-03-17 19:37:41 +01:00
#define Ntf_NOTIFICATIONS_ID "notif"
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/******************************** Public types *******************************/
/*****************************************************************************/
2017-05-21 18:08:35 +02:00
#define Ntf_NUM_NOTIFY_EVENTS (1 + 20)
2014-12-01 23:55:08 +01:00
// If the numbers assigned to each event type change,
2016-04-22 09:47:25 +02:00
// it is necessary to change old numbers to new ones
// in database tables ntf_notifications, sta_notifications and usr_data
// TODO: Change numbers (also in database)!!!!!!!!!!!!!!
typedef enum
2014-12-01 23:55:08 +01:00
{
2016-01-23 19:11:07 +01:00
Ntf_EVENT_UNKNOWN = 0,
2019-11-20 01:47:22 +01:00
/* Start tab */
Ntf_EVENT_TML_COMMENT = 10, // New comment to one of my social publishings (notes or comments)
Ntf_EVENT_TML_FAV = 11, // New fav of one of my social publishings (notes or comments)
Ntf_EVENT_TML_SHARE = 12, // New sharing of one of my social notes
Ntf_EVENT_TML_MENTION = 13, // New mention
2019-11-20 01:47:22 +01:00
Ntf_EVENT_FOLLOWER = 14,
/* System tab */
/* Country tab */
/* Institution tab */
/* Center tab */
2019-11-20 01:47:22 +01:00
/* Degree tab */
2014-12-01 23:55:08 +01:00
/* Course tab */
/* Assessment tab */
2017-03-30 11:20:06 +02:00
Ntf_EVENT_ASSIGNMENT = 4,
Ntf_EVENT_CALL_FOR_EXAM = 5,
2017-04-27 10:15:07 +02:00
/* Files tab */
2017-05-21 18:08:35 +02:00
Ntf_EVENT_DOCUMENT_FILE = 1,
Ntf_EVENT_TEACHERS_FILE = 2,
Ntf_EVENT_SHARED_FILE = 3,
Ntf_EVENT_MARKS_FILE = 6,
2015-12-29 10:38:46 +01:00
/* Users tab */
2017-05-21 18:08:35 +02:00
Ntf_EVENT_ENROLMENT_STD = 7,
2017-06-04 18:18:54 +02:00
Ntf_EVENT_ENROLMENT_NET = 20,
2017-05-21 18:08:35 +02:00
Ntf_EVENT_ENROLMENT_TCH = 8,
2017-03-30 11:20:06 +02:00
Ntf_EVENT_ENROLMENT_REQUEST = 9,
2014-12-01 23:55:08 +01:00
/* Messages tab */
2017-03-30 11:20:06 +02:00
Ntf_EVENT_NOTICE = 17,
2019-11-20 01:47:22 +01:00
Ntf_EVENT_FORUM_POST_COURSE = 15, // New post in forums of my courses
Ntf_EVENT_FORUM_REPLY = 16, // New reply to one of my posts in any forum
2017-03-30 11:20:06 +02:00
Ntf_EVENT_MESSAGE = 18,
2019-11-20 01:47:22 +01:00
/* Analytics tab */
Ntf_EVENT_SURVEY = 19,
2015-12-30 20:11:50 +01:00
/* Profile tab */
2014-12-01 23:55:08 +01:00
} Ntf_NotifyEvent_t;
typedef enum
{
Ntf_STATUS_BIT_EMAIL = (1 << 0), // User want to receive notification by email
Ntf_STATUS_BIT_SENT = (1 << 1), // Email has been sent
Ntf_STATUS_BIT_READ = (1 << 2), // User has seen the event which caused the notification
Ntf_STATUS_BIT_REMOVED = (1 << 3), // The event which caused the notification has been removed
} Ntf_Status_Bits_t;
typedef unsigned Ntf_Status_t;
#define Ntf_NUM_STATUS_TXT 4
typedef enum
{
Ntf_STATUS_NO_EMAIL = 0, // ---0 !(Status & Ntf_STATUS_BIT_EMAIL)
Ntf_STATUS_EMAIL_PENDING = 1, // 0001 (Status & Ntf_STATUS_BIT_EMAIL) && !(Status & Ntf_STATUS_BIT_SENT) && !(Status & (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED))
Ntf_STATUS_EMAIL_CANCELLED = 2, // XX01 (Status & Ntf_STATUS_BIT_EMAIL) && !(Status & Ntf_STATUS_BIT_SENT) && (Status & (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED))
Ntf_STATUS_EMAIL_SENT = 3, // --11 (Status & Ntf_STATUS_BIT_EMAIL) && (Status & Ntf_STATUS_BIT_SENT)
} Ntf_StatusTxt_t;
/*****************************************************************************/
/****************************** Public prototypes ****************************/
/*****************************************************************************/
void Ntf_ShowMyNotifications (void);
2016-01-25 14:40:57 +01:00
Ntf_NotifyEvent_t Ntf_GetParNotifyEvent (void);
2016-01-25 14:40:57 +01:00
2014-12-01 23:55:08 +01:00
Ntf_StatusTxt_t Ntf_GetStatusTxtFromStatusBits (Ntf_Status_t Status);
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);
2016-01-04 01:56:28 +01:00
void Ntf_MarkNotifOneFileAsRemoved (const char *Path);
void Ntf_MarkNotifChildrenOfFolderAsRemoved (const char *Path);
2014-12-01 23:55:08 +01:00
unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod);
void Ntf_SendPendingNotifByEMailToAllUsrs (void);
2019-12-17 00:36:22 +01:00
Ntf_NotifyEvent_t Ntf_GetNotifyEventFromStr (const char *Str);
2014-12-01 23:55:08 +01:00
void Ntf_MarkAllNotifAsSeen (void);
void Ntf_PutFormChangeNotifSentByEMail (void);
void Ntf_ChangeNotifyEvents (void);
void Ntf_WriteNumberOfNewNtfs (void);
//-------------------------------- Figures ------------------------------------
void Ntf_GetAndShowNumUsrsPerNotifyEvent (void);
2014-12-01 23:55:08 +01:00
#endif