Version 18.17

This commit is contained in:
Antonio Cañas Vargas 2018-11-14 23:40:56 +01:00
parent 8aaa1925c9
commit ce1772f53e
9 changed files with 57 additions and 50 deletions

View File

@ -120,7 +120,7 @@ void Ale_ShowAlertAndButton1 (Ale_AlertType_t AlertType,const char *Txt)
static const bool AlertClosable[Ale_NUM_ALERT_TYPES] =
{
false, // Ale_NONE
false, // Ale_CLIPBOARD
true, // Ale_CLIPBOARD
true, // Ale_INFO
true, // Ale_SUCCESS
true, // Ale_QUESTION

View File

@ -353,10 +353,11 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
#define Log_PLATFORM_VERSION "SWAD 18.16.3 (2018-11-14)"
#define Log_PLATFORM_VERSION "SWAD 18.17 (2018-11-14)"
#define CSS_FILE "swad18.4.css"
#define JS_FILE "swad17.17.1.js"
/*
Version 18.17: Nov 14, 2018 Code refactoring related to database queries. (236899 lines)
Version 18.16.3: Nov 14, 2018 Fixed bug when copying-pasting on assignments/works of another user, reported by Javier Fernández Baldomero. (236890 lines)
Version 18.16.2: Nov 14, 2018 Fixed bug in account, discovered by Oresti Baños. (236848 lines)
Version 18.16.1: Nov 12, 2018 MOOC advertisement. (236846 lines)

View File

@ -53,8 +53,9 @@ extern struct Globals Gbl;
/*****************************************************************************/
static void DB_CreateTable (const char *Query);
// static void DB_QueryPrintf (char **strp,const char *fmt,...);
static unsigned long DB_QuerySELECTusingQueryStr (char *Query,
MYSQL_RES **mysql_res,
const char *MsgError);
/*****************************************************************************/
/***************************** Database tables *******************************/
@ -3105,23 +3106,23 @@ unsigned long DB_QuerySELECT (MYSQL_RES **mysql_res,const char *MsgError,
// vasprintf will return -1
Lay_NotEnoughMemoryExit ();
return DB_QuerySELECTusingQueryStr (&Query,mysql_res,MsgError);
return DB_QuerySELECTusingQueryStr (Query,mysql_res,MsgError);
}
unsigned long DB_QuerySELECTusingQueryStr (char **Query,
MYSQL_RES **mysql_res,const char *MsgError)
static unsigned long DB_QuerySELECTusingQueryStr (char *Query,
MYSQL_RES **mysql_res,
const char *MsgError)
{
int Result;
/***** Check that query string pointer
does point to an allocated string *****/
if (*Query == NULL)
if (Query == NULL)
Lay_ShowErrorAndExit ("Wrong query string.");
/***** Query database and free query string pointer *****/
Result = mysql_query (&Gbl.mysql,*Query); // Returns 0 on success
free ((void *) *Query);
*Query = NULL;
Result = mysql_query (&Gbl.mysql,Query); // Returns 0 on success
free ((void *) Query);
if (Result)
DB_ExitOnMySQLError (MsgError);
@ -3164,7 +3165,7 @@ unsigned long DB_QueryCOUNT (const char *MsgError,const char *fmt,...)
Lay_NotEnoughMemoryExit ();
/***** Make query "SELECT COUNT(*) FROM..." *****/
DB_QuerySELECTusingQueryStr (&Query,&mysql_res,MsgError);
DB_QuerySELECTusingQueryStr (Query,&mysql_res,MsgError);
/***** Get number of rows *****/
row = mysql_fetch_row (mysql_res);

View File

@ -41,9 +41,6 @@ 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_QuerySELECTusingQueryStr (char **Query,
MYSQL_RES **mysql_res,const char *MsgError);
unsigned long DB_GetNumRowsTable (const char *Table);
unsigned long DB_QueryCOUNT (const char *MsgError,const char *fmt,...);

View File

@ -145,7 +145,7 @@ static void Soc_UpdateLastPubCodIntoSession (void);
static void Soc_UpdateFirstPubCodIntoSession (long FirstPubCod);
static void Soc_DropTemporaryTablesUsedToQueryTimeline (void);
static void Soc_ShowTimeline (char **Query,
static void Soc_ShowTimeline (char *Query,
const char *Title,long NotCodToHighlight);
static void Soc_PutIconsTimeline (void);
@ -157,8 +157,8 @@ static void Soc_GetParamsWhichUsrs (void);
static void Soc_ShowWarningYouDontFollowAnyUser (void);
static void Soc_InsertNewPubsInTimeline (char **Query);
static void Soc_ShowOldPubsInTimeline (char **Query);
static void Soc_InsertNewPubsInTimeline (char *Query);
static void Soc_ShowOldPubsInTimeline (char *Query);
static void Soc_GetDataOfSocialPublishingFromRow (MYSQL_ROW row,struct SocialPublishing *SocPub);
@ -372,7 +372,7 @@ static void Soc_ShowTimelineGblHighlightingNot (long NotCod)
Soc_GET_RECENT_TIMELINE);
/***** Show timeline *****/
Soc_ShowTimeline (&Query,Txt_Timeline,NotCod);
Soc_ShowTimeline (Query,Txt_Timeline,NotCod);
/***** Drop temporary tables *****/
Soc_DropTemporaryTablesUsedToQueryTimeline ();
@ -401,7 +401,7 @@ static void Soc_ShowTimelineUsrHighlightingNot (long NotCod)
snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Timeline_OF_A_USER,
Gbl.Usrs.Other.UsrDat.FirstName);
Soc_ShowTimeline (&Query,Gbl.Title,NotCod);
Soc_ShowTimeline (Query,Gbl.Title,NotCod);
/***** Drop temporary tables *****/
Soc_DropTemporaryTablesUsedToQueryTimeline ();
@ -430,7 +430,7 @@ void Soc_RefreshNewTimelineGbl (void)
Soc_GET_ONLY_NEW_PUBS);
/***** Show new timeline *****/
Soc_InsertNewPubsInTimeline (&Query);
Soc_InsertNewPubsInTimeline (Query);
/***** Drop temporary tables *****/
Soc_DropTemporaryTablesUsedToQueryTimeline ();
@ -475,7 +475,7 @@ static void Soc_GetAndShowOldTimeline (Soc_TimelineUsrOrGbl_t TimelineUsrOrGbl)
Soc_GET_ONLY_OLD_PUBS);
/***** Show old timeline *****/
Soc_ShowOldPubsInTimeline (&Query);
Soc_ShowOldPubsInTimeline (Query);
/***** Drop temporary tables *****/
Soc_DropTemporaryTablesUsedToQueryTimeline ();
@ -919,7 +919,7 @@ static void Soc_DropTemporaryTablesUsedToQueryTimeline (void)
| |_____|
\ |_____|
*/
static void Soc_ShowTimeline (char **Query,
static void Soc_ShowTimeline (char *Query,
const char *Title,long NotCodToHighlight)
{
extern const char *Hlp_SOCIAL_Timeline;
@ -933,8 +933,9 @@ static void Soc_ShowTimeline (char **Query,
bool ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
/***** Get publishings from database *****/
NumPubsGot = DB_QuerySELECTusingQueryStr (Query,&mysql_res,
"can not get timeline");
NumPubsGot = DB_QuerySELECT (&mysql_res,"can not get timeline",
"%s",
Query);
/***** Start box *****/
Box_StartBox (Soc_WIDTH_TIMELINE,Title,Soc_PutIconsTimeline,
@ -1123,7 +1124,7 @@ static void Soc_ShowWarningYouDontFollowAnyUser (void)
/*****************************************************************************/
// The publishings are inserted as list elements of a hidden list
static void Soc_InsertNewPubsInTimeline (char **Query)
static void Soc_InsertNewPubsInTimeline (char *Query)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
@ -1133,8 +1134,9 @@ static void Soc_InsertNewPubsInTimeline (char **Query)
struct SocialNote SocNot;
/***** Get new publishings timeline from database *****/
NumPubsGot = DB_QuerySELECTusingQueryStr (Query,&mysql_res,
"can not get timeline");
NumPubsGot = DB_QuerySELECT (&mysql_res,"can not get timeline",
"%s",
Query);
/***** List new publishings timeline *****/
for (NumPub = 0;
@ -1164,7 +1166,7 @@ static void Soc_InsertNewPubsInTimeline (char **Query)
/*****************************************************************************/
// The publishings are inserted as list elements of a hidden list
static void Soc_ShowOldPubsInTimeline (char **Query)
static void Soc_ShowOldPubsInTimeline (char *Query)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
@ -1174,8 +1176,9 @@ static void Soc_ShowOldPubsInTimeline (char **Query)
struct SocialNote SocNot;
/***** Get old publishings timeline from database *****/
NumPubsGot = DB_QuerySELECTusingQueryStr (Query,&mysql_res,
"can not get timeline");
NumPubsGot = DB_QuerySELECT (&mysql_res,"can not get timeline",
"%s",
Query);
/***** List old publishings in timeline *****/
for (NumPub = 0, SocPub.PubCod = 0;

View File

@ -1459,8 +1459,9 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
Ale_ShowAlert (Ale_INFO,Query);
*/
/***** Make the query *****/
NumRows = DB_QuerySELECTusingQueryStr (&Query,&mysql_res,
"can not get clicks");
NumRows = DB_QuerySELECT (&mysql_res,"can not get clicks",
"%s",
Query);
/***** Count the number of rows in result *****/
if (NumRows == 0)

View File

@ -2652,8 +2652,9 @@ static unsigned long Tst_GetQuestions (MYSQL_RES **mysql_res)
}
/* Make the query */
NumRows = DB_QuerySELECTusingQueryStr (&Query,mysql_res,
"can not get questions");
NumRows = DB_QuerySELECT (mysql_res,"can not get questions",
"%s",
Query);
if (NumRows == 0)
Ale_ShowAlert (Ale_INFO,Txt_No_questions_found_matching_your_search_criteria);
@ -2789,8 +2790,9 @@ static unsigned long Tst_GetQuestionsForTest (MYSQL_RES **mysql_res)
Lay_ShowAlert (Lay_INFO,Query);
*/
/* Make the query */
return DB_QuerySELECTusingQueryStr (&Query,mysql_res,
"can not get questions");
return DB_QuerySELECT (mysql_res,"can not get questions",
"%s",
Query);
}
/*****************************************************************************/

View File

@ -186,7 +186,7 @@ static void Usr_BuildQueryToGetUsrsLstCrs (char **Query,Rol_Role_t Role);
static void Usr_GetAdmsLst (Sco_Scope_t Scope);
static void Usr_GetGstsLst (Sco_Scope_t Scope);
static void Usr_GetListUsrsFromQuery (char **Query,Rol_Role_t Role,Sco_Scope_t Scope);
static void Usr_GetListUsrsFromQuery (char *Query,Rol_Role_t Role,Sco_Scope_t Scope);
static void Usr_AllocateUsrsList (Rol_Role_t Role);
static void Usr_PutButtonToConfirmIWantToSeeBigList (unsigned NumUsrs,const char *OnSubmit);
@ -4619,7 +4619,7 @@ void Usr_GetListUsrs (Sco_Scope_t Scope,Rol_Role_t Role)
Lay_ShowAlert (Lay_INFO,Query);
*/
/***** Get list of users from database given a query *****/
Usr_GetListUsrsFromQuery (&Query,Role,Scope);
Usr_GetListUsrsFromQuery (Query,Role,Scope);
}
/*****************************************************************************/
@ -4897,7 +4897,7 @@ void Usr_SearchListUsrs (Rol_Role_t Role)
// Lay_ShowAlert (Lay_INFO,Query);
/***** Get list of users from database given a query *****/
Usr_GetListUsrsFromQuery (&Query,Role,Gbl.Scope.Current);
Usr_GetListUsrsFromQuery (Query,Role,Gbl.Scope.Current);
}
/*****************************************************************************/
@ -5101,7 +5101,7 @@ static void Usr_GetAdmsLst (Sco_Scope_t Scope)
}
/***** Get list of administrators from database *****/
Usr_GetListUsrsFromQuery (&Query,Rol_DEG_ADM,Scope);
Usr_GetListUsrsFromQuery (Query,Rol_DEG_ADM,Scope);
}
/*****************************************************************************/
@ -5180,7 +5180,7 @@ static void Usr_GetGstsLst (Sco_Scope_t Scope)
}
/***** Get list of students from database *****/
Usr_GetListUsrsFromQuery (&Query,Rol_GST,Scope);
Usr_GetListUsrsFromQuery (Query,Rol_GST,Scope);
}
/*****************************************************************************/
@ -5231,7 +5231,7 @@ void Usr_GetUnorderedStdsCodesInDeg (long DegCod)
DegCod,(unsigned) Rol_STD);
/***** Get list of students from database *****/
Usr_GetListUsrsFromQuery (&Query,Rol_STD,Sco_SCOPE_DEG);
Usr_GetListUsrsFromQuery (Query,Rol_STD,Sco_SCOPE_DEG);
}
}
@ -5239,7 +5239,7 @@ void Usr_GetUnorderedStdsCodesInDeg (long DegCod)
/********************** Get list of users from database **********************/
/*****************************************************************************/
static void Usr_GetListUsrsFromQuery (char **Query,Rol_Role_t Role,Sco_Scope_t Scope)
static void Usr_GetListUsrsFromQuery (char *Query,Rol_Role_t Role,Sco_Scope_t Scope)
{
extern const char *Txt_The_list_of_X_users_is_too_large_to_be_displayed;
MYSQL_RES *mysql_res;
@ -5248,13 +5248,13 @@ static void Usr_GetListUsrsFromQuery (char **Query,Rol_Role_t Role,Sco_Scope_t S
struct UsrInList *UsrInList;
bool Abort = false;
if (*Query == NULL)
if (Query == NULL)
{
Gbl.Usrs.LstUsrs[Role].NumUsrs = 0;
return;
}
if (!*Query[0])
if (!Query[0])
{
Gbl.Usrs.LstUsrs[Role].NumUsrs = 0;
return;
@ -5262,8 +5262,9 @@ static void Usr_GetListUsrsFromQuery (char **Query,Rol_Role_t Role,Sco_Scope_t S
/***** Query database *****/
if ((Gbl.Usrs.LstUsrs[Role].NumUsrs =
(unsigned) DB_QuerySELECTusingQueryStr (Query,&mysql_res,
"can not get list of users")))
(unsigned) DB_QuerySELECT (&mysql_res,"can not get list of users",
"%s",
Query)))
{
if (Gbl.Usrs.LstUsrs[Role].NumUsrs > Cfg_MAX_USRS_IN_LIST)
{

View File

@ -3375,8 +3375,9 @@ int swad__sendMessage (struct soap *soap,
if (ReplyUsrCod > 0 || ThereAreNicknames) // There are a recipient to reply or nicknames in "to"
{
/***** Get users *****/
NumRows = DB_QuerySELECTusingQueryStr (&Query,&mysql_res,
"can not get users");
NumRows = DB_QuerySELECT (&mysql_res,"can not get users",
"%s",
Query);
sendMessageOut->numUsers = (int) NumRows;
sendMessageOut->usersArray.__size = (int) NumRows;