mirror of https://github.com/acanas/swad-core.git
Version 21.21.2: Oct 01, 2021 Queries moved to module swad_notification_database.
This commit is contained in:
parent
0b87fdd951
commit
73e5e67df0
|
@ -3354,7 +3354,7 @@ int swad__getNotifications (struct soap *soap,
|
|||
|
||||
/* Get institution (row[4]) */
|
||||
Hie.Ins.InsCod = Str_ConvertStrCodToLongCod (row[4]);
|
||||
Ins_GetDataOfInstitutionByCod (&Hie.Ins);
|
||||
Ins_GetDataOfInstitByCod (&Hie.Ins);
|
||||
|
||||
/* Get center (row[5]) */
|
||||
Hie.Ctr.CtrCod = Str_ConvertStrCodToLongCod (row[5]);
|
||||
|
|
|
@ -5782,7 +5782,7 @@ static void Brw_WriteCurrentClipboard (void)
|
|||
{
|
||||
case Brw_ADMI_DOC_INS:
|
||||
Hie.Ins.InsCod = Gbl.FileBrowser.Clipboard.Cod;
|
||||
Ins_GetDataOfInstitutionByCod (&Hie.Ins);
|
||||
Ins_GetDataOfInstitByCod (&Hie.Ins);
|
||||
snprintf (TxtClipboardZone,sizeof (TxtClipboardZone),
|
||||
"%s, %s <strong>%s</strong>",
|
||||
Txt_documents_management_area,
|
||||
|
@ -5790,7 +5790,7 @@ static void Brw_WriteCurrentClipboard (void)
|
|||
break;
|
||||
case Brw_ADMI_SHR_INS:
|
||||
Hie.Ins.InsCod = Gbl.FileBrowser.Clipboard.Cod;
|
||||
Ins_GetDataOfInstitutionByCod (&Hie.Ins);
|
||||
Ins_GetDataOfInstitByCod (&Hie.Ins);
|
||||
snprintf (TxtClipboardZone,sizeof (TxtClipboardZone),
|
||||
"%s, %s <strong>%s</strong>",
|
||||
Txt_shared_files_area,
|
||||
|
@ -6338,7 +6338,7 @@ static void Brw_PasteClipboard (void)
|
|||
case Brw_ADMI_DOC_INS:
|
||||
case Brw_ADMI_SHR_INS:
|
||||
Hie.Ins.InsCod = Gbl.FileBrowser.Clipboard.Cod;
|
||||
if (Ins_GetDataOfInstitutionByCod (&Hie.Ins))
|
||||
if (Ins_GetDataOfInstitByCod (&Hie.Ins))
|
||||
snprintf (PathOrg,sizeof (PathOrg),"%s/%02u/%u/%s",
|
||||
Cfg_PATH_INS_PRIVATE,
|
||||
(unsigned) (Hie.Ins.InsCod % 100),
|
||||
|
|
|
@ -947,7 +947,7 @@ static void Cfe_ShowCallForExam (struct Cfe_CallsForExams *CallsForExams,
|
|||
|
||||
/***** Get data of institution of this degree *****/
|
||||
Ins.InsCod = Gbl.Hierarchy.Ins.InsCod;
|
||||
Ins_GetDataOfInstitutionByCod (&Ins);
|
||||
Ins_GetDataOfInstitByCod (&Ins);
|
||||
|
||||
/***** Build anchor string *****/
|
||||
Frm_SetAnchorStr (ExaCod,&Anchor);
|
||||
|
@ -1613,7 +1613,7 @@ static void Cfe_GetNotifContentCallForExam (const struct Cfe_CallsForExams *Call
|
|||
|
||||
/***** Get data of institution *****/
|
||||
Hie.Ins.InsCod = Deg_DB_GetInsCodOfDegreeByCod (Hie.Deg.DegCod);
|
||||
Ins_GetDataOfInstitutionByCod (&Hie.Ins);
|
||||
Ins_GetDataOfInstitByCod (&Hie.Ins);
|
||||
|
||||
/***** Convert struct date to a date string *****/
|
||||
Dat_ConvDateToDateStr (&CallsForExams->CallForExam.ExamDate,StrExamDate);
|
||||
|
|
|
@ -1023,7 +1023,7 @@ void CtrCfg_ChangeCtrIns (void)
|
|||
if (NewIns.InsCod != Gbl.Hierarchy.Ctr.InsCod)
|
||||
{
|
||||
/***** Get data of new institution *****/
|
||||
Ins_GetDataOfInstitutionByCod (&NewIns);
|
||||
Ins_GetDataOfInstitByCod (&NewIns);
|
||||
|
||||
/***** Check if it already exists a center with the same name in the new institution *****/
|
||||
if (Ctr_DB_CheckIfCtrNameExistsInIns ("ShortName",
|
||||
|
|
|
@ -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.21.1 (2021-10-01)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 21.21.2 (2021-10-01)"
|
||||
#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.2: Oct 01, 2021 Queries moved to module swad_notification_database. (317963 lines)
|
||||
Version 21.21.1: Oct 01, 2021 Queries moved to module swad_notification_database. (317938 lines)
|
||||
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)
|
||||
|
|
|
@ -300,7 +300,7 @@ static void CtyCfg_Map (void)
|
|||
|
||||
/* Get data of institution */
|
||||
Ins.InsCod = Ctr.InsCod;
|
||||
Ins_GetDataOfInstitutionByCod (&Ins);
|
||||
Ins_GetDataOfInstitByCod (&Ins);
|
||||
|
||||
/* Add marker */
|
||||
Map_AddMarker (&Ctr.Coord);
|
||||
|
|
|
@ -254,7 +254,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
|
|||
|
||||
/***** Get data of this institution *****/
|
||||
Hie.Ins.InsCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||
if (!Ins_GetDataOfInstitutionByCod (&Hie.Ins))
|
||||
if (!Ins_GetDataOfInstitByCod (&Hie.Ins))
|
||||
Err_WrongInstitExit ();
|
||||
|
||||
/***** Write link to institution *****/
|
||||
|
|
|
@ -465,7 +465,7 @@ static void Dpt_ListDepartmentsForEdition (const struct Dpt_Departments *Departm
|
|||
|
||||
/* Get data of institution of this department */
|
||||
Ins.InsCod = Dpt->InsCod;
|
||||
Ins_GetDataOfInstitutionByCod (&Ins);
|
||||
Ins_GetDataOfInstitByCod (&Ins);
|
||||
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
|
|
|
@ -1270,7 +1270,7 @@ static unsigned Fig_GetInsAndStat (struct Ins_Instit *Ins,MYSQL_RES *mysql_res)
|
|||
|
||||
/***** Get data of this institution (row[0]) *****/
|
||||
Ins->InsCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||
if (!Ins_GetDataOfInstitutionByCod (Ins))
|
||||
if (!Ins_GetDataOfInstitByCod (Ins))
|
||||
Err_WrongInstitExit ();
|
||||
|
||||
/***** Get statistic (row[1]) *****/
|
||||
|
|
|
@ -1811,13 +1811,13 @@ void For_SetForumName (const struct For_Forum *Forum,
|
|||
break;
|
||||
case For_FORUM_INSTIT_USRS:
|
||||
Hie.Ins.InsCod = Forum->Location;
|
||||
if (!Ins_GetDataOfInstitutionByCod (&Hie.Ins))
|
||||
if (!Ins_GetDataOfInstitByCod (&Hie.Ins))
|
||||
Err_WrongInstitExit ();
|
||||
Str_Copy (ForumName,Hie.Ins.ShrtName,For_MAX_BYTES_FORUM_NAME);
|
||||
break;
|
||||
case For_FORUM_INSTIT_TCHS:
|
||||
Hie.Ins.InsCod = Forum->Location;
|
||||
if (!Ins_GetDataOfInstitutionByCod (&Hie.Ins))
|
||||
if (!Ins_GetDataOfInstitByCod (&Hie.Ins))
|
||||
Err_WrongInstitExit ();
|
||||
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s",
|
||||
Hie.Ins.ShrtName,
|
||||
|
|
|
@ -557,7 +557,7 @@ void Hie_InitHierarchy (void)
|
|||
/***** If institution code is available, get institution data *****/
|
||||
if (Gbl.Hierarchy.Ins.InsCod > 0)
|
||||
{
|
||||
if (Ins_GetDataOfInstitutionByCod (&Gbl.Hierarchy.Ins)) // Institution found
|
||||
if (Ins_GetDataOfInstitByCod (&Gbl.Hierarchy.Ins)) // Institution found
|
||||
Gbl.Hierarchy.Cty.CtyCod = Gbl.Hierarchy.Ins.CtyCod;
|
||||
else
|
||||
Hie_ResetHierarchy ();
|
||||
|
@ -701,7 +701,7 @@ void Hie_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan)
|
|||
if (Hie.Ins.InsCod > 0)
|
||||
{
|
||||
/* Get data of institution */
|
||||
Ins_GetDataOfInstitutionByCod (&Hie.Ins);
|
||||
Ins_GetDataOfInstitByCod (&Hie.Ins);
|
||||
|
||||
/* Write institution logo and name */
|
||||
Ins_DrawInstitutionLogoAndNameWithLink (&Hie.Ins,ActSeeInsInf,
|
||||
|
|
|
@ -174,7 +174,7 @@ void Ins_SeeInsWithPendingCtrs (void)
|
|||
Gbl.ColorRows[Gbl.RowEvenOdd];
|
||||
|
||||
/* Get data of institution */
|
||||
Ins_GetDataOfInstitutionByCod (&Ins);
|
||||
Ins_GetDataOfInstitByCod (&Ins);
|
||||
|
||||
/* Institution logo and name */
|
||||
HTM_TR_Begin (NULL);
|
||||
|
@ -709,7 +709,7 @@ void Ins_WriteInstitutionNameAndCty (long InsCod)
|
|||
/************************* Get data of an institution ************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
bool Ins_GetDataOfInstitutionByCod (struct Ins_Instit *Ins)
|
||||
bool Ins_GetDataOfInstitByCod (struct Ins_Instit *Ins)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
|
@ -1220,7 +1220,7 @@ void Ins_RemoveInstitution (void)
|
|||
Ins_EditingIns->InsCod = Ins_GetAndCheckParamOtherInsCod (1);
|
||||
|
||||
/***** Get data of the institution from database *****/
|
||||
Ins_GetDataOfInstitutionByCod (Ins_EditingIns);
|
||||
Ins_GetDataOfInstitByCod (Ins_EditingIns);
|
||||
|
||||
/***** Check if this institution has users *****/
|
||||
if (!Ins_CheckIfICanEdit (Ins_EditingIns))
|
||||
|
@ -1340,7 +1340,7 @@ void Ins_RenameInstitution (struct Ins_Instit *Ins,Cns_ShrtOrFullName_t ShrtOrFu
|
|||
Par_GetParToText (ParamName,NewInsName,MaxBytes);
|
||||
|
||||
/***** Get from the database the old names of the institution *****/
|
||||
Ins_GetDataOfInstitutionByCod (Ins);
|
||||
Ins_GetDataOfInstitByCod (Ins);
|
||||
|
||||
/***** Check if new name is empty *****/
|
||||
if (NewInsName[0])
|
||||
|
@ -1411,7 +1411,7 @@ void Ins_ChangeInsWWW (void)
|
|||
Par_GetParToText ("WWW",NewWWW,Cns_MAX_BYTES_WWW);
|
||||
|
||||
/***** Get data of institution *****/
|
||||
Ins_GetDataOfInstitutionByCod (Ins_EditingIns);
|
||||
Ins_GetDataOfInstitByCod (Ins_EditingIns);
|
||||
|
||||
/***** Check if new WWW is empty *****/
|
||||
if (NewWWW[0])
|
||||
|
@ -1459,7 +1459,7 @@ void Ins_ChangeInsStatus (void)
|
|||
Status = Ins_GetStatusBitsFromStatusTxt (StatusTxt); // New status
|
||||
|
||||
/***** Get data of institution *****/
|
||||
Ins_GetDataOfInstitutionByCod (Ins_EditingIns);
|
||||
Ins_GetDataOfInstitByCod (Ins_EditingIns);
|
||||
|
||||
/***** Update status in table of institutions *****/
|
||||
Ins_DB_UpdateInsStatus (Status,Ins_EditingIns->InsCod);
|
||||
|
@ -1918,7 +1918,7 @@ void Ins_ListInssFound (MYSQL_RES **mysql_res,unsigned NumInss)
|
|||
Ins.InsCod = DB_GetNextCode (*mysql_res);
|
||||
|
||||
/* Get data of institution */
|
||||
Ins_GetDataOfInstitutionByCod (&Ins);
|
||||
Ins_GetDataOfInstitByCod (&Ins);
|
||||
|
||||
/* Write data of this institution */
|
||||
Ins_ListOneInstitutionForSeeing (&Ins,NumIns);
|
||||
|
|
|
@ -103,7 +103,7 @@ void Ins_GetBasicListOfInstitutions (long CtyCod);
|
|||
void Ins_GetFullListOfInstitutions (long CtyCod);
|
||||
|
||||
void Ins_WriteInstitutionNameAndCty (long InsCod);
|
||||
bool Ins_GetDataOfInstitutionByCod (struct Ins_Instit *Ins);
|
||||
bool Ins_GetDataOfInstitByCod (struct Ins_Instit *Ins);
|
||||
void Ins_FlushCacheFullNameAndCtyOfInstitution (void);
|
||||
|
||||
void Ins_FreeListInstitutions (void);
|
||||
|
|
|
@ -1537,7 +1537,7 @@ void Lay_WriteHeaderClassPhoto (bool PrintView,bool DrawingClassPhoto,
|
|||
|
||||
/***** Get data of institution *****/
|
||||
Hie.Ins.InsCod = InsCod;
|
||||
Ins_GetDataOfInstitutionByCod (&Hie.Ins);
|
||||
Ins_GetDataOfInstitByCod (&Hie.Ins);
|
||||
|
||||
/***** Get data of degree *****/
|
||||
Hie.Deg.DegCod = DegCod;
|
||||
|
|
|
@ -404,7 +404,7 @@ void Ntf_ShowMyNotifications (void)
|
|||
|
||||
/* Get institution code (row[2]) */
|
||||
Hie.Ins.InsCod = Str_ConvertStrCodToLongCod (row[2]);
|
||||
Ins_GetDataOfInstitutionByCod (&Hie.Ins);
|
||||
Ins_GetDataOfInstitByCod (&Hie.Ins);
|
||||
|
||||
/* Get center code (row[3]) */
|
||||
Hie.Ctr.CtrCod = Str_ConvertStrCodToLongCod (row[3]);
|
||||
|
@ -1394,10 +1394,7 @@ void Ntf_SendPendingNotifByEMailToAllUsrs (void)
|
|||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
||||
/***** Delete old notifications ******/
|
||||
DB_QueryDELETE ("can not remove old notifications",
|
||||
"DELETE LOW_PRIORITY FROM ntf_notifications"
|
||||
" WHERE TimeNotif<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)",
|
||||
Cfg_TIME_TO_DELETE_OLD_NOTIF);
|
||||
Ntf_DB_RemoveOldNtfs ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1418,8 +1415,8 @@ static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsign
|
|||
extern const char *Txt_If_you_no_longer_wish_to_receive_email_notifications_NO_HTML[1 + Lan_NUM_LANGUAGES];
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumNots;
|
||||
unsigned NumNot;
|
||||
unsigned NumNtfs;
|
||||
unsigned NumNtf;
|
||||
Lan_Language_t ToUsrLanguage;
|
||||
struct UsrData FromUsrDat;
|
||||
Ntf_NotifyEvent_t NotifyEvent = (Ntf_NotifyEvent_t) 0; // Initialized to avoid warning
|
||||
|
@ -1436,34 +1433,13 @@ static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsign
|
|||
int ReturnCode;
|
||||
|
||||
/***** Return 0 notifications and 0 mails when error *****/
|
||||
*NumNotif = *NumMails = 0;
|
||||
*NumNotif =
|
||||
*NumMails = 0;
|
||||
|
||||
if (Mai_CheckIfUsrCanReceiveEmailNotif (ToUsrDat))
|
||||
{
|
||||
/***** Get pending notifications of this user from database ******/
|
||||
NumNots = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get pending notifications"
|
||||
" of a user",
|
||||
"SELECT NotifyEvent," // row[0]
|
||||
"FromUsrCod," // row[1]
|
||||
"InsCod," // row[2]
|
||||
"CtrCod," // row[3]
|
||||
"DegCod," // row[4]
|
||||
"CrsCod," // row[5]
|
||||
"Cod" // row[6]
|
||||
" FROM ntf_notifications"
|
||||
" 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));
|
||||
|
||||
if (NumNots) // Events found
|
||||
if ((NumNtfs = Ntf_DB_GetPendingNtfsToUsr (&mysql_res,ToUsrDat->UsrCod))) // Notifications found
|
||||
{
|
||||
/***** If user has no language, set it to current language *****/
|
||||
ToUsrLanguage = ToUsrDat->Prefs.Language;
|
||||
|
@ -1475,21 +1451,21 @@ static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsign
|
|||
|
||||
/***** Welcome note *****/
|
||||
Mai_WriteWelcomeNoteEMail (FileMail,ToUsrDat);
|
||||
if (NumNots == 1)
|
||||
if (NumNtfs == 1)
|
||||
fprintf (FileMail,Txt_NOTIFY_EVENTS_There_is_a_new_event_NO_HTML[ToUsrLanguage],
|
||||
Cfg_PLATFORM_SHORT_NAME);
|
||||
else
|
||||
fprintf (FileMail,Txt_NOTIFY_EVENTS_There_are_X_new_events_NO_HTML[ToUsrLanguage],
|
||||
(unsigned) NumNots,Cfg_PLATFORM_SHORT_NAME);
|
||||
(unsigned) NumNtfs,Cfg_PLATFORM_SHORT_NAME);
|
||||
fprintf (FileMail,": \n");
|
||||
|
||||
/***** Initialize structure with origin user's data *****/
|
||||
Usr_UsrDataConstructor (&FromUsrDat);
|
||||
|
||||
/***** Inform about the events one by one *****/
|
||||
for (NumNot = 0;
|
||||
NumNot < NumNots;
|
||||
NumNot++)
|
||||
for (NumNtf = 0;
|
||||
NumNtf < NumNtfs;
|
||||
NumNtf++)
|
||||
{
|
||||
/* Get next event */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -1503,20 +1479,19 @@ static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsign
|
|||
Usr_DONT_GET_PREFS,
|
||||
Usr_DONT_GET_ROLE_IN_CURRENT_CRS);
|
||||
|
||||
/* Get institution code (row[2]) */
|
||||
/* Get institution code (row[2]),
|
||||
center code (row[3]),
|
||||
degree code (row[4]),
|
||||
course code (row[5]) */
|
||||
Hie.Ins.InsCod = Str_ConvertStrCodToLongCod (row[2]);
|
||||
Ins_GetDataOfInstitutionByCod (&Hie.Ins);
|
||||
|
||||
/* Get center code (row[3]) */
|
||||
Hie.Ctr.CtrCod = Str_ConvertStrCodToLongCod (row[3]);
|
||||
Ctr_GetDataOfCenterByCod (&Hie.Ctr);
|
||||
|
||||
/* Get degree code (row[4]) */
|
||||
Hie.Deg.DegCod = Str_ConvertStrCodToLongCod (row[4]);
|
||||
Deg_GetDataOfDegreeByCod (&Hie.Deg);
|
||||
|
||||
/* Get course code (row[5]) */
|
||||
Hie.Crs.CrsCod = Str_ConvertStrCodToLongCod (row[5]);
|
||||
|
||||
/* Get data of institution, center, degree and course */
|
||||
Ins_GetDataOfInstitByCod (&Hie.Ins);
|
||||
Ctr_GetDataOfCenterByCod (&Hie.Ctr);
|
||||
Deg_GetDataOfDegreeByCod (&Hie.Deg);
|
||||
Crs_GetDataOfCourseByCod (&Hie.Crs);
|
||||
|
||||
/* Get message/post/... code (row[6]) */
|
||||
|
@ -1617,7 +1592,7 @@ static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsign
|
|||
ReturnCode = WEXITSTATUS(ReturnCode);
|
||||
if (ReturnCode == 0) // Message sent successfully
|
||||
{
|
||||
*NumNotif = NumNots;
|
||||
*NumNotif = NumNtfs;
|
||||
*NumMails = 1;
|
||||
|
||||
/* Update statistics about notifications */
|
||||
|
@ -1625,18 +1600,7 @@ static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsign
|
|||
}
|
||||
|
||||
/***** Mark all the pending notifications of this user as 'sent' *****/
|
||||
DB_QueryUPDATE ("can not set pending notifications of a user as sent",
|
||||
"UPDATE ntf_notifications"
|
||||
" 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));
|
||||
Ntf_DB_MarkPendingNtfsAsSent (ToUsrDat->UsrCod);
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
|
|
|
@ -88,6 +88,26 @@ void Ntf_DB_UpdateMyLastAccessToNotifications (void)
|
|||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********** Mark all the pending notifications of a user as 'sent' ***********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Ntf_DB_MarkPendingNtfsAsSent (long ToUsrCod)
|
||||
{
|
||||
DB_QueryUPDATE ("can not set pending notifications of a user as sent",
|
||||
"UPDATE ntf_notifications"
|
||||
" SET Status=(Status | %u)"
|
||||
" WHERE ToUsrCod=%ld"
|
||||
" AND (Status & %u)<>0"
|
||||
" AND (Status & %u)=0"
|
||||
" AND (Status & %u)=0",
|
||||
(unsigned) Ntf_STATUS_BIT_SENT,
|
||||
ToUsrCod,
|
||||
(unsigned) Ntf_STATUS_BIT_EMAIL,
|
||||
(unsigned) Ntf_STATUS_BIT_SENT,
|
||||
(unsigned) (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************** Set possible notification as seen ********************/
|
||||
/*****************************************************************************/
|
||||
|
@ -303,6 +323,34 @@ unsigned Ntf_DB_GetMyNotifications (MYSQL_RES **mysql_res,bool AllNotifications)
|
|||
SubQuery);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Get pending notifications to a user *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Ntf_DB_GetPendingNtfsToUsr (MYSQL_RES **mysql_res,long ToUsrCod)
|
||||
{
|
||||
return (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get user's pending notifications",
|
||||
"SELECT NotifyEvent," // row[0]
|
||||
"FromUsrCod," // row[1]
|
||||
"InsCod," // row[2]
|
||||
"CtrCod," // row[3]
|
||||
"DegCod," // row[4]
|
||||
"CrsCod," // row[5]
|
||||
"Cod" // row[6]
|
||||
" FROM ntf_notifications"
|
||||
" WHERE ToUsrCod=%ld"
|
||||
" AND (Status & %u)<>0"
|
||||
" AND (Status & %u)=0"
|
||||
" AND (Status & %u)=0"
|
||||
" ORDER BY TimeNotif,"
|
||||
"NotifyEvent",
|
||||
ToUsrCod,
|
||||
(unsigned) Ntf_STATUS_BIT_EMAIL,
|
||||
(unsigned) Ntf_STATUS_BIT_SENT,
|
||||
(unsigned) (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Get the number of (all) my unseen notifications ***************/
|
||||
/*****************************************************************************/
|
||||
|
@ -462,3 +510,15 @@ void Ntf_DB_RemoveUsrNtfs (long ToUsrCod)
|
|||
ToUsrCod);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************* Delete old notifications **************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Ntf_DB_RemoveOldNtfs (void)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove old notifications",
|
||||
"DELETE LOW_PRIORITY FROM ntf_notifications"
|
||||
" WHERE TimeNotif<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)",
|
||||
Cfg_TIME_TO_DELETE_OLD_NOTIF);
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ void Ntf_DB_StoreNotifyEventToOneUser (Ntf_NotifyEvent_t NotifyEvent,
|
|||
long Cod,Ntf_Status_t Status,
|
||||
long InsCod,long CtrCod,long DegCod,long CrsCod);
|
||||
void Ntf_DB_UpdateMyLastAccessToNotifications (void);
|
||||
void Ntf_DB_MarkPendingNtfsAsSent (long ToUsrCod);
|
||||
void Ntf_DB_MarkNotifAsSeen (Ntf_NotifyEvent_t NotifyEvent,long Cod,long CrsCod,long ToUsrCod);
|
||||
void Ntf_DB_MarkNotifToOneUsrAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod,long ToUsrCod);
|
||||
void Ntf_DB_MarkNotifInCrsAsRemoved (long ToUsrCod,long CrsCod);
|
||||
|
@ -58,11 +59,13 @@ void Ntf_DB_MarkNotifChildrenOfFolderAsRemoved (Ntf_NotifyEvent_t NotifyEvent,
|
|||
long Cod,const char *Path);
|
||||
|
||||
unsigned Ntf_DB_GetMyNotifications (MYSQL_RES **mysql_res,bool AllNotifications);
|
||||
unsigned Ntf_DB_GetPendingNtfsToUsr (MYSQL_RES **mysql_res,long ToUsrCod);
|
||||
unsigned Ntf_DB_GetNumAllMyUnseenNtfs (void);
|
||||
unsigned Ntf_DB_GetNumMyNewUnseenNtfs (void);
|
||||
unsigned Ntf_DB_GetUsrsWhoMustBeNotified (MYSQL_RES **mysql_res);
|
||||
unsigned Ntf_DB_GetNumNotifs (MYSQL_RES **mysql_res,Ntf_NotifyEvent_t NotifyEvent);
|
||||
|
||||
void Ntf_DB_RemoveUsrNtfs (long ToUsrCod);
|
||||
void Ntf_DB_RemoveOldNtfs (void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2240,7 +2240,7 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView,
|
|||
|
||||
Ins.InsCod = UsrDat->InsCod;
|
||||
if (Ins.InsCod > 0)
|
||||
Ins_GetDataOfInstitutionByCod (&Ins);
|
||||
Ins_GetDataOfInstitByCod (&Ins);
|
||||
|
||||
/***** Begin box and table *****/
|
||||
sprintf (StrRecordWidth,"%upx",Rec_RECORD_WIDTH);
|
||||
|
@ -4114,7 +4114,7 @@ void Rec_UpdateMyInstitution (void)
|
|||
/* Get country of institution */
|
||||
if (Ins.InsCod > 0)
|
||||
{
|
||||
Ins_GetDataOfInstitutionByCod (&Ins);
|
||||
Ins_GetDataOfInstitByCod (&Ins);
|
||||
if (Gbl.Usrs.Me.UsrDat.InsCtyCod != Ins.CtyCod)
|
||||
Gbl.Usrs.Me.UsrDat.InsCtyCod = Ins.CtyCod;
|
||||
}
|
||||
|
|
|
@ -562,7 +562,7 @@ static void Rep_WriteSectionUsrInfo (void)
|
|||
|
||||
/***** User's institution *****/
|
||||
Ins.InsCod = Gbl.Usrs.Me.UsrDat.InsCod;
|
||||
Ins_GetDataOfInstitutionByCod (&Ins);
|
||||
Ins_GetDataOfInstitByCod (&Ins);
|
||||
fprintf (Gbl.F.Rep,"<li>%s: %s</li>",
|
||||
Txt_Institution,
|
||||
Ins.FullName);
|
||||
|
|
|
@ -3530,7 +3530,7 @@ static void Sta_WriteInstit (long InsCod)
|
|||
{
|
||||
/***** Get data of institution *****/
|
||||
Ins.InsCod = InsCod;
|
||||
Ins_GetDataOfInstitutionByCod (&Ins);
|
||||
Ins_GetDataOfInstitByCod (&Ins);
|
||||
|
||||
/***** Title in cell *****/
|
||||
HTM_TD_Begin ("class=\"LOG LM\" title=\"%s\"",Ins.FullName);
|
||||
|
|
|
@ -273,7 +273,7 @@ static void SysCfg_Map (void)
|
|||
|
||||
/* Get data of institution */
|
||||
Ins.InsCod = Ctr.InsCod;
|
||||
Ins_GetDataOfInstitutionByCod (&Ins);
|
||||
Ins_GetDataOfInstitByCod (&Ins);
|
||||
|
||||
/* Add marker */
|
||||
Map_AddMarker (&Ctr.Coord);
|
||||
|
|
|
@ -446,7 +446,7 @@ static void Tml_Not_GetLocationInHierarchy (const struct Tml_Not_Note *Not,
|
|||
case TL_NOTE_INS_SHA_PUB_FILE:
|
||||
/* Get institution data */
|
||||
Hie->Ins.InsCod = Not->HieCod;
|
||||
Ins_GetDataOfInstitutionByCod (&Hie->Ins);
|
||||
Ins_GetDataOfInstitByCod (&Hie->Ins);
|
||||
break;
|
||||
case TL_NOTE_CTR_DOC_PUB_FILE:
|
||||
case TL_NOTE_CTR_SHA_PUB_FILE:
|
||||
|
|
10
swad_user.c
10
swad_user.c
|
@ -3743,7 +3743,7 @@ void Usr_WriteRowUsrMainData (unsigned NumUsr,struct UsrData *UsrDat,
|
|||
|
||||
/***** Write rest of main user's data *****/
|
||||
Ins.InsCod = UsrDat->InsCod;
|
||||
Ins_GetDataOfInstitutionByCod (&Ins);
|
||||
Ins_GetDataOfInstitByCod (&Ins);
|
||||
Usr_WriteMainUsrDataExceptUsrID (UsrDat,BgColor);
|
||||
|
||||
HTM_TD_Begin ("class=\"LM %s\"",BgColor);
|
||||
|
@ -3783,7 +3783,7 @@ static void Usr_WriteRowGstAllData (struct UsrData *UsrDat)
|
|||
|
||||
/***** Write rest of guest's main data *****/
|
||||
Ins.InsCod = UsrDat->InsCod;
|
||||
Ins_GetDataOfInstitutionByCod (&Ins);
|
||||
Ins_GetDataOfInstitByCod (&Ins);
|
||||
Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd]);
|
||||
Usr_WriteEmail (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd]);
|
||||
Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd],
|
||||
|
@ -3870,7 +3870,7 @@ static void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GroupNames)
|
|||
|
||||
/***** Write rest of main student's data *****/
|
||||
Ins.InsCod = UsrDat->InsCod;
|
||||
Ins_GetDataOfInstitutionByCod (&Ins);
|
||||
Ins_GetDataOfInstitByCod (&Ins);
|
||||
Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd]);
|
||||
Usr_WriteEmail (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd]);
|
||||
Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd],
|
||||
|
@ -3970,7 +3970,7 @@ static void Usr_WriteRowTchAllData (struct UsrData *UsrDat)
|
|||
|
||||
/***** Write rest of main teacher's data *****/
|
||||
Ins.InsCod = UsrDat->InsCod;
|
||||
Ins_GetDataOfInstitutionByCod (&Ins);
|
||||
Ins_GetDataOfInstitByCod (&Ins);
|
||||
Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd]);
|
||||
Usr_WriteEmail (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd]);
|
||||
Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd],
|
||||
|
@ -4043,7 +4043,7 @@ static void Usr_WriteRowAdmData (unsigned NumUsr,struct UsrData *UsrDat)
|
|||
|
||||
/***** Write rest of main administrator's data *****/
|
||||
Ins.InsCod = UsrDat->InsCod;
|
||||
Ins_GetDataOfInstitutionByCod (&Ins);
|
||||
Ins_GetDataOfInstitByCod (&Ins);
|
||||
Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd]);
|
||||
|
||||
HTM_TD_Begin ("class=\"LM %s\"",Gbl.ColorRows[Gbl.RowEvenOdd]);
|
||||
|
|
Loading…
Reference in New Issue