mirror of
https://github.com/acanas/swad-core.git
synced 2024-06-11 19:25:22 +02:00
Version 18.13.3
This commit is contained in:
parent
e7ba3b873a
commit
aa53ece0ce
63
swad_ID.c
63
swad_ID.c
|
@ -175,8 +175,8 @@ unsigned ID_GetListUsrCodsFromUsrID (struct UsrData *UsrDat,
|
||||||
struct ListUsrCods *ListUsrCods,
|
struct ListUsrCods *ListUsrCods,
|
||||||
bool OnlyConfirmedIDs)
|
bool OnlyConfirmedIDs)
|
||||||
{
|
{
|
||||||
char *Query = NULL;
|
char *SubQueryAllUsrs = NULL;
|
||||||
char SubQuery[256];
|
char SubQueryOneUsr[1 + ID_MAX_BYTES_USR_ID + 1 + 1];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
size_t MaxLength;
|
size_t MaxLength;
|
||||||
|
@ -190,53 +190,54 @@ unsigned ID_GetListUsrCodsFromUsrID (struct UsrData *UsrDat,
|
||||||
if (EncryptedPassword[0])
|
if (EncryptedPassword[0])
|
||||||
CheckPassword = true;
|
CheckPassword = true;
|
||||||
|
|
||||||
/***** Allocate memory for query string *****/
|
/***** Allocate memory for subquery string *****/
|
||||||
MaxLength = 512 + UsrDat->IDs.Num * (1 + ID_MAX_BYTES_USR_ID + 1) - 1;
|
MaxLength = 512 + UsrDat->IDs.Num * (1 + ID_MAX_BYTES_USR_ID + 1) - 1;
|
||||||
if ((Query = (char *) malloc (MaxLength + 1)) == NULL)
|
if ((SubQueryAllUsrs = (char *) malloc (MaxLength + 1)) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
SubQueryAllUsrs[0] = '\0';
|
||||||
|
|
||||||
/***** Get user's code(s) from database *****/
|
/***** Get user's code(s) from database *****/
|
||||||
Str_Copy (Query,CheckPassword ? "SELECT DISTINCT(usr_IDs.UsrCod) FROM usr_IDs,usr_data"
|
|
||||||
" WHERE usr_IDs.UsrID IN (" :
|
|
||||||
"SELECT DISTINCT(UsrCod) FROM usr_IDs"
|
|
||||||
" WHERE UsrID IN (",
|
|
||||||
MaxLength);
|
|
||||||
for (NumID = 0;
|
for (NumID = 0;
|
||||||
NumID < UsrDat->IDs.Num;
|
NumID < UsrDat->IDs.Num;
|
||||||
NumID++)
|
NumID++)
|
||||||
{
|
{
|
||||||
if (NumID)
|
if (NumID)
|
||||||
Str_Concat (Query,",",
|
Str_Concat (SubQueryAllUsrs,",",
|
||||||
MaxLength);
|
MaxLength);
|
||||||
sprintf (SubQuery,"'%s'",UsrDat->IDs.List[NumID].ID);
|
sprintf (SubQueryOneUsr,"'%s'",UsrDat->IDs.List[NumID].ID);
|
||||||
|
|
||||||
Str_Concat (Query,SubQuery,
|
Str_Concat (SubQueryAllUsrs,SubQueryOneUsr,
|
||||||
MaxLength);
|
MaxLength);
|
||||||
}
|
}
|
||||||
Str_Concat (Query,")",
|
|
||||||
MaxLength);
|
|
||||||
|
|
||||||
if (CheckPassword)
|
if (CheckPassword)
|
||||||
{
|
{
|
||||||
if (OnlyConfirmedIDs)
|
|
||||||
Str_Concat (Query," AND usr_IDs.Confirmed='Y'",
|
|
||||||
MaxLength);
|
|
||||||
|
|
||||||
// Get user's code if I have written the correct password
|
// Get user's code if I have written the correct password
|
||||||
// or if password in database is empty (new user)
|
// or if password in database is empty (new user)
|
||||||
sprintf (SubQuery," AND usr_IDs.UsrCod=usr_data.UsrCod"
|
ListUsrCods->NumUsrs =
|
||||||
" AND (usr_data.Password='%s' OR usr_data.Password='')",
|
(unsigned) DB_QuerySELECT (&mysql_res,"can not get user's codes",
|
||||||
EncryptedPassword);
|
"SELECT DISTINCT(usr_IDs.UsrCod) FROM usr_IDs,usr_data"
|
||||||
Str_Concat (Query,SubQuery,
|
" WHERE usr_IDs.UsrID IN (%s)"
|
||||||
MaxLength);
|
"%s"
|
||||||
}
|
" AND usr_IDs.UsrCod=usr_data.UsrCod"
|
||||||
else if (OnlyConfirmedIDs)
|
" AND (usr_data.Password='%s' OR usr_data.Password='')",
|
||||||
Str_Concat (Query," AND Confirmed='Y'",
|
SubQueryAllUsrs,
|
||||||
MaxLength);
|
OnlyConfirmedIDs ? " AND usr_IDs.Confirmed='Y'" :
|
||||||
|
"",
|
||||||
|
EncryptedPassword);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ListUsrCods->NumUsrs =
|
||||||
|
(unsigned) DB_QuerySELECT (&mysql_res,"can not get user's codes",
|
||||||
|
"SELECT DISTINCT(UsrCod) FROM usr_IDs"
|
||||||
|
" WHERE UsrID IN (%s)"
|
||||||
|
"%s",
|
||||||
|
SubQueryAllUsrs,
|
||||||
|
OnlyConfirmedIDs ? " AND Confirmed='Y'" :
|
||||||
|
"");
|
||||||
|
|
||||||
ListUsrCods->NumUsrs =
|
/***** Free memory for subquery string *****/
|
||||||
(unsigned) DB_QuerySELECTusingQueryStr (&Query,&mysql_res,
|
free ((void *) SubQueryAllUsrs);
|
||||||
"can not get user's codes");
|
|
||||||
|
|
||||||
if (ListUsrCods->NumUsrs)
|
if (ListUsrCods->NumUsrs)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2487,6 +2487,9 @@ static unsigned Att_GetNumStdsFromAListWhoAreInAttEvent (long AttCod,long LstSel
|
||||||
" WHERE AttCod=%ld"
|
" WHERE AttCod=%ld"
|
||||||
" AND UsrCod IN (%s) AND Present='Y'",
|
" AND UsrCod IN (%s) AND Present='Y'",
|
||||||
AttCod,SubQueryAllUsrs);
|
AttCod,SubQueryAllUsrs);
|
||||||
|
|
||||||
|
/***** Free memory for subquery string *****/
|
||||||
|
free ((void *) SubQueryAllUsrs);
|
||||||
}
|
}
|
||||||
return NumStdsInAttEvent;
|
return NumStdsInAttEvent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -355,10 +355,11 @@ En OpenSWAD:
|
||||||
ps2pdf source.ps destination.pdf
|
ps2pdf source.ps destination.pdf
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 18.13.2 (2018-11-04)"
|
#define Log_PLATFORM_VERSION "SWAD 18.13.3 (2018-11-04)"
|
||||||
#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.13.3: Nov 04, 2018 Code refactoring related to databse queries. (236562 lines)
|
||||||
Version 18.13.2: Nov 04, 2018 Code refactoring related to databse queries. (236555 lines)
|
Version 18.13.2: Nov 04, 2018 Code refactoring related to databse queries. (236555 lines)
|
||||||
Version 18.13.1: Nov 04, 2018 New database funtion to get number of rows in a table. (236572 lines)
|
Version 18.13.1: Nov 04, 2018 New database funtion to get number of rows in a table. (236572 lines)
|
||||||
Version 18.13: Nov 03, 2018 Joining building and performing query into one function. (236563 lines)
|
Version 18.13: Nov 03, 2018 Joining building and performing query into one function. (236563 lines)
|
||||||
|
|
|
@ -2845,6 +2845,9 @@ int swad__sendAttendanceUsers (struct soap *soap,
|
||||||
" WHERE AttCod=%ld%s",
|
" WHERE AttCod=%ld%s",
|
||||||
Att.AttCod,SubQueryAllUsrs);
|
Att.AttCod,SubQueryAllUsrs);
|
||||||
|
|
||||||
|
/* Free memory for subquery string */
|
||||||
|
free ((void *) SubQueryAllUsrs);
|
||||||
|
|
||||||
/* Clean table att_usr */
|
/* Clean table att_usr */
|
||||||
Att_RemoveUsrsAbsentWithoutCommentsFromAttEvent (Att.AttCod);
|
Att_RemoveUsrsAbsentWithoutCommentsFromAttEvent (Att.AttCod);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user