mirror of https://github.com/acanas/swad-core.git
Version19.112.26
This commit is contained in:
parent
9cfd964da5
commit
4d6c9c7587
137
swad_centre.c
137
swad_centre.c
|
@ -239,7 +239,7 @@ void Ctr_ShowCtrsOfCurrentIns (void)
|
|||
Ctr_GetParamCtrOrder ();
|
||||
|
||||
/***** Get list of centres *****/
|
||||
Ctr_GetListCentres (Gbl.Hierarchy.Ins.InsCod);
|
||||
Ctr_GetFullListOfCentres (Gbl.Hierarchy.Ins.InsCod);
|
||||
|
||||
/***** Write menu to select country and institution *****/
|
||||
Hie_WriteMenuHierarchy ();
|
||||
|
@ -384,7 +384,7 @@ static void Ctr_ListOneCentreForSeeing (struct Centre *Ctr,unsigned NumCtr)
|
|||
|
||||
/***** Number of users who claim to belong to this centre *****/
|
||||
HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor);
|
||||
HTM_Unsigned (Usr_GetNumUsrsWhoClaimToBelongToCtr (Ctr->CtrCod));
|
||||
HTM_Unsigned (Usr_GetNumUsrsWhoClaimToBelongToCtr (Ctr));
|
||||
HTM_TD_End ();
|
||||
|
||||
/***** Place *****/
|
||||
|
@ -472,7 +472,7 @@ static void Ctr_EditCentresInternal (void)
|
|||
|
||||
/***** Get list of centres *****/
|
||||
Gbl.Hierarchy.Ins.Ctrs.SelectedOrder = Ctr_ORDER_BY_CENTRE;
|
||||
Ctr_GetListCentres (Gbl.Hierarchy.Ins.InsCod);
|
||||
Ctr_GetFullListOfCentres (Gbl.Hierarchy.Ins.InsCod);
|
||||
|
||||
/***** Write menu to select country and institution *****/
|
||||
Hie_WriteMenuHierarchy ();
|
||||
|
@ -528,18 +528,11 @@ void Ctr_PutIconToViewCentres (void)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***** Get a list with all the centres or with those of an institution *******/
|
||||
/************ Get basic list of centres ordered by name of centre ************/
|
||||
/*****************************************************************************/
|
||||
// If InsCod <= 0 ==> get all the centres, of any institution
|
||||
// In InsCod > 0 ==> get only the centres of the specified institution
|
||||
|
||||
void Ctr_GetListCentres (long InsCod)
|
||||
void Ctr_GetBasicListOfCentres (long InsCod)
|
||||
{
|
||||
static const char *OrderBySubQuery[Ctr_NUM_ORDERS] =
|
||||
{
|
||||
[Ctr_ORDER_BY_CENTRE ] = "FullName",
|
||||
[Ctr_ORDER_BY_NUM_USRS] = "NumUsrs DESC,FullName",
|
||||
};
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows;
|
||||
|
@ -561,8 +554,100 @@ void Ctr_GetListCentres (long InsCod)
|
|||
"WWW" // row[10]
|
||||
" FROM centres"
|
||||
" WHERE InsCod=%ld"
|
||||
" ORDER BY FullName",
|
||||
InsCod);
|
||||
|
||||
if (NumRows) // Centres found...
|
||||
{
|
||||
// NumRows should be equal to Deg->NumCourses
|
||||
Gbl.Hierarchy.Ins.Ctrs.Num = (unsigned) NumRows;
|
||||
|
||||
/***** Create list with courses in degree *****/
|
||||
if ((Gbl.Hierarchy.Ins.Ctrs.Lst = (struct Centre *) calloc (NumRows,
|
||||
sizeof (struct Centre))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the centres *****/
|
||||
for (NumCtr = 0;
|
||||
NumCtr < Gbl.Hierarchy.Ins.Ctrs.Num;
|
||||
NumCtr++)
|
||||
{
|
||||
Ctr = &(Gbl.Hierarchy.Ins.Ctrs.Lst[NumCtr]);
|
||||
|
||||
/* Get centre data */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
Ctr_GetDataOfCentreFromRow (Ctr,row);
|
||||
|
||||
/* Reset number of users who claim to belong to this centre */
|
||||
Ctr->NumUsrsWhoClaimToBelongToCtr.Valid = false;
|
||||
|
||||
/* Reset other fields */
|
||||
Ctr->Degs.Num = 0;
|
||||
Ctr->Degs.Lst = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
Gbl.Hierarchy.Ins.Ctrs.Num = 0;
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Get full list of centres **************/
|
||||
/************* with number of users who claim to belong to them **************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Ctr_GetFullListOfCentres (long InsCod)
|
||||
{
|
||||
static const char *OrderBySubQuery[Ctr_NUM_ORDERS] =
|
||||
{
|
||||
[Ctr_ORDER_BY_CENTRE ] = "FullName",
|
||||
[Ctr_ORDER_BY_NUM_USRS] = "NumUsrs DESC,FullName",
|
||||
};
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows;
|
||||
unsigned NumCtr;
|
||||
struct Centre *Ctr;
|
||||
|
||||
/***** Get centres from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get centres",
|
||||
"(SELECT centres.CtrCod," // row[ 0]
|
||||
"centres.InsCod," // row[ 1]
|
||||
"centres.PlcCod," // row[ 2]
|
||||
"centres.Status," // row[ 3]
|
||||
"centres.RequesterUsrCod," // row[ 4]
|
||||
"centres.Latitude," // row[ 5]
|
||||
"centres.Longitude," // row[ 6]
|
||||
"centres.Altitude," // row[ 7]
|
||||
"centres.ShortName," // row[ 8]
|
||||
"centres.FullName," // row[ 9]
|
||||
"centres.WWW," // row[10]
|
||||
"COUNT(*) 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"
|
||||
" WHERE InsCod=%ld"
|
||||
" AND CtrCod NOT IN"
|
||||
" (SELECT DISTINCT CtrCod FROM usr_data))"
|
||||
" ORDER BY %s",
|
||||
InsCod,
|
||||
InsCod,InsCod,
|
||||
OrderBySubQuery[Gbl.Hierarchy.Ins.Ctrs.SelectedOrder]);
|
||||
|
||||
if (NumRows) // Centres found...
|
||||
|
@ -585,6 +670,15 @@ void Ctr_GetListCentres (long InsCod)
|
|||
/* Get centre data */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
Ctr_GetDataOfCentreFromRow (Ctr,row);
|
||||
|
||||
/* Get number of users who claim to belong to this centre (row[11]) */
|
||||
Ctr->NumUsrsWhoClaimToBelongToCtr.Valid = false;
|
||||
if (sscanf (row[11],"%u",&(Ctr->NumUsrsWhoClaimToBelongToCtr.NumUsrs)) == 1)
|
||||
Ctr->NumUsrsWhoClaimToBelongToCtr.Valid = true;
|
||||
|
||||
/* Reset other fields */
|
||||
Ctr->Degs.Num = 0;
|
||||
Ctr->Degs.Lst = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -615,6 +709,7 @@ bool Ctr_GetDataOfCentreByCod (struct Centre *Ctr)
|
|||
Ctr->WWW[0] = '\0';
|
||||
Ctr->Degs.Num = 0;
|
||||
Ctr->Degs.Lst = NULL;
|
||||
Ctr->NumUsrsWhoClaimToBelongToCtr.Valid = false;
|
||||
|
||||
/***** Check if centre code is correct *****/
|
||||
if (Ctr->CtrCod > 0)
|
||||
|
@ -874,12 +969,12 @@ static void Ctr_ListCentresForEdition (void)
|
|||
/* Put icon to remove centre */
|
||||
HTM_TR_Begin (NULL);
|
||||
HTM_TD_Begin ("class=\"BM\"");
|
||||
if (!ICanEdit || // I cannot edit
|
||||
NumUsrsInCrssOfCtr) // Centre has users
|
||||
if (!ICanEdit || // I cannot edit
|
||||
NumUsrsInCrssOfCtr) // Centre has users
|
||||
Ico_PutIconRemovalNotAllowed ();
|
||||
else if (Deg_GetNumDegsInCtr (Ctr->CtrCod)) // Centre has degrees
|
||||
else if (Deg_GetNumDegsInCtr (Ctr->CtrCod)) // Centre has degrees
|
||||
Ico_PutIconRemovalNotAllowed ();
|
||||
else if (Usr_GetNumUsrsWhoClaimToBelongToCtr (Ctr->CtrCod)) // Centre has users who claim to belong to it
|
||||
else if (Usr_GetNumUsrsWhoClaimToBelongToCtr (Ctr)) // Centre has users who claim to belong to it
|
||||
Ico_PutIconRemovalNotAllowed ();
|
||||
else // I can remove centre
|
||||
{
|
||||
|
@ -981,7 +1076,7 @@ static void Ctr_ListCentresForEdition (void)
|
|||
|
||||
/* Number of users who claim to belong to this centre */
|
||||
HTM_TD_Begin ("class=\"DAT RM\"");
|
||||
HTM_Unsigned (Usr_GetNumUsrsWhoClaimToBelongToCtr (Ctr->CtrCod));
|
||||
HTM_Unsigned (Usr_GetNumUsrsWhoClaimToBelongToCtr (Ctr));
|
||||
HTM_TD_End ();
|
||||
|
||||
/* Number of degrees */
|
||||
|
@ -1142,14 +1237,14 @@ void Ctr_RemoveCentre (void)
|
|||
Ctr_GetDataOfCentreByCod (Ctr_EditingCtr);
|
||||
|
||||
/***** Check if this centre has teachers *****/
|
||||
if (Deg_GetNumDegsInCtr (Ctr_EditingCtr->CtrCod)) // Centre has degrees
|
||||
if (Deg_GetNumDegsInCtr (Ctr_EditingCtr->CtrCod)) // Centre has degrees
|
||||
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_GetNumUsrsWhoClaimToBelongToCtr (Ctr_EditingCtr)) // Centre has users who claim to belong to it
|
||||
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
|
||||
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
|
||||
|
|
|
@ -72,6 +72,11 @@ struct Centre
|
|||
char FullName[Hie_MAX_BYTES_FULL_NAME + 1];
|
||||
char WWW[Cns_MAX_BYTES_WWW + 1];
|
||||
struct ListDegrees Degs; // List of degrees in this centre
|
||||
struct
|
||||
{
|
||||
bool Valid;
|
||||
unsigned NumUsrs;
|
||||
} NumUsrsWhoClaimToBelongToCtr;
|
||||
};
|
||||
|
||||
#define Ctr_NUM_ORDERS 2
|
||||
|
@ -96,7 +101,8 @@ void Ctr_EditCentres (void);
|
|||
|
||||
void Ctr_PutIconToViewCentres (void);
|
||||
|
||||
void Ctr_GetListCentres (long InsCod);
|
||||
void Ctr_GetBasicListOfCentres (long InsCod);
|
||||
void Ctr_GetFullListOfCentres (long InsCod);
|
||||
bool Ctr_GetDataOfCentreByCod (struct Centre *Ctr);
|
||||
long Ctr_GetInsCodOfCentreByCod (long CtrCod);
|
||||
void Ctr_GetShortNameOfCentreByCod (struct Centre *Ctr);
|
||||
|
|
|
@ -748,7 +748,7 @@ static void CtrCfg_NumUsrs (void)
|
|||
|
||||
/* Data */
|
||||
HTM_TD_Begin ("class=\"DAT LB\"");
|
||||
HTM_Unsigned (Usr_GetNumUsrsWhoClaimToBelongToCtr (Gbl.Hierarchy.Ctr.CtrCod));
|
||||
HTM_Unsigned (Usr_GetNumUsrsWhoClaimToBelongToCtr (&Gbl.Hierarchy.Ctr));
|
||||
HTM_TD_End ();
|
||||
|
||||
HTM_TR_End ();
|
||||
|
|
|
@ -492,7 +492,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
|
|||
En OpenSWAD:
|
||||
ps2pdf source.ps destination.pdf
|
||||
*/
|
||||
#define Log_PLATFORM_VERSION "SWAD 19.112.25 (2020-01-07)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 19.112.26 (2020-01-08)"
|
||||
#define CSS_FILE "swad19.112.css"
|
||||
#define JS_FILE "swad19.91.1.js"
|
||||
/*
|
||||
|
@ -501,6 +501,7 @@ ps2pdf source.ps destination.pdf
|
|||
// TODO: No se puede entrar con DNI '1' suponiendo que no tenga password ¿por qué?
|
||||
// TODO: Mapas más estrechos en móvil
|
||||
|
||||
Version 19.112.26:Jan 08, 2020 Fixed bug in list of centres. (278755 lines)
|
||||
Version 19.112.25:Jan 07, 2020 Changing action descriptions from database to swad-core. Not finished. (278670 lines)
|
||||
Version 19.112.24:Jan 07, 2020 Fixed bug in edition of institutions. (278815 lines)
|
||||
Version 19.112.23:Jan 07, 2020 Optimization in number of centres in an institution. (278807 lines)
|
||||
|
|
|
@ -767,7 +767,7 @@ void Cty_GetBasicListOfCountries (void)
|
|||
Str_Copy (Cty->Name[Gbl.Prefs.Language],row[2],
|
||||
Cty_MAX_BYTES_NAME);
|
||||
|
||||
/* Number of users who claim to belong to country not got */
|
||||
/* Reset number of users who claim to belong to country */
|
||||
Cty->NumUsrsWhoClaimToBelongToCty.Valid = false;
|
||||
|
||||
/* Reset other fields */
|
||||
|
@ -798,6 +798,11 @@ void Cty_GetFullListOfCountries (void)
|
|||
char SubQueryWWW1[Cty_MAX_BYTES_SUBQUERY_CTYS + 1];
|
||||
char SubQueryWWW2[Cty_MAX_BYTES_SUBQUERY_CTYS + 1];
|
||||
char *OrderBySubQuery = NULL;
|
||||
static const char *OrderBySubQueryFmt[Cty_NUM_ORDERS] =
|
||||
{
|
||||
[Cty_ORDER_BY_COUNTRY ] = "Name_%s",
|
||||
[Cty_ORDER_BY_NUM_USRS] = "NumUsrs DESC,Name_%s",
|
||||
};
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows = 0;
|
||||
|
@ -838,21 +843,9 @@ void Cty_GetFullListOfCountries (void)
|
|||
}
|
||||
|
||||
/* Build order subquery */
|
||||
switch (Gbl.Hierarchy.Sys.Ctys.SelectedOrder)
|
||||
{
|
||||
case Cty_ORDER_BY_COUNTRY:
|
||||
if (asprintf (&OrderBySubQuery,"Name_%s",
|
||||
Lan_STR_LANG_ID[Gbl.Prefs.Language]) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
case Cty_ORDER_BY_NUM_USRS:
|
||||
if (asprintf (&OrderBySubQuery,"NumUsrs DESC,Name_%s",
|
||||
Lan_STR_LANG_ID[Gbl.Prefs.Language]) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
default:
|
||||
Lay_WrongOrderExit ();
|
||||
}
|
||||
if (asprintf (&OrderBySubQuery,OrderBySubQueryFmt[Gbl.Hierarchy.Sys.Ctys.SelectedOrder],
|
||||
Lan_STR_LANG_ID[Gbl.Prefs.Language]) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
|
||||
/* Query database */
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get countries",
|
||||
|
@ -912,11 +905,14 @@ void Cty_GetFullListOfCountries (void)
|
|||
}
|
||||
|
||||
/* Get number of users who claim to belong to this country */
|
||||
Cty->NumUsrsWhoClaimToBelongToCty.Valid = false;
|
||||
if (sscanf (row[1 + Lan_NUM_LANGUAGES * 2 + 1],"%u",
|
||||
&(Cty->NumUsrsWhoClaimToBelongToCty.NumUsrs)) == 1)
|
||||
Cty->NumUsrsWhoClaimToBelongToCty.Valid = true;
|
||||
else
|
||||
Cty->NumUsrsWhoClaimToBelongToCty.Valid = false;
|
||||
|
||||
/* Reset other fields */
|
||||
Cty->Inss.Num = 0;
|
||||
Cty->Inss.Lst = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -309,7 +309,7 @@ void Deg_ShowDegsOfCurrentCtr (void)
|
|||
return;
|
||||
|
||||
/***** Get list of centres and degrees *****/
|
||||
Ctr_GetListCentres (Gbl.Hierarchy.Ins.InsCod);
|
||||
Ctr_GetBasicListOfCentres (Gbl.Hierarchy.Ins.InsCod);
|
||||
Deg_GetListDegsInCurrentCtr ();
|
||||
|
||||
/***** Write menu to select country, institution and centre *****/
|
||||
|
|
|
@ -223,7 +223,7 @@ static void DegCfg_Centre (bool PrintView,bool PutForm)
|
|||
if (PutForm)
|
||||
{
|
||||
/* Get list of centres of the current institution */
|
||||
Ctr_GetListCentres (Gbl.Hierarchy.Ins.InsCod);
|
||||
Ctr_GetBasicListOfCentres (Gbl.Hierarchy.Ins.InsCod);
|
||||
|
||||
/* Put form to select centre */
|
||||
Frm_StartForm (ActChgDegCtrCfg);
|
||||
|
|
|
@ -670,7 +670,11 @@ void Ins_GetBasicListOfInstitutions (long CtyCod)
|
|||
|
||||
void Ins_GetFullListOfInstitutions (long CtyCod)
|
||||
{
|
||||
char *OrderBySubQuery = NULL;
|
||||
static const char *OrderBySubQuery[Ins_NUM_ORDERS] =
|
||||
{
|
||||
[Ins_ORDER_BY_INSTITUTION] = "FullName",
|
||||
[Ins_ORDER_BY_NUM_USRS ] = "NumUsrs DESC,FullName",
|
||||
};
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows = 0; // Initialized to avoid warning
|
||||
|
@ -678,19 +682,6 @@ void Ins_GetFullListOfInstitutions (long CtyCod)
|
|||
struct Instit *Ins;
|
||||
|
||||
/***** Get institutions from database *****/
|
||||
/* Build order subquery */
|
||||
switch (Gbl.Hierarchy.Cty.Inss.SelectedOrder)
|
||||
{
|
||||
case Ins_ORDER_BY_INSTITUTION:
|
||||
OrderBySubQuery = "FullName";
|
||||
break;
|
||||
case Ins_ORDER_BY_NUM_USRS:
|
||||
OrderBySubQuery = "NumUsrs DESC,FullName";
|
||||
break;
|
||||
default:
|
||||
Lay_WrongOrderExit ();
|
||||
}
|
||||
|
||||
/* Query database */
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||
"(SELECT institutions.InsCod," // row[0]
|
||||
|
@ -719,7 +710,7 @@ void Ins_GetFullListOfInstitutions (long CtyCod)
|
|||
" AND InsCod NOT IN"
|
||||
" (SELECT DISTINCT InsCod FROM usr_data))"
|
||||
" ORDER BY %s",
|
||||
CtyCod,CtyCod,OrderBySubQuery);
|
||||
CtyCod,CtyCod,OrderBySubQuery[Gbl.Hierarchy.Cty.Inss.SelectedOrder]);
|
||||
|
||||
if (NumRows) // Institutions found...
|
||||
{
|
||||
|
|
|
@ -4029,7 +4029,7 @@ static void Rec_ShowFormMyInsCtrDpt (bool IAmATeacher)
|
|||
/* Get list of centres in this institution */
|
||||
Ctr_FreeListCentres ();
|
||||
if (Gbl.Usrs.Me.UsrDat.InsCod > 0)
|
||||
Ctr_GetListCentres (Gbl.Usrs.Me.UsrDat.InsCod);
|
||||
Ctr_GetBasicListOfCentres (Gbl.Usrs.Me.UsrDat.InsCod);
|
||||
|
||||
/* Begin form to select centre */
|
||||
Frm_StartFormAnchor (ActChgMyCtr,Rec_MY_INS_CTR_DPT_ID);
|
||||
|
|
27
swad_user.c
27
swad_user.c
|
@ -4715,25 +4715,34 @@ void Usr_FlushCacheNumUsrsWhoClaimToBelongToCtr (void)
|
|||
Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.NumUsrs = 0;
|
||||
}
|
||||
|
||||
unsigned Usr_GetNumUsrsWhoClaimToBelongToCtr (long CtrCod)
|
||||
unsigned Usr_GetNumUsrsWhoClaimToBelongToCtr (struct Centre *Ctr)
|
||||
{
|
||||
/***** 1. Fast check: Trivial case *****/
|
||||
if (CtrCod <= 0)
|
||||
if (Ctr->CtrCod <= 0)
|
||||
return 0;
|
||||
|
||||
/***** 2. Fast check: If cached... *****/
|
||||
if (CtrCod == Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.CtrCod)
|
||||
return Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.NumUsrs;
|
||||
/***** 2. Fast check: If already got... *****/
|
||||
if (Ctr->NumUsrsWhoClaimToBelongToCtr.Valid)
|
||||
return Ctr->NumUsrsWhoClaimToBelongToCtr.NumUsrs;
|
||||
|
||||
/***** 3. Slow: number of users who claim to belong to a centre
|
||||
/***** 3. Fast check: If cached... *****/
|
||||
if (Ctr->CtrCod == Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.CtrCod)
|
||||
{
|
||||
Ctr->NumUsrsWhoClaimToBelongToCtr.NumUsrs = Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.NumUsrs;
|
||||
Ctr->NumUsrsWhoClaimToBelongToCtr.Valid = true;
|
||||
return Ctr->NumUsrsWhoClaimToBelongToCtr.NumUsrs;
|
||||
}
|
||||
|
||||
/***** 4. Slow: number of users who claim to belong to a centre
|
||||
from database *****/
|
||||
Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.CtrCod = CtrCod;
|
||||
Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.CtrCod = Ctr->CtrCod;
|
||||
Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.NumUsrs =
|
||||
Ctr->NumUsrsWhoClaimToBelongToCtr.NumUsrs =
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of users",
|
||||
"SELECT COUNT(UsrCod) FROM usr_data"
|
||||
" WHERE CtrCod=%ld",
|
||||
CtrCod);
|
||||
return Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.NumUsrs;
|
||||
Ctr->CtrCod);
|
||||
return Ctr->NumUsrsWhoClaimToBelongToCtr.NumUsrs;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -431,7 +431,7 @@ unsigned Usr_GetNumUsrsWhoClaimToBelongToCty (struct Country *Cty);
|
|||
void Usr_FlushCacheNumUsrsWhoClaimToBelongToIns (void);
|
||||
unsigned Usr_GetNumUsrsWhoClaimToBelongToIns (struct Instit *Ins);
|
||||
void Usr_FlushCacheNumUsrsWhoClaimToBelongToCtr (void);
|
||||
unsigned Usr_GetNumUsrsWhoClaimToBelongToCtr (long CtrCod);
|
||||
unsigned Usr_GetNumUsrsWhoClaimToBelongToCtr (struct Centre *Ctr);
|
||||
unsigned Usr_GetNumberOfTeachersInCentre (long CtrCod);
|
||||
|
||||
void Usr_GetListUsrs (Hie_Level_t Scope,Rol_Role_t Role);
|
||||
|
|
Loading…
Reference in New Issue