Version 20.51.16: Mar 19, 2021 Notifications database table renamed.

This commit is contained in:
acanas 2021-03-19 00:48:18 +01:00
parent 89dacb2549
commit 7d42118a5b
7 changed files with 154 additions and 84 deletions

View File

@ -844,9 +844,9 @@ CREATE TABLE IF NOT EXISTS institutions (
INDEX(CtyCod), INDEX(CtyCod),
INDEX(Status)); INDEX(Status));
-- --
-- Table links: stores the global institutional links shown on right part of page -- Table lnk_links: stores the global institutional links shown on right part of page
-- --
CREATE TABLE IF NOT EXISTS links ( CREATE TABLE IF NOT EXISTS lnk_links (
LnkCod INT NOT NULL AUTO_INCREMENT, LnkCod INT NOT NULL AUTO_INCREMENT,
ShortName VARCHAR(511) NOT NULL, ShortName VARCHAR(511) NOT NULL,
FullName VARCHAR(2047) NOT NULL, FullName VARCHAR(2047) NOT NULL,
@ -1122,9 +1122,9 @@ CREATE TABLE IF NOT EXISTS notices_deleted (
INDEX(UsrCod), INDEX(UsrCod),
INDEX(CreatTime)); INDEX(CreatTime));
-- --
-- Table notif: stores the notifications of events -- Table ntf_notifications: stores the notifications of events
-- --
CREATE TABLE IF NOT EXISTS notif ( CREATE TABLE IF NOT EXISTS ntf_notifications (
NtfCod INT NOT NULL AUTO_INCREMENT, NtfCod INT NOT NULL AUTO_INCREMENT,
NotifyEvent TINYINT NOT NULL, NotifyEvent TINYINT NOT NULL,
ToUsrCod INT NOT NULL, ToUsrCod INT NOT NULL,

View File

@ -3342,8 +3342,9 @@ int swad__getNotifications (struct soap *soap,
"CrsCod," // row[7] "CrsCod," // row[7]
"Cod," // row[8] "Cod," // row[8]
"Status" // row[9] "Status" // row[9]
" FROM notif" " FROM ntf_notifications"
" WHERE ToUsrCod=%ld AND TimeNotif>=FROM_UNIXTIME(%ld)" " WHERE ToUsrCod=%ld"
" AND TimeNotif>=FROM_UNIXTIME(%ld)"
" ORDER BY TimeNotif DESC", " ORDER BY TimeNotif DESC",
Gbl.Usrs.Me.UsrDat.UsrCod,beginTime); Gbl.Usrs.Me.UsrDat.UsrCod,beginTime);
@ -3612,8 +3613,10 @@ int swad__markNotificationsAsRead (struct soap *soap,
{ {
/***** Mark notification as read in the database *****/ /***** Mark notification as read in the database *****/
DB_QueryUPDATE ("can not mark notification as read", DB_QueryUPDATE ("can not mark notification as read",
"UPDATE notif SET Status=(Status | %u)" "UPDATE ntf_notifications"
" WHERE NtfCod=%ld AND ToUsrCod=%ld", " SET Status=(Status | %u)"
" WHERE NtfCod=%ld"
" AND ToUsrCod=%ld",
(unsigned) Ntf_STATUS_BIT_READ, (unsigned) Ntf_STATUS_BIT_READ,
(long) NtfCod,Gbl.Usrs.Me.UsrDat.UsrCod); (long) NtfCod,Gbl.Usrs.Me.UsrDat.UsrCod);
@ -3891,7 +3894,7 @@ static int API_SendMessageToUsr (long OriginalMsgCod,
/***** Create notification for this recipient. /***** Create notification for this recipient.
If this recipient wants to receive notifications by email, activate the sending of a notification *****/ If this recipient wants to receive notifications by email, activate the sending of a notification *****/
DB_QueryINSERT ("can not create new notification event", DB_QueryINSERT ("can not create new notification event",
"INSERT INTO notif" "INSERT INTO ntf_notifications"
" (NotifyEvent,ToUsrCod,FromUsrCod,InsCod,DegCod,CrsCod,Cod,TimeNotif,Status)" " (NotifyEvent,ToUsrCod,FromUsrCod,InsCod,DegCod,CrsCod,Cod,TimeNotif,Status)"
" VALUES" " VALUES"
" (%u,%ld,%ld,-1,-1,-1,%ld,NOW(),%u)", " (%u,%ld,%ld,-1,-1,-1,%ld,NOW(),%u)",

View File

@ -600,13 +600,17 @@ TODO: Salvador Romero Cort
TODO: FIX BUG, URGENT! En las fechas como parámetro Dat_WriteParamsIniEndDates(), por ejemplo al cambiar el color de la gráfica de accesos por día y hora, no se respeta la zona horaria. TODO: FIX BUG, URGENT! En las fechas como parámetro Dat_WriteParamsIniEndDates(), por ejemplo al cambiar el color de la gráfica de accesos por día y hora, no se respeta la zona horaria.
*/ */
#define Log_PLATFORM_VERSION "SWAD 20.51.15 (2021-03-19)" #define Log_PLATFORM_VERSION "SWAD 20.51.16 (2021-03-19)"
#define CSS_FILE "swad20.45.css" #define CSS_FILE "swad20.45.css"
#define JS_FILE "swad20.6.2.js" #define JS_FILE "swad20.6.2.js"
/* /*
TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename CENTRE to CENTER in help wiki.
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
Version 20.51.16: Mar 19, 2021 Notifications database table renamed. (307980 lines)
1 change necessary in database:
RENAME TABLE notif TO ntf_notifications;
Version 20.51.15: Mar 19, 2021 Holidays database table renamed. (307911 lines) Version 20.51.15: Mar 19, 2021 Holidays database table renamed. (307911 lines)
1 change necessary in database: 1 change necessary in database:
RENAME TABLE holidays TO hld_holidays; RENAME TABLE holidays TO hld_holidays;

View File

@ -1828,9 +1828,9 @@ mysql> DESCRIBE ins_instits;
"INDEX(CtyCod)," "INDEX(CtyCod),"
"INDEX(Status))"); "INDEX(Status))");
/***** Table links *****/ /***** Table lnk_links *****/
/* /*
mysql> DESCRIBE links; mysql> DESCRIBE lnk_links;
+-----------+---------------+------+-----+---------+----------------+ +-----------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra | | Field | Type | Null | Key | Default | Extra |
+-----------+---------------+------+-----+---------+----------------+ +-----------+---------------+------+-----+---------+----------------+
@ -1841,7 +1841,7 @@ mysql> DESCRIBE links;
+-----------+---------------+------+-----+---------+----------------+ +-----------+---------------+------+-----+---------+----------------+
4 rows in set (0,00 sec) 4 rows in set (0,00 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS links (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS lnk_links ("
"LnkCod INT NOT NULL AUTO_INCREMENT," "LnkCod INT NOT NULL AUTO_INCREMENT,"
"ShortName VARCHAR(511) NOT NULL," // Lnk_MAX_BYTES_LINK_SHRT_NAME "ShortName VARCHAR(511) NOT NULL," // Lnk_MAX_BYTES_LINK_SHRT_NAME
"FullName VARCHAR(2047) NOT NULL," // Lnk_MAX_BYTES_LINK_FULL_NAME "FullName VARCHAR(2047) NOT NULL," // Lnk_MAX_BYTES_LINK_FULL_NAME
@ -2338,9 +2338,9 @@ mysql> DESCRIBE notices_deleted;
"INDEX(UsrCod)," "INDEX(UsrCod),"
"INDEX(CreatTime))"); "INDEX(CreatTime))");
/***** Table notif *****/ /***** Table ntf_notifications *****/
/* /*
mysql> DESCRIBE notif; mysql> DESCRIBE ntf_notifications;
+-------------+------------+------+-----+---------+----------------+ +-------------+------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra | | Field | Type | Null | Key | Default | Extra |
+-------------+------------+------+-----+---------+----------------+ +-------------+------------+------+-----+---------+----------------+
@ -2359,7 +2359,7 @@ mysql> DESCRIBE notif;
11 rows in set (0.02 sec) 11 rows in set (0.02 sec)
*/ */
// TODO: Change NtfCod and LogCod from INT to BIGINT in database tables. // TODO: Change NtfCod and LogCod from INT to BIGINT in database tables.
DB_CreateTable ("CREATE TABLE IF NOT EXISTS notif (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS ntf_notifications ("
"NtfCod INT NOT NULL AUTO_INCREMENT," "NtfCod INT NOT NULL AUTO_INCREMENT,"
"NotifyEvent TINYINT NOT NULL," "NotifyEvent TINYINT NOT NULL,"
"ToUsrCod INT NOT NULL," "ToUsrCod INT NOT NULL,"

View File

@ -3074,11 +3074,12 @@ static void Enr_RemoveExpiredEnrolmentRequests (void)
/***** Mark possible notifications as removed /***** Mark possible notifications as removed
Important: do this before removing the request *****/ Important: do this before removing the request *****/
DB_QueryUPDATE ("can not set notification(s) as removed", DB_QueryUPDATE ("can not set notification(s) as removed",
"UPDATE notif,crs_usr_requests" "UPDATE ntf_notifications,"
" SET notif.Status=(notif.Status | %u)" "crs_usr_requests"
" WHERE notif.NotifyEvent=%u" " SET ntf_notifications.Status=(ntf_notifications.Status | %u)"
" AND notif.Cod=crs_usr_requests.ReqCod" " WHERE ntf_notifications.NotifyEvent=%u"
" AND crs_usr_requests.RequestTime<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)", " AND ntf_notifications.Cod=crs_usr_requests.ReqCod"
" AND crs_usr_requests.RequestTime<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)",
(unsigned) Ntf_STATUS_BIT_REMOVED, (unsigned) Ntf_STATUS_BIT_REMOVED,
(unsigned) Ntf_EVENT_ENROLMENT_REQUEST, (unsigned) Ntf_EVENT_ENROLMENT_REQUEST,
Cfg_TIME_TO_DELETE_ENROLMENT_REQUESTS); Cfg_TIME_TO_DELETE_ENROLMENT_REQUESTS);

View File

@ -295,8 +295,12 @@ void Lnk_GetListLinks (void)
{ {
/***** Get institutional links from database *****/ /***** Get institutional links from database *****/
NumRows = DB_QuerySELECT (&mysql_res,"can not get institutional links", NumRows = DB_QuerySELECT (&mysql_res,"can not get institutional links",
"SELECT LnkCod,ShortName,FullName,WWW" "SELECT LnkCod," // row[0]
" FROM links ORDER BY ShortName"); "ShortName," // row[1]
"FullName," // row[2]
"WWW" // row[3]
" FROM lnk_links"
" ORDER BY ShortName");
if (NumRows) // Places found... if (NumRows) // Places found...
{ {
@ -354,7 +358,10 @@ void Lnk_GetDataOfLinkByCod (struct Link *Lnk)
/***** Get data of an institutional link from database *****/ /***** Get data of an institutional link from database *****/
NumRows = DB_QuerySELECT (&mysql_res,"can not get data" NumRows = DB_QuerySELECT (&mysql_res,"can not get data"
" of an institutional link", " of an institutional link",
"SELECT ShortName,FullName,WWW FROM links" "SELECT ShortName," // row[0]
"FullName," // row[1]
"WWW" // row[2]
" FROM lnk_links"
" WHERE LnkCod=%ld", " WHERE LnkCod=%ld",
Lnk->LnkCod); Lnk->LnkCod);
@ -501,7 +508,8 @@ void Lnk_RemoveLink (void)
/***** Remove link *****/ /***** Remove link *****/
DB_QueryDELETE ("can not remove an institutional link", DB_QueryDELETE ("can not remove an institutional link",
"DELETE FROM links WHERE LnkCod=%ld", "DELETE FROM lnk_links"
" WHERE LnkCod=%ld",
Lnk_EditingLnk->LnkCod); Lnk_EditingLnk->LnkCod);
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
@ -622,8 +630,10 @@ static bool Lnk_CheckIfLinkNameExists (const char *FieldName,const char *Name,lo
/***** Get number of links with a name from database *****/ /***** Get number of links with a name from database *****/
return (DB_QueryCOUNT ("can not check if the name of an institutional link" return (DB_QueryCOUNT ("can not check if the name of an institutional link"
" already existed", " already existed",
"SELECT COUNT(*) FROM links" "SELECT COUNT(*)"
" WHERE %s='%s' AND LnkCod<>%ld", " FROM lnk_links"
" WHERE %s='%s'"
" AND LnkCod<>%ld",
FieldName,Name,LnkCod) != 0); FieldName,Name,LnkCod) != 0);
} }
@ -635,7 +645,9 @@ static void Lnk_UpdateLnkNameDB (long LnkCod,const char *FieldName,const char *N
{ {
/***** Update institutional link changing old name by new name */ /***** Update institutional link changing old name by new name */
DB_QueryUPDATE ("can not update the name of an institutional link", DB_QueryUPDATE ("can not update the name of an institutional link",
"UPDATE links SET %s='%s' WHERE LnkCod=%ld", "UPDATE lnk_links"
" SET %s='%s'"
" WHERE LnkCod=%ld",
FieldName,NewLnkName,LnkCod); FieldName,NewLnkName,LnkCod);
} }
@ -667,7 +679,9 @@ void Lnk_ChangeLinkWWW (void)
{ {
/***** Update the table changing old WWW by new WWW *****/ /***** Update the table changing old WWW by new WWW *****/
DB_QueryUPDATE ("can not update the web of an institutional link", DB_QueryUPDATE ("can not update the web of an institutional link",
"UPDATE links SET WWW='%s' WHERE LnkCod=%ld", "UPDATE lnk_links"
" SET WWW='%s'"
" WHERE LnkCod=%ld",
NewWWW,Lnk_EditingLnk->LnkCod); NewWWW,Lnk_EditingLnk->LnkCod);
/***** Message to show the change made *****/ /***** Message to show the change made *****/
@ -838,7 +852,7 @@ static void Lnk_CreateLink (struct Link *Lnk)
{ {
/***** Create a new link *****/ /***** Create a new link *****/
DB_QueryINSERT ("can not create institutional link", DB_QueryINSERT ("can not create institutional link",
"INSERT INTO links" "INSERT INTO lnk_links"
" (ShortName,FullName,WWW)" " (ShortName,FullName,WWW)"
" VALUES" " VALUES"
" ('%s','%s','%s')", " ('%s','%s','%s')",

View File

@ -347,13 +347,21 @@ void Ntf_ShowMyNotifications (void)
sprintf (SubQuery," AND (Status&%u)=0", sprintf (SubQuery," AND (Status&%u)=0",
Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_READ |
Ntf_STATUS_BIT_REMOVED); Ntf_STATUS_BIT_REMOVED);
NumNotifications = DB_QuerySELECT (&mysql_res,"can not get your notifications", NumNotifications =
"SELECT NotifyEvent,FromUsrCod,InsCod,CtrCod,DegCod,CrsCod," DB_QuerySELECT (&mysql_res,"can not get your notifications",
"Cod,UNIX_TIMESTAMP(TimeNotif),Status" "SELECT NotifyEvent," // row[0]
" FROM notif" "FromUsrCod," // row[1]
" WHERE ToUsrCod=%ld%s" "InsCod," // row[2]
" ORDER BY TimeNotif DESC", "CtrCod," // row[3]
Gbl.Usrs.Me.UsrDat.UsrCod,SubQuery); "DegCod," // row[4]
"CrsCod," // row[5]
"Cod," // row[6]
"UNIX_TIMESTAMP(TimeNotif)," // row[7]
"Status" // row[8]
" FROM ntf_notifications"
" WHERE ToUsrCod=%ld%s"
" ORDER BY TimeNotif DESC",
Gbl.Usrs.Me.UsrDat.UsrCod,SubQuery);
/***** Contextual menu *****/ /***** Contextual menu *****/
Mnu_ContextMenuBegin (); Mnu_ContextMenuBegin ();
@ -913,24 +921,37 @@ void Ntf_MarkNotifAsSeen (Ntf_NotifyEvent_t NotifyEvent,long Cod,long CrsCod,lon
if (Cod > 0) // Set only one notification if (Cod > 0) // Set only one notification
// for the user as seen // for the user as seen
DB_QueryUPDATE ("can not set notification(s) as seen", DB_QueryUPDATE ("can not set notification(s) as seen",
"UPDATE notif SET Status=(Status | %u)" "UPDATE ntf_notifications"
" WHERE ToUsrCod=%ld AND NotifyEvent=%u AND Cod=%ld", " SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld"
" AND NotifyEvent=%u"
" AND Cod=%ld",
(unsigned) Ntf_STATUS_BIT_READ, (unsigned) Ntf_STATUS_BIT_READ,
ToUsrCod,(unsigned) NotifyEvent,Cod); ToUsrCod,
(unsigned) NotifyEvent,
Cod);
else if (CrsCod > 0) // Set all notifications of this type else if (CrsCod > 0) // Set all notifications of this type
// in the current course for the user as seen // in the current course for the user as seen
DB_QueryUPDATE ("can not set notification(s) as seen", DB_QueryUPDATE ("can not set notification(s) as seen",
"UPDATE notif SET Status=(Status | %u)" "UPDATE ntf_notifications"
" WHERE ToUsrCod=%ld AND NotifyEvent=%u AND CrsCod=%ld", " SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld"
" AND NotifyEvent=%u"
" AND CrsCod=%ld",
(unsigned) Ntf_STATUS_BIT_READ, (unsigned) Ntf_STATUS_BIT_READ,
ToUsrCod,(unsigned) NotifyEvent,Gbl.Hierarchy.Crs.CrsCod); ToUsrCod,
(unsigned) NotifyEvent,
Gbl.Hierarchy.Crs.CrsCod);
else // Set all notifications of this type else // Set all notifications of this type
// for the user as seen // for the user as seen
DB_QueryUPDATE ("can not set notification(s) as seen", DB_QueryUPDATE ("can not set notification(s) as seen",
"UPDATE notif SET Status=(Status | %u)" "UPDATE ntf_notifications"
" WHERE ToUsrCod=%ld AND NotifyEvent=%u", " SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld"
" AND NotifyEvent=%u",
(unsigned) Ntf_STATUS_BIT_READ, (unsigned) Ntf_STATUS_BIT_READ,
ToUsrCod,(unsigned) NotifyEvent); ToUsrCod,
(unsigned) NotifyEvent);
} }
} }
@ -942,8 +963,10 @@ void Ntf_MarkNotifAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod)
{ {
/***** Set notification as removed *****/ /***** Set notification as removed *****/
DB_QueryUPDATE ("can not set notification(s) as removed", DB_QueryUPDATE ("can not set notification(s) as removed",
"UPDATE notif SET Status=(Status | %u)" "UPDATE ntf_notifications"
" WHERE NotifyEvent=%u AND Cod=%ld", " SET Status=(Status | %u)"
" WHERE NotifyEvent=%u"
" AND Cod=%ld",
(unsigned) Ntf_STATUS_BIT_REMOVED, (unsigned) Ntf_STATUS_BIT_REMOVED,
(unsigned) NotifyEvent,Cod); (unsigned) NotifyEvent,Cod);
} }
@ -957,18 +980,26 @@ void Ntf_MarkNotifToOneUsrAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod,long
/***** Set notification as removed *****/ /***** Set notification as removed *****/
if (Cod > 0) // Set only one notification as removed if (Cod > 0) // Set only one notification as removed
DB_QueryUPDATE ("can not set notification(s) as removed", DB_QueryUPDATE ("can not set notification(s) as removed",
"UPDATE notif SET Status=(Status | %u)" "UPDATE ntf_notifications"
" WHERE ToUsrCod=%ld AND NotifyEvent=%u AND Cod=%ld", " SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld"
" AND NotifyEvent=%u"
" AND Cod=%ld",
(unsigned) Ntf_STATUS_BIT_REMOVED, (unsigned) Ntf_STATUS_BIT_REMOVED,
ToUsrCod,(unsigned) NotifyEvent, ToUsrCod,
(unsigned) NotifyEvent,
Cod); Cod);
else // Set all notifications of this type, else // Set all notifications of this type,
// in the current course for the user, as removed // in the current course for the user, as removed
DB_QueryUPDATE ("can not set notification(s) as removed", DB_QueryUPDATE ("can not set notification(s) as removed",
"UPDATE notif SET Status=(Status | %u)" "UPDATE ntf_notifications"
" WHERE ToUsrCod=%ld AND NotifyEvent=%u AND CrsCod=%ld", " SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld"
" AND NotifyEvent=%u"
" AND CrsCod=%ld",
(unsigned) Ntf_STATUS_BIT_REMOVED, (unsigned) Ntf_STATUS_BIT_REMOVED,
ToUsrCod,(unsigned) NotifyEvent, ToUsrCod,
(unsigned) NotifyEvent,
Gbl.Hierarchy.Crs.CrsCod); Gbl.Hierarchy.Crs.CrsCod);
} }
@ -986,20 +1017,24 @@ void Ntf_MarkNotifInCrsAsRemoved (long ToUsrCod,long CrsCod)
except notifications about new messages *****/ except notifications about new messages *****/
if (ToUsrCod > 0) // If the user code is specified if (ToUsrCod > 0) // If the user code is specified
DB_QueryUPDATE ("can not set notification(s) as removed", DB_QueryUPDATE ("can not set notification(s) as removed",
"UPDATE notif SET Status=(Status | %u)" "UPDATE ntf_notifications"
" SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld" " WHERE ToUsrCod=%ld"
" AND CrsCod=%ld" " AND CrsCod=%ld"
" AND NotifyEvent<>%u", // messages will remain available " AND NotifyEvent<>%u", // messages will remain available
(unsigned) Ntf_STATUS_BIT_REMOVED, (unsigned) Ntf_STATUS_BIT_REMOVED,
ToUsrCod, ToUsrCod,
CrsCod,(unsigned) Ntf_EVENT_MESSAGE); CrsCod,
(unsigned) Ntf_EVENT_MESSAGE);
else // User code not specified ==> any user else // User code not specified ==> any user
DB_QueryUPDATE ("can not set notification(s) as removed", DB_QueryUPDATE ("can not set notification(s) as removed",
"UPDATE notif SET Status=(Status | %u)" "UPDATE ntf_notifications"
" SET Status=(Status | %u)"
" WHERE CrsCod=%ld" " WHERE CrsCod=%ld"
" AND NotifyEvent<>%u", // messages will remain available " AND NotifyEvent<>%u", // messages will remain available
(unsigned) Ntf_STATUS_BIT_REMOVED, (unsigned) Ntf_STATUS_BIT_REMOVED,
CrsCod,(unsigned) Ntf_EVENT_MESSAGE); CrsCod,
(unsigned) Ntf_EVENT_MESSAGE);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -1101,7 +1136,7 @@ void Ntf_MarkNotifChildrenOfFolderAsRemoved (const char *Path)
return; return;
} }
DB_QueryUPDATE ("can not set notification(s) as removed", DB_QueryUPDATE ("can not set notification(s) as removed",
"UPDATE notif" "UPDATE ntf_notifications"
" SET Status=(Status | %u)" " SET Status=(Status | %u)"
" WHERE NotifyEvent=%u" " WHERE NotifyEvent=%u"
" AND Cod IN" " AND Cod IN"
@ -1128,7 +1163,7 @@ void Ntf_MarkNotifFilesInGroupAsRemoved (long GrpCod)
{ {
/***** Set notifications as removed *****/ /***** Set notifications as removed *****/
DB_QueryUPDATE ("can not set notification(s) as removed", DB_QueryUPDATE ("can not set notification(s) as removed",
"UPDATE notif" "UPDATE ntf_notifications"
" SET Status=(Status | %u)" " SET Status=(Status | %u)"
" WHERE NotifyEvent IN (%u,%u,%u,%u)" " WHERE NotifyEvent IN (%u,%u,%u,%u)"
" AND Cod IN" " AND Cod IN"
@ -1483,7 +1518,7 @@ void Ntf_StoreNotifyEventToOneUser (Ntf_NotifyEvent_t NotifyEvent,
{ {
/***** Store notify event *****/ /***** Store notify event *****/
DB_QueryINSERT ("can not create new notification event", DB_QueryINSERT ("can not create new notification event",
"INSERT INTO notif" "INSERT INTO ntf_notifications"
" (NotifyEvent,ToUsrCod,FromUsrCod," " (NotifyEvent,ToUsrCod,FromUsrCod,"
"InsCod,CtrCod,DegCod,CrsCod,Cod,TimeNotif,Status)" "InsCod,CtrCod,DegCod,CrsCod,Cod,TimeNotif,Status)"
" VALUES" " VALUES"
@ -1529,11 +1564,12 @@ void Ntf_SendPendingNotifByEMailToAllUsrs (void)
// !(Status & (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED)) // !(Status & (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED))
if ((NumRows = DB_QuerySELECT (&mysql_res,"can not get users" if ((NumRows = DB_QuerySELECT (&mysql_res,"can not get users"
" who must be notified", " who must be notified",
"SELECT DISTINCT ToUsrCod FROM notif" "SELECT DISTINCT ToUsrCod"
" FROM ntf_notifications"
" WHERE TimeNotif<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)" " WHERE TimeNotif<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)"
" AND (Status & %u)<>0" " AND (Status & %u)<>0"
" AND (Status & %u)=0" " AND (Status & %u)=0"
" AND (Status & %u)=0", " AND (Status & %u)=0",
Cfg_TIME_TO_SEND_PENDING_NOTIF, Cfg_TIME_TO_SEND_PENDING_NOTIF,
(unsigned) Ntf_STATUS_BIT_EMAIL, (unsigned) Ntf_STATUS_BIT_EMAIL,
(unsigned) Ntf_STATUS_BIT_SENT, (unsigned) Ntf_STATUS_BIT_SENT,
@ -1572,7 +1608,7 @@ void Ntf_SendPendingNotifByEMailToAllUsrs (void)
/***** Delete old notifications ******/ /***** Delete old notifications ******/
DB_QueryDELETE ("can not remove old notifications", DB_QueryDELETE ("can not remove old notifications",
"DELETE LOW_PRIORITY FROM notif" "DELETE LOW_PRIORITY FROM ntf_notifications"
" WHERE TimeNotif<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)", " WHERE TimeNotif<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)",
Cfg_TIME_TO_DELETE_OLD_NOTIF); Cfg_TIME_TO_DELETE_OLD_NOTIF);
} }
@ -1627,11 +1663,13 @@ static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsign
"DegCod," "DegCod,"
"CrsCod," "CrsCod,"
"Cod" "Cod"
" FROM notif WHERE ToUsrCod=%ld" " FROM ntf_notifications"
" AND (Status & %u)<>0" " WHERE ToUsrCod=%ld"
" AND (Status & %u)=0" " AND (Status & %u)<>0"
" AND (Status & %u)=0" " AND (Status & %u)=0"
" ORDER BY TimeNotif,NotifyEvent", " AND (Status & %u)=0"
" ORDER BY TimeNotif,"
"NotifyEvent",
ToUsrDat->UsrCod, ToUsrDat->UsrCod,
(unsigned) Ntf_STATUS_BIT_EMAIL, (unsigned) Ntf_STATUS_BIT_EMAIL,
(unsigned) Ntf_STATUS_BIT_SENT, (unsigned) Ntf_STATUS_BIT_SENT,
@ -1798,10 +1836,14 @@ static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsign
/***** Mark all the pending notifications of this user as 'sent' *****/ /***** Mark all the pending notifications of this user as 'sent' *****/
DB_QueryUPDATE ("can not set pending notifications of a user as sent", DB_QueryUPDATE ("can not set pending notifications of a user as sent",
"UPDATE notif SET Status=(Status | %u)" "UPDATE ntf_notifications"
" SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld" " WHERE ToUsrCod=%ld"
" AND (Status & %u)<>0 AND (Status & %u)=0 AND (Status & %u)=0", " AND (Status & %u)<>0"
(unsigned) Ntf_STATUS_BIT_SENT,ToUsrDat->UsrCod, " AND (Status & %u)=0"
" AND (Status & %u)=0",
(unsigned) Ntf_STATUS_BIT_SENT,
ToUsrDat->UsrCod,
(unsigned) Ntf_STATUS_BIT_EMAIL, (unsigned) Ntf_STATUS_BIT_EMAIL,
(unsigned) Ntf_STATUS_BIT_SENT, (unsigned) Ntf_STATUS_BIT_SENT,
(unsigned) (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED)); (unsigned) (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED));
@ -1896,7 +1938,8 @@ void Ntf_MarkAllNotifAsSeen (void)
{ {
/***** Set all my notifications as seen *****/ /***** Set all my notifications as seen *****/
DB_QueryUPDATE ("can not set notification(s) as seen", DB_QueryUPDATE ("can not set notification(s) as seen",
"UPDATE notif SET Status=(Status | %u)" "UPDATE ntf_notifications"
" SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld", " WHERE ToUsrCod=%ld",
(unsigned) Ntf_STATUS_BIT_READ, (unsigned) Ntf_STATUS_BIT_READ,
Gbl.Usrs.Me.UsrDat.UsrCod); Gbl.Usrs.Me.UsrDat.UsrCod);
@ -2099,8 +2142,10 @@ static unsigned Ntf_GetNumberOfAllMyUnseenNtfs (void)
{ {
/***** Get number of places with a name from database *****/ /***** Get number of places with a name from database *****/
return DB_QueryCOUNT ("can not get number of unseen notifications", return DB_QueryCOUNT ("can not get number of unseen notifications",
"SELECT COUNT(*) FROM notif" "SELECT COUNT(*)"
" WHERE ToUsrCod=%ld AND (Status & %u)=0", " FROM ntf_notifications"
" WHERE ToUsrCod=%ld"
" AND (Status & %u)=0",
Gbl.Usrs.Me.UsrDat.UsrCod, Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED)); (unsigned) (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED));
} }
@ -2113,9 +2158,11 @@ static unsigned Ntf_GetNumberOfMyNewUnseenNtfs (void)
{ {
/***** Get number of places with a name from database *****/ /***** Get number of places with a name from database *****/
return DB_QueryCOUNT ("can not get number of unseen notifications", return DB_QueryCOUNT ("can not get number of unseen notifications",
"SELECT COUNT(*) FROM notif" "SELECT COUNT(*)"
" WHERE ToUsrCod=%ld AND (Status & %u)=0" " FROM ntf_notifications"
" AND TimeNotif>FROM_UNIXTIME(%ld)", " WHERE ToUsrCod=%ld"
" AND (Status & %u)=0"
" AND TimeNotif>FROM_UNIXTIME(%ld)",
Gbl.Usrs.Me.UsrDat.UsrCod, Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED), (unsigned) (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED),
Gbl.Usrs.Me.UsrLast.LastAccNotif); Gbl.Usrs.Me.UsrLast.LastAccNotif);
@ -2129,6 +2176,7 @@ void Ntf_RemoveUsrNtfs (long ToUsrCod)
{ {
/***** Delete notifications of a user ******/ /***** Delete notifications of a user ******/
DB_QueryDELETE ("can not remove notifications of a user", DB_QueryDELETE ("can not remove notifications of a user",
"DELETE LOW_PRIORITY FROM notif WHERE ToUsrCod=%ld", "DELETE LOW_PRIORITY FROM ntf_notifications"
" WHERE ToUsrCod=%ld",
ToUsrCod); ToUsrCod);
} }