mirror of https://github.com/acanas/swad-core.git
Version 18.11
This commit is contained in:
parent
6ca705598e
commit
f7b1f69fc3
|
@ -233,7 +233,7 @@ unsigned ID_GetListUsrCodsFromUsrID (struct UsrData *UsrDat,
|
|||
Str_Concat (Query," AND Confirmed='Y'",
|
||||
MaxLength);
|
||||
|
||||
ListUsrCods->NumUsrs = (unsigned) DB_QuerySELECT (&Query,&mysql_res,"can not get user's codes");
|
||||
ListUsrCods->NumUsrs = (unsigned) DB_QuerySELECT_old (&Query,&mysql_res,"can not get user's codes");
|
||||
if (ListUsrCods->NumUsrs)
|
||||
{
|
||||
/***** Allocate space for the list of users' codes *****/
|
||||
|
|
|
@ -200,14 +200,13 @@ void Acc_CheckIfEmptyAccountExists (void)
|
|||
/***** Check if there are users with this user's ID *****/
|
||||
if (ID_CheckIfUsrIDIsValid (ID))
|
||||
{
|
||||
DB_BuildQuery ("SELECT usr_IDs.UsrCod"
|
||||
" FROM usr_IDs,usr_data"
|
||||
" WHERE usr_IDs.UsrID='%s'"
|
||||
" AND usr_IDs.UsrCod=usr_data.UsrCod"
|
||||
" AND usr_data.Password=''",
|
||||
ID);
|
||||
NumUsrs = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get user's codes");
|
||||
|
||||
NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get user's codes"
|
||||
"SELECT usr_IDs.UsrCod"
|
||||
" FROM usr_IDs,usr_data"
|
||||
" WHERE usr_IDs.UsrID='%s'"
|
||||
" AND usr_IDs.UsrCod=usr_data.UsrCod"
|
||||
" AND usr_data.Password=''",
|
||||
ID);
|
||||
if (NumUsrs)
|
||||
{
|
||||
/***** Start box and table *****/
|
||||
|
|
|
@ -5123,10 +5123,10 @@ char *Act_GetActionTextFromDB (long ActCod,
|
|||
MYSQL_ROW row;
|
||||
|
||||
/***** Get test for an action from database *****/
|
||||
DB_BuildQuery ("SELECT Txt FROM actions"
|
||||
" WHERE ActCod=%ld AND Language='%s'",
|
||||
ActCod,Txt_STR_LANG_ID[Txt_LANGUAGE_ES]); // !!! TODO: Replace Txt_LANGUAGE_ES by Gbl.Prefs.Language !!!
|
||||
if (DB_QuerySELECT_new (&mysql_res,"can not get text for an action"))
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get text for an action",
|
||||
"SELECT Txt FROM actions"
|
||||
" WHERE ActCod=%ld AND Language='%s'",
|
||||
ActCod,Txt_STR_LANG_ID[Txt_LANGUAGE_ES])) // !!! TODO: Replace Txt_LANGUAGE_ES by Gbl.Prefs.Language !!!
|
||||
{
|
||||
/***** Get text *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
|
222
swad_agenda.c
222
swad_agenda.c
|
@ -1105,15 +1105,15 @@ static void Agd_GetListEvents (Agd_AgendaType_t AgendaType)
|
|||
}
|
||||
|
||||
/* Build full query */
|
||||
DB_BuildQuery ("SELECT AgdCod FROM agendas"
|
||||
" WHERE %s%s%s%s"
|
||||
" ORDER BY %s",
|
||||
UsrSubQuery,
|
||||
Past__FutureEventsSubQuery,
|
||||
PrivatPublicEventsSubQuery,
|
||||
HiddenVisiblEventsSubQuery,
|
||||
OrderBySubQuery);
|
||||
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get agenda events");
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get agenda events",
|
||||
"SELECT AgdCod FROM agendas"
|
||||
" WHERE %s%s%s%s"
|
||||
" ORDER BY %s",
|
||||
UsrSubQuery,
|
||||
Past__FutureEventsSubQuery,
|
||||
PrivatPublicEventsSubQuery,
|
||||
HiddenVisiblEventsSubQuery,
|
||||
OrderBySubQuery);
|
||||
|
||||
/* Free allocated memory for subqueries */
|
||||
free ((void *) OrderBySubQuery);
|
||||
|
@ -1157,19 +1157,17 @@ static void Agd_GetDataOfEventByCod (struct AgendaEvent *AgdEvent)
|
|||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
|
||||
/***** Build query *****/
|
||||
DB_BuildQuery ("SELECT AgdCod,Public,Hidden,"
|
||||
"UNIX_TIMESTAMP(StartTime),"
|
||||
"UNIX_TIMESTAMP(EndTime),"
|
||||
"NOW()>EndTime," // Past event?
|
||||
"NOW()<StartTime," // Future event?
|
||||
"Event,Location"
|
||||
" FROM agendas"
|
||||
" WHERE AgdCod=%ld AND UsrCod=%ld",
|
||||
AgdEvent->AgdCod,AgdEvent->UsrCod);
|
||||
|
||||
/***** Get data of event from database *****/
|
||||
if (DB_QuerySELECT_new (&mysql_res,"can not get agenda event data")) // Event found...
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get agenda event data",
|
||||
"SELECT AgdCod,Public,Hidden,"
|
||||
"UNIX_TIMESTAMP(StartTime),"
|
||||
"UNIX_TIMESTAMP(EndTime),"
|
||||
"NOW()>EndTime," // Past event?
|
||||
"NOW()<StartTime," // Future event?
|
||||
"Event,Location"
|
||||
" FROM agendas"
|
||||
" WHERE AgdCod=%ld AND UsrCod=%ld",
|
||||
AgdEvent->AgdCod,AgdEvent->UsrCod)) // Event found...
|
||||
{
|
||||
/* Get row:
|
||||
row[0] AgdCod
|
||||
|
@ -1257,10 +1255,10 @@ static void Agd_GetEventTxtFromDB (struct AgendaEvent *AgdEvent,
|
|||
unsigned long NumRows;
|
||||
|
||||
/***** Get text of event from database *****/
|
||||
DB_BuildQuery ("SELECT Txt FROM agendas"
|
||||
" WHERE AgdCod=%ld AND UsrCod=%ld",
|
||||
AgdEvent->AgdCod,AgdEvent->UsrCod);
|
||||
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get event text");
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get event text",
|
||||
"SELECT Txt FROM agendas"
|
||||
" WHERE AgdCod=%ld AND UsrCod=%ld",
|
||||
AgdEvent->AgdCod,AgdEvent->UsrCod);
|
||||
|
||||
/***** The result of the query must have one row or none *****/
|
||||
if (NumRows == 1)
|
||||
|
@ -1782,64 +1780,69 @@ unsigned Agd_GetNumUsrsWithEvents (Sco_Scope_t Scope)
|
|||
switch (Scope)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT UsrCod)"
|
||||
" FROM agendas"
|
||||
" WHERE UsrCod>0");
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of users with events",
|
||||
"SELECT COUNT(DISTINCT UsrCod)"
|
||||
" FROM agendas"
|
||||
" WHERE UsrCod>0");
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT agendas.UsrCod)"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr,agendas"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.Status=0"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.UsrCod=agendas.UsrCod",
|
||||
Gbl.CurrentCty.Cty.CtyCod);
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of users with events",
|
||||
"SELECT COUNT(DISTINCT agendas.UsrCod)"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr,agendas"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.Status=0"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.UsrCod=agendas.UsrCod",
|
||||
Gbl.CurrentCty.Cty.CtyCod);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT agendas.UsrCod)"
|
||||
" FROM centres,degrees,courses,crs_usr,agendas"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.Status=0"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.UsrCod=agendas.UsrCod",
|
||||
Gbl.CurrentIns.Ins.InsCod);
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of users with events",
|
||||
"SELECT COUNT(DISTINCT agendas.UsrCod)"
|
||||
" FROM centres,degrees,courses,crs_usr,agendas"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.Status=0"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.UsrCod=agendas.UsrCod",
|
||||
Gbl.CurrentIns.Ins.InsCod);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT agendas.UsrCod)"
|
||||
" FROM degrees,courses,crs_usr,agendas"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.Status=0"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.UsrCod=agendas.UsrCod",
|
||||
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of users with events",
|
||||
"SELECT COUNT(DISTINCT agendas.UsrCod)"
|
||||
" FROM degrees,courses,crs_usr,agendas"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.Status=0"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.UsrCod=agendas.UsrCod",
|
||||
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT agendas.UsrCod)"
|
||||
" FROM courses,crs_usr,agendas"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.Status=0"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.UsrCod=agendas.UsrCod",
|
||||
Gbl.CurrentDeg.Deg.DegCod);
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of users with events",
|
||||
"SELECT COUNT(DISTINCT agendas.UsrCod)"
|
||||
" FROM courses,crs_usr,agendas"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.Status=0"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.UsrCod=agendas.UsrCod",
|
||||
Gbl.CurrentDeg.Deg.DegCod);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT agendas.UsrCod)"
|
||||
" FROM crs_usr,agendas"
|
||||
" WHERE crs_usr.CrsCod=%ld"
|
||||
" AND crs_usr.UsrCod=agendas.UsrCod",
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of users with events",
|
||||
"SELECT COUNT(DISTINCT agendas.UsrCod)"
|
||||
" FROM crs_usr,agendas"
|
||||
" WHERE crs_usr.CrsCod=%ld"
|
||||
" AND crs_usr.UsrCod=agendas.UsrCod",
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
DB_QuerySELECT_new (&mysql_res,"can not get number of users with events");
|
||||
|
||||
/***** Get number of users *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -1867,60 +1870,65 @@ unsigned Agd_GetNumEvents (Sco_Scope_t Scope)
|
|||
switch (Scope)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
DB_BuildQuery ("SELECT COUNT(*)"
|
||||
" FROM agendas"
|
||||
" WHERE UsrCod>0");
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of events",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM agendas"
|
||||
" WHERE UsrCod>0");
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
DB_BuildQuery ("SELECT COUNT(*)"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr,agendas"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.UsrCod=agendas.UsrCod",
|
||||
Gbl.CurrentCty.Cty.CtyCod);
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of events",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr,agendas"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.UsrCod=agendas.UsrCod",
|
||||
Gbl.CurrentCty.Cty.CtyCod);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
DB_BuildQuery ("SELECT COUNT(*)"
|
||||
" FROM centres,degrees,courses,crs_usr,agendas"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.UsrCod=agendas.UsrCod",
|
||||
Gbl.CurrentIns.Ins.InsCod);
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of events",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM centres,degrees,courses,crs_usr,agendas"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.UsrCod=agendas.UsrCod",
|
||||
Gbl.CurrentIns.Ins.InsCod);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
DB_BuildQuery ("SELECT COUNT(*)"
|
||||
" FROM degrees,courses,crs_usr,agendas"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.UsrCod=agendas.UsrCod",
|
||||
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of events",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM degrees,courses,crs_usr,agendas"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.UsrCod=agendas.UsrCod",
|
||||
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
DB_BuildQuery ("SELECT COUNT(*)"
|
||||
" FROM courses,crs_usr,agendas"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.UsrCod=agendas.UsrCod",
|
||||
Gbl.CurrentDeg.Deg.DegCod);
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of events",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM courses,crs_usr,agendas"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.UsrCod=agendas.UsrCod",
|
||||
Gbl.CurrentDeg.Deg.DegCod);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
DB_BuildQuery ("SELECT COUNT(*)"
|
||||
" FROM crs_usr,agendas"
|
||||
" WHERE crs_usr.CrsCod=%ld"
|
||||
" AND crs_usr.UsrCod=agendas.UsrCod",
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of events",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM crs_usr,agendas"
|
||||
" WHERE crs_usr.CrsCod=%ld"
|
||||
" AND crs_usr.UsrCod=agendas.UsrCod",
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
DB_QuerySELECT_new (&mysql_res,"can not get number of events");
|
||||
|
||||
/***** Get number of events *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
|
|
@ -96,31 +96,33 @@ void Ann_ShowAllAnnouncements (void)
|
|||
if (ICanEdit)
|
||||
{
|
||||
/* Select all announcements */
|
||||
DB_BuildQuery ("SELECT AnnCod,Status,Roles,Subject,Content"
|
||||
" FROM announcements"
|
||||
" ORDER BY AnnCod DESC");
|
||||
NumAnnouncements = (unsigned) DB_QuerySELECT (&mysql_res,"can not get announcements",
|
||||
"SELECT AnnCod,Status,Roles,Subject,Content"
|
||||
" FROM announcements"
|
||||
" ORDER BY AnnCod DESC");
|
||||
}
|
||||
else if (Gbl.Usrs.Me.Logged)
|
||||
{
|
||||
/* Select only announcements I can see */
|
||||
Rol_GetRolesInAllCrssIfNotYetGot (&Gbl.Usrs.Me.UsrDat);
|
||||
DB_BuildQuery ("SELECT AnnCod,Status,Roles,Subject,Content"
|
||||
" FROM announcements"
|
||||
" WHERE (Roles&%u)<>0 "
|
||||
" ORDER BY AnnCod DESC",
|
||||
(unsigned) Gbl.Usrs.Me.UsrDat.Roles.InCrss); // All my roles in different courses
|
||||
NumAnnouncements = (unsigned) DB_QuerySELECT (&mysql_res,"can not get announcements",
|
||||
"SELECT AnnCod,Status,Roles,Subject,Content"
|
||||
" FROM announcements"
|
||||
" WHERE (Roles&%u)<>0 "
|
||||
" ORDER BY AnnCod DESC",
|
||||
(unsigned) Gbl.Usrs.Me.UsrDat.Roles.InCrss); // All my roles in different courses
|
||||
}
|
||||
else // No user logged
|
||||
{
|
||||
/* Select only active announcements for unknown users */
|
||||
DB_BuildQuery ("SELECT AnnCod,Status,Roles,Subject,Content"
|
||||
" FROM announcements"
|
||||
" WHERE Status=%u AND (Roles&%u)<>0 "
|
||||
" ORDER BY AnnCod DESC",
|
||||
(unsigned) Ann_ACTIVE_ANNOUNCEMENT,
|
||||
(unsigned) (1 << Rol_UNK));
|
||||
NumAnnouncements = (unsigned) DB_QuerySELECT (&mysql_res,"can not get announcements",
|
||||
"SELECT AnnCod,Status,Roles,Subject,Content"
|
||||
" FROM announcements"
|
||||
" WHERE Status=%u AND (Roles&%u)<>0 "
|
||||
" ORDER BY AnnCod DESC",
|
||||
(unsigned) Ann_ACTIVE_ANNOUNCEMENT,
|
||||
(unsigned) (1 << Rol_UNK));
|
||||
}
|
||||
NumAnnouncements = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get announcements");
|
||||
|
||||
/***** Start box *****/
|
||||
Box_StartBox ("550px",Txt_Announcements,
|
||||
|
@ -219,15 +221,15 @@ void Ann_ShowMyAnnouncementsNotMarkedAsSeen (void)
|
|||
|
||||
/***** Select announcements not seen *****/
|
||||
Rol_GetRolesInAllCrssIfNotYetGot (&Gbl.Usrs.Me.UsrDat);
|
||||
DB_BuildQuery ("SELECT AnnCod,Subject,Content FROM announcements"
|
||||
" WHERE Status=%u AND (Roles&%u)<>0 "
|
||||
" AND AnnCod NOT IN"
|
||||
" (SELECT AnnCod FROM ann_seen WHERE UsrCod=%ld)"
|
||||
" ORDER BY AnnCod DESC", // Newest first
|
||||
(unsigned) Ann_ACTIVE_ANNOUNCEMENT,
|
||||
(unsigned) Gbl.Usrs.Me.UsrDat.Roles.InCrss, // All my roles in different courses
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
NumAnnouncements = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get announcements");
|
||||
NumAnnouncements = (unsigned) DB_QuerySELECT (&mysql_res,"can not get announcements",
|
||||
"SELECT AnnCod,Subject,Content FROM announcements"
|
||||
" WHERE Status=%u AND (Roles&%u)<>0 "
|
||||
" AND AnnCod NOT IN"
|
||||
" (SELECT AnnCod FROM ann_seen WHERE UsrCod=%ld)"
|
||||
" ORDER BY AnnCod DESC", // Newest first
|
||||
(unsigned) Ann_ACTIVE_ANNOUNCEMENT,
|
||||
(unsigned) Gbl.Usrs.Me.UsrDat.Roles.InCrss, // All my roles in different courses
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
|
||||
/***** Show the announcements *****/
|
||||
if (NumAnnouncements)
|
||||
|
|
|
@ -81,7 +81,9 @@ static void Asg_GetParamAsgOrder (void);
|
|||
|
||||
static void Asg_PutFormsToRemEditOneAsg (long AsgCod,bool Hidden);
|
||||
static void Asg_PutParams (void);
|
||||
static void Asg_GetDataOfAssignment (struct Assignment *Asg);
|
||||
static void Asg_GetDataOfAssignment (struct Assignment *Asg,
|
||||
MYSQL_RES **mysql_res,
|
||||
unsigned long NumRows);
|
||||
static void Asg_ResetAssignment (struct Assignment *Asg);
|
||||
static void Asg_GetAssignmentTxtFromDB (long AsgCod,char Txt[Cns_MAX_BYTES_TEXT + 1]);
|
||||
static void Asg_PutParamAsgCod (long AsgCod);
|
||||
|
@ -657,24 +659,25 @@ void Asg_GetListAssignments (void)
|
|||
break;
|
||||
}
|
||||
if (Gbl.CurrentCrs.Grps.WhichGrps == Grp_ONLY_MY_GROUPS)
|
||||
DB_BuildQuery ("SELECT AsgCod"
|
||||
" FROM assignments"
|
||||
" WHERE CrsCod=%ld%s"
|
||||
" AND (AsgCod NOT IN (SELECT AsgCod FROM asg_grp) OR"
|
||||
" AsgCod IN (SELECT asg_grp.AsgCod FROM asg_grp,crs_grp_usr"
|
||||
" WHERE crs_grp_usr.UsrCod=%ld AND asg_grp.GrpCod=crs_grp_usr.GrpCod))"
|
||||
" ORDER BY %s",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,HiddenSubQuery,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
OrderBySubQuery);
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get assignments",
|
||||
"SELECT AsgCod"
|
||||
" FROM assignments"
|
||||
" WHERE CrsCod=%ld%s"
|
||||
" AND (AsgCod NOT IN (SELECT AsgCod FROM asg_grp) OR"
|
||||
" AsgCod IN (SELECT asg_grp.AsgCod FROM asg_grp,crs_grp_usr"
|
||||
" WHERE crs_grp_usr.UsrCod=%ld AND asg_grp.GrpCod=crs_grp_usr.GrpCod))"
|
||||
" ORDER BY %s",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,HiddenSubQuery,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
OrderBySubQuery);
|
||||
else // Gbl.CurrentCrs.Grps.WhichGrps == Grp_ALL_GROUPS
|
||||
DB_BuildQuery ("SELECT AsgCod"
|
||||
" FROM assignments"
|
||||
" WHERE CrsCod=%ld%s"
|
||||
" ORDER BY %s",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,HiddenSubQuery,
|
||||
OrderBySubQuery);
|
||||
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get assignments");
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get assignments",
|
||||
"SELECT AsgCod"
|
||||
" FROM assignments"
|
||||
" WHERE CrsCod=%ld%s"
|
||||
" ORDER BY %s",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,HiddenSubQuery,
|
||||
OrderBySubQuery);
|
||||
|
||||
/* Free allocated memory for subqueries */
|
||||
free ((void *) OrderBySubQuery);
|
||||
|
@ -714,20 +717,24 @@ void Asg_GetListAssignments (void)
|
|||
|
||||
void Asg_GetDataOfAssignmentByCod (struct Assignment *Asg)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
unsigned long NumRows;
|
||||
|
||||
if (Asg->AsgCod > 0)
|
||||
{
|
||||
/***** Build query *****/
|
||||
DB_BuildQuery ("SELECT AsgCod,Hidden,UsrCod,"
|
||||
"UNIX_TIMESTAMP(StartTime),"
|
||||
"UNIX_TIMESTAMP(EndTime),"
|
||||
"NOW() BETWEEN StartTime AND EndTime,"
|
||||
"Title,Folder"
|
||||
" FROM assignments"
|
||||
" WHERE AsgCod=%ld AND CrsCod=%ld",
|
||||
Asg->AsgCod,Gbl.CurrentCrs.Crs.CrsCod);
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get assignment data",
|
||||
"SELECT AsgCod,Hidden,UsrCod,"
|
||||
"UNIX_TIMESTAMP(StartTime),"
|
||||
"UNIX_TIMESTAMP(EndTime),"
|
||||
"NOW() BETWEEN StartTime AND EndTime,"
|
||||
"Title,Folder"
|
||||
" FROM assignments"
|
||||
" WHERE AsgCod=%ld AND CrsCod=%ld",
|
||||
Asg->AsgCod,Gbl.CurrentCrs.Crs.CrsCod);
|
||||
|
||||
/***** Get data of assignment *****/
|
||||
Asg_GetDataOfAssignment (Asg);
|
||||
Asg_GetDataOfAssignment (Asg,&mysql_res,NumRows);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -743,20 +750,24 @@ void Asg_GetDataOfAssignmentByCod (struct Assignment *Asg)
|
|||
|
||||
void Asg_GetDataOfAssignmentByFolder (struct Assignment *Asg)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
unsigned long NumRows;
|
||||
|
||||
if (Asg->Folder[0])
|
||||
{
|
||||
/***** Query database *****/
|
||||
DB_BuildQuery ("SELECT AsgCod,Hidden,UsrCod,"
|
||||
"UNIX_TIMESTAMP(StartTime),"
|
||||
"UNIX_TIMESTAMP(EndTime),"
|
||||
"NOW() BETWEEN StartTime AND EndTime,"
|
||||
"Title,Folder"
|
||||
" FROM assignments"
|
||||
" WHERE CrsCod=%ld AND Folder='%s'",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,Asg->Folder);
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get assignment data",
|
||||
"SELECT AsgCod,Hidden,UsrCod,"
|
||||
"UNIX_TIMESTAMP(StartTime),"
|
||||
"UNIX_TIMESTAMP(EndTime),"
|
||||
"NOW() BETWEEN StartTime AND EndTime,"
|
||||
"Title,Folder"
|
||||
" FROM assignments"
|
||||
" WHERE CrsCod=%ld AND Folder='%s'",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,Asg->Folder);
|
||||
|
||||
/***** Get data of assignment *****/
|
||||
Asg_GetDataOfAssignment (Asg);
|
||||
Asg_GetDataOfAssignment (Asg,&mysql_res,NumRows);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -770,19 +781,20 @@ void Asg_GetDataOfAssignmentByFolder (struct Assignment *Asg)
|
|||
/************************* Get assignment data *******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Asg_GetDataOfAssignment (struct Assignment *Asg)
|
||||
static void Asg_GetDataOfAssignment (struct Assignment *Asg,
|
||||
MYSQL_RES **mysql_res,
|
||||
unsigned long NumRows)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
|
||||
/***** Clear all assignment data *****/
|
||||
Asg_ResetAssignment (Asg);
|
||||
|
||||
/***** Get data of assignment from database *****/
|
||||
if (DB_QuerySELECT_new (&mysql_res,"can not get assignment data")) // Assignment found...
|
||||
if (NumRows) // Assignment found...
|
||||
{
|
||||
/* Get row */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
row = mysql_fetch_row (*mysql_res);
|
||||
|
||||
/* Get code of the assignment (row[0]) */
|
||||
Asg->AsgCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||
|
@ -816,7 +828,7 @@ static void Asg_GetDataOfAssignment (struct Assignment *Asg)
|
|||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
DB_FreeMySQLResult (mysql_res);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -866,10 +878,10 @@ static void Asg_GetAssignmentTxtFromDB (long AsgCod,char Txt[Cns_MAX_BYTES_TEXT
|
|||
unsigned long NumRows;
|
||||
|
||||
/***** Get text of assignment from database *****/
|
||||
DB_BuildQuery ("SELECT Txt FROM assignments"
|
||||
" WHERE AsgCod=%ld AND CrsCod=%ld",
|
||||
AsgCod,Gbl.CurrentCrs.Crs.CrsCod);
|
||||
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get assignment text");
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get assignment text",
|
||||
"SELECT Txt FROM assignments"
|
||||
" WHERE AsgCod=%ld AND CrsCod=%ld",
|
||||
AsgCod,Gbl.CurrentCrs.Crs.CrsCod);
|
||||
|
||||
/***** The result of the query must have one row or none *****/
|
||||
if (NumRows == 1)
|
||||
|
@ -906,8 +918,10 @@ void Asg_GetNotifAssignment (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
|||
SummaryStr[0] = '\0'; // Return nothing on error
|
||||
|
||||
/***** Build query *****/
|
||||
DB_BuildQuery ("SELECT Title,Txt FROM assignments WHERE AsgCod=%ld",AsgCod);
|
||||
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get assignment title and text");
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get assignment title and text",
|
||||
"SELECT Title,Txt FROM assignments"
|
||||
" WHERE AsgCod=%ld",
|
||||
AsgCod);
|
||||
|
||||
/***** Result should have a unique row *****/
|
||||
if (NumRows == 1)
|
||||
|
@ -1630,14 +1644,14 @@ static void Asg_GetAndWriteNamesOfGrpsAssociatedToAsg (struct Assignment *Asg)
|
|||
unsigned long NumRows;
|
||||
|
||||
/***** Get groups associated to an assignment from database *****/
|
||||
DB_BuildQuery ("SELECT crs_grp_types.GrpTypName,crs_grp.GrpName"
|
||||
" FROM asg_grp,crs_grp,crs_grp_types"
|
||||
" WHERE asg_grp.AsgCod=%ld"
|
||||
" AND asg_grp.GrpCod=crs_grp.GrpCod"
|
||||
" AND crs_grp.GrpTypCod=crs_grp_types.GrpTypCod"
|
||||
" ORDER BY crs_grp_types.GrpTypName,crs_grp.GrpName",
|
||||
Asg->AsgCod);
|
||||
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get groups of an assignment");
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get groups of an assignment",
|
||||
"SELECT crs_grp_types.GrpTypName,crs_grp.GrpName"
|
||||
" FROM asg_grp,crs_grp,crs_grp_types"
|
||||
" WHERE asg_grp.AsgCod=%ld"
|
||||
" AND asg_grp.GrpCod=crs_grp.GrpCod"
|
||||
" AND crs_grp.GrpTypCod=crs_grp_types.GrpTypCod"
|
||||
" ORDER BY crs_grp_types.GrpTypName,crs_grp.GrpName",
|
||||
Asg->AsgCod);
|
||||
|
||||
/***** Write heading *****/
|
||||
fprintf (Gbl.F.Out,"<div class=\"%s\">%s: ",
|
||||
|
@ -1762,59 +1776,64 @@ unsigned Asg_GetNumCoursesWithAssignments (Sco_Scope_t Scope)
|
|||
switch (Scope)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT CrsCod)"
|
||||
" FROM assignments"
|
||||
" WHERE CrsCod>0");
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with assignments",
|
||||
"SELECT COUNT(DISTINCT CrsCod)"
|
||||
" FROM assignments"
|
||||
" WHERE CrsCod>0");
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT assignments.CrsCod)"
|
||||
" FROM institutions,centres,degrees,courses,assignments"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.Status=0"
|
||||
" AND courses.CrsCod=assignments.CrsCod",
|
||||
Gbl.CurrentCty.Cty.CtyCod);
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with assignments",
|
||||
"SELECT COUNT(DISTINCT assignments.CrsCod)"
|
||||
" FROM institutions,centres,degrees,courses,assignments"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.Status=0"
|
||||
" AND courses.CrsCod=assignments.CrsCod",
|
||||
Gbl.CurrentCty.Cty.CtyCod);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT assignments.CrsCod)"
|
||||
" FROM centres,degrees,courses,assignments"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.Status=0"
|
||||
" AND courses.CrsCod=assignments.CrsCod",
|
||||
Gbl.CurrentIns.Ins.InsCod);
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with assignments",
|
||||
"SELECT COUNT(DISTINCT assignments.CrsCod)"
|
||||
" FROM centres,degrees,courses,assignments"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.Status=0"
|
||||
" AND courses.CrsCod=assignments.CrsCod",
|
||||
Gbl.CurrentIns.Ins.InsCod);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT assignments.CrsCod)"
|
||||
" FROM degrees,courses,assignments"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.Status=0"
|
||||
" AND courses.CrsCod=assignments.CrsCod",
|
||||
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with assignments",
|
||||
"SELECT COUNT(DISTINCT assignments.CrsCod)"
|
||||
" FROM degrees,courses,assignments"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.Status=0"
|
||||
" AND courses.CrsCod=assignments.CrsCod",
|
||||
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT assignments.CrsCod)"
|
||||
" FROM courses,assignments"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.Status=0"
|
||||
" AND courses.CrsCod=assignments.CrsCod",
|
||||
Gbl.CurrentDeg.Deg.DegCod);
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with assignments",
|
||||
"SELECT COUNT(DISTINCT assignments.CrsCod)"
|
||||
" FROM courses,assignments"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.Status=0"
|
||||
" AND courses.CrsCod=assignments.CrsCod",
|
||||
Gbl.CurrentDeg.Deg.DegCod);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
DB_BuildQuery ("SELECT COUNT(DISTINCT CrsCod)"
|
||||
" FROM assignments"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with assignments",
|
||||
"SELECT COUNT(DISTINCT CrsCod)"
|
||||
" FROM assignments"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
DB_QuerySELECT_new (&mysql_res,"can not get number of courses with assignments");
|
||||
|
||||
/***** Get number of courses *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -1843,55 +1862,60 @@ unsigned Asg_GetNumAssignments (Sco_Scope_t Scope,unsigned *NumNotif)
|
|||
switch (Scope)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
DB_BuildQuery ("SELECT COUNT(*),SUM(NumNotif)"
|
||||
" FROM assignments"
|
||||
" WHERE CrsCod>0");
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of assignments",
|
||||
"SELECT COUNT(*),SUM(NumNotif)"
|
||||
" FROM assignments"
|
||||
" WHERE CrsCod>0");
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
DB_BuildQuery ("SELECT COUNT(*),SUM(assignments.NumNotif)"
|
||||
" FROM institutions,centres,degrees,courses,assignments"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=assignments.CrsCod",
|
||||
Gbl.CurrentCty.Cty.CtyCod);
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of assignments",
|
||||
"SELECT COUNT(*),SUM(assignments.NumNotif)"
|
||||
" FROM institutions,centres,degrees,courses,assignments"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=assignments.CrsCod",
|
||||
Gbl.CurrentCty.Cty.CtyCod);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
DB_BuildQuery ("SELECT COUNT(*),SUM(assignments.NumNotif)"
|
||||
" FROM centres,degrees,courses,assignments"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=assignments.CrsCod",
|
||||
Gbl.CurrentIns.Ins.InsCod);
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of assignments",
|
||||
"SELECT COUNT(*),SUM(assignments.NumNotif)"
|
||||
" FROM centres,degrees,courses,assignments"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=assignments.CrsCod",
|
||||
Gbl.CurrentIns.Ins.InsCod);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
DB_BuildQuery ("SELECT COUNT(*),SUM(assignments.NumNotif)"
|
||||
" FROM degrees,courses,assignments"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=assignments.CrsCod",
|
||||
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of assignments",
|
||||
"SELECT COUNT(*),SUM(assignments.NumNotif)"
|
||||
" FROM degrees,courses,assignments"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=assignments.CrsCod",
|
||||
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
DB_BuildQuery ("SELECT COUNT(*),SUM(assignments.NumNotif)"
|
||||
" FROM courses,assignments"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=assignments.CrsCod",
|
||||
Gbl.CurrentDeg.Deg.DegCod);
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of assignments",
|
||||
"SELECT COUNT(*),SUM(assignments.NumNotif)"
|
||||
" FROM courses,assignments"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=assignments.CrsCod",
|
||||
Gbl.CurrentDeg.Deg.DegCod);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
DB_BuildQuery ("SELECT COUNT(*),SUM(NumNotif)"
|
||||
" FROM assignments"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of assignments",
|
||||
"SELECT COUNT(*),SUM(NumNotif)"
|
||||
" FROM assignments"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
DB_QuerySELECT_new (&mysql_res,"can not get number of assignments");
|
||||
|
||||
/***** Get number of assignments *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
|
|
@ -2452,7 +2452,7 @@ static unsigned Att_GetNumStdsFromAListWhoAreInAttEvent (long AttCod,long LstSel
|
|||
MaxLength);
|
||||
|
||||
|
||||
NumStdsInAttEvent = (unsigned) DB_QueryCOUNT (&Query,"can not get number of students from a list who are registered in an event");
|
||||
NumStdsInAttEvent = (unsigned) DB_QueryCOUNT_old (&Query,"can not get number of students from a list who are registered in an event");
|
||||
}
|
||||
return NumStdsInAttEvent;
|
||||
}
|
||||
|
|
|
@ -355,10 +355,11 @@ En OpenSWAD:
|
|||
ps2pdf source.ps destination.pdf
|
||||
*/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.10.2 (2018-10-30)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.11 (2018-10-30)"
|
||||
#define CSS_FILE "swad18.4.css"
|
||||
#define JS_FILE "swad17.17.1.js"
|
||||
/*
|
||||
Version 18.11: Oct 30, 2018 Joining building and performing query into one function. (235465 lines)
|
||||
Version 18.10.2: Oct 30, 2018 Fixed bugs in access to database. (235414 lines)
|
||||
Version 18.10.1: Oct 30, 2018 Fixed bugs in access to database. (235399 lines)
|
||||
Version 18.10: Oct 30, 2018 Fixing bugs in access to database. Not finished. (235399 lines)
|
||||
|
|
|
@ -3123,12 +3123,31 @@ static void DB_QueryPrintf (char **strp,const char *fmt,...)
|
|||
/******************** Make a SELECT query from database **********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned long DB_QuerySELECT_new (MYSQL_RES **mysql_res,const char *MsgError)
|
||||
unsigned long DB_QuerySELECT (MYSQL_RES **mysql_res,const char *MsgError,
|
||||
const char *fmt,...)
|
||||
{
|
||||
return DB_QuerySELECT (&Gbl.DB.QueryPtr,mysql_res,MsgError);
|
||||
int NumBytesPrinted;
|
||||
va_list ap;
|
||||
char *Query = NULL;
|
||||
|
||||
va_start (ap,fmt);
|
||||
NumBytesPrinted = vasprintf (&Query,fmt,ap);
|
||||
va_end (ap);
|
||||
|
||||
if (NumBytesPrinted < 0) // If memory allocation wasn't possible,
|
||||
// or some other error occurs,
|
||||
// vasprintf will return -1
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
|
||||
return DB_QuerySELECT_old (&Query,mysql_res,MsgError);
|
||||
}
|
||||
|
||||
unsigned long DB_QuerySELECT (char **Query,MYSQL_RES **mysql_res,const char *MsgError)
|
||||
unsigned long DB_QuerySELECT_new (MYSQL_RES **mysql_res,const char *MsgError)
|
||||
{
|
||||
return DB_QuerySELECT_old (&Gbl.DB.QueryPtr,mysql_res,MsgError);
|
||||
}
|
||||
|
||||
unsigned long DB_QuerySELECT_old (char **Query,MYSQL_RES **mysql_res,const char *MsgError)
|
||||
{
|
||||
int Result;
|
||||
|
||||
|
@ -3158,17 +3177,17 @@ unsigned long DB_QuerySELECT (char **Query,MYSQL_RES **mysql_res,const char *Msg
|
|||
|
||||
unsigned long DB_QueryCOUNT_new (const char *MsgError)
|
||||
{
|
||||
return DB_QueryCOUNT (&Gbl.DB.QueryPtr,MsgError);
|
||||
return DB_QueryCOUNT_old (&Gbl.DB.QueryPtr,MsgError);
|
||||
}
|
||||
|
||||
unsigned long DB_QueryCOUNT (char **Query,const char *MsgError)
|
||||
unsigned long DB_QueryCOUNT_old (char **Query,const char *MsgError)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows;
|
||||
|
||||
/***** Make query "SELECT COUNT(*) FROM..." *****/
|
||||
DB_QuerySELECT (Query,&mysql_res,MsgError);
|
||||
DB_QuerySELECT_old (Query,&mysql_res,MsgError);
|
||||
|
||||
/***** Get number of rows *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -3206,7 +3225,7 @@ void DB_QueryINSERT_new (const char *MsgError)
|
|||
/******************** Make an INSERT query in database ***********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void DB_QueryINSERT (char **Query,const char *MsgError)
|
||||
void DB_QueryINSERT_old (char **Query,const char *MsgError)
|
||||
{
|
||||
int Result;
|
||||
|
||||
|
@ -3274,10 +3293,10 @@ void DB_QueryREPLACE_new (const char *MsgError)
|
|||
|
||||
void DB_QueryUPDATE_new (const char *MsgError)
|
||||
{
|
||||
DB_QueryUPDATE (&Gbl.DB.QueryPtr,MsgError);
|
||||
DB_QueryUPDATE_old (&Gbl.DB.QueryPtr,MsgError);
|
||||
}
|
||||
|
||||
void DB_QueryUPDATE (char **Query,const char *MsgError)
|
||||
void DB_QueryUPDATE_old (char **Query,const char *MsgError)
|
||||
{
|
||||
int Result;
|
||||
|
||||
|
|
|
@ -40,21 +40,23 @@ void DB_CloseDBConnection (void);
|
|||
void DB_BuildQuery (const char *fmt,...);
|
||||
void DB_BuildQuery_old (char **Query,const char *fmt,...);
|
||||
|
||||
unsigned long DB_QuerySELECT (MYSQL_RES **mysql_res,const char *MsgError,
|
||||
const char *fmt,...);
|
||||
unsigned long DB_QuerySELECT_new (MYSQL_RES **mysql_res,const char *MsgError);
|
||||
unsigned long DB_QuerySELECT (char **Query,MYSQL_RES **mysql_res,const char *MsgError);
|
||||
unsigned long DB_QuerySELECT_old (char **Query,MYSQL_RES **mysql_res,const char *MsgError);
|
||||
|
||||
unsigned long DB_QueryCOUNT_new (const char *MsgError);
|
||||
unsigned long DB_QueryCOUNT (char **Query,const char *MsgError);
|
||||
unsigned long DB_QueryCOUNT_old (char **Query,const char *MsgError);
|
||||
|
||||
void DB_QueryINSERT_new (const char *MsgError);
|
||||
void DB_QueryINSERT (char **Query,const char *MsgError);
|
||||
void DB_QueryINSERT_old (char **Query,const char *MsgError);
|
||||
|
||||
long DB_QueryINSERTandReturnCode_new (const char *MsgError);
|
||||
|
||||
void DB_QueryREPLACE_new (const char *MsgError);
|
||||
|
||||
void DB_QueryUPDATE_new (const char *MsgError);
|
||||
void DB_QueryUPDATE (char **Query,const char *MsgError);
|
||||
void DB_QueryUPDATE_old (char **Query,const char *MsgError);
|
||||
|
||||
void DB_QueryDELETE_new (const char *MsgError);
|
||||
|
||||
|
|
|
@ -912,7 +912,7 @@ static void Soc_ShowTimeline (char **Query,
|
|||
bool ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||
|
||||
/***** Get publishings from database *****/
|
||||
NumPubsGot = DB_QuerySELECT (Query,&mysql_res,"can not get timeline");
|
||||
NumPubsGot = DB_QuerySELECT_old (Query,&mysql_res,"can not get timeline");
|
||||
|
||||
/***** Start box *****/
|
||||
Box_StartBox (Soc_WIDTH_TIMELINE,Title,Soc_PutIconsTimeline,
|
||||
|
@ -1111,7 +1111,7 @@ static void Soc_InsertNewPubsInTimeline (char **Query)
|
|||
struct SocialNote SocNot;
|
||||
|
||||
/***** Get new publishings timeline from database *****/
|
||||
NumPubsGot = DB_QuerySELECT (Query,&mysql_res,"can not get timeline");
|
||||
NumPubsGot = DB_QuerySELECT_old (Query,&mysql_res,"can not get timeline");
|
||||
|
||||
/***** List new publishings timeline *****/
|
||||
for (NumPub = 0;
|
||||
|
@ -1151,7 +1151,7 @@ static void Soc_ShowOldPubsInTimeline (char **Query)
|
|||
struct SocialNote SocNot;
|
||||
|
||||
/***** Get old publishings timeline from database *****/
|
||||
NumPubsGot = DB_QuerySELECT (Query,&mysql_res,"can not get timeline");
|
||||
NumPubsGot = DB_QuerySELECT_old (Query,&mysql_res,"can not get timeline");
|
||||
|
||||
/***** List old publishings in timeline *****/
|
||||
for (NumPub = 0;
|
||||
|
|
|
@ -349,7 +349,7 @@ void Sta_LogAccess (const char *Comments)
|
|||
Str_Concat (Query,"')",
|
||||
MaxLength);
|
||||
|
||||
DB_QueryINSERT (&Query,"can not log access (comments)");
|
||||
DB_QueryINSERT_old (&Query,"can not log access (comments)");
|
||||
}
|
||||
|
||||
if (Gbl.Search.LogSearch && Gbl.Search.Str[0])
|
||||
|
@ -370,7 +370,7 @@ void Sta_LogAccess (const char *Comments)
|
|||
Str_Concat (Query,"')",
|
||||
MaxLength);
|
||||
|
||||
DB_QueryINSERT (&Query,"can not log access (search)");
|
||||
DB_QueryINSERT_old (&Query,"can not log access (search)");
|
||||
}
|
||||
|
||||
if (Gbl.WebService.IsWebService)
|
||||
|
@ -1484,7 +1484,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
|
|||
Ale_ShowAlert (Ale_INFO,Query);
|
||||
*/
|
||||
/***** Make the query *****/
|
||||
NumRows = DB_QuerySELECT (&Query,&mysql_res,"can not get clicks");
|
||||
NumRows = DB_QuerySELECT_old (&Query,&mysql_res,"can not get clicks");
|
||||
|
||||
/***** Count the number of rows in result *****/
|
||||
if (NumRows == 0)
|
||||
|
|
|
@ -2635,7 +2635,7 @@ static unsigned long Tst_GetQuestions (MYSQL_RES **mysql_res)
|
|||
}
|
||||
|
||||
/* Make the query */
|
||||
NumRows = DB_QuerySELECT (&Query,mysql_res,"can not get questions");
|
||||
NumRows = DB_QuerySELECT_old (&Query,mysql_res,"can not get questions");
|
||||
|
||||
if (NumRows == 0)
|
||||
Ale_ShowAlert (Ale_INFO,Txt_No_questions_found_matching_your_search_criteria);
|
||||
|
@ -2771,7 +2771,7 @@ static unsigned long Tst_GetQuestionsForTest (MYSQL_RES **mysql_res)
|
|||
Lay_ShowAlert (Lay_INFO,Query);
|
||||
*/
|
||||
/* Make the query */
|
||||
return DB_QuerySELECT (&Query,mysql_res,"can not get questions");
|
||||
return DB_QuerySELECT_old (&Query,mysql_res,"can not get questions");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -5104,7 +5104,7 @@ static void Usr_GetListUsrsFromQuery (char **Query,Rol_Role_t Role,Sco_Scope_t S
|
|||
}
|
||||
|
||||
/***** Query database *****/
|
||||
if ((Gbl.Usrs.LstUsrs[Role].NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get list of users")))
|
||||
if ((Gbl.Usrs.LstUsrs[Role].NumUsrs = (unsigned) DB_QuerySELECT_old (Query,&mysql_res,"can not get list of users")))
|
||||
{
|
||||
if (Gbl.Usrs.LstUsrs[Role].NumUsrs > Cfg_MAX_USRS_IN_LIST)
|
||||
{
|
||||
|
|
|
@ -2779,7 +2779,7 @@ int swad__sendAttendanceUsers (struct soap *soap,
|
|||
Str_Concat (Query,")",
|
||||
Length);
|
||||
|
||||
DB_QueryUPDATE (&Query,"can not set other users as absent");
|
||||
DB_QueryUPDATE_old (&Query,"can not set other users as absent");
|
||||
|
||||
/* Clean table att_usr */
|
||||
Att_RemoveUsrsAbsentWithoutCommentsFromAttEvent (Att.AttCod);
|
||||
|
@ -3296,7 +3296,7 @@ int swad__sendMessage (struct soap *soap,
|
|||
if (ReplyUsrCod > 0 || ThereAreNicknames) // There are a recipient to reply or nicknames in "to"
|
||||
{
|
||||
/***** Get users *****/
|
||||
NumRows = DB_QuerySELECT (&Query,&mysql_res,"can not get users");
|
||||
NumRows = DB_QuerySELECT_old (&Query,&mysql_res,"can not get users");
|
||||
|
||||
sendMessageOut->numUsers = (int) NumRows;
|
||||
sendMessageOut->usersArray.__size = (int) NumRows;
|
||||
|
|
Loading…
Reference in New Issue