mirror of
https://github.com/acanas/swad-core.git
synced 2024-09-20 00:02:42 +02:00
Version 21.22: Oct 04, 2021 Queries related to notifications moved to other modules.
This commit is contained in:
parent
73e5e67df0
commit
c529b1b8e8
|
@ -25,9 +25,10 @@
|
||||||
/*********************************** Headers *********************************/
|
/*********************************** Headers *********************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#include "swad_database.h"
|
|
||||||
#include "swad_admin.h"
|
#include "swad_admin.h"
|
||||||
#include "swad_admin_database.h"
|
#include "swad_admin_database.h"
|
||||||
|
#include "swad_database.h"
|
||||||
|
#include "swad_global.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
|
@ -71,6 +72,28 @@ void Adm_DB_InsertAdmin (long UsrCod,HieLvl_Level_t Scope,long Cod)
|
||||||
Cod);
|
Cod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********** Get all admin codes above the current course, except me **********/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Adm_DB_GetAdmsCurrentScopeExceptMe (MYSQL_RES **mysql_res)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get admins from current scope",
|
||||||
|
"SELECT UsrCod"
|
||||||
|
" FROM usr_admins"
|
||||||
|
" WHERE (Scope='%s'"
|
||||||
|
" OR (Scope='%s' AND Cod=%ld)"
|
||||||
|
" OR (Scope='%s' AND Cod=%ld)"
|
||||||
|
" OR (Scope='%s' AND Cod=%ld))"
|
||||||
|
" AND UsrCod<>%ld",
|
||||||
|
Sco_GetDBStrFromScope (HieLvl_SYS),
|
||||||
|
Sco_GetDBStrFromScope (HieLvl_INS),Gbl.Hierarchy.Ins.InsCod,
|
||||||
|
Sco_GetDBStrFromScope (HieLvl_CTR),Gbl.Hierarchy.Ctr.CtrCod,
|
||||||
|
Sco_GetDBStrFromScope (HieLvl_DEG),Gbl.Hierarchy.Deg.DegCod,
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***** Remove user as administrator of an institution, center or degree ******/
|
/***** Remove user as administrator of an institution, center or degree ******/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -42,6 +42,9 @@
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Adm_DB_InsertAdmin (long UsrCod,HieLvl_Level_t Scope,long Cod);
|
void Adm_DB_InsertAdmin (long UsrCod,HieLvl_Level_t Scope,long Cod);
|
||||||
|
|
||||||
|
unsigned Adm_DB_GetAdmsCurrentScopeExceptMe (MYSQL_RES **mysql_res);
|
||||||
|
|
||||||
void Adm_DB_RemAdmin (long UsrCod,HieLvl_Level_t Scope,long Cod);
|
void Adm_DB_RemAdmin (long UsrCod,HieLvl_Level_t Scope,long Cod);
|
||||||
void Adm_DB_RemUsrAsAdmin (long UsrCod);
|
void Adm_DB_RemUsrAsAdmin (long UsrCod);
|
||||||
void Adm_DB_RemAdmins (HieLvl_Level_t Scope,long Cod);
|
void Adm_DB_RemAdmins (HieLvl_Level_t Scope,long Cod);
|
||||||
|
|
|
@ -461,7 +461,6 @@ void Asg_DB_RemoveCrsAssignments (long CrsCod)
|
||||||
void Asg_DB_UpdateNumUsrsNotifiedByEMailAboutAssignment (long AsgCod,
|
void Asg_DB_UpdateNumUsrsNotifiedByEMailAboutAssignment (long AsgCod,
|
||||||
unsigned NumUsrsToBeNotifiedByEMail)
|
unsigned NumUsrsToBeNotifiedByEMail)
|
||||||
{
|
{
|
||||||
/***** Update number of users notified *****/
|
|
||||||
DB_QueryUPDATE ("can not update the number of notifs. of an assignment",
|
DB_QueryUPDATE ("can not update the number of notifs. of an assignment",
|
||||||
"UPDATE asg_assignments"
|
"UPDATE asg_assignments"
|
||||||
" SET NumNotif=NumNotif+%u"
|
" SET NumNotif=NumNotif+%u"
|
||||||
|
@ -470,6 +469,41 @@ void Asg_DB_UpdateNumUsrsNotifiedByEMailAboutAssignment (long AsgCod,
|
||||||
AsgCod);
|
AsgCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********** Get all user codes belonging to an assignment, except me *********/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Asg_DB_GetUsrsFromAssignmentExceptMe (MYSQL_RES **mysql_res,long AsgCod)
|
||||||
|
{
|
||||||
|
// 1. If the assignment is available for the whole course ==> get all users enroled in the course except me
|
||||||
|
// 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
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get users to be notified",
|
||||||
|
"(SELECT crs_users.UsrCod"
|
||||||
|
" FROM asg_assignments,"
|
||||||
|
"crs_users"
|
||||||
|
" WHERE asg_assignments.AsgCod=%ld"
|
||||||
|
" AND asg_assignments.AsgCod NOT IN"
|
||||||
|
" (SELECT AsgCod"
|
||||||
|
" FROM asg_groups"
|
||||||
|
" WHERE AsgCod=%ld)"
|
||||||
|
" AND asg_assignments.CrsCod=crs_users.CrsCod"
|
||||||
|
" AND crs_users.UsrCod<>%ld)"
|
||||||
|
" UNION "
|
||||||
|
"(SELECT DISTINCT grp_users.UsrCod"
|
||||||
|
" FROM asg_groups,"
|
||||||
|
"grp_users"
|
||||||
|
" WHERE asg_groups.AsgCod=%ld"
|
||||||
|
" AND asg_groups.GrpCod=grp_users.GrpCod"
|
||||||
|
" AND grp_users.UsrCod<>%ld)",
|
||||||
|
AsgCod,
|
||||||
|
AsgCod,
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
|
AsgCod,
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/****************** Get number of courses with assignments *******************/
|
/****************** Get number of courses with assignments *******************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -75,6 +75,7 @@ void Asg_DB_RemoveCrsAssignments (long CrsCod);
|
||||||
|
|
||||||
void Asg_DB_UpdateNumUsrsNotifiedByEMailAboutAssignment (long AsgCod,
|
void Asg_DB_UpdateNumUsrsNotifiedByEMailAboutAssignment (long AsgCod,
|
||||||
unsigned NumUsrsToBeNotifiedByEMail);
|
unsigned NumUsrsToBeNotifiedByEMail);
|
||||||
|
unsigned Asg_DB_GetUsrsFromAssignmentExceptMe (MYSQL_RES **mysql_res,long AsgCod);
|
||||||
|
|
||||||
unsigned Asg_DB_GetNumCoursesWithAssignments (HieLvl_Level_t Scope);
|
unsigned Asg_DB_GetNumCoursesWithAssignments (HieLvl_Level_t Scope);
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ void Cal_ChangeFirstDayOfWeek (void)
|
||||||
|
|
||||||
/***** Store icon first day of week database *****/
|
/***** Store icon first day of week database *****/
|
||||||
if (Gbl.Usrs.Me.Logged)
|
if (Gbl.Usrs.Me.Logged)
|
||||||
Set_DB_ChangeFirstDayOfWeek (Gbl.Prefs.FirstDayOfWeek);
|
Set_DB_UpdateMySettingsAboutFirstDayOfWeek (Gbl.Prefs.FirstDayOfWeek);
|
||||||
|
|
||||||
/***** Set settings from current IP *****/
|
/***** Set settings from current IP *****/
|
||||||
Set_SetSettingsFromIP ();
|
Set_SetSettingsFromIP ();
|
||||||
|
|
|
@ -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.
|
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.2 (2021-10-01)"
|
#define Log_PLATFORM_VERSION "SWAD 21.22 (2021-10-04)"
|
||||||
#define CSS_FILE "swad20.45.css"
|
#define CSS_FILE "swad20.45.css"
|
||||||
#define JS_FILE "swad20.69.1.js"
|
#define JS_FILE "swad20.69.1.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 21.22: Oct 04, 2021 Queries related to notifications moved to other modules. (318058 lines)
|
||||||
Version 21.21.2: Oct 01, 2021 Queries moved to module swad_notification_database. (317963 lines)
|
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.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.21: Sep 30, 2021 New module swad_notice_database for database queries related to notices. (317901 lines)
|
||||||
|
|
|
@ -106,6 +106,40 @@ unsigned Enr_DB_GetUsrsFromCurrentCrs (MYSQL_RES **mysql_res)
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******* Get all user codes belonging to the current course, except me *******/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Enr_DB_GetUsrsFromCurrentCrsExceptMe (MYSQL_RES **mysql_res)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get users from current course",
|
||||||
|
"SELECT UsrCod"
|
||||||
|
" FROM crs_users"
|
||||||
|
" WHERE CrsCod=%ld"
|
||||||
|
" AND UsrCod<>%ld",
|
||||||
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/***** Get all teachers codes belonging to the current course, except me *****/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Enr_DB_GetTchsFromCurrentCrsExceptMe (MYSQL_RES **mysql_res)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get teachers from current course",
|
||||||
|
"SELECT UsrCod"
|
||||||
|
" FROM crs_users"
|
||||||
|
" WHERE CrsCod=%ld"
|
||||||
|
" AND UsrCod<>%ld"
|
||||||
|
" AND Role=%u", // Teachers only
|
||||||
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
|
(unsigned) Rol_TCH);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************************** Remove user from course **************************/
|
/************************** Remove user from course **************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -47,6 +47,8 @@ void Enr_DB_InsertUsrInCurrentCrs (long UsrCod,long CrsCod,Rol_Role_t NewRole,
|
||||||
void Enr_DB_AcceptUsrInCrs (long UsrCod,long CrsCod);
|
void Enr_DB_AcceptUsrInCrs (long UsrCod,long CrsCod);
|
||||||
|
|
||||||
unsigned Enr_DB_GetUsrsFromCurrentCrs (MYSQL_RES **mysql_res);
|
unsigned Enr_DB_GetUsrsFromCurrentCrs (MYSQL_RES **mysql_res);
|
||||||
|
unsigned Enr_DB_GetUsrsFromCurrentCrsExceptMe (MYSQL_RES **mysql_res);
|
||||||
|
unsigned Enr_DB_GetTchsFromCurrentCrsExceptMe (MYSQL_RES **mysql_res);
|
||||||
|
|
||||||
void Enr_DB_RemUsrFromCrs (long UsrCod,long CrsCod);
|
void Enr_DB_RemUsrFromCrs (long UsrCod,long CrsCod);
|
||||||
void Enr_DB_RemUsrFromAllCrss (long UsrCod);
|
void Enr_DB_RemUsrFromAllCrss (long UsrCod);
|
||||||
|
|
|
@ -364,6 +364,24 @@ unsigned For_DB_GetThreadAndNumPostsGivenPstCod (MYSQL_RES **mysql_res,long PstC
|
||||||
PstCod);
|
PstCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************* Get all publisher codes in a thread, except me ****************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned For_DB_GetPublishersInThreadExceptMe (MYSQL_RES **mysql_res,long PstCod)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get publishers in thread",
|
||||||
|
"SELECT DISTINCT(UsrCod)"
|
||||||
|
" FROM for_posts"
|
||||||
|
" WHERE ThrCod=(SELECT ThrCod"
|
||||||
|
" FROM for_posts"
|
||||||
|
" WHERE PstCod=%ld)"
|
||||||
|
" AND UsrCod<>%ld",
|
||||||
|
PstCod,
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/********************* Remove post from forum posts table ********************/
|
/********************* Remove post from forum posts table ********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -58,6 +58,7 @@ unsigned For_DB_GetForumTypeAndLocationOfAPost (MYSQL_RES **mysql_res,long PstCo
|
||||||
unsigned For_DB_GetNumPostsUsr (long UsrCod);
|
unsigned For_DB_GetNumPostsUsr (long UsrCod);
|
||||||
unsigned For_DB_GetPostsOfAThread (MYSQL_RES **mysql_res,long ThrCod);
|
unsigned For_DB_GetPostsOfAThread (MYSQL_RES **mysql_res,long ThrCod);
|
||||||
unsigned For_DB_GetThreadAndNumPostsGivenPstCod (MYSQL_RES **mysql_res,long PstCod);
|
unsigned For_DB_GetThreadAndNumPostsGivenPstCod (MYSQL_RES **mysql_res,long PstCod);
|
||||||
|
unsigned For_DB_GetPublishersInThreadExceptMe (MYSQL_RES **mysql_res,long PstCod);
|
||||||
void For_DB_RemovePst (long PstCod);
|
void For_DB_RemovePst (long PstCod);
|
||||||
void For_DB_RemoveThreadPsts (long ThrCod);
|
void For_DB_RemoveThreadPsts (long ThrCod);
|
||||||
|
|
||||||
|
|
|
@ -306,6 +306,46 @@ unsigned Grp_DB_CountNumUsrsInNoGrpsOfType (Rol_Role_t Role,long GrpTypCod)
|
||||||
GrpTypCod);
|
GrpTypCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******** Get all user codes belonging to the current group, except me *******/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Grp_DB_GetUsrsFromCurrentGrpExceptMe (MYSQL_RES **mysql_res)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get users from current group",
|
||||||
|
"SELECT UsrCod"
|
||||||
|
" FROM grp_users"
|
||||||
|
" WHERE GrpCod=%ld"
|
||||||
|
" AND UsrCod<>%ld",
|
||||||
|
Gbl.Crs.Grps.GrpCod,
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/****** Get all teacher codes belonging to the current group, except me ******/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Grp_DB_GetTchsFromCurrentGrpExceptMe (MYSQL_RES **mysql_res)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get teachers from current group",
|
||||||
|
"SELECT grp_users.UsrCod"
|
||||||
|
" FROM grp_users,"
|
||||||
|
"grp_groups,"
|
||||||
|
"grp_types,"
|
||||||
|
"crs_users"
|
||||||
|
" WHERE grp_users.GrpCod=%ld"
|
||||||
|
" AND grp_users.UsrCod<>%ld"
|
||||||
|
" AND grp_users.GrpCod=grp_groups.GrpCod"
|
||||||
|
" AND grp_groups.GrpTypCod=grp_types.GrpTypCod"
|
||||||
|
" AND grp_types.CrsCod=crs_users.CrsCod"
|
||||||
|
" AND crs_users.Role=%u", // Teachers only
|
||||||
|
Gbl.Crs.Grps.GrpCod,
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
|
(unsigned) Rol_TCH);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/********* Check if I belong to any groups of a given type I belong **********/
|
/********* Check if I belong to any groups of a given type I belong **********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -59,6 +59,8 @@ bool Grp_DB_CheckIfGrpNameExistsForGrpTyp (long GrpTypCod,const char *GrpName,lo
|
||||||
|
|
||||||
unsigned Grp_DB_CountNumUsrsInGrp (Rol_Role_t Role,long GrpCod);
|
unsigned Grp_DB_CountNumUsrsInGrp (Rol_Role_t Role,long GrpCod);
|
||||||
unsigned Grp_DB_CountNumUsrsInNoGrpsOfType (Rol_Role_t Role,long GrpTypCod);
|
unsigned Grp_DB_CountNumUsrsInNoGrpsOfType (Rol_Role_t Role,long GrpTypCod);
|
||||||
|
unsigned Grp_DB_GetUsrsFromCurrentGrpExceptMe (MYSQL_RES **mysql_res);
|
||||||
|
unsigned Grp_DB_GetTchsFromCurrentGrpExceptMe (MYSQL_RES **mysql_res);
|
||||||
|
|
||||||
bool Grp_DB_CheckIfIBelongToGrpsOfType (long GrpTypCod);
|
bool Grp_DB_CheckIfIBelongToGrpsOfType (long GrpTypCod);
|
||||||
bool Grp_DB_CheckIfIBelongToGrp (long GrpCod);
|
bool Grp_DB_CheckIfIBelongToGrp (long GrpCod);
|
||||||
|
|
|
@ -165,7 +165,7 @@ void Ico_ChangeIconSet (void)
|
||||||
|
|
||||||
/***** Store icon set in database *****/
|
/***** Store icon set in database *****/
|
||||||
if (Gbl.Usrs.Me.Logged)
|
if (Gbl.Usrs.Me.Logged)
|
||||||
Set_DB_ChangeIconSet (Ico_IconSetId[Gbl.Prefs.IconSet]);
|
Set_DB_UpdateMySettingsAboutIconSet (Ico_IconSetId[Gbl.Prefs.IconSet]);
|
||||||
|
|
||||||
/***** Set settings from current IP *****/
|
/***** Set settings from current IP *****/
|
||||||
Set_SetSettingsFromIP ();
|
Set_SetSettingsFromIP ();
|
||||||
|
|
|
@ -129,7 +129,7 @@ int main (void)
|
||||||
Fil_CreateFileForHTMLOutput ();
|
Fil_CreateFileForHTMLOutput ();
|
||||||
|
|
||||||
/***** Remove old (expired) sessions *****/
|
/***** Remove old (expired) sessions *****/
|
||||||
Ses_RemoveExpiredSessions ();
|
Ses_DB_RemoveExpiredSessions ();
|
||||||
|
|
||||||
/***** Remove old users from connected list *****/
|
/***** Remove old users from connected list *****/
|
||||||
Con_DB_RemoveOldConnected ();
|
Con_DB_RemoveOldConnected ();
|
||||||
|
|
|
@ -329,7 +329,7 @@ void Mnu_ChangeMenu (void)
|
||||||
|
|
||||||
/***** Store menu in database *****/
|
/***** Store menu in database *****/
|
||||||
if (Gbl.Usrs.Me.Logged)
|
if (Gbl.Usrs.Me.Logged)
|
||||||
Set_DB_ChangeMenu (Gbl.Prefs.Menu);
|
Set_DB_UpdateMySettingsAboutMenu (Gbl.Prefs.Menu);
|
||||||
|
|
||||||
/***** Set settings from current IP *****/
|
/***** Set settings from current IP *****/
|
||||||
Set_SetSettingsFromIP ();
|
Set_SetSettingsFromIP ();
|
||||||
|
|
|
@ -1549,7 +1549,7 @@ static void Msg_ShowSntOrRcvMessages (struct Msg_Messages *Messages)
|
||||||
Messages->CurrentPage = (unsigned) Pagination.CurrentPage;
|
Messages->CurrentPage = (unsigned) Pagination.CurrentPage;
|
||||||
|
|
||||||
/***** Save my current page in order to show it next time I'll view my received/sent messages *****/
|
/***** Save my current page in order to show it next time I'll view my received/sent messages *****/
|
||||||
Pag_DB_SaveLastPageMsgIntoSession (WhatPaginate[Messages->TypeOfMessages],
|
Ses_DB_SaveLastPageMsgIntoSession (WhatPaginate[Messages->TypeOfMessages],
|
||||||
Messages->CurrentPage);
|
Messages->CurrentPage);
|
||||||
|
|
||||||
/***** Write links to pages *****/
|
/***** Write links to pages *****/
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
#include <unistd.h> // For unlink
|
#include <unistd.h> // For unlink
|
||||||
|
|
||||||
#include "swad_action.h"
|
#include "swad_action.h"
|
||||||
|
#include "swad_admin_database.h"
|
||||||
|
#include "swad_assignment_database.h"
|
||||||
#include "swad_box.h"
|
#include "swad_box.h"
|
||||||
#include "swad_browser_database.h"
|
#include "swad_browser_database.h"
|
||||||
#include "swad_call_for_exam.h"
|
#include "swad_call_for_exam.h"
|
||||||
|
@ -39,12 +41,15 @@
|
||||||
#include "swad_config.h"
|
#include "swad_config.h"
|
||||||
#include "swad_database.h"
|
#include "swad_database.h"
|
||||||
#include "swad_enrolment.h"
|
#include "swad_enrolment.h"
|
||||||
|
#include "swad_enrolment_database.h"
|
||||||
#include "swad_error.h"
|
#include "swad_error.h"
|
||||||
#include "swad_figure.h"
|
#include "swad_figure.h"
|
||||||
#include "swad_follow.h"
|
#include "swad_follow.h"
|
||||||
#include "swad_form.h"
|
#include "swad_form.h"
|
||||||
#include "swad_forum.h"
|
#include "swad_forum.h"
|
||||||
|
#include "swad_forum_database.h"
|
||||||
#include "swad_global.h"
|
#include "swad_global.h"
|
||||||
|
#include "swad_group_database.h"
|
||||||
#include "swad_hierarchy.h"
|
#include "swad_hierarchy.h"
|
||||||
#include "swad_hierarchy_level.h"
|
#include "swad_hierarchy_level.h"
|
||||||
#include "swad_HTML.h"
|
#include "swad_HTML.h"
|
||||||
|
@ -55,8 +60,10 @@
|
||||||
#include "swad_notification.h"
|
#include "swad_notification.h"
|
||||||
#include "swad_notification_database.h"
|
#include "swad_notification_database.h"
|
||||||
#include "swad_parameter.h"
|
#include "swad_parameter.h"
|
||||||
|
#include "swad_setting.h"
|
||||||
#include "swad_survey.h"
|
#include "swad_survey.h"
|
||||||
#include "swad_timeline.h"
|
#include "swad_timeline.h"
|
||||||
|
#include "swad_timeline_database.h"
|
||||||
#include "swad_timeline_notification.h"
|
#include "swad_timeline_notification.h"
|
||||||
#include "swad_timeline_publication.h"
|
#include "swad_timeline_publication.h"
|
||||||
|
|
||||||
|
@ -1033,97 +1040,29 @@ unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod)
|
||||||
case Brw_ADMI_DOC_CRS:
|
case Brw_ADMI_DOC_CRS:
|
||||||
case Brw_ADMI_SHR_CRS:
|
case Brw_ADMI_SHR_CRS:
|
||||||
case Brw_ADMI_MRK_CRS: // Notify all users in course except me
|
case Brw_ADMI_MRK_CRS: // Notify all users in course except me
|
||||||
NumUsrs = (unsigned)
|
NumUsrs = Enr_DB_GetUsrsFromCurrentCrsExceptMe (&mysql_res);
|
||||||
DB_QuerySELECT (&mysql_res,"can not get users to be notified",
|
|
||||||
"SELECT UsrCod"
|
|
||||||
" FROM crs_users"
|
|
||||||
" WHERE CrsCod=%ld"
|
|
||||||
" AND UsrCod<>%ld",
|
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
|
||||||
break;
|
break;
|
||||||
case Brw_ADMI_TCH_CRS: // Notify all teachers in course except me
|
case Brw_ADMI_TCH_CRS: // Notify all teachers in course except me
|
||||||
NumUsrs = (unsigned)
|
NumUsrs = Enr_DB_GetTchsFromCurrentCrsExceptMe (&mysql_res);
|
||||||
DB_QuerySELECT (&mysql_res,"can not get users to be notified",
|
|
||||||
"SELECT UsrCod"
|
|
||||||
" FROM crs_users"
|
|
||||||
" WHERE CrsCod=%ld"
|
|
||||||
" AND UsrCod<>%ld"
|
|
||||||
" AND Role=%u", // Notify teachers only
|
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
|
||||||
(unsigned) Rol_TCH);
|
|
||||||
break;
|
break;
|
||||||
case Brw_ADMI_DOC_GRP:
|
case Brw_ADMI_DOC_GRP:
|
||||||
case Brw_ADMI_SHR_GRP:
|
case Brw_ADMI_SHR_GRP:
|
||||||
case Brw_ADMI_MRK_GRP: // Notify all users in group except me
|
case Brw_ADMI_MRK_GRP: // Notify all users in group except me
|
||||||
NumUsrs = (unsigned)
|
NumUsrs = Grp_DB_GetUsrsFromCurrentGrpExceptMe (&mysql_res);
|
||||||
DB_QuerySELECT (&mysql_res,"can not get users to be notified",
|
|
||||||
"SELECT UsrCod"
|
|
||||||
" FROM grp_users"
|
|
||||||
" WHERE GrpCod=%ld"
|
|
||||||
" AND UsrCod<>%ld",
|
|
||||||
Gbl.Crs.Grps.GrpCod,
|
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
|
||||||
break;
|
break;
|
||||||
case Brw_ADMI_TCH_GRP: // Notify all teachers in group except me
|
case Brw_ADMI_TCH_GRP: // Notify all teachers in group except me
|
||||||
NumUsrs = (unsigned)
|
NumUsrs = Grp_DB_GetTchsFromCurrentGrpExceptMe (&mysql_res);
|
||||||
DB_QuerySELECT (&mysql_res,"can not get users to be notified",
|
|
||||||
"SELECT grp_users.UsrCod"
|
|
||||||
" FROM grp_users,"
|
|
||||||
"grp_groups,"
|
|
||||||
"grp_types,"
|
|
||||||
"crs_users"
|
|
||||||
" WHERE grp_users.GrpCod=%ld"
|
|
||||||
" AND grp_users.UsrCod<>%ld"
|
|
||||||
" AND grp_users.GrpCod=grp_groups.GrpCod"
|
|
||||||
" AND grp_groups.GrpTypCod=grp_types.GrpTypCod"
|
|
||||||
" AND grp_types.CrsCod=crs_users.CrsCod"
|
|
||||||
" AND crs_users.Role=%u", // Notify teachers only
|
|
||||||
Gbl.Crs.Grps.GrpCod,
|
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
|
||||||
(unsigned) Rol_TCH);
|
|
||||||
break;
|
break;
|
||||||
default: // This function should not be called in other cases
|
default: // This function should not be called in other cases
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Ntf_EVENT_ASSIGNMENT:
|
case Ntf_EVENT_ASSIGNMENT:
|
||||||
// 1. If the assignment is available for the whole course ==> get all users enroled in the course except me
|
NumUsrs = Asg_DB_GetUsrsFromAssignmentExceptMe (&mysql_res,Cod);
|
||||||
// 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
|
|
||||||
NumUsrs = (unsigned)
|
|
||||||
DB_QuerySELECT (&mysql_res,"can not get users to be notified",
|
|
||||||
"(SELECT crs_users.UsrCod"
|
|
||||||
" FROM asg_assignments,"
|
|
||||||
"crs_users"
|
|
||||||
" WHERE asg_assignments.AsgCod=%ld"
|
|
||||||
" AND asg_assignments.AsgCod NOT IN"
|
|
||||||
" (SELECT AsgCod"
|
|
||||||
" FROM asg_groups"
|
|
||||||
" WHERE AsgCod=%ld)"
|
|
||||||
" AND asg_assignments.CrsCod=crs_users.CrsCod"
|
|
||||||
" AND crs_users.UsrCod<>%ld)"
|
|
||||||
" UNION "
|
|
||||||
"(SELECT DISTINCT grp_users.UsrCod"
|
|
||||||
" FROM asg_groups,"
|
|
||||||
"grp_users"
|
|
||||||
" WHERE asg_groups.AsgCod=%ld"
|
|
||||||
" AND asg_groups.GrpCod=grp_users.GrpCod"
|
|
||||||
" AND grp_users.UsrCod<>%ld)",
|
|
||||||
Cod,Cod,Gbl.Usrs.Me.UsrDat.UsrCod,
|
|
||||||
Cod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
|
||||||
break;
|
break;
|
||||||
case Ntf_EVENT_CALL_FOR_EXAM:
|
case Ntf_EVENT_CALL_FOR_EXAM:
|
||||||
case Ntf_EVENT_NOTICE:
|
case Ntf_EVENT_NOTICE:
|
||||||
NumUsrs = (unsigned)
|
NumUsrs = Enr_DB_GetUsrsFromCurrentCrsExceptMe (&mysql_res);
|
||||||
DB_QuerySELECT (&mysql_res,"can not get users to be notified",
|
|
||||||
"SELECT UsrCod"
|
|
||||||
" FROM crs_users"
|
|
||||||
" WHERE CrsCod=%ld"
|
|
||||||
" AND UsrCod<>%ld",
|
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
|
||||||
break;
|
break;
|
||||||
case Ntf_EVENT_ENROLMENT_STD: // This function should not be called in this case
|
case Ntf_EVENT_ENROLMENT_STD: // This function should not be called in this case
|
||||||
case Ntf_EVENT_ENROLMENT_NET: // This function should not be called in this case
|
case Ntf_EVENT_ENROLMENT_NET: // This function should not be called in this case
|
||||||
|
@ -1133,48 +1072,17 @@ unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod)
|
||||||
if (Usr_GetNumUsrsInCrss (HieLvl_CRS,Gbl.Hierarchy.Crs.CrsCod,
|
if (Usr_GetNumUsrsInCrss (HieLvl_CRS,Gbl.Hierarchy.Crs.CrsCod,
|
||||||
1 << Rol_TCH))
|
1 << Rol_TCH))
|
||||||
// If this course has teachers ==> send notification to teachers
|
// If this course has teachers ==> send notification to teachers
|
||||||
NumUsrs = (unsigned)
|
NumUsrs = Enr_DB_GetTchsFromCurrentCrsExceptMe (&mysql_res);
|
||||||
DB_QuerySELECT (&mysql_res,"can not get users to be notified",
|
|
||||||
"SELECT UsrCod"
|
|
||||||
" FROM crs_users"
|
|
||||||
" WHERE CrsCod=%ld"
|
|
||||||
" AND UsrCod<>%ld"
|
|
||||||
" AND Role=%u", // Notify teachers only
|
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
|
||||||
(unsigned) Rol_TCH);
|
|
||||||
else // Course without teachers
|
else // Course without teachers
|
||||||
// If this course has no teachers
|
// If this course has no teachers
|
||||||
// and I want to be a teacher (checked before calling this function
|
// and I want to be a teacher (checked before calling this function
|
||||||
// to not send requests to be a student to admins)
|
// to not send requests to be a student to admins)
|
||||||
// ==> send notification to administrators or superusers
|
// ==> send notification to administrators or superusers
|
||||||
NumUsrs = (unsigned)
|
NumUsrs = Adm_DB_GetAdmsCurrentScopeExceptMe (&mysql_res);
|
||||||
DB_QuerySELECT (&mysql_res,"can not get users to be notified",
|
|
||||||
"SELECT UsrCod"
|
|
||||||
" FROM usr_admins"
|
|
||||||
" WHERE (Scope='%s'"
|
|
||||||
" OR (Scope='%s' AND Cod=%ld)"
|
|
||||||
" OR (Scope='%s' AND Cod=%ld)"
|
|
||||||
" OR (Scope='%s' AND Cod=%ld))"
|
|
||||||
" AND UsrCod<>%ld",
|
|
||||||
Sco_GetDBStrFromScope (HieLvl_SYS),
|
|
||||||
Sco_GetDBStrFromScope (HieLvl_INS),Gbl.Hierarchy.Ins.InsCod,
|
|
||||||
Sco_GetDBStrFromScope (HieLvl_CTR),Gbl.Hierarchy.Ctr.CtrCod,
|
|
||||||
Sco_GetDBStrFromScope (HieLvl_DEG),Gbl.Hierarchy.Deg.DegCod,
|
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
|
||||||
break;
|
break;
|
||||||
case Ntf_EVENT_TL_COMMENT: // New comment to one of my social notes or comments
|
case Ntf_EVENT_TL_COMMENT: // New comment to one of my social notes or comments
|
||||||
// Cod is the code of the social publishing
|
// Cod is the code of the social publishing
|
||||||
NumUsrs = (unsigned)
|
NumUsrs = Tml_DB_GetPublishersInNoteExceptMe (&mysql_res,Cod);
|
||||||
DB_QuerySELECT (&mysql_res,"can not get users to be notified",
|
|
||||||
"SELECT DISTINCT(PublisherCod)"
|
|
||||||
" FROM tml_pubs"
|
|
||||||
" WHERE NotCod=(SELECT NotCod"
|
|
||||||
" FROM tml_pubs"
|
|
||||||
" WHERE PubCod=%ld)"
|
|
||||||
" AND PublisherCod<>%ld",
|
|
||||||
Cod,
|
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
|
||||||
break;
|
break;
|
||||||
case Ntf_EVENT_TL_FAV: // New favourite to one of my social notes or comments
|
case Ntf_EVENT_TL_FAV: // New favourite to one of my social notes or comments
|
||||||
case Ntf_EVENT_TL_SHARE: // New sharing of one of my social notes
|
case Ntf_EVENT_TL_SHARE: // New sharing of one of my social notes
|
||||||
|
@ -1189,84 +1097,23 @@ unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod)
|
||||||
switch (ForumSelected.Type)
|
switch (ForumSelected.Type)
|
||||||
{
|
{
|
||||||
case For_FORUM_COURSE_USRS:
|
case For_FORUM_COURSE_USRS:
|
||||||
NumUsrs = (unsigned)
|
NumUsrs = Enr_DB_GetUsrsFromCurrentCrsExceptMe (&mysql_res);
|
||||||
DB_QuerySELECT (&mysql_res,"can not get users to be notified",
|
|
||||||
"SELECT UsrCod"
|
|
||||||
" FROM crs_users"
|
|
||||||
" WHERE CrsCod=%ld"
|
|
||||||
" AND UsrCod<>%ld",
|
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
|
||||||
break;
|
break;
|
||||||
case For_FORUM_COURSE_TCHS:
|
case For_FORUM_COURSE_TCHS:
|
||||||
NumUsrs = (unsigned)
|
NumUsrs = Enr_DB_GetTchsFromCurrentCrsExceptMe (&mysql_res);
|
||||||
DB_QuerySELECT (&mysql_res,"can not get users to be notified",
|
|
||||||
"SELECT UsrCod"
|
|
||||||
" FROM crs_users"
|
|
||||||
" WHERE CrsCod=%ld"
|
|
||||||
" AND Role=%u"
|
|
||||||
" AND UsrCod<>%ld",
|
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
|
||||||
(unsigned) Rol_TCH,
|
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Ntf_EVENT_FORUM_REPLY:
|
case Ntf_EVENT_FORUM_REPLY:
|
||||||
NumUsrs = (unsigned)
|
// Cod is the code of the post
|
||||||
DB_QuerySELECT (&mysql_res,"can not get users to be notified",
|
NumUsrs = For_DB_GetPublishersInThreadExceptMe (&mysql_res,Cod);
|
||||||
"SELECT DISTINCT(UsrCod)"
|
|
||||||
" FROM for_posts"
|
|
||||||
" WHERE ThrCod=(SELECT ThrCod"
|
|
||||||
" FROM for_posts"
|
|
||||||
" WHERE PstCod=%ld)"
|
|
||||||
" AND UsrCod<>%ld",
|
|
||||||
Cod,
|
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
|
||||||
break;
|
break;
|
||||||
case Ntf_EVENT_MESSAGE: // This function should not be called in this case
|
case Ntf_EVENT_MESSAGE: // This function should not be called in this case
|
||||||
return 0;
|
return 0;
|
||||||
case Ntf_EVENT_SURVEY: // Only surveys for a course are notified, not surveys for a degree or global
|
case Ntf_EVENT_SURVEY: // Only surveys for a course are notified, not surveys for a degree or global
|
||||||
// 1. If the survey is available for the whole course ==> get users enroled in the course whose role is available in survey, except me
|
NumUsrs = Svy_DB_GetUsrsFromSurveyExceptMe (&mysql_res,Cod);
|
||||||
// 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
|
|
||||||
NumUsrs = (unsigned)
|
|
||||||
DB_QuerySELECT (&mysql_res,"can not get users to be notified",
|
|
||||||
"(SELECT crs_users.UsrCod"
|
|
||||||
" FROM svy_surveys,"
|
|
||||||
"crs_users"
|
|
||||||
" WHERE svy_surveys.SvyCod=%ld"
|
|
||||||
" AND svy_surveys.SvyCod NOT IN"
|
|
||||||
" (SELECT SvyCod"
|
|
||||||
" FROM svy_groups"
|
|
||||||
" WHERE SvyCod=%ld)"
|
|
||||||
" AND svy_surveys.Scope='%s'"
|
|
||||||
" AND svy_surveys.Cod=crs_users.CrsCod"
|
|
||||||
" AND crs_users.UsrCod<>%ld"
|
|
||||||
" AND (svy_surveys.Roles&(1<<crs_users.Role))<>0)"
|
|
||||||
" UNION "
|
|
||||||
"(SELECT DISTINCT grp_users.UsrCod"
|
|
||||||
" FROM svy_groups,"
|
|
||||||
"grp_users,"
|
|
||||||
"svy_surveys,"
|
|
||||||
"crs_users"
|
|
||||||
" WHERE svy_groups.SvyCod=%ld"
|
|
||||||
" AND svy_groups.GrpCod=grp_users.GrpCod"
|
|
||||||
" AND grp_users.UsrCod=crs_users.UsrCod"
|
|
||||||
" AND grp_users.UsrCod<>%ld"
|
|
||||||
" AND svy_groups.SvyCod=svy_surveys.SvyCod"
|
|
||||||
" AND svy_surveys.Scope='%s'"
|
|
||||||
" AND svy_surveys.Cod=crs_users.CrsCod"
|
|
||||||
" AND (svy_surveys.Roles&(1<<crs_users.Role))<>0)",
|
|
||||||
Cod,
|
|
||||||
Cod,
|
|
||||||
Sco_GetDBStrFromScope (HieLvl_CRS),
|
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
|
||||||
Cod,
|
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
|
||||||
Sco_GetDBStrFromScope (HieLvl_CRS));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1635,17 +1482,7 @@ static void Ntf_GetNumNotifSent (long DegCod,long CrsCod,
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
/***** Get number of notifications sent by email from database *****/
|
/***** Get number of notifications sent by email from database *****/
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not get number of notifications"
|
if (Ntf_DB_GetNumNotifSent (&mysql_res,DegCod,CrsCod,NotifyEvent))
|
||||||
" sent by email",
|
|
||||||
"SELECT NumEvents," // row[0]
|
|
||||||
"NumMails" // row[1]
|
|
||||||
" FROM sta_notifications"
|
|
||||||
" WHERE DegCod=%ld"
|
|
||||||
" AND CrsCod=%ld"
|
|
||||||
" AND NotifyEvent=%u",
|
|
||||||
DegCod,
|
|
||||||
CrsCod,
|
|
||||||
(unsigned) NotifyEvent))
|
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
if (sscanf (row[0],"%u",NumEvents) != 1)
|
if (sscanf (row[0],"%u",NumEvents) != 1)
|
||||||
|
@ -1661,7 +1498,7 @@ static void Ntf_GetNumNotifSent (long DegCod,long CrsCod,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******************** Update number of notify emails sent ********************/
|
/********** Update number of notifications and notify emails sent ************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Ntf_UpdateNumNotifSent (long DegCod,long CrsCod,
|
static void Ntf_UpdateNumNotifSent (long DegCod,long CrsCod,
|
||||||
|
@ -1674,15 +1511,8 @@ static void Ntf_UpdateNumNotifSent (long DegCod,long CrsCod,
|
||||||
/***** Get number of events notified and number of mails sent *****/
|
/***** Get number of events notified and number of mails sent *****/
|
||||||
Ntf_GetNumNotifSent (DegCod,CrsCod,NotifyEvent,&CurrentNumEvents,&CurrentNumMails);
|
Ntf_GetNumNotifSent (DegCod,CrsCod,NotifyEvent,&CurrentNumEvents,&CurrentNumMails);
|
||||||
|
|
||||||
/***** Update number of users notified *****/
|
/***** Update number of notifications and notify emails sent *****/
|
||||||
DB_QueryREPLACE ("can not update the number of sent notifications",
|
Ntf_DB_UpdateNumNotifSent (DegCod,CrsCod,NotifyEvent,
|
||||||
"REPLACE INTO sta_notifications"
|
|
||||||
" (DegCod,CrsCod,NotifyEvent,NumEvents,NumMails)"
|
|
||||||
" VALUES"
|
|
||||||
" (%ld,%ld,%u,%u,%u)",
|
|
||||||
DegCod,
|
|
||||||
CrsCod,
|
|
||||||
(unsigned) NotifyEvent,
|
|
||||||
CurrentNumEvents + NumEvents,
|
CurrentNumEvents + NumEvents,
|
||||||
CurrentNumMails + NumMails);
|
CurrentNumMails + NumMails);
|
||||||
}
|
}
|
||||||
|
@ -1694,12 +1524,7 @@ static void Ntf_UpdateNumNotifSent (long DegCod,long CrsCod,
|
||||||
void Ntf_MarkAllNotifAsSeen (void)
|
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",
|
Ntf_DB_MarkAllMyNotifAsSeen ();
|
||||||
"UPDATE ntf_notifications"
|
|
||||||
" SET Status=(Status | %u)"
|
|
||||||
" WHERE ToUsrCod=%ld",
|
|
||||||
(unsigned) Ntf_STATUS_BIT_READ,
|
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
|
||||||
|
|
||||||
/***** Show my notifications again *****/
|
/***** Show my notifications again *****/
|
||||||
Ntf_ShowMyNotifications ();
|
Ntf_ShowMyNotifications ();
|
||||||
|
@ -1829,14 +1654,7 @@ void Ntf_ChangeNotifyEvents (void)
|
||||||
Ntf_GetParamsNotifyEvents ();
|
Ntf_GetParamsNotifyEvents ();
|
||||||
|
|
||||||
/***** Store settings about notify events *****/
|
/***** Store settings about notify events *****/
|
||||||
DB_QueryUPDATE ("can not update user's settings",
|
Set_DB_UpdateMySettingsAboutNotifyEvents ();
|
||||||
"UPDATE usr_data"
|
|
||||||
" SET NotifNtfEvents=%u,"
|
|
||||||
"EmailNtfEvents=%u"
|
|
||||||
" WHERE UsrCod=%ld",
|
|
||||||
Gbl.Usrs.Me.UsrDat.NtfEvents.CreateNotif,
|
|
||||||
Gbl.Usrs.Me.UsrDat.NtfEvents.SendEmail,
|
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
|
||||||
|
|
||||||
/***** Show message *****/
|
/***** Show message *****/
|
||||||
Ale_ShowAlert (Ale_SUCCESS,Txt_Your_settings_about_notifications_have_changed);
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Your_settings_about_notifications_have_changed);
|
||||||
|
|
|
@ -88,6 +88,20 @@ void Ntf_DB_UpdateMyLastAccessToNotifications (void)
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******************** Mark all my notifications as seen **********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Ntf_DB_MarkAllMyNotifAsSeen (void)
|
||||||
|
{
|
||||||
|
DB_QueryUPDATE ("can not set notification(s) as seen",
|
||||||
|
"UPDATE ntf_notifications"
|
||||||
|
" SET Status=(Status | %u)"
|
||||||
|
" WHERE ToUsrCod=%ld",
|
||||||
|
(unsigned) Ntf_STATUS_BIT_READ,
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/********** Mark all the pending notifications of a user as 'sent' ***********/
|
/********** Mark all the pending notifications of a user as 'sent' ***********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -288,6 +302,47 @@ void Ntf_DB_MarkNotifChildrenOfFolderAsRemoved (Ntf_NotifyEvent_t NotifyEvent,
|
||||||
Path);
|
Path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******************** Update number of notify emails sent ********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Ntf_DB_UpdateNumNotifSent (long DegCod,long CrsCod,
|
||||||
|
Ntf_NotifyEvent_t NotifyEvent,
|
||||||
|
unsigned NumEvents,unsigned NumMails)
|
||||||
|
{
|
||||||
|
DB_QueryREPLACE ("can not update the number of sent notifications",
|
||||||
|
"REPLACE INTO sta_notifications"
|
||||||
|
" (DegCod,CrsCod,NotifyEvent,NumEvents,NumMails)"
|
||||||
|
" VALUES"
|
||||||
|
" (%ld,%ld,%u,%u,%u)",
|
||||||
|
DegCod,
|
||||||
|
CrsCod,
|
||||||
|
(unsigned) NotifyEvent,
|
||||||
|
NumEvents,
|
||||||
|
NumMails);
|
||||||
|
}
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************* Get number of events notified and emails sent *****************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Ntf_DB_GetNumNotifSent (MYSQL_RES **mysql_res,
|
||||||
|
long DegCod,long CrsCod,
|
||||||
|
Ntf_NotifyEvent_t NotifyEvent)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get number of notifications"
|
||||||
|
" sent by email",
|
||||||
|
"SELECT NumEvents," // row[0]
|
||||||
|
"NumMails" // row[1]
|
||||||
|
" FROM sta_notifications"
|
||||||
|
" WHERE DegCod=%ld"
|
||||||
|
" AND CrsCod=%ld"
|
||||||
|
" AND NotifyEvent=%u",
|
||||||
|
DegCod,
|
||||||
|
CrsCod,
|
||||||
|
(unsigned) NotifyEvent);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*************************** Get my notifications ***************************/
|
/*************************** Get my notifications ***************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -48,6 +48,7 @@ void Ntf_DB_StoreNotifyEventToOneUser (Ntf_NotifyEvent_t NotifyEvent,
|
||||||
long Cod,Ntf_Status_t Status,
|
long Cod,Ntf_Status_t Status,
|
||||||
long InsCod,long CtrCod,long DegCod,long CrsCod);
|
long InsCod,long CtrCod,long DegCod,long CrsCod);
|
||||||
void Ntf_DB_UpdateMyLastAccessToNotifications (void);
|
void Ntf_DB_UpdateMyLastAccessToNotifications (void);
|
||||||
|
void Ntf_DB_MarkAllMyNotifAsSeen (void);
|
||||||
void Ntf_DB_MarkPendingNtfsAsSent (long ToUsrCod);
|
void Ntf_DB_MarkPendingNtfsAsSent (long ToUsrCod);
|
||||||
void Ntf_DB_MarkNotifAsSeen (Ntf_NotifyEvent_t NotifyEvent,long Cod,long CrsCod,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_MarkNotifToOneUsrAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod,long ToUsrCod);
|
||||||
|
@ -57,7 +58,13 @@ void Ntf_DB_MarkNotifFilesInGroupAsRemoved (long GrpCod);
|
||||||
void Ntf_DB_MarkNotifChildrenOfFolderAsRemoved (Ntf_NotifyEvent_t NotifyEvent,
|
void Ntf_DB_MarkNotifChildrenOfFolderAsRemoved (Ntf_NotifyEvent_t NotifyEvent,
|
||||||
Brw_FileBrowser_t FileBrowser,
|
Brw_FileBrowser_t FileBrowser,
|
||||||
long Cod,const char *Path);
|
long Cod,const char *Path);
|
||||||
|
void Ntf_DB_UpdateNumNotifSent (long DegCod,long CrsCod,
|
||||||
|
Ntf_NotifyEvent_t NotifyEvent,
|
||||||
|
unsigned NumEvents,unsigned NumMails);
|
||||||
|
|
||||||
|
unsigned Ntf_DB_GetNumNotifSent (MYSQL_RES **mysql_res,
|
||||||
|
long DegCod,long CrsCod,
|
||||||
|
Ntf_NotifyEvent_t NotifyEvent);
|
||||||
unsigned Ntf_DB_GetMyNotifications (MYSQL_RES **mysql_res,bool AllNotifications);
|
unsigned Ntf_DB_GetMyNotifications (MYSQL_RES **mysql_res,bool AllNotifications);
|
||||||
unsigned Ntf_DB_GetPendingNtfsToUsr (MYSQL_RES **mysql_res,long ToUsrCod);
|
unsigned Ntf_DB_GetPendingNtfsToUsr (MYSQL_RES **mysql_res,long ToUsrCod);
|
||||||
unsigned Ntf_DB_GetNumAllMyUnseenNtfs (void);
|
unsigned Ntf_DB_GetNumAllMyUnseenNtfs (void);
|
||||||
|
|
|
@ -919,33 +919,12 @@ unsigned Pag_GetParamPagNum (Pag_WhatPaginate_t WhatPaginate)
|
||||||
return CurrentPage;
|
return CurrentPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/********* Save last page of received/sent messages into session *************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
void Pag_DB_SaveLastPageMsgIntoSession (Pag_WhatPaginate_t WhatPaginate,unsigned NumPage)
|
|
||||||
{
|
|
||||||
/***** Save last page of received/sent messages *****/
|
|
||||||
DB_QueryUPDATE ("can not update last page of messages",
|
|
||||||
"UPDATE ses_sessions"
|
|
||||||
" SET %s=%u"
|
|
||||||
" WHERE SessionId='%s'",
|
|
||||||
WhatPaginate == Pag_MESSAGES_RECEIVED ? "LastPageMsgRcv" :
|
|
||||||
"LastPageMsgSnt",
|
|
||||||
NumPage,Gbl.Session.Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/********* Get last page of received/sent messages stored in session *********/
|
/********* Get last page of received/sent messages stored in session *********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned Pag_GetLastPageMsgFromSession (Pag_WhatPaginate_t WhatPaginate)
|
unsigned Pag_GetLastPageMsgFromSession (Pag_WhatPaginate_t WhatPaginate)
|
||||||
{
|
{
|
||||||
static const char *Field[Pag_NUM_WHAT_PAGINATE] =
|
|
||||||
{
|
|
||||||
[Pag_MESSAGES_RECEIVED] = "LastPageMsgRcv",
|
|
||||||
[Pag_MESSAGES_SENT ] = "LastPageMsgSnt",
|
|
||||||
};
|
|
||||||
unsigned NumPage;
|
unsigned NumPage;
|
||||||
|
|
||||||
switch (WhatPaginate)
|
switch (WhatPaginate)
|
||||||
|
@ -953,13 +932,7 @@ unsigned Pag_GetLastPageMsgFromSession (Pag_WhatPaginate_t WhatPaginate)
|
||||||
case Pag_MESSAGES_RECEIVED:
|
case Pag_MESSAGES_RECEIVED:
|
||||||
case Pag_MESSAGES_SENT:
|
case Pag_MESSAGES_SENT:
|
||||||
/***** Get last page of received/sent messages from database *****/
|
/***** Get last page of received/sent messages from database *****/
|
||||||
NumPage = DB_QuerySELECTUnsigned ("can not get last page of messages",
|
if ((NumPage = Ses_DB_GetLastPageMsgFromSession (WhatPaginate)) == 0)
|
||||||
"SELECT %s"
|
|
||||||
" FROM ses_sessions"
|
|
||||||
" WHERE SessionId='%s'",
|
|
||||||
Field[WhatPaginate],
|
|
||||||
Gbl.Session.Id);
|
|
||||||
if (NumPage == 0)
|
|
||||||
return 1;
|
return 1;
|
||||||
return NumPage;
|
return NumPage;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -89,7 +89,6 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
|
||||||
void Pag_PutHiddenParamPagNum (Pag_WhatPaginate_t WhatPaginate,unsigned NumPage);
|
void Pag_PutHiddenParamPagNum (Pag_WhatPaginate_t WhatPaginate,unsigned NumPage);
|
||||||
unsigned Pag_GetParamPagNum (Pag_WhatPaginate_t WhatPaginate);
|
unsigned Pag_GetParamPagNum (Pag_WhatPaginate_t WhatPaginate);
|
||||||
|
|
||||||
void Pag_DB_SaveLastPageMsgIntoSession (Pag_WhatPaginate_t WhatPaginate,unsigned NumPage);
|
|
||||||
unsigned Pag_GetLastPageMsgFromSession (Pag_WhatPaginate_t WhatPaginate);
|
unsigned Pag_GetLastPageMsgFromSession (Pag_WhatPaginate_t WhatPaginate);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "swad_database.h"
|
#include "swad_database.h"
|
||||||
#include "swad_error.h"
|
#include "swad_error.h"
|
||||||
#include "swad_global.h"
|
#include "swad_global.h"
|
||||||
|
#include "swad_pagination.h"
|
||||||
#include "swad_parameter.h"
|
#include "swad_parameter.h"
|
||||||
#include "swad_timeline_database.h"
|
#include "swad_timeline_database.h"
|
||||||
|
|
||||||
|
@ -214,12 +215,11 @@ void Ses_UpdateSessionDataInDB (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******************** Modify session last refresh in database ****************/
|
/******************** Update session last refresh in database ****************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Ses_UpdateSessionLastRefreshInDB (void)
|
void Ses_DB_UpdateSessionLastRefresh (void)
|
||||||
{
|
{
|
||||||
/***** Update session in database *****/
|
|
||||||
DB_QueryUPDATE ("can not update session",
|
DB_QueryUPDATE ("can not update session",
|
||||||
"UPDATE ses_sessions"
|
"UPDATE ses_sessions"
|
||||||
" SET LastRefresh=NOW()"
|
" SET LastRefresh=NOW()"
|
||||||
|
@ -248,7 +248,7 @@ static void Ses_RemoveSessionFromDB (void)
|
||||||
/*************************** Remove expired sessions *************************/
|
/*************************** Remove expired sessions *************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Ses_RemoveExpiredSessions (void)
|
void Ses_DB_RemoveExpiredSessions (void)
|
||||||
{
|
{
|
||||||
/***** Remove expired sessions *****/
|
/***** Remove expired sessions *****/
|
||||||
/* A session expire
|
/* A session expire
|
||||||
|
@ -560,3 +560,39 @@ void Ses_RemovePublicDirsFromExpiredSessions (void)
|
||||||
" (SELECT SessionId"
|
" (SELECT SessionId"
|
||||||
" FROM ses_sessions)");
|
" FROM ses_sessions)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********* Save last page of received/sent messages into session *************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Ses_DB_SaveLastPageMsgIntoSession (Pag_WhatPaginate_t WhatPaginate,unsigned NumPage)
|
||||||
|
{
|
||||||
|
/***** Save last page of received/sent messages *****/
|
||||||
|
DB_QueryUPDATE ("can not update last page of messages",
|
||||||
|
"UPDATE ses_sessions"
|
||||||
|
" SET %s=%u"
|
||||||
|
" WHERE SessionId='%s'",
|
||||||
|
WhatPaginate == Pag_MESSAGES_RECEIVED ? "LastPageMsgRcv" :
|
||||||
|
"LastPageMsgSnt",
|
||||||
|
NumPage,Gbl.Session.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********* Get last page of received/sent messages stored in session *********/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Ses_DB_GetLastPageMsgFromSession (Pag_WhatPaginate_t WhatPaginate)
|
||||||
|
{
|
||||||
|
static const char *Field[Pag_NUM_WHAT_PAGINATE] =
|
||||||
|
{
|
||||||
|
[Pag_MESSAGES_RECEIVED] = "LastPageMsgRcv",
|
||||||
|
[Pag_MESSAGES_SENT ] = "LastPageMsgSnt",
|
||||||
|
};
|
||||||
|
|
||||||
|
return DB_QuerySELECTUnsigned ("can not get last page of messages",
|
||||||
|
"SELECT %s"
|
||||||
|
" FROM ses_sessions"
|
||||||
|
" WHERE SessionId='%s'",
|
||||||
|
Field[WhatPaginate],
|
||||||
|
Gbl.Session.Id);
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#include "swad_action.h"
|
#include "swad_action.h"
|
||||||
|
#include "swad_pagination.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***************************** Public constants ******************************/
|
/***************************** Public constants ******************************/
|
||||||
|
@ -43,8 +44,8 @@ bool Ses_CheckIfSessionExists (const char *IdSes);
|
||||||
void Ses_CloseSession (void);
|
void Ses_CloseSession (void);
|
||||||
void Ses_InsertSessionInDB (void);
|
void Ses_InsertSessionInDB (void);
|
||||||
void Ses_UpdateSessionDataInDB (void);
|
void Ses_UpdateSessionDataInDB (void);
|
||||||
void Ses_UpdateSessionLastRefreshInDB (void);
|
void Ses_DB_UpdateSessionLastRefresh (void);
|
||||||
void Ses_RemoveExpiredSessions (void);
|
void Ses_DB_RemoveExpiredSessions (void);
|
||||||
void Ses_DB_RemoveUsrSessions (long UsrCod);
|
void Ses_DB_RemoveUsrSessions (long UsrCod);
|
||||||
bool Ses_GetSessionData (void);
|
bool Ses_GetSessionData (void);
|
||||||
|
|
||||||
|
@ -60,4 +61,7 @@ void Ses_AddPublicDirToCache (const char *FullPathMediaPriv,
|
||||||
void Ses_RemovePublicDirsCache (void);
|
void Ses_RemovePublicDirsCache (void);
|
||||||
void Ses_RemovePublicDirsFromExpiredSessions (void);
|
void Ses_RemovePublicDirsFromExpiredSessions (void);
|
||||||
|
|
||||||
|
void Ses_DB_SaveLastPageMsgIntoSession (Pag_WhatPaginate_t WhatPaginate,unsigned NumPage);
|
||||||
|
unsigned Ses_DB_GetLastPageMsgFromSession (Pag_WhatPaginate_t WhatPaginate);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -373,7 +373,7 @@ void Set_DB_UpdateMySettingsAboutDateFormat (Dat_Format_t DateFormat)
|
||||||
/***************** Update my settings about first day of week ****************/
|
/***************** Update my settings about first day of week ****************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Set_DB_ChangeFirstDayOfWeek (unsigned FirstDayOfWeek)
|
void Set_DB_UpdateMySettingsAboutFirstDayOfWeek (unsigned FirstDayOfWeek)
|
||||||
{
|
{
|
||||||
DB_QueryUPDATE ("can not update your setting about first day of week",
|
DB_QueryUPDATE ("can not update your setting about first day of week",
|
||||||
"UPDATE usr_data"
|
"UPDATE usr_data"
|
||||||
|
@ -387,7 +387,7 @@ void Set_DB_ChangeFirstDayOfWeek (unsigned FirstDayOfWeek)
|
||||||
/********************* Update my settings about icon set *********************/
|
/********************* Update my settings about icon set *********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Set_DB_ChangeIconSet (const char *IconSetId)
|
void Set_DB_UpdateMySettingsAboutIconSet (const char *IconSetId)
|
||||||
{
|
{
|
||||||
DB_QueryUPDATE ("can not update your setting about icon set",
|
DB_QueryUPDATE ("can not update your setting about icon set",
|
||||||
"UPDATE usr_data"
|
"UPDATE usr_data"
|
||||||
|
@ -401,7 +401,7 @@ void Set_DB_ChangeIconSet (const char *IconSetId)
|
||||||
/***************** Update my settings about first day of week ****************/
|
/***************** Update my settings about first day of week ****************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Set_DB_ChangeMenu (Mnu_Menu_t Menu)
|
void Set_DB_UpdateMySettingsAboutMenu (Mnu_Menu_t Menu)
|
||||||
{
|
{
|
||||||
DB_QueryUPDATE ("can not update your setting about menu",
|
DB_QueryUPDATE ("can not update your setting about menu",
|
||||||
"UPDATE usr_data"
|
"UPDATE usr_data"
|
||||||
|
@ -411,6 +411,22 @@ void Set_DB_ChangeMenu (Mnu_Menu_t Menu)
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******************* Update my settings about notify events ******************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Set_DB_UpdateMySettingsAboutNotifyEvents (void)
|
||||||
|
{
|
||||||
|
DB_QueryUPDATE ("can not update user's settings",
|
||||||
|
"UPDATE usr_data"
|
||||||
|
" SET NotifNtfEvents=%u,"
|
||||||
|
"EmailNtfEvents=%u"
|
||||||
|
" WHERE UsrCod=%ld",
|
||||||
|
Gbl.Usrs.Me.UsrDat.NtfEvents.CreateNotif,
|
||||||
|
Gbl.Usrs.Me.UsrDat.NtfEvents.SendEmail,
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*********** Head to select one or several settings using icons **************/
|
/*********** Head to select one or several settings using icons **************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -52,9 +52,10 @@ unsigned Set_GetParamSideCols (void);
|
||||||
|
|
||||||
void Set_DB_UpdateMySettingsAboutLanguage (void);
|
void Set_DB_UpdateMySettingsAboutLanguage (void);
|
||||||
void Set_DB_UpdateMySettingsAboutDateFormat (Dat_Format_t DateFormat);
|
void Set_DB_UpdateMySettingsAboutDateFormat (Dat_Format_t DateFormat);
|
||||||
void Set_DB_ChangeFirstDayOfWeek (unsigned FirstDayOfWeek);
|
void Set_DB_UpdateMySettingsAboutFirstDayOfWeek (unsigned FirstDayOfWeek);
|
||||||
void Set_DB_ChangeIconSet (const char *IconSetId);
|
void Set_DB_UpdateMySettingsAboutIconSet (const char *IconSetId);
|
||||||
void Set_DB_ChangeMenu (Mnu_Menu_t Menu);
|
void Set_DB_UpdateMySettingsAboutMenu (Mnu_Menu_t Menu);
|
||||||
|
void Set_DB_UpdateMySettingsAboutNotifyEvents (void);
|
||||||
|
|
||||||
void Set_BeginSettingsHead (void);
|
void Set_BeginSettingsHead (void);
|
||||||
void Set_EndSettingsHead (void);
|
void Set_EndSettingsHead (void);
|
||||||
|
|
|
@ -4241,3 +4241,49 @@ double Svy_GetNumQstsPerCrsSurvey (HieLvl_Level_t Scope)
|
||||||
return 0.0; // Not reached
|
return 0.0; // Not reached
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************ Get all user codes belonging to a survey, except me ************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Svy_DB_GetUsrsFromSurveyExceptMe (MYSQL_RES **mysql_res,long SvyCod)
|
||||||
|
{
|
||||||
|
// 1. If the survey is available for the whole course ==> get users enroled in the course whose role is available in survey, except me
|
||||||
|
// 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
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get users to be notified",
|
||||||
|
"(SELECT crs_users.UsrCod"
|
||||||
|
" FROM svy_surveys,"
|
||||||
|
"crs_users"
|
||||||
|
" WHERE svy_surveys.SvyCod=%ld"
|
||||||
|
" AND svy_surveys.SvyCod NOT IN"
|
||||||
|
" (SELECT SvyCod"
|
||||||
|
" FROM svy_groups"
|
||||||
|
" WHERE SvyCod=%ld)"
|
||||||
|
" AND svy_surveys.Scope='%s'"
|
||||||
|
" AND svy_surveys.Cod=crs_users.CrsCod"
|
||||||
|
" AND crs_users.UsrCod<>%ld"
|
||||||
|
" AND (svy_surveys.Roles&(1<<crs_users.Role))<>0)"
|
||||||
|
" UNION "
|
||||||
|
"(SELECT DISTINCT grp_users.UsrCod"
|
||||||
|
" FROM svy_groups,"
|
||||||
|
"grp_users,"
|
||||||
|
"svy_surveys,"
|
||||||
|
"crs_users"
|
||||||
|
" WHERE svy_groups.SvyCod=%ld"
|
||||||
|
" AND svy_groups.GrpCod=grp_users.GrpCod"
|
||||||
|
" AND grp_users.UsrCod=crs_users.UsrCod"
|
||||||
|
" AND grp_users.UsrCod<>%ld"
|
||||||
|
" AND svy_groups.SvyCod=svy_surveys.SvyCod"
|
||||||
|
" AND svy_surveys.Scope='%s'"
|
||||||
|
" AND svy_surveys.Cod=crs_users.CrsCod"
|
||||||
|
" AND (svy_surveys.Roles&(1<<crs_users.Role))<>0)",
|
||||||
|
SvyCod,
|
||||||
|
SvyCod,
|
||||||
|
Sco_GetDBStrFromScope (HieLvl_CRS),
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
|
SvyCod,
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
|
Sco_GetDBStrFromScope (HieLvl_CRS));
|
||||||
|
}
|
||||||
|
|
|
@ -124,4 +124,6 @@ unsigned Svy_GetNumCoursesWithCrsSurveys (HieLvl_Level_t Scope);
|
||||||
unsigned Svy_GetNumCrsSurveys (HieLvl_Level_t Scope,unsigned *NumNotif);
|
unsigned Svy_GetNumCrsSurveys (HieLvl_Level_t Scope,unsigned *NumNotif);
|
||||||
double Svy_GetNumQstsPerCrsSurvey (HieLvl_Level_t Scope);
|
double Svy_GetNumQstsPerCrsSurvey (HieLvl_Level_t Scope);
|
||||||
|
|
||||||
|
unsigned Svy_DB_GetUsrsFromSurveyExceptMe (MYSQL_RES **mysql_res,long SvyCod);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1097,6 +1097,24 @@ unsigned Tml_DB_GetNumPubsUsr (long UsrCod)
|
||||||
UsrCod);
|
UsrCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************** Get all publisher codes in a note, except me *****************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Tml_DB_GetPublishersInNoteExceptMe (MYSQL_RES **mysql_res,long PubCod)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get publishers of a note",
|
||||||
|
"SELECT DISTINCT(PublisherCod)"
|
||||||
|
" FROM tml_pubs"
|
||||||
|
" WHERE NotCod=(SELECT NotCod"
|
||||||
|
" FROM tml_pubs"
|
||||||
|
" WHERE PubCod=%ld)"
|
||||||
|
" AND PublisherCod<>%ld",
|
||||||
|
PubCod,
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/********************* Insert new publication in database ********************/
|
/********************* Insert new publication in database ********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -117,6 +117,7 @@ unsigned Tml_DB_GetDataOfPubByCod (long PubCod,MYSQL_RES **mysql_res);
|
||||||
long Tml_DB_GetNotCodFromPubCod (long PubCod);
|
long Tml_DB_GetNotCodFromPubCod (long PubCod);
|
||||||
long Tml_DB_GetPubCodFromSession (const char *FieldName);
|
long Tml_DB_GetPubCodFromSession (const char *FieldName);
|
||||||
unsigned Tml_DB_GetNumPubsUsr (long UsrCod);
|
unsigned Tml_DB_GetNumPubsUsr (long UsrCod);
|
||||||
|
unsigned Tml_DB_GetPublishersInNoteExceptMe (MYSQL_RES **mysql_res,long PubCod);
|
||||||
long Tml_DB_CreateNewPub (const struct Tml_Pub_Publication *Pub);
|
long Tml_DB_CreateNewPub (const struct Tml_Pub_Publication *Pub);
|
||||||
void Tml_DB_UpdateFirstPubCodInSession (long FirstPubCod);
|
void Tml_DB_UpdateFirstPubCodInSession (long FirstPubCod);
|
||||||
void Tml_DB_UpdateLastPubCodInSession (void);
|
void Tml_DB_UpdateLastPubCodInSession (void);
|
||||||
|
|
|
@ -3105,7 +3105,7 @@ void Usr_ChkUsrAndGetUsrData (void)
|
||||||
Usr_SetMyPrefsAndRoles ();
|
Usr_SetMyPrefsAndRoles ();
|
||||||
|
|
||||||
if (Gbl.Action.IsAJAXAutoRefresh) // If refreshing ==> don't refresh LastTime in session
|
if (Gbl.Action.IsAJAXAutoRefresh) // If refreshing ==> don't refresh LastTime in session
|
||||||
Ses_UpdateSessionLastRefreshInDB ();
|
Ses_DB_UpdateSessionLastRefresh ();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Act_AdjustCurrentAction ();
|
Act_AdjustCurrentAction ();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user