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)
{
/***** Remove one of my user's IDs *****/
DB_BuildQuery ("DELETE FROM usr_IDs"
" WHERE UsrCod=%ld AND UsrID='%s'",
UsrCod,UsrID);
DB_QueryREPLACE_new ("can not remove a user's ID");
DB_QueryREPLACE ("can not remove a user's ID",
"DELETE FROM usr_IDs"
" WHERE UsrCod=%ld AND UsrID='%s'",
UsrCod,UsrID);
}
/*****************************************************************************/

View File

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

View File

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

View File

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

View File

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

View File

@ -3069,8 +3069,8 @@ void DB_CloseDBConnection (void)
void DB_BuildQuery (const char *fmt,...)
{
int NumBytesPrinted;
va_list ap;
int NumBytesPrinted;
if (Gbl.DB.QueryPtr != NULL)
Lay_ShowErrorAndExit ("Error building query.");
@ -3087,8 +3087,8 @@ void DB_BuildQuery (const char *fmt,...)
void DB_BuildQuery_old (char **Query,const char *fmt,...)
{
int NumBytesPrinted;
va_list ap;
int NumBytesPrinted;
if (*Query != NULL)
Lay_ShowErrorAndExit ("Error building query.");
@ -3103,22 +3103,6 @@ void DB_BuildQuery_old (char **Query,const char *fmt,...)
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 **********************/
/*****************************************************************************/
@ -3126,8 +3110,8 @@ static void DB_QueryPrintf (char **strp,const char *fmt,...)
unsigned long DB_QuerySELECT (MYSQL_RES **mysql_res,const char *MsgError,
const char *fmt,...)
{
int NumBytesPrinted;
va_list ap;
int NumBytesPrinted;
char *Query = NULL;
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,
const char *fmt,...)
{
int NumBytesPrinted;
va_list ap;
int NumBytesPrinted;
char *Query = NULL;
va_start (ap,fmt);
@ -3284,19 +3268,31 @@ long DB_QueryINSERTandReturnCode_new (const char *MsgError)
/******************** 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;
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
does point to an allocated string *****/
if (Gbl.DB.QueryPtr == NULL)
if (Query == 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;
Result = mysql_query (&Gbl.mysql,Query); // Returns 0 on success
free ((void *) Query);
Query = NULL;
if (Result)
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);
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_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
{
/***** Insert or replace administrator in current institution/centre/degree *****/
DB_BuildQuery ("REPLACE INTO admin"
" (UsrCod,Scope,Cod)"
" VALUES"
" (%ld,'%s',%ld)",
UsrDat->UsrCod,Sco_ScopeDB[Scope],Cod);
DB_QueryREPLACE_new ("can not create administrator");
DB_QueryREPLACE ("can not create administrator",
"REPLACE INTO admin"
" (UsrCod,Scope,Cod)"
" VALUES"
" (%ld,'%s',%ld)",
UsrDat->UsrCod,Sco_ScopeDB[Scope],Cod);
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
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 ();
/***** Update size of the file browser in database *****/
DB_BuildQuery ("REPLACE INTO file_browser_size"
" (FileBrowser,Cod,ZoneUsrCod,"
"NumLevels,NumFolders,NumFiles,TotalSize)"
" VALUES"
" (%u,%ld,%ld,"
"%u,'%lu','%lu','%llu')",
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],Cod,ZoneUsrCod,
Gbl.FileBrowser.Size.NumLevls,
Gbl.FileBrowser.Size.NumFolds,
Gbl.FileBrowser.Size.NumFiles,
Gbl.FileBrowser.Size.TotalSiz);
DB_QueryREPLACE_new ("can not store the size of a file browser");
DB_QueryREPLACE ("can not store the size of a file browser",
"REPLACE INTO file_browser_size"
" (FileBrowser,Cod,ZoneUsrCod,"
"NumLevels,NumFolders,NumFiles,TotalSize)"
" VALUES"
" (%u,%ld,%ld,"
"%u,'%lu','%lu','%llu')",
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
Cod,ZoneUsrCod,
Gbl.FileBrowser.Size.NumLevls,
Gbl.FileBrowser.Size.NumFolds,
Gbl.FileBrowser.Size.NumFiles,
Gbl.FileBrowser.Size.TotalSiz);
}
/*****************************************************************************/
@ -5551,14 +5552,14 @@ static void Brw_GetAndUpdateDateLastAccFileBrowser (void)
DB_FreeMySQLResult (&mysql_res);
/***** Update date of my last access to file browser in this course *****/
DB_BuildQuery ("REPLACE INTO file_browser_last"
" (UsrCod,FileBrowser,Cod,LastClick)"
" VALUES"
" (%ld,%u,%ld,NOW())",
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) Brw_FileBrowserForDB_file_browser_last[Gbl.FileBrowser.Type],
Cod);
DB_QueryREPLACE_new ("can not update date of last access to a file browser");
DB_QueryREPLACE ("can not update date of last access to a file browser",
"REPLACE INTO file_browser_last"
" (UsrCod,FileBrowser,Cod,LastClick)"
" VALUES"
" (%ld,%u,%ld,NOW())",
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) Brw_FileBrowserForDB_file_browser_last[Gbl.FileBrowser.Type],
Cod);
}
/*****************************************************************************/

View File

@ -1014,13 +1014,13 @@ void Fol_FollowUsr1 (void)
Gbl.Usrs.Other.UsrDat.UsrCod))
{
/***** Follow user in database *****/
DB_BuildQuery ("REPLACE INTO usr_follow"
" (FollowerCod,FollowedCod,FollowTime)"
" VALUES"
" (%ld,%ld,NOW())",
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Other.UsrDat.UsrCod);
DB_QueryREPLACE_new ("can not follow user");
DB_QueryREPLACE ("can not follow user",
"REPLACE INTO usr_follow"
" (FollowerCod,FollowedCod,FollowTime)"
" VALUES"
" (%ld,%ld,NOW())",
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Other.UsrDat.UsrCod);
/***** This follow must be notified by email? *****/
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
if (Fol_CheckUsrIsFollowerOf (Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Other.UsrDat.UsrCod))
{
/***** Unfollow user in database *****/
DB_BuildQuery ("DELETE FROM usr_follow"
" WHERE FollowerCod=%ld AND FollowedCod=%ld",
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Other.UsrDat.UsrCod);
DB_QueryREPLACE_new ("can not unfollow user");
}
DB_QueryREPLACE ("can not unfollow user",
"DELETE FROM usr_follow"
" WHERE FollowerCod=%ld AND FollowedCod=%ld",
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Other.UsrDat.UsrCod);
Gbl.Alert.Type = Ale_SUCCESS;
}
else

View File

@ -481,12 +481,12 @@ static void For_DeletePstFromDisabledPstTable (long PstCod)
static void For_InsertPstIntoBannedPstTable (long PstCod)
{
/***** Remove post from banned posts table *****/
DB_BuildQuery ("REPLACE INTO forum_disabled_post"
" (PstCod,UsrCod,DisableTime)"
" VALUES"
" (%ld,%ld,NOW())",
PstCod,Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryREPLACE_new ("can not ban a post of a forum");
DB_QueryREPLACE ("can not ban a post of a forum",
"REPLACE INTO forum_disabled_post"
" (PstCod,UsrCod,DisableTime)"
" VALUES"
" (%ld,%ld,NOW())",
PstCod,Gbl.Usrs.Me.UsrDat.UsrCod);
}
/*****************************************************************************/
@ -771,13 +771,14 @@ static void For_UpdateThrReadTime (long ThrCod,
time_t CreatTimeUTCOfTheMostRecentPostRead)
{
/***** Insert or replace pair ThrCod-UsrCod in forum_thr_read *****/
DB_BuildQuery ("REPLACE INTO forum_thr_read"
" (ThrCod,UsrCod,ReadTime)"
" VALUES"
" (%ld,%ld,FROM_UNIXTIME(%ld))",
ThrCod,Gbl.Usrs.Me.UsrDat.UsrCod,
(long) CreatTimeUTCOfTheMostRecentPostRead);
DB_QueryREPLACE_new ("can not update the status of reading of a thread of a forum");
DB_QueryREPLACE ("can not update the status of reading"
" of a thread of a forum",
"REPLACE INTO forum_thr_read"
" (ThrCod,UsrCod,ReadTime)"
" VALUES"
" (%ld,%ld,FROM_UNIXTIME(%ld))",
ThrCod,Gbl.Usrs.Me.UsrDat.UsrCod,
(long) CreatTimeUTCOfTheMostRecentPostRead);
}
/*****************************************************************************/
@ -4466,12 +4467,12 @@ static void For_InsertThrInClipboard (long ThrCod)
For_RemoveExpiredThrsClipboards ();
/***** Add thread to my clipboard *****/
DB_BuildQuery ("REPLACE INTO forum_thr_clip"
" (ThrCod,UsrCod)"
" VALUES"
" (%ld,%ld)",
ThrCod,Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryREPLACE_new ("can not add thread to clipboard");
DB_QueryREPLACE ("can not add thread to clipboard",
"REPLACE INTO forum_thr_clip"
" (ThrCod,UsrCod)"
" VALUES"
" (%ld,%ld)",
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)
{
/***** Insert or replace info source for a specific type of course information *****/
DB_BuildQuery ("REPLACE INTO crs_info_txt"
" (CrsCod,InfoType,InfoTxtHTML,InfoTxtMD)"
" VALUES"
" (%ld,'%s','%s','%s')",
Gbl.CurrentCrs.Crs.CrsCod,
Inf_NamesInDBForInfoType[Gbl.CurrentCrs.Info.Type],
InfoTxtHTML,InfoTxtMD);
DB_QueryREPLACE_new ("can not update info text");
DB_QueryREPLACE ("can not update info text",
"REPLACE INTO crs_info_txt"
" (CrsCod,InfoType,InfoTxtHTML,InfoTxtMD)"
" VALUES"
" (%ld,'%s','%s','%s')",
Gbl.CurrentCrs.Crs.CrsCod,
Inf_NamesInDBForInfoType[Gbl.CurrentCrs.Info.Type],
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])
{
/***** Remove an old email address *****/
DB_BuildQuery ("DELETE FROM usr_emails"
" WHERE UsrCod=%ld AND E_mail='%s'",
UsrCod,Email);
DB_QueryREPLACE_new ("can not remove an old email address");
DB_QueryREPLACE ("can not remove an old email address",
"DELETE FROM usr_emails"
" WHERE UsrCod=%ld AND E_mail='%s'",
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");
/***** Update email in database *****/
DB_BuildQuery ("REPLACE INTO usr_emails"
" (UsrCod,E_mail,CreatTime)"
" VALUES"
" (%ld,'%s',NOW())",
UsrDat->UsrCod,NewEmail);
DB_QueryREPLACE_new ("can not update email");
DB_QueryREPLACE ("can not update email",
"REPLACE INTO usr_emails"
" (UsrCod,E_mail,CreatTime)"
" VALUES"
" (%ld,'%s',NOW())",
UsrDat->UsrCod,NewEmail);
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");
/***** Insert mail key in database *****/
DB_BuildQuery ("INSERT INTO pending_emails"
" (UsrCod,E_mail,MailKey,DateAndTime)"
" VALUES"
" (%ld,'%s','%s',NOW())",
Gbl.Usrs.Me.UsrDat.UsrCod,
Email,
MailKey);
DB_QueryREPLACE_new ("can not create pending password");
DB_QueryREPLACE ("can not create pending password",
"INSERT INTO pending_emails"
" (UsrCod,E_mail,MailKey,DateAndTime)"
" VALUES"
" (%ld,'%s','%s',NOW())",
Gbl.Usrs.Me.UsrDat.UsrCod,
Email,
MailKey);
}
/*****************************************************************************/

View File

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

View File

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

View File

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

View File

@ -1889,14 +1889,14 @@ static void Ntf_UpdateNumNotifSent (long DegCod,long CrsCod,
Ntf_GetNumNotifSent (DegCod,CrsCod,NotifyEvent,&CurrentNumEvents,&CurrentNumMails);
/***** Update number of users notified *****/
DB_BuildQuery ("REPLACE INTO sta_notif"
" (DegCod,CrsCod,NotifyEvent,NumEvents,NumMails)"
" VALUES"
" (%ld,%ld,%u,%u,%u)",
DegCod,CrsCod,(unsigned) NotifyEvent,
CurrentNumEvents + NumEvents,
CurrentNumMails + NumMails);
DB_QueryREPLACE_new ("can not update the number of sent notifications");
DB_QueryREPLACE ("can not update the number of sent notifications",
"REPLACE INTO sta_notif"
" (DegCod,CrsCod,NotifyEvent,NumEvents,NumMails)"
" VALUES"
" (%ld,%ld,%u,%u,%u)",
DegCod,CrsCod,(unsigned) NotifyEvent,
CurrentNumEvents + NumEvents,
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");
/***** Update my current password in database *****/
DB_BuildQuery ("REPLACE INTO pending_passwd"
" (UsrCod,PendingPassword,DateAndTime)"
" VALUES"
" (%ld,'%s',NOW())",
Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Usrs.Me.PendingPassword);
DB_QueryREPLACE_new ("can not create pending password");
DB_QueryREPLACE ("can not create pending password",
"REPLACE INTO pending_passwd"
" (UsrCod,PendingPassword,DateAndTime)"
" VALUES"
" (%ld,'%s',NOW())",
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];
DB_BuildQuery ("REPLACE INTO sta_degrees"
" (DegCod,Sex,NumStds,NumStdsWithPhoto,"
"TimeAvgPhoto,TimeToComputeAvgPhoto)"
" VALUES"
" (%ld,'%s',%u,%u,NOW(),%ld)",
DegCod,Usr_StringsSexDB[Sex],NumStds,NumStdsWithPhoto,
TimeToComputeAvgPhotoInMicroseconds);
DB_QueryREPLACE_new ("can not save stats of a degree");
DB_QueryREPLACE ("can not save stats of a degree",
"REPLACE INTO sta_degrees"
" (DegCod,Sex,NumStds,NumStdsWithPhoto,"
"TimeAvgPhoto,TimeToComputeAvgPhoto)"
" VALUES"
" (%ld,'%s',%u,%u,NOW(),%ld)",
DegCod,Usr_StringsSexDB[Sex],NumStds,NumStdsWithPhoto,
TimeToComputeAvgPhotoInMicroseconds);
}
/*****************************************************************************/

View File

@ -178,20 +178,20 @@ void Pre_SetPrefsFromIP (void)
extern const char *Ico_IconSetId[Ico_NUM_ICON_SETS];
/***** Update preferences from current IP in database *****/
DB_BuildQuery ("REPLACE INTO IP_prefs"
" (IP,UsrCod,LastChange,"
"FirstDayOfWeek,DateFormat,Theme,IconSet,Menu,SideCols)"
" VALUES"
" ('%s',%ld,NOW(),"
"%u,%u,'%s','%s',%u,%u)",
Gbl.IP,Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Prefs.FirstDayOfWeek,
(unsigned) Gbl.Prefs.DateFormat,
The_ThemeId[Gbl.Prefs.Theme],
Ico_IconSetId[Gbl.Prefs.IconSet],
(unsigned) Gbl.Prefs.Menu,
Gbl.Prefs.SideCols);
DB_QueryREPLACE_new ("can not store preferences from current IP address");
DB_QueryREPLACE ("can not store preferences from current IP address",
"REPLACE INTO IP_prefs"
" (IP,UsrCod,LastChange,"
"FirstDayOfWeek,DateFormat,Theme,IconSet,Menu,SideCols)"
" VALUES"
" ('%s',%ld,NOW(),"
"%u,%u,'%s','%s',%u,%u)",
Gbl.IP,Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Prefs.FirstDayOfWeek,
(unsigned) Gbl.Prefs.DateFormat,
The_ThemeId[Gbl.Prefs.Theme],
Ico_IconSetId[Gbl.Prefs.IconSet],
(unsigned) Gbl.Prefs.Menu,
Gbl.Prefs.SideCols);
/***** If a user is logged, update its preferences in database for all its IP's *****/
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);
/* Add user to project */
DB_BuildQuery ("REPLACE INTO prj_usr"
" (PrjCod,RoleInProject,UsrCod)"
" VALUES"
" (%ld,%u,%ld)",
PrjCod,(unsigned) RoleInProject,
Gbl.Usrs.Other.UsrDat.UsrCod);
DB_QueryREPLACE_new ("can not add user to project");
DB_QueryREPLACE ("can not add user to project",
"REPLACE INTO prj_usr"
" (PrjCod,RoleInProject,UsrCod)"
" VALUES"
" (%ld,%u,%ld)",
PrjCod,(unsigned) RoleInProject,
Gbl.Usrs.Other.UsrDat.UsrCod);
/***** Flush cache *****/
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");
/***** Update database *****/
DB_BuildQuery ("REPLACE INTO tst_status"
" (SessionId,CrsCod,NumTst,Status)"
" VALUES"
" ('%s',%ld,%u,%u)",
Gbl.Session.Id,Gbl.CurrentCrs.Crs.CrsCod,
NumTst,(unsigned) TstStatus);
DB_QueryREPLACE_new ("can not update status of test");
DB_QueryREPLACE ("can not update status of test",
"REPLACE INTO tst_status"
" (SessionId,CrsCod,NumTst,Status)"
" VALUES"
" ('%s',%ld,%u,%u)",
Gbl.Session.Id,Gbl.CurrentCrs.Crs.CrsCod,
NumTst,(unsigned) TstStatus);
}
/*****************************************************************************/
@ -2257,16 +2257,16 @@ void Tst_ReceiveConfigTst (void)
Gbl.Test.Config.Feedback = Tst_GetFeedbackTypeFromForm ();
/***** Update database *****/
DB_BuildQuery ("REPLACE INTO tst_config"
" (CrsCod,Pluggable,Min,Def,Max,MinTimeNxtTstPerQst,Feedback)"
" VALUES"
" (%ld,'%s',%u,%u,%u,'%lu','%s')",
Gbl.CurrentCrs.Crs.CrsCod,
Tst_PluggableDB[Gbl.Test.Config.Pluggable],
Gbl.Test.Config.Min,Gbl.Test.Config.Def,Gbl.Test.Config.Max,
Gbl.Test.Config.MinTimeNxtTstPerQst,
Tst_FeedbackDB[Gbl.Test.Config.Feedback]);
DB_QueryREPLACE_new ("can not save configuration of tests");
DB_QueryREPLACE ("can not save configuration of tests",
"REPLACE INTO tst_config"
" (CrsCod,Pluggable,Min,Def,Max,MinTimeNxtTstPerQst,Feedback)"
" VALUES"
" (%ld,'%s',%u,%u,%u,'%lu','%s')",
Gbl.CurrentCrs.Crs.CrsCod,
Tst_PluggableDB[Gbl.Test.Config.Pluggable],
Gbl.Test.Config.Min,Gbl.Test.Config.Def,Gbl.Test.Config.Max,
Gbl.Test.Config.MinTimeNxtTstPerQst,
Tst_FeedbackDB[Gbl.Test.Config.Feedback]);
/***** Show confirmation message *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_The_test_configuration_has_been_updated);