Version 18.11.18

This commit is contained in:
Antonio Cañas Vargas 2018-11-02 16:39:35 +01:00
parent 0affd0d419
commit c364d4ea76
23 changed files with 228 additions and 233 deletions

View File

@ -855,10 +855,10 @@ static bool ID_CheckIfConfirmed (long UsrCod,const char *UsrID)
static void ID_RemoveUsrIDFromDB (long UsrCod,const char *UsrID) static void ID_RemoveUsrIDFromDB (long UsrCod,const char *UsrID)
{ {
/***** Remove one of my user's IDs *****/ /***** Remove one of my user's IDs *****/
DB_BuildQuery ("DELETE FROM usr_IDs" DB_QueryREPLACE ("can not remove a user's ID",
" WHERE UsrCod=%ld AND UsrID='%s'", "DELETE FROM usr_IDs"
UsrCod,UsrID); " WHERE UsrCod=%ld AND UsrID='%s'",
DB_QueryREPLACE_new ("can not remove a user's ID"); UsrCod,UsrID);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -373,12 +373,12 @@ void MFU_UpdateMFUActions (void)
DB_FreeMySQLResult (&mysql_res); DB_FreeMySQLResult (&mysql_res);
/***** Update score for the current action *****/ /***** Update score for the current action *****/
DB_BuildQuery ("REPLACE INTO actions_MFU" DB_QueryREPLACE ("can not update most frequently used actions",
" (UsrCod,ActCod,Score,LastClick)" "REPLACE INTO actions_MFU"
" VALUES" " (UsrCod,ActCod,Score,LastClick)"
" (%ld,%ld,'%f',NOW())", " VALUES"
Gbl.Usrs.Me.UsrDat.UsrCod,ActCod,Score); " (%ld,%ld,'%f',NOW())",
DB_QueryREPLACE_new ("can not update most frequently used actions"); Gbl.Usrs.Me.UsrDat.UsrCod,ActCod,Score);
/***** Update score for other actions *****/ /***** Update score for other actions *****/
DB_BuildQuery ("UPDATE actions_MFU SET Score=GREATEST(Score*'%f','%f')" DB_BuildQuery ("UPDATE actions_MFU SET Score=GREATEST(Score*'%f','%f')"

View File

@ -595,12 +595,12 @@ void Ann_MarkAnnouncementAsSeen (void)
AnnCod = Ann_GetParamAnnCod (); AnnCod = Ann_GetParamAnnCod ();
/***** Mark announcement as seen *****/ /***** Mark announcement as seen *****/
DB_BuildQuery ("REPLACE INTO ann_seen" DB_QueryREPLACE ("can not mark announcement as seen",
" (AnnCod,UsrCod)" "REPLACE INTO ann_seen"
" VALUES" " (AnnCod,UsrCod)"
" (%ld,%ld)", " VALUES"
AnnCod,Gbl.Usrs.Me.UsrDat.UsrCod); " (%ld,%ld)",
DB_QueryREPLACE_new ("can not mark announcement as seen"); AnnCod,Gbl.Usrs.Me.UsrDat.UsrCod);
/***** Show other announcements again *****/ /***** Show other announcements again *****/
Ann_ShowMyAnnouncementsNotMarkedAsSeen (); Ann_ShowMyAnnouncementsNotMarkedAsSeen ();

View File

@ -2602,16 +2602,16 @@ static void Att_RegUsrInAttEventChangingComments (long AttCod,long UsrCod,bool P
const char *CommentStd,const char *CommentTch) const char *CommentStd,const char *CommentTch)
{ {
/***** Register user as assistant to an event in database *****/ /***** Register user as assistant to an event in database *****/
DB_BuildQuery ("REPLACE INTO att_usr" DB_QueryREPLACE ("can not register user in an event",
" (AttCod,UsrCod,Present,CommentStd,CommentTch)" "REPLACE INTO att_usr"
" VALUES" " (AttCod,UsrCod,Present,CommentStd,CommentTch)"
" (%ld,%ld,'%c','%s','%s')", " VALUES"
AttCod,UsrCod, " (%ld,%ld,'%c','%s','%s')",
Present ? 'Y' : AttCod,UsrCod,
'N', Present ? 'Y' :
CommentStd, 'N',
CommentTch); CommentStd,
DB_QueryREPLACE_new ("can not register user in an event"); CommentTch);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -2624,7 +2624,7 @@ static void Att_RemoveUsrFromAttEvent (long AttCod,long UsrCod)
DB_BuildQuery ("DELETE FROM att_usr" DB_BuildQuery ("DELETE FROM att_usr"
" WHERE AttCod=%ld AND UsrCod=%ld", " WHERE AttCod=%ld AND UsrCod=%ld",
AttCod,UsrCod); AttCod,UsrCod);
DB_QueryREPLACE_new ("can not remove student from an event"); DB_QueryDELETE_new ("can not remove student from an event");
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -355,10 +355,11 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf ps2pdf source.ps destination.pdf
*/ */
#define Log_PLATFORM_VERSION "SWAD 18.11.17 (2018-11-02)" #define Log_PLATFORM_VERSION "SWAD 18.11.18 (2018-11-02)"
#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.11.18: Nov 02, 2018 Joining building and performing query into one function. (236499 lines)
Version 18.11.17: Nov 02, 2018 Joining building and performing query into one function. (236504 lines) Version 18.11.17: Nov 02, 2018 Joining building and performing query into one function. (236504 lines)
Version 18.11.16: Nov 02, 2018 Joining building and performing query into one function. (236332 lines) Version 18.11.16: Nov 02, 2018 Joining building and performing query into one function. (236332 lines)
Version 18.11.15: Nov 02, 2018 Joining building and performing query into one function. (236312 lines) Version 18.11.15: Nov 02, 2018 Joining building and performing query into one function. (236312 lines)

View File

@ -642,14 +642,14 @@ void Con_UpdateMeInConnectedList (void)
{ {
/***** Update my entry in connected list. /***** Update my entry in connected list.
The role which is stored is the role of the last click *****/ The role which is stored is the role of the last click *****/
DB_BuildQuery ("REPLACE INTO connected" DB_QueryREPLACE ("can not update list of connected users",
" (UsrCod,RoleInLastCrs,LastCrsCod,LastTime)" "REPLACE INTO connected"
" VALUES" " (UsrCod,RoleInLastCrs,LastCrsCod,LastTime)"
" (%ld,%u,%ld,NOW())", " VALUES"
Gbl.Usrs.Me.UsrDat.UsrCod, " (%ld,%u,%ld,NOW())",
(unsigned) Gbl.Usrs.Me.Role.Logged, Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.CurrentCrs.Crs.CrsCod); (unsigned) Gbl.Usrs.Me.Role.Logged,
DB_QueryREPLACE_new ("can not update list of connected users"); Gbl.CurrentCrs.Crs.CrsCod);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -3069,8 +3069,8 @@ void DB_CloseDBConnection (void)
void DB_BuildQuery (const char *fmt,...) void DB_BuildQuery (const char *fmt,...)
{ {
int NumBytesPrinted;
va_list ap; va_list ap;
int NumBytesPrinted;
if (Gbl.DB.QueryPtr != NULL) if (Gbl.DB.QueryPtr != NULL)
Lay_ShowErrorAndExit ("Error building query."); Lay_ShowErrorAndExit ("Error building query.");
@ -3087,8 +3087,8 @@ void DB_BuildQuery (const char *fmt,...)
void DB_BuildQuery_old (char **Query,const char *fmt,...) void DB_BuildQuery_old (char **Query,const char *fmt,...)
{ {
int NumBytesPrinted;
va_list ap; va_list ap;
int NumBytesPrinted;
if (*Query != NULL) if (*Query != NULL)
Lay_ShowErrorAndExit ("Error building query."); Lay_ShowErrorAndExit ("Error building query.");
@ -3103,22 +3103,6 @@ void DB_BuildQuery_old (char **Query,const char *fmt,...)
Lay_NotEnoughMemoryExit (); Lay_NotEnoughMemoryExit ();
} }
/*
static void DB_QueryPrintf (char **strp,const char *fmt,...)
{
int NumBytesPrinted;
va_list ap;
va_start (ap, fmt);
NumBytesPrinted = vasprintf (strp, fmt, ap);
va_end (ap);
if (NumBytesPrinted < 0) // If memory allocation wasn't possible,
// or some other error occurs,
// vasprintf will return -1
Lay_NotEnoughMemoryExit ();
}
*/
/*****************************************************************************/ /*****************************************************************************/
/******************** Make a SELECT query from database **********************/ /******************** Make a SELECT query from database **********************/
/*****************************************************************************/ /*****************************************************************************/
@ -3126,8 +3110,8 @@ static void DB_QueryPrintf (char **strp,const char *fmt,...)
unsigned long DB_QuerySELECT (MYSQL_RES **mysql_res,const char *MsgError, unsigned long DB_QuerySELECT (MYSQL_RES **mysql_res,const char *MsgError,
const char *fmt,...) const char *fmt,...)
{ {
int NumBytesPrinted;
va_list ap; va_list ap;
int NumBytesPrinted;
char *Query = NULL; char *Query = NULL;
va_start (ap,fmt); va_start (ap,fmt);
@ -3173,8 +3157,8 @@ unsigned long DB_QuerySELECT_old (char **Query,MYSQL_RES **mysql_res,const char
unsigned long DB_QueryCOUNT (const char *MsgError, unsigned long DB_QueryCOUNT (const char *MsgError,
const char *fmt,...) const char *fmt,...)
{ {
int NumBytesPrinted;
va_list ap; va_list ap;
int NumBytesPrinted;
char *Query = NULL; char *Query = NULL;
va_start (ap,fmt); va_start (ap,fmt);
@ -3284,19 +3268,31 @@ long DB_QueryINSERTandReturnCode_new (const char *MsgError)
/******************** Make an REPLACE query in database **********************/ /******************** Make an REPLACE query in database **********************/
/*****************************************************************************/ /*****************************************************************************/
void DB_QueryREPLACE_new (const char *MsgError) void DB_QueryREPLACE (const char *MsgError,const char *fmt,...)
{ {
va_list ap;
int NumBytesPrinted;
char *Query = NULL;
int Result; int Result;
va_start (ap,fmt);
NumBytesPrinted = vasprintf (&Query,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // If memory allocation wasn't possible,
// or some other error occurs,
// vasprintf will return -1
Lay_NotEnoughMemoryExit ();
/***** Check that query string pointer /***** Check that query string pointer
does point to an allocated string *****/ does point to an allocated string *****/
if (Gbl.DB.QueryPtr == NULL) if (Query == NULL)
Lay_ShowErrorAndExit ("Wrong query string."); Lay_ShowErrorAndExit ("Wrong query string.");
/***** Query database and free query string pointer *****/ /***** Query database and free query string pointer *****/
Result = mysql_query (&Gbl.mysql,Gbl.DB.QueryPtr); // Returns 0 on success Result = mysql_query (&Gbl.mysql,Query); // Returns 0 on success
free ((void *) Gbl.DB.QueryPtr); free ((void *) Query);
Gbl.DB.QueryPtr = NULL; Query = NULL;
if (Result) if (Result)
DB_ExitOnMySQLError (MsgError); DB_ExitOnMySQLError (MsgError);
} }

View File

@ -54,7 +54,7 @@ void DB_QueryINSERT_old (char **Query,const char *MsgError);
long DB_QueryINSERTandReturnCode_new (const char *MsgError); long DB_QueryINSERTandReturnCode_new (const char *MsgError);
void DB_QueryREPLACE_new (const char *MsgError); void DB_QueryREPLACE (const char *MsgError,const char *fmt,...);
void DB_QueryUPDATE_new (const char *MsgError); void DB_QueryUPDATE_new (const char *MsgError);
void DB_QueryUPDATE_old (char **Query,const char *MsgError); void DB_QueryUPDATE_old (char **Query,const char *MsgError);

View File

@ -3471,12 +3471,12 @@ static void Enr_RegisterAdmin (struct UsrData *UsrDat,Sco_Scope_t Scope,long Cod
else // User was not administrator of current institution/centre/degree else // User was not administrator of current institution/centre/degree
{ {
/***** Insert or replace administrator in current institution/centre/degree *****/ /***** Insert or replace administrator in current institution/centre/degree *****/
DB_BuildQuery ("REPLACE INTO admin" DB_QueryREPLACE ("can not create administrator",
" (UsrCod,Scope,Cod)" "REPLACE INTO admin"
" VALUES" " (UsrCod,Scope,Cod)"
" (%ld,'%s',%ld)", " VALUES"
UsrDat->UsrCod,Sco_ScopeDB[Scope],Cod); " (%ld,'%s',%ld)",
DB_QueryREPLACE_new ("can not create administrator"); UsrDat->UsrCod,Sco_ScopeDB[Scope],Cod);
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
Txt_THE_USER_X_has_been_enroled_as_administrator_of_Y, Txt_THE_USER_X_has_been_enroled_as_administrator_of_Y,

View File

@ -4533,18 +4533,19 @@ static void Brw_StoreSizeOfFileTreeInDB (void)
long ZoneUsrCod = Brw_GetZoneUsrCodForFiles (); long ZoneUsrCod = Brw_GetZoneUsrCodForFiles ();
/***** Update size of the file browser in database *****/ /***** Update size of the file browser in database *****/
DB_BuildQuery ("REPLACE INTO file_browser_size" DB_QueryREPLACE ("can not store the size of a file browser",
" (FileBrowser,Cod,ZoneUsrCod," "REPLACE INTO file_browser_size"
"NumLevels,NumFolders,NumFiles,TotalSize)" " (FileBrowser,Cod,ZoneUsrCod,"
" VALUES" "NumLevels,NumFolders,NumFiles,TotalSize)"
" (%u,%ld,%ld," " VALUES"
"%u,'%lu','%lu','%llu')", " (%u,%ld,%ld,"
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],Cod,ZoneUsrCod, "%u,'%lu','%lu','%llu')",
Gbl.FileBrowser.Size.NumLevls, (unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
Gbl.FileBrowser.Size.NumFolds, Cod,ZoneUsrCod,
Gbl.FileBrowser.Size.NumFiles, Gbl.FileBrowser.Size.NumLevls,
Gbl.FileBrowser.Size.TotalSiz); Gbl.FileBrowser.Size.NumFolds,
DB_QueryREPLACE_new ("can not store the size of a file browser"); Gbl.FileBrowser.Size.NumFiles,
Gbl.FileBrowser.Size.TotalSiz);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -5551,14 +5552,14 @@ static void Brw_GetAndUpdateDateLastAccFileBrowser (void)
DB_FreeMySQLResult (&mysql_res); DB_FreeMySQLResult (&mysql_res);
/***** Update date of my last access to file browser in this course *****/ /***** Update date of my last access to file browser in this course *****/
DB_BuildQuery ("REPLACE INTO file_browser_last" DB_QueryREPLACE ("can not update date of last access to a file browser",
" (UsrCod,FileBrowser,Cod,LastClick)" "REPLACE INTO file_browser_last"
" VALUES" " (UsrCod,FileBrowser,Cod,LastClick)"
" (%ld,%u,%ld,NOW())", " VALUES"
Gbl.Usrs.Me.UsrDat.UsrCod, " (%ld,%u,%ld,NOW())",
(unsigned) Brw_FileBrowserForDB_file_browser_last[Gbl.FileBrowser.Type], Gbl.Usrs.Me.UsrDat.UsrCod,
Cod); (unsigned) Brw_FileBrowserForDB_file_browser_last[Gbl.FileBrowser.Type],
DB_QueryREPLACE_new ("can not update date of last access to a file browser"); Cod);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -1014,13 +1014,13 @@ void Fol_FollowUsr1 (void)
Gbl.Usrs.Other.UsrDat.UsrCod)) Gbl.Usrs.Other.UsrDat.UsrCod))
{ {
/***** Follow user in database *****/ /***** Follow user in database *****/
DB_BuildQuery ("REPLACE INTO usr_follow" DB_QueryREPLACE ("can not follow user",
" (FollowerCod,FollowedCod,FollowTime)" "REPLACE INTO usr_follow"
" VALUES" " (FollowerCod,FollowedCod,FollowTime)"
" (%ld,%ld,NOW())", " VALUES"
Gbl.Usrs.Me.UsrDat.UsrCod, " (%ld,%ld,NOW())",
Gbl.Usrs.Other.UsrDat.UsrCod); Gbl.Usrs.Me.UsrDat.UsrCod,
DB_QueryREPLACE_new ("can not follow user"); Gbl.Usrs.Other.UsrDat.UsrCod);
/***** This follow must be notified by email? *****/ /***** This follow must be notified by email? *****/
CreateNotif = (Gbl.Usrs.Other.UsrDat.Prefs.NotifNtfEvents & (1 << Ntf_EVENT_FOLLOWER)); CreateNotif = (Gbl.Usrs.Other.UsrDat.Prefs.NotifNtfEvents & (1 << Ntf_EVENT_FOLLOWER));
@ -1075,14 +1075,12 @@ void Fol_UnfollowUsr1 (void)
// Unfollow only if I follow him/her // Unfollow only if I follow him/her
if (Fol_CheckUsrIsFollowerOf (Gbl.Usrs.Me.UsrDat.UsrCod, if (Fol_CheckUsrIsFollowerOf (Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Other.UsrDat.UsrCod)) Gbl.Usrs.Other.UsrDat.UsrCod))
{
/***** Unfollow user in database *****/ /***** Unfollow user in database *****/
DB_BuildQuery ("DELETE FROM usr_follow" DB_QueryREPLACE ("can not unfollow user",
" WHERE FollowerCod=%ld AND FollowedCod=%ld", "DELETE FROM usr_follow"
Gbl.Usrs.Me.UsrDat.UsrCod, " WHERE FollowerCod=%ld AND FollowedCod=%ld",
Gbl.Usrs.Other.UsrDat.UsrCod); Gbl.Usrs.Me.UsrDat.UsrCod,
DB_QueryREPLACE_new ("can not unfollow user"); Gbl.Usrs.Other.UsrDat.UsrCod);
}
Gbl.Alert.Type = Ale_SUCCESS; Gbl.Alert.Type = Ale_SUCCESS;
} }
else else

View File

@ -481,12 +481,12 @@ static void For_DeletePstFromDisabledPstTable (long PstCod)
static void For_InsertPstIntoBannedPstTable (long PstCod) static void For_InsertPstIntoBannedPstTable (long PstCod)
{ {
/***** Remove post from banned posts table *****/ /***** Remove post from banned posts table *****/
DB_BuildQuery ("REPLACE INTO forum_disabled_post" DB_QueryREPLACE ("can not ban a post of a forum",
" (PstCod,UsrCod,DisableTime)" "REPLACE INTO forum_disabled_post"
" VALUES" " (PstCod,UsrCod,DisableTime)"
" (%ld,%ld,NOW())", " VALUES"
PstCod,Gbl.Usrs.Me.UsrDat.UsrCod); " (%ld,%ld,NOW())",
DB_QueryREPLACE_new ("can not ban a post of a forum"); PstCod,Gbl.Usrs.Me.UsrDat.UsrCod);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -771,13 +771,14 @@ static void For_UpdateThrReadTime (long ThrCod,
time_t CreatTimeUTCOfTheMostRecentPostRead) time_t CreatTimeUTCOfTheMostRecentPostRead)
{ {
/***** Insert or replace pair ThrCod-UsrCod in forum_thr_read *****/ /***** Insert or replace pair ThrCod-UsrCod in forum_thr_read *****/
DB_BuildQuery ("REPLACE INTO forum_thr_read" DB_QueryREPLACE ("can not update the status of reading"
" (ThrCod,UsrCod,ReadTime)" " of a thread of a forum",
" VALUES" "REPLACE INTO forum_thr_read"
" (%ld,%ld,FROM_UNIXTIME(%ld))", " (ThrCod,UsrCod,ReadTime)"
ThrCod,Gbl.Usrs.Me.UsrDat.UsrCod, " VALUES"
(long) CreatTimeUTCOfTheMostRecentPostRead); " (%ld,%ld,FROM_UNIXTIME(%ld))",
DB_QueryREPLACE_new ("can not update the status of reading of a thread of a forum"); ThrCod,Gbl.Usrs.Me.UsrDat.UsrCod,
(long) CreatTimeUTCOfTheMostRecentPostRead);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -4466,12 +4467,12 @@ static void For_InsertThrInClipboard (long ThrCod)
For_RemoveExpiredThrsClipboards (); For_RemoveExpiredThrsClipboards ();
/***** Add thread to my clipboard *****/ /***** Add thread to my clipboard *****/
DB_BuildQuery ("REPLACE INTO forum_thr_clip" DB_QueryREPLACE ("can not add thread to clipboard",
" (ThrCod,UsrCod)" "REPLACE INTO forum_thr_clip"
" VALUES" " (ThrCod,UsrCod)"
" (%ld,%ld)", " VALUES"
ThrCod,Gbl.Usrs.Me.UsrDat.UsrCod); " (%ld,%ld)",
DB_QueryREPLACE_new ("can not add thread to clipboard"); ThrCod,Gbl.Usrs.Me.UsrDat.UsrCod);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -1687,14 +1687,14 @@ Inf_InfoSrc_t Inf_ConvertFromStrDBToInfoSrc (const char *StrInfoSrcDB)
static void Inf_SetInfoTxtIntoDB (const char *InfoTxtHTML,const char *InfoTxtMD) static void Inf_SetInfoTxtIntoDB (const char *InfoTxtHTML,const char *InfoTxtMD)
{ {
/***** Insert or replace info source for a specific type of course information *****/ /***** Insert or replace info source for a specific type of course information *****/
DB_BuildQuery ("REPLACE INTO crs_info_txt" DB_QueryREPLACE ("can not update info text",
" (CrsCod,InfoType,InfoTxtHTML,InfoTxtMD)" "REPLACE INTO crs_info_txt"
" VALUES" " (CrsCod,InfoType,InfoTxtHTML,InfoTxtMD)"
" (%ld,'%s','%s','%s')", " VALUES"
Gbl.CurrentCrs.Crs.CrsCod, " (%ld,'%s','%s','%s')",
Inf_NamesInDBForInfoType[Gbl.CurrentCrs.Info.Type], Gbl.CurrentCrs.Crs.CrsCod,
InfoTxtHTML,InfoTxtMD); Inf_NamesInDBForInfoType[Gbl.CurrentCrs.Info.Type],
DB_QueryREPLACE_new ("can not update info text"); InfoTxtHTML,InfoTxtMD);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -1496,10 +1496,10 @@ static void Mai_RemoveEmail (struct UsrData *UsrDat)
static void Mai_RemoveEmailFromDB (long UsrCod,const char Email[Cns_MAX_BYTES_EMAIL_ADDRESS + 1]) static void Mai_RemoveEmailFromDB (long UsrCod,const char Email[Cns_MAX_BYTES_EMAIL_ADDRESS + 1])
{ {
/***** Remove an old email address *****/ /***** Remove an old email address *****/
DB_BuildQuery ("DELETE FROM usr_emails" DB_QueryREPLACE ("can not remove an old email address",
" WHERE UsrCod=%ld AND E_mail='%s'", "DELETE FROM usr_emails"
UsrCod,Email); " WHERE UsrCod=%ld AND E_mail='%s'",
DB_QueryREPLACE_new ("can not remove an old email address"); UsrCod,Email);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -1650,12 +1650,12 @@ bool Mai_UpdateEmailInDB (const struct UsrData *UsrDat,const char NewEmail[Cns_M
DB_QueryDELETE_new ("can not remove not confirmed email for other users"); DB_QueryDELETE_new ("can not remove not confirmed email for other users");
/***** Update email in database *****/ /***** Update email in database *****/
DB_BuildQuery ("REPLACE INTO usr_emails" DB_QueryREPLACE ("can not update email",
" (UsrCod,E_mail,CreatTime)" "REPLACE INTO usr_emails"
" VALUES" " (UsrCod,E_mail,CreatTime)"
" (%ld,'%s',NOW())", " VALUES"
UsrDat->UsrCod,NewEmail); " (%ld,'%s',NOW())",
DB_QueryREPLACE_new ("can not update email"); UsrDat->UsrCod,NewEmail);
return true; // Successfully updated return true; // Successfully updated
} }
@ -1781,14 +1781,14 @@ static void Mai_InsertMailKey (const char Email[Cns_MAX_BYTES_EMAIL_ADDRESS + 1]
DB_QueryDELETE_new ("can not remove old pending mail keys"); DB_QueryDELETE_new ("can not remove old pending mail keys");
/***** Insert mail key in database *****/ /***** Insert mail key in database *****/
DB_BuildQuery ("INSERT INTO pending_emails" DB_QueryREPLACE ("can not create pending password",
" (UsrCod,E_mail,MailKey,DateAndTime)" "INSERT INTO pending_emails"
" VALUES" " (UsrCod,E_mail,MailKey,DateAndTime)"
" (%ld,'%s','%s',NOW())", " VALUES"
Gbl.Usrs.Me.UsrDat.UsrCod, " (%ld,'%s','%s',NOW())",
Email, Gbl.Usrs.Me.UsrDat.UsrCod,
MailKey); Email,
DB_QueryREPLACE_new ("can not create pending password"); MailKey);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -3646,12 +3646,12 @@ void Msg_BanSenderWhenShowingMsgs (void)
Lay_ShowErrorAndExit ("Sender does not exist."); Lay_ShowErrorAndExit ("Sender does not exist.");
/***** Insert pair (sender's code - my code) in table of banned senders if not inserted *****/ /***** Insert pair (sender's code - my code) in table of banned senders if not inserted *****/
DB_BuildQuery ("REPLACE INTO msg_banned" DB_QueryREPLACE ("can not ban sender",
" (FromUsrCod,ToUsrCod)" "REPLACE INTO msg_banned"
" VALUES" " (FromUsrCod,ToUsrCod)"
" (%ld,%ld)", " VALUES"
Gbl.Usrs.Other.UsrDat.UsrCod,Gbl.Usrs.Me.UsrDat.UsrCod); " (%ld,%ld)",
DB_QueryREPLACE_new ("can not ban sender"); Gbl.Usrs.Other.UsrDat.UsrCod,Gbl.Usrs.Me.UsrDat.UsrCod);
/***** Show alert with the change made *****/ /***** Show alert with the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),

View File

@ -399,17 +399,15 @@ static void Net_GetMyWebsAndSocialNetsFromForm (void)
/***** Get URL *****/ /***** Get URL *****/
Par_GetParToText ("URL",URL,Cns_MAX_BYTES_WWW); Par_GetParToText ("URL",URL,Cns_MAX_BYTES_WWW);
if (URL[0]) if (URL[0])
{
/***** Insert or replace web / social network *****/ /***** Insert or replace web / social network *****/
DB_BuildQuery ("REPLACE INTO usr_webs" DB_QueryREPLACE ("can not update user's web / social network",
" (UsrCod,Web,URL)" "REPLACE INTO usr_webs"
" VALUES" " (UsrCod,Web,URL)"
" (%ld,'%s','%s')", " VALUES"
Gbl.Usrs.Me.UsrDat.UsrCod, " (%ld,'%s','%s')",
Net_WebsAndSocialNetworksDB[Web], Gbl.Usrs.Me.UsrDat.UsrCod,
URL); Net_WebsAndSocialNetworksDB[Web],
DB_QueryREPLACE_new ("can not update user's web / social network"); URL);
}
else else
{ {
/***** Remove web / social network *****/ /***** Remove web / social network *****/

View File

@ -500,10 +500,10 @@ void Nck_RemoveOtherUsrNick (void)
static void Nck_RemoveNicknameFromDB (long UsrCod,const char *Nickname) static void Nck_RemoveNicknameFromDB (long UsrCod,const char *Nickname)
{ {
/***** Remove a nickname *****/ /***** Remove a nickname *****/
DB_BuildQuery ("DELETE FROM usr_nicknames" DB_QueryREPLACE ("can not remove a nickname",
" WHERE UsrCod=%ld AND Nickname='%s'", "DELETE FROM usr_nicknames"
UsrCod,Nickname); " WHERE UsrCod=%ld AND Nickname='%s'",
DB_QueryREPLACE_new ("can not remove a nickname"); UsrCod,Nickname);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -633,10 +633,10 @@ static void Nck_UpdateUsrNick (struct UsrData *UsrDat)
void Nck_UpdateNickInDB (long UsrCod,const char *NewNickname) void Nck_UpdateNickInDB (long UsrCod,const char *NewNickname)
{ {
/***** Update user's nickname in database *****/ /***** Update user's nickname in database *****/
DB_BuildQuery ("REPLACE INTO usr_nicknames" DB_QueryREPLACE ("can not update nickname",
" (UsrCod,Nickname,CreatTime)" "REPLACE INTO usr_nicknames"
" VALUES" " (UsrCod,Nickname,CreatTime)"
" (%ld,'%s',NOW())", " VALUES"
UsrCod,NewNickname); " (%ld,'%s',NOW())",
DB_QueryREPLACE_new ("can not update nickname"); UsrCod,NewNickname);
} }

View File

@ -1889,14 +1889,14 @@ static void Ntf_UpdateNumNotifSent (long DegCod,long CrsCod,
Ntf_GetNumNotifSent (DegCod,CrsCod,NotifyEvent,&CurrentNumEvents,&CurrentNumMails); Ntf_GetNumNotifSent (DegCod,CrsCod,NotifyEvent,&CurrentNumEvents,&CurrentNumMails);
/***** Update number of users notified *****/ /***** Update number of users notified *****/
DB_BuildQuery ("REPLACE INTO sta_notif" DB_QueryREPLACE ("can not update the number of sent notifications",
" (DegCod,CrsCod,NotifyEvent,NumEvents,NumMails)" "REPLACE INTO sta_notif"
" VALUES" " (DegCod,CrsCod,NotifyEvent,NumEvents,NumMails)"
" (%ld,%ld,%u,%u,%u)", " VALUES"
DegCod,CrsCod,(unsigned) NotifyEvent, " (%ld,%ld,%u,%u,%u)",
CurrentNumEvents + NumEvents, DegCod,CrsCod,(unsigned) NotifyEvent,
CurrentNumMails + NumMails); CurrentNumEvents + NumEvents,
DB_QueryREPLACE_new ("can not update the number of sent notifications"); CurrentNumMails + NumMails);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -519,12 +519,12 @@ void Pwd_SetMyPendingPassword (char PlainPassword[Pwd_MAX_BYTES_PLAIN_PASSWORD +
DB_QueryDELETE_new ("can not remove expired pending passwords"); DB_QueryDELETE_new ("can not remove expired pending passwords");
/***** Update my current password in database *****/ /***** Update my current password in database *****/
DB_BuildQuery ("REPLACE INTO pending_passwd" DB_QueryREPLACE ("can not create pending password",
" (UsrCod,PendingPassword,DateAndTime)" "REPLACE INTO pending_passwd"
" VALUES" " (UsrCod,PendingPassword,DateAndTime)"
" (%ld,'%s',NOW())", " VALUES"
Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Usrs.Me.PendingPassword); " (%ld,'%s',NOW())",
DB_QueryREPLACE_new ("can not create pending password"); Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Usrs.Me.PendingPassword);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -2398,14 +2398,14 @@ static void Pho_UpdateDegStats (long DegCod,Usr_Sex_t Sex,unsigned NumStds,unsig
{ {
extern const char *Usr_StringsSexDB[Usr_NUM_SEXS]; extern const char *Usr_StringsSexDB[Usr_NUM_SEXS];
DB_BuildQuery ("REPLACE INTO sta_degrees" DB_QueryREPLACE ("can not save stats of a degree",
" (DegCod,Sex,NumStds,NumStdsWithPhoto," "REPLACE INTO sta_degrees"
"TimeAvgPhoto,TimeToComputeAvgPhoto)" " (DegCod,Sex,NumStds,NumStdsWithPhoto,"
" VALUES" "TimeAvgPhoto,TimeToComputeAvgPhoto)"
" (%ld,'%s',%u,%u,NOW(),%ld)", " VALUES"
DegCod,Usr_StringsSexDB[Sex],NumStds,NumStdsWithPhoto, " (%ld,'%s',%u,%u,NOW(),%ld)",
TimeToComputeAvgPhotoInMicroseconds); DegCod,Usr_StringsSexDB[Sex],NumStds,NumStdsWithPhoto,
DB_QueryREPLACE_new ("can not save stats of a degree"); TimeToComputeAvgPhotoInMicroseconds);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -178,20 +178,20 @@ void Pre_SetPrefsFromIP (void)
extern const char *Ico_IconSetId[Ico_NUM_ICON_SETS]; extern const char *Ico_IconSetId[Ico_NUM_ICON_SETS];
/***** Update preferences from current IP in database *****/ /***** Update preferences from current IP in database *****/
DB_BuildQuery ("REPLACE INTO IP_prefs" DB_QueryREPLACE ("can not store preferences from current IP address",
" (IP,UsrCod,LastChange," "REPLACE INTO IP_prefs"
"FirstDayOfWeek,DateFormat,Theme,IconSet,Menu,SideCols)" " (IP,UsrCod,LastChange,"
" VALUES" "FirstDayOfWeek,DateFormat,Theme,IconSet,Menu,SideCols)"
" ('%s',%ld,NOW()," " VALUES"
"%u,%u,'%s','%s',%u,%u)", " ('%s',%ld,NOW(),"
Gbl.IP,Gbl.Usrs.Me.UsrDat.UsrCod, "%u,%u,'%s','%s',%u,%u)",
Gbl.Prefs.FirstDayOfWeek, Gbl.IP,Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) Gbl.Prefs.DateFormat, Gbl.Prefs.FirstDayOfWeek,
The_ThemeId[Gbl.Prefs.Theme], (unsigned) Gbl.Prefs.DateFormat,
Ico_IconSetId[Gbl.Prefs.IconSet], The_ThemeId[Gbl.Prefs.Theme],
(unsigned) Gbl.Prefs.Menu, Ico_IconSetId[Gbl.Prefs.IconSet],
Gbl.Prefs.SideCols); (unsigned) Gbl.Prefs.Menu,
DB_QueryREPLACE_new ("can not store preferences from current IP address"); Gbl.Prefs.SideCols);
/***** If a user is logged, update its preferences in database for all its IP's *****/ /***** If a user is logged, update its preferences in database for all its IP's *****/
if (Gbl.Usrs.Me.Logged) if (Gbl.Usrs.Me.Logged)

View File

@ -1968,13 +1968,13 @@ static void Prj_AddUsrToProject (Prj_RoleInProject_t RoleInProject)
Usr_GetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat); Usr_GetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat);
/* Add user to project */ /* Add user to project */
DB_BuildQuery ("REPLACE INTO prj_usr" DB_QueryREPLACE ("can not add user to project",
" (PrjCod,RoleInProject,UsrCod)" "REPLACE INTO prj_usr"
" VALUES" " (PrjCod,RoleInProject,UsrCod)"
" (%ld,%u,%ld)", " VALUES"
PrjCod,(unsigned) RoleInProject, " (%ld,%u,%ld)",
Gbl.Usrs.Other.UsrDat.UsrCod); PrjCod,(unsigned) RoleInProject,
DB_QueryREPLACE_new ("can not add user to project"); Gbl.Usrs.Other.UsrDat.UsrCod);
/***** Flush cache *****/ /***** Flush cache *****/
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod); ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);

View File

@ -734,13 +734,13 @@ static void Tst_SetTstStatus (unsigned NumTst,Tst_Status_t TstStatus)
DB_QueryDELETE_new ("can not remove old status of tests"); DB_QueryDELETE_new ("can not remove old status of tests");
/***** Update database *****/ /***** Update database *****/
DB_BuildQuery ("REPLACE INTO tst_status" DB_QueryREPLACE ("can not update status of test",
" (SessionId,CrsCod,NumTst,Status)" "REPLACE INTO tst_status"
" VALUES" " (SessionId,CrsCod,NumTst,Status)"
" ('%s',%ld,%u,%u)", " VALUES"
Gbl.Session.Id,Gbl.CurrentCrs.Crs.CrsCod, " ('%s',%ld,%u,%u)",
NumTst,(unsigned) TstStatus); Gbl.Session.Id,Gbl.CurrentCrs.Crs.CrsCod,
DB_QueryREPLACE_new ("can not update status of test"); NumTst,(unsigned) TstStatus);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -2257,16 +2257,16 @@ void Tst_ReceiveConfigTst (void)
Gbl.Test.Config.Feedback = Tst_GetFeedbackTypeFromForm (); Gbl.Test.Config.Feedback = Tst_GetFeedbackTypeFromForm ();
/***** Update database *****/ /***** Update database *****/
DB_BuildQuery ("REPLACE INTO tst_config" DB_QueryREPLACE ("can not save configuration of tests",
" (CrsCod,Pluggable,Min,Def,Max,MinTimeNxtTstPerQst,Feedback)" "REPLACE INTO tst_config"
" VALUES" " (CrsCod,Pluggable,Min,Def,Max,MinTimeNxtTstPerQst,Feedback)"
" (%ld,'%s',%u,%u,%u,'%lu','%s')", " VALUES"
Gbl.CurrentCrs.Crs.CrsCod, " (%ld,'%s',%u,%u,%u,'%lu','%s')",
Tst_PluggableDB[Gbl.Test.Config.Pluggable], Gbl.CurrentCrs.Crs.CrsCod,
Gbl.Test.Config.Min,Gbl.Test.Config.Def,Gbl.Test.Config.Max, Tst_PluggableDB[Gbl.Test.Config.Pluggable],
Gbl.Test.Config.MinTimeNxtTstPerQst, Gbl.Test.Config.Min,Gbl.Test.Config.Def,Gbl.Test.Config.Max,
Tst_FeedbackDB[Gbl.Test.Config.Feedback]); Gbl.Test.Config.MinTimeNxtTstPerQst,
DB_QueryREPLACE_new ("can not save configuration of tests"); Tst_FeedbackDB[Gbl.Test.Config.Feedback]);
/***** Show confirmation message *****/ /***** Show confirmation message *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_The_test_configuration_has_been_updated); Ale_ShowAlert (Ale_SUCCESS,Txt_The_test_configuration_has_been_updated);