mirror of
https://github.com/acanas/swad-core.git
synced 2024-06-18 14:35:46 +02:00
Version 18.8.18
This commit is contained in:
parent
e2472291d3
commit
69f57ed8fb
|
@ -355,10 +355,11 @@ En OpenSWAD:
|
||||||
ps2pdf source.ps destination.pdf
|
ps2pdf source.ps destination.pdf
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 18.8.17 (2018-10-28)"
|
#define Log_PLATFORM_VERSION "SWAD 18.8.18 (2018-10-28)"
|
||||||
#define CSS_FILE "swad18.4.css"
|
#define CSS_FILE "swad18.4.css"
|
||||||
#define JS_FILE "swad17.17.1.js"
|
#define JS_FILE "swad17.17.1.js"
|
||||||
/*
|
/*
|
||||||
|
Version 18.8.18: Oct 28, 2018 Some asprintf for database queries changed by internal function. (236105 lines)
|
||||||
Version 18.8.17: Oct 28, 2018 Some asprintf for database queries changed by internal function. (236116 lines)
|
Version 18.8.17: Oct 28, 2018 Some asprintf for database queries changed by internal function. (236116 lines)
|
||||||
Version 18.8.16: Oct 28, 2018 Some asprintf for database queries changed by internal function. (236263 lines)
|
Version 18.8.16: Oct 28, 2018 Some asprintf for database queries changed by internal function. (236263 lines)
|
||||||
Version 18.8.15: Oct 28, 2018 Some asprintf for database queries changed by internal function. (236425 lines)
|
Version 18.8.15: Oct 28, 2018 Some asprintf for database queries changed by internal function. (236425 lines)
|
||||||
|
|
|
@ -3342,13 +3342,19 @@ void DB_QueryDELETE (const char *Query,const char *MsgError)
|
||||||
/**************** Make other kind of query from database *********************/
|
/**************** Make other kind of query from database *********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void DB_Query_free (const char *Query,const char *MsgError)
|
void DB_Query_new (const char *MsgError)
|
||||||
{
|
{
|
||||||
int Result;
|
int Result;
|
||||||
|
|
||||||
/***** Query database *****/
|
/***** Check that query string pointer
|
||||||
Result = mysql_query (&Gbl.mysql,Query); // Returns 0 on success
|
does not point to an allocated string *****/
|
||||||
free ((void *) Query);
|
if (Gbl.DB.QueryPtr == NULL)
|
||||||
|
Lay_ShowErrorAndExit ("Wrong query string.");
|
||||||
|
|
||||||
|
/***** Query database and free query string pointer *****/
|
||||||
|
Result = mysql_query (&Gbl.mysql,Gbl.DB.QueryPtr); // Returns 0 on success
|
||||||
|
free ((void *) Gbl.DB.QueryPtr);
|
||||||
|
Gbl.DB.QueryPtr = NULL;
|
||||||
if (Result)
|
if (Result)
|
||||||
DB_ExitOnMySQLError (MsgError);
|
DB_ExitOnMySQLError (MsgError);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ void DB_QueryUPDATE (const char *Query,const char *MsgError);
|
||||||
void DB_QueryDELETE_new (const char *MsgError);
|
void DB_QueryDELETE_new (const char *MsgError);
|
||||||
void DB_QueryDELETE (const char *Query,const char *MsgError);
|
void DB_QueryDELETE (const char *Query,const char *MsgError);
|
||||||
|
|
||||||
void DB_Query_free (const char *Query,const char *MsgError);
|
void DB_Query_new (const char *MsgError);
|
||||||
void DB_Query (const char *Query,const char *MsgError);
|
void DB_Query (const char *Query,const char *MsgError);
|
||||||
void DB_FreeMySQLResult (MYSQL_RES **mysql_res);
|
void DB_FreeMySQLResult (MYSQL_RES **mysql_res);
|
||||||
void DB_ExitOnMySQLError (const char *Message);
|
void DB_ExitOnMySQLError (const char *Message);
|
||||||
|
|
11
swad_game.c
11
swad_game.c
|
@ -3403,14 +3403,12 @@ void Gam_MoveDownQst (void)
|
||||||
static void Gam_ExchangeQuestions (long GamCod,
|
static void Gam_ExchangeQuestions (long GamCod,
|
||||||
unsigned QstIndTop,unsigned QstIndBottom)
|
unsigned QstIndTop,unsigned QstIndBottom)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
long QstCodTop;
|
long QstCodTop;
|
||||||
long QstCodBottom;
|
long QstCodBottom;
|
||||||
|
|
||||||
/***** Lock table to make the inscription atomic *****/
|
/***** Lock table to make the inscription atomic *****/
|
||||||
if (asprintf (&Query,"LOCK TABLES gam_questions WRITE") < 0)
|
DB_BuildQuery ("LOCK TABLES gam_questions WRITE");
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_Query_new ("can not lock tables to move game question");
|
||||||
DB_Query_free (Query,"can not lock tables to move game question");
|
|
||||||
Gbl.DB.LockedTables = true;
|
Gbl.DB.LockedTables = true;
|
||||||
|
|
||||||
/***** Get question code of the questions to be moved *****/
|
/***** Get question code of the questions to be moved *****/
|
||||||
|
@ -3445,9 +3443,8 @@ static void Gam_ExchangeQuestions (long GamCod,
|
||||||
/***** Unlock table *****/
|
/***** Unlock table *****/
|
||||||
Gbl.DB.LockedTables = false; // Set to false before the following unlock...
|
Gbl.DB.LockedTables = false; // Set to false before the following unlock...
|
||||||
// ...to not retry the unlock if error in unlocking
|
// ...to not retry the unlock if error in unlocking
|
||||||
if (asprintf (&Query,"UNLOCK TABLES") < 0)
|
DB_BuildQuery ("UNLOCK TABLES");
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_Query_new ("can not unlock tables after moving game questions");
|
||||||
DB_Query_free (Query,"can not unlock tables after moving game questions");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
16
swad_group.c
16
swad_group.c
|
@ -957,12 +957,9 @@ void Grp_ChangeGrpsOtherUsrAtomically (struct ListCodGrps *LstGrpsUsrWants)
|
||||||
|
|
||||||
static void Grp_LockTables (void)
|
static void Grp_LockTables (void)
|
||||||
{
|
{
|
||||||
char *Query;
|
DB_BuildQuery ("LOCK TABLES crs_grp_types WRITE,crs_grp WRITE,"
|
||||||
|
"crs_grp_usr WRITE,crs_usr READ");
|
||||||
if (asprintf (&Query,"LOCK TABLES crs_grp_types WRITE,crs_grp WRITE,"
|
DB_Query_new ("can not lock tables to change user's groups");
|
||||||
"crs_grp_usr WRITE,crs_usr READ") < 0)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
DB_Query_free (Query,"can not lock tables to change user's groups");
|
|
||||||
Gbl.DB.LockedTables = true;
|
Gbl.DB.LockedTables = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -972,13 +969,10 @@ static void Grp_LockTables (void)
|
||||||
|
|
||||||
static void Grp_UnlockTables (void)
|
static void Grp_UnlockTables (void)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
|
|
||||||
Gbl.DB.LockedTables = false; // Set to false before the following unlock...
|
Gbl.DB.LockedTables = false; // Set to false before the following unlock...
|
||||||
// ...to not retry the unlock if error in unlocking
|
// ...to not retry the unlock if error in unlocking
|
||||||
if (asprintf (&Query,"UNLOCK TABLES") < 0)
|
DB_BuildQuery ("UNLOCK TABLES");
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_Query_new ("can not unlock tables after changing user's groups");
|
||||||
DB_Query_free (Query,"can not unlock tables after changing user's groups");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
23
swad_mail.c
23
swad_mail.c
|
@ -218,7 +218,6 @@ void Mai_EditMailDomains (void)
|
||||||
static void Mai_GetListMailDomainsAllowedForNotif (void)
|
static void Mai_GetListMailDomainsAllowedForNotif (void)
|
||||||
{
|
{
|
||||||
char OrderBySubQuery[256];
|
char OrderBySubQuery[256];
|
||||||
char *Query;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
|
@ -230,19 +229,16 @@ static void Mai_GetListMailDomainsAllowedForNotif (void)
|
||||||
// ...because a unique temporary table can not be used twice in the same query
|
// ...because a unique temporary table can not be used twice in the same query
|
||||||
|
|
||||||
/***** Create temporary table with all the mail domains present in users' emails table *****/
|
/***** Create temporary table with all the mail domains present in users' emails table *****/
|
||||||
if (asprintf (&Query,"DROP TEMPORARY TABLE IF EXISTS T1,T2") < 0)
|
DB_BuildQuery ("DROP TEMPORARY TABLE IF EXISTS T1,T2");
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_Query_new ("can not remove temporary tables");
|
||||||
DB_Query_free (Query,"can not remove temporary tables");
|
|
||||||
|
|
||||||
if (asprintf (&Query,"CREATE TEMPORARY TABLE T1 ENGINE=MEMORY"
|
DB_BuildQuery ("CREATE TEMPORARY TABLE T1 ENGINE=MEMORY"
|
||||||
" SELECT SUBSTRING_INDEX(E_mail,'@',-1) AS Domain,COUNT(*) as N"
|
" SELECT SUBSTRING_INDEX(E_mail,'@',-1) AS Domain,COUNT(*) as N"
|
||||||
" FROM usr_emails GROUP BY Domain") < 0)
|
" FROM usr_emails GROUP BY Domain");
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_Query_new ("can not create temporary table");
|
||||||
DB_Query_free (Query,"can not create temporary table");
|
|
||||||
|
|
||||||
if (asprintf (&Query,"CREATE TEMPORARY TABLE T2 ENGINE=MEMORY SELECT * FROM T1") < 0)
|
DB_BuildQuery ("CREATE TEMPORARY TABLE T2 ENGINE=MEMORY SELECT * FROM T1");
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_Query_new ("can not create temporary table");
|
||||||
DB_Query_free (Query,"can not create temporary table");
|
|
||||||
|
|
||||||
/***** Get mail domains from database *****/
|
/***** Get mail domains from database *****/
|
||||||
switch (Gbl.Mails.SelectedOrder)
|
switch (Gbl.Mails.SelectedOrder)
|
||||||
|
@ -309,9 +305,8 @@ static void Mai_GetListMailDomainsAllowedForNotif (void)
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
|
||||||
/***** Drop temporary table *****/
|
/***** Drop temporary table *****/
|
||||||
if (asprintf (&Query,"DROP TEMPORARY TABLE IF EXISTS T1,T2") < 0)
|
DB_BuildQuery ("DROP TEMPORARY TABLE IF EXISTS T1,T2");
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_Query_new ("can not remove temporary tables");
|
||||||
DB_Query_free (Query,"can not remove temporary tables");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -924,7 +924,6 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
|
||||||
{
|
{
|
||||||
extern const char *Txt_document_in_my_courses;
|
extern const char *Txt_document_in_my_courses;
|
||||||
extern const char *Txt_documents_in_my_courses;
|
extern const char *Txt_documents_in_my_courses;
|
||||||
char *Query;
|
|
||||||
char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1];
|
char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1];
|
||||||
unsigned NumDocs;
|
unsigned NumDocs;
|
||||||
|
|
||||||
|
@ -936,11 +935,10 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
|
||||||
{
|
{
|
||||||
/***** Create temporary table with codes of files in documents and shared areas accessible by me.
|
/***** Create temporary table with codes of files in documents and shared areas accessible by me.
|
||||||
It is necessary to speed up the second query *****/
|
It is necessary to speed up the second query *****/
|
||||||
if (asprintf (&Query,"DROP TEMPORARY TABLE IF EXISTS my_files_crs,my_files_grp") < 0)
|
DB_BuildQuery ("DROP TEMPORARY TABLE IF EXISTS my_files_crs,my_files_grp");
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_Query_new ("can not remove temporary table");
|
||||||
DB_Query_free (Query,"can not remove temporary table");
|
|
||||||
|
|
||||||
if (asprintf (&Query,"CREATE TEMPORARY TABLE my_files_crs"
|
DB_BuildQuery ("CREATE TEMPORARY TABLE my_files_crs"
|
||||||
" (FilCod INT NOT NULL,UNIQUE INDEX(FilCod))"
|
" (FilCod INT NOT NULL,UNIQUE INDEX(FilCod))"
|
||||||
" ENGINE=MEMORY"
|
" ENGINE=MEMORY"
|
||||||
" SELECT files.FilCod FROM crs_usr,files"
|
" SELECT files.FilCod FROM crs_usr,files"
|
||||||
|
@ -951,11 +949,10 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
|
||||||
(unsigned) Brw_ADMI_DOC_CRS,
|
(unsigned) Brw_ADMI_DOC_CRS,
|
||||||
(unsigned) Brw_ADMI_TCH_CRS,
|
(unsigned) Brw_ADMI_TCH_CRS,
|
||||||
(unsigned) Brw_ADMI_SHR_CRS,
|
(unsigned) Brw_ADMI_SHR_CRS,
|
||||||
(unsigned) Brw_ADMI_MRK_CRS) < 0)
|
(unsigned) Brw_ADMI_MRK_CRS);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_Query_new ("can not create temporary table");
|
||||||
DB_Query_free (Query,"can not create temporary table");
|
|
||||||
|
|
||||||
if (asprintf (&Query,"CREATE TEMPORARY TABLE my_files_grp"
|
DB_BuildQuery ("CREATE TEMPORARY TABLE my_files_grp"
|
||||||
" (FilCod INT NOT NULL,UNIQUE INDEX(FilCod))"
|
" (FilCod INT NOT NULL,UNIQUE INDEX(FilCod))"
|
||||||
" ENGINE=MEMORY"
|
" ENGINE=MEMORY"
|
||||||
" SELECT files.FilCod FROM crs_grp_usr,files"
|
" SELECT files.FilCod FROM crs_grp_usr,files"
|
||||||
|
@ -966,11 +963,10 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
|
||||||
(unsigned) Brw_ADMI_DOC_GRP,
|
(unsigned) Brw_ADMI_DOC_GRP,
|
||||||
(unsigned) Brw_ADMI_TCH_GRP,
|
(unsigned) Brw_ADMI_TCH_GRP,
|
||||||
(unsigned) Brw_ADMI_SHR_GRP,
|
(unsigned) Brw_ADMI_SHR_GRP,
|
||||||
(unsigned) Brw_ADMI_MRK_GRP) < 0)
|
(unsigned) Brw_ADMI_MRK_GRP);
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
/* if (Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM)
|
/* if (Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM)
|
||||||
Lay_ShowAlert (Lay_INFO,Query); */
|
Lay_ShowAlert (Lay_INFO,Query); */
|
||||||
DB_Query_free (Query,"can not create temporary table");
|
DB_Query_new ("can not create temporary table");
|
||||||
|
|
||||||
/***** Build the query *****/
|
/***** Build the query *****/
|
||||||
DB_BuildQuery ("SELECT * FROM "
|
DB_BuildQuery ("SELECT * FROM "
|
||||||
|
@ -1033,9 +1029,8 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
|
||||||
Txt_documents_in_my_courses);
|
Txt_documents_in_my_courses);
|
||||||
|
|
||||||
/***** Drop temporary table *****/
|
/***** Drop temporary table *****/
|
||||||
if (asprintf (&Query,"DROP TEMPORARY TABLE IF EXISTS my_files_crs,my_files_grp") < 0)
|
DB_BuildQuery ("DROP TEMPORARY TABLE IF EXISTS my_files_crs,my_files_grp");
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_Query_new ("can not remove temporary table");
|
||||||
DB_Query_free (Query,"can not remove temporary table");
|
|
||||||
|
|
||||||
return NumDocs;
|
return NumDocs;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user