mirror of
https://github.com/acanas/swad-core.git
synced 2024-06-16 13:44:06 +02:00
Version 18.8.6
This commit is contained in:
parent
1707123a8b
commit
90e2b164ea
12
swad_ID.c
12
swad_ID.c
|
@ -88,7 +88,6 @@ static void ID_InsertANewUsrIDInDB (long UsrCod,const char *NewID,bool Confirmed
|
||||||
|
|
||||||
void ID_GetListIDsFromUsrCod (struct UsrData *UsrDat)
|
void ID_GetListIDsFromUsrCod (struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumIDs;
|
unsigned NumIDs;
|
||||||
|
@ -102,12 +101,11 @@ void ID_GetListIDsFromUsrCod (struct UsrData *UsrDat)
|
||||||
/***** Get user's IDs from database *****/
|
/***** Get user's IDs from database *****/
|
||||||
// First the confirmed (Confirmed == 'Y')
|
// First the confirmed (Confirmed == 'Y')
|
||||||
// Then the unconfirmed (Confirmed == 'N')
|
// Then the unconfirmed (Confirmed == 'N')
|
||||||
if (asprintf (&Query,"SELECT UsrID,Confirmed FROM usr_IDs"
|
DB_BuildQuery ("SELECT UsrID,Confirmed FROM usr_IDs"
|
||||||
" WHERE UsrCod=%ld"
|
" WHERE UsrCod=%ld"
|
||||||
" ORDER BY Confirmed DESC,UsrID",
|
" ORDER BY Confirmed DESC,UsrID",
|
||||||
UsrDat->UsrCod) < 0)
|
UsrDat->UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
if ((NumIDs = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get user's IDs")))
|
||||||
if ((NumIDs = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get user's IDs")))
|
|
||||||
{
|
{
|
||||||
/***** Allocate space for the list *****/
|
/***** Allocate space for the list *****/
|
||||||
ID_ReallocateListIDs (UsrDat,NumIDs);
|
ID_ReallocateListIDs (UsrDat,NumIDs);
|
||||||
|
|
31
swad_MFU.c
31
swad_MFU.c
|
@ -100,7 +100,6 @@ void MFU_FreeMFUActions (struct MFU_ListMFUActions *ListMFUActions)
|
||||||
void MFU_GetMFUActions (struct MFU_ListMFUActions *ListMFUActions,unsigned MaxActionsShown)
|
void MFU_GetMFUActions (struct MFU_ListMFUActions *ListMFUActions,unsigned MaxActionsShown)
|
||||||
{
|
{
|
||||||
extern Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD];
|
extern Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD];
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRow,NumRows;
|
unsigned long NumRow,NumRows;
|
||||||
|
@ -108,11 +107,10 @@ void MFU_GetMFUActions (struct MFU_ListMFUActions *ListMFUActions,unsigned MaxAc
|
||||||
Act_Action_t Action;
|
Act_Action_t Action;
|
||||||
|
|
||||||
/***** Get most frequently used actions *****/
|
/***** Get most frequently used actions *****/
|
||||||
if (asprintf (&Query,"SELECT ActCod FROM actions_MFU"
|
DB_BuildQuery ("SELECT ActCod FROM actions_MFU"
|
||||||
" WHERE UsrCod=%ld ORDER BY Score DESC,LastClick DESC",
|
" WHERE UsrCod=%ld ORDER BY Score DESC,LastClick DESC",
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get most frequently used actions");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get most frequently used actions");
|
|
||||||
|
|
||||||
/***** Write list of frequently used actions *****/
|
/***** Write list of frequently used actions *****/
|
||||||
for (NumRow = 0, ListMFUActions->NumActions = 0;
|
for (NumRow = 0, ListMFUActions->NumActions = 0;
|
||||||
|
@ -141,7 +139,6 @@ void MFU_GetMFUActions (struct MFU_ListMFUActions *ListMFUActions,unsigned MaxAc
|
||||||
Act_Action_t MFU_GetMyLastActionInCurrentTab (void)
|
Act_Action_t MFU_GetMyLastActionInCurrentTab (void)
|
||||||
{
|
{
|
||||||
extern Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD];
|
extern Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD];
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumActions;
|
unsigned NumActions;
|
||||||
|
@ -153,12 +150,11 @@ Act_Action_t MFU_GetMyLastActionInCurrentTab (void)
|
||||||
if (Gbl.Usrs.Me.UsrDat.UsrCod > 0)
|
if (Gbl.Usrs.Me.UsrDat.UsrCod > 0)
|
||||||
{
|
{
|
||||||
/***** Get my most frequently used actions *****/
|
/***** Get my most frequently used actions *****/
|
||||||
if (asprintf (&Query,"SELECT ActCod FROM actions_MFU"
|
DB_BuildQuery ("SELECT ActCod FROM actions_MFU"
|
||||||
" WHERE UsrCod=%ld"
|
" WHERE UsrCod=%ld"
|
||||||
" ORDER BY LastClick DESC,Score DESC",
|
" ORDER BY LastClick DESC,Score DESC",
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumActions = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get most frequently used actions");
|
||||||
NumActions = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get most frequently used actions");
|
|
||||||
|
|
||||||
/***** Loop over list of frequently used actions *****/
|
/***** Loop over list of frequently used actions *****/
|
||||||
for (NumAct = 0;
|
for (NumAct = 0;
|
||||||
|
@ -357,11 +353,10 @@ void MFU_UpdateMFUActions (void)
|
||||||
Str_SetDecimalPointToUS (); // To get the decimal point as a dot
|
Str_SetDecimalPointToUS (); // To get the decimal point as a dot
|
||||||
|
|
||||||
/***** Get current score *****/
|
/***** Get current score *****/
|
||||||
if (asprintf (&Query,"SELECT Score FROM actions_MFU"
|
DB_BuildQuery ("SELECT Score FROM actions_MFU"
|
||||||
" WHERE UsrCod=%ld AND ActCod=%ld",
|
" WHERE UsrCod=%ld AND ActCod=%ld",
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,ActCod) < 0)
|
Gbl.Usrs.Me.UsrDat.UsrCod,ActCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
if (DB_QuerySELECT_new (&mysql_res,"can not get score for current action"))
|
||||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get score for current action"))
|
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
if (sscanf (row[0],"%f",&Score) != 1)
|
if (sscanf (row[0],"%f",&Score) != 1)
|
||||||
|
|
32
swad_RSS.c
32
swad_RSS.c
|
@ -150,7 +150,6 @@ void RSS_UpdateRSSFileForACrs (struct Course *Crs)
|
||||||
static void RSS_WriteNotices (FILE *FileRSS,struct Course *Crs)
|
static void RSS_WriteNotices (FILE *FileRSS,struct Course *Crs)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Notice;
|
extern const char *Txt_Notice;
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
struct UsrData UsrDat;
|
struct UsrData UsrDat;
|
||||||
|
@ -161,13 +160,12 @@ static void RSS_WriteNotices (FILE *FileRSS,struct Course *Crs)
|
||||||
char Content[Cns_MAX_BYTES_TEXT + 1];
|
char Content[Cns_MAX_BYTES_TEXT + 1];
|
||||||
|
|
||||||
/***** Get active notices in course *****/
|
/***** Get active notices in course *****/
|
||||||
if (asprintf (&Query,"SELECT NotCod,UNIX_TIMESTAMP(CreatTime) AS T,UsrCod,Content"
|
DB_BuildQuery ("SELECT NotCod,UNIX_TIMESTAMP(CreatTime) AS T,UsrCod,Content"
|
||||||
" FROM notices"
|
" FROM notices"
|
||||||
" WHERE CrsCod=%ld AND Status=%u"
|
" WHERE CrsCod=%ld AND Status=%u"
|
||||||
" ORDER BY T DESC",
|
" ORDER BY T DESC",
|
||||||
Crs->CrsCod,(unsigned) Not_ACTIVE_NOTICE) < 0)
|
Crs->CrsCod,(unsigned) Not_ACTIVE_NOTICE);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumNotices = DB_QuerySELECT_new (&mysql_res,"can not get notices from database");
|
||||||
NumNotices = DB_QuerySELECT_free (Query,&mysql_res,"can not get notices from database");
|
|
||||||
|
|
||||||
/***** Write items with notices *****/
|
/***** Write items with notices *****/
|
||||||
if (NumNotices)
|
if (NumNotices)
|
||||||
|
@ -248,7 +246,6 @@ static void RSS_WriteNotices (FILE *FileRSS,struct Course *Crs)
|
||||||
static void RSS_WriteExamAnnouncements (FILE *FileRSS,struct Course *Crs)
|
static void RSS_WriteExamAnnouncements (FILE *FileRSS,struct Course *Crs)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Exam;
|
extern const char *Txt_Exam;
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
struct UsrData UsrDat;
|
struct UsrData UsrDat;
|
||||||
|
@ -260,15 +257,14 @@ static void RSS_WriteExamAnnouncements (FILE *FileRSS,struct Course *Crs)
|
||||||
if (Gbl.DB.DatabaseIsOpen)
|
if (Gbl.DB.DatabaseIsOpen)
|
||||||
{
|
{
|
||||||
/***** Get exam announcements (only future exams) in current course from database *****/
|
/***** Get exam announcements (only future exams) in current course from database *****/
|
||||||
if (asprintf (&Query,"SELECT ExaCod,UNIX_TIMESTAMP(CallDate) AS T,"
|
DB_BuildQuery ("SELECT ExaCod,UNIX_TIMESTAMP(CallDate) AS T,"
|
||||||
"DATE_FORMAT(ExamDate,'%%d/%%m/%%Y %%H:%%i')"
|
"DATE_FORMAT(ExamDate,'%%d/%%m/%%Y %%H:%%i')"
|
||||||
" FROM exam_announcements"
|
" FROM exam_announcements"
|
||||||
" WHERE CrsCod=%ld AND Status=%u AND ExamDate>=NOW()"
|
" WHERE CrsCod=%ld AND Status=%u AND ExamDate>=NOW()"
|
||||||
" ORDER BY T",
|
" ORDER BY T",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
(unsigned) Exa_VISIBLE_EXAM_ANNOUNCEMENT) < 0)
|
(unsigned) Exa_VISIBLE_EXAM_ANNOUNCEMENT);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumExamAnnouncements = DB_QuerySELECT_new (&mysql_res,"can not get exam announcements");
|
||||||
NumExamAnnouncements = DB_QuerySELECT_free (Query,&mysql_res,"can not get exam announcements");
|
|
||||||
|
|
||||||
/***** Write items with notices *****/
|
/***** Write items with notices *****/
|
||||||
if (NumExamAnnouncements)
|
if (NumExamAnnouncements)
|
||||||
|
|
|
@ -355,10 +355,11 @@ En OpenSWAD:
|
||||||
ps2pdf source.ps destination.pdf
|
ps2pdf source.ps destination.pdf
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 18.8.5 (2018-10-26)"
|
#define Log_PLATFORM_VERSION "SWAD 18.8.6 (2018-10-26)"
|
||||||
#define CSS_FILE "swad18.4.css"
|
#define CSS_FILE "swad18.4.css"
|
||||||
#define JS_FILE "swad17.17.1.js"
|
#define JS_FILE "swad17.17.1.js"
|
||||||
/*
|
/*
|
||||||
|
Version 18.8.6: Oct 26, 2018 Some asprintf for database queries changed by internal function. (237407 lines)
|
||||||
Version 18.8.5: Oct 26, 2018 Some asprintf for database queries changed by internal function. (237723 lines)
|
Version 18.8.5: Oct 26, 2018 Some asprintf for database queries changed by internal function. (237723 lines)
|
||||||
Version 18.8.4: Oct 25, 2018 Some asprintf for database queries changed by internal function. (237916 lines)
|
Version 18.8.4: Oct 25, 2018 Some asprintf for database queries changed by internal function. (237916 lines)
|
||||||
Version 18.8.3: Oct 25, 2018 Some asprintf for database queries changed by internal function. (237968 lines)
|
Version 18.8.3: Oct 25, 2018 Some asprintf for database queries changed by internal function. (237968 lines)
|
||||||
|
|
108
swad_follow.c
108
swad_follow.c
|
@ -1125,83 +1125,75 @@ void Fol_UnfollowUsr2 (void)
|
||||||
|
|
||||||
void Fol_GetAndShowRankingFollowers (void)
|
void Fol_GetAndShowRankingFollowers (void)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Get ranking from database *****/
|
/***** Get ranking from database *****/
|
||||||
switch (Gbl.Scope.Current)
|
switch (Gbl.Scope.Current)
|
||||||
{
|
{
|
||||||
case Sco_SCOPE_SYS:
|
case Sco_SCOPE_SYS:
|
||||||
if (asprintf (&Query,"SELECT FollowedCod,COUNT(FollowerCod) AS N"
|
DB_BuildQuery ("SELECT FollowedCod,COUNT(FollowerCod) AS N"
|
||||||
" FROM usr_follow"
|
" FROM usr_follow"
|
||||||
" GROUP BY FollowedCod"
|
" GROUP BY FollowedCod"
|
||||||
" ORDER BY N DESC,FollowedCod LIMIT 100") < 0)
|
" ORDER BY N DESC,FollowedCod LIMIT 100");
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CTY:
|
case Sco_SCOPE_CTY:
|
||||||
if (asprintf (&Query,"SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
DB_BuildQuery ("SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
||||||
" FROM institutions,centres,degrees,courses,crs_usr,usr_follow"
|
" FROM institutions,centres,degrees,courses,crs_usr,usr_follow"
|
||||||
" WHERE institutions.CtyCod=%ld"
|
" WHERE institutions.CtyCod=%ld"
|
||||||
" AND institutions.InsCod=centres.InsCod"
|
" AND institutions.InsCod=centres.InsCod"
|
||||||
" AND centres.CtrCod=degrees.CtrCod"
|
" AND centres.CtrCod=degrees.CtrCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
||||||
" GROUP BY usr_follow.FollowedCod"
|
" GROUP BY usr_follow.FollowedCod"
|
||||||
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
||||||
Gbl.CurrentCty.Cty.CtyCod) < 0)
|
Gbl.CurrentCty.Cty.CtyCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_INS:
|
case Sco_SCOPE_INS:
|
||||||
if (asprintf (&Query,"SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
DB_BuildQuery ("SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
||||||
" FROM centres,degrees,courses,crs_usr,usr_follow"
|
" FROM centres,degrees,courses,crs_usr,usr_follow"
|
||||||
" WHERE centres.InsCod=%ld"
|
" WHERE centres.InsCod=%ld"
|
||||||
" AND centres.CtrCod=degrees.CtrCod"
|
" AND centres.CtrCod=degrees.CtrCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
||||||
" GROUP BY usr_follow.FollowedCod"
|
" GROUP BY usr_follow.FollowedCod"
|
||||||
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
||||||
Gbl.CurrentIns.Ins.InsCod) < 0)
|
Gbl.CurrentIns.Ins.InsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CTR:
|
case Sco_SCOPE_CTR:
|
||||||
if (asprintf (&Query,"SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
DB_BuildQuery ("SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
||||||
" FROM degrees,courses,crs_usr,usr_follow"
|
" FROM degrees,courses,crs_usr,usr_follow"
|
||||||
" WHERE degrees.CtrCod=%ld"
|
" WHERE degrees.CtrCod=%ld"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
||||||
" GROUP BY usr_follow.FollowedCod"
|
" GROUP BY usr_follow.FollowedCod"
|
||||||
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
||||||
Gbl.CurrentCtr.Ctr.CtrCod) < 0)
|
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_DEG:
|
case Sco_SCOPE_DEG:
|
||||||
if (asprintf (&Query,"SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
DB_BuildQuery ("SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
||||||
" FROM courses,crs_usr,usr_follow"
|
" FROM courses,crs_usr,usr_follow"
|
||||||
" WHERE courses.DegCod=%ld"
|
" WHERE courses.DegCod=%ld"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
||||||
" GROUP BY usr_follow.FollowedCod"
|
" GROUP BY usr_follow.FollowedCod"
|
||||||
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
||||||
Gbl.CurrentDeg.Deg.DegCod) < 0)
|
Gbl.CurrentDeg.Deg.DegCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CRS:
|
case Sco_SCOPE_CRS:
|
||||||
if (asprintf (&Query,"SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
DB_BuildQuery ("SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
||||||
" FROM crs_usr,usr_follow"
|
" FROM crs_usr,usr_follow"
|
||||||
" WHERE crs_usr.CrsCod=%ld"
|
" WHERE crs_usr.CrsCod=%ld"
|
||||||
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
||||||
" GROUP BY usr_follow.FollowedCod"
|
" GROUP BY usr_follow.FollowedCod"
|
||||||
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod) < 0)
|
Gbl.CurrentCrs.Crs.CrsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Lay_WrongScopeExit ();
|
Lay_WrongScopeExit ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Prf_ShowRankingFigure (Query);
|
Prf_ShowRankingFigure ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
271
swad_group.c
271
swad_group.c
|
@ -2688,7 +2688,6 @@ static void Grp_PutFormToCreateGroup (void)
|
||||||
|
|
||||||
void Grp_GetListGrpTypesInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
|
void Grp_GetListGrpTypesInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRow;
|
unsigned long NumRow;
|
||||||
|
@ -2705,44 +2704,42 @@ void Grp_GetListGrpTypesInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
|
||||||
switch (WhichGroupTypes)
|
switch (WhichGroupTypes)
|
||||||
{
|
{
|
||||||
case Grp_ONLY_GROUP_TYPES_WITH_GROUPS:
|
case Grp_ONLY_GROUP_TYPES_WITH_GROUPS:
|
||||||
if (asprintf (&Query,"SELECT crs_grp_types.GrpTypCod,crs_grp_types.GrpTypName,"
|
DB_BuildQuery ("SELECT crs_grp_types.GrpTypCod,crs_grp_types.GrpTypName,"
|
||||||
"crs_grp_types.Mandatory,crs_grp_types.Multiple,"
|
"crs_grp_types.Mandatory,crs_grp_types.Multiple,"
|
||||||
"crs_grp_types.MustBeOpened,"
|
"crs_grp_types.MustBeOpened,"
|
||||||
"UNIX_TIMESTAMP(crs_grp_types.OpenTime),"
|
"UNIX_TIMESTAMP(crs_grp_types.OpenTime),"
|
||||||
"COUNT(crs_grp.GrpCod)"
|
"COUNT(crs_grp.GrpCod)"
|
||||||
" FROM crs_grp_types,crs_grp"
|
" FROM crs_grp_types,crs_grp"
|
||||||
" WHERE crs_grp_types.CrsCod=%ld"
|
" WHERE crs_grp_types.CrsCod=%ld"
|
||||||
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
|
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
|
||||||
" GROUP BY crs_grp_types.GrpTypCod"
|
" GROUP BY crs_grp_types.GrpTypCod"
|
||||||
" ORDER BY crs_grp_types.GrpTypName",
|
" ORDER BY crs_grp_types.GrpTypName",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod) < 0)
|
Gbl.CurrentCrs.Crs.CrsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Grp_ALL_GROUP_TYPES:
|
case Grp_ALL_GROUP_TYPES:
|
||||||
if (asprintf (&Query,"(SELECT crs_grp_types.GrpTypCod,crs_grp_types.GrpTypName AS GrpTypName,"
|
DB_BuildQuery ("(SELECT crs_grp_types.GrpTypCod,crs_grp_types.GrpTypName AS GrpTypName,"
|
||||||
"crs_grp_types.Mandatory,crs_grp_types.Multiple,"
|
"crs_grp_types.Mandatory,crs_grp_types.Multiple,"
|
||||||
"crs_grp_types.MustBeOpened,"
|
"crs_grp_types.MustBeOpened,"
|
||||||
"UNIX_TIMESTAMP(crs_grp_types.OpenTime),"
|
"UNIX_TIMESTAMP(crs_grp_types.OpenTime),"
|
||||||
"COUNT(crs_grp.GrpCod)"
|
"COUNT(crs_grp.GrpCod)"
|
||||||
" FROM crs_grp_types,crs_grp"
|
" FROM crs_grp_types,crs_grp"
|
||||||
" WHERE crs_grp_types.CrsCod=%ld"
|
" WHERE crs_grp_types.CrsCod=%ld"
|
||||||
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
|
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
|
||||||
" GROUP BY crs_grp_types.GrpTypCod)"
|
" GROUP BY crs_grp_types.GrpTypCod)"
|
||||||
" UNION "
|
" UNION "
|
||||||
"(SELECT GrpTypCod,GrpTypName,"
|
"(SELECT GrpTypCod,GrpTypName,"
|
||||||
"Mandatory,Multiple,"
|
"Mandatory,Multiple,"
|
||||||
"MustBeOpened,"
|
"MustBeOpened,"
|
||||||
"UNIX_TIMESTAMP(OpenTime),"
|
"UNIX_TIMESTAMP(OpenTime),"
|
||||||
"0"
|
"0"
|
||||||
" FROM crs_grp_types WHERE CrsCod=%ld"
|
" FROM crs_grp_types WHERE CrsCod=%ld"
|
||||||
" AND GrpTypCod NOT IN (SELECT GrpTypCod FROM crs_grp))"
|
" AND GrpTypCod NOT IN (SELECT GrpTypCod FROM crs_grp))"
|
||||||
" ORDER BY GrpTypName",
|
" ORDER BY GrpTypName",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
Gbl.CurrentCrs.Crs.CrsCod) < 0)
|
Gbl.CurrentCrs.Crs.CrsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Gbl.CurrentCrs.Grps.GrpTypes.Num = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get types of group of a course");
|
Gbl.CurrentCrs.Grps.GrpTypes.Num = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get types of group of a course");
|
||||||
|
|
||||||
/***** Get group types *****/
|
/***** Get group types *****/
|
||||||
Gbl.CurrentCrs.Grps.GrpTypes.NumGrpsTotal = 0;
|
Gbl.CurrentCrs.Grps.GrpTypes.NumGrpsTotal = 0;
|
||||||
|
@ -2813,13 +2810,12 @@ void Grp_OpenGroupsAutomatically (void)
|
||||||
long GrpTypCod;
|
long GrpTypCod;
|
||||||
|
|
||||||
/***** Find group types to be opened *****/
|
/***** Find group types to be opened *****/
|
||||||
if (asprintf (&Query,"SELECT GrpTypCod FROM crs_grp_types"
|
DB_BuildQuery ("SELECT GrpTypCod FROM crs_grp_types"
|
||||||
" WHERE CrsCod=%ld AND MustBeOpened='Y'"
|
" WHERE CrsCod=%ld AND MustBeOpened='Y'"
|
||||||
" AND OpenTime<=NOW()",
|
" AND OpenTime<=NOW()",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod) < 0)
|
Gbl.CurrentCrs.Crs.CrsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumGrpTypes = (unsigned) DB_QuerySELECT_new (&mysql_res,
|
||||||
NumGrpTypes = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,
|
"can not get the types of group to be opened");
|
||||||
"can not get the types of group to be opened");
|
|
||||||
for (NumGrpTyp = 0;
|
for (NumGrpTyp = 0;
|
||||||
NumGrpTyp < NumGrpTypes;
|
NumGrpTyp < NumGrpTypes;
|
||||||
NumGrpTyp++)
|
NumGrpTyp++)
|
||||||
|
@ -3001,16 +2997,13 @@ static unsigned Grp_CountNumGrpsInThisCrsOfType (long GrpTypCod)
|
||||||
|
|
||||||
unsigned long Grp_GetGrpsOfType (long GrpTypCod,MYSQL_RES **mysql_res)
|
unsigned long Grp_GetGrpsOfType (long GrpTypCod,MYSQL_RES **mysql_res)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Get groups of a type from database *****/
|
/***** Get groups of a type from database *****/
|
||||||
if (asprintf (&Query,"SELECT GrpCod,GrpName,MaxStudents,Open,FileZones"
|
DB_BuildQuery ("SELECT GrpCod,GrpName,MaxStudents,Open,FileZones"
|
||||||
" FROM crs_grp"
|
" FROM crs_grp"
|
||||||
" WHERE GrpTypCod=%ld"
|
" WHERE GrpTypCod=%ld"
|
||||||
" ORDER BY GrpName",
|
" ORDER BY GrpName",
|
||||||
GrpTypCod) < 0)
|
GrpTypCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
return DB_QuerySELECT_new (mysql_res,"can not get groups of a type");
|
||||||
return DB_QuerySELECT_free (Query,mysql_res,"can not get groups of a type");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -3020,18 +3013,16 @@ unsigned long Grp_GetGrpsOfType (long GrpTypCod,MYSQL_RES **mysql_res)
|
||||||
|
|
||||||
static void Grp_GetDataOfGroupTypeByCod (struct GroupType *GrpTyp)
|
static void Grp_GetDataOfGroupTypeByCod (struct GroupType *GrpTyp)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
|
|
||||||
/***** Get data of a type of group from database *****/
|
/***** Get data of a type of group from database *****/
|
||||||
if (asprintf (&Query,"SELECT GrpTypName,Mandatory,Multiple,MustBeOpened,UNIX_TIMESTAMP(OpenTime)"
|
DB_BuildQuery ("SELECT GrpTypName,Mandatory,Multiple,MustBeOpened,UNIX_TIMESTAMP(OpenTime)"
|
||||||
" FROM crs_grp_types"
|
" FROM crs_grp_types"
|
||||||
" WHERE CrsCod=%ld AND GrpTypCod=%ld",
|
" WHERE CrsCod=%ld AND GrpTypCod=%ld",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,GrpTyp->GrpTypCod) < 0)
|
Gbl.CurrentCrs.Crs.CrsCod,GrpTyp->GrpTypCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get type of group");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get type of group");
|
|
||||||
|
|
||||||
/***** Count number of rows in result *****/
|
/***** Count number of rows in result *****/
|
||||||
if (NumRows != 1)
|
if (NumRows != 1)
|
||||||
|
@ -3056,16 +3047,14 @@ static void Grp_GetDataOfGroupTypeByCod (struct GroupType *GrpTyp)
|
||||||
|
|
||||||
static bool Grp_GetMultipleEnrolmentOfAGroupType (long GrpTypCod)
|
static bool Grp_GetMultipleEnrolmentOfAGroupType (long GrpTypCod)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
bool MultipleEnrolment;
|
bool MultipleEnrolment;
|
||||||
|
|
||||||
/***** Get data of a type of group from database *****/
|
/***** Get data of a type of group from database *****/
|
||||||
if (asprintf (&Query,"SELECT Multiple FROM crs_grp_types WHERE GrpTypCod=%ld",
|
DB_BuildQuery ("SELECT Multiple FROM crs_grp_types WHERE GrpTypCod=%ld",
|
||||||
GrpTypCod) < 0)
|
GrpTypCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
if (DB_QuerySELECT_new (&mysql_res,"can not get if type of group has multiple enrolment") != 1)
|
||||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get if type of group has multiple enrolment") != 1)
|
|
||||||
Lay_ShowErrorAndExit ("Error when getting type of group.");
|
Lay_ShowErrorAndExit ("Error when getting type of group.");
|
||||||
|
|
||||||
/***** Get multiple enrolment *****/
|
/***** Get multiple enrolment *****/
|
||||||
|
@ -3084,7 +3073,6 @@ static bool Grp_GetMultipleEnrolmentOfAGroupType (long GrpTypCod)
|
||||||
|
|
||||||
void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat)
|
void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
|
@ -3103,16 +3091,15 @@ void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat)
|
||||||
if (GrpDat->GrpCod > 0)
|
if (GrpDat->GrpCod > 0)
|
||||||
{
|
{
|
||||||
/***** Get data of a group from database *****/
|
/***** Get data of a group from database *****/
|
||||||
if (asprintf (&Query,"SELECT crs_grp_types.GrpTypCod,crs_grp_types.CrsCod,"
|
DB_BuildQuery ("SELECT crs_grp_types.GrpTypCod,crs_grp_types.CrsCod,"
|
||||||
"crs_grp_types.GrpTypName,crs_grp_types.Multiple,"
|
"crs_grp_types.GrpTypName,crs_grp_types.Multiple,"
|
||||||
"crs_grp.GrpName,crs_grp.MaxStudents,"
|
"crs_grp.GrpName,crs_grp.MaxStudents,"
|
||||||
"crs_grp.Open,crs_grp.FileZones"
|
"crs_grp.Open,crs_grp.FileZones"
|
||||||
" FROM crs_grp,crs_grp_types"
|
" FROM crs_grp,crs_grp_types"
|
||||||
" WHERE crs_grp.GrpCod=%ld"
|
" WHERE crs_grp.GrpCod=%ld"
|
||||||
" AND crs_grp.GrpTypCod=crs_grp_types.GrpTypCod",
|
" AND crs_grp.GrpTypCod=crs_grp_types.GrpTypCod",
|
||||||
GrpDat->GrpCod) < 0)
|
GrpDat->GrpCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get data of a group");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get data of a group");
|
|
||||||
|
|
||||||
if (NumRows == 1)
|
if (NumRows == 1)
|
||||||
{
|
{
|
||||||
|
@ -3159,16 +3146,13 @@ void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat)
|
||||||
|
|
||||||
static long Grp_GetTypeOfGroupOfAGroup (long GrpCod)
|
static long Grp_GetTypeOfGroupOfAGroup (long GrpCod)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
long GrpTypCod;
|
long GrpTypCod;
|
||||||
|
|
||||||
/***** Get data of a group from database *****/
|
/***** Get data of a group from database *****/
|
||||||
if (asprintf (&Query,"SELECT GrpTypCod FROM crs_grp WHERE GrpCod=%ld",
|
DB_BuildQuery ("SELECT GrpTypCod FROM crs_grp WHERE GrpCod=%ld",GrpCod);
|
||||||
GrpCod) < 0)
|
if (DB_QuerySELECT_new (&mysql_res,"can not get the type of a group") != 1)
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get the type of a group") != 1)
|
|
||||||
Lay_ShowErrorAndExit ("Error when getting group.");
|
Lay_ShowErrorAndExit ("Error when getting group.");
|
||||||
|
|
||||||
/***** Get data of group *****/
|
/***** Get data of group *****/
|
||||||
|
@ -3244,23 +3228,21 @@ unsigned Grp_CountNumUsrsInGrp (Rol_Role_t Role,long GrpCod)
|
||||||
|
|
||||||
static unsigned Grp_CountNumUsrsInNoGrpsOfType (Rol_Role_t Role,long GrpTypCod)
|
static unsigned Grp_CountNumUsrsInNoGrpsOfType (Rol_Role_t Role,long GrpTypCod)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumUsrs;
|
unsigned NumUsrs;
|
||||||
|
|
||||||
/***** Get number of users not belonging to groups of a type ******/
|
/***** Get number of users not belonging to groups of a type ******/
|
||||||
if (asprintf (&Query,"SELECT COUNT(UsrCod) FROM crs_usr"
|
DB_BuildQuery ("SELECT COUNT(UsrCod) FROM crs_usr"
|
||||||
" WHERE CrsCod=%ld AND Role=%u"
|
" WHERE CrsCod=%ld AND Role=%u"
|
||||||
" AND UsrCod NOT IN"
|
" AND UsrCod NOT IN"
|
||||||
" (SELECT DISTINCT crs_grp_usr.UsrCod"
|
" (SELECT DISTINCT crs_grp_usr.UsrCod"
|
||||||
" FROM crs_grp,crs_grp_usr"
|
" FROM crs_grp,crs_grp_usr"
|
||||||
" WHERE crs_grp.GrpTypCod=%ld"
|
" WHERE crs_grp.GrpTypCod=%ld"
|
||||||
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod)",
|
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod)",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,(unsigned) Role,GrpTypCod) < 0)
|
Gbl.CurrentCrs.Crs.CrsCod,(unsigned) Role,GrpTypCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QuerySELECT_new (&mysql_res,"can not get the number of users"
|
||||||
DB_QuerySELECT_free (Query,&mysql_res,"can not get the number of users"
|
" not belonging to groups of a type");
|
||||||
" not belonging to groups of a type");
|
|
||||||
|
|
||||||
/***** Get the number of users (row[0]) *****/
|
/***** Get the number of users (row[0]) *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -3281,20 +3263,18 @@ static unsigned Grp_CountNumUsrsInNoGrpsOfType (Rol_Role_t Role,long GrpTypCod)
|
||||||
|
|
||||||
static long Grp_GetFirstCodGrpIBelongTo (long GrpTypCod)
|
static long Grp_GetFirstCodGrpIBelongTo (long GrpTypCod)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
long CodGrpIBelong;
|
long CodGrpIBelong;
|
||||||
|
|
||||||
/***** Get a group which I belong to from database *****/
|
/***** Get a group which I belong to from database *****/
|
||||||
if (asprintf (&Query,"SELECT crs_grp.GrpCod FROM crs_grp,crs_grp_usr"
|
DB_BuildQuery ("SELECT crs_grp.GrpCod FROM crs_grp,crs_grp_usr"
|
||||||
" WHERE crs_grp.GrpTypCod=%ld"
|
" WHERE crs_grp.GrpTypCod=%ld"
|
||||||
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod"
|
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod"
|
||||||
" AND crs_grp_usr.UsrCod=%ld",
|
" AND crs_grp_usr.UsrCod=%ld",
|
||||||
GrpTypCod,Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
GrpTypCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not check if you belong to a group");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not check if you belong to a group");
|
|
||||||
|
|
||||||
/***** Get the group *****/
|
/***** Get the group *****/
|
||||||
if (NumRows == 0)
|
if (NumRows == 0)
|
||||||
|
@ -3543,46 +3523,37 @@ static bool Grp_GetIfGrpIsAvailable (long GrpTypCod)
|
||||||
static void Grp_GetLstCodGrpsUsrBelongs (long CrsCod,long GrpTypCod,
|
static void Grp_GetLstCodGrpsUsrBelongs (long CrsCod,long GrpTypCod,
|
||||||
long UsrCod,struct ListCodGrps *LstGrps)
|
long UsrCod,struct ListCodGrps *LstGrps)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumGrp;
|
unsigned NumGrp;
|
||||||
|
|
||||||
/***** Get groups which a user belong to from database *****/
|
/***** Get groups which a user belong to from database *****/
|
||||||
if (CrsCod < 0) // Query the groups from all the user's courses
|
if (CrsCod < 0) // Query the groups from all the user's courses
|
||||||
{
|
DB_BuildQuery ("SELECT GrpCod"
|
||||||
if (asprintf (&Query,"SELECT GrpCod"
|
" FROM crs_grp_usr"
|
||||||
" FROM crs_grp_usr"
|
" WHERE UsrCod=%ld", // Groups will be unordered
|
||||||
" WHERE UsrCod=%ld", // Groups will be unordered
|
UsrCod);
|
||||||
UsrCod) < 0)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
}
|
|
||||||
else if (GrpTypCod < 0) // Query the groups of any type in the course
|
else if (GrpTypCod < 0) // Query the groups of any type in the course
|
||||||
{
|
DB_BuildQuery ("SELECT crs_grp.GrpCod"
|
||||||
if (asprintf (&Query,"SELECT crs_grp.GrpCod"
|
" FROM crs_grp_types,crs_grp,crs_grp_usr"
|
||||||
" FROM crs_grp_types,crs_grp,crs_grp_usr"
|
" WHERE crs_grp_types.CrsCod=%ld"
|
||||||
" WHERE crs_grp_types.CrsCod=%ld"
|
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
|
||||||
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
|
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod"
|
||||||
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod"
|
" AND crs_grp_usr.UsrCod=%ld"
|
||||||
" AND crs_grp_usr.UsrCod=%ld"
|
" ORDER BY crs_grp_types.GrpTypName,crs_grp.GrpName",
|
||||||
" ORDER BY crs_grp_types.GrpTypName,crs_grp.GrpName",
|
Gbl.CurrentCrs.Crs.CrsCod,UsrCod);
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,UsrCod) < 0)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
}
|
|
||||||
else // Query only the groups of specified type in the course
|
else // Query only the groups of specified type in the course
|
||||||
{
|
DB_BuildQuery ("SELECT crs_grp.GrpCod"
|
||||||
if (asprintf (&Query,"SELECT crs_grp.GrpCod"
|
" FROM crs_grp_types,crs_grp,crs_grp_usr"
|
||||||
" FROM crs_grp_types,crs_grp,crs_grp_usr"
|
" WHERE crs_grp_types.CrsCod=%ld"
|
||||||
" WHERE crs_grp_types.CrsCod=%ld"
|
" AND crs_grp_types.GrpTypCod=%ld"
|
||||||
" AND crs_grp_types.GrpTypCod=%ld"
|
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
|
||||||
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
|
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod"
|
||||||
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod"
|
" AND crs_grp_usr.UsrCod=%ld"
|
||||||
" AND crs_grp_usr.UsrCod=%ld"
|
" ORDER BY crs_grp.GrpName",
|
||||||
" ORDER BY crs_grp.GrpName",
|
Gbl.CurrentCrs.Crs.CrsCod,GrpTypCod,UsrCod);
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,GrpTypCod,UsrCod) < 0)
|
LstGrps->NumGrps = (unsigned) DB_QuerySELECT_new (&mysql_res,
|
||||||
Lay_NotEnoughMemoryExit ();
|
"can not get the groups which a user belongs to");
|
||||||
}
|
|
||||||
LstGrps->NumGrps = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get the groups which a user belongs to");
|
|
||||||
|
|
||||||
/***** Get the groups *****/
|
/***** Get the groups *****/
|
||||||
if (LstGrps->NumGrps)
|
if (LstGrps->NumGrps)
|
||||||
|
@ -3612,23 +3583,21 @@ static void Grp_GetLstCodGrpsUsrBelongs (long CrsCod,long GrpTypCod,
|
||||||
|
|
||||||
void Grp_GetLstCodGrpsWithFileZonesIBelong (struct ListCodGrps *LstGrps)
|
void Grp_GetLstCodGrpsWithFileZonesIBelong (struct ListCodGrps *LstGrps)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumGrp;
|
unsigned NumGrp;
|
||||||
|
|
||||||
/***** Get groups which I belong to from database *****/
|
/***** Get groups which I belong to from database *****/
|
||||||
if (asprintf (&Query,"SELECT crs_grp.GrpCod"
|
DB_BuildQuery ("SELECT crs_grp.GrpCod"
|
||||||
" FROM crs_grp_types,crs_grp,crs_grp_usr"
|
" FROM crs_grp_types,crs_grp,crs_grp_usr"
|
||||||
" WHERE crs_grp_types.CrsCod=%ld"
|
" WHERE crs_grp_types.CrsCod=%ld"
|
||||||
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
|
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
|
||||||
" AND crs_grp.FileZones='Y'"
|
" AND crs_grp.FileZones='Y'"
|
||||||
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod"
|
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod"
|
||||||
" AND crs_grp_usr.UsrCod=%ld"
|
" AND crs_grp_usr.UsrCod=%ld"
|
||||||
" ORDER BY crs_grp_types.GrpTypName,crs_grp.GrpName",
|
" ORDER BY crs_grp_types.GrpTypName,crs_grp.GrpName",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
Gbl.CurrentCrs.Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
LstGrps->NumGrps = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get the groups which I belong to");
|
||||||
LstGrps->NumGrps = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get the groups which I belong to");
|
|
||||||
|
|
||||||
/***** Get the groups *****/
|
/***** Get the groups *****/
|
||||||
if (LstGrps->NumGrps)
|
if (LstGrps->NumGrps)
|
||||||
|
@ -3674,7 +3643,6 @@ static bool Grp_CheckIfGrpIsInList (long GrpCod,struct ListCodGrps *LstGrps)
|
||||||
|
|
||||||
void Grp_GetNamesGrpsStdBelongsTo (long GrpTypCod,long UsrCod,char *GroupNames)
|
void Grp_GetNamesGrpsStdBelongsTo (long GrpTypCod,long UsrCod,char *GroupNames)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRow;
|
unsigned long NumRow;
|
||||||
|
@ -3682,14 +3650,13 @@ void Grp_GetNamesGrpsStdBelongsTo (long GrpTypCod,long UsrCod,char *GroupNames)
|
||||||
size_t MaxLength = (Grp_MAX_BYTES_GROUP_NAME + 2) * Gbl.CurrentCrs.Grps.GrpTypes.NumGrpsTotal;
|
size_t MaxLength = (Grp_MAX_BYTES_GROUP_NAME + 2) * Gbl.CurrentCrs.Grps.GrpTypes.NumGrpsTotal;
|
||||||
|
|
||||||
/***** Get the names of groups which a user belongs to, from database *****/
|
/***** Get the names of groups which a user belongs to, from database *****/
|
||||||
if (asprintf (&Query,"SELECT crs_grp.GrpName FROM crs_grp,crs_grp_usr"
|
DB_BuildQuery ("SELECT crs_grp.GrpName FROM crs_grp,crs_grp_usr"
|
||||||
" WHERE crs_grp.GrpTypCod=%ld"
|
" WHERE crs_grp.GrpTypCod=%ld"
|
||||||
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod"
|
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod"
|
||||||
" AND crs_grp_usr.UsrCod=%ld"
|
" AND crs_grp_usr.UsrCod=%ld"
|
||||||
" ORDER BY crs_grp.GrpName",
|
" ORDER BY crs_grp.GrpName",
|
||||||
GrpTypCod,UsrCod) < 0)
|
GrpTypCod,UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get the names of groups a user belongs to");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get the names of groups a user belongs to");
|
|
||||||
|
|
||||||
/***** Get the groups *****/
|
/***** Get the groups *****/
|
||||||
GroupNames[0] = '\0';
|
GroupNames[0] = '\0';
|
||||||
|
|
100
swad_holiday.c
100
swad_holiday.c
|
@ -249,7 +249,6 @@ void Hld_EditHolidays (void)
|
||||||
void Hld_GetListHolidays (void)
|
void Hld_GetListHolidays (void)
|
||||||
{
|
{
|
||||||
char OrderBySubQuery[256];
|
char OrderBySubQuery[256];
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumHld;
|
unsigned NumHld;
|
||||||
|
@ -270,31 +269,30 @@ void Hld_GetListHolidays (void)
|
||||||
sprintf (OrderBySubQuery,"StartDate,Place");
|
sprintf (OrderBySubQuery,"StartDate,Place");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (asprintf (&Query,"(SELECT holidays.HldCod,holidays.PlcCod,"
|
DB_BuildQuery ("(SELECT holidays.HldCod,holidays.PlcCod,"
|
||||||
"places.FullName as Place,HldTyp,"
|
"places.FullName as Place,HldTyp,"
|
||||||
"DATE_FORMAT(holidays.StartDate,'%%Y%%m%%d') AS StartDate,"
|
"DATE_FORMAT(holidays.StartDate,'%%Y%%m%%d') AS StartDate,"
|
||||||
"DATE_FORMAT(holidays.EndDate,'%%Y%%m%%d') AS EndDate,"
|
"DATE_FORMAT(holidays.EndDate,'%%Y%%m%%d') AS EndDate,"
|
||||||
"holidays.Name"
|
"holidays.Name"
|
||||||
" FROM holidays,places"
|
" FROM holidays,places"
|
||||||
" WHERE holidays.InsCod=%ld"
|
" WHERE holidays.InsCod=%ld"
|
||||||
" AND holidays.PlcCod=places.PlcCod"
|
" AND holidays.PlcCod=places.PlcCod"
|
||||||
" AND places.InsCod=%ld)"
|
" AND places.InsCod=%ld)"
|
||||||
" UNION "
|
" UNION "
|
||||||
"(SELECT HldCod,PlcCod,'' as Place,HldTyp,"
|
"(SELECT HldCod,PlcCod,'' as Place,HldTyp,"
|
||||||
"DATE_FORMAT(StartDate,'%%Y%%m%%d') AS StartDate,"
|
"DATE_FORMAT(StartDate,'%%Y%%m%%d') AS StartDate,"
|
||||||
"DATE_FORMAT(EndDate,'%%Y%%m%%d') AS EndDate,Name"
|
"DATE_FORMAT(EndDate,'%%Y%%m%%d') AS EndDate,Name"
|
||||||
" FROM holidays"
|
" FROM holidays"
|
||||||
" WHERE InsCod=%ld"
|
" WHERE InsCod=%ld"
|
||||||
" AND PlcCod NOT IN"
|
" AND PlcCod NOT IN"
|
||||||
"(SELECT DISTINCT PlcCod FROM places WHERE InsCod=%ld))"
|
"(SELECT DISTINCT PlcCod FROM places WHERE InsCod=%ld))"
|
||||||
" ORDER BY %s",
|
" ORDER BY %s",
|
||||||
Gbl.CurrentIns.Ins.InsCod,
|
Gbl.CurrentIns.Ins.InsCod,
|
||||||
Gbl.CurrentIns.Ins.InsCod,
|
Gbl.CurrentIns.Ins.InsCod,
|
||||||
Gbl.CurrentIns.Ins.InsCod,
|
Gbl.CurrentIns.Ins.InsCod,
|
||||||
Gbl.CurrentIns.Ins.InsCod,
|
Gbl.CurrentIns.Ins.InsCod,
|
||||||
OrderBySubQuery) < 0)
|
OrderBySubQuery);
|
||||||
Lay_NotEnoughMemoryExit ();
|
if ((Gbl.Hlds.Num = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get holidays"))) // Holidays found...
|
||||||
if ((Gbl.Hlds.Num = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get holidays"))) // Holidays found...
|
|
||||||
{
|
{
|
||||||
/***** Create list of holidays *****/
|
/***** Create list of holidays *****/
|
||||||
if ((Gbl.Hlds.Lst = (struct Holiday *) calloc ((size_t) Gbl.Hlds.Num,sizeof (struct Holiday))) == NULL)
|
if ((Gbl.Hlds.Lst = (struct Holiday *) calloc ((size_t) Gbl.Hlds.Num,sizeof (struct Holiday))) == NULL)
|
||||||
|
@ -361,7 +359,6 @@ void Hld_GetListHolidays (void)
|
||||||
|
|
||||||
static void Hld_GetDataOfHolidayByCod (struct Holiday *Hld)
|
static void Hld_GetDataOfHolidayByCod (struct Holiday *Hld)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
|
@ -378,31 +375,30 @@ static void Hld_GetDataOfHolidayByCod (struct Holiday *Hld)
|
||||||
Lay_ShowErrorAndExit ("Wrong code of holiday.");
|
Lay_ShowErrorAndExit ("Wrong code of holiday.");
|
||||||
|
|
||||||
/***** Get data of holiday from database *****/
|
/***** Get data of holiday from database *****/
|
||||||
if (asprintf (&Query,"(SELECT holidays.PlcCod,places.FullName as Place,HldTyp,"
|
DB_BuildQuery ("(SELECT holidays.PlcCod,places.FullName as Place,HldTyp,"
|
||||||
"DATE_FORMAT(holidays.StartDate,'%%Y%%m%%d'),"
|
"DATE_FORMAT(holidays.StartDate,'%%Y%%m%%d'),"
|
||||||
"DATE_FORMAT(holidays.EndDate,'%%Y%%m%%d'),holidays.Name"
|
"DATE_FORMAT(holidays.EndDate,'%%Y%%m%%d'),holidays.Name"
|
||||||
" FROM holidays,places"
|
" FROM holidays,places"
|
||||||
" WHERE holidays.HldCod=%ld"
|
" WHERE holidays.HldCod=%ld"
|
||||||
" AND holidays.InsCod=%ld"
|
" AND holidays.InsCod=%ld"
|
||||||
" AND holidays.PlcCod=places.PlcCod"
|
" AND holidays.PlcCod=places.PlcCod"
|
||||||
" AND places.InsCod=%ld)"
|
" AND places.InsCod=%ld)"
|
||||||
" UNION "
|
" UNION "
|
||||||
"(SELECT PlcCod,'' as Place,HldTyp,"
|
"(SELECT PlcCod,'' as Place,HldTyp,"
|
||||||
"DATE_FORMAT(StartDate,'%%Y%%m%%d'),"
|
"DATE_FORMAT(StartDate,'%%Y%%m%%d'),"
|
||||||
"DATE_FORMAT(EndDate,'%%Y%%m%%d'),Name"
|
"DATE_FORMAT(EndDate,'%%Y%%m%%d'),Name"
|
||||||
" FROM holidays"
|
" FROM holidays"
|
||||||
" WHERE HldCod=%ld"
|
" WHERE HldCod=%ld"
|
||||||
" AND InsCod=%ld"
|
" AND InsCod=%ld"
|
||||||
" AND PlcCod NOT IN"
|
" AND PlcCod NOT IN"
|
||||||
"(SELECT DISTINCT PlcCod FROM places WHERE InsCod=%ld))",
|
"(SELECT DISTINCT PlcCod FROM places WHERE InsCod=%ld))",
|
||||||
Hld->HldCod,
|
Hld->HldCod,
|
||||||
Gbl.CurrentIns.Ins.InsCod,
|
Gbl.CurrentIns.Ins.InsCod,
|
||||||
Gbl.CurrentIns.Ins.InsCod,
|
Gbl.CurrentIns.Ins.InsCod,
|
||||||
Hld->HldCod,
|
Hld->HldCod,
|
||||||
Gbl.CurrentIns.Ins.InsCod,
|
Gbl.CurrentIns.Ins.InsCod,
|
||||||
Gbl.CurrentIns.Ins.InsCod) < 0)
|
Gbl.CurrentIns.Ins.InsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
if (DB_QuerySELECT_new (&mysql_res,"can not get data of a holiday")) // Holiday found...
|
||||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get data of a holiday")) // Holiday found...
|
|
||||||
{
|
{
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
405
swad_indicator.c
405
swad_indicator.c
|
@ -327,220 +327,176 @@ static void Ind_GetParamNumIndicators (void)
|
||||||
|
|
||||||
static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res)
|
static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
|
|
||||||
switch (Gbl.Scope.Current)
|
switch (Gbl.Scope.Current)
|
||||||
{
|
{
|
||||||
case Sco_SCOPE_SYS:
|
case Sco_SCOPE_SYS:
|
||||||
if (Gbl.Stat.DptCod >= 0) // 0 means another department
|
if (Gbl.Stat.DptCod >= 0) // 0 means another department
|
||||||
{
|
{
|
||||||
if (Gbl.Stat.DegTypCod > 0)
|
if (Gbl.Stat.DegTypCod > 0)
|
||||||
{
|
DB_BuildQuery ("SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
||||||
if (asprintf (&Query,"SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
" FROM degrees,courses,crs_usr,usr_data"
|
||||||
" FROM degrees,courses,crs_usr,usr_data"
|
" WHERE degrees.DegTypCod=%ld"
|
||||||
" WHERE degrees.DegTypCod=%ld"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND crs_usr.Role=%u"
|
||||||
" AND crs_usr.Role=%u"
|
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
||||||
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
" AND usr_data.DptCod=%ld"
|
||||||
" AND usr_data.DptCod=%ld"
|
" ORDER BY degrees.FullName,courses.FullName",
|
||||||
" ORDER BY degrees.FullName,courses.FullName",
|
Gbl.Stat.DegTypCod,
|
||||||
Gbl.Stat.DegTypCod,
|
(unsigned) Rol_TCH,
|
||||||
(unsigned) Rol_TCH,
|
Gbl.Stat.DptCod);
|
||||||
Gbl.Stat.DptCod) < 0)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
DB_BuildQuery ("SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
||||||
if (asprintf (&Query,"SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
" FROM degrees,courses,crs_usr,usr_data"
|
||||||
" FROM degrees,courses,crs_usr,usr_data"
|
" WHERE degrees.DegCod=courses.DegCod"
|
||||||
" WHERE degrees.DegCod=courses.DegCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND crs_usr.Role=%u"
|
||||||
" AND crs_usr.Role=%u"
|
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
||||||
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
" AND usr_data.DptCod=%ld"
|
||||||
" AND usr_data.DptCod=%ld"
|
" ORDER BY degrees.FullName,courses.FullName",
|
||||||
" ORDER BY degrees.FullName,courses.FullName",
|
(unsigned) Rol_TCH,
|
||||||
(unsigned) Rol_TCH,
|
Gbl.Stat.DptCod);
|
||||||
Gbl.Stat.DptCod) < 0)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Gbl.Stat.DegTypCod > 0)
|
if (Gbl.Stat.DegTypCod > 0)
|
||||||
{
|
DB_BuildQuery ("SELECT degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
||||||
if (asprintf (&Query,"SELECT degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
" FROM degrees,courses"
|
||||||
" FROM degrees,courses"
|
" WHERE degrees.DegTypCod=%ld"
|
||||||
" WHERE degrees.DegTypCod=%ld"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" ORDER BY degrees.FullName,courses.FullName",
|
||||||
" ORDER BY degrees.FullName,courses.FullName",
|
Gbl.Stat.DegTypCod);
|
||||||
Gbl.Stat.DegTypCod) < 0)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
DB_BuildQuery ("SELECT degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
||||||
if (asprintf (&Query,"SELECT degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
" FROM degrees,courses"
|
||||||
" FROM degrees,courses"
|
" WHERE degrees.DegCod=courses.DegCod"
|
||||||
" WHERE degrees.DegCod=courses.DegCod"
|
" ORDER BY degrees.FullName,courses.FullName");
|
||||||
" ORDER BY degrees.FullName,courses.FullName") < 0)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CTY:
|
case Sco_SCOPE_CTY:
|
||||||
if (Gbl.Stat.DptCod >= 0) // 0 means another department
|
if (Gbl.Stat.DptCod >= 0) // 0 means another department
|
||||||
{
|
DB_BuildQuery ("SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
||||||
if (asprintf (&Query,"SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
" FROM institutions,centres,degrees,courses,crs_usr,usr_data"
|
||||||
" FROM institutions,centres,degrees,courses,crs_usr,usr_data"
|
" WHERE institutions.CtyCod=%ld"
|
||||||
" WHERE institutions.CtyCod=%ld"
|
" AND institutions.InsCod=centres.InsCod"
|
||||||
" AND institutions.InsCod=centres.InsCod"
|
" AND centres.CtrCod=degrees.CtrCod"
|
||||||
" AND centres.CtrCod=degrees.CtrCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND crs_usr.Role=%u"
|
||||||
" AND crs_usr.Role=%u"
|
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
||||||
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
" AND usr_data.DptCod=%ld"
|
||||||
" AND usr_data.DptCod=%ld"
|
" ORDER BY degrees.FullName,courses.FullName",
|
||||||
" ORDER BY degrees.FullName,courses.FullName",
|
Gbl.CurrentCty.Cty.CtyCod,
|
||||||
Gbl.CurrentCty.Cty.CtyCod,
|
(unsigned) Rol_TCH,
|
||||||
(unsigned) Rol_TCH,
|
Gbl.Stat.DptCod);
|
||||||
Gbl.Stat.DptCod) < 0)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
DB_BuildQuery ("SELECT degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
||||||
if (asprintf (&Query,"SELECT degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
" FROM institutions,centres,degrees,courses"
|
||||||
" FROM institutions,centres,degrees,courses"
|
" WHERE institutions.CtyCod=%ld"
|
||||||
" WHERE institutions.CtyCod=%ld"
|
" AND institutions.InsCod=centres.InsCod"
|
||||||
" AND institutions.InsCod=centres.InsCod"
|
" AND centres.CtrCod=degrees.CtrCod"
|
||||||
" AND centres.CtrCod=degrees.CtrCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" ORDER BY degrees.FullName,courses.FullName",
|
||||||
" ORDER BY degrees.FullName,courses.FullName",
|
Gbl.CurrentCty.Cty.CtyCod);
|
||||||
Gbl.CurrentCty.Cty.CtyCod) < 0)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_INS:
|
case Sco_SCOPE_INS:
|
||||||
if (Gbl.Stat.DptCod >= 0) // 0 means another department
|
if (Gbl.Stat.DptCod >= 0) // 0 means another department
|
||||||
{
|
DB_BuildQuery ("SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
||||||
if (asprintf (&Query,"SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
" FROM centres,degrees,courses,crs_usr,usr_data"
|
||||||
" FROM centres,degrees,courses,crs_usr,usr_data"
|
" WHERE centres.InsCod=%ld"
|
||||||
" WHERE centres.InsCod=%ld"
|
" AND centres.CtrCod=degrees.CtrCod"
|
||||||
" AND centres.CtrCod=degrees.CtrCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND crs_usr.Role=%u"
|
||||||
" AND crs_usr.Role=%u"
|
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
||||||
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
" AND usr_data.DptCod=%ld"
|
||||||
" AND usr_data.DptCod=%ld"
|
" ORDER BY degrees.FullName,courses.FullName",
|
||||||
" ORDER BY degrees.FullName,courses.FullName",
|
Gbl.CurrentIns.Ins.InsCod,
|
||||||
Gbl.CurrentIns.Ins.InsCod,
|
(unsigned) Rol_TCH,
|
||||||
(unsigned) Rol_TCH,
|
Gbl.Stat.DptCod);
|
||||||
Gbl.Stat.DptCod) < 0)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
DB_BuildQuery ("SELECT degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
||||||
if (asprintf (&Query,"SELECT degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
" FROM centres,degrees,courses"
|
||||||
" FROM centres,degrees,courses"
|
" WHERE centres.InsCod=%ld"
|
||||||
" WHERE centres.InsCod=%ld"
|
" AND centres.CtrCod=degrees.CtrCod"
|
||||||
" AND centres.CtrCod=degrees.CtrCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" ORDER BY degrees.FullName,courses.FullName",
|
||||||
" ORDER BY degrees.FullName,courses.FullName",
|
Gbl.CurrentIns.Ins.InsCod);
|
||||||
Gbl.CurrentIns.Ins.InsCod) < 0)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CTR:
|
case Sco_SCOPE_CTR:
|
||||||
if (Gbl.Stat.DptCod >= 0) // 0 means another department
|
if (Gbl.Stat.DptCod >= 0) // 0 means another department
|
||||||
{
|
DB_BuildQuery ("SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
||||||
if (asprintf (&Query,"SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
" FROM degrees,courses,crs_usr,usr_data"
|
||||||
" FROM degrees,courses,crs_usr,usr_data"
|
" WHERE degrees.CtrCod=%ld"
|
||||||
" WHERE degrees.CtrCod=%ld"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND crs_usr.Role=%u"
|
||||||
" AND crs_usr.Role=%u"
|
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
||||||
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
" AND usr_data.DptCod=%ld"
|
||||||
" AND usr_data.DptCod=%ld"
|
" ORDER BY degrees.FullName,courses.FullName",
|
||||||
" ORDER BY degrees.FullName,courses.FullName",
|
Gbl.CurrentCtr.Ctr.CtrCod,
|
||||||
Gbl.CurrentCtr.Ctr.CtrCod,
|
(unsigned) Rol_TCH,
|
||||||
(unsigned) Rol_TCH,
|
Gbl.Stat.DptCod);
|
||||||
Gbl.Stat.DptCod) < 0)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
DB_BuildQuery ("SELECT degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
||||||
if (asprintf (&Query,"SELECT degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
" FROM degrees,courses"
|
||||||
" FROM degrees,courses"
|
" WHERE degrees.CtrCod=%ld"
|
||||||
" WHERE degrees.CtrCod=%ld"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" ORDER BY degrees.FullName,courses.FullName",
|
||||||
" ORDER BY degrees.FullName,courses.FullName",
|
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||||
Gbl.CurrentCtr.Ctr.CtrCod) < 0)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_DEG:
|
case Sco_SCOPE_DEG:
|
||||||
if (Gbl.Stat.DptCod >= 0) // 0 means another department
|
if (Gbl.Stat.DptCod >= 0) // 0 means another department
|
||||||
{
|
DB_BuildQuery ("SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
||||||
if (asprintf (&Query,"SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
" FROM degrees,courses,crs_usr,usr_data"
|
||||||
" FROM degrees,courses,crs_usr,usr_data"
|
" WHERE degrees.DegCod=%ld"
|
||||||
" WHERE degrees.DegCod=%ld"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND crs_usr.Role=%u"
|
||||||
" AND crs_usr.Role=%u"
|
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
||||||
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
" AND usr_data.DptCod=%ld"
|
||||||
" AND usr_data.DptCod=%ld"
|
" ORDER BY degrees.FullName,courses.FullName",
|
||||||
" ORDER BY degrees.FullName,courses.FullName",
|
Gbl.CurrentDeg.Deg.DegCod,
|
||||||
Gbl.CurrentDeg.Deg.DegCod,
|
(unsigned) Rol_TCH,
|
||||||
(unsigned) Rol_TCH,
|
Gbl.Stat.DptCod);
|
||||||
Gbl.Stat.DptCod) < 0)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
DB_BuildQuery ("SELECT degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
||||||
if (asprintf (&Query,"SELECT degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
" FROM degrees,courses"
|
||||||
" FROM degrees,courses"
|
" WHERE degrees.DegCod=%ld"
|
||||||
" WHERE degrees.DegCod=%ld"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" ORDER BY degrees.FullName,courses.FullName",
|
||||||
" ORDER BY degrees.FullName,courses.FullName",
|
Gbl.CurrentDeg.Deg.DegCod);
|
||||||
Gbl.CurrentDeg.Deg.DegCod) < 0)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CRS:
|
case Sco_SCOPE_CRS:
|
||||||
if (Gbl.Stat.DptCod >= 0) // 0 means another department
|
if (Gbl.Stat.DptCod >= 0) // 0 means another department
|
||||||
{
|
DB_BuildQuery ("SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
||||||
if (asprintf (&Query,"SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
" FROM degrees,courses,crs_usr,usr_data"
|
||||||
" FROM degrees,courses,crs_usr,usr_data"
|
" WHERE courses.CrsCod=%ld"
|
||||||
" WHERE courses.CrsCod=%ld"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND crs_usr.CrsCod=%ld"
|
||||||
" AND crs_usr.CrsCod=%ld"
|
" AND crs_usr.Role=%u"
|
||||||
" AND crs_usr.Role=%u"
|
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
||||||
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
" AND usr_data.DptCod=%ld"
|
||||||
" AND usr_data.DptCod=%ld"
|
" ORDER BY degrees.FullName,courses.FullName",
|
||||||
" ORDER BY degrees.FullName,courses.FullName",
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
(unsigned) Rol_TCH,
|
||||||
(unsigned) Rol_TCH,
|
Gbl.Stat.DptCod);
|
||||||
Gbl.Stat.DptCod) < 0)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
DB_BuildQuery ("SELECT degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
||||||
if (asprintf (&Query,"SELECT degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
|
" FROM degrees,courses"
|
||||||
" FROM degrees,courses"
|
" WHERE courses.CrsCod=%ld"
|
||||||
" WHERE courses.CrsCod=%ld"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" ORDER BY degrees.FullName,courses.FullName",
|
||||||
" ORDER BY degrees.FullName,courses.FullName",
|
Gbl.CurrentCrs.Crs.CrsCod);
|
||||||
Gbl.CurrentCrs.Crs.CrsCod) < 0)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Lay_WrongScopeExit ();
|
Lay_WrongScopeExit ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (unsigned) DB_QuerySELECT_free (Query,mysql_res,"can not get courses");
|
return (unsigned) DB_QuerySELECT_new (mysql_res,"can not get courses");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1433,16 +1389,13 @@ static unsigned Ind_GetAndUpdateNumIndicatorsCrs (long CrsCod)
|
||||||
|
|
||||||
int Ind_GetNumIndicatorsCrsFromDB (long CrsCod)
|
int Ind_GetNumIndicatorsCrsFromDB (long CrsCod)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
int NumIndicatorsFromDB = -1; // -1 means not yet calculated
|
int NumIndicatorsFromDB = -1; // -1 means not yet calculated
|
||||||
|
|
||||||
/***** Get number of indicators of a course from database *****/
|
/***** Get number of indicators of a course from database *****/
|
||||||
if (asprintf (&Query,"SELECT NumIndicators FROM courses WHERE CrsCod=%ld",
|
DB_BuildQuery ("SELECT NumIndicators FROM courses WHERE CrsCod=%ld",CrsCod);
|
||||||
CrsCod) < 0)
|
if (DB_QuerySELECT_new (&mysql_res,"can not get number of indicators"))
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get number of indicators"))
|
|
||||||
{
|
{
|
||||||
/***** Get row *****/
|
/***** Get row *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -1552,28 +1505,26 @@ void Ind_ComputeAndStoreIndicatorsCrs (long CrsCod,int NumIndicatorsFromDB,
|
||||||
static unsigned long Ind_GetNumFilesInDocumZonesOfCrsFromDB (long CrsCod)
|
static unsigned long Ind_GetNumFilesInDocumZonesOfCrsFromDB (long CrsCod)
|
||||||
{
|
{
|
||||||
extern const Brw_FileBrowser_t Brw_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
|
extern const Brw_FileBrowser_t Brw_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumFiles;
|
unsigned long NumFiles;
|
||||||
|
|
||||||
/***** Get number of files in document zones of a course from database *****/
|
/***** Get number of files in document zones of a course from database *****/
|
||||||
if (asprintf (&Query,"SELECT"
|
DB_BuildQuery ("SELECT"
|
||||||
" (SELECT COALESCE(SUM(NumFiles),0)"
|
" (SELECT COALESCE(SUM(NumFiles),0)"
|
||||||
" FROM file_browser_size"
|
" FROM file_browser_size"
|
||||||
" WHERE FileBrowser=%u AND Cod=%ld) +"
|
" WHERE FileBrowser=%u AND Cod=%ld) +"
|
||||||
" (SELECT COALESCE(SUM(file_browser_size.NumFiles),0)"
|
" (SELECT COALESCE(SUM(file_browser_size.NumFiles),0)"
|
||||||
" FROM crs_grp_types,crs_grp,file_browser_size"
|
" FROM crs_grp_types,crs_grp,file_browser_size"
|
||||||
" WHERE crs_grp_types.CrsCod=%ld"
|
" WHERE crs_grp_types.CrsCod=%ld"
|
||||||
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
|
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
|
||||||
" AND file_browser_size.FileBrowser=%u"
|
" AND file_browser_size.FileBrowser=%u"
|
||||||
" AND file_browser_size.Cod=crs_grp.GrpCod)",
|
" AND file_browser_size.Cod=crs_grp.GrpCod)",
|
||||||
(unsigned) Brw_FileBrowserForDB_files[Brw_ADMI_DOC_CRS],
|
(unsigned) Brw_FileBrowserForDB_files[Brw_ADMI_DOC_CRS],
|
||||||
CrsCod,
|
CrsCod,
|
||||||
CrsCod,
|
CrsCod,
|
||||||
(unsigned) Brw_FileBrowserForDB_files[Brw_ADMI_DOC_GRP]) < 0)
|
(unsigned) Brw_FileBrowserForDB_files[Brw_ADMI_DOC_GRP]);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QuerySELECT_new (&mysql_res,"can not get the number of files");
|
||||||
DB_QuerySELECT_free (Query,&mysql_res,"can not get the number of files");
|
|
||||||
|
|
||||||
/***** Get row *****/
|
/***** Get row *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -1595,28 +1546,26 @@ static unsigned long Ind_GetNumFilesInDocumZonesOfCrsFromDB (long CrsCod)
|
||||||
static unsigned long Ind_GetNumFilesInShareZonesOfCrsFromDB (long CrsCod)
|
static unsigned long Ind_GetNumFilesInShareZonesOfCrsFromDB (long CrsCod)
|
||||||
{
|
{
|
||||||
extern const Brw_FileBrowser_t Brw_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
|
extern const Brw_FileBrowser_t Brw_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumFiles;
|
unsigned long NumFiles;
|
||||||
|
|
||||||
/***** Get number of files in document zones of a course from database *****/
|
/***** Get number of files in document zones of a course from database *****/
|
||||||
if (asprintf (&Query,"SELECT"
|
DB_BuildQuery ("SELECT"
|
||||||
" (SELECT COALESCE(SUM(NumFiles),0)"
|
" (SELECT COALESCE(SUM(NumFiles),0)"
|
||||||
" FROM file_browser_size"
|
" FROM file_browser_size"
|
||||||
" WHERE FileBrowser=%u AND Cod=%ld) +"
|
" WHERE FileBrowser=%u AND Cod=%ld) +"
|
||||||
" (SELECT COALESCE(SUM(file_browser_size.NumFiles),0)"
|
" (SELECT COALESCE(SUM(file_browser_size.NumFiles),0)"
|
||||||
" FROM crs_grp_types,crs_grp,file_browser_size"
|
" FROM crs_grp_types,crs_grp,file_browser_size"
|
||||||
" WHERE crs_grp_types.CrsCod=%ld"
|
" WHERE crs_grp_types.CrsCod=%ld"
|
||||||
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
|
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
|
||||||
" AND file_browser_size.FileBrowser=%u"
|
" AND file_browser_size.FileBrowser=%u"
|
||||||
" AND file_browser_size.Cod=crs_grp.GrpCod)",
|
" AND file_browser_size.Cod=crs_grp.GrpCod)",
|
||||||
(unsigned) Brw_FileBrowserForDB_files[Brw_ADMI_SHR_CRS],
|
(unsigned) Brw_FileBrowserForDB_files[Brw_ADMI_SHR_CRS],
|
||||||
CrsCod,
|
CrsCod,
|
||||||
CrsCod,
|
CrsCod,
|
||||||
(unsigned) Brw_FileBrowserForDB_files[Brw_ADMI_SHR_GRP]) < 0)
|
(unsigned) Brw_FileBrowserForDB_files[Brw_ADMI_SHR_GRP]);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QuerySELECT_new (&mysql_res,"can not get the number of files");
|
||||||
DB_QuerySELECT_free (Query,&mysql_res,"can not get the number of files");
|
|
||||||
|
|
||||||
/***** Get row *****/
|
/***** Get row *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -1638,19 +1587,17 @@ static unsigned long Ind_GetNumFilesInShareZonesOfCrsFromDB (long CrsCod)
|
||||||
static unsigned long Ind_GetNumFilesInAssigZonesOfCrsFromDB (long CrsCod)
|
static unsigned long Ind_GetNumFilesInAssigZonesOfCrsFromDB (long CrsCod)
|
||||||
{
|
{
|
||||||
extern const Brw_FileBrowser_t Brw_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
|
extern const Brw_FileBrowser_t Brw_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumFiles;
|
unsigned long NumFiles;
|
||||||
|
|
||||||
/***** Get number of files in document zones of a course from database *****/
|
/***** Get number of files in document zones of a course from database *****/
|
||||||
if (asprintf (&Query,"SELECT COALESCE(SUM(NumFiles),0)"
|
DB_BuildQuery ("SELECT COALESCE(SUM(NumFiles),0)"
|
||||||
" FROM file_browser_size"
|
" FROM file_browser_size"
|
||||||
" WHERE FileBrowser=%u AND Cod=%ld",
|
" WHERE FileBrowser=%u AND Cod=%ld",
|
||||||
(unsigned) Brw_FileBrowserForDB_files[Brw_ADMI_ASG_USR],
|
(unsigned) Brw_FileBrowserForDB_files[Brw_ADMI_ASG_USR],
|
||||||
CrsCod) < 0)
|
CrsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QuerySELECT_new (&mysql_res,"can not get the number of files");
|
||||||
DB_QuerySELECT_free (Query,&mysql_res,"can not get the number of files");
|
|
||||||
|
|
||||||
/***** Get row *****/
|
/***** Get row *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -1672,19 +1619,17 @@ static unsigned long Ind_GetNumFilesInAssigZonesOfCrsFromDB (long CrsCod)
|
||||||
static unsigned long Ind_GetNumFilesInWorksZonesOfCrsFromDB (long CrsCod)
|
static unsigned long Ind_GetNumFilesInWorksZonesOfCrsFromDB (long CrsCod)
|
||||||
{
|
{
|
||||||
extern const Brw_FileBrowser_t Brw_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
|
extern const Brw_FileBrowser_t Brw_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumFiles;
|
unsigned long NumFiles;
|
||||||
|
|
||||||
/***** Get number of files in document zones of a course from database *****/
|
/***** Get number of files in document zones of a course from database *****/
|
||||||
if (asprintf (&Query,"SELECT COALESCE(SUM(NumFiles),0)"
|
DB_BuildQuery ("SELECT COALESCE(SUM(NumFiles),0)"
|
||||||
" FROM file_browser_size"
|
" FROM file_browser_size"
|
||||||
" WHERE FileBrowser=%u AND Cod=%ld",
|
" WHERE FileBrowser=%u AND Cod=%ld",
|
||||||
(unsigned) Brw_FileBrowserForDB_files[Brw_ADMI_WRK_USR],
|
(unsigned) Brw_FileBrowserForDB_files[Brw_ADMI_WRK_USR],
|
||||||
CrsCod) < 0)
|
CrsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QuerySELECT_new (&mysql_res,"can not get the number of files");
|
||||||
DB_QuerySELECT_free (Query,&mysql_res,"can not get the number of files");
|
|
||||||
|
|
||||||
/***** Get row *****/
|
/***** Get row *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
38
swad_info.c
38
swad_info.c
|
@ -540,7 +540,6 @@ static bool Inf_CheckIfIHaveReadInfo (void)
|
||||||
|
|
||||||
bool Inf_GetIfIMustReadAnyCrsInfoInThisCrs (void)
|
bool Inf_GetIfIMustReadAnyCrsInfoInThisCrs (void)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRow,NumRows;
|
unsigned long NumRow,NumRows;
|
||||||
|
@ -553,15 +552,14 @@ bool Inf_GetIfIMustReadAnyCrsInfoInThisCrs (void)
|
||||||
Gbl.CurrentCrs.Info.MustBeRead[InfoType] = false;
|
Gbl.CurrentCrs.Info.MustBeRead[InfoType] = false;
|
||||||
|
|
||||||
/***** Get info types where students must read info *****/
|
/***** Get info types where students must read info *****/
|
||||||
if (asprintf (&Query,"SELECT InfoType FROM crs_info_src"
|
DB_BuildQuery ("SELECT InfoType FROM crs_info_src"
|
||||||
" WHERE CrsCod=%ld AND MustBeRead='Y'"
|
" WHERE CrsCod=%ld AND MustBeRead='Y'"
|
||||||
" AND InfoType NOT IN"
|
" AND InfoType NOT IN"
|
||||||
" (SELECT InfoType FROM crs_info_read"
|
" (SELECT InfoType FROM crs_info_read"
|
||||||
" WHERE UsrCod=%ld AND CrsCod=%ld)",
|
" WHERE UsrCod=%ld AND CrsCod=%ld)",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.CurrentCrs.Crs.CrsCod) < 0)
|
Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.CurrentCrs.Crs.CrsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get if you must read any course info");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get if you must read any course info");
|
|
||||||
|
|
||||||
/***** Set must-be-read to true for each rown in result *****/
|
/***** Set must-be-read to true for each rown in result *****/
|
||||||
for (NumRow = 0;
|
for (NumRow = 0;
|
||||||
|
@ -1542,17 +1540,15 @@ void Inf_SetInfoSrcIntoDB (Inf_InfoSrc_t InfoSrc)
|
||||||
|
|
||||||
Inf_InfoSrc_t Inf_GetInfoSrcFromDB (long CrsCod,Inf_InfoType_t InfoType)
|
Inf_InfoSrc_t Inf_GetInfoSrcFromDB (long CrsCod,Inf_InfoType_t InfoType)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
Inf_InfoSrc_t InfoSrc;
|
Inf_InfoSrc_t InfoSrc;
|
||||||
|
|
||||||
/***** Get info source for a specific type of info from database *****/
|
/***** Get info source for a specific type of info from database *****/
|
||||||
if (asprintf (&Query,"SELECT InfoSrc FROM crs_info_src"
|
DB_BuildQuery ("SELECT InfoSrc FROM crs_info_src"
|
||||||
" WHERE CrsCod=%ld AND InfoType='%s'",
|
" WHERE CrsCod=%ld AND InfoType='%s'",
|
||||||
CrsCod,Inf_NamesInDBForInfoType[InfoType]) < 0)
|
CrsCod,Inf_NamesInDBForInfoType[InfoType]);
|
||||||
Lay_NotEnoughMemoryExit ();
|
if (DB_QuerySELECT_new (&mysql_res,"can not get info source"))
|
||||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get info source"))
|
|
||||||
{
|
{
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -1577,7 +1573,6 @@ void Inf_GetAndCheckInfoSrcFromDB (long CrsCod,
|
||||||
Inf_InfoType_t InfoType,
|
Inf_InfoType_t InfoType,
|
||||||
Inf_InfoSrc_t *InfoSrc,bool *MustBeRead)
|
Inf_InfoSrc_t *InfoSrc,bool *MustBeRead)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
|
@ -1587,11 +1582,10 @@ void Inf_GetAndCheckInfoSrcFromDB (long CrsCod,
|
||||||
*MustBeRead = false;
|
*MustBeRead = false;
|
||||||
|
|
||||||
/***** Get info source for a specific type of info from database *****/
|
/***** Get info source for a specific type of info from database *****/
|
||||||
if (asprintf (&Query,"SELECT InfoSrc,MustBeRead FROM crs_info_src"
|
DB_BuildQuery ("SELECT InfoSrc,MustBeRead FROM crs_info_src"
|
||||||
" WHERE CrsCod=%ld AND InfoType='%s'",
|
" WHERE CrsCod=%ld AND InfoType='%s'",
|
||||||
CrsCod,Inf_NamesInDBForInfoType[InfoType]) < 0)
|
CrsCod,Inf_NamesInDBForInfoType[InfoType]);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get info source");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get info source");
|
|
||||||
|
|
||||||
/***** The result of the query must have one row or none *****/
|
/***** The result of the query must have one row or none *****/
|
||||||
if (NumRows == 1)
|
if (NumRows == 1)
|
||||||
|
|
|
@ -118,7 +118,6 @@ void Ins_SeeInsWithPendingCtrs (void)
|
||||||
extern const char *Txt_Institution;
|
extern const char *Txt_Institution;
|
||||||
extern const char *Txt_Centres_ABBREVIATION;
|
extern const char *Txt_Centres_ABBREVIATION;
|
||||||
extern const char *Txt_There_are_no_institutions_with_requests_for_centres_to_be_confirmed;
|
extern const char *Txt_There_are_no_institutions_with_requests_for_centres_to_be_confirmed;
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumInss;
|
unsigned NumInss;
|
||||||
|
@ -130,30 +129,29 @@ void Ins_SeeInsWithPendingCtrs (void)
|
||||||
switch (Gbl.Usrs.Me.Role.Logged)
|
switch (Gbl.Usrs.Me.Role.Logged)
|
||||||
{
|
{
|
||||||
case Rol_INS_ADM:
|
case Rol_INS_ADM:
|
||||||
if (asprintf (&Query,"SELECT centres.InsCod,COUNT(*)"
|
DB_BuildQuery ("SELECT centres.InsCod,COUNT(*)"
|
||||||
" FROM centres,ins_admin,institutions"
|
" FROM centres,ins_admin,institutions"
|
||||||
" WHERE (centres.Status & %u)<>0"
|
" WHERE (centres.Status & %u)<>0"
|
||||||
" AND centres.InsCod=ins_admin.InsCod AND ins_admin.UsrCod=%ld"
|
" AND centres.InsCod=ins_admin.InsCod AND ins_admin.UsrCod=%ld"
|
||||||
" AND centres.InsCod=institutions.InsCod"
|
" AND centres.InsCod=institutions.InsCod"
|
||||||
" GROUP BY centres.InsCod ORDER BY institutions.ShortName",
|
" GROUP BY centres.InsCod ORDER BY institutions.ShortName",
|
||||||
(unsigned) Ctr_STATUS_BIT_PENDING,Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
(unsigned) Ctr_STATUS_BIT_PENDING,
|
||||||
Lay_NotEnoughMemoryExit ();
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
break;
|
break;
|
||||||
case Rol_SYS_ADM:
|
case Rol_SYS_ADM:
|
||||||
if (asprintf (&Query,"SELECT centres.InsCod,COUNT(*)"
|
DB_BuildQuery ("SELECT centres.InsCod,COUNT(*)"
|
||||||
" FROM centres,institutions"
|
" FROM centres,institutions"
|
||||||
" WHERE (centres.Status & %u)<>0"
|
" WHERE (centres.Status & %u)<>0"
|
||||||
" AND centres.InsCod=institutions.InsCod"
|
" AND centres.InsCod=institutions.InsCod"
|
||||||
" GROUP BY centres.InsCod ORDER BY institutions.ShortName",
|
" GROUP BY centres.InsCod ORDER BY institutions.ShortName",
|
||||||
(unsigned) Ctr_STATUS_BIT_PENDING) < 0)
|
(unsigned) Ctr_STATUS_BIT_PENDING);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
default: // Forbidden for other users
|
default: // Forbidden for other users
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Get institutions *****/
|
/***** Get institutions *****/
|
||||||
if ((NumInss = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get institutions with pending centres")))
|
if ((NumInss = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get institutions with pending centres")))
|
||||||
{
|
{
|
||||||
/***** Start box and table *****/
|
/***** Start box and table *****/
|
||||||
Box_StartBoxTable (NULL,Txt_Institutions_with_pending_centres,NULL,
|
Box_StartBoxTable (NULL,Txt_Institutions_with_pending_centres,NULL,
|
||||||
|
@ -965,7 +963,6 @@ static void Ins_PutIconToViewInstitutions (void)
|
||||||
void Ins_GetListInstitutions (long CtyCod,Ins_GetExtraData_t GetExtraData)
|
void Ins_GetListInstitutions (long CtyCod,Ins_GetExtraData_t GetExtraData)
|
||||||
{
|
{
|
||||||
char OrderBySubQuery[256];
|
char OrderBySubQuery[256];
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
|
@ -976,12 +973,11 @@ void Ins_GetListInstitutions (long CtyCod,Ins_GetExtraData_t GetExtraData)
|
||||||
switch (GetExtraData)
|
switch (GetExtraData)
|
||||||
{
|
{
|
||||||
case Ins_GET_BASIC_DATA:
|
case Ins_GET_BASIC_DATA:
|
||||||
if (asprintf (&Query,"SELECT InsCod,CtyCod,Status,RequesterUsrCod,ShortName,FullName,WWW"
|
DB_BuildQuery ("SELECT InsCod,CtyCod,Status,RequesterUsrCod,ShortName,FullName,WWW"
|
||||||
" FROM institutions"
|
" FROM institutions"
|
||||||
" WHERE CtyCod=%ld"
|
" WHERE CtyCod=%ld"
|
||||||
" ORDER BY FullName",
|
" ORDER BY FullName",
|
||||||
CtyCod) < 0)
|
CtyCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Ins_GET_EXTRA_DATA:
|
case Ins_GET_EXTRA_DATA:
|
||||||
switch (Gbl.Inss.SelectedOrder)
|
switch (Gbl.Inss.SelectedOrder)
|
||||||
|
@ -993,27 +989,26 @@ void Ins_GetListInstitutions (long CtyCod,Ins_GetExtraData_t GetExtraData)
|
||||||
sprintf (OrderBySubQuery,"NumUsrs DESC,FullName");
|
sprintf (OrderBySubQuery,"NumUsrs DESC,FullName");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (asprintf (&Query,"(SELECT institutions.InsCod,institutions.CtyCod,"
|
DB_BuildQuery ("(SELECT institutions.InsCod,institutions.CtyCod,"
|
||||||
"institutions.Status,institutions.RequesterUsrCod,"
|
"institutions.Status,institutions.RequesterUsrCod,"
|
||||||
"institutions.ShortName,institutions.FullName,"
|
"institutions.ShortName,institutions.FullName,"
|
||||||
"institutions.WWW,COUNT(*) AS NumUsrs"
|
"institutions.WWW,COUNT(*) AS NumUsrs"
|
||||||
" FROM institutions,usr_data"
|
" FROM institutions,usr_data"
|
||||||
" WHERE institutions.CtyCod=%ld"
|
" WHERE institutions.CtyCod=%ld"
|
||||||
" AND institutions.InsCod=usr_data.InsCod"
|
" AND institutions.InsCod=usr_data.InsCod"
|
||||||
" GROUP BY institutions.InsCod)"
|
" GROUP BY institutions.InsCod)"
|
||||||
" UNION "
|
" UNION "
|
||||||
"(SELECT InsCod,CtyCod,Status,RequesterUsrCod,ShortName,FullName,WWW,0 AS NumUsrs"
|
"(SELECT InsCod,CtyCod,Status,RequesterUsrCod,ShortName,FullName,WWW,0 AS NumUsrs"
|
||||||
" FROM institutions"
|
" FROM institutions"
|
||||||
" WHERE CtyCod=%ld"
|
" WHERE CtyCod=%ld"
|
||||||
" AND InsCod NOT IN"
|
" AND InsCod NOT IN"
|
||||||
" (SELECT DISTINCT InsCod FROM usr_data))"
|
" (SELECT DISTINCT InsCod FROM usr_data))"
|
||||||
" ORDER BY %s",
|
" ORDER BY %s",
|
||||||
CtyCod,CtyCod,
|
CtyCod,CtyCod,
|
||||||
OrderBySubQuery) < 0)
|
OrderBySubQuery);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get institutions");
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get institutions");
|
||||||
|
|
||||||
if (NumRows) // Institutions found...
|
if (NumRows) // Institutions found...
|
||||||
{
|
{
|
||||||
|
@ -1123,7 +1118,6 @@ void Ins_WriteInstitutionNameAndCty (long InsCod)
|
||||||
bool Ins_GetDataOfInstitutionByCod (struct Instit *Ins,
|
bool Ins_GetDataOfInstitutionByCod (struct Instit *Ins,
|
||||||
Ins_GetExtraData_t GetExtraData)
|
Ins_GetExtraData_t GetExtraData)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
bool InsFound = false;
|
bool InsFound = false;
|
||||||
|
@ -1143,13 +1137,12 @@ bool Ins_GetDataOfInstitutionByCod (struct Instit *Ins,
|
||||||
if (Ins->InsCod > 0)
|
if (Ins->InsCod > 0)
|
||||||
{
|
{
|
||||||
/***** Get data of an institution from database *****/
|
/***** Get data of an institution from database *****/
|
||||||
if (asprintf (&Query,"SELECT CtyCod,Status,RequesterUsrCod,ShortName,FullName,WWW"
|
DB_BuildQuery ("SELECT CtyCod,Status,RequesterUsrCod,ShortName,FullName,WWW"
|
||||||
" FROM institutions WHERE InsCod=%ld",
|
" FROM institutions WHERE InsCod=%ld",
|
||||||
Ins->InsCod) < 0)
|
Ins->InsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
|
|
||||||
/***** Count number of rows in result *****/
|
/***** Count number of rows in result *****/
|
||||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get data of an institution")) // Institution found...
|
if (DB_QuerySELECT_new (&mysql_res,"can not get data of an institution")) // Institution found...
|
||||||
{
|
{
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -1215,7 +1208,6 @@ void Ins_FlushCacheShortNameOfInstitution (void)
|
||||||
|
|
||||||
void Ins_GetShortNameOfInstitution (struct Instit *Ins)
|
void Ins_GetShortNameOfInstitution (struct Instit *Ins)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
|
@ -1237,10 +1229,9 @@ void Ins_GetShortNameOfInstitution (struct Instit *Ins)
|
||||||
/***** 3. Slow: get short name of institution from database *****/
|
/***** 3. Slow: get short name of institution from database *****/
|
||||||
Gbl.Cache.InstitutionShrtName.InsCod = Ins->InsCod;
|
Gbl.Cache.InstitutionShrtName.InsCod = Ins->InsCod;
|
||||||
|
|
||||||
if (asprintf (&Query,"SELECT ShortName FROM institutions WHERE InsCod=%ld",
|
DB_BuildQuery ("SELECT ShortName FROM institutions WHERE InsCod=%ld",
|
||||||
Ins->InsCod) < 0)
|
Ins->InsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
if (DB_QuerySELECT_new (&mysql_res,"can not get the short name of an institution") == 1)
|
||||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get the short name of an institution") == 1)
|
|
||||||
{
|
{
|
||||||
/* Get the short name of this institution */
|
/* Get the short name of this institution */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -1273,7 +1264,6 @@ static void Ins_GetFullNameAndCtyOfInstitution (struct Instit *Ins,
|
||||||
char CtyName[Hie_MAX_BYTES_FULL_NAME + 1])
|
char CtyName[Hie_MAX_BYTES_FULL_NAME + 1])
|
||||||
{
|
{
|
||||||
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
|
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
|
@ -1298,13 +1288,12 @@ static void Ins_GetFullNameAndCtyOfInstitution (struct Instit *Ins,
|
||||||
/***** 3. Slow: get full name and country of institution from database *****/
|
/***** 3. Slow: get full name and country of institution from database *****/
|
||||||
Gbl.Cache.InstitutionFullNameAndCty.InsCod = Ins->InsCod;
|
Gbl.Cache.InstitutionFullNameAndCty.InsCod = Ins->InsCod;
|
||||||
|
|
||||||
if (asprintf (&Query,"SELECT institutions.FullName,countries.Name_%s"
|
DB_BuildQuery ("SELECT institutions.FullName,countries.Name_%s"
|
||||||
" FROM institutions,countries"
|
" FROM institutions,countries"
|
||||||
" WHERE institutions.InsCod=%ld"
|
" WHERE institutions.InsCod=%ld"
|
||||||
" AND institutions.CtyCod=countries.CtyCod",
|
" AND institutions.CtyCod=countries.CtyCod",
|
||||||
Txt_STR_LANG_ID[Gbl.Prefs.Language],Ins->InsCod) < 0)
|
Txt_STR_LANG_ID[Gbl.Prefs.Language],Ins->InsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
if (DB_QuerySELECT_new (&mysql_res,"can not get the full name of an institution") == 1)
|
||||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get the full name of an institution") == 1)
|
|
||||||
{
|
{
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -1354,7 +1343,6 @@ void Ins_FreeListInstitutions (void)
|
||||||
void Ins_WriteSelectorOfInstitution (void)
|
void Ins_WriteSelectorOfInstitution (void)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Institution;
|
extern const char *Txt_Institution;
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumInss;
|
unsigned NumInss;
|
||||||
|
@ -1378,12 +1366,11 @@ void Ins_WriteSelectorOfInstitution (void)
|
||||||
if (Gbl.CurrentCty.Cty.CtyCod > 0)
|
if (Gbl.CurrentCty.Cty.CtyCod > 0)
|
||||||
{
|
{
|
||||||
/***** Get institutions of selected country from database *****/
|
/***** Get institutions of selected country from database *****/
|
||||||
if (asprintf (&Query,"SELECT DISTINCT InsCod,ShortName FROM institutions"
|
DB_BuildQuery ("SELECT DISTINCT InsCod,ShortName FROM institutions"
|
||||||
" WHERE CtyCod=%ld"
|
" WHERE CtyCod=%ld"
|
||||||
" ORDER BY ShortName",
|
" ORDER BY ShortName",
|
||||||
Gbl.CurrentCty.Cty.CtyCod) < 0)
|
Gbl.CurrentCty.Cty.CtyCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumInss = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get institutions");
|
||||||
NumInss = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get institutions");
|
|
||||||
|
|
||||||
/***** List institutions *****/
|
/***** List institutions *****/
|
||||||
for (NumIns = 0;
|
for (NumIns = 0;
|
||||||
|
|
18
swad_link.c
18
swad_link.c
|
@ -254,7 +254,6 @@ void Lnk_EditLinks (void)
|
||||||
|
|
||||||
void Lnk_GetListLinks (void)
|
void Lnk_GetListLinks (void)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
|
@ -264,10 +263,9 @@ void Lnk_GetListLinks (void)
|
||||||
if (Gbl.DB.DatabaseIsOpen)
|
if (Gbl.DB.DatabaseIsOpen)
|
||||||
{
|
{
|
||||||
/***** Get institutional links from database *****/
|
/***** Get institutional links from database *****/
|
||||||
if (asprintf (&Query,"SELECT LnkCod,ShortName,FullName,WWW"
|
DB_BuildQuery ("SELECT LnkCod,ShortName,FullName,WWW"
|
||||||
" FROM links ORDER BY ShortName") < 0)
|
" FROM links ORDER BY ShortName");
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get institutional links");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get institutional links");
|
|
||||||
|
|
||||||
if (NumRows) // Places found...
|
if (NumRows) // Places found...
|
||||||
{
|
{
|
||||||
|
@ -318,7 +316,6 @@ void Lnk_GetListLinks (void)
|
||||||
|
|
||||||
void Lnk_GetDataOfLinkByCod (struct Link *Lnk)
|
void Lnk_GetDataOfLinkByCod (struct Link *Lnk)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
|
@ -330,11 +327,10 @@ void Lnk_GetDataOfLinkByCod (struct Link *Lnk)
|
||||||
if (Lnk->LnkCod > 0)
|
if (Lnk->LnkCod > 0)
|
||||||
{
|
{
|
||||||
/***** Get data of an institutional link from database *****/
|
/***** Get data of an institutional link from database *****/
|
||||||
if (asprintf (&Query,"SELECT ShortName,FullName,WWW FROM links"
|
DB_BuildQuery ("SELECT ShortName,FullName,WWW FROM links"
|
||||||
" WHERE LnkCod=%ld",
|
" WHERE LnkCod=%ld",
|
||||||
Lnk->LnkCod) < 0)
|
Lnk->LnkCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get data of an institutional link");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get data of an institutional link");
|
|
||||||
|
|
||||||
if (NumRows) // Link found...
|
if (NumRows) // Link found...
|
||||||
{
|
{
|
||||||
|
|
81
swad_mail.c
81
swad_mail.c
|
@ -257,18 +257,17 @@ static void Mai_GetListMailDomainsAllowedForNotif (void)
|
||||||
sprintf (OrderBySubQuery,"N DESC,Info,Domain");
|
sprintf (OrderBySubQuery,"N DESC,Info,Domain");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (asprintf (&Query,"(SELECT mail_domains.MaiCod,mail_domains.Domain AS Domain,mail_domains.Info AS Info,T1.N AS N"
|
DB_BuildQuery ("(SELECT mail_domains.MaiCod,mail_domains.Domain AS Domain,mail_domains.Info AS Info,T1.N AS N"
|
||||||
" FROM mail_domains,T1"
|
" FROM mail_domains,T1"
|
||||||
" WHERE mail_domains.Domain=T1.Domain COLLATE 'latin1_bin')"
|
" WHERE mail_domains.Domain=T1.Domain COLLATE 'latin1_bin')"
|
||||||
" UNION "
|
" UNION "
|
||||||
"(SELECT MaiCod,Domain,Info,0 AS N"
|
"(SELECT MaiCod,Domain,Info,0 AS N"
|
||||||
" FROM mail_domains"
|
" FROM mail_domains"
|
||||||
" WHERE Domain NOT IN (SELECT Domain COLLATE 'latin1_bin' FROM T2))"
|
" WHERE Domain NOT IN (SELECT Domain COLLATE 'latin1_bin' FROM T2))"
|
||||||
" ORDER BY %s", // COLLATE necessary to avoid error in comparisons
|
" ORDER BY %s", // COLLATE necessary to avoid error in comparisons
|
||||||
OrderBySubQuery) < 0)
|
OrderBySubQuery);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
|
|
||||||
if ((NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get mail domains"))) // Mail domains found...
|
if ((NumRows = DB_QuerySELECT_new (&mysql_res,"can not get mail domains"))) // Mail domains found...
|
||||||
{
|
{
|
||||||
Gbl.Mails.Num = (unsigned) NumRows;
|
Gbl.Mails.Num = (unsigned) NumRows;
|
||||||
|
|
||||||
|
@ -396,7 +395,6 @@ void Mai_WriteWarningEmailNotifications (void)
|
||||||
|
|
||||||
void Mai_GetDataOfMailDomainByCod (struct Mail *Mai)
|
void Mai_GetDataOfMailDomainByCod (struct Mail *Mai)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
|
@ -408,10 +406,9 @@ void Mai_GetDataOfMailDomainByCod (struct Mail *Mai)
|
||||||
if (Mai->MaiCod > 0)
|
if (Mai->MaiCod > 0)
|
||||||
{
|
{
|
||||||
/***** Get data of a mail domain from database *****/
|
/***** Get data of a mail domain from database *****/
|
||||||
if (asprintf (&Query,"SELECT Domain,Info FROM mail_domains WHERE MaiCod=%ld",
|
DB_BuildQuery ("SELECT Domain,Info FROM mail_domains WHERE MaiCod=%ld",
|
||||||
Mai->MaiCod) < 0)
|
Mai->MaiCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get data of a mail domain");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get data of a mail domain");
|
|
||||||
|
|
||||||
if (NumRows) // Mail found...
|
if (NumRows) // Mail found...
|
||||||
{
|
{
|
||||||
|
@ -1076,18 +1073,16 @@ bool Mai_CheckIfEmailIsValid (const char *Email)
|
||||||
|
|
||||||
bool Mai_GetEmailFromUsrCod (struct UsrData *UsrDat)
|
bool Mai_GetEmailFromUsrCod (struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
bool Found;
|
bool Found;
|
||||||
|
|
||||||
/***** Get current (last updated) user's nickname from database *****/
|
/***** Get current (last updated) user's nickname from database *****/
|
||||||
if (asprintf (&Query,"SELECT E_mail,Confirmed FROM usr_emails"
|
DB_BuildQuery ("SELECT E_mail,Confirmed FROM usr_emails"
|
||||||
" WHERE UsrCod=%ld ORDER BY CreatTime DESC LIMIT 1",
|
" WHERE UsrCod=%ld ORDER BY CreatTime DESC LIMIT 1",
|
||||||
UsrDat->UsrCod) < 0)
|
UsrDat->UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get email address");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get email address");
|
|
||||||
|
|
||||||
if (NumRows == 0)
|
if (NumRows == 0)
|
||||||
{
|
{
|
||||||
|
@ -1118,7 +1113,6 @@ bool Mai_GetEmailFromUsrCod (struct UsrData *UsrDat)
|
||||||
|
|
||||||
long Mai_GetUsrCodFromEmail (const char Email[Cns_MAX_BYTES_EMAIL_ADDRESS + 1])
|
long Mai_GetUsrCodFromEmail (const char Email[Cns_MAX_BYTES_EMAIL_ADDRESS + 1])
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumUsrs;
|
unsigned NumUsrs;
|
||||||
|
@ -1129,12 +1123,11 @@ long Mai_GetUsrCodFromEmail (const char Email[Cns_MAX_BYTES_EMAIL_ADDRESS + 1])
|
||||||
{
|
{
|
||||||
/***** Get user's code from database *****/
|
/***** Get user's code from database *****/
|
||||||
/* Check if user code from table usr_emails is also in table usr_data */
|
/* Check if user code from table usr_emails is also in table usr_data */
|
||||||
if (asprintf (&Query,"SELECT usr_emails.UsrCod FROM usr_emails,usr_data"
|
DB_BuildQuery ("SELECT usr_emails.UsrCod FROM usr_emails,usr_data"
|
||||||
" WHERE usr_emails.E_mail='%s'"
|
" WHERE usr_emails.E_mail='%s'"
|
||||||
" AND usr_emails.UsrCod=usr_data.UsrCod",
|
" AND usr_emails.UsrCod=usr_data.UsrCod",
|
||||||
Email) < 0)
|
Email);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumUsrs = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get user's code");
|
||||||
NumUsrs = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get user's code");
|
|
||||||
if (NumUsrs == 0)
|
if (NumUsrs == 0)
|
||||||
/* User not found for this email ==> set user's code to void */
|
/* User not found for this email ==> set user's code to void */
|
||||||
UsrCod = -1L;
|
UsrCod = -1L;
|
||||||
|
@ -1240,7 +1233,6 @@ static void Mai_ShowFormChangeUsrEmail (const struct UsrData *UsrDat,bool ItsMe,
|
||||||
extern const char *Txt_Email;
|
extern const char *Txt_Email;
|
||||||
extern const char *Txt_Change_email;
|
extern const char *Txt_Change_email;
|
||||||
extern const char *Txt_Save;
|
extern const char *Txt_Save;
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumEmails;
|
unsigned NumEmails;
|
||||||
|
@ -1259,12 +1251,11 @@ static void Mai_ShowFormChangeUsrEmail (const struct UsrData *UsrDat,bool ItsMe,
|
||||||
Ale_ShowAlert (Ale_WARNING,Txt_Please_confirm_your_email_address);
|
Ale_ShowAlert (Ale_WARNING,Txt_Please_confirm_your_email_address);
|
||||||
|
|
||||||
/***** Get my emails *****/
|
/***** Get my emails *****/
|
||||||
if (asprintf (&Query,"SELECT E_mail,Confirmed FROM usr_emails"
|
DB_BuildQuery ("SELECT E_mail,Confirmed FROM usr_emails"
|
||||||
" WHERE UsrCod=%ld"
|
" WHERE UsrCod=%ld"
|
||||||
" ORDER BY CreatTime DESC",
|
" ORDER BY CreatTime DESC",
|
||||||
UsrDat->UsrCod) < 0)
|
UsrDat->UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumEmails = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get old email addresses of a user");
|
||||||
NumEmails = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get old email addresses of a user");
|
|
||||||
|
|
||||||
/***** Start table *****/
|
/***** Start table *****/
|
||||||
Tbl_StartTableWide (2);
|
Tbl_StartTableWide (2);
|
||||||
|
@ -1840,11 +1831,10 @@ void Mai_ConfirmEmail (void)
|
||||||
Par_GetParToText ("key",MailKey,Mai_LENGTH_EMAIL_CONFIRM_KEY);
|
Par_GetParToText ("key",MailKey,Mai_LENGTH_EMAIL_CONFIRM_KEY);
|
||||||
|
|
||||||
/***** Get user's code and email from key *****/
|
/***** Get user's code and email from key *****/
|
||||||
if (asprintf (&Query,"SELECT UsrCod,E_mail FROM pending_emails"
|
DB_BuildQuery ("SELECT UsrCod,E_mail FROM pending_emails"
|
||||||
" WHERE MailKey='%s'",
|
" WHERE MailKey='%s'",
|
||||||
MailKey) < 0)
|
MailKey);
|
||||||
Lay_NotEnoughMemoryExit ();
|
if (DB_QuerySELECT_new (&mysql_res,"can not get user's code and email from key"))
|
||||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get user's code and email from key"))
|
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
|
@ -1871,11 +1861,10 @@ void Mai_ConfirmEmail (void)
|
||||||
|
|
||||||
/***** Check user's code and email
|
/***** Check user's code and email
|
||||||
and get if email is already confirmed *****/
|
and get if email is already confirmed *****/
|
||||||
if (asprintf (&Query,"SELECT Confirmed FROM usr_emails"
|
DB_BuildQuery ("SELECT Confirmed FROM usr_emails"
|
||||||
" WHERE UsrCod=%ld AND E_mail='%s'",
|
" WHERE UsrCod=%ld AND E_mail='%s'",
|
||||||
UsrCod,Email) < 0)
|
UsrCod,Email);
|
||||||
Lay_NotEnoughMemoryExit ();
|
if (DB_QuerySELECT_new (&mysql_res,"can not get user's code and email"))
|
||||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get user's code and email"))
|
|
||||||
{
|
{
|
||||||
Confirmed = (row[0][0] == 'Y');
|
Confirmed = (row[0][0] == 'Y');
|
||||||
|
|
||||||
|
|
40
swad_mark.c
40
swad_mark.c
|
@ -190,7 +190,6 @@ static void Mrk_GetNumRowsHeaderAndFooter (struct MarksProperties *Marks)
|
||||||
{
|
{
|
||||||
extern const Brw_FileBrowser_t Brw_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
|
extern const Brw_FileBrowser_t Brw_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
|
||||||
long Cod = Brw_GetCodForFiles ();
|
long Cod = Brw_GetCodForFiles ();
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
|
@ -199,18 +198,17 @@ static void Mrk_GetNumRowsHeaderAndFooter (struct MarksProperties *Marks)
|
||||||
/* There should be a single file in database.
|
/* There should be a single file in database.
|
||||||
If, due to an error, there is more than one file,
|
If, due to an error, there is more than one file,
|
||||||
get the number of rows of the more recent file. */
|
get the number of rows of the more recent file. */
|
||||||
if (asprintf (&Query,"SELECT marks_properties.%s,marks_properties.%s"
|
DB_BuildQuery ("SELECT marks_properties.%s,marks_properties.%s"
|
||||||
" FROM files,marks_properties"
|
" FROM files,marks_properties"
|
||||||
" WHERE files.FileBrowser=%u AND files.Cod=%ld AND files.Path='%s'"
|
" WHERE files.FileBrowser=%u AND files.Cod=%ld AND files.Path='%s'"
|
||||||
" AND files.FilCod=marks_properties.FilCod"
|
" AND files.FilCod=marks_properties.FilCod"
|
||||||
" ORDER BY files.FilCod DESC LIMIT 1", // On duplicate entries, get the more recent
|
" ORDER BY files.FilCod DESC LIMIT 1", // On duplicate entries, get the more recent
|
||||||
Mrk_HeadOrFootStr[Brw_HEADER],
|
Mrk_HeadOrFootStr[Brw_HEADER],
|
||||||
Mrk_HeadOrFootStr[Brw_FOOTER],
|
Mrk_HeadOrFootStr[Brw_FOOTER],
|
||||||
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
|
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
|
||||||
Cod,
|
Cod,
|
||||||
Gbl.FileBrowser.Priv.FullPathInTree) < 0)
|
Gbl.FileBrowser.Priv.FullPathInTree);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get the number of rows in header and footer");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get the number of rows in header and footer");
|
|
||||||
|
|
||||||
/***** The result of the query must have only one row *****/
|
/***** The result of the query must have only one row *****/
|
||||||
if (NumRows == 1)
|
if (NumRows == 1)
|
||||||
|
@ -736,7 +734,6 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
||||||
char **ContentStr,
|
char **ContentStr,
|
||||||
long MrkCod,long UsrCod,bool GetContent)
|
long MrkCod,long UsrCod,bool GetContent)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
struct UsrData UsrDat;
|
struct UsrData UsrDat;
|
||||||
|
@ -772,14 +769,13 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
||||||
ID_GetListIDsFromUsrCod (&UsrDat);
|
ID_GetListIDsFromUsrCod (&UsrDat);
|
||||||
|
|
||||||
/***** Get subject of message from database *****/
|
/***** Get subject of message from database *****/
|
||||||
if (asprintf (&Query,"SELECT files.FileBrowser,files.Cod,files.Path,"
|
DB_BuildQuery ("SELECT files.FileBrowser,files.Cod,files.Path,"
|
||||||
"marks_properties.Header,marks_properties.Footer"
|
"marks_properties.Header,marks_properties.Footer"
|
||||||
" FROM files,marks_properties"
|
" FROM files,marks_properties"
|
||||||
" WHERE files.FilCod=%ld"
|
" WHERE files.FilCod=%ld"
|
||||||
" AND files.FilCod=marks_properties.FilCod",
|
" AND files.FilCod=marks_properties.FilCod",
|
||||||
MrkCod) < 0)
|
MrkCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
if (DB_QuerySELECT_new (&mysql_res,"can not get the number of rows in header and footer") == 1) // Result should have a unique row
|
||||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get the number of rows in header and footer") == 1) // Result should have a unique row
|
|
||||||
{
|
{
|
||||||
/***** Get data of this file of marks *****/
|
/***** Get data of this file of marks *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
143
swad_message.c
143
swad_message.c
|
@ -498,7 +498,6 @@ static void Msg_WriteFormSubjectAndContentMsgToUsrs (char Content[Cns_MAX_BYTES_
|
||||||
extern const char *Txt_MSG_Subject;
|
extern const char *Txt_MSG_Subject;
|
||||||
extern const char *Txt_MSG_Content;
|
extern const char *Txt_MSG_Content;
|
||||||
extern const char *Txt_Original_message;
|
extern const char *Txt_Original_message;
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
|
@ -527,10 +526,9 @@ static void Msg_WriteFormSubjectAndContentMsgToUsrs (char Content[Cns_MAX_BYTES_
|
||||||
if (!SubjectAndContentComeFromForm)
|
if (!SubjectAndContentComeFromForm)
|
||||||
{
|
{
|
||||||
/* Get subject and content of message from database */
|
/* Get subject and content of message from database */
|
||||||
if (asprintf (&Query,"SELECT Subject,Content FROM msg_content"
|
DB_BuildQuery ("SELECT Subject,Content FROM msg_content"
|
||||||
" WHERE MsgCod=%ld",MsgCod) < 0)
|
" WHERE MsgCod=%ld",MsgCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get message content");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get message content");
|
|
||||||
|
|
||||||
/* Result should have a unique row */
|
/* Result should have a unique row */
|
||||||
if (NumRows != 1)
|
if (NumRows != 1)
|
||||||
|
@ -2530,7 +2528,6 @@ void Msg_PutHiddenParamsMsgsFilters (void)
|
||||||
|
|
||||||
void Msg_GetDistinctCoursesInMyMessages (void)
|
void Msg_GetDistinctCoursesInMyMessages (void)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRow,NumRows;
|
unsigned long NumRow,NumRows;
|
||||||
|
@ -2540,28 +2537,26 @@ void Msg_GetDistinctCoursesInMyMessages (void)
|
||||||
switch (Gbl.Msg.TypeOfMessages)
|
switch (Gbl.Msg.TypeOfMessages)
|
||||||
{
|
{
|
||||||
case Msg_MESSAGES_RECEIVED:
|
case Msg_MESSAGES_RECEIVED:
|
||||||
if (asprintf (&Query,"SELECT DISTINCT courses.CrsCod,courses.ShortName"
|
DB_BuildQuery ("SELECT DISTINCT courses.CrsCod,courses.ShortName"
|
||||||
" FROM msg_rcv,msg_snt,courses"
|
" FROM msg_rcv,msg_snt,courses"
|
||||||
" WHERE msg_rcv.UsrCod=%ld"
|
" WHERE msg_rcv.UsrCod=%ld"
|
||||||
" AND msg_rcv.MsgCod=msg_snt.MsgCod"
|
" AND msg_rcv.MsgCod=msg_snt.MsgCod"
|
||||||
" AND msg_snt.CrsCod=courses.CrsCod"
|
" AND msg_snt.CrsCod=courses.CrsCod"
|
||||||
" ORDER BY courses.ShortName",
|
" ORDER BY courses.ShortName",
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Msg_MESSAGES_SENT:
|
case Msg_MESSAGES_SENT:
|
||||||
if (asprintf (&Query,"SELECT DISTINCT courses.CrsCod,courses.ShortName"
|
DB_BuildQuery ("SELECT DISTINCT courses.CrsCod,courses.ShortName"
|
||||||
" FROM msg_snt,courses"
|
" FROM msg_snt,courses"
|
||||||
" WHERE msg_snt.UsrCod=%ld"
|
" WHERE msg_snt.UsrCod=%ld"
|
||||||
" AND msg_snt.CrsCod=courses.CrsCod"
|
" AND msg_snt.CrsCod=courses.CrsCod"
|
||||||
" ORDER BY courses.ShortName",
|
" ORDER BY courses.ShortName",
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
default: // Not aplicable here
|
default: // Not aplicable here
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get distinct courses in your messages");
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get distinct courses in your messages");
|
||||||
|
|
||||||
/***** Get distinct courses in messages from database *****/
|
/***** Get distinct courses in messages from database *****/
|
||||||
Gbl.Msg.NumCourses = 0;
|
Gbl.Msg.NumCourses = 0;
|
||||||
|
@ -2717,27 +2712,24 @@ static void Msg_GetMsgSntData (long MsgCod,long *CrsCod,long *UsrCod,
|
||||||
char Subject[Cns_MAX_BYTES_SUBJECT + 1],
|
char Subject[Cns_MAX_BYTES_SUBJECT + 1],
|
||||||
bool *Deleted)
|
bool *Deleted)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
|
|
||||||
/***** Get data of message from table msg_snt *****/
|
/***** Get data of message from table msg_snt *****/
|
||||||
*Deleted = false;
|
*Deleted = false;
|
||||||
if (asprintf (&Query,"SELECT CrsCod,UsrCod,UNIX_TIMESTAMP(CreatTime)"
|
DB_BuildQuery ("SELECT CrsCod,UsrCod,UNIX_TIMESTAMP(CreatTime)"
|
||||||
" FROM msg_snt WHERE MsgCod=%ld",
|
" FROM msg_snt WHERE MsgCod=%ld",
|
||||||
MsgCod) < 0)
|
MsgCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get data of a message");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get data of a message");
|
|
||||||
|
|
||||||
if (NumRows == 0) // If not result ==> sent message is deleted
|
if (NumRows == 0) // If not result ==> sent message is deleted
|
||||||
{
|
{
|
||||||
/***** Get data of message from table msg_snt_deleted *****/
|
/***** Get data of message from table msg_snt_deleted *****/
|
||||||
if (asprintf (&Query,"SELECT CrsCod,UsrCod,UNIX_TIMESTAMP(CreatTime)"
|
DB_BuildQuery ("SELECT CrsCod,UsrCod,UNIX_TIMESTAMP(CreatTime)"
|
||||||
" FROM msg_snt_deleted WHERE MsgCod=%ld",
|
" FROM msg_snt_deleted WHERE MsgCod=%ld",
|
||||||
MsgCod) < 0)
|
MsgCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get data of a message");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get data of a message");
|
|
||||||
|
|
||||||
*Deleted = true;
|
*Deleted = true;
|
||||||
}
|
}
|
||||||
|
@ -2771,16 +2763,14 @@ static void Msg_GetMsgSntData (long MsgCod,long *CrsCod,long *UsrCod,
|
||||||
|
|
||||||
void Msg_GetMsgSubject (long MsgCod,char Subject[Cns_MAX_BYTES_SUBJECT + 1])
|
void Msg_GetMsgSubject (long MsgCod,char Subject[Cns_MAX_BYTES_SUBJECT + 1])
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
/***** Get subject of message from database *****/
|
/***** Get subject of message from database *****/
|
||||||
if (asprintf (&Query,"SELECT Subject FROM msg_content WHERE MsgCod=%ld",MsgCod) < 0)
|
DB_BuildQuery ("SELECT Subject FROM msg_content WHERE MsgCod=%ld",MsgCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
|
|
||||||
/***** Result should have a unique row *****/
|
/***** Result should have a unique row *****/
|
||||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get the subject of a message") == 1)
|
if (DB_QuerySELECT_new (&mysql_res,"can not get the subject of a message") == 1)
|
||||||
{
|
{
|
||||||
/***** Get subject *****/
|
/***** Get subject *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -2801,17 +2791,15 @@ void Msg_GetMsgSubject (long MsgCod,char Subject[Cns_MAX_BYTES_SUBJECT + 1])
|
||||||
static void Msg_GetMsgContent (long MsgCod,char Content[Cns_MAX_BYTES_LONG_TEXT + 1],
|
static void Msg_GetMsgContent (long MsgCod,char Content[Cns_MAX_BYTES_LONG_TEXT + 1],
|
||||||
struct Image *Image)
|
struct Image *Image)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
|
|
||||||
/***** Get content of message from database *****/
|
/***** Get content of message from database *****/
|
||||||
if (asprintf (&Query,"SELECT Content,ImageName,ImageTitle,ImageURL"
|
DB_BuildQuery ("SELECT Content,ImageName,ImageTitle,ImageURL"
|
||||||
" FROM msg_content WHERE MsgCod=%ld",
|
" FROM msg_content WHERE MsgCod=%ld",
|
||||||
MsgCod) < 0)
|
MsgCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get the content of a message");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get the content of a message");
|
|
||||||
|
|
||||||
/***** Result should have a unique row *****/
|
/***** Result should have a unique row *****/
|
||||||
if (NumRows != 1)
|
if (NumRows != 1)
|
||||||
|
@ -2837,17 +2825,15 @@ static void Msg_GetMsgContent (long MsgCod,char Content[Cns_MAX_BYTES_LONG_TEXT
|
||||||
|
|
||||||
static void Msg_GetStatusOfSentMsg (long MsgCod,bool *Expanded)
|
static void Msg_GetStatusOfSentMsg (long MsgCod,bool *Expanded)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
|
|
||||||
/***** Get if sent message has been replied/expanded from database *****/
|
/***** Get if sent message has been replied/expanded from database *****/
|
||||||
if (asprintf (&Query,"SELECT Expanded FROM msg_snt"
|
DB_BuildQuery ("SELECT Expanded FROM msg_snt"
|
||||||
" WHERE MsgCod=%ld AND UsrCod=%ld",
|
" WHERE MsgCod=%ld AND UsrCod=%ld",
|
||||||
MsgCod,Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
MsgCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get if a sent message has been replied/expanded");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get if a sent message has been replied/expanded");
|
|
||||||
|
|
||||||
/***** Result should have a unique row *****/
|
/***** Result should have a unique row *****/
|
||||||
if (NumRows != 1)
|
if (NumRows != 1)
|
||||||
|
@ -2869,17 +2855,15 @@ static void Msg_GetStatusOfSentMsg (long MsgCod,bool *Expanded)
|
||||||
|
|
||||||
static void Msg_GetStatusOfReceivedMsg (long MsgCod,bool *Open,bool *Replied,bool *Expanded)
|
static void Msg_GetStatusOfReceivedMsg (long MsgCod,bool *Open,bool *Replied,bool *Expanded)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
|
|
||||||
/***** Get if received message has been replied/expanded from database *****/
|
/***** Get if received message has been replied/expanded from database *****/
|
||||||
if (asprintf (&Query,"SELECT Open,Replied,Expanded FROM msg_rcv"
|
DB_BuildQuery ("SELECT Open,Replied,Expanded FROM msg_rcv"
|
||||||
" WHERE MsgCod=%ld AND UsrCod=%ld",
|
" WHERE MsgCod=%ld AND UsrCod=%ld",
|
||||||
MsgCod,Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
MsgCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get if a received message has been replied/expanded");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get if a received message has been replied/expanded");
|
|
||||||
|
|
||||||
/***** Result should have a unique row *****/
|
/***** Result should have a unique row *****/
|
||||||
if (NumRows != 1)
|
if (NumRows != 1)
|
||||||
|
@ -3088,7 +3072,6 @@ void Msg_GetNotifMessage (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
||||||
char **ContentStr,long MsgCod,bool GetContent)
|
char **ContentStr,long MsgCod,bool GetContent)
|
||||||
{
|
{
|
||||||
extern const char *Txt_MSG_Subject;
|
extern const char *Txt_MSG_Subject;
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
size_t Length;
|
size_t Length;
|
||||||
|
@ -3097,12 +3080,11 @@ void Msg_GetNotifMessage (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
||||||
// This function may be called inside a web service, so don't report error
|
// This function may be called inside a web service, so don't report error
|
||||||
|
|
||||||
/***** Get subject of message from database *****/
|
/***** Get subject of message from database *****/
|
||||||
if (asprintf (&Query,"SELECT Subject,Content FROM msg_content"
|
DB_BuildQuery ("SELECT Subject,Content FROM msg_content"
|
||||||
" WHERE MsgCod=%ld",
|
" WHERE MsgCod=%ld",
|
||||||
MsgCod) < 0)
|
MsgCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
|
|
||||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get subject and content of a message") == 1) // Result should have a unique row
|
if (DB_QuerySELECT_new (&mysql_res,"can not get subject and content of a message") == 1) // Result should have a unique row
|
||||||
{
|
{
|
||||||
/***** Get subject and content of the message *****/
|
/***** Get subject and content of the message *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -3457,19 +3439,18 @@ static void Msg_WriteMsgTo (long MsgCod)
|
||||||
NumRecipientsTotal = (unsigned) DB_QueryCOUNT_free (Query,"can not get number of recipients");
|
NumRecipientsTotal = (unsigned) DB_QueryCOUNT_free (Query,"can not get number of recipients");
|
||||||
|
|
||||||
/***** Get recipients of a message from database *****/
|
/***** Get recipients of a message from database *****/
|
||||||
if (asprintf (&Query,"(SELECT msg_rcv.UsrCod,'N',msg_rcv.Open,"
|
DB_BuildQuery ("(SELECT msg_rcv.UsrCod,'N',msg_rcv.Open,"
|
||||||
"usr_data.Surname1 AS S1,usr_data.Surname2 AS S2,usr_data.FirstName AS FN"
|
"usr_data.Surname1 AS S1,usr_data.Surname2 AS S2,usr_data.FirstName AS FN"
|
||||||
" FROM msg_rcv,usr_data"
|
" FROM msg_rcv,usr_data"
|
||||||
" WHERE msg_rcv.MsgCod=%ld AND msg_rcv.UsrCod=usr_data.UsrCod)"
|
" WHERE msg_rcv.MsgCod=%ld AND msg_rcv.UsrCod=usr_data.UsrCod)"
|
||||||
" UNION "
|
" UNION "
|
||||||
"(SELECT msg_rcv_deleted.UsrCod,'Y',msg_rcv_deleted.Open,"
|
"(SELECT msg_rcv_deleted.UsrCod,'Y',msg_rcv_deleted.Open,"
|
||||||
"usr_data.Surname1 AS S1,usr_data.Surname2 AS S2,usr_data.FirstName AS FN"
|
"usr_data.Surname1 AS S1,usr_data.Surname2 AS S2,usr_data.FirstName AS FN"
|
||||||
" FROM msg_rcv_deleted,usr_data"
|
" FROM msg_rcv_deleted,usr_data"
|
||||||
" WHERE msg_rcv_deleted.MsgCod=%ld AND msg_rcv_deleted.UsrCod=usr_data.UsrCod)"
|
" WHERE msg_rcv_deleted.MsgCod=%ld AND msg_rcv_deleted.UsrCod=usr_data.UsrCod)"
|
||||||
" ORDER BY S1,S2,FN",
|
" ORDER BY S1,S2,FN",
|
||||||
MsgCod,MsgCod) < 0)
|
MsgCod,MsgCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRecipientsKnown = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get recipients of a message");
|
||||||
NumRecipientsKnown = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get recipients of a message");
|
|
||||||
|
|
||||||
/***** Check number of recipients *****/
|
/***** Check number of recipients *****/
|
||||||
if (NumRecipientsTotal)
|
if (NumRecipientsTotal)
|
||||||
|
@ -3830,7 +3811,6 @@ void Msg_ListBannedUsrs (void)
|
||||||
extern const char *Txt_You_have_not_banned_any_sender;
|
extern const char *Txt_You_have_not_banned_any_sender;
|
||||||
extern const char *Txt_Banned_users;
|
extern const char *Txt_Banned_users;
|
||||||
extern const char *Txt_Sender_banned_click_to_unban_him;
|
extern const char *Txt_Sender_banned_click_to_unban_him;
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumUsr,NumUsrs;
|
unsigned NumUsr,NumUsrs;
|
||||||
|
@ -3839,13 +3819,12 @@ void Msg_ListBannedUsrs (void)
|
||||||
char PhotoURL[PATH_MAX + 1];
|
char PhotoURL[PATH_MAX + 1];
|
||||||
|
|
||||||
/***** Get my banned users *****/
|
/***** Get my banned users *****/
|
||||||
if (asprintf (&Query,"SELECT msg_banned.FromUsrCod FROM msg_banned,usr_data"
|
DB_BuildQuery ("SELECT msg_banned.FromUsrCod FROM msg_banned,usr_data"
|
||||||
" WHERE msg_banned.ToUsrCod=%ld"
|
" WHERE msg_banned.ToUsrCod=%ld"
|
||||||
" AND msg_banned.FromUsrCod=usr_data.UsrCod"
|
" AND msg_banned.FromUsrCod=usr_data.UsrCod"
|
||||||
" ORDER BY usr_data.Surname1,usr_data.Surname2,usr_data.FirstName",
|
" ORDER BY usr_data.Surname1,usr_data.Surname2,usr_data.FirstName",
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumUsrs = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get banned users");
|
||||||
NumUsrs = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get banned users");
|
|
||||||
|
|
||||||
if (NumUsrs == 0) // If not result ==> sent message is deleted
|
if (NumUsrs == 0) // If not result ==> sent message is deleted
|
||||||
Ale_ShowAlert (Ale_INFO,Txt_You_have_not_banned_any_sender);
|
Ale_ShowAlert (Ale_INFO,Txt_You_have_not_banned_any_sender);
|
||||||
|
|
141
swad_network.c
141
swad_network.c
|
@ -205,7 +205,6 @@ static void Net_GetMyWebsAndSocialNetsFromForm (void);
|
||||||
|
|
||||||
void Net_ShowWebsAndSocialNets (const struct UsrData *UsrDat)
|
void Net_ShowWebsAndSocialNets (const struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
Net_WebsAndSocialNetworks_t NumURL;
|
Net_WebsAndSocialNetworks_t NumURL;
|
||||||
|
@ -224,13 +223,12 @@ void Net_ShowWebsAndSocialNets (const struct UsrData *UsrDat)
|
||||||
NumURL++)
|
NumURL++)
|
||||||
{
|
{
|
||||||
/***** Get user's web / social network from database *****/
|
/***** Get user's web / social network from database *****/
|
||||||
if (asprintf (&Query,"SELECT URL FROM usr_webs"
|
DB_BuildQuery ("SELECT URL FROM usr_webs"
|
||||||
" WHERE UsrCod=%ld AND Web='%s'",
|
" WHERE UsrCod=%ld AND Web='%s'",
|
||||||
UsrDat->UsrCod,Net_WebsAndSocialNetworksDB[NumURL]) < 0)
|
UsrDat->UsrCod,Net_WebsAndSocialNetworksDB[NumURL]);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
|
|
||||||
/***** Check if exists the web / social network for this user *****/
|
/***** Check if exists the web / social network for this user *****/
|
||||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get user's web / social network"))
|
if (DB_QuerySELECT_new (&mysql_res,"can not get user's web / social network"))
|
||||||
{
|
{
|
||||||
/* Get URL */
|
/* Get URL */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -281,7 +279,6 @@ void Net_ShowFormMyWebsAndSocialNets (void)
|
||||||
extern const char *Hlp_PROFILE_Webs;
|
extern const char *Hlp_PROFILE_Webs;
|
||||||
extern const char *The_ClassForm[The_NUM_THEMES];
|
extern const char *The_ClassForm[The_NUM_THEMES];
|
||||||
extern const char *Txt_Webs_social_networks;
|
extern const char *Txt_Webs_social_networks;
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
Net_WebsAndSocialNetworks_t NumURL;
|
Net_WebsAndSocialNetworks_t NumURL;
|
||||||
|
@ -304,14 +301,13 @@ void Net_ShowFormMyWebsAndSocialNets (void)
|
||||||
NumURL++)
|
NumURL++)
|
||||||
{
|
{
|
||||||
/***** Get user's web / social network from database *****/
|
/***** Get user's web / social network from database *****/
|
||||||
if (asprintf (&Query,"SELECT URL FROM usr_webs"
|
DB_BuildQuery ("SELECT URL FROM usr_webs"
|
||||||
" WHERE UsrCod=%ld AND Web='%s'",
|
" WHERE UsrCod=%ld AND Web='%s'",
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Net_WebsAndSocialNetworksDB[NumURL]) < 0)
|
Net_WebsAndSocialNetworksDB[NumURL]);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
|
|
||||||
/***** Check number of rows in result *****/
|
/***** Check number of rows in result *****/
|
||||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get user's web / social network"))
|
if (DB_QuerySELECT_new (&mysql_res,"can not get user's web / social network"))
|
||||||
{
|
{
|
||||||
/***** Read the data comunes a all the users *****/
|
/***** Read the data comunes a all the users *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -442,7 +438,6 @@ void Net_ShowWebAndSocialNetworksStats (void)
|
||||||
extern const char *Txt_Web_social_network;
|
extern const char *Txt_Web_social_network;
|
||||||
extern const char *Txt_No_of_users;
|
extern const char *Txt_No_of_users;
|
||||||
extern const char *Txt_PERCENT_of_users;
|
extern const char *Txt_PERCENT_of_users;
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumRows;
|
unsigned NumRows;
|
||||||
|
@ -463,83 +458,77 @@ void Net_ShowWebAndSocialNetworksStats (void)
|
||||||
switch (Gbl.Scope.Current)
|
switch (Gbl.Scope.Current)
|
||||||
{
|
{
|
||||||
case Sco_SCOPE_SYS:
|
case Sco_SCOPE_SYS:
|
||||||
if (asprintf (&Query,"SELECT Web,COUNT(*) AS N"
|
DB_BuildQuery ("SELECT Web,COUNT(*) AS N"
|
||||||
" FROM usr_webs"
|
" FROM usr_webs"
|
||||||
" GROUP BY Web"
|
" GROUP BY Web"
|
||||||
" ORDER BY N DESC,Web") < 0)
|
" ORDER BY N DESC,Web");
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CTY:
|
case Sco_SCOPE_CTY:
|
||||||
if (asprintf (&Query,"SELECT usr_webs.Web,"
|
DB_BuildQuery ("SELECT usr_webs.Web,"
|
||||||
"COUNT(DISTINCT usr_webs.UsrCod) AS N"
|
"COUNT(DISTINCT usr_webs.UsrCod) AS N"
|
||||||
" FROM institutions,centres,degrees,courses,crs_usr,usr_webs"
|
" FROM institutions,centres,degrees,courses,crs_usr,usr_webs"
|
||||||
" WHERE institutions.CtyCod=%ld"
|
" WHERE institutions.CtyCod=%ld"
|
||||||
" AND institutions.InsCod=centres.InsCod"
|
" AND institutions.InsCod=centres.InsCod"
|
||||||
" AND centres.CtrCod=degrees.CtrCod"
|
" AND centres.CtrCod=degrees.CtrCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod=usr_webs.UsrCod"
|
" AND crs_usr.UsrCod=usr_webs.UsrCod"
|
||||||
" GROUP BY usr_webs.Web"
|
" GROUP BY usr_webs.Web"
|
||||||
" ORDER BY N DESC,usr_webs.Web",
|
" ORDER BY N DESC,usr_webs.Web",
|
||||||
Gbl.CurrentCty.Cty.CtyCod) < 0)
|
Gbl.CurrentCty.Cty.CtyCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_INS:
|
case Sco_SCOPE_INS:
|
||||||
if (asprintf (&Query,"SELECT usr_webs.Web,"
|
DB_BuildQuery ("SELECT usr_webs.Web,"
|
||||||
"COUNT(DISTINCT usr_webs.UsrCod) AS N"
|
"COUNT(DISTINCT usr_webs.UsrCod) AS N"
|
||||||
" FROM centres,degrees,courses,crs_usr,usr_webs"
|
" FROM centres,degrees,courses,crs_usr,usr_webs"
|
||||||
" WHERE centres.InsCod=%ld"
|
" WHERE centres.InsCod=%ld"
|
||||||
" AND centres.CtrCod=degrees.CtrCod"
|
" AND centres.CtrCod=degrees.CtrCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod=usr_webs.UsrCod"
|
" AND crs_usr.UsrCod=usr_webs.UsrCod"
|
||||||
" GROUP BY usr_webs.Web"
|
" GROUP BY usr_webs.Web"
|
||||||
" ORDER BY N DESC,usr_webs.Web",
|
" ORDER BY N DESC,usr_webs.Web",
|
||||||
Gbl.CurrentIns.Ins.InsCod) < 0)
|
Gbl.CurrentIns.Ins.InsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CTR:
|
case Sco_SCOPE_CTR:
|
||||||
if (asprintf (&Query,"SELECT usr_webs.Web,"
|
DB_BuildQuery ("SELECT usr_webs.Web,"
|
||||||
"COUNT(DISTINCT usr_webs.UsrCod) AS N"
|
"COUNT(DISTINCT usr_webs.UsrCod) AS N"
|
||||||
" FROM degrees,courses,crs_usr,usr_webs"
|
" FROM degrees,courses,crs_usr,usr_webs"
|
||||||
" WHERE degrees.CtrCod=%ld"
|
" WHERE degrees.CtrCod=%ld"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod=usr_webs.UsrCod"
|
" AND crs_usr.UsrCod=usr_webs.UsrCod"
|
||||||
" GROUP BY usr_webs.Web"
|
" GROUP BY usr_webs.Web"
|
||||||
" ORDER BY N DESC,usr_webs.Web",
|
" ORDER BY N DESC,usr_webs.Web",
|
||||||
Gbl.CurrentCtr.Ctr.CtrCod) < 0)
|
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_DEG:
|
case Sco_SCOPE_DEG:
|
||||||
if (asprintf (&Query,"SELECT usr_webs.Web,"
|
DB_BuildQuery ("SELECT usr_webs.Web,"
|
||||||
"COUNT(DISTINCT usr_webs.UsrCod) AS N"
|
"COUNT(DISTINCT usr_webs.UsrCod) AS N"
|
||||||
" FROM courses,crs_usr,usr_webs"
|
" FROM courses,crs_usr,usr_webs"
|
||||||
" WHERE courses.DegCod=%ld"
|
" WHERE courses.DegCod=%ld"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod=usr_webs.UsrCod"
|
" AND crs_usr.UsrCod=usr_webs.UsrCod"
|
||||||
" GROUP BY usr_webs.Web"
|
" GROUP BY usr_webs.Web"
|
||||||
" ORDER BY N DESC,usr_webs.Web",
|
" ORDER BY N DESC,usr_webs.Web",
|
||||||
Gbl.CurrentDeg.Deg.DegCod) < 0)
|
Gbl.CurrentDeg.Deg.DegCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CRS:
|
case Sco_SCOPE_CRS:
|
||||||
if (asprintf (&Query,"SELECT usr_webs.Web,"
|
DB_BuildQuery ("SELECT usr_webs.Web,"
|
||||||
"COUNT(DISTINCT usr_webs.UsrCod) AS N"
|
"COUNT(DISTINCT usr_webs.UsrCod) AS N"
|
||||||
" FROM crs_usr,usr_webs"
|
" FROM crs_usr,usr_webs"
|
||||||
" WHERE crs_usr.CrsCod=%ld"
|
" WHERE crs_usr.CrsCod=%ld"
|
||||||
" AND crs_usr.UsrCod=usr_webs.UsrCod"
|
" AND crs_usr.UsrCod=usr_webs.UsrCod"
|
||||||
" GROUP BY usr_webs.Web"
|
" GROUP BY usr_webs.Web"
|
||||||
" ORDER BY N DESC,usr_webs.Web",
|
" ORDER BY N DESC,usr_webs.Web",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod) < 0)
|
Gbl.CurrentCrs.Crs.CrsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Lay_WrongScopeExit ();
|
Lay_WrongScopeExit ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
NumRows = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,
|
NumRows = (unsigned) DB_QuerySELECT_new (&mysql_res,
|
||||||
"can not get number of users with webs / social networks");
|
"can not get number of users with webs / social networks");
|
||||||
|
|
||||||
/***** Start box and table *****/
|
/***** Start box and table *****/
|
||||||
Box_StartBoxTable (NULL,Txt_STAT_USE_STAT_TYPES[Sta_SOCIAL_NETWORKS],NULL,
|
Box_StartBoxTable (NULL,Txt_STAT_USE_STAT_TYPES[Sta_SOCIAL_NETWORKS],NULL,
|
||||||
|
|
|
@ -115,17 +115,15 @@ bool Nck_CheckIfNickWithArrobaIsValid (const char *NicknameWithArroba)
|
||||||
bool Nck_GetNicknameFromUsrCod (long UsrCod,
|
bool Nck_GetNicknameFromUsrCod (long UsrCod,
|
||||||
char Nickname[Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA + 1])
|
char Nickname[Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA + 1])
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
bool Found;
|
bool Found;
|
||||||
|
|
||||||
/***** Get current (last updated) user's nickname from database *****/
|
/***** Get current (last updated) user's nickname from database *****/
|
||||||
if (asprintf (&Query,"SELECT Nickname FROM usr_nicknames"
|
DB_BuildQuery ("SELECT Nickname FROM usr_nicknames"
|
||||||
" WHERE UsrCod=%ld ORDER BY CreatTime DESC LIMIT 1",
|
" WHERE UsrCod=%ld ORDER BY CreatTime DESC LIMIT 1",
|
||||||
UsrCod) < 0)
|
UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
if (DB_QuerySELECT_new (&mysql_res,"can not get nickname"))
|
||||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get nickname"))
|
|
||||||
{
|
{
|
||||||
/* Get nickname */
|
/* Get nickname */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -154,7 +152,6 @@ bool Nck_GetNicknameFromUsrCod (long UsrCod,
|
||||||
long Nck_GetUsrCodFromNickname (const char *Nickname)
|
long Nck_GetUsrCodFromNickname (const char *Nickname)
|
||||||
{
|
{
|
||||||
char NicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
|
char NicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1];
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
long UsrCod = -1L;
|
long UsrCod = -1L;
|
||||||
|
@ -169,13 +166,12 @@ long Nck_GetUsrCodFromNickname (const char *Nickname)
|
||||||
|
|
||||||
/***** Get user's code from database *****/
|
/***** Get user's code from database *****/
|
||||||
/* Check if user code from table usr_nicknames is also in table usr_data */
|
/* Check if user code from table usr_nicknames is also in table usr_data */
|
||||||
if (asprintf (&Query,"SELECT usr_nicknames.UsrCod"
|
DB_BuildQuery ("SELECT usr_nicknames.UsrCod"
|
||||||
" FROM usr_nicknames,usr_data"
|
" FROM usr_nicknames,usr_data"
|
||||||
" WHERE usr_nicknames.Nickname='%s'"
|
" WHERE usr_nicknames.Nickname='%s'"
|
||||||
" AND usr_nicknames.UsrCod=usr_data.UsrCod",
|
" AND usr_nicknames.UsrCod=usr_data.UsrCod",
|
||||||
NicknameWithoutArroba) < 0)
|
NicknameWithoutArroba);
|
||||||
Lay_NotEnoughMemoryExit ();
|
if (DB_QuerySELECT_new (&mysql_res,"can not get user's code"))
|
||||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get user's code"))
|
|
||||||
{
|
{
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -230,7 +226,6 @@ static void Nck_ShowFormChangeUsrNickname (const struct UsrData *UsrDat,bool Its
|
||||||
extern const char *Txt_New_nickname;
|
extern const char *Txt_New_nickname;
|
||||||
extern const char *Txt_Change_nickname;
|
extern const char *Txt_Change_nickname;
|
||||||
extern const char *Txt_Save;
|
extern const char *Txt_Save;
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
char StrRecordWidth[10 + 1];
|
char StrRecordWidth[10 + 1];
|
||||||
|
@ -242,12 +237,11 @@ static void Nck_ShowFormChangeUsrNickname (const struct UsrData *UsrDat,bool Its
|
||||||
Lay_StartSection (Nck_NICKNAME_SECTION_ID);
|
Lay_StartSection (Nck_NICKNAME_SECTION_ID);
|
||||||
|
|
||||||
/***** Get my nicknames *****/
|
/***** Get my nicknames *****/
|
||||||
if (asprintf (&Query,"SELECT Nickname FROM usr_nicknames"
|
DB_BuildQuery ("SELECT Nickname FROM usr_nicknames"
|
||||||
" WHERE UsrCod=%ld"
|
" WHERE UsrCod=%ld"
|
||||||
" ORDER BY CreatTime DESC",
|
" ORDER BY CreatTime DESC",
|
||||||
UsrDat->UsrCod) < 0)
|
UsrDat->UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumNicks = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get nicknames of a user");
|
||||||
NumNicks = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get nicknames of a user");
|
|
||||||
|
|
||||||
/***** Start box *****/
|
/***** Start box *****/
|
||||||
snprintf (StrRecordWidth,sizeof (StrRecordWidth),
|
snprintf (StrRecordWidth,sizeof (StrRecordWidth),
|
||||||
|
|
212
swad_notice.c
212
swad_notice.c
|
@ -356,7 +356,6 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing)
|
||||||
extern const char *Txt_All_notices;
|
extern const char *Txt_All_notices;
|
||||||
extern const char *Txt_Notices;
|
extern const char *Txt_Notices;
|
||||||
extern const char *Txt_No_notices;
|
extern const char *Txt_No_notices;
|
||||||
char *Query = NULL;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
char StrWidth[10 + 2 + 1];
|
char StrWidth[10 + 2 + 1];
|
||||||
|
@ -377,24 +376,22 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing)
|
||||||
switch (TypeNoticesListing)
|
switch (TypeNoticesListing)
|
||||||
{
|
{
|
||||||
case Not_LIST_BRIEF_NOTICES:
|
case Not_LIST_BRIEF_NOTICES:
|
||||||
if (asprintf (&Query,"SELECT NotCod,UNIX_TIMESTAMP(CreatTime) AS F,UsrCod,Content,Status"
|
DB_BuildQuery ("SELECT NotCod,UNIX_TIMESTAMP(CreatTime) AS F,UsrCod,Content,Status"
|
||||||
" FROM notices"
|
" FROM notices"
|
||||||
" WHERE CrsCod=%ld AND Status=%u"
|
" WHERE CrsCod=%ld AND Status=%u"
|
||||||
" ORDER BY CreatTime DESC",
|
" ORDER BY CreatTime DESC",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
(unsigned) Not_ACTIVE_NOTICE) < 0)
|
(unsigned) Not_ACTIVE_NOTICE);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Not_LIST_FULL_NOTICES:
|
case Not_LIST_FULL_NOTICES:
|
||||||
if (asprintf (&Query,"SELECT NotCod,UNIX_TIMESTAMP(CreatTime) AS F,UsrCod,Content,Status"
|
DB_BuildQuery ("SELECT NotCod,UNIX_TIMESTAMP(CreatTime) AS F,UsrCod,Content,Status"
|
||||||
" FROM notices"
|
" FROM notices"
|
||||||
" WHERE CrsCod=%ld"
|
" WHERE CrsCod=%ld"
|
||||||
" ORDER BY CreatTime DESC",
|
" ORDER BY CreatTime DESC",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod) < 0)
|
Gbl.CurrentCrs.Crs.CrsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
NumNotices = DB_QuerySELECT_free (Query,&mysql_res,"can not get notices from database");
|
NumNotices = DB_QuerySELECT_new (&mysql_res,"can not get notices from database");
|
||||||
|
|
||||||
if (TypeNoticesListing == Not_LIST_FULL_NOTICES)
|
if (TypeNoticesListing == Not_LIST_FULL_NOTICES)
|
||||||
{
|
{
|
||||||
|
@ -550,7 +547,6 @@ static void Not_PutButtonToAddNewNotice (void)
|
||||||
|
|
||||||
static void Not_GetDataAndShowNotice (long NotCod)
|
static void Not_GetDataAndShowNotice (long NotCod)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
char Content[Cns_MAX_BYTES_TEXT + 1];
|
char Content[Cns_MAX_BYTES_TEXT + 1];
|
||||||
|
@ -560,13 +556,12 @@ static void Not_GetDataAndShowNotice (long NotCod)
|
||||||
Not_Status_t Status;
|
Not_Status_t Status;
|
||||||
|
|
||||||
/***** Get notice data from database *****/
|
/***** Get notice data from database *****/
|
||||||
if (asprintf (&Query,"SELECT UNIX_TIMESTAMP(CreatTime) AS F,UsrCod,Content,Status"
|
DB_BuildQuery ("SELECT UNIX_TIMESTAMP(CreatTime) AS F,UsrCod,Content,Status"
|
||||||
" FROM notices"
|
" FROM notices"
|
||||||
" WHERE NotCod=%ld AND CrsCod=%ld",
|
" WHERE NotCod=%ld AND CrsCod=%ld",
|
||||||
NotCod,
|
NotCod,
|
||||||
Gbl.CurrentCrs.Crs.CrsCod) < 0)
|
Gbl.CurrentCrs.Crs.CrsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
if (DB_QuerySELECT_new (&mysql_res,"can not get notice from database"))
|
||||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get notice from database"))
|
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
|
@ -766,7 +761,6 @@ void Not_GetSummaryAndContentNotice (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
||||||
char **ContentStr,
|
char **ContentStr,
|
||||||
long NotCod,bool GetContent)
|
long NotCod,bool GetContent)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
size_t Length;
|
size_t Length;
|
||||||
|
@ -775,10 +769,8 @@ void Not_GetSummaryAndContentNotice (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
||||||
// This function may be called inside a web service, so don't report error
|
// This function may be called inside a web service, so don't report error
|
||||||
|
|
||||||
/***** Get subject of message from database *****/
|
/***** Get subject of message from database *****/
|
||||||
if (asprintf (&Query,"SELECT Content FROM notices WHERE NotCod=%ld",
|
DB_BuildQuery ("SELECT Content FROM notices WHERE NotCod=%ld",NotCod);
|
||||||
NotCod) < 0)
|
if (DB_QuerySELECT_new (&mysql_res,"can not get content of notice") == 1) // Result should have a unique row
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get content of notice") == 1) // Result should have a unique row
|
|
||||||
{
|
{
|
||||||
/***** Get sumary / content *****/
|
/***** Get sumary / content *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -818,7 +810,6 @@ void Not_GetSummaryAndContentNotice (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
||||||
|
|
||||||
unsigned Not_GetNumNotices (Sco_Scope_t Scope,Not_Status_t Status,unsigned *NumNotif)
|
unsigned Not_GetNumNotices (Sco_Scope_t Scope,Not_Status_t Status,unsigned *NumNotif)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumNotices;
|
unsigned NumNotices;
|
||||||
|
@ -827,72 +818,66 @@ unsigned Not_GetNumNotices (Sco_Scope_t Scope,Not_Status_t Status,unsigned *NumN
|
||||||
switch (Scope)
|
switch (Scope)
|
||||||
{
|
{
|
||||||
case Sco_SCOPE_SYS:
|
case Sco_SCOPE_SYS:
|
||||||
if (asprintf (&Query,"SELECT COUNT(*),SUM(NumNotif)"
|
DB_BuildQuery ("SELECT COUNT(*),SUM(NumNotif)"
|
||||||
" FROM notices"
|
" FROM notices"
|
||||||
" WHERE Status=%u",
|
" WHERE Status=%u",
|
||||||
Status) < 0)
|
Status);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CTY:
|
case Sco_SCOPE_CTY:
|
||||||
if (asprintf (&Query,"SELECT COUNT(*),SUM(notices.NumNotif)"
|
DB_BuildQuery ("SELECT COUNT(*),SUM(notices.NumNotif)"
|
||||||
" FROM institutions,centres,degrees,courses,notices"
|
" FROM institutions,centres,degrees,courses,notices"
|
||||||
" WHERE institutions.CtyCod=%ld"
|
" WHERE institutions.CtyCod=%ld"
|
||||||
" AND institutions.InsCod=centres.InsCod"
|
" AND institutions.InsCod=centres.InsCod"
|
||||||
" AND centres.CtrCod=degrees.CtrCod"
|
" AND centres.CtrCod=degrees.CtrCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=notices.CrsCod"
|
" AND courses.CrsCod=notices.CrsCod"
|
||||||
" AND notices.Status=%u",
|
" AND notices.Status=%u",
|
||||||
Gbl.CurrentCty.Cty.CtyCod,
|
Gbl.CurrentCty.Cty.CtyCod,
|
||||||
Status) < 0)
|
Status);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_INS:
|
case Sco_SCOPE_INS:
|
||||||
if (asprintf (&Query,"SELECT COUNT(*),SUM(notices.NumNotif)"
|
DB_BuildQuery ("SELECT COUNT(*),SUM(notices.NumNotif)"
|
||||||
" FROM centres,degrees,courses,notices"
|
" FROM centres,degrees,courses,notices"
|
||||||
" WHERE centres.InsCod=%ld"
|
" WHERE centres.InsCod=%ld"
|
||||||
" AND centres.CtrCod=degrees.CtrCod"
|
" AND centres.CtrCod=degrees.CtrCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=notices.CrsCod"
|
" AND courses.CrsCod=notices.CrsCod"
|
||||||
" AND notices.Status=%u",
|
" AND notices.Status=%u",
|
||||||
Gbl.CurrentIns.Ins.InsCod,
|
Gbl.CurrentIns.Ins.InsCod,
|
||||||
Status) < 0)
|
Status);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CTR:
|
case Sco_SCOPE_CTR:
|
||||||
if (asprintf (&Query,"SELECT COUNT(*),SUM(notices.NumNotif)"
|
DB_BuildQuery ("SELECT COUNT(*),SUM(notices.NumNotif)"
|
||||||
" FROM degrees,courses,notices"
|
" FROM degrees,courses,notices"
|
||||||
" WHERE degrees.CtrCod=%ld"
|
" WHERE degrees.CtrCod=%ld"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=notices.CrsCod"
|
" AND courses.CrsCod=notices.CrsCod"
|
||||||
" AND notices.Status=%u",
|
" AND notices.Status=%u",
|
||||||
Gbl.CurrentCtr.Ctr.CtrCod,
|
Gbl.CurrentCtr.Ctr.CtrCod,
|
||||||
Status) < 0)
|
Status);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_DEG:
|
case Sco_SCOPE_DEG:
|
||||||
if (asprintf (&Query,"SELECT COUNT(*),SUM(notices.NumNotif)"
|
DB_BuildQuery ("SELECT COUNT(*),SUM(notices.NumNotif)"
|
||||||
" FROM courses,notices"
|
" FROM courses,notices"
|
||||||
" WHERE courses.DegCod=%ld"
|
" WHERE courses.DegCod=%ld"
|
||||||
" AND courses.CrsCod=notices.CrsCod"
|
" AND courses.CrsCod=notices.CrsCod"
|
||||||
" AND notices.Status=%u",
|
" AND notices.Status=%u",
|
||||||
Gbl.CurrentDeg.Deg.DegCod,
|
Gbl.CurrentDeg.Deg.DegCod,
|
||||||
Status) < 0)
|
Status);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CRS:
|
case Sco_SCOPE_CRS:
|
||||||
if (asprintf (&Query,"SELECT COUNT(*),SUM(NumNotif)"
|
DB_BuildQuery ("SELECT COUNT(*),SUM(NumNotif)"
|
||||||
" FROM notices"
|
" FROM notices"
|
||||||
" WHERE CrsCod=%ld"
|
" WHERE CrsCod=%ld"
|
||||||
" AND Status=%u",
|
" AND Status=%u",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
Status) < 0)
|
Status);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Lay_WrongScopeExit ();
|
Lay_WrongScopeExit ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
DB_QuerySELECT_free (Query,&mysql_res,"can not get number of notices");
|
DB_QuerySELECT_new (&mysql_res,"can not get number of notices");
|
||||||
|
|
||||||
/***** Get number of notices *****/
|
/***** Get number of notices *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -922,7 +907,6 @@ unsigned Not_GetNumNotices (Sco_Scope_t Scope,Not_Status_t Status,unsigned *NumN
|
||||||
|
|
||||||
unsigned Not_GetNumNoticesDeleted (Sco_Scope_t Scope,unsigned *NumNotif)
|
unsigned Not_GetNumNoticesDeleted (Sco_Scope_t Scope,unsigned *NumNotif)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumNotices;
|
unsigned NumNotices;
|
||||||
|
@ -931,60 +915,54 @@ unsigned Not_GetNumNoticesDeleted (Sco_Scope_t Scope,unsigned *NumNotif)
|
||||||
switch (Scope)
|
switch (Scope)
|
||||||
{
|
{
|
||||||
case Sco_SCOPE_SYS:
|
case Sco_SCOPE_SYS:
|
||||||
if (asprintf (&Query,"SELECT COUNT(*),SUM(NumNotif)"
|
DB_BuildQuery ("SELECT COUNT(*),SUM(NumNotif)"
|
||||||
" FROM notices_deleted") < 0)
|
" FROM notices_deleted");
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CTY:
|
case Sco_SCOPE_CTY:
|
||||||
if (asprintf (&Query,"SELECT COUNT(*),SUM(notices_deleted.NumNotif)"
|
DB_BuildQuery ("SELECT COUNT(*),SUM(notices_deleted.NumNotif)"
|
||||||
" FROM institutions,centres,degrees,courses,notices_deleted"
|
" FROM institutions,centres,degrees,courses,notices_deleted"
|
||||||
" WHERE institutions.CtyCod=%ld"
|
" WHERE institutions.CtyCod=%ld"
|
||||||
" AND institutions.InsCod=centres.InsCod"
|
" AND institutions.InsCod=centres.InsCod"
|
||||||
" AND centres.CtrCod=degrees.CtrCod"
|
" AND centres.CtrCod=degrees.CtrCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=notices_deleted.CrsCod",
|
" AND courses.CrsCod=notices_deleted.CrsCod",
|
||||||
Gbl.CurrentCty.Cty.CtyCod) < 0)
|
Gbl.CurrentCty.Cty.CtyCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_INS:
|
case Sco_SCOPE_INS:
|
||||||
if (asprintf (&Query,"SELECT COUNT(*),SUM(notices_deleted.NumNotif)"
|
DB_BuildQuery ("SELECT COUNT(*),SUM(notices_deleted.NumNotif)"
|
||||||
" FROM centres,degrees,courses,notices_deleted"
|
" FROM centres,degrees,courses,notices_deleted"
|
||||||
" WHERE centres.InsCod=%ld"
|
" WHERE centres.InsCod=%ld"
|
||||||
" AND centres.CtrCod=degrees.CtrCod"
|
" AND centres.CtrCod=degrees.CtrCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=notices_deleted.CrsCod",
|
" AND courses.CrsCod=notices_deleted.CrsCod",
|
||||||
Gbl.CurrentIns.Ins.InsCod) < 0)
|
Gbl.CurrentIns.Ins.InsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CTR:
|
case Sco_SCOPE_CTR:
|
||||||
if (asprintf (&Query,"SELECT COUNT(*),SUM(notices_deleted.NumNotif)"
|
DB_BuildQuery ("SELECT COUNT(*),SUM(notices_deleted.NumNotif)"
|
||||||
" FROM degrees,courses,notices_deleted"
|
" FROM degrees,courses,notices_deleted"
|
||||||
" WHERE degrees.CtrCod=%ld"
|
" WHERE degrees.CtrCod=%ld"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=notices_deleted.CrsCod",
|
" AND courses.CrsCod=notices_deleted.CrsCod",
|
||||||
Gbl.CurrentCtr.Ctr.CtrCod) < 0)
|
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_DEG:
|
case Sco_SCOPE_DEG:
|
||||||
if (asprintf (&Query,"SELECT COUNT(*),SUM(notices_deleted.NumNotif)"
|
DB_BuildQuery ("SELECT COUNT(*),SUM(notices_deleted.NumNotif)"
|
||||||
" FROM courses,notices_deleted"
|
" FROM courses,notices_deleted"
|
||||||
" WHERE courses.DegCod=%ld"
|
" WHERE courses.DegCod=%ld"
|
||||||
" AND courses.CrsCod=notices_deleted.CrsCod",
|
" AND courses.CrsCod=notices_deleted.CrsCod",
|
||||||
Gbl.CurrentDeg.Deg.DegCod) < 0)
|
Gbl.CurrentDeg.Deg.DegCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CRS:
|
case Sco_SCOPE_CRS:
|
||||||
if (asprintf (&Query,"SELECT COUNT(*),SUM(NumNotif)"
|
DB_BuildQuery ("SELECT COUNT(*),SUM(NumNotif)"
|
||||||
" FROM notices_deleted"
|
" FROM notices_deleted"
|
||||||
" WHERE CrsCod=%ld",
|
" WHERE CrsCod=%ld",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod) < 0)
|
Gbl.CurrentCrs.Crs.CrsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Lay_WrongScopeExit ();
|
Lay_WrongScopeExit ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
DB_QuerySELECT_free (Query,&mysql_res,"can not get number of deleted notices");
|
DB_QuerySELECT_new (&mysql_res,"can not get number of deleted notices");
|
||||||
|
|
||||||
/***** Get number of notices *****/
|
/***** Get number of notices *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
|
@ -1220,7 +1220,6 @@ void Ntf_MarkNotifFilesInGroupAsRemoved (long GrpCod)
|
||||||
unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod)
|
unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod)
|
||||||
{
|
{
|
||||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRow;
|
unsigned long NumRow;
|
||||||
|
@ -1244,46 +1243,42 @@ 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
|
||||||
if (asprintf (&Query,"SELECT UsrCod FROM crs_usr"
|
DB_BuildQuery ("SELECT UsrCod FROM crs_usr"
|
||||||
" WHERE CrsCod=%ld"
|
" WHERE CrsCod=%ld"
|
||||||
" AND UsrCod<>%ld",
|
" AND UsrCod<>%ld",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
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
|
||||||
if (asprintf (&Query,"SELECT UsrCod FROM crs_usr"
|
DB_BuildQuery ("SELECT UsrCod FROM crs_usr"
|
||||||
" WHERE CrsCod=%ld"
|
" WHERE CrsCod=%ld"
|
||||||
" AND UsrCod<>%ld"
|
" AND UsrCod<>%ld"
|
||||||
" AND Role=%u", // Notify teachers only
|
" AND Role=%u", // Notify teachers only
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
(unsigned) Rol_TCH) < 0)
|
(unsigned) Rol_TCH);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
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
|
||||||
if (asprintf (&Query,"SELECT UsrCod FROM crs_grp_usr"
|
DB_BuildQuery ("SELECT UsrCod FROM crs_grp_usr"
|
||||||
" WHERE crs_grp_usr.GrpCod=%ld"
|
" WHERE crs_grp_usr.GrpCod=%ld"
|
||||||
" AND crs_grp_usr.UsrCod<>%ld",
|
" AND crs_grp_usr.UsrCod<>%ld",
|
||||||
Gbl.CurrentCrs.Grps.GrpCod,
|
Gbl.CurrentCrs.Grps.GrpCod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
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
|
||||||
if (asprintf (&Query,"SELECT crs_grp_usr.UsrCod"
|
DB_BuildQuery ("SELECT crs_grp_usr.UsrCod"
|
||||||
" FROM crs_grp_usr,crs_grp,crs_grp_types,crs_usr"
|
" FROM crs_grp_usr,crs_grp,crs_grp_types,crs_usr"
|
||||||
" WHERE crs_grp_usr.GrpCod=%ld"
|
" WHERE crs_grp_usr.GrpCod=%ld"
|
||||||
" AND crs_grp_usr.UsrCod<>%ld"
|
" AND crs_grp_usr.UsrCod<>%ld"
|
||||||
" AND crs_grp_usr.GrpCod=crs_grp.GrpCod"
|
" AND crs_grp_usr.GrpCod=crs_grp.GrpCod"
|
||||||
" AND crs_grp.GrpTypCod=crs_grp_types.GrpTypCod"
|
" AND crs_grp.GrpTypCod=crs_grp_types.GrpTypCod"
|
||||||
" AND crs_grp_types.CrsCod=crs_usr.CrsCod"
|
" AND crs_grp_types.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.Role=%u", // Notify teachers only
|
" AND crs_usr.Role=%u", // Notify teachers only
|
||||||
Gbl.CurrentCrs.Grps.GrpCod,
|
Gbl.CurrentCrs.Grps.GrpCod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
(unsigned) Rol_TCH) < 0)
|
(unsigned) Rol_TCH);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
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;
|
||||||
|
@ -1293,30 +1288,28 @@ unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod)
|
||||||
// 1. If the assignment is available for the whole course ==> get all users enroled in the course except me
|
// 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
|
// 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
|
// Cases 1 and 2 are mutually exclusive, so the union returns the case 1 or 2
|
||||||
if (asprintf (&Query,"(SELECT crs_usr.UsrCod"
|
DB_BuildQuery ("(SELECT crs_usr.UsrCod"
|
||||||
" FROM assignments,crs_usr"
|
" FROM assignments,crs_usr"
|
||||||
" WHERE assignments.AsgCod=%ld"
|
" WHERE assignments.AsgCod=%ld"
|
||||||
" AND assignments.AsgCod NOT IN"
|
" AND assignments.AsgCod NOT IN"
|
||||||
" (SELECT AsgCod FROM asg_grp WHERE AsgCod=%ld)"
|
" (SELECT AsgCod FROM asg_grp WHERE AsgCod=%ld)"
|
||||||
" AND assignments.CrsCod=crs_usr.CrsCod"
|
" AND assignments.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod<>%ld)"
|
" AND crs_usr.UsrCod<>%ld)"
|
||||||
" UNION "
|
" UNION "
|
||||||
"(SELECT DISTINCT crs_grp_usr.UsrCod"
|
"(SELECT DISTINCT crs_grp_usr.UsrCod"
|
||||||
" FROM asg_grp,crs_grp_usr"
|
" FROM asg_grp,crs_grp_usr"
|
||||||
" WHERE asg_grp.AsgCod=%ld"
|
" WHERE asg_grp.AsgCod=%ld"
|
||||||
" AND asg_grp.GrpCod=crs_grp_usr.GrpCod"
|
" AND asg_grp.GrpCod=crs_grp_usr.GrpCod"
|
||||||
" AND crs_grp_usr.UsrCod<>%ld)",
|
" AND crs_grp_usr.UsrCod<>%ld)",
|
||||||
Cod,Cod,Gbl.Usrs.Me.UsrDat.UsrCod,
|
Cod,Cod,Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Cod,Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
Cod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Ntf_EVENT_EXAM_ANNOUNCEMENT:
|
case Ntf_EVENT_EXAM_ANNOUNCEMENT:
|
||||||
case Ntf_EVENT_NOTICE:
|
case Ntf_EVENT_NOTICE:
|
||||||
if (asprintf (&Query,"SELECT UsrCod FROM crs_usr"
|
DB_BuildQuery ("SELECT UsrCod FROM crs_usr"
|
||||||
" WHERE CrsCod=%ld AND UsrCod<>%ld",
|
" WHERE CrsCod=%ld AND UsrCod<>%ld",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
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
|
||||||
|
@ -1326,14 +1319,13 @@ unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod)
|
||||||
if (Gbl.CurrentCrs.Crs.NumUsrs[Rol_TCH])
|
if (Gbl.CurrentCrs.Crs.NumUsrs[Rol_TCH])
|
||||||
{
|
{
|
||||||
// If this course has teachers ==> send notification to teachers
|
// If this course has teachers ==> send notification to teachers
|
||||||
if (asprintf (&Query,"SELECT UsrCod FROM crs_usr"
|
DB_BuildQuery ("SELECT UsrCod FROM crs_usr"
|
||||||
" WHERE CrsCod=%ld"
|
" WHERE CrsCod=%ld"
|
||||||
" AND UsrCod<>%ld"
|
" AND UsrCod<>%ld"
|
||||||
" AND Role=%u", // Notify teachers only
|
" AND Role=%u", // Notify teachers only
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
(unsigned) Rol_TCH) < 0)
|
(unsigned) Rol_TCH);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
}
|
}
|
||||||
else // Course without teachers
|
else // Course without teachers
|
||||||
{
|
{
|
||||||
|
@ -1341,28 +1333,26 @@ unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod)
|
||||||
// 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
|
||||||
if (asprintf (&Query,"SELECT UsrCod FROM admin"
|
DB_BuildQuery ("SELECT UsrCod FROM admin"
|
||||||
" WHERE (Scope='%s'"
|
" WHERE (Scope='%s'"
|
||||||
" OR (Scope='%s' AND Cod=%ld)"
|
" OR (Scope='%s' AND Cod=%ld)"
|
||||||
" OR (Scope='%s' AND Cod=%ld)"
|
" OR (Scope='%s' AND Cod=%ld)"
|
||||||
" OR (Scope='%s' AND Cod=%ld))"
|
" OR (Scope='%s' AND Cod=%ld))"
|
||||||
" AND UsrCod<>%ld",
|
" AND UsrCod<>%ld",
|
||||||
Sco_ScopeDB[Sco_SCOPE_SYS],
|
Sco_ScopeDB[Sco_SCOPE_SYS],
|
||||||
Sco_ScopeDB[Sco_SCOPE_INS],Gbl.CurrentIns.Ins.InsCod,
|
Sco_ScopeDB[Sco_SCOPE_INS],Gbl.CurrentIns.Ins.InsCod,
|
||||||
Sco_ScopeDB[Sco_SCOPE_CTR],Gbl.CurrentCtr.Ctr.CtrCod,
|
Sco_ScopeDB[Sco_SCOPE_CTR],Gbl.CurrentCtr.Ctr.CtrCod,
|
||||||
Sco_ScopeDB[Sco_SCOPE_DEG],Gbl.CurrentDeg.Deg.DegCod,
|
Sco_ScopeDB[Sco_SCOPE_DEG],Gbl.CurrentDeg.Deg.DegCod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Ntf_EVENT_TIMELINE_COMMENT: // New comment to one of my social notes or comments
|
case Ntf_EVENT_TIMELINE_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
|
||||||
if (asprintf (&Query,"SELECT DISTINCT(PublisherCod) FROM social_pubs"
|
DB_BuildQuery ("SELECT DISTINCT(PublisherCod) FROM social_pubs"
|
||||||
" WHERE NotCod = (SELECT NotCod FROM social_pubs"
|
" WHERE NotCod = (SELECT NotCod FROM social_pubs"
|
||||||
" WHERE PubCod=%ld)"
|
" WHERE PubCod=%ld)"
|
||||||
" AND PublisherCod<>%ld",
|
" AND PublisherCod<>%ld",
|
||||||
Cod,Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
Cod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Ntf_EVENT_TIMELINE_FAV: // New favourite to one of my social notes or comments
|
case Ntf_EVENT_TIMELINE_FAV: // New favourite to one of my social notes or comments
|
||||||
case Ntf_EVENT_TIMELINE_SHARE: // New sharing of one of my social notes
|
case Ntf_EVENT_TIMELINE_SHARE: // New sharing of one of my social notes
|
||||||
|
@ -1376,31 +1366,28 @@ 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:
|
||||||
if (asprintf (&Query,"SELECT UsrCod FROM crs_usr"
|
DB_BuildQuery ("SELECT UsrCod FROM crs_usr"
|
||||||
" WHERE CrsCod=%ld AND UsrCod<>%ld",
|
" WHERE CrsCod=%ld AND UsrCod<>%ld",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case For_FORUM_COURSE_TCHS:
|
case For_FORUM_COURSE_TCHS:
|
||||||
if (asprintf (&Query,"SELECT UsrCod FROM crs_usr"
|
DB_BuildQuery ("SELECT UsrCod FROM crs_usr"
|
||||||
" WHERE CrsCod=%ld AND Role=%u AND UsrCod<>%ld",
|
" WHERE CrsCod=%ld AND Role=%u AND UsrCod<>%ld",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
(unsigned) Rol_TCH,
|
(unsigned) Rol_TCH,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Ntf_EVENT_FORUM_REPLY:
|
case Ntf_EVENT_FORUM_REPLY:
|
||||||
if (asprintf (&Query,"SELECT DISTINCT(UsrCod) FROM forum_post"
|
DB_BuildQuery ("SELECT DISTINCT(UsrCod) FROM forum_post"
|
||||||
" WHERE ThrCod = (SELECT ThrCod FROM forum_post"
|
" WHERE ThrCod = (SELECT ThrCod FROM forum_post"
|
||||||
" WHERE PstCod=%ld)"
|
" WHERE PstCod=%ld)"
|
||||||
" AND UsrCod<>%ld",
|
" AND UsrCod<>%ld",
|
||||||
Cod,Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
Cod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
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;
|
||||||
|
@ -1408,36 +1395,35 @@ unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod)
|
||||||
// 1. If the survey is available for the whole course ==> get users enroled in the course whose role is available in survey, except me
|
// 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
|
// 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
|
// Cases 1 and 2 are mutually exclusive, so the union returns the case 1 or 2
|
||||||
if (asprintf (&Query,"(SELECT crs_usr.UsrCod"
|
DB_BuildQuery ("(SELECT crs_usr.UsrCod"
|
||||||
" FROM surveys,crs_usr"
|
" FROM surveys,crs_usr"
|
||||||
" WHERE surveys.SvyCod=%ld"
|
" WHERE surveys.SvyCod=%ld"
|
||||||
" AND surveys.SvyCod NOT IN"
|
" AND surveys.SvyCod NOT IN"
|
||||||
" (SELECT SvyCod FROM svy_grp WHERE SvyCod=%ld)"
|
" (SELECT SvyCod FROM svy_grp WHERE SvyCod=%ld)"
|
||||||
" AND surveys.Scope='%s' AND surveys.Cod=crs_usr.CrsCod"
|
" AND surveys.Scope='%s' AND surveys.Cod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod<>%ld"
|
" AND crs_usr.UsrCod<>%ld"
|
||||||
" AND (surveys.Roles&(1<<crs_usr.Role))<>0)"
|
" AND (surveys.Roles&(1<<crs_usr.Role))<>0)"
|
||||||
" UNION "
|
" UNION "
|
||||||
"(SELECT DISTINCT crs_grp_usr.UsrCod"
|
"(SELECT DISTINCT crs_grp_usr.UsrCod"
|
||||||
" FROM svy_grp,crs_grp_usr,surveys,crs_usr"
|
" FROM svy_grp,crs_grp_usr,surveys,crs_usr"
|
||||||
" WHERE svy_grp.SvyCod=%ld"
|
" WHERE svy_grp.SvyCod=%ld"
|
||||||
" AND svy_grp.GrpCod=crs_grp_usr.GrpCod"
|
" AND svy_grp.GrpCod=crs_grp_usr.GrpCod"
|
||||||
" AND crs_grp_usr.UsrCod=crs_usr.UsrCod"
|
" AND crs_grp_usr.UsrCod=crs_usr.UsrCod"
|
||||||
" AND crs_grp_usr.UsrCod<>%ld"
|
" AND crs_grp_usr.UsrCod<>%ld"
|
||||||
" AND svy_grp.SvyCod=surveys.SvyCod"
|
" AND svy_grp.SvyCod=surveys.SvyCod"
|
||||||
" AND surveys.Scope='%s' AND surveys.Cod=crs_usr.CrsCod"
|
" AND surveys.Scope='%s' AND surveys.Cod=crs_usr.CrsCod"
|
||||||
" AND (surveys.Roles&(1<<crs_usr.Role))<>0)",
|
" AND (surveys.Roles&(1<<crs_usr.Role))<>0)",
|
||||||
Cod,
|
Cod,
|
||||||
Cod,
|
Cod,
|
||||||
Sco_ScopeDB[Sco_SCOPE_CRS],
|
Sco_ScopeDB[Sco_SCOPE_CRS],
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Cod,
|
Cod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Sco_ScopeDB[Sco_SCOPE_CRS]) < 0)
|
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get users to be notified"))) // Users found
|
if ((NumRows = DB_QuerySELECT_new (&mysql_res,"can not get users to be notified"))) // Users found
|
||||||
{
|
{
|
||||||
/***** Initialize structure with user's data *****/
|
/***** Initialize structure with user's data *****/
|
||||||
Usr_UsrDataConstructor (&UsrDat);
|
Usr_UsrDataConstructor (&UsrDat);
|
||||||
|
@ -1572,15 +1558,14 @@ void Ntf_SendPendingNotifByEMailToAllUsrs (void)
|
||||||
|
|
||||||
/***** Get users who must be notified from database ******/
|
/***** Get users who must be notified from database ******/
|
||||||
// (Status & Ntf_STATUS_BIT_EMAIL) && !(Status & Ntf_STATUS_BIT_SENT) && !(Status & (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED))
|
// (Status & Ntf_STATUS_BIT_EMAIL) && !(Status & Ntf_STATUS_BIT_SENT) && !(Status & (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED))
|
||||||
if (asprintf (&Query,"SELECT DISTINCT ToUsrCod FROM notif"
|
DB_BuildQuery ("SELECT DISTINCT ToUsrCod FROM notif"
|
||||||
" WHERE TimeNotif<FROM_UNIXTIME(UNIX_TIMESTAMP()-'%lu')"
|
" WHERE TimeNotif<FROM_UNIXTIME(UNIX_TIMESTAMP()-'%lu')"
|
||||||
" AND (Status & %u)<>0 AND (Status & %u)=0 AND (Status & %u)=0",
|
" AND (Status & %u)<>0 AND (Status & %u)=0 AND (Status & %u)=0",
|
||||||
Cfg_TIME_TO_SEND_PENDING_NOTIF,
|
Cfg_TIME_TO_SEND_PENDING_NOTIF,
|
||||||
(unsigned) Ntf_STATUS_BIT_EMAIL,
|
(unsigned) Ntf_STATUS_BIT_EMAIL,
|
||||||
(unsigned) Ntf_STATUS_BIT_SENT,
|
(unsigned) Ntf_STATUS_BIT_SENT,
|
||||||
(unsigned) (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED)) < 0)
|
(unsigned) (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED));
|
||||||
Lay_NotEnoughMemoryExit ();
|
if ((NumRows = DB_QuerySELECT_new (&mysql_res,"can not get users who must be notified"))) // Events found
|
||||||
if ((NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get users who must be notified"))) // Events found
|
|
||||||
{
|
{
|
||||||
/***** Initialize structure with user's data *****/
|
/***** Initialize structure with user's data *****/
|
||||||
Usr_UsrDataConstructor (&UsrDat);
|
Usr_UsrDataConstructor (&UsrDat);
|
||||||
|
@ -1664,16 +1649,15 @@ static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsign
|
||||||
if (Mai_CheckIfUsrCanReceiveEmailNotif (ToUsrDat))
|
if (Mai_CheckIfUsrCanReceiveEmailNotif (ToUsrDat))
|
||||||
{
|
{
|
||||||
/***** Get pending notifications of this user from database ******/
|
/***** Get pending notifications of this user from database ******/
|
||||||
if (asprintf (&Query,"SELECT NotifyEvent,FromUsrCod,InsCod,CtrCod,DegCod,CrsCod,Cod"
|
DB_BuildQuery ("SELECT NotifyEvent,FromUsrCod,InsCod,CtrCod,DegCod,CrsCod,Cod"
|
||||||
" FROM notif WHERE ToUsrCod=%ld"
|
" FROM notif WHERE ToUsrCod=%ld"
|
||||||
" AND (Status & %u)<>0 AND (Status & %u)=0 AND (Status & %u)=0"
|
" AND (Status & %u)<>0 AND (Status & %u)=0 AND (Status & %u)=0"
|
||||||
" ORDER BY TimeNotif,NotifyEvent",
|
" ORDER BY TimeNotif,NotifyEvent",
|
||||||
ToUsrDat->UsrCod,
|
ToUsrDat->UsrCod,
|
||||||
(unsigned) Ntf_STATUS_BIT_EMAIL,
|
(unsigned) Ntf_STATUS_BIT_EMAIL,
|
||||||
(unsigned) Ntf_STATUS_BIT_SENT,
|
(unsigned) Ntf_STATUS_BIT_SENT,
|
||||||
(unsigned) (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED)) < 0)
|
(unsigned) (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED));
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get pending notifications of a user");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get pending notifications of a user");
|
|
||||||
|
|
||||||
if (NumRows) // Events found
|
if (NumRows) // Events found
|
||||||
{
|
{
|
||||||
|
@ -1874,17 +1858,15 @@ static void Ntf_GetNumNotifSent (long DegCod,long CrsCod,
|
||||||
Ntf_NotifyEvent_t NotifyEvent,
|
Ntf_NotifyEvent_t NotifyEvent,
|
||||||
unsigned *NumEvents,unsigned *NumMails)
|
unsigned *NumEvents,unsigned *NumMails)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
|
|
||||||
/***** Get number of notifications sent by email from database *****/
|
/***** Get number of notifications sent by email from database *****/
|
||||||
if (asprintf (&Query,"SELECT NumEvents,NumMails FROM sta_notif"
|
DB_BuildQuery ("SELECT NumEvents,NumMails FROM sta_notif"
|
||||||
" WHERE DegCod=%ld AND CrsCod=%ld AND NotifyEvent=%u",
|
" WHERE DegCod=%ld AND CrsCod=%ld AND NotifyEvent=%u",
|
||||||
DegCod,CrsCod,(unsigned) NotifyEvent) < 0)
|
DegCod,CrsCod,(unsigned) NotifyEvent);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get number of notifications sent by email");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get number of notifications sent by email");
|
|
||||||
|
|
||||||
/***** Get number of rows *****/
|
/***** Get number of rows *****/
|
||||||
if (NumRows)
|
if (NumRows)
|
||||||
|
|
|
@ -817,19 +817,17 @@ void Pag_SaveLastPageMsgIntoSession (Pag_WhatPaginate_t WhatPaginate,unsigned Nu
|
||||||
|
|
||||||
unsigned Pag_GetLastPageMsgFromSession (Pag_WhatPaginate_t WhatPaginate)
|
unsigned Pag_GetLastPageMsgFromSession (Pag_WhatPaginate_t WhatPaginate)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
unsigned NumPage;
|
unsigned NumPage;
|
||||||
|
|
||||||
/***** Get last page of received/sent messages from database *****/
|
/***** Get last page of received/sent messages from database *****/
|
||||||
if (asprintf (&Query,"SELECT %s FROM sessions WHERE SessionId='%s'",
|
DB_BuildQuery ("SELECT %s FROM sessions WHERE SessionId='%s'",
|
||||||
WhatPaginate == Pag_MESSAGES_RECEIVED ? "LastPageMsgRcv" :
|
WhatPaginate == Pag_MESSAGES_RECEIVED ? "LastPageMsgRcv" :
|
||||||
"LastPageMsgSnt",
|
"LastPageMsgSnt",
|
||||||
Gbl.Session.Id) < 0)
|
Gbl.Session.Id);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get last page of messages");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get last page of messages");
|
|
||||||
|
|
||||||
/***** Check number of rows of the result ****/
|
/***** Check number of rows of the result ****/
|
||||||
if (NumRows != 1)
|
if (NumRows != 1)
|
||||||
|
|
|
@ -114,16 +114,14 @@ bool Pwd_CheckCurrentPassword (void)
|
||||||
|
|
||||||
bool Pwd_CheckPendingPassword (void)
|
bool Pwd_CheckPendingPassword (void)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
/***** Get pending password from database *****/
|
/***** Get pending password from database *****/
|
||||||
if (asprintf (&Query,"SELECT PendingPassword FROM pending_passwd"
|
DB_BuildQuery ("SELECT PendingPassword FROM pending_passwd"
|
||||||
" WHERE UsrCod=%ld",
|
" WHERE UsrCod=%ld",
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
if (DB_QuerySELECT_new (&mysql_res,"can not get pending password"))
|
||||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get pending password"))
|
|
||||||
{
|
{
|
||||||
/* Get encrypted pending password */
|
/* Get encrypted pending password */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
174
swad_photo.c
174
swad_photo.c
|
@ -121,7 +121,7 @@ static void Pho_PutLinkToCalculateDegreeStats (void);
|
||||||
static void Pho_GetMaxStdsPerDegree (void);
|
static void Pho_GetMaxStdsPerDegree (void);
|
||||||
static void Pho_ShowOrPrintClassPhotoDegrees (Pho_AvgPhotoSeeOrPrint_t SeeOrPrint);
|
static void Pho_ShowOrPrintClassPhotoDegrees (Pho_AvgPhotoSeeOrPrint_t SeeOrPrint);
|
||||||
static void Pho_ShowOrPrintListDegrees (Pho_AvgPhotoSeeOrPrint_t SeeOrPrint);
|
static void Pho_ShowOrPrintListDegrees (Pho_AvgPhotoSeeOrPrint_t SeeOrPrint);
|
||||||
static void Pho_BuildQueryOfDegrees (char **Query);
|
static void Pho_BuildQueryOfDegrees (void);
|
||||||
static void Pho_GetNumStdsInDegree (long DegCod,Usr_Sex_t Sex,int *NumStds,int *NumStdsWithPhoto);
|
static void Pho_GetNumStdsInDegree (long DegCod,Usr_Sex_t Sex,int *NumStds,int *NumStdsWithPhoto);
|
||||||
static void Pho_UpdateDegStats (long DegCod,Usr_Sex_t Sex,unsigned NumStds,unsigned NumStdsWithPhoto,long TimeToComputeAvgPhoto);
|
static void Pho_UpdateDegStats (long DegCod,Usr_Sex_t Sex,unsigned NumStds,unsigned NumStdsWithPhoto,long TimeToComputeAvgPhoto);
|
||||||
static void Pho_ShowDegreeStat (int NumStds,int NumStdsWithPhoto);
|
static void Pho_ShowDegreeStat (int NumStds,int NumStdsWithPhoto);
|
||||||
|
@ -984,11 +984,10 @@ unsigned Pho_UpdateMyClicksWithoutPhoto (void)
|
||||||
unsigned NumClicks;
|
unsigned NumClicks;
|
||||||
|
|
||||||
/***** Get number of clicks without photo from database *****/
|
/***** Get number of clicks without photo from database *****/
|
||||||
if (asprintf (&Query,"SELECT NumClicks FROM clicks_without_photo"
|
DB_BuildQuery ("SELECT NumClicks FROM clicks_without_photo"
|
||||||
" WHERE UsrCod=%ld",
|
" WHERE UsrCod=%ld",
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get number of clicks without photo");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get number of clicks without photo");
|
|
||||||
|
|
||||||
/***** Update the list of clicks without photo *****/
|
/***** Update the list of clicks without photo *****/
|
||||||
if (NumRows) // The user exists ==> update number of clicks without photo
|
if (NumRows) // The user exists ==> update number of clicks without photo
|
||||||
|
@ -1443,7 +1442,6 @@ void Pho_CalcPhotoDegree (void)
|
||||||
|
|
||||||
static long Pho_GetDegWithAvgPhotoLeastRecentlyUpdated (void)
|
static long Pho_GetDegWithAvgPhotoLeastRecentlyUpdated (void)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows = 0;
|
unsigned long NumRows = 0;
|
||||||
|
@ -1455,17 +1453,16 @@ static long Pho_GetDegWithAvgPhotoLeastRecentlyUpdated (void)
|
||||||
/***** 1. If a degree is not in table of computed degrees,
|
/***** 1. If a degree is not in table of computed degrees,
|
||||||
choose it as least recently updated *****/
|
choose it as least recently updated *****/
|
||||||
/* Get one degree with students not yet computed */
|
/* Get one degree with students not yet computed */
|
||||||
if (asprintf (&Query,"SELECT DISTINCT degrees.DegCod"
|
DB_BuildQuery ("SELECT DISTINCT degrees.DegCod"
|
||||||
" FROM degrees,courses,crs_usr"
|
" FROM degrees,courses,crs_usr"
|
||||||
" WHERE degrees.DegCod=courses.DegCod"
|
" WHERE degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.Role=%u"
|
" AND crs_usr.Role=%u"
|
||||||
" AND degrees.DegCod NOT IN"
|
" AND degrees.DegCod NOT IN"
|
||||||
" (SELECT DISTINCT DegCod FROM sta_degrees)"
|
" (SELECT DISTINCT DegCod FROM sta_degrees)"
|
||||||
" LIMIT 1",
|
" LIMIT 1",
|
||||||
(unsigned) Rol_STD) < 0)
|
(unsigned) Rol_STD);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get degrees");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get degrees");
|
|
||||||
|
|
||||||
/* If number of rows is 1, then get the degree code */
|
/* If number of rows is 1, then get the degree code */
|
||||||
if (NumRows == 1)
|
if (NumRows == 1)
|
||||||
|
@ -1485,17 +1482,16 @@ static long Pho_GetDegWithAvgPhotoLeastRecentlyUpdated (void)
|
||||||
/***** 2. If all the degrees are in table,
|
/***** 2. If all the degrees are in table,
|
||||||
choose the least recently updated that has students *****/
|
choose the least recently updated that has students *****/
|
||||||
/* Get degrees from database */
|
/* Get degrees from database */
|
||||||
if (asprintf (&Query,"SELECT sta_degrees.DegCod"
|
DB_BuildQuery ("SELECT sta_degrees.DegCod"
|
||||||
" FROM sta_degrees,courses,crs_usr"
|
" FROM sta_degrees,courses,crs_usr"
|
||||||
" WHERE sta_degrees.TimeAvgPhoto<FROM_UNIXTIME(UNIX_TIMESTAMP()-'%lu')"
|
" WHERE sta_degrees.TimeAvgPhoto<FROM_UNIXTIME(UNIX_TIMESTAMP()-'%lu')"
|
||||||
" AND sta_degrees.DegCod=courses.DegCod"
|
" AND sta_degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.Role=%u"
|
" AND crs_usr.Role=%u"
|
||||||
" ORDER BY sta_degrees.TimeAvgPhoto LIMIT 1",
|
" ORDER BY sta_degrees.TimeAvgPhoto LIMIT 1",
|
||||||
Cfg_MIN_TIME_TO_RECOMPUTE_AVG_PHOTO,
|
Cfg_MIN_TIME_TO_RECOMPUTE_AVG_PHOTO,
|
||||||
(unsigned) Rol_STD) < 0)
|
(unsigned) Rol_STD);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get degrees");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get degrees");
|
|
||||||
|
|
||||||
/* If number of rows is 1, then get the degree code */
|
/* If number of rows is 1, then get the degree code */
|
||||||
if (NumRows == 1)
|
if (NumRows == 1)
|
||||||
|
@ -1535,19 +1531,17 @@ void Pho_RemoveObsoleteStatDegrees (void)
|
||||||
|
|
||||||
static long Pho_GetTimeAvgPhotoWasComputed (long DegCod)
|
static long Pho_GetTimeAvgPhotoWasComputed (long DegCod)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
long TimeAvgPhotoWasComputed = 0L;
|
long TimeAvgPhotoWasComputed = 0L;
|
||||||
|
|
||||||
/***** Get last time an average photo was computed from database *****/
|
/***** Get last time an average photo was computed from database *****/
|
||||||
if (asprintf (&Query,"SELECT MIN(UNIX_TIMESTAMP(TimeAvgPhoto))"
|
DB_BuildQuery ("SELECT MIN(UNIX_TIMESTAMP(TimeAvgPhoto))"
|
||||||
" FROM sta_degrees WHERE DegCod=%ld",
|
" FROM sta_degrees WHERE DegCod=%ld",
|
||||||
DegCod) < 0)
|
DegCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,
|
"can not get last time an average photo was computed");
|
||||||
"can not get last time an average photo was computed");
|
|
||||||
|
|
||||||
if (NumRows == 1)
|
if (NumRows == 1)
|
||||||
{
|
{
|
||||||
|
@ -1571,7 +1565,6 @@ static long Pho_GetTimeAvgPhotoWasComputed (long DegCod)
|
||||||
|
|
||||||
static long Pho_GetTimeToComputeAvgPhoto (long DegCod)
|
static long Pho_GetTimeToComputeAvgPhoto (long DegCod)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
|
@ -1580,11 +1573,10 @@ static long Pho_GetTimeToComputeAvgPhoto (long DegCod)
|
||||||
long TotalTimeToComputeAvgPhoto = -1L;
|
long TotalTimeToComputeAvgPhoto = -1L;
|
||||||
|
|
||||||
/***** Get time to compute average photo from database *****/
|
/***** Get time to compute average photo from database *****/
|
||||||
if (asprintf (&Query,"SELECT TimeToComputeAvgPhoto FROM sta_degrees"
|
DB_BuildQuery ("SELECT TimeToComputeAvgPhoto FROM sta_degrees"
|
||||||
" WHERE DegCod=%ld",DegCod) < 0)
|
" WHERE DegCod=%ld",DegCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,
|
"can not get time to compute average photo");
|
||||||
"can not get time to compute average photo");
|
|
||||||
|
|
||||||
/***** Count number of rows in result *****/
|
/***** Count number of rows in result *****/
|
||||||
if (NumRows == Usr_NUM_SEXS)
|
if (NumRows == Usr_NUM_SEXS)
|
||||||
|
@ -2094,19 +2086,17 @@ static void Pho_PutLinkToCalculateDegreeStats (void)
|
||||||
|
|
||||||
static void Pho_GetMaxStdsPerDegree (void)
|
static void Pho_GetMaxStdsPerDegree (void)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
|
|
||||||
/***** Get maximum number of students in a degree from database *****/
|
/***** Get maximum number of students in a degree from database *****/
|
||||||
if (asprintf (&Query,"SELECT MAX(NumStds),MAX(NumStdsWithPhoto),"
|
DB_BuildQuery ("SELECT MAX(NumStds),MAX(NumStdsWithPhoto),"
|
||||||
"MAX(NumStdsWithPhoto/NumStds)"
|
"MAX(NumStdsWithPhoto/NumStds)"
|
||||||
" FROM sta_degrees"
|
" FROM sta_degrees"
|
||||||
" WHERE Sex='all' AND NumStds>0") < 0)
|
" WHERE Sex='all' AND NumStds>0");
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,
|
"can not get maximum number of students in a degree");
|
||||||
"can not get maximum number of students in a degree");
|
|
||||||
|
|
||||||
/***** Count number of rows in result *****/
|
/***** Count number of rows in result *****/
|
||||||
if (NumRows == 1)
|
if (NumRows == 1)
|
||||||
|
@ -2144,7 +2134,6 @@ static void Pho_GetMaxStdsPerDegree (void)
|
||||||
|
|
||||||
static void Pho_ShowOrPrintClassPhotoDegrees (Pho_AvgPhotoSeeOrPrint_t SeeOrPrint)
|
static void Pho_ShowOrPrintClassPhotoDegrees (Pho_AvgPhotoSeeOrPrint_t SeeOrPrint)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRow;
|
unsigned long NumRow;
|
||||||
|
@ -2156,8 +2145,8 @@ static void Pho_ShowOrPrintClassPhotoDegrees (Pho_AvgPhotoSeeOrPrint_t SeeOrPrin
|
||||||
bool TRIsOpen = false;
|
bool TRIsOpen = false;
|
||||||
|
|
||||||
/***** Get degrees from database *****/
|
/***** Get degrees from database *****/
|
||||||
Pho_BuildQueryOfDegrees (&Query);
|
Pho_BuildQueryOfDegrees ();
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get degrees");
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get degrees");
|
||||||
|
|
||||||
if (NumRows) // Degrees with students found
|
if (NumRows) // Degrees with students found
|
||||||
{
|
{
|
||||||
|
@ -2226,7 +2215,6 @@ static void Pho_ShowOrPrintListDegrees (Pho_AvgPhotoSeeOrPrint_t SeeOrPrint)
|
||||||
extern const char *Txt_No_INDEX;
|
extern const char *Txt_No_INDEX;
|
||||||
extern const char *Txt_Degree;
|
extern const char *Txt_Degree;
|
||||||
extern const char *Txt_SEX_PLURAL_Abc[Usr_NUM_SEXS];
|
extern const char *Txt_SEX_PLURAL_Abc[Usr_NUM_SEXS];
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRow;
|
unsigned long NumRow;
|
||||||
|
@ -2238,8 +2226,8 @@ static void Pho_ShowOrPrintListDegrees (Pho_AvgPhotoSeeOrPrint_t SeeOrPrint)
|
||||||
Usr_Sex_t Sex;
|
Usr_Sex_t Sex;
|
||||||
|
|
||||||
/***** Get degrees from database *****/
|
/***** Get degrees from database *****/
|
||||||
Pho_BuildQueryOfDegrees (&Query);
|
Pho_BuildQueryOfDegrees ();
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get degrees");
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get degrees");
|
||||||
|
|
||||||
if (NumRows) // Degrees with students found
|
if (NumRows) // Degrees with students found
|
||||||
{
|
{
|
||||||
|
@ -2335,50 +2323,46 @@ static void Pho_ShowOrPrintListDegrees (Pho_AvgPhotoSeeOrPrint_t SeeOrPrint)
|
||||||
/****** Build a query to get the degrees ordered by different criteria *******/
|
/****** Build a query to get the degrees ordered by different criteria *******/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Pho_BuildQueryOfDegrees (char **Query)
|
static void Pho_BuildQueryOfDegrees (void)
|
||||||
{
|
{
|
||||||
switch (Gbl.Stat.DegPhotos.HowOrderDegrees)
|
switch (Gbl.Stat.DegPhotos.HowOrderDegrees)
|
||||||
{
|
{
|
||||||
case Pho_NUMBER_OF_STUDENTS:
|
case Pho_NUMBER_OF_STUDENTS:
|
||||||
if (asprintf (Query,"SELECT degrees.DegCod"
|
DB_BuildQuery ("SELECT degrees.DegCod"
|
||||||
" FROM degrees,sta_degrees"
|
" FROM degrees,sta_degrees"
|
||||||
" WHERE sta_degrees.Sex='all'"
|
" WHERE sta_degrees.Sex='all'"
|
||||||
" AND sta_degrees.NumStds>0"
|
" AND sta_degrees.NumStds>0"
|
||||||
" AND degrees.DegCod=sta_degrees.DegCod"
|
" AND degrees.DegCod=sta_degrees.DegCod"
|
||||||
" ORDER BY sta_degrees.NumStds DESC,"
|
" ORDER BY sta_degrees.NumStds DESC,"
|
||||||
"sta_degrees.NumStdsWithPhoto DESC,"
|
"sta_degrees.NumStdsWithPhoto DESC,"
|
||||||
"degrees.ShortName") < 0)
|
"degrees.ShortName");
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Pho_NUMBER_OF_PHOTOS:
|
case Pho_NUMBER_OF_PHOTOS:
|
||||||
if (asprintf (Query,"SELECT degrees.DegCod"
|
DB_BuildQuery ("SELECT degrees.DegCod"
|
||||||
" FROM degrees,sta_degrees"
|
" FROM degrees,sta_degrees"
|
||||||
" WHERE sta_degrees.Sex='all'"
|
" WHERE sta_degrees.Sex='all'"
|
||||||
" AND sta_degrees.NumStds>0"
|
" AND sta_degrees.NumStds>0"
|
||||||
" AND degrees.DegCod=sta_degrees.DegCod"
|
" AND degrees.DegCod=sta_degrees.DegCod"
|
||||||
" ORDER BY sta_degrees.NumStdsWithPhoto DESC,"
|
" ORDER BY sta_degrees.NumStdsWithPhoto DESC,"
|
||||||
"sta_degrees.NumStds DESC,"
|
"sta_degrees.NumStds DESC,"
|
||||||
"degrees.ShortName") < 0)
|
"degrees.ShortName");
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Pho_PERCENT:
|
case Pho_PERCENT:
|
||||||
if (asprintf (Query,"SELECT degrees.DegCod"
|
DB_BuildQuery ("SELECT degrees.DegCod"
|
||||||
" FROM degrees,sta_degrees"
|
" FROM degrees,sta_degrees"
|
||||||
" WHERE sta_degrees.Sex='all'"
|
" WHERE sta_degrees.Sex='all'"
|
||||||
" AND sta_degrees.NumStds>0"
|
" AND sta_degrees.NumStds>0"
|
||||||
" AND degrees.DegCod=sta_degrees.DegCod"
|
" AND degrees.DegCod=sta_degrees.DegCod"
|
||||||
" ORDER BY sta_degrees.NumStdsWithPhoto/sta_degrees.NumStds DESC,"
|
" ORDER BY sta_degrees.NumStdsWithPhoto/sta_degrees.NumStds DESC,"
|
||||||
"degrees.ShortName") < 0)
|
"degrees.ShortName");
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Pho_DEGREE_NAME:
|
case Pho_DEGREE_NAME:
|
||||||
if (asprintf (Query,"SELECT degrees.DegCod"
|
DB_BuildQuery ("SELECT degrees.DegCod"
|
||||||
" FROM degrees,sta_degrees"
|
" FROM degrees,sta_degrees"
|
||||||
" WHERE sta_degrees.Sex='all'"
|
" WHERE sta_degrees.Sex='all'"
|
||||||
" AND sta_degrees.NumStds>0"
|
" AND sta_degrees.NumStds>0"
|
||||||
" AND degrees.DegCod=sta_degrees.DegCod"
|
" AND degrees.DegCod=sta_degrees.DegCod"
|
||||||
" ORDER BY degrees.ShortName") < 0)
|
" ORDER BY degrees.ShortName");
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2390,17 +2374,15 @@ static void Pho_BuildQueryOfDegrees (char **Query)
|
||||||
static void Pho_GetNumStdsInDegree (long DegCod,Usr_Sex_t Sex,int *NumStds,int *NumStdsWithPhoto)
|
static void Pho_GetNumStdsInDegree (long DegCod,Usr_Sex_t Sex,int *NumStds,int *NumStdsWithPhoto)
|
||||||
{
|
{
|
||||||
extern const char *Usr_StringsSexDB[Usr_NUM_SEXS];
|
extern const char *Usr_StringsSexDB[Usr_NUM_SEXS];
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
|
|
||||||
/***** Get the number of students in a degree from database *****/
|
/***** Get the number of students in a degree from database *****/
|
||||||
if (asprintf (&Query,"SELECT NumStds,NumStdsWithPhoto FROM sta_degrees"
|
DB_BuildQuery ("SELECT NumStds,NumStdsWithPhoto FROM sta_degrees"
|
||||||
" WHERE DegCod=%ld AND Sex='%s'",
|
" WHERE DegCod=%ld AND Sex='%s'",
|
||||||
DegCod,Usr_StringsSexDB[Sex]) < 0)
|
DegCod,Usr_StringsSexDB[Sex]);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get the number of students in a degree");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get the number of students in a degree");
|
|
||||||
|
|
||||||
if (NumRows == 0)
|
if (NumRows == 0)
|
||||||
*NumStds = *NumStdsWithPhoto = -1;
|
*NumStds = *NumStdsWithPhoto = -1;
|
||||||
|
|
74
swad_place.c
74
swad_place.c
|
@ -283,7 +283,6 @@ static void Plc_PutIconToViewPlacesWhenEditing (void)
|
||||||
void Plc_GetListPlaces (void)
|
void Plc_GetListPlaces (void)
|
||||||
{
|
{
|
||||||
char OrderBySubQuery[256];
|
char OrderBySubQuery[256];
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
|
@ -300,26 +299,25 @@ void Plc_GetListPlaces (void)
|
||||||
sprintf (OrderBySubQuery,"NumCtrs DESC,FullName");
|
sprintf (OrderBySubQuery,"NumCtrs DESC,FullName");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (asprintf (&Query,"(SELECT places.PlcCod,places.ShortName,places.FullName,COUNT(*) AS NumCtrs"
|
DB_BuildQuery ("(SELECT places.PlcCod,places.ShortName,places.FullName,COUNT(*) AS NumCtrs"
|
||||||
" FROM places,centres"
|
" FROM places,centres"
|
||||||
" WHERE places.InsCod=%ld"
|
" WHERE places.InsCod=%ld"
|
||||||
" AND places.PlcCod=centres.PlcCod"
|
" AND places.PlcCod=centres.PlcCod"
|
||||||
" AND centres.InsCod=%ld"
|
" AND centres.InsCod=%ld"
|
||||||
" GROUP BY places.PlcCod)"
|
" GROUP BY places.PlcCod)"
|
||||||
" UNION "
|
" UNION "
|
||||||
"(SELECT PlcCod,ShortName,FullName,0 AS NumCtrs"
|
"(SELECT PlcCod,ShortName,FullName,0 AS NumCtrs"
|
||||||
" FROM places"
|
" FROM places"
|
||||||
" WHERE InsCod=%ld"
|
" WHERE InsCod=%ld"
|
||||||
" AND PlcCod NOT IN"
|
" AND PlcCod NOT IN"
|
||||||
" (SELECT DISTINCT PlcCod FROM centres WHERE InsCod=%ld))"
|
" (SELECT DISTINCT PlcCod FROM centres WHERE InsCod=%ld))"
|
||||||
" ORDER BY %s",
|
" ORDER BY %s",
|
||||||
Gbl.CurrentIns.Ins.InsCod,
|
Gbl.CurrentIns.Ins.InsCod,
|
||||||
Gbl.CurrentIns.Ins.InsCod,
|
Gbl.CurrentIns.Ins.InsCod,
|
||||||
Gbl.CurrentIns.Ins.InsCod,
|
Gbl.CurrentIns.Ins.InsCod,
|
||||||
Gbl.CurrentIns.Ins.InsCod,
|
Gbl.CurrentIns.Ins.InsCod,
|
||||||
OrderBySubQuery) < 0)
|
OrderBySubQuery);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get places");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get places");
|
|
||||||
|
|
||||||
/***** Count number of rows in result *****/
|
/***** Count number of rows in result *****/
|
||||||
if (NumRows) // Places found...
|
if (NumRows) // Places found...
|
||||||
|
@ -372,7 +370,6 @@ void Plc_GetDataOfPlaceByCod (struct Place *Plc)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Place_unspecified;
|
extern const char *Txt_Place_unspecified;
|
||||||
extern const char *Txt_Another_place;
|
extern const char *Txt_Another_place;
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
|
@ -400,23 +397,22 @@ void Plc_GetDataOfPlaceByCod (struct Place *Plc)
|
||||||
else if (Plc->PlcCod > 0)
|
else if (Plc->PlcCod > 0)
|
||||||
{
|
{
|
||||||
/***** Get data of a place from database *****/
|
/***** Get data of a place from database *****/
|
||||||
if (asprintf (&Query,"(SELECT places.ShortName,places.FullName,COUNT(*)"
|
DB_BuildQuery ("(SELECT places.ShortName,places.FullName,COUNT(*)"
|
||||||
" FROM places,centres"
|
" FROM places,centres"
|
||||||
" WHERE places.PlcCod=%ld"
|
" WHERE places.PlcCod=%ld"
|
||||||
" AND places.PlcCod=centres.PlcCod"
|
" AND places.PlcCod=centres.PlcCod"
|
||||||
" AND centres.PlcCod=%ld"
|
" AND centres.PlcCod=%ld"
|
||||||
" GROUP BY places.PlcCod)"
|
" GROUP BY places.PlcCod)"
|
||||||
" UNION "
|
" UNION "
|
||||||
"(SELECT ShortName,FullName,0"
|
"(SELECT ShortName,FullName,0"
|
||||||
" FROM places"
|
" FROM places"
|
||||||
" WHERE PlcCod=%ld"
|
" WHERE PlcCod=%ld"
|
||||||
" AND PlcCod NOT IN"
|
" AND PlcCod NOT IN"
|
||||||
" (SELECT DISTINCT PlcCod FROM centres))",
|
" (SELECT DISTINCT PlcCod FROM centres))",
|
||||||
Plc->PlcCod,
|
Plc->PlcCod,
|
||||||
Plc->PlcCod,
|
Plc->PlcCod,
|
||||||
Plc->PlcCod) < 0)
|
Plc->PlcCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get data of a place");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get data of a place");
|
|
||||||
|
|
||||||
/***** Count number of rows in result *****/
|
/***** Count number of rows in result *****/
|
||||||
if (NumRows) // Place found...
|
if (NumRows) // Place found...
|
||||||
|
|
|
@ -184,7 +184,6 @@ void Plg_EditPlugins (void)
|
||||||
|
|
||||||
static void Plg_GetListPlugins (void)
|
static void Plg_GetListPlugins (void)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
|
@ -192,10 +191,9 @@ static void Plg_GetListPlugins (void)
|
||||||
struct Plugin *Plg;
|
struct Plugin *Plg;
|
||||||
|
|
||||||
/***** Get plugins from database *****/
|
/***** Get plugins from database *****/
|
||||||
if (asprintf (&Query,"SELECT PlgCod,Name,Description,Logo,AppKey,URL,IP"
|
DB_BuildQuery ("SELECT PlgCod,Name,Description,Logo,AppKey,URL,IP"
|
||||||
" FROM plugins ORDER BY Name") < 0)
|
" FROM plugins ORDER BY Name");
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get plugins");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get plugins");
|
|
||||||
|
|
||||||
/***** Count number of rows in result *****/
|
/***** Count number of rows in result *****/
|
||||||
if (NumRows) // Plugins found...
|
if (NumRows) // Plugins found...
|
||||||
|
@ -258,7 +256,6 @@ static void Plg_GetListPlugins (void)
|
||||||
|
|
||||||
bool Plg_GetDataOfPluginByCod (struct Plugin *Plg)
|
bool Plg_GetDataOfPluginByCod (struct Plugin *Plg)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
|
@ -277,12 +274,11 @@ bool Plg_GetDataOfPluginByCod (struct Plugin *Plg)
|
||||||
// Plg->PlgCod > 0
|
// Plg->PlgCod > 0
|
||||||
|
|
||||||
/***** Get data of a plugin from database *****/
|
/***** Get data of a plugin from database *****/
|
||||||
if (asprintf (&Query,"SELECT Name,Description,Logo,AppKey,URL,IP"
|
DB_BuildQuery ("SELECT Name,Description,Logo,AppKey,URL,IP"
|
||||||
" FROM plugins"
|
" FROM plugins"
|
||||||
" WHERE PlgCod=%ld",
|
" WHERE PlgCod=%ld",
|
||||||
Plg->PlgCod) < 0)
|
Plg->PlgCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get data of a plugin");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get data of a plugin");
|
|
||||||
|
|
||||||
/***** Count number of rows in result *****/
|
/***** Count number of rows in result *****/
|
||||||
if (NumRows) // Plugin found...
|
if (NumRows) // Plugin found...
|
||||||
|
|
|
@ -122,7 +122,6 @@ void Pre_EditPrefs (void)
|
||||||
|
|
||||||
void Pre_GetPrefsFromIP (void)
|
void Pre_GetPrefsFromIP (void)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
@ -130,11 +129,10 @@ void Pre_GetPrefsFromIP (void)
|
||||||
if (Gbl.IP[0])
|
if (Gbl.IP[0])
|
||||||
{
|
{
|
||||||
/***** Get preferences from database *****/
|
/***** Get preferences from database *****/
|
||||||
if (asprintf (&Query,"SELECT FirstDayOfWeek,DateFormat,Theme,IconSet,Menu,SideCols"
|
DB_BuildQuery ("SELECT FirstDayOfWeek,DateFormat,Theme,IconSet,Menu,SideCols"
|
||||||
" FROM IP_prefs WHERE IP='%s'",
|
" FROM IP_prefs WHERE IP='%s'",
|
||||||
Gbl.IP) < 0)
|
Gbl.IP);
|
||||||
Lay_NotEnoughMemoryExit ();
|
if ((NumRows = DB_QuerySELECT_new (&mysql_res,"can not get preferences")))
|
||||||
if ((NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get preferences")))
|
|
||||||
{
|
{
|
||||||
if (NumRows != 1)
|
if (NumRows != 1)
|
||||||
Lay_ShowErrorAndExit ("Internal error while getting preferences.");
|
Lay_ShowErrorAndExit ("Internal error while getting preferences.");
|
||||||
|
|
326
swad_profile.c
326
swad_profile.c
|
@ -622,19 +622,17 @@ static void Prf_PutLinkToUpdateAction (Act_Action_t Action,const char *Encrypted
|
||||||
|
|
||||||
void Prf_GetUsrFigures (long UsrCod,struct UsrFigures *UsrFigures)
|
void Prf_GetUsrFigures (long UsrCod,struct UsrFigures *UsrFigures)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumRows;
|
unsigned NumRows;
|
||||||
|
|
||||||
/***** Get user's figures from database *****/
|
/***** Get user's figures from database *****/
|
||||||
if (asprintf (&Query,"SELECT UNIX_TIMESTAMP(FirstClickTime),"
|
DB_BuildQuery ("SELECT UNIX_TIMESTAMP(FirstClickTime),"
|
||||||
"DATEDIFF(NOW(),FirstClickTime)+1,"
|
"DATEDIFF(NOW(),FirstClickTime)+1,"
|
||||||
"NumClicks,NumFileViews,NumForPst,NumMsgSnt"
|
"NumClicks,NumFileViews,NumForPst,NumMsgSnt"
|
||||||
" FROM usr_figures WHERE UsrCod=%ld",
|
" FROM usr_figures WHERE UsrCod=%ld",
|
||||||
UsrCod) < 0)
|
UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
if ((NumRows = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get user's figures")))
|
||||||
if ((NumRows = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get user's figures")))
|
|
||||||
{
|
{
|
||||||
/***** Get user's figures *****/
|
/***** Get user's figures *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -856,12 +854,11 @@ static void Prf_GetFirstClickFromLogAndStoreAsUsrFigure (long UsrCod)
|
||||||
Prf_ResetUsrFigures (&UsrFigures);
|
Prf_ResetUsrFigures (&UsrFigures);
|
||||||
|
|
||||||
/***** Get first click from log table *****/
|
/***** Get first click from log table *****/
|
||||||
if (asprintf (&Query,"SELECT UNIX_TIMESTAMP("
|
DB_BuildQuery ("SELECT UNIX_TIMESTAMP("
|
||||||
"(SELECT MIN(ClickTime) FROM log_full WHERE UsrCod=%ld)"
|
"(SELECT MIN(ClickTime) FROM log_full WHERE UsrCod=%ld)"
|
||||||
")",
|
")",
|
||||||
UsrCod) < 0)
|
UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
if (DB_QuerySELECT_new (&mysql_res,"can not get user's first click"))
|
||||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get user's first click"))
|
|
||||||
{
|
{
|
||||||
/* Get first click */
|
/* Get first click */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -1206,104 +1203,96 @@ void Prf_GetAndShowRankingMsgSnt (void)
|
||||||
|
|
||||||
static void Prf_GetAndShowRankingFigure (const char *FieldName)
|
static void Prf_GetAndShowRankingFigure (const char *FieldName)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Get ranking from database *****/
|
/***** Get ranking from database *****/
|
||||||
switch (Gbl.Scope.Current)
|
switch (Gbl.Scope.Current)
|
||||||
{
|
{
|
||||||
case Sco_SCOPE_SYS:
|
case Sco_SCOPE_SYS:
|
||||||
if (asprintf (&Query,"SELECT UsrCod,%s"
|
DB_BuildQuery ("SELECT UsrCod,%s"
|
||||||
" FROM usr_figures"
|
" FROM usr_figures"
|
||||||
" WHERE %s>=0"
|
" WHERE %s>=0"
|
||||||
" AND UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
" AND UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
||||||
" ORDER BY %s DESC,UsrCod LIMIT 100",
|
" ORDER BY %s DESC,UsrCod LIMIT 100",
|
||||||
FieldName,
|
FieldName,
|
||||||
FieldName,FieldName) < 0)
|
FieldName,FieldName);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CTY:
|
case Sco_SCOPE_CTY:
|
||||||
if (asprintf (&Query,"SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
DB_BuildQuery ("SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
||||||
" FROM institutions,centres,degrees,courses,crs_usr,usr_figures"
|
" FROM institutions,centres,degrees,courses,crs_usr,usr_figures"
|
||||||
" WHERE institutions.CtyCod=%ld"
|
" WHERE institutions.CtyCod=%ld"
|
||||||
" AND institutions.InsCod=centres.InsCod"
|
" AND institutions.InsCod=centres.InsCod"
|
||||||
" AND centres.CtrCod=degrees.CtrCod"
|
" AND centres.CtrCod=degrees.CtrCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
||||||
" AND usr_figures.%s>=0"
|
" AND usr_figures.%s>=0"
|
||||||
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
||||||
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
||||||
FieldName,
|
FieldName,
|
||||||
Gbl.CurrentCty.Cty.CtyCod,
|
Gbl.CurrentCty.Cty.CtyCod,
|
||||||
FieldName,FieldName) < 0)
|
FieldName,FieldName);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_INS:
|
case Sco_SCOPE_INS:
|
||||||
if (asprintf (&Query,"SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
DB_BuildQuery ("SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
||||||
" FROM centres,degrees,courses,crs_usr,usr_figures"
|
" FROM centres,degrees,courses,crs_usr,usr_figures"
|
||||||
" WHERE centres.InsCod=%ld"
|
" WHERE centres.InsCod=%ld"
|
||||||
" AND centres.CtrCod=degrees.CtrCod"
|
" AND centres.CtrCod=degrees.CtrCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
||||||
" AND usr_figures.%s>=0"
|
" AND usr_figures.%s>=0"
|
||||||
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
||||||
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
||||||
FieldName,
|
FieldName,
|
||||||
Gbl.CurrentIns.Ins.InsCod,
|
Gbl.CurrentIns.Ins.InsCod,
|
||||||
FieldName,FieldName) < 0)
|
FieldName,FieldName);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CTR:
|
case Sco_SCOPE_CTR:
|
||||||
if (asprintf (&Query,"SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
DB_BuildQuery ("SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
||||||
" FROM degrees,courses,crs_usr,usr_figures"
|
" FROM degrees,courses,crs_usr,usr_figures"
|
||||||
" WHERE degrees.CtrCod=%ld"
|
" WHERE degrees.CtrCod=%ld"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
||||||
" AND usr_figures.%s>=0"
|
" AND usr_figures.%s>=0"
|
||||||
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
||||||
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
||||||
FieldName,
|
FieldName,
|
||||||
Gbl.CurrentCtr.Ctr.CtrCod,
|
Gbl.CurrentCtr.Ctr.CtrCod,
|
||||||
FieldName,FieldName) < 0)
|
FieldName,FieldName);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_DEG:
|
case Sco_SCOPE_DEG:
|
||||||
if (asprintf (&Query,"SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
DB_BuildQuery ("SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
||||||
" FROM courses,crs_usr,usr_figures"
|
" FROM courses,crs_usr,usr_figures"
|
||||||
" WHERE courses.DegCod=%ld"
|
" WHERE courses.DegCod=%ld"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
||||||
" AND usr_figures.%s>=0"
|
" AND usr_figures.%s>=0"
|
||||||
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
||||||
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
||||||
FieldName,
|
FieldName,
|
||||||
Gbl.CurrentDeg.Deg.DegCod,
|
Gbl.CurrentDeg.Deg.DegCod,
|
||||||
FieldName,FieldName) < 0)
|
FieldName,FieldName);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CRS:
|
case Sco_SCOPE_CRS:
|
||||||
if (asprintf (&Query,"SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
DB_BuildQuery ("SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
||||||
" FROM crs_usr,usr_figures"
|
" FROM crs_usr,usr_figures"
|
||||||
" WHERE crs_usr.CrsCod=%ld"
|
" WHERE crs_usr.CrsCod=%ld"
|
||||||
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
||||||
" AND usr_figures.%s>=0"
|
" AND usr_figures.%s>=0"
|
||||||
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
||||||
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
||||||
FieldName,
|
FieldName,
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
FieldName,FieldName) < 0)
|
FieldName,FieldName);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Lay_WrongScopeExit ();
|
Lay_WrongScopeExit ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Prf_ShowRankingFigure (Query);
|
Prf_ShowRankingFigure ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Prf_ShowRankingFigure (const char *Query)
|
void Prf_ShowRankingFigure (void)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
@ -1314,7 +1303,7 @@ void Prf_ShowRankingFigure (const char *Query)
|
||||||
long FigureHigh = LONG_MAX;
|
long FigureHigh = LONG_MAX;
|
||||||
long Figure;
|
long Figure;
|
||||||
|
|
||||||
NumUsrs = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get ranking");
|
NumUsrs = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get ranking");
|
||||||
if (NumUsrs)
|
if (NumUsrs)
|
||||||
{
|
{
|
||||||
/***** Initialize structure with user's data *****/
|
/***** Initialize structure with user's data *****/
|
||||||
|
@ -1371,7 +1360,6 @@ void Prf_ShowRankingFigure (const char *Query)
|
||||||
|
|
||||||
void Prf_GetAndShowRankingClicksPerDay (void)
|
void Prf_GetAndShowRankingClicksPerDay (void)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumUsrs;
|
unsigned NumUsrs;
|
||||||
|
@ -1385,100 +1373,94 @@ void Prf_GetAndShowRankingClicksPerDay (void)
|
||||||
switch (Gbl.Scope.Current)
|
switch (Gbl.Scope.Current)
|
||||||
{
|
{
|
||||||
case Sco_SCOPE_SYS:
|
case Sco_SCOPE_SYS:
|
||||||
if (asprintf (&Query,"SELECT UsrCod,"
|
DB_BuildQuery ("SELECT UsrCod,"
|
||||||
"NumClicks/(DATEDIFF(NOW(),FirstClickTime)+1) AS NumClicksPerDay"
|
"NumClicks/(DATEDIFF(NOW(),FirstClickTime)+1) AS NumClicksPerDay"
|
||||||
" FROM usr_figures"
|
" FROM usr_figures"
|
||||||
" WHERE NumClicks>0"
|
" WHERE NumClicks>0"
|
||||||
" AND UNIX_TIMESTAMP(FirstClickTime)>0"
|
" AND UNIX_TIMESTAMP(FirstClickTime)>0"
|
||||||
" AND UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
" AND UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
||||||
" ORDER BY NumClicksPerDay DESC,UsrCod LIMIT 100") < 0)
|
" ORDER BY NumClicksPerDay DESC,UsrCod LIMIT 100");
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CTY:
|
case Sco_SCOPE_CTY:
|
||||||
if (asprintf (&Query,"SELECT DISTINCTROW usr_figures.UsrCod,"
|
DB_BuildQuery ("SELECT DISTINCTROW usr_figures.UsrCod,"
|
||||||
"usr_figures.NumClicks/(DATEDIFF(NOW(),"
|
"usr_figures.NumClicks/(DATEDIFF(NOW(),"
|
||||||
"usr_figures.FirstClickTime)+1) AS NumClicksPerDay"
|
"usr_figures.FirstClickTime)+1) AS NumClicksPerDay"
|
||||||
" FROM institutions,centres,degrees,courses,crs_usr,usr_figures"
|
" FROM institutions,centres,degrees,courses,crs_usr,usr_figures"
|
||||||
" WHERE institutions.CtyCod=%ld"
|
" WHERE institutions.CtyCod=%ld"
|
||||||
" AND institutions.InsCod=centres.InsCod"
|
" AND institutions.InsCod=centres.InsCod"
|
||||||
" AND centres.CtrCod=degrees.CtrCod"
|
" AND centres.CtrCod=degrees.CtrCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
||||||
" AND usr_figures.NumClicks>0"
|
" AND usr_figures.NumClicks>0"
|
||||||
" AND UNIX_TIMESTAMP(usr_figures.FirstClickTime)>0"
|
" AND UNIX_TIMESTAMP(usr_figures.FirstClickTime)>0"
|
||||||
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
||||||
" ORDER BY NumClicksPerDay DESC,usr_figures.UsrCod LIMIT 100",
|
" ORDER BY NumClicksPerDay DESC,usr_figures.UsrCod LIMIT 100",
|
||||||
Gbl.CurrentCty.Cty.CtyCod) < 0)
|
Gbl.CurrentCty.Cty.CtyCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_INS:
|
case Sco_SCOPE_INS:
|
||||||
if (asprintf (&Query,"SELECT DISTINCTROW usr_figures.UsrCod,"
|
DB_BuildQuery ("SELECT DISTINCTROW usr_figures.UsrCod,"
|
||||||
"usr_figures.NumClicks/(DATEDIFF(NOW(),"
|
"usr_figures.NumClicks/(DATEDIFF(NOW(),"
|
||||||
"usr_figures.FirstClickTime)+1) AS NumClicksPerDay"
|
"usr_figures.FirstClickTime)+1) AS NumClicksPerDay"
|
||||||
" FROM centres,degrees,courses,crs_usr,usr_figures"
|
" FROM centres,degrees,courses,crs_usr,usr_figures"
|
||||||
" WHERE centres.InsCod=%ld"
|
" WHERE centres.InsCod=%ld"
|
||||||
" AND centres.CtrCod=degrees.CtrCod"
|
" AND centres.CtrCod=degrees.CtrCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
||||||
" AND usr_figures.NumClicks>0"
|
" AND usr_figures.NumClicks>0"
|
||||||
" AND UNIX_TIMESTAMP(usr_figures.FirstClickTime)>0"
|
" AND UNIX_TIMESTAMP(usr_figures.FirstClickTime)>0"
|
||||||
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
||||||
" ORDER BY NumClicksPerDay DESC,usr_figures.UsrCod LIMIT 100",
|
" ORDER BY NumClicksPerDay DESC,usr_figures.UsrCod LIMIT 100",
|
||||||
Gbl.CurrentIns.Ins.InsCod) < 0)
|
Gbl.CurrentIns.Ins.InsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CTR:
|
case Sco_SCOPE_CTR:
|
||||||
if (asprintf (&Query,"SELECT DISTINCTROW usr_figures.UsrCod,"
|
DB_BuildQuery ("SELECT DISTINCTROW usr_figures.UsrCod,"
|
||||||
"usr_figures.NumClicks/(DATEDIFF(NOW(),"
|
"usr_figures.NumClicks/(DATEDIFF(NOW(),"
|
||||||
"usr_figures.FirstClickTime)+1) AS NumClicksPerDay"
|
"usr_figures.FirstClickTime)+1) AS NumClicksPerDay"
|
||||||
" FROM degrees,courses,crs_usr,usr_figures"
|
" FROM degrees,courses,crs_usr,usr_figures"
|
||||||
" WHERE degrees.CtrCod=%ld"
|
" WHERE degrees.CtrCod=%ld"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
||||||
" AND usr_figures.NumClicks>0"
|
" AND usr_figures.NumClicks>0"
|
||||||
" AND UNIX_TIMESTAMP(usr_figures.FirstClickTime)>0"
|
" AND UNIX_TIMESTAMP(usr_figures.FirstClickTime)>0"
|
||||||
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
||||||
" ORDER BY NumClicksPerDay DESC,usr_figures.UsrCod LIMIT 100",
|
" ORDER BY NumClicksPerDay DESC,usr_figures.UsrCod LIMIT 100",
|
||||||
Gbl.CurrentCtr.Ctr.CtrCod) < 0)
|
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_DEG:
|
case Sco_SCOPE_DEG:
|
||||||
if (asprintf (&Query,"SELECT DISTINCTROW usr_figures.UsrCod,"
|
DB_BuildQuery ("SELECT DISTINCTROW usr_figures.UsrCod,"
|
||||||
"usr_figures.NumClicks/(DATEDIFF(NOW(),"
|
"usr_figures.NumClicks/(DATEDIFF(NOW(),"
|
||||||
"usr_figures.FirstClickTime)+1) AS NumClicksPerDay"
|
"usr_figures.FirstClickTime)+1) AS NumClicksPerDay"
|
||||||
" FROM courses,crs_usr,usr_figures"
|
" FROM courses,crs_usr,usr_figures"
|
||||||
" WHERE courses.DegCod=%ld"
|
" WHERE courses.DegCod=%ld"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
||||||
" AND usr_figures.NumClicks>0"
|
" AND usr_figures.NumClicks>0"
|
||||||
" AND UNIX_TIMESTAMP(usr_figures.FirstClickTime)>0"
|
" AND UNIX_TIMESTAMP(usr_figures.FirstClickTime)>0"
|
||||||
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
||||||
" ORDER BY NumClicksPerDay DESC,usr_figures.UsrCod LIMIT 100",
|
" ORDER BY NumClicksPerDay DESC,usr_figures.UsrCod LIMIT 100",
|
||||||
Gbl.CurrentDeg.Deg.DegCod) < 0)
|
Gbl.CurrentDeg.Deg.DegCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CRS:
|
case Sco_SCOPE_CRS:
|
||||||
if (asprintf (&Query,"SELECT DISTINCTROW usr_figures.UsrCod,"
|
DB_BuildQuery ("SELECT DISTINCTROW usr_figures.UsrCod,"
|
||||||
"usr_figures.NumClicks/(DATEDIFF(NOW(),"
|
"usr_figures.NumClicks/(DATEDIFF(NOW(),"
|
||||||
"usr_figures.FirstClickTime)+1) AS NumClicksPerDay"
|
"usr_figures.FirstClickTime)+1) AS NumClicksPerDay"
|
||||||
" FROM crs_usr,usr_figures"
|
" FROM crs_usr,usr_figures"
|
||||||
" WHERE crs_usr.CrsCod=%ld"
|
" WHERE crs_usr.CrsCod=%ld"
|
||||||
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
||||||
" AND usr_figures.NumClicks>0"
|
" AND usr_figures.NumClicks>0"
|
||||||
" AND UNIX_TIMESTAMP(usr_figures.FirstClickTime)>0"
|
" AND UNIX_TIMESTAMP(usr_figures.FirstClickTime)>0"
|
||||||
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
||||||
" ORDER BY NumClicksPerDay DESC,usr_figures.UsrCod LIMIT 100",
|
" ORDER BY NumClicksPerDay DESC,usr_figures.UsrCod LIMIT 100",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod) < 0)
|
Gbl.CurrentCrs.Crs.CrsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Lay_WrongScopeExit ();
|
Lay_WrongScopeExit ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
NumUsrs = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get ranking");
|
NumUsrs = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get ranking");
|
||||||
if (NumUsrs)
|
if (NumUsrs)
|
||||||
{
|
{
|
||||||
/***** Initialize structure with user's data *****/
|
/***** Initialize structure with user's data *****/
|
||||||
|
|
|
@ -77,7 +77,7 @@ void Prf_GetAndShowRankingClicks (void);
|
||||||
void Prf_GetAndShowRankingFileViews (void);
|
void Prf_GetAndShowRankingFileViews (void);
|
||||||
void Prf_GetAndShowRankingForPst (void);
|
void Prf_GetAndShowRankingForPst (void);
|
||||||
void Prf_GetAndShowRankingMsgSnt (void);
|
void Prf_GetAndShowRankingMsgSnt (void);
|
||||||
void Prf_ShowRankingFigure (const char *Query);
|
void Prf_ShowRankingFigure (void);
|
||||||
void Prf_GetAndShowRankingClicksPerDay (void);
|
void Prf_GetAndShowRankingClicksPerDay (void);
|
||||||
void Prf_ShowUsrInRanking (struct UsrData *UsrDat,unsigned Rank);
|
void Prf_ShowUsrInRanking (struct UsrData *UsrDat,unsigned Rank);
|
||||||
|
|
||||||
|
|
285
swad_project.c
285
swad_project.c
|
@ -1799,21 +1799,18 @@ static void Prj_ShowTableAllProjectsMembersWithARole (const struct Project *Prj,
|
||||||
static unsigned Prj_GetUsrsInPrj (long PrjCod,Prj_RoleInProject_t RoleInProject,
|
static unsigned Prj_GetUsrsInPrj (long PrjCod,Prj_RoleInProject_t RoleInProject,
|
||||||
MYSQL_RES **mysql_res)
|
MYSQL_RES **mysql_res)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Get users in project from database *****/
|
/***** Get users in project from database *****/
|
||||||
if (asprintf (&Query,"SELECT prj_usr.UsrCod,"
|
DB_BuildQuery ("SELECT prj_usr.UsrCod,"
|
||||||
"usr_data.Surname1 AS S1,"
|
"usr_data.Surname1 AS S1,"
|
||||||
"usr_data.Surname2 AS S2,"
|
"usr_data.Surname2 AS S2,"
|
||||||
"usr_data.FirstName AS FN"
|
"usr_data.FirstName AS FN"
|
||||||
" FROM prj_usr,usr_data"
|
" FROM prj_usr,usr_data"
|
||||||
" WHERE prj_usr.PrjCod=%ld AND RoleInProject=%u"
|
" WHERE prj_usr.PrjCod=%ld AND RoleInProject=%u"
|
||||||
" AND prj_usr.UsrCod=usr_data.UsrCod"
|
" AND prj_usr.UsrCod=usr_data.UsrCod"
|
||||||
" ORDER BY S1,S2,FN",
|
" ORDER BY S1,S2,FN",
|
||||||
PrjCod,(unsigned) RoleInProject) < 0)
|
PrjCod,(unsigned) RoleInProject);
|
||||||
Lay_NotEnoughMemoryExit ();
|
return (unsigned) DB_QuerySELECT_new (mysql_res,
|
||||||
return (unsigned) DB_QuerySELECT_free (Query,mysql_res,
|
"can not get users in project");
|
||||||
"can not get users in project");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1828,7 +1825,6 @@ void Prj_FlushCacheMyRoleInProject (void)
|
||||||
|
|
||||||
Prj_RoleInProject_t Prj_GetMyRoleInProject (long PrjCod)
|
Prj_RoleInProject_t Prj_GetMyRoleInProject (long PrjCod)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
|
@ -1845,11 +1841,10 @@ Prj_RoleInProject_t Prj_GetMyRoleInProject (long PrjCod)
|
||||||
The result of the query will have one row or none *****/
|
The result of the query will have one row or none *****/
|
||||||
Gbl.Cache.MyRoleInProject.PrjCod = PrjCod;
|
Gbl.Cache.MyRoleInProject.PrjCod = PrjCod;
|
||||||
Gbl.Cache.MyRoleInProject.RoleInProject = Prj_ROLE_UNK;
|
Gbl.Cache.MyRoleInProject.RoleInProject = Prj_ROLE_UNK;
|
||||||
if (asprintf (&Query,"SELECT RoleInProject FROM prj_usr"
|
DB_BuildQuery ("SELECT RoleInProject FROM prj_usr"
|
||||||
" WHERE PrjCod=%ld AND UsrCod=%ld",
|
" WHERE PrjCod=%ld AND UsrCod=%ld",
|
||||||
PrjCod,Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
PrjCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
if (DB_QuerySELECT_new (&mysql_res,"can not get my role in project"))
|
||||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get my role in project"))
|
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
Gbl.Cache.MyRoleInProject.RoleInProject = Prj_ConvertUnsignedStrToRoleInProject (row[0]);
|
Gbl.Cache.MyRoleInProject.RoleInProject = Prj_ConvertUnsignedStrToRoleInProject (row[0]);
|
||||||
|
@ -2295,7 +2290,6 @@ void Prj_GetListProjects (void)
|
||||||
char HidVisSubQuery[Prj_MAX_BYTES_SUBQUERY];
|
char HidVisSubQuery[Prj_MAX_BYTES_SUBQUERY];
|
||||||
char DptCodSubQuery[Prj_MAX_BYTES_SUBQUERY];
|
char DptCodSubQuery[Prj_MAX_BYTES_SUBQUERY];
|
||||||
char OrderBySubQuery[Prj_MAX_BYTES_SUBQUERY];
|
char OrderBySubQuery[Prj_MAX_BYTES_SUBQUERY];
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
|
@ -2396,33 +2390,31 @@ void Prj_GetListProjects (void)
|
||||||
case Prj_ORDER_START_TIME:
|
case Prj_ORDER_START_TIME:
|
||||||
case Prj_ORDER_END_TIME:
|
case Prj_ORDER_END_TIME:
|
||||||
case Prj_ORDER_TITLE:
|
case Prj_ORDER_TITLE:
|
||||||
if (asprintf (&Query,"SELECT projects.PrjCod"
|
DB_BuildQuery ("SELECT projects.PrjCod"
|
||||||
" FROM projects,prj_usr"
|
" FROM projects,prj_usr"
|
||||||
" WHERE projects.CrsCod=%ld"
|
" WHERE projects.CrsCod=%ld"
|
||||||
"%s%s%s"
|
"%s%s%s"
|
||||||
" AND projects.PrjCod=prj_usr.PrjCod"
|
" AND projects.PrjCod=prj_usr.PrjCod"
|
||||||
" AND prj_usr.UsrCod=%ld"
|
" AND prj_usr.UsrCod=%ld"
|
||||||
" ORDER BY %s",
|
" ORDER BY %s",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
PreNonSubQuery,HidVisSubQuery,DptCodSubQuery,
|
PreNonSubQuery,HidVisSubQuery,DptCodSubQuery,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
OrderBySubQuery) < 0)
|
OrderBySubQuery);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Prj_ORDER_DEPARTMENT:
|
case Prj_ORDER_DEPARTMENT:
|
||||||
if (asprintf (&Query,"SELECT projects.PrjCod"
|
DB_BuildQuery ("SELECT projects.PrjCod"
|
||||||
" FROM prj_usr,projects LEFT JOIN departments"
|
" FROM prj_usr,projects LEFT JOIN departments"
|
||||||
" ON projects.DptCod=departments.DptCod"
|
" ON projects.DptCod=departments.DptCod"
|
||||||
" WHERE projects.CrsCod=%ld"
|
" WHERE projects.CrsCod=%ld"
|
||||||
"%s%s%s"
|
"%s%s%s"
|
||||||
" AND projects.PrjCod=prj_usr.PrjCod"
|
" AND projects.PrjCod=prj_usr.PrjCod"
|
||||||
" AND prj_usr.UsrCod=%ld"
|
" AND prj_usr.UsrCod=%ld"
|
||||||
" ORDER BY %s",
|
" ORDER BY %s",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
PreNonSubQuery,HidVisSubQuery,DptCodSubQuery,
|
PreNonSubQuery,HidVisSubQuery,DptCodSubQuery,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
OrderBySubQuery) < 0)
|
OrderBySubQuery);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else // Gbl.Prjs.My_All == Prj_ALL_PROJECTS
|
else // Gbl.Prjs.My_All == Prj_ALL_PROJECTS
|
||||||
|
@ -2431,31 +2423,29 @@ void Prj_GetListProjects (void)
|
||||||
case Prj_ORDER_START_TIME:
|
case Prj_ORDER_START_TIME:
|
||||||
case Prj_ORDER_END_TIME:
|
case Prj_ORDER_END_TIME:
|
||||||
case Prj_ORDER_TITLE:
|
case Prj_ORDER_TITLE:
|
||||||
if (asprintf (&Query,"SELECT projects.PrjCod"
|
DB_BuildQuery ("SELECT projects.PrjCod"
|
||||||
" FROM projects"
|
" FROM projects"
|
||||||
" WHERE projects.CrsCod=%ld"
|
" WHERE projects.CrsCod=%ld"
|
||||||
"%s%s%s"
|
"%s%s%s"
|
||||||
" ORDER BY %s",
|
" ORDER BY %s",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
PreNonSubQuery,HidVisSubQuery,DptCodSubQuery,
|
PreNonSubQuery,HidVisSubQuery,DptCodSubQuery,
|
||||||
OrderBySubQuery) < 0)
|
OrderBySubQuery);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Prj_ORDER_DEPARTMENT:
|
case Prj_ORDER_DEPARTMENT:
|
||||||
if (asprintf (&Query,"SELECT projects.PrjCod"
|
DB_BuildQuery ("SELECT projects.PrjCod"
|
||||||
" FROM projects LEFT JOIN departments"
|
" FROM projects LEFT JOIN departments"
|
||||||
" ON projects.DptCod=departments.DptCod"
|
" ON projects.DptCod=departments.DptCod"
|
||||||
" WHERE projects.CrsCod=%ld"
|
" WHERE projects.CrsCod=%ld"
|
||||||
"%s%s%s"
|
"%s%s%s"
|
||||||
" ORDER BY %s",
|
" ORDER BY %s",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
PreNonSubQuery,HidVisSubQuery,DptCodSubQuery,
|
PreNonSubQuery,HidVisSubQuery,DptCodSubQuery,
|
||||||
OrderBySubQuery) < 0)
|
OrderBySubQuery);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get projects");
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get projects");
|
||||||
|
|
||||||
if (NumRows) // Projects found...
|
if (NumRows) // Projects found...
|
||||||
{
|
{
|
||||||
|
@ -2492,7 +2482,6 @@ void Prj_GetListProjects (void)
|
||||||
|
|
||||||
long Prj_GetCourseOfProject (long PrjCod)
|
long Prj_GetCourseOfProject (long PrjCod)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
long CrsCod = -1L;
|
long CrsCod = -1L;
|
||||||
|
@ -2500,10 +2489,8 @@ long Prj_GetCourseOfProject (long PrjCod)
|
||||||
if (PrjCod > 0)
|
if (PrjCod > 0)
|
||||||
{
|
{
|
||||||
/***** Get course code from database *****/
|
/***** Get course code from database *****/
|
||||||
if (asprintf (&Query,"SELECT CrsCod FROM projects WHERE PrjCod=%ld",
|
DB_BuildQuery ("SELECT CrsCod FROM projects WHERE PrjCod=%ld",PrjCod);
|
||||||
PrjCod) < 0)
|
if (DB_QuerySELECT_new (&mysql_res,"can not get project course")) // Project found...
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
if (DB_QuerySELECT_free (Query,&mysql_res,"can not get project course")) // Project found...
|
|
||||||
{
|
{
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -3504,7 +3491,6 @@ void Prj_RemoveUsrFromProjects (long UsrCod)
|
||||||
|
|
||||||
unsigned Prj_GetNumCoursesWithProjects (Sco_Scope_t Scope)
|
unsigned Prj_GetNumCoursesWithProjects (Sco_Scope_t Scope)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumCourses;
|
unsigned NumCourses;
|
||||||
|
@ -3513,65 +3499,59 @@ unsigned Prj_GetNumCoursesWithProjects (Sco_Scope_t Scope)
|
||||||
switch (Scope)
|
switch (Scope)
|
||||||
{
|
{
|
||||||
case Sco_SCOPE_SYS:
|
case Sco_SCOPE_SYS:
|
||||||
if (asprintf (&Query,"SELECT COUNT(DISTINCT CrsCod)"
|
DB_BuildQuery ("SELECT COUNT(DISTINCT CrsCod)"
|
||||||
" FROM projects"
|
" FROM projects"
|
||||||
" WHERE CrsCod>0") < 0)
|
" WHERE CrsCod>0");
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CTY:
|
case Sco_SCOPE_CTY:
|
||||||
if (asprintf (&Query,"SELECT COUNT(DISTINCT projects.CrsCod)"
|
DB_BuildQuery ("SELECT COUNT(DISTINCT projects.CrsCod)"
|
||||||
" FROM institutions,centres,degrees,courses,projects"
|
" FROM institutions,centres,degrees,courses,projects"
|
||||||
" WHERE institutions.CtyCod=%ld"
|
" WHERE institutions.CtyCod=%ld"
|
||||||
" AND institutions.InsCod=centres.InsCod"
|
" AND institutions.InsCod=centres.InsCod"
|
||||||
" AND centres.CtrCod=degrees.CtrCod"
|
" AND centres.CtrCod=degrees.CtrCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.Status=0"
|
" AND courses.Status=0"
|
||||||
" AND courses.CrsCod=projects.CrsCod",
|
" AND courses.CrsCod=projects.CrsCod",
|
||||||
Gbl.CurrentCty.Cty.CtyCod) < 0)
|
Gbl.CurrentCty.Cty.CtyCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_INS:
|
case Sco_SCOPE_INS:
|
||||||
if (asprintf (&Query,"SELECT COUNT(DISTINCT projects.CrsCod)"
|
DB_BuildQuery ("SELECT COUNT(DISTINCT projects.CrsCod)"
|
||||||
" FROM centres,degrees,courses,projects"
|
" FROM centres,degrees,courses,projects"
|
||||||
" WHERE centres.InsCod=%ld"
|
" WHERE centres.InsCod=%ld"
|
||||||
" AND centres.CtrCod=degrees.CtrCod"
|
" AND centres.CtrCod=degrees.CtrCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.Status=0"
|
" AND courses.Status=0"
|
||||||
" AND courses.CrsCod=projects.CrsCod",
|
" AND courses.CrsCod=projects.CrsCod",
|
||||||
Gbl.CurrentIns.Ins.InsCod) < 0)
|
Gbl.CurrentIns.Ins.InsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CTR:
|
case Sco_SCOPE_CTR:
|
||||||
if (asprintf (&Query,"SELECT COUNT(DISTINCT projects.CrsCod)"
|
DB_BuildQuery ("SELECT COUNT(DISTINCT projects.CrsCod)"
|
||||||
" FROM degrees,courses,projects"
|
" FROM degrees,courses,projects"
|
||||||
" WHERE degrees.CtrCod=%ld"
|
" WHERE degrees.CtrCod=%ld"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.Status=0"
|
" AND courses.Status=0"
|
||||||
" AND courses.CrsCod=projects.CrsCod",
|
" AND courses.CrsCod=projects.CrsCod",
|
||||||
Gbl.CurrentCtr.Ctr.CtrCod) < 0)
|
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_DEG:
|
case Sco_SCOPE_DEG:
|
||||||
if (asprintf (&Query,"SELECT COUNT(DISTINCT projects.CrsCod)"
|
DB_BuildQuery ("SELECT COUNT(DISTINCT projects.CrsCod)"
|
||||||
" FROM courses,projects"
|
" FROM courses,projects"
|
||||||
" WHERE courses.DegCod=%ld"
|
" WHERE courses.DegCod=%ld"
|
||||||
" AND courses.Status=0"
|
" AND courses.Status=0"
|
||||||
" AND courses.CrsCod=projects.CrsCod",
|
" AND courses.CrsCod=projects.CrsCod",
|
||||||
Gbl.CurrentDeg.Deg.DegCod) < 0)
|
Gbl.CurrentDeg.Deg.DegCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CRS:
|
case Sco_SCOPE_CRS:
|
||||||
if (asprintf (&Query,"SELECT COUNT(DISTINCT CrsCod)"
|
DB_BuildQuery ("SELECT COUNT(DISTINCT CrsCod)"
|
||||||
" FROM projects"
|
" FROM projects"
|
||||||
" WHERE CrsCod=%ld",
|
" WHERE CrsCod=%ld",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod) < 0)
|
Gbl.CurrentCrs.Crs.CrsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Lay_WrongScopeExit ();
|
Lay_WrongScopeExit ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
DB_QuerySELECT_free (Query,&mysql_res,"can not get number of courses with projects");
|
DB_QuerySELECT_new (&mysql_res,"can not get number of courses with projects");
|
||||||
|
|
||||||
/***** Get number of courses *****/
|
/***** Get number of courses *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -3591,7 +3571,6 @@ unsigned Prj_GetNumCoursesWithProjects (Sco_Scope_t Scope)
|
||||||
|
|
||||||
unsigned Prj_GetNumProjects (Sco_Scope_t Scope)
|
unsigned Prj_GetNumProjects (Sco_Scope_t Scope)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumProjects;
|
unsigned NumProjects;
|
||||||
|
@ -3600,61 +3579,55 @@ unsigned Prj_GetNumProjects (Sco_Scope_t Scope)
|
||||||
switch (Scope)
|
switch (Scope)
|
||||||
{
|
{
|
||||||
case Sco_SCOPE_SYS:
|
case Sco_SCOPE_SYS:
|
||||||
if (asprintf (&Query,"SELECT COUNT(*)"
|
DB_BuildQuery ("SELECT COUNT(*)"
|
||||||
" FROM projects"
|
" FROM projects"
|
||||||
" WHERE CrsCod>0") < 0)
|
" WHERE CrsCod>0");
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CTY:
|
case Sco_SCOPE_CTY:
|
||||||
if (asprintf (&Query,"SELECT COUNT(*)"
|
DB_BuildQuery ("SELECT COUNT(*)"
|
||||||
" FROM institutions,centres,degrees,courses,projects"
|
" FROM institutions,centres,degrees,courses,projects"
|
||||||
" WHERE institutions.CtyCod=%ld"
|
" WHERE institutions.CtyCod=%ld"
|
||||||
" AND institutions.InsCod=centres.InsCod"
|
" AND institutions.InsCod=centres.InsCod"
|
||||||
" AND centres.CtrCod=degrees.CtrCod"
|
" AND centres.CtrCod=degrees.CtrCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=projects.CrsCod",
|
" AND courses.CrsCod=projects.CrsCod",
|
||||||
Gbl.CurrentCty.Cty.CtyCod) < 0)
|
Gbl.CurrentCty.Cty.CtyCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_INS:
|
case Sco_SCOPE_INS:
|
||||||
if (asprintf (&Query,"SELECT COUNT(*)"
|
DB_BuildQuery ("SELECT COUNT(*)"
|
||||||
" FROM centres,degrees,courses,projects"
|
" FROM centres,degrees,courses,projects"
|
||||||
" WHERE centres.InsCod=%ld"
|
" WHERE centres.InsCod=%ld"
|
||||||
" AND centres.CtrCod=degrees.CtrCod"
|
" AND centres.CtrCod=degrees.CtrCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=projects.CrsCod",
|
" AND courses.CrsCod=projects.CrsCod",
|
||||||
Gbl.CurrentIns.Ins.InsCod) < 0)
|
Gbl.CurrentIns.Ins.InsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CTR:
|
case Sco_SCOPE_CTR:
|
||||||
if (asprintf (&Query,"SELECT COUNT(*)"
|
DB_BuildQuery ("SELECT COUNT(*)"
|
||||||
" FROM degrees,courses,projects"
|
" FROM degrees,courses,projects"
|
||||||
" WHERE degrees.CtrCod=%ld"
|
" WHERE degrees.CtrCod=%ld"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=projects.CrsCod",
|
" AND courses.CrsCod=projects.CrsCod",
|
||||||
Gbl.CurrentCtr.Ctr.CtrCod) < 0)
|
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_DEG:
|
case Sco_SCOPE_DEG:
|
||||||
if (asprintf (&Query,"SELECT COUNT(*)"
|
DB_BuildQuery ("SELECT COUNT(*)"
|
||||||
" FROM courses,projects"
|
" FROM courses,projects"
|
||||||
" WHERE courses.DegCod=%ld"
|
" WHERE courses.DegCod=%ld"
|
||||||
" AND courses.CrsCod=projects.CrsCod",
|
" AND courses.CrsCod=projects.CrsCod",
|
||||||
Gbl.CurrentDeg.Deg.DegCod) < 0)
|
Gbl.CurrentDeg.Deg.DegCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CRS:
|
case Sco_SCOPE_CRS:
|
||||||
if (asprintf (&Query,"SELECT COUNT(*)"
|
DB_BuildQuery ("SELECT COUNT(*)"
|
||||||
" FROM projects"
|
" FROM projects"
|
||||||
" WHERE CrsCod=%ld",
|
" WHERE CrsCod=%ld",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod) < 0)
|
Gbl.CurrentCrs.Crs.CrsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Lay_WrongScopeExit ();
|
Lay_WrongScopeExit ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
DB_QuerySELECT_free (Query,&mysql_res,"can not get number of projects");
|
DB_QuerySELECT_new (&mysql_res,"can not get number of projects");
|
||||||
|
|
||||||
/***** Get number of projects *****/
|
/***** Get number of projects *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
|
@ -223,7 +223,6 @@ void Rec_ReqEditRecordFields (void)
|
||||||
|
|
||||||
void Rec_GetListRecordFieldsInCurrentCrs (void)
|
void Rec_GetListRecordFieldsInCurrentCrs (void)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRow;
|
unsigned long NumRow;
|
||||||
|
@ -233,12 +232,11 @@ void Rec_GetListRecordFieldsInCurrentCrs (void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/***** Get fields of cards of a course from database *****/
|
/***** Get fields of cards of a course from database *****/
|
||||||
if (asprintf (&Query,"SELECT FieldCod,FieldName,NumLines,Visibility"
|
DB_BuildQuery ("SELECT FieldCod,FieldName,NumLines,Visibility"
|
||||||
" FROM crs_record_fields"
|
" FROM crs_record_fields"
|
||||||
" WHERE CrsCod=%ld ORDER BY FieldName",
|
" WHERE CrsCod=%ld ORDER BY FieldName",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod) < 0)
|
Gbl.CurrentCrs.Crs.CrsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
Gbl.CurrentCrs.Records.LstFields.Num = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get fields of cards of a course");
|
||||||
Gbl.CurrentCrs.Records.LstFields.Num = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get fields of cards of a course");
|
|
||||||
|
|
||||||
/***** Get the fields of records *****/
|
/***** Get the fields of records *****/
|
||||||
if (Gbl.CurrentCrs.Records.LstFields.Num)
|
if (Gbl.CurrentCrs.Records.LstFields.Num)
|
||||||
|
@ -559,16 +557,13 @@ bool Rec_CheckIfRecordFieldIsRepeated (const char *FieldName)
|
||||||
|
|
||||||
unsigned long Rec_GetAllFieldsInCurrCrs (MYSQL_RES **mysql_res)
|
unsigned long Rec_GetAllFieldsInCurrCrs (MYSQL_RES **mysql_res)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Get fields of cards of current course from database *****/
|
/***** Get fields of cards of current course from database *****/
|
||||||
if (asprintf (&Query,"SELECT FieldCod,FieldName,Visibility"
|
DB_BuildQuery ("SELECT FieldCod,FieldName,Visibility"
|
||||||
" FROM crs_record_fields"
|
" FROM crs_record_fields"
|
||||||
" WHERE CrsCod=%ld ORDER BY FieldName",
|
" WHERE CrsCod=%ld ORDER BY FieldName",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod) < 0)
|
Gbl.CurrentCrs.Crs.CrsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
return DB_QuerySELECT_new (mysql_res,
|
||||||
return DB_QuerySELECT_free (Query,mysql_res,
|
"can not get fields of cards of a course");
|
||||||
"can not get fields of cards of a course");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -739,18 +734,16 @@ static void Rec_PutParamFielCod (void)
|
||||||
static void Rec_GetFieldByCod (long FieldCod,char Name[Rec_MAX_BYTES_NAME_FIELD + 1],
|
static void Rec_GetFieldByCod (long FieldCod,char Name[Rec_MAX_BYTES_NAME_FIELD + 1],
|
||||||
unsigned *NumLines,Rec_VisibilityRecordFields_t *Visibility)
|
unsigned *NumLines,Rec_VisibilityRecordFields_t *Visibility)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
unsigned Vis;
|
unsigned Vis;
|
||||||
|
|
||||||
/***** Get a field of a record in a course from database *****/
|
/***** Get a field of a record in a course from database *****/
|
||||||
if (asprintf (&Query,"SELECT FieldName,NumLines,Visibility FROM crs_record_fields"
|
DB_BuildQuery ("SELECT FieldName,NumLines,Visibility FROM crs_record_fields"
|
||||||
" WHERE CrsCod=%ld AND FieldCod=%ld",
|
" WHERE CrsCod=%ld AND FieldCod=%ld",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,FieldCod) < 0)
|
Gbl.CurrentCrs.Crs.CrsCod,FieldCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get a field of a record in a course");
|
||||||
NumRows = DB_QuerySELECT_free (Query,&mysql_res,"can not get a field of a record in a course");
|
|
||||||
|
|
||||||
/***** Count number of rows in result *****/
|
/***** Count number of rows in result *****/
|
||||||
if (NumRows != 1)
|
if (NumRows != 1)
|
||||||
|
@ -1961,14 +1954,11 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
|
||||||
|
|
||||||
unsigned long Rec_GetFieldFromCrsRecord (long UsrCod,long FieldCod,MYSQL_RES **mysql_res)
|
unsigned long Rec_GetFieldFromCrsRecord (long UsrCod,long FieldCod,MYSQL_RES **mysql_res)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Get the text of a field of a record from database *****/
|
/***** Get the text of a field of a record from database *****/
|
||||||
if (asprintf (&Query,"SELECT Txt FROM crs_records"
|
DB_BuildQuery ("SELECT Txt FROM crs_records"
|
||||||
" WHERE FieldCod=%ld AND UsrCod=%ld",
|
" WHERE FieldCod=%ld AND UsrCod=%ld",
|
||||||
FieldCod,UsrCod) < 0)
|
FieldCod,UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
return DB_QuerySELECT_new (mysql_res,"can not get the text of a field of a record.");
|
||||||
return DB_QuerySELECT_free (Query,mysql_res,"can not get the text of a field of a record.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -717,9 +717,7 @@ static Tst_AnswerType_t TsI_ConvertFromStrAnsTypXMLToAnsTyp (const char *StrAnsT
|
||||||
static bool TsI_CheckIfQuestionExistsInDB (void)
|
static bool TsI_CheckIfQuestionExistsInDB (void)
|
||||||
{
|
{
|
||||||
extern const char *Tst_StrAnswerTypesDB[Tst_NUM_ANS_TYPES];
|
extern const char *Tst_StrAnswerTypesDB[Tst_NUM_ANS_TYPES];
|
||||||
char *QueryQst;
|
|
||||||
MYSQL_RES *mysql_res_qst;
|
MYSQL_RES *mysql_res_qst;
|
||||||
char *QueryAns;
|
|
||||||
MYSQL_RES *mysql_res_ans;
|
MYSQL_RES *mysql_res_ans;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
bool IdenticalQuestionFound = false;
|
bool IdenticalQuestionFound = false;
|
||||||
|
@ -732,21 +730,12 @@ static bool TsI_CheckIfQuestionExistsInDB (void)
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
/***** Check if stem exists *****/
|
/***** Check if stem exists *****/
|
||||||
/* Allocate space for query */
|
DB_BuildQuery ("SELECT QstCod FROM tst_questions"
|
||||||
if ((QueryQst = (char *) malloc (256 + Gbl.Test.Stem.Length)) == NULL)
|
" WHERE CrsCod=%ld AND AnsType='%s' AND Stem='%s'",
|
||||||
Lay_NotEnoughMemoryExit ();
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
|
Tst_StrAnswerTypesDB[Gbl.Test.AnswerType],
|
||||||
/* Make database query */
|
Gbl.Test.Stem.Text);
|
||||||
if (asprintf (&QueryQst,"SELECT QstCod FROM tst_questions"
|
NumQstsWithThisStem = (unsigned) DB_QuerySELECT_new (&mysql_res_qst,"can not check if a question exists");
|
||||||
" WHERE CrsCod=%ld AND AnsType='%s' AND Stem='%s'",
|
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
|
||||||
Tst_StrAnswerTypesDB[Gbl.Test.AnswerType],
|
|
||||||
Gbl.Test.Stem.Text) < 0)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
NumQstsWithThisStem = (unsigned) DB_QuerySELECT_free (QueryQst,&mysql_res_qst,"can not check if a question exists");
|
|
||||||
|
|
||||||
/* Free space user for query */
|
|
||||||
free ((void *) QueryQst);
|
|
||||||
|
|
||||||
if (NumQstsWithThisStem) // There are questions in database with the same stem that the one of this question
|
if (NumQstsWithThisStem) // There are questions in database with the same stem that the one of this question
|
||||||
{
|
{
|
||||||
|
@ -761,11 +750,10 @@ static bool TsI_CheckIfQuestionExistsInDB (void)
|
||||||
Lay_ShowErrorAndExit ("Wrong code of question.");
|
Lay_ShowErrorAndExit ("Wrong code of question.");
|
||||||
|
|
||||||
/* Get answers from this question */
|
/* Get answers from this question */
|
||||||
if (asprintf (&QueryAns,"SELECT Answer FROM tst_answers"
|
DB_BuildQuery ("SELECT Answer FROM tst_answers"
|
||||||
" WHERE QstCod=%ld ORDER BY AnsInd",
|
" WHERE QstCod=%ld ORDER BY AnsInd",
|
||||||
QstCod) < 0)
|
QstCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
NumOptsExistingQstInDB = (unsigned) DB_QuerySELECT_new (&mysql_res_ans,"can not get the answer of a question");
|
||||||
NumOptsExistingQstInDB = (unsigned) DB_QuerySELECT_free (QueryAns,&mysql_res_ans,"can not get the answer of a question");
|
|
||||||
|
|
||||||
switch (Gbl.Test.AnswerType)
|
switch (Gbl.Test.AnswerType)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user