mirror of https://github.com/acanas/swad-core.git
Version19.112.6
This commit is contained in:
parent
d2d0bd079a
commit
d664dd1982
145
swad_centre.c
145
swad_centre.c
|
@ -384,7 +384,7 @@ static void Ctr_ListOneCentreForSeeing (struct Centre *Ctr,unsigned NumCtr)
|
||||||
|
|
||||||
/***** Number of users who claim to belong to this centre *****/
|
/***** Number of users who claim to belong to this centre *****/
|
||||||
HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor);
|
HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor);
|
||||||
HTM_Unsigned (Ctr->NumUsrsWhoClaimToBelongToCtr);
|
HTM_Unsigned (Usr_GetNumUsrsWhoClaimToBelongToCtr (Ctr->CtrCod));
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/***** Place *****/
|
/***** Place *****/
|
||||||
|
@ -411,7 +411,7 @@ static void Ctr_ListOneCentreForSeeing (struct Centre *Ctr,unsigned NumCtr)
|
||||||
|
|
||||||
/***** Number of courses *****/
|
/***** Number of courses *****/
|
||||||
HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor);
|
HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor);
|
||||||
HTM_Unsigned (Ctr->NumCrss);
|
HTM_Unsigned (Crs_GetNumCrssInCtr (Ctr->CtrCod));
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/***** Number of users in courses of this centre *****/
|
/***** Number of users in courses of this centre *****/
|
||||||
|
@ -548,43 +548,21 @@ void Ctr_GetListCentres (long InsCod)
|
||||||
|
|
||||||
/***** Get centres from database *****/
|
/***** Get centres from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get centres",
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get centres",
|
||||||
"(SELECT centres.CtrCod," // row[ 0]
|
"SELECT CtrCod," // row[ 0]
|
||||||
"centres.InsCod," // row[ 1]
|
"InsCod," // row[ 1]
|
||||||
"centres.PlcCod," // row[ 2]
|
"PlcCod," // row[ 2]
|
||||||
"centres.Status," // row[ 3]
|
"Status," // row[ 3]
|
||||||
"centres.RequesterUsrCod," // row[ 4]
|
"RequesterUsrCod," // row[ 4]
|
||||||
"centres.Latitude," // row[ 5]
|
"Latitude," // row[ 5]
|
||||||
"centres.Longitude," // row[ 6]
|
"Longitude," // row[ 6]
|
||||||
"centres.Altitude," // row[ 7]
|
"Altitude," // row[ 7]
|
||||||
"centres.ShortName," // row[ 8]
|
"ShortName," // row[ 8]
|
||||||
"centres.FullName," // row[ 9]
|
"FullName," // row[ 9]
|
||||||
"centres.WWW," // row[10]
|
"WWW" // row[10]
|
||||||
"COUNT(DISTINCT usr_data.UsrCod)"
|
|
||||||
" AS NumUsrs" // row[11]
|
|
||||||
" FROM centres,usr_data"
|
|
||||||
" WHERE centres.InsCod=%ld"
|
|
||||||
" AND centres.CtrCod=usr_data.CtrCod"
|
|
||||||
" GROUP BY centres.CtrCod)"
|
|
||||||
" UNION "
|
|
||||||
"(SELECT CtrCod," // row[ 0]
|
|
||||||
"InsCod," // row[ 1]
|
|
||||||
"PlcCod," // row[ 2]
|
|
||||||
"Status," // row[ 3]
|
|
||||||
"RequesterUsrCod," // row[ 4]
|
|
||||||
"Latitude," // row[ 5]
|
|
||||||
"Longitude," // row[ 6]
|
|
||||||
"Altitude," // row[ 7]
|
|
||||||
"ShortName," // row[ 8]
|
|
||||||
"FullName," // row[ 9]
|
|
||||||
"WWW," // row[10]
|
|
||||||
"0 AS NumUsrs" // row[11]
|
|
||||||
" FROM centres"
|
" FROM centres"
|
||||||
" WHERE centres.InsCod=%ld"
|
" WHERE InsCod=%ld"
|
||||||
" AND CtrCod NOT IN"
|
|
||||||
" (SELECT DISTINCT CtrCod FROM usr_data))"
|
|
||||||
" ORDER BY %s",
|
" ORDER BY %s",
|
||||||
InsCod,
|
InsCod,
|
||||||
InsCod,
|
|
||||||
OrderBySubQuery[Gbl.Hierarchy.Ins.Ctrs.SelectedOrder]);
|
OrderBySubQuery[Gbl.Hierarchy.Ins.Ctrs.SelectedOrder]);
|
||||||
|
|
||||||
if (NumRows) // Centres found...
|
if (NumRows) // Centres found...
|
||||||
|
@ -610,9 +588,6 @@ void Ctr_GetListCentres (long InsCod)
|
||||||
|
|
||||||
/* Get number of degrees in this centre */
|
/* Get number of degrees in this centre */
|
||||||
Ctr->Degs.Num = Deg_GetNumDegsInCtr (Ctr->CtrCod);
|
Ctr->Degs.Num = Deg_GetNumDegsInCtr (Ctr->CtrCod);
|
||||||
|
|
||||||
/* Get number of courses in this centre */
|
|
||||||
Ctr->NumCrss = Crs_GetNumCrssInCtr (Ctr->CtrCod);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -642,50 +617,26 @@ bool Ctr_GetDataOfCentreByCod (struct Centre *Ctr,
|
||||||
Ctr->ShrtName[0] = '\0';
|
Ctr->ShrtName[0] = '\0';
|
||||||
Ctr->FullName[0] = '\0';
|
Ctr->FullName[0] = '\0';
|
||||||
Ctr->WWW[0] = '\0';
|
Ctr->WWW[0] = '\0';
|
||||||
Ctr->NumUsrsWhoClaimToBelongToCtr = 0;
|
Ctr->Degs.Num = 0;
|
||||||
Ctr->Degs.Num =
|
|
||||||
Ctr->NumCrss = 0;
|
|
||||||
|
|
||||||
/***** Check if centre code is correct *****/
|
/***** Check if centre code is correct *****/
|
||||||
if (Ctr->CtrCod > 0)
|
if (Ctr->CtrCod > 0)
|
||||||
{
|
{
|
||||||
/***** Get data of a centre from database *****/
|
/***** Get data of a centre from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get data of a centre",
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get data of a centre",
|
||||||
"(SELECT centres.CtrCod," // row[ 0]
|
"SELECT CtrCod," // row[ 0]
|
||||||
"centres.InsCod," // row[ 1]
|
"InsCod," // row[ 1]
|
||||||
"centres.PlcCod," // row[ 2]
|
"PlcCod," // row[ 2]
|
||||||
"centres.Status," // row[ 3]
|
"Status," // row[ 3]
|
||||||
"centres.RequesterUsrCod," // row[ 4]
|
"RequesterUsrCod," // row[ 4]
|
||||||
"centres.Latitude," // row[ 5]
|
"Latitude," // row[ 5]
|
||||||
"centres.Longitude," // row[ 6]
|
"Longitude," // row[ 6]
|
||||||
"centres.Altitude," // row[ 7]
|
"Altitude," // row[ 7]
|
||||||
"centres.ShortName," // row[ 8]
|
"ShortName," // row[ 8]
|
||||||
"centres.FullName," // row[ 9]
|
"FullName," // row[ 9]
|
||||||
"centres.WWW," // row[10]
|
"WWW" // row[10]
|
||||||
"COUNT(DISTINCT usr_data.UsrCod)"
|
|
||||||
" AS NumUsrs" // row[11]
|
|
||||||
" FROM centres,usr_data"
|
|
||||||
" WHERE centres.CtrCod=%ld"
|
|
||||||
" AND centres.CtrCod=usr_data.CtrCod"
|
|
||||||
" GROUP BY centres.CtrCod)"
|
|
||||||
" UNION "
|
|
||||||
"(SELECT CtrCod," // row[ 0]
|
|
||||||
"InsCod," // row[ 1]
|
|
||||||
"PlcCod," // row[ 2]
|
|
||||||
"Status," // row[ 3]
|
|
||||||
"RequesterUsrCod," // row[ 4]
|
|
||||||
"Latitude," // row[ 5]
|
|
||||||
"Longitude," // row[ 6]
|
|
||||||
"Altitude," // row[ 7]
|
|
||||||
"ShortName," // row[ 8]
|
|
||||||
"FullName," // row[ 9]
|
|
||||||
"WWW," // row[10]
|
|
||||||
"0 AS NumUsrs" // row[11]
|
|
||||||
" FROM centres"
|
" FROM centres"
|
||||||
" WHERE CtrCod=%ld"
|
" WHERE CtrCod=%ld",
|
||||||
" AND CtrCod NOT IN"
|
|
||||||
" (SELECT DISTINCT CtrCod FROM usr_data))",
|
|
||||||
Ctr->CtrCod,
|
|
||||||
Ctr->CtrCod);
|
Ctr->CtrCod);
|
||||||
if (NumRows) // Centre found...
|
if (NumRows) // Centre found...
|
||||||
{
|
{
|
||||||
|
@ -695,14 +646,9 @@ bool Ctr_GetDataOfCentreByCod (struct Centre *Ctr,
|
||||||
|
|
||||||
/* Get extra data */
|
/* Get extra data */
|
||||||
if (GetExtraData == Ctr_GET_EXTRA_DATA)
|
if (GetExtraData == Ctr_GET_EXTRA_DATA)
|
||||||
{
|
|
||||||
/* Get number of degrees in this centre */
|
/* Get number of degrees in this centre */
|
||||||
Ctr->Degs.Num = Deg_GetNumDegsInCtr (Ctr->CtrCod);
|
Ctr->Degs.Num = Deg_GetNumDegsInCtr (Ctr->CtrCod);
|
||||||
|
|
||||||
/* Get number of courses in this centre */
|
|
||||||
Ctr->NumCrss = Crs_GetNumCrssInCtr (Ctr->CtrCod);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set return value */
|
/* Set return value */
|
||||||
CtrFound = true;
|
CtrFound = true;
|
||||||
}
|
}
|
||||||
|
@ -757,10 +703,6 @@ static void Ctr_GetDataOfCentreFromRow (struct Centre *Ctr,MYSQL_ROW row)
|
||||||
/***** Get the URL of the centre (row[10]) *****/
|
/***** Get the URL of the centre (row[10]) *****/
|
||||||
Str_Copy (Ctr->WWW,row[10],
|
Str_Copy (Ctr->WWW,row[10],
|
||||||
Cns_MAX_BYTES_WWW);
|
Cns_MAX_BYTES_WWW);
|
||||||
|
|
||||||
/***** Get number of users who claim to belong to this centre (row[11]) *****/
|
|
||||||
if (sscanf (row[11],"%u",&Ctr->NumUsrsWhoClaimToBelongToCtr) != 1)
|
|
||||||
Ctr->NumUsrsWhoClaimToBelongToCtr = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -940,14 +882,14 @@ static void Ctr_ListCentresForEdition (void)
|
||||||
HTM_TD_Begin ("class=\"BM\"");
|
HTM_TD_Begin ("class=\"BM\"");
|
||||||
if (!ICanEdit)
|
if (!ICanEdit)
|
||||||
Ico_PutIconRemovalNotAllowed ();
|
Ico_PutIconRemovalNotAllowed ();
|
||||||
else if (Ctr->Degs.Num) // Centre has degrees
|
else if (Ctr->Degs.Num) // Centre has degrees
|
||||||
Ico_PutIconRemovalNotAllowed ();
|
Ico_PutIconRemovalNotAllowed ();
|
||||||
else if (Ctr->NumUsrsWhoClaimToBelongToCtr) // Centre has users who claim to belong to it
|
else if (Usr_GetNumUsrsWhoClaimToBelongToCtr (Ctr->CtrCod)) // Centre has users who claim to belong to it
|
||||||
Ico_PutIconRemovalNotAllowed ();
|
Ico_PutIconRemovalNotAllowed ();
|
||||||
else if (Usr_GetNumUsrsInCrssOfCtr (Rol_UNK, // Here Rol_UNK means "all users"
|
else if (Usr_GetNumUsrsInCrssOfCtr (Rol_UNK, // Here Rol_UNK means "all users"
|
||||||
Ctr->CtrCod)) // Centre has users
|
Ctr->CtrCod)) // Centre has users
|
||||||
Ico_PutIconRemovalNotAllowed ();
|
Ico_PutIconRemovalNotAllowed ();
|
||||||
else // I can remove centre
|
else // I can remove centre
|
||||||
{
|
{
|
||||||
Frm_StartForm (ActRemCtr);
|
Frm_StartForm (ActRemCtr);
|
||||||
Ctr_PutParamOtherCtrCod (Ctr->CtrCod);
|
Ctr_PutParamOtherCtrCod (Ctr->CtrCod);
|
||||||
|
@ -1047,7 +989,7 @@ static void Ctr_ListCentresForEdition (void)
|
||||||
|
|
||||||
/* Number of users who claim to belong to this centre */
|
/* Number of users who claim to belong to this centre */
|
||||||
HTM_TD_Begin ("class=\"DAT RM\"");
|
HTM_TD_Begin ("class=\"DAT RM\"");
|
||||||
HTM_Unsigned (Ctr->NumUsrsWhoClaimToBelongToCtr);
|
HTM_Unsigned (Usr_GetNumUsrsWhoClaimToBelongToCtr (Ctr->CtrCod));
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/* Number of degrees */
|
/* Number of degrees */
|
||||||
|
@ -1209,13 +1151,16 @@ void Ctr_RemoveCentre (void)
|
||||||
Ctr_GetDataOfCentreByCod (Ctr_EditingCtr,Ctr_GET_EXTRA_DATA);
|
Ctr_GetDataOfCentreByCod (Ctr_EditingCtr,Ctr_GET_EXTRA_DATA);
|
||||||
|
|
||||||
/***** Check if this centre has teachers *****/
|
/***** Check if this centre has teachers *****/
|
||||||
if (Ctr_EditingCtr->Degs.Num) // Centre has degrees
|
if (Ctr_EditingCtr->Degs.Num) // Centre has degrees
|
||||||
Ale_ShowAlert (Ale_WARNING,Txt_To_remove_a_centre_you_must_first_remove_all_degrees_and_teachers_in_the_centre);
|
Ale_ShowAlert (Ale_WARNING,
|
||||||
else if (Ctr_EditingCtr->NumUsrsWhoClaimToBelongToCtr) // Centre has users who claim to belong to it
|
Txt_To_remove_a_centre_you_must_first_remove_all_degrees_and_teachers_in_the_centre);
|
||||||
Ale_ShowAlert (Ale_WARNING,Txt_To_remove_a_centre_you_must_first_remove_all_degrees_and_teachers_in_the_centre);
|
else if (Usr_GetNumUsrsWhoClaimToBelongToCtr (Ctr_EditingCtr->CtrCod)) // Centre has users who claim to belong to it
|
||||||
else if (Usr_GetNumUsrsInCrssOfCtr (Rol_UNK, // Here Rol_UNK means "all users"
|
Ale_ShowAlert (Ale_WARNING,
|
||||||
Ctr_EditingCtr->CtrCod)) // Centre has users
|
Txt_To_remove_a_centre_you_must_first_remove_all_degrees_and_teachers_in_the_centre);
|
||||||
Ale_ShowAlert (Ale_WARNING,Txt_To_remove_a_centre_you_must_first_remove_all_degrees_and_teachers_in_the_centre);
|
else if (Usr_GetNumUsrsInCrssOfCtr (Rol_UNK, // Here Rol_UNK means "all users"
|
||||||
|
Ctr_EditingCtr->CtrCod)) // Centre has users
|
||||||
|
Ale_ShowAlert (Ale_WARNING,
|
||||||
|
Txt_To_remove_a_centre_you_must_first_remove_all_degrees_and_teachers_in_the_centre);
|
||||||
else // Centre has no degrees or users ==> remove it
|
else // Centre has no degrees or users ==> remove it
|
||||||
{
|
{
|
||||||
/***** Remove all the threads and posts in forums of the centre *****/
|
/***** Remove all the threads and posts in forums of the centre *****/
|
||||||
|
@ -1244,7 +1189,9 @@ void Ctr_RemoveCentre (void)
|
||||||
Ctr_EditingCtr->CtrCod);
|
Ctr_EditingCtr->CtrCod);
|
||||||
|
|
||||||
/***** Flush caches *****/
|
/***** Flush caches *****/
|
||||||
Ctr_FlushCacheNumUsrsInCrssOfCtr ();
|
Crs_FlushCacheNumCrssInCtr ();
|
||||||
|
Usr_FlushCacheNumUsrsWhoClaimToBelongToCtr ();
|
||||||
|
Usr_FlushCacheNumUsrsInCrssOfCtr ();
|
||||||
|
|
||||||
/***** Write message to show the change made *****/
|
/***** Write message to show the change made *****/
|
||||||
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
||||||
|
@ -2056,8 +2003,6 @@ static void Ctr_EditingCentreConstructor (void)
|
||||||
Ctr_EditingCtr->WWW[0] = '\0';
|
Ctr_EditingCtr->WWW[0] = '\0';
|
||||||
Ctr_EditingCtr->Degs.Num = 0;
|
Ctr_EditingCtr->Degs.Num = 0;
|
||||||
Ctr_EditingCtr->Degs.Lst = NULL;
|
Ctr_EditingCtr->Degs.Lst = NULL;
|
||||||
Ctr_EditingCtr->NumCrss = 0;
|
|
||||||
Ctr_EditingCtr->NumUsrsWhoClaimToBelongToCtr = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Ctr_EditingCentreDestructor (void)
|
static void Ctr_EditingCentreDestructor (void)
|
||||||
|
|
|
@ -72,8 +72,6 @@ struct Centre
|
||||||
char FullName[Hie_MAX_BYTES_FULL_NAME + 1];
|
char FullName[Hie_MAX_BYTES_FULL_NAME + 1];
|
||||||
char WWW[Cns_MAX_BYTES_WWW + 1];
|
char WWW[Cns_MAX_BYTES_WWW + 1];
|
||||||
struct ListDegrees Degs; // List of degrees in this centre
|
struct ListDegrees Degs; // List of degrees in this centre
|
||||||
unsigned NumCrss; // Number of courses in this centre
|
|
||||||
unsigned NumUsrsWhoClaimToBelongToCtr; // Number of users who claim to belong in this centre
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define Ctr_NUM_ORDERS 2
|
#define Ctr_NUM_ORDERS 2
|
||||||
|
|
|
@ -492,7 +492,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
|
||||||
En OpenSWAD:
|
En OpenSWAD:
|
||||||
ps2pdf source.ps destination.pdf
|
ps2pdf source.ps destination.pdf
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 19.112.4 (2020-01-05)"
|
#define Log_PLATFORM_VERSION "SWAD 19.112.6 (2020-01-05)"
|
||||||
#define CSS_FILE "swad19.112.css"
|
#define CSS_FILE "swad19.112.css"
|
||||||
#define JS_FILE "swad19.91.1.js"
|
#define JS_FILE "swad19.91.1.js"
|
||||||
/*
|
/*
|
||||||
|
@ -501,6 +501,8 @@ ps2pdf source.ps destination.pdf
|
||||||
// TODO: No se puede entrar con DNI '1' suponiendo que no tenga password ¿por qué?
|
// TODO: No se puede entrar con DNI '1' suponiendo que no tenga password ¿por qué?
|
||||||
// TODO: Mapas más estrechos en móvil
|
// TODO: Mapas más estrechos en móvil
|
||||||
|
|
||||||
|
Version 19.112.6: Jan 05, 2020 Optimization in number of courses in a centre. (278374 lines)
|
||||||
|
Version 19.112.5: Jan 05, 2020 Optimization in number of users who claim to belong to a centre. (278361 lines)
|
||||||
Version 19.112.4: Jan 05, 2020 Optimization in number of users in courses of a centre. (278385 lines)
|
Version 19.112.4: Jan 05, 2020 Optimization in number of users in courses of a centre. (278385 lines)
|
||||||
Version 19.112.3: Jan 04, 2020 Fixed bug in hierarchy. (278357 lines)
|
Version 19.112.3: Jan 04, 2020 Fixed bug in hierarchy. (278357 lines)
|
||||||
Version 19.112.2: Jan 04, 2020 Changing action descriptions from database to swad-core. Not finished. (278351 lines)
|
Version 19.112.2: Jan 04, 2020 Changing action descriptions from database to swad-core. Not finished. (278351 lines)
|
||||||
|
|
|
@ -444,15 +444,31 @@ unsigned Crs_GetNumCrssInIns (long InsCod)
|
||||||
/******************** Get number of courses in a centre **********************/
|
/******************** Get number of courses in a centre **********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Crs_FlushCacheNumCrssInCtr (void)
|
||||||
|
{
|
||||||
|
Gbl.Cache.NumCrssInCtr.CtrCod = -1L;
|
||||||
|
Gbl.Cache.NumCrssInCtr.NumCrss = 0;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned Crs_GetNumCrssInCtr (long CtrCod)
|
unsigned Crs_GetNumCrssInCtr (long CtrCod)
|
||||||
{
|
{
|
||||||
/***** Get number of courses in a degree from database *****/
|
/***** 1. Fast check: Trivial case *****/
|
||||||
return
|
if (CtrCod <= 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/***** 2. Fast check: If cached... *****/
|
||||||
|
if (CtrCod == Gbl.Cache.NumCrssInCtr.CtrCod)
|
||||||
|
return Gbl.Cache.NumCrssInCtr.NumCrss;
|
||||||
|
|
||||||
|
/***** 3. Slow: number of courses in a centre from database *****/
|
||||||
|
Gbl.Cache.NumCrssInCtr.CtrCod = CtrCod;
|
||||||
|
Gbl.Cache.NumCrssInCtr.NumCrss =
|
||||||
(unsigned) DB_QueryCOUNT ("can not get the number of courses in a centre",
|
(unsigned) DB_QueryCOUNT ("can not get the number of courses in a centre",
|
||||||
"SELECT COUNT(*) FROM degrees,courses"
|
"SELECT COUNT(*) FROM degrees,courses"
|
||||||
" WHERE degrees.CtrCod=%ld"
|
" WHERE degrees.CtrCod=%ld"
|
||||||
" AND degrees.DegCod=courses.DegCod",
|
" AND degrees.DegCod=courses.DegCod",
|
||||||
CtrCod);
|
CtrCod);
|
||||||
|
return Gbl.Cache.NumCrssInCtr.NumCrss;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -103,6 +103,7 @@ void Crs_ShowIntroduction (void);
|
||||||
unsigned Crs_GetNumCrssTotal (void);
|
unsigned Crs_GetNumCrssTotal (void);
|
||||||
unsigned Crs_GetNumCrssInCty (long CtyCod);
|
unsigned Crs_GetNumCrssInCty (long CtyCod);
|
||||||
unsigned Crs_GetNumCrssInIns (long InsCod);
|
unsigned Crs_GetNumCrssInIns (long InsCod);
|
||||||
|
void Crs_FlushCacheNumCrssInCtr (void);
|
||||||
unsigned Crs_GetNumCrssInCtr (long CtrCod);
|
unsigned Crs_GetNumCrssInCtr (long CtrCod);
|
||||||
unsigned Crs_GetNumCrssInDeg (long DegCod);
|
unsigned Crs_GetNumCrssInDeg (long DegCod);
|
||||||
unsigned Crs_GetNumCrssWithUsrs (Rol_Role_t Role,const char *SubQuery);
|
unsigned Crs_GetNumCrssWithUsrs (Rol_Role_t Role,const char *SubQuery);
|
||||||
|
|
|
@ -412,7 +412,9 @@ void Gbl_InitializeGlobals (void)
|
||||||
Cty_FlushCacheCountryName ();
|
Cty_FlushCacheCountryName ();
|
||||||
Ins_FlushCacheShortNameOfInstitution ();
|
Ins_FlushCacheShortNameOfInstitution ();
|
||||||
Ins_FlushCacheFullNameAndCtyOfInstitution ();
|
Ins_FlushCacheFullNameAndCtyOfInstitution ();
|
||||||
Ctr_FlushCacheNumUsrsInCrssOfCtr ();
|
Crs_FlushCacheNumCrssInCtr ();
|
||||||
|
Usr_FlushCacheNumUsrsWhoClaimToBelongToCtr ();
|
||||||
|
Usr_FlushCacheNumUsrsInCrssOfCtr ();
|
||||||
Usr_FlushCacheUsrIsSuperuser ();
|
Usr_FlushCacheUsrIsSuperuser ();
|
||||||
Usr_FlushCacheUsrBelongsToIns ();
|
Usr_FlushCacheUsrBelongsToIns ();
|
||||||
Usr_FlushCacheUsrBelongsToCtr ();
|
Usr_FlushCacheUsrBelongsToCtr ();
|
||||||
|
|
|
@ -772,6 +772,16 @@ struct Globals
|
||||||
char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1];
|
char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1];
|
||||||
char CtyName[Hie_MAX_BYTES_FULL_NAME + 1];
|
char CtyName[Hie_MAX_BYTES_FULL_NAME + 1];
|
||||||
} InstitutionShrtNameAndCty;
|
} InstitutionShrtNameAndCty;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
long CtrCod;
|
||||||
|
unsigned NumCrss;
|
||||||
|
} NumCrssInCtr;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
long CtrCod;
|
||||||
|
unsigned NumUsrs;
|
||||||
|
} NumUsrsWhoClaimToBelongToCtr;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
Rol_Role_t Role;
|
Rol_Role_t Role;
|
||||||
|
|
23
swad_user.c
23
swad_user.c
|
@ -4200,7 +4200,7 @@ unsigned Usr_GetNumUsrsInCrssOfDeg (Rol_Role_t Role,long DegCod)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// Here Rol_UNK means any user (students, non-editing teachers or teachers)
|
// Here Rol_UNK means any user (students, non-editing teachers or teachers)
|
||||||
|
|
||||||
void Ctr_FlushCacheNumUsrsInCrssOfCtr (void)
|
void Usr_FlushCacheNumUsrsInCrssOfCtr (void)
|
||||||
{
|
{
|
||||||
Gbl.Cache.NumUsrsInCrssOfCtr.Role = Rol_UNK;
|
Gbl.Cache.NumUsrsInCrssOfCtr.Role = Rol_UNK;
|
||||||
Gbl.Cache.NumUsrsInCrssOfCtr.CtrCod = -1L;
|
Gbl.Cache.NumUsrsInCrssOfCtr.CtrCod = -1L;
|
||||||
|
@ -4440,14 +4440,31 @@ unsigned Usr_GetNumUsrsWhoClaimToBelongToIns (long InsCod)
|
||||||
/*********** Get number of users who claim to belong to a centre *************/
|
/*********** Get number of users who claim to belong to a centre *************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Usr_FlushCacheNumUsrsWhoClaimToBelongToCtr (void)
|
||||||
|
{
|
||||||
|
Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.CtrCod = -1L;
|
||||||
|
Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.NumUsrs = 0;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned Usr_GetNumUsrsWhoClaimToBelongToCtr (long CtrCod)
|
unsigned Usr_GetNumUsrsWhoClaimToBelongToCtr (long CtrCod)
|
||||||
{
|
{
|
||||||
/***** Get the number of users in a centre from database *****/
|
/***** 1. Fast check: Trivial case *****/
|
||||||
return
|
if (CtrCod <= 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/***** 2. Fast check: If cached... *****/
|
||||||
|
if (CtrCod == Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.CtrCod)
|
||||||
|
return Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.NumUsrs;
|
||||||
|
|
||||||
|
/***** 3. Slow: number of users who claim to belong to a centre
|
||||||
|
from database *****/
|
||||||
|
Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.CtrCod = CtrCod;
|
||||||
|
Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.NumUsrs =
|
||||||
(unsigned) DB_QueryCOUNT ("can not get the number of users in a centre",
|
(unsigned) DB_QueryCOUNT ("can not get the number of users in a centre",
|
||||||
"SELECT COUNT(UsrCod) FROM usr_data"
|
"SELECT COUNT(UsrCod) FROM usr_data"
|
||||||
" WHERE CtrCod=%ld",
|
" WHERE CtrCod=%ld",
|
||||||
CtrCod);
|
CtrCod);
|
||||||
|
return Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.NumUsrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -409,7 +409,7 @@ void Usr_WriteRowUsrMainData (unsigned NumUsr,struct UsrData *UsrDat,
|
||||||
|
|
||||||
unsigned Usr_GetNumUsrsInCrs (Rol_Role_t Role,long CrsCod);
|
unsigned Usr_GetNumUsrsInCrs (Rol_Role_t Role,long CrsCod);
|
||||||
unsigned Usr_GetNumUsrsInCrssOfDeg (Rol_Role_t Role,long DegCod);
|
unsigned Usr_GetNumUsrsInCrssOfDeg (Rol_Role_t Role,long DegCod);
|
||||||
void Ctr_FlushCacheNumUsrsInCrssOfCtr (void);
|
void Usr_FlushCacheNumUsrsInCrssOfCtr (void);
|
||||||
unsigned Usr_GetNumUsrsInCrssOfCtr (Rol_Role_t Role,long CtrCod);
|
unsigned Usr_GetNumUsrsInCrssOfCtr (Rol_Role_t Role,long CtrCod);
|
||||||
unsigned Usr_GetNumUsrsInCrssOfIns (Rol_Role_t Role,long InsCod);
|
unsigned Usr_GetNumUsrsInCrssOfIns (Rol_Role_t Role,long InsCod);
|
||||||
unsigned Usr_GetNumUsrsInCrssOfCty (Rol_Role_t Role,long CtyCod);
|
unsigned Usr_GetNumUsrsInCrssOfCty (Rol_Role_t Role,long CtyCod);
|
||||||
|
@ -420,6 +420,7 @@ long Usr_GetRamdomStdFromGrp (long GrpCod);
|
||||||
unsigned Usr_GetNumTchsCurrentInsInDepartment (long DptCod);
|
unsigned Usr_GetNumTchsCurrentInsInDepartment (long DptCod);
|
||||||
unsigned Usr_GetNumUsrsWhoClaimToBelongToCty (long CtyCod);
|
unsigned Usr_GetNumUsrsWhoClaimToBelongToCty (long CtyCod);
|
||||||
unsigned Usr_GetNumUsrsWhoClaimToBelongToIns (long InsCod);
|
unsigned Usr_GetNumUsrsWhoClaimToBelongToIns (long InsCod);
|
||||||
|
void Usr_FlushCacheNumUsrsWhoClaimToBelongToCtr (void);
|
||||||
unsigned Usr_GetNumUsrsWhoClaimToBelongToCtr (long CtrCod);
|
unsigned Usr_GetNumUsrsWhoClaimToBelongToCtr (long CtrCod);
|
||||||
unsigned Usr_GetNumberOfTeachersInCentre (long CtrCod);
|
unsigned Usr_GetNumberOfTeachersInCentre (long CtrCod);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue