mirror of https://github.com/acanas/swad-core.git
Version 21.21: Sep 30, 2021 New module swad_notice_database for database queries related to notices.
This commit is contained in:
parent
265f284802
commit
940c6f76d0
8
Makefile
8
Makefile
|
@ -67,10 +67,10 @@ OBJS = swad_account.o swad_account_database.o swad_action.o swad_admin.o \
|
|||
swad_match_result.o swad_media.o swad_media_database.o swad_menu.o \
|
||||
swad_message.o swad_message_database.o swad_MFU.o swad_MFU_database.o \
|
||||
swad_network.o swad_network_database.o swad_nickname.o \
|
||||
swad_nickname_database.o swad_notice.o swad_notification.o \
|
||||
swad_notification_database.o swad_pagination.o \
|
||||
swad_parameter.o swad_password.o swad_photo.o swad_place.o \
|
||||
swad_plugin.o swad_privacy.o swad_profile.o swad_program.o \
|
||||
swad_nickname_database.o swad_notice.o swad_notice_database.o \
|
||||
swad_notification.o swad_notification_database.o \
|
||||
swad_pagination.o swad_parameter.o swad_password.o swad_photo.o \
|
||||
swad_place.o swad_plugin.o swad_privacy.o swad_profile.o swad_program.o \
|
||||
swad_project.o \
|
||||
swad_QR.o \
|
||||
swad_record.o swad_report.o swad_role.o swad_room.o swad_RSS.o \
|
||||
|
|
|
@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par
|
|||
|
||||
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
|
||||
*/
|
||||
#define Log_PLATFORM_VERSION "SWAD 21.20.1 (2021-09-30)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 21.21 (2021-09-30)"
|
||||
#define CSS_FILE "swad20.45.css"
|
||||
#define JS_FILE "swad20.69.1.js"
|
||||
/*
|
||||
TODO: Rename CENTRE to CENTER in help wiki.
|
||||
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
||||
|
||||
Version 21.21: Sep 30, 2021 New module swad_notice_database for database queries related to notices. (317901 lines)
|
||||
Version 21.20.1: Sep 30, 2021 Code refactoring related to nicknames. (317756 lines)
|
||||
Version 21.20: Sep 30, 2021 New module swad_nickname_database for database queries related to nicknames. (317751 lines)
|
||||
Version 21.19: Sep 29, 2021 New module swad_network_database for database queries related to webs/social networks. (317644 lines)
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include "swad_logo.h"
|
||||
#include "swad_message.h"
|
||||
#include "swad_notice.h"
|
||||
#include "swad_notice_database.h"
|
||||
#include "swad_project.h"
|
||||
#include "swad_search.h"
|
||||
#include "swad_setting.h"
|
||||
|
|
|
@ -1332,7 +1332,7 @@ static void Msg_MoveRcvMsgToDeleted (long MsgCod,long UsrCod)
|
|||
{
|
||||
/***** Move message from msg_rcv to msg_rcv_deleted *****/
|
||||
/* Insert message into msg_rcv_deleted */
|
||||
Msg_DB_MoveRcvMsgToDeleted (MsgCod,UsrCod);
|
||||
Msg_DB_CopyRcvMsgToDeleted (MsgCod,UsrCod);
|
||||
|
||||
/* Delete message from msg_rcv *****/
|
||||
Msg_DB_RemoveRcvMsg (MsgCod,UsrCod);
|
||||
|
@ -1354,7 +1354,7 @@ static void Msg_MoveSntMsgToDeleted (long MsgCod)
|
|||
{
|
||||
/***** Move message from msg_snt to msg_snt_deleted *****/
|
||||
/* Insert message into msg_snt_deleted */
|
||||
Msg_DB_MoveSntMsgToDeleted (MsgCod);
|
||||
Msg_DB_CopySntMsgToDeleted (MsgCod);
|
||||
|
||||
/* Delete message from msg_snt *****/
|
||||
Msg_DB_RemoveSntMsg (MsgCod);
|
||||
|
|
|
@ -222,7 +222,7 @@ void Msg_DB_SetRcvMsgAsOpen (long MsgCod,long UsrCod)
|
|||
/******************* Insert received message into deleted ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Msg_DB_MoveRcvMsgToDeleted (long MsgCod,long UsrCod)
|
||||
void Msg_DB_CopyRcvMsgToDeleted (long MsgCod,long UsrCod)
|
||||
{
|
||||
DB_QueryINSERT ("can not remove a received message",
|
||||
"INSERT IGNORE INTO msg_rcv_deleted"
|
||||
|
@ -243,7 +243,7 @@ void Msg_DB_MoveRcvMsgToDeleted (long MsgCod,long UsrCod)
|
|||
/******************* Insert received message into deleted ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Msg_DB_MoveSntMsgToDeleted (long MsgCod)
|
||||
void Msg_DB_CopySntMsgToDeleted (long MsgCod)
|
||||
{
|
||||
DB_QueryINSERT ("can not remove a sent message",
|
||||
"INSERT IGNORE INTO msg_snt_deleted"
|
||||
|
|
|
@ -54,8 +54,8 @@ void Msg_DB_ExpandRcvMsg (long MsgCod);
|
|||
void Msg_DB_ContractSntMsg (long MsgCod);
|
||||
void Msg_DB_ContractRcvMsg (long MsgCod);
|
||||
void Msg_DB_SetRcvMsgAsOpen (long MsgCod,long UsrCod);
|
||||
void Msg_DB_MoveRcvMsgToDeleted (long MsgCod,long UsrCod);
|
||||
void Msg_DB_MoveSntMsgToDeleted (long MsgCod);
|
||||
void Msg_DB_CopyRcvMsgToDeleted (long MsgCod,long UsrCod);
|
||||
void Msg_DB_CopySntMsgToDeleted (long MsgCod);
|
||||
|
||||
unsigned Msg_DB_GetDistinctCrssInMyRcvMsgs (MYSQL_RES **mysql_res);
|
||||
unsigned Msg_DB_GetDistinctCrssInMySntMsgs (MYSQL_RES **mysql_res);
|
||||
|
|
|
@ -25,25 +25,13 @@
|
|||
/********************************* Headers ***********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
// #include <string.h> // For string functions
|
||||
|
||||
// #include "swad_account.h"
|
||||
// #include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
// #include "swad_form.h"
|
||||
// #include "swad_global.h"
|
||||
// #include "swad_HTML.h"
|
||||
#include "swad_nickname_database.h"
|
||||
// #include "swad_parameter.h"
|
||||
// #include "swad_QR.h"
|
||||
// #include "swad_user.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** External global variables from others modules ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
// extern struct Globals Gbl;
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Private constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
|
377
swad_notice.c
377
swad_notice.c
|
@ -41,6 +41,7 @@
|
|||
#include "swad_hierarchy_level.h"
|
||||
#include "swad_HTML.h"
|
||||
#include "swad_notice.h"
|
||||
#include "swad_notice_database.h"
|
||||
#include "swad_notification.h"
|
||||
#include "swad_parameter.h"
|
||||
#include "swad_RSS.h"
|
||||
|
@ -86,9 +87,7 @@ static void Not_DrawANotice (Not_Listing_t TypeNoticesListing,
|
|||
const char *Content,
|
||||
long UsrCod,
|
||||
Not_Status_t Status);
|
||||
static long Not_DB_InsertNotice (const char *Content);
|
||||
static void Not_DB_UpdateNumUsrsNotifiedByEMailAboutNotice (long NotCod,
|
||||
unsigned NumUsrsToBeNotifiedByEMail);
|
||||
|
||||
static void Not_PutParams (void *NotCod);
|
||||
static long Not_GetParamNotCod (void);
|
||||
|
||||
|
@ -166,42 +165,6 @@ void Not_ReceiveNotice (void)
|
|||
Gbl.Crs.Notices.HighlightNotCod = NotCod;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Insert a notice in the table of notices *****************/
|
||||
/*****************************************************************************/
|
||||
// Return the code of the new inserted notice
|
||||
|
||||
static long Not_DB_InsertNotice (const char *Content)
|
||||
{
|
||||
/***** Insert notice in the database *****/
|
||||
return
|
||||
DB_QueryINSERTandReturnCode ("can not create notice",
|
||||
"INSERT INTO not_notices"
|
||||
" (CrsCod,UsrCod,CreatTime,Content,Status)"
|
||||
" VALUES"
|
||||
" (%ld,%ld,NOW(),'%s',%u)",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Content,
|
||||
(unsigned) Not_ACTIVE_NOTICE);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Update number of users notified in table of notices *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Not_DB_UpdateNumUsrsNotifiedByEMailAboutNotice (long NotCod,
|
||||
unsigned NumUsrsToBeNotifiedByEMail)
|
||||
{
|
||||
/***** Update number of users notified *****/
|
||||
DB_QueryUPDATE ("can not update the number of notifications of a notice",
|
||||
"UPDATE not_notices"
|
||||
" SET NumNotif=%u"
|
||||
" WHERE NotCod=%ld",
|
||||
NumUsrsToBeNotifiedByEMail,
|
||||
NotCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* List notices after removing one of them *****************/
|
||||
/*****************************************************************************/
|
||||
|
@ -250,14 +213,7 @@ void Not_HideActiveNotice (void)
|
|||
NotCod = Not_GetParamNotCod ();
|
||||
|
||||
/***** Set notice as hidden *****/
|
||||
DB_QueryUPDATE ("can not hide notice",
|
||||
"UPDATE not_notices"
|
||||
" SET Status=%u"
|
||||
" WHERE NotCod=%ld"
|
||||
" AND CrsCod=%ld",
|
||||
(unsigned) Not_OBSOLETE_NOTICE,
|
||||
NotCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
Not_DB_ChangeNoticeStatus (NotCod,Not_OBSOLETE_NOTICE);
|
||||
|
||||
/***** Update RSS of current course *****/
|
||||
RSS_UpdateRSSFileForACrs (&Gbl.Hierarchy.Crs);
|
||||
|
@ -278,14 +234,7 @@ void Not_RevealHiddenNotice (void)
|
|||
NotCod = Not_GetParamNotCod ();
|
||||
|
||||
/***** Set notice as active *****/
|
||||
DB_QueryUPDATE ("can not reveal notice",
|
||||
"UPDATE not_notices"
|
||||
" SET Status=%u"
|
||||
" WHERE NotCod=%ld"
|
||||
" AND CrsCod=%ld",
|
||||
(unsigned) Not_ACTIVE_NOTICE,
|
||||
NotCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
Not_DB_ChangeNoticeStatus (NotCod,Not_ACTIVE_NOTICE);
|
||||
|
||||
/***** Update RSS of current course *****/
|
||||
RSS_UpdateRSSFileForACrs (&Gbl.Hierarchy.Crs);
|
||||
|
@ -337,28 +286,10 @@ void Not_RemoveNotice (void)
|
|||
|
||||
/***** Remove notice *****/
|
||||
/* Copy notice to table of deleted notices */
|
||||
DB_QueryINSERT ("can not remove notice",
|
||||
"INSERT IGNORE INTO not_deleted"
|
||||
" (NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif)"
|
||||
" SELECT NotCod,"
|
||||
"CrsCod,"
|
||||
"UsrCod,"
|
||||
"CreatTime,"
|
||||
"Content,"
|
||||
"NumNotif"
|
||||
" FROM not_notices"
|
||||
" WHERE NotCod=%ld"
|
||||
" AND CrsCod=%ld",
|
||||
NotCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
Not_DB_CopyNoticeToDeleted (NotCod);
|
||||
|
||||
/* Remove notice */
|
||||
DB_QueryDELETE ("can not remove notice",
|
||||
"DELETE FROM not_notices"
|
||||
" WHERE NotCod=%ld"
|
||||
" AND CrsCod=%ld",
|
||||
NotCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
Not_DB_RemoveNotice (NotCod);
|
||||
|
||||
/***** Mark possible notifications as removed *****/
|
||||
Ntf_DB_MarkNotifAsRemoved (Ntf_EVENT_NOTICE,NotCod);
|
||||
|
@ -401,32 +332,10 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,long HighlightNotCod)
|
|||
switch (TypeNoticesListing)
|
||||
{
|
||||
case Not_LIST_BRIEF_NOTICES:
|
||||
NumNotices = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get notices from database",
|
||||
"SELECT NotCod," // row[0]
|
||||
"UNIX_TIMESTAMP(CreatTime) AS F," // row[1]
|
||||
"UsrCod," // row[2]
|
||||
"Content," // row[3]
|
||||
"Status" // row[4]
|
||||
" FROM not_notices"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND Status=%u"
|
||||
" ORDER BY CreatTime DESC",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
(unsigned) Not_ACTIVE_NOTICE);
|
||||
NumNotices = Not_DB_GetActiveNotices (&mysql_res);
|
||||
break;
|
||||
case Not_LIST_FULL_NOTICES:
|
||||
NumNotices = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get notices from database",
|
||||
"SELECT NotCod," // row[0]
|
||||
"UNIX_TIMESTAMP(CreatTime) AS F," // row[1]
|
||||
"UsrCod," // row[2]
|
||||
"Content," // row[3]
|
||||
"Status" // row[4]
|
||||
" FROM not_notices"
|
||||
" WHERE CrsCod=%ld"
|
||||
" ORDER BY CreatTime DESC",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
NumNotices = Not_DB_GetAllNotices (&mysql_res);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -438,8 +347,8 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,long HighlightNotCod)
|
|||
Box_BoxBegin (StrWidth,Txt_Notices,
|
||||
Not_PutIconsListNotices,NULL,
|
||||
Hlp_COMMUNICATION_Notices,Box_NOT_CLOSABLE);
|
||||
if (!NumNotices)
|
||||
Ale_ShowAlert (Ale_INFO,Txt_No_notices);
|
||||
if (!NumNotices)
|
||||
Ale_ShowAlert (Ale_INFO,Txt_No_notices);
|
||||
}
|
||||
|
||||
/***** Show the notices *****/
|
||||
|
@ -501,16 +410,16 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,long HighlightNotCod)
|
|||
|
||||
/* Put a link to the RSS file */
|
||||
HTM_DIV_Begin ("class=\"CM\"");
|
||||
RSS_BuildRSSLink (RSSLink,Gbl.Hierarchy.Crs.CrsCod);
|
||||
HTM_A_Begin ("href=\"%s\" target=\"_blank\"",RSSLink);
|
||||
Ico_PutIcon ("rss-square.svg","RSS","ICO16x16");
|
||||
HTM_A_End ();
|
||||
RSS_BuildRSSLink (RSSLink,Gbl.Hierarchy.Crs.CrsCod);
|
||||
HTM_A_Begin ("href=\"%s\" target=\"_blank\"",RSSLink);
|
||||
Ico_PutIcon ("rss-square.svg","RSS","ICO16x16");
|
||||
HTM_A_End ();
|
||||
HTM_DIV_End ();
|
||||
break;
|
||||
case Not_LIST_FULL_NOTICES:
|
||||
/***** Button to add new notice *****/
|
||||
if (Not_CheckIfICanEditNotices ())
|
||||
Not_PutButtonToAddNewNotice ();
|
||||
/***** Button to add new notice *****/
|
||||
if (Not_CheckIfICanEditNotices ())
|
||||
Not_PutButtonToAddNewNotice ();
|
||||
|
||||
/***** End box *****/
|
||||
Box_BoxEnd ();
|
||||
|
@ -591,16 +500,7 @@ static void Not_GetDataAndShowNotice (long NotCod)
|
|||
Not_Status_t Status;
|
||||
|
||||
/***** Get notice data from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get notice from database",
|
||||
"SELECT UNIX_TIMESTAMP(CreatTime) AS F," // row[0]
|
||||
"UsrCod," // row[1]
|
||||
"Content," // row[2]
|
||||
"Status" // row[3]
|
||||
" FROM not_notices"
|
||||
" WHERE NotCod=%ld"
|
||||
" AND CrsCod=%ld",
|
||||
NotCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod))
|
||||
if (Not_DB_GetDataOfNotice (&mysql_res,NotCod))
|
||||
{
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
|
@ -801,12 +701,8 @@ void Not_GetSummaryAndContentNotice (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
|||
|
||||
SummaryStr[0] = '\0'; // Return nothing on error
|
||||
|
||||
/***** Get subject of message from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get content of notice",
|
||||
"SELECT Content" // row[0]
|
||||
" FROM not_notices"
|
||||
" WHERE NotCod=%ld",
|
||||
NotCod) == 1) // Result should have a unique row
|
||||
/***** Get content of message from database *****/
|
||||
if (Not_DB_ContentNotice (&mysql_res,NotCod) == 1) // Result should have a unique row
|
||||
{
|
||||
/***** Get sumary / content *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -851,104 +747,27 @@ unsigned Not_GetNumNotices (HieLvl_Level_t Scope,Not_Status_t Status,unsigned *N
|
|||
unsigned NumNotices;
|
||||
|
||||
/***** Get number of notices from database *****/
|
||||
switch (Scope)
|
||||
if (Not_DB_GetNumNotices (&mysql_res,Scope,Status) == 1)
|
||||
{
|
||||
case HieLvl_SYS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of notices",
|
||||
"SELECT COUNT(*)," // row[0]
|
||||
"SUM(NumNotif)" // row[1]
|
||||
" FROM not_notices"
|
||||
" WHERE Status=%u",
|
||||
Status);
|
||||
break;
|
||||
case HieLvl_CTY:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of notices",
|
||||
"SELECT COUNT(*)," // row[0]
|
||||
"SUM(not_notices.NumNotif)" // row[1]
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"not_notices"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=not_notices.CrsCod"
|
||||
" AND not_notices.Status=%u",
|
||||
Gbl.Hierarchy.Cty.CtyCod,
|
||||
Status);
|
||||
break;
|
||||
case HieLvl_INS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of notices",
|
||||
"SELECT COUNT(*)," // row[0]
|
||||
"SUM(not_notices.NumNotif)" // row[1]
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"not_notices"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=not_notices.CrsCod"
|
||||
" AND not_notices.Status=%u",
|
||||
Gbl.Hierarchy.Ins.InsCod,
|
||||
Status);
|
||||
break;
|
||||
case HieLvl_CTR:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of notices",
|
||||
"SELECT COUNT(*)," // row[0]
|
||||
"SUM(not_notices.NumNotif)" // row[1]
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"not_notices"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=not_notices.CrsCod"
|
||||
" AND not_notices.Status=%u",
|
||||
Gbl.Hierarchy.Ctr.CtrCod,
|
||||
Status);
|
||||
break;
|
||||
case HieLvl_DEG:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of notices",
|
||||
"SELECT COUNT(*)," // row[0]
|
||||
"SUM(not_notices.NumNotif)" // row[1]
|
||||
" FROM crs_courses,"
|
||||
"not_notices"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.CrsCod=not_notices.CrsCod"
|
||||
" AND not_notices.Status=%u",
|
||||
Gbl.Hierarchy.Deg.DegCod,
|
||||
Status);
|
||||
break;
|
||||
case HieLvl_CRS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of notices",
|
||||
"SELECT COUNT(*)," // row[0]
|
||||
"SUM(NumNotif)" // row[1]
|
||||
" FROM not_notices"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND Status=%u",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
Status);
|
||||
break;
|
||||
default:
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
/***** Get number of notices *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
if (sscanf (row[0],"%u",&NumNotices) != 1)
|
||||
Err_ShowErrorAndExit ("Error when getting number of notices.");
|
||||
|
||||
/***** Get number of notices *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
if (sscanf (row[0],"%u",&NumNotices) != 1)
|
||||
Err_ShowErrorAndExit ("Error when getting number of notices.");
|
||||
|
||||
/***** Get number of notifications by email *****/
|
||||
if (row[1])
|
||||
{
|
||||
if (sscanf (row[1],"%u",NumNotif) != 1)
|
||||
Err_ShowErrorAndExit ("Error when getting number of notifications of notices.");
|
||||
/***** Get number of notifications by email *****/
|
||||
if (row[1])
|
||||
{
|
||||
if (sscanf (row[1],"%u",NumNotif) != 1)
|
||||
Err_ShowErrorAndExit ("Error when getting number of notifications of notices.");
|
||||
}
|
||||
else
|
||||
*NumNotif = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
NumNotices = 0;
|
||||
*NumNotif = 0;
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
@ -969,92 +788,27 @@ unsigned Not_GetNumNoticesDeleted (HieLvl_Level_t Scope,unsigned *NumNotif)
|
|||
unsigned NumNotices;
|
||||
|
||||
/***** Get number of notices from database *****/
|
||||
switch (Scope)
|
||||
if (Not_DB_GetNumNoticesDeleted (&mysql_res,Scope) == 1)
|
||||
{
|
||||
case HieLvl_SYS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of deleted notices",
|
||||
"SELECT COUNT(*)," // row[0]
|
||||
"SUM(NumNotif)" // row[1]
|
||||
" FROM not_deleted");
|
||||
break;
|
||||
case HieLvl_CTY:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of deleted notices",
|
||||
"SELECT COUNT(*)," // row[0]
|
||||
"SUM(not_deleted.NumNotif)" // row[1]
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"not_deleted"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=not_deleted.CrsCod",
|
||||
Gbl.Hierarchy.Cty.CtyCod);
|
||||
break;
|
||||
case HieLvl_INS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of deleted notices",
|
||||
"SELECT COUNT(*)," // row[0]
|
||||
"SUM(not_deleted.NumNotif)" // row[1]
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"not_deleted"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=not_deleted.CrsCod",
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
break;
|
||||
case HieLvl_CTR:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of deleted notices",
|
||||
"SELECT COUNT(*)," // row[0]
|
||||
"SUM(not_deleted.NumNotif)" // row[1]
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"not_deleted"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=not_deleted.CrsCod",
|
||||
Gbl.Hierarchy.Ctr.CtrCod);
|
||||
break;
|
||||
case HieLvl_DEG:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of deleted notices",
|
||||
"SELECT COUNT(*)," // row[0]
|
||||
"SUM(not_deleted.NumNotif)" // row[1]
|
||||
" FROM crs_courses,"
|
||||
"not_deleted"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.CrsCod=not_deleted.CrsCod",
|
||||
Gbl.Hierarchy.Deg.DegCod);
|
||||
break;
|
||||
case HieLvl_CRS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of deleted notices",
|
||||
"SELECT COUNT(*)," // row[0]
|
||||
"SUM(NumNotif)" // row[1]
|
||||
" FROM not_deleted"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
/***** Get number of notices *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
if (sscanf (row[0],"%u",&NumNotices) != 1)
|
||||
Err_ShowErrorAndExit ("Error when getting number of deleted notices.");
|
||||
|
||||
/***** Get number of notices *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
if (sscanf (row[0],"%u",&NumNotices) != 1)
|
||||
Err_ShowErrorAndExit ("Error when getting number of deleted notices.");
|
||||
|
||||
/***** Get number of notifications by email *****/
|
||||
if (row[1])
|
||||
{
|
||||
if (sscanf (row[1],"%u",NumNotif) != 1)
|
||||
Err_ShowErrorAndExit ("Error when getting number of notifications of deleted notices.");
|
||||
/***** Get number of notifications by email *****/
|
||||
if (row[1])
|
||||
{
|
||||
if (sscanf (row[1],"%u",NumNotif) != 1)
|
||||
Err_ShowErrorAndExit ("Error when getting number of notifications of deleted notices.");
|
||||
}
|
||||
else
|
||||
*NumNotif = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
NumNotices = 0;
|
||||
*NumNotif = 0;
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
@ -1090,30 +844,3 @@ static long Not_GetParamNotCod (void)
|
|||
/***** Get notice code *****/
|
||||
return Par_GetParToLong ("NotCod");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************* Remove notices in a course ************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Not_DB_RemoveCrsNotices (long CrsCod)
|
||||
{
|
||||
/***** Copy all notices from the course to table of deleted notices *****/
|
||||
DB_QueryINSERT ("can not remove notices in a course",
|
||||
"INSERT INTO not_deleted"
|
||||
" (NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif)"
|
||||
" SELECT NotCod,"
|
||||
"CrsCod,"
|
||||
"UsrCod,"
|
||||
"CreatTime,"
|
||||
"Content,"
|
||||
"NumNotif"
|
||||
" FROM not_notices"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
|
||||
/***** Remove all notices from the course *****/
|
||||
DB_QueryDELETE ("can not remove notices in a course",
|
||||
"DELETE FROM not_notices"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
|
|
@ -77,6 +77,4 @@ unsigned Not_GetNumNoticesDeleted (HieLvl_Level_t Scope,unsigned *NumNotif);
|
|||
|
||||
void Not_PutHiddenParamNotCod (long NotCod);
|
||||
|
||||
void Not_DB_RemoveCrsNotices (long CrsCod);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue