Version 18.8.14

This commit is contained in:
Antonio Cañas Vargas 2018-10-28 01:25:31 +02:00
parent b60c71b5a6
commit 24c1e20c59
27 changed files with 352 additions and 551 deletions

View File

@ -332,7 +332,6 @@ void MFU_WriteSmallMFUActions (struct MFU_ListMFUActions *ListMFUActions)
void MFU_UpdateMFUActions (void)
{
char *Query;
MYSQL_RES *mysql_res;
MYSQL_ROW row;
float Score;
@ -380,12 +379,11 @@ void MFU_UpdateMFUActions (void)
DB_QueryREPLACE_new ("can not update most frequently used actions");
/***** Update score for other actions *****/
if (asprintf (&Query,"UPDATE actions_MFU SET Score=GREATEST(Score*'%f','%f')"
" WHERE UsrCod=%ld AND ActCod<>%ld",
MFU_DECREASE_FACTOR,MFU_MIN_SCORE,
Gbl.Usrs.Me.UsrDat.UsrCod,ActCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update most frequently used actions");
DB_BuildQuery ("UPDATE actions_MFU SET Score=GREATEST(Score*'%f','%f')"
" WHERE UsrCod=%ld AND ActCod<>%ld",
MFU_DECREASE_FACTOR,MFU_MIN_SCORE,
Gbl.Usrs.Me.UsrDat.UsrCod,ActCod);
DB_QueryUPDATE_new ("can not update most frequently used actions");
Str_SetDecimalPointToLocal (); // Return to local system
}

View File

@ -355,10 +355,11 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
#define Log_PLATFORM_VERSION "SWAD 18.8.13 (2018-10-27)"
#define Log_PLATFORM_VERSION "SWAD 18.8.14 (2018-10-28)"
#define CSS_FILE "swad18.4.css"
#define JS_FILE "swad17.17.1.js"
/*
Version 18.8.14: Oct 28, 2018 Some asprintf for database queries changed by internal function. (236493 lines)
Version 18.8.13: Oct 27, 2018 Some asprintf for database queries changed by internal function. (236661 lines)
Version 18.8.12: Oct 27, 2018 Some asprintf for database queries changed by internal function. (236870 lines)
Version 18.8.11: Oct 27, 2018 Some asprintf for database queries changed by internal function. (236921 lines)

View File

@ -2607,14 +2607,11 @@ static void Crs_UpdateCrsYear (struct Course *Crs,unsigned NewYear)
void Crs_UpdateInstitutionalCrsCod (struct Course *Crs,const char *NewInstitutionalCrsCod)
{
char *Query;
/***** Update institutional course code in table of courses *****/
if (asprintf (&Query,"UPDATE courses SET InsCrsCod='%s' WHERE CrsCod=%ld",
NewInstitutionalCrsCod,Crs->CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the institutional code"
" of the current course");
DB_BuildQuery ("UPDATE courses SET InsCrsCod='%s' WHERE CrsCod=%ld",
NewInstitutionalCrsCod,Crs->CrsCod);
DB_QueryUPDATE_new ("can not update the institutional code"
" of the current course");
/***** Copy institutional course code *****/
Str_Copy (Crs->InstitutionalCrsCod,NewInstitutionalCrsCod,

View File

@ -3300,20 +3300,6 @@ void DB_QueryUPDATE_new (const char *MsgError)
//return (unsigned long) mysql_affected_rows (&Gbl.mysql);
}
void DB_QueryUPDATE_free (const char *Query,const char *MsgError)
{
int Result;
/***** Query database *****/
Result = mysql_query (&Gbl.mysql,Query); // Returns 0 on success
free ((void *) Query);
if (Result)
DB_ExitOnMySQLError (MsgError);
/***** Return number of rows updated *****/
//return (unsigned long) mysql_affected_rows (&Gbl.mysql);
}
void DB_QueryUPDATE (const char *Query,const char *MsgError)
{
/***** Query database *****/

View File

@ -55,7 +55,6 @@ void DB_QueryREPLACE_new (const char *MsgError);
void DB_QueryREPLACE (const char *Query,const char *MsgError);
void DB_QueryUPDATE_new (const char *MsgError);
void DB_QueryUPDATE_free (const char *Query,const char *MsgError);
void DB_QueryUPDATE (const char *Query,const char *MsgError);
void DB_QueryDELETE_new (const char *MsgError);

View File

@ -679,7 +679,6 @@ void Hld_RemoveHoliday2 (void)
void Hld_ChangeHolidayPlace1 (void)
{
extern const char *Txt_The_place_of_the_holiday_X_has_changed_to_Y;
char *Query;
struct Holiday *Hld;
struct Place NewPlace;
@ -700,10 +699,9 @@ void Hld_ChangeHolidayPlace1 (void)
Hld_GetDataOfHolidayByCod (Hld);
/***** Update the place in database *****/
if (asprintf (&Query,"UPDATE holidays SET PlcCod=%ld WHERE HldCod=%ld",
NewPlace.PlcCod,Hld->HldCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the place of a holiday");
DB_BuildQuery ("UPDATE holidays SET PlcCod=%ld WHERE HldCod=%ld",
NewPlace.PlcCod,Hld->HldCod);
DB_QueryUPDATE_new ("can not update the place of a holiday");
Hld->PlcCod = NewPlace.PlcCod;
Str_Copy (Hld->PlaceFullName,NewPlace.FullName,
Plc_MAX_BYTES_PLACE_FULL_NAME);
@ -731,7 +729,6 @@ void Hld_ChangeHolidayPlace2 (void)
void Hld_ChangeHolidayType1 (void)
{
extern const char *Txt_The_type_of_the_holiday_X_has_changed;
char *Query;
struct Holiday *Hld;
Hld = &Gbl.Hlds.EditingHld;
@ -748,11 +745,10 @@ void Hld_ChangeHolidayType1 (void)
/***** Update holiday/no school period in database *****/
Dat_AssignDate (&Hld->EndDate,&Hld->StartDate);
if (asprintf (&Query,"UPDATE holidays SET HldTyp=%u,EndDate=StartDate"
" WHERE HldCod=%ld",
(unsigned) Hld->HldTyp,Hld->HldCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the type of a holiday");
DB_BuildQuery ("UPDATE holidays SET HldTyp=%u,EndDate=StartDate"
" WHERE HldCod=%ld",
(unsigned) Hld->HldTyp,Hld->HldCod);
DB_QueryUPDATE_new ("can not update the type of a holiday");
/***** Write message to show the change made *****/
Gbl.Alert.Type = Ale_SUCCESS;
@ -795,7 +791,6 @@ void Hld_ChangeEndDate1 (void)
static void Hld_ChangeDate (Hld_StartOrEndDate_t StartOrEndDate)
{
extern const char *Txt_The_date_of_the_holiday_X_has_changed_to_Y;
char *Query;
struct Holiday *Hld;
struct Date NewDate;
struct Date *PtrDate = NULL; // Initialized to avoid warning
@ -845,14 +840,13 @@ static void Hld_ChangeDate (Hld_StartOrEndDate_t StartOrEndDate)
}
/***** Update the date in database *****/
if (asprintf (&Query,"UPDATE holidays SET %s='%04u%02u%02u' WHERE HldCod=%ld",
StrStartOrEndDate,
NewDate.Year,
NewDate.Month,
NewDate.Day,
Hld->HldCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the date of a holiday");
DB_BuildQuery ("UPDATE holidays SET %s='%04u%02u%02u' WHERE HldCod=%ld",
StrStartOrEndDate,
NewDate.Year,
NewDate.Month,
NewDate.Day,
Hld->HldCod);
DB_QueryUPDATE_new ("can not update the date of a holiday");
Dat_AssignDate (PtrDate,&NewDate);
/***** Write message to show the change made *****/
@ -885,7 +879,6 @@ void Hld_RenameHoliday1 (void)
extern const char *Txt_You_can_not_leave_the_name_of_the_holiday_X_empty;
extern const char *Txt_The_name_of_the_holiday_X_has_changed_to_Y;
extern const char *Txt_The_name_of_the_holiday_X_has_not_changed;
char *Query;
struct Holiday *Hld;
char NewHldName[Hld_MAX_BYTES_HOLIDAY_NAME + 1];
@ -917,10 +910,9 @@ void Hld_RenameHoliday1 (void)
{
/***** If degree was in database... *****/
/* Update the table changing old name by new name */
if (asprintf (&Query,"UPDATE holidays SET Name='%s' WHERE HldCod=%ld",
NewHldName,Hld->HldCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the text of a holiday");
DB_BuildQuery ("UPDATE holidays SET Name='%s' WHERE HldCod=%ld",
NewHldName,Hld->HldCod);
DB_QueryUPDATE_new ("can not update the text of a holiday");
Str_Copy (Hld->Name,NewHldName,
Hld_MAX_BYTES_HOLIDAY_NAME);

View File

@ -122,8 +122,6 @@ static void Ico_PutIconsIconSet (void)
void Ico_ChangeIconSet (void)
{
char *Query;
/***** Get param with icon set *****/
Gbl.Prefs.IconSet = Ico_GetParamIconSet ();
snprintf (Gbl.Prefs.PathIconSet,sizeof (Gbl.Prefs.PathIconSet),
@ -135,11 +133,10 @@ void Ico_ChangeIconSet (void)
/***** Store icon set in database *****/
if (Gbl.Usrs.Me.Logged)
{
if (asprintf (&Query,"UPDATE usr_data SET IconSet='%s' WHERE UsrCod=%ld",
Ico_IconSetId[Gbl.Prefs.IconSet],
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update your preference about icon set");
DB_BuildQuery ("UPDATE usr_data SET IconSet='%s' WHERE UsrCod=%ld",
Ico_IconSetId[Gbl.Prefs.IconSet],
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE_new ("can not update your preference about icon set");
}
/***** Set preferences from current IP *****/

View File

@ -1417,13 +1417,10 @@ int Ind_GetNumIndicatorsCrsFromDB (long CrsCod)
static void Ind_StoreIndicatorsCrsIntoDB (long CrsCod,unsigned NumIndicators)
{
char *Query;
/***** Store number of indicators of a course in database *****/
if (asprintf (&Query,"UPDATE courses SET NumIndicators=%u WHERE CrsCod=%ld",
NumIndicators,CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not store number of indicators of a course");
DB_BuildQuery ("UPDATE courses SET NumIndicators=%u WHERE CrsCod=%ld",
NumIndicators,CrsCod);
DB_QueryUPDATE_new ("can not store number of indicators of a course");
}
/*****************************************************************************/

View File

@ -695,16 +695,14 @@ static bool Inf_GetIfIHaveReadFromForm (void)
static void Inf_SetForceReadIntoDB (bool MustBeRead)
{
char *Query;
/***** Insert or replace info source for a specific type of course information *****/
if (asprintf (&Query,"UPDATE crs_info_src SET MustBeRead='%c'"
" WHERE CrsCod=%ld AND InfoType='%s'",
MustBeRead ? 'Y' :
'N',
Gbl.CurrentCrs.Crs.CrsCod,Inf_NamesInDBForInfoType[Gbl.CurrentCrs.Info.Type]) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update if info must be read");
DB_BuildQuery ("UPDATE crs_info_src SET MustBeRead='%c'"
" WHERE CrsCod=%ld AND InfoType='%s'",
MustBeRead ? 'Y' :
'N',
Gbl.CurrentCrs.Crs.CrsCod,
Inf_NamesInDBForInfoType[Gbl.CurrentCrs.Info.Type]);
DB_QueryUPDATE_new ("can not update if info must be read");
}
/*****************************************************************************/
@ -713,31 +711,27 @@ static void Inf_SetForceReadIntoDB (bool MustBeRead)
static void Inf_SetIHaveReadIntoDB (bool IHaveRead)
{
char *Query;
if (IHaveRead)
{
/***** Insert I have read course information *****/
if (asprintf (&Query,"REPLACE INTO crs_info_read"
" (UsrCod,CrsCod,InfoType)"
" VALUES"
" (%ld,%ld,'%s')",
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.CurrentCrs.Crs.CrsCod,
Inf_NamesInDBForInfoType[Gbl.CurrentCrs.Info.Type]) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not set that I have read course info");
DB_BuildQuery ("REPLACE INTO crs_info_read"
" (UsrCod,CrsCod,InfoType)"
" VALUES"
" (%ld,%ld,'%s')",
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.CurrentCrs.Crs.CrsCod,
Inf_NamesInDBForInfoType[Gbl.CurrentCrs.Info.Type]);
DB_QueryUPDATE_new ("can not set that I have read course info");
}
else
{
/***** Remove I have read course information *****/
if (asprintf (&Query,"DELETE FROM crs_info_read"
" WHERE UsrCod=%ld AND CrsCod=%ld AND InfoType='%s'",
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.CurrentCrs.Crs.CrsCod,
Inf_NamesInDBForInfoType[Gbl.CurrentCrs.Info.Type]) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryDELETE_free (Query,"can not set that I have not read course info");
DB_BuildQuery ("DELETE FROM crs_info_read"
" WHERE UsrCod=%ld AND CrsCod=%ld AND InfoType='%s'",
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.CurrentCrs.Crs.CrsCod,
Inf_NamesInDBForInfoType[Gbl.CurrentCrs.Info.Type]);
DB_QueryDELETE_new ("can not set that I have not read course info");
}
}
@ -1486,35 +1480,26 @@ Inf_InfoSrc_t Inf_GetInfoSrcFromForm (void)
void Inf_SetInfoSrcIntoDB (Inf_InfoSrc_t InfoSrc)
{
char *Query;
/***** Get if info source is already stored in database *****/
if (asprintf (&Query,"SELECT COUNT(*) FROM crs_info_src"
" WHERE CrsCod=%ld AND InfoType='%s'",
Gbl.CurrentCrs.Crs.CrsCod,
Inf_NamesInDBForInfoType[Gbl.CurrentCrs.Info.Type]) < 0)
Lay_NotEnoughMemoryExit ();
if (DB_QueryCOUNT (Query,"can not get if info source is already stored in database")) // Info is already stored in database, so update it
DB_BuildQuery ("SELECT COUNT(*) FROM crs_info_src"
" WHERE CrsCod=%ld AND InfoType='%s'",
Gbl.CurrentCrs.Crs.CrsCod,
Inf_NamesInDBForInfoType[Gbl.CurrentCrs.Info.Type]);
if (DB_QueryCOUNT_new ("can not get if info source is already stored in database")) // Info is already stored in database, so update it
{ // Update info source
if (InfoSrc == Inf_INFO_SRC_NONE)
{
if (asprintf (&Query,"UPDATE crs_info_src SET InfoSrc='%s',MustBeRead='N'"
" WHERE CrsCod=%ld AND InfoType='%s'",
Inf_NamesInDBForInfoSrc[Inf_INFO_SRC_NONE],
Gbl.CurrentCrs.Crs.CrsCod,
Inf_NamesInDBForInfoType[Gbl.CurrentCrs.Info.Type]) < 0)
Lay_NotEnoughMemoryExit ();
}
DB_BuildQuery ("UPDATE crs_info_src SET InfoSrc='%s',MustBeRead='N'"
" WHERE CrsCod=%ld AND InfoType='%s'",
Inf_NamesInDBForInfoSrc[Inf_INFO_SRC_NONE],
Gbl.CurrentCrs.Crs.CrsCod,
Inf_NamesInDBForInfoType[Gbl.CurrentCrs.Info.Type]);
else // MustBeRead remains unchanged
{
if (asprintf (&Query,"UPDATE crs_info_src SET InfoSrc='%s'"
" WHERE CrsCod=%ld AND InfoType='%s'",
Inf_NamesInDBForInfoSrc[InfoSrc],
Gbl.CurrentCrs.Crs.CrsCod,
Inf_NamesInDBForInfoType[Gbl.CurrentCrs.Info.Type]) < 0)
Lay_NotEnoughMemoryExit ();
}
DB_QueryUPDATE_free (Query,"can not update info source");
DB_BuildQuery ("UPDATE crs_info_src SET InfoSrc='%s'"
" WHERE CrsCod=%ld AND InfoType='%s'",
Inf_NamesInDBForInfoSrc[InfoSrc],
Gbl.CurrentCrs.Crs.CrsCod,
Inf_NamesInDBForInfoType[Gbl.CurrentCrs.Info.Type]);
DB_QueryUPDATE_new ("can not update info source");
}
else // Info is not stored in database, so insert it
{

View File

@ -1876,13 +1876,10 @@ static bool Ins_CheckIfInsNameExistsInCty (const char *FieldName,const char *Nam
static void Ins_UpdateInsNameDB (long InsCod,const char *FieldName,const char *NewInsName)
{
char *Query;
/***** Update institution changing old name by new name */
if (asprintf (&Query,"UPDATE institutions SET %s='%s' WHERE InsCod=%ld",
FieldName,NewInsName,InsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the name of an institution");
DB_BuildQuery ("UPDATE institutions SET %s='%s' WHERE InsCod=%ld",
FieldName,NewInsName,InsCod);
DB_QueryUPDATE_new ("can not update the name of an institution");
/***** Flush caches *****/
Ins_FlushCacheShortNameOfInstitution ();
@ -1961,13 +1958,10 @@ void Ins_ContEditAfterChgInsInConfig (void)
static void Ins_UpdateInsCtyDB (long InsCod,long CtyCod)
{
char *Query;
/***** Update country in table of institutions *****/
if (asprintf (&Query,"UPDATE institutions SET CtyCod=%ld WHERE InsCod=%ld",
CtyCod,InsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the country of an institution");
DB_BuildQuery ("UPDATE institutions SET CtyCod=%ld WHERE InsCod=%ld",
CtyCod,InsCod);
DB_QueryUPDATE_new ("can not update the country of an institution");
}
/*****************************************************************************/
@ -2050,13 +2044,10 @@ void Ins_ChangeInsWWWInConfig (void)
static void Ins_UpdateInsWWWDB (long InsCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1])
{
char *Query;
/***** Update database changing old WWW by new WWW *****/
if (asprintf (&Query,"UPDATE institutions SET WWW='%s' WHERE InsCod=%ld",
NewWWW,InsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the web of an institution");
DB_BuildQuery ("UPDATE institutions SET WWW='%s' WHERE InsCod=%ld",
NewWWW,InsCod);
DB_QueryUPDATE_new ("can not update the web of an institution");
}
/*****************************************************************************/
@ -2066,7 +2057,6 @@ static void Ins_UpdateInsWWWDB (long InsCod,const char NewWWW[Cns_MAX_BYTES_WWW
void Ins_ChangeInsStatus (void)
{
extern const char *Txt_The_status_of_the_institution_X_has_changed;
char *Query;
Ins_Status_t Status;
Ins_StatusTxt_t StatusTxt;
@ -2089,10 +2079,9 @@ void Ins_ChangeInsStatus (void)
Ins_GetDataOfInstitutionByCod (&Gbl.Inss.EditingIns,Ins_GET_BASIC_DATA);
/***** Update status in table of institutions *****/
if (asprintf (&Query,"UPDATE institutions SET Status=%u WHERE InsCod=%ld",
(unsigned) Status,Gbl.Inss.EditingIns.InsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the status of an institution");
DB_BuildQuery ("UPDATE institutions SET Status=%u WHERE InsCod=%ld",
(unsigned) Status,Gbl.Inss.EditingIns.InsCod);
DB_QueryUPDATE_new ("can not update the status of an institution");
Gbl.Inss.EditingIns.Status = Status;
/***** Write message to show the change made

View File

@ -179,17 +179,15 @@ void Lan_ChangeLanguage (void)
void Lan_UpdateMyLanguageToCurrentLanguage (void)
{
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
char *Query;
/***** Set my language to the current language *****/
Gbl.Usrs.Me.UsrDat.Prefs.Language = Gbl.Prefs.Language;
/***** Update my language in database *****/
if (asprintf (&Query,"UPDATE usr_data SET Language='%s' WHERE UsrCod=%ld",
DB_BuildQuery ("UPDATE usr_data SET Language='%s' WHERE UsrCod=%ld",
Txt_STR_LANG_ID[Gbl.Prefs.Language],
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update your language");
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE_new ("can not update your language");
}
/*****************************************************************************/

View File

@ -642,13 +642,10 @@ static bool Lnk_CheckIfLinkNameExists (const char *FieldName,const char *Name,lo
static void Lnk_UpdateLnkNameDB (long LnkCod,const char *FieldName,const char *NewLnkName)
{
char *Query;
/***** Update institutional link changing old name by new name */
if (asprintf (&Query,"UPDATE links SET %s='%s' WHERE LnkCod=%ld",
FieldName,NewLnkName,LnkCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the name of an institutional link");
DB_BuildQuery ("UPDATE links SET %s='%s' WHERE LnkCod=%ld",
FieldName,NewLnkName,LnkCod);
DB_QueryUPDATE_new ("can not update the name of an institutional link");
}
/*****************************************************************************/
@ -660,7 +657,6 @@ void Lnk_ChangeLinkWWW (void)
extern const char *Txt_The_new_web_address_is_X;
extern const char *Txt_You_can_not_leave_the_web_address_empty;
struct Link *Lnk;
char *Query;
char NewWWW[Cns_MAX_BYTES_WWW + 1];
Lnk = &Gbl.Links.EditingLnk;
@ -677,10 +673,9 @@ void Lnk_ChangeLinkWWW (void)
if (NewWWW[0])
{
/* Update the table changing old WWW by new WWW */
if (asprintf (&Query,"UPDATE links SET WWW='%s' WHERE LnkCod=%ld",
NewWWW,Lnk->LnkCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the web of an institutional link");
DB_BuildQuery ("UPDATE links SET WWW='%s' WHERE LnkCod=%ld",
NewWWW,Lnk->LnkCod);
DB_QueryUPDATE_new ("can not update the web of an institutional link");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),

View File

@ -703,13 +703,10 @@ static bool Mai_CheckIfMailDomainNameExists (const char *FieldName,const char *N
static void Mai_UpdateMailDomainNameDB (long MaiCod,const char *FieldName,const char *NewMaiName)
{
char *Query;
/***** Update mail domain changing old name by new name */
if (asprintf (&Query,"UPDATE mail_domains SET %s='%s' WHERE MaiCod=%ld",
FieldName,NewMaiName,MaiCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the name of a mail domain");
DB_BuildQuery ("UPDATE mail_domains SET %s='%s' WHERE MaiCod=%ld",
FieldName,NewMaiName,MaiCod);
DB_QueryUPDATE_new ("can not update the name of a mail domain");
}
/*****************************************************************************/
@ -1861,12 +1858,11 @@ void Mai_ConfirmEmail (void)
Email);
else
{
if (asprintf (&Query,"UPDATE usr_emails SET Confirmed='Y'"
" WHERE usr_emails.UsrCod=%ld"
" AND usr_emails.E_mail='%s'",
UsrCod,Email) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not confirm email");
DB_BuildQuery ("UPDATE usr_emails SET Confirmed='Y'"
" WHERE usr_emails.UsrCod=%ld"
" AND usr_emails.E_mail='%s'",
UsrCod,Email);
DB_QueryUPDATE_new ("can not confirm email");
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
Txt_The_email_X_has_been_confirmed,

View File

@ -257,7 +257,6 @@ static void Mrk_ChangeNumRowsHeaderOrFooter (Brw_HeadOrFoot_t HeaderOrFooter)
extern const char *Txt_The_number_of_rows_is_now_X;
char UnsignedStr[10 + 1];
long Cod;
char *Query;
unsigned NumRows;
/***** Get parameters related to file browser *****/
@ -269,16 +268,15 @@ static void Mrk_ChangeNumRowsHeaderOrFooter (Brw_HeadOrFoot_t HeaderOrFooter)
{
/***** Update properties of marks in the database *****/
Cod = Brw_GetCodForFiles ();
if (asprintf (&Query,"UPDATE marks_properties,files"
" SET marks_properties.%s=%u"
" WHERE files.FileBrowser=%u AND files.Cod=%ld AND files.Path='%s'"
" AND files.FilCod=marks_properties.FilCod",
Mrk_HeadOrFootStr[HeaderOrFooter],NumRows,
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
Cod,
Gbl.FileBrowser.Priv.FullPathInTree) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update properties of marks");
DB_BuildQuery ("UPDATE marks_properties,files"
" SET marks_properties.%s=%u"
" WHERE files.FileBrowser=%u AND files.Cod=%ld AND files.Path='%s'"
" AND files.FilCod=marks_properties.FilCod",
Mrk_HeadOrFootStr[HeaderOrFooter],NumRows,
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
Cod,
Gbl.FileBrowser.Priv.FullPathInTree);
DB_QueryUPDATE_new ("can not update properties of marks");
/***** Write message of success *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),

View File

@ -455,18 +455,15 @@ static void Mnu_PutIconsMenu (void)
void Mnu_ChangeMenu (void)
{
char *Query;
/***** Get param with menu *****/
Gbl.Prefs.Menu = Mnu_GetParamMenu ();
/***** Store menu in database *****/
if (Gbl.Usrs.Me.Logged)
{
if (asprintf (&Query,"UPDATE usr_data SET Menu=%u WHERE UsrCod=%ld",
(unsigned) Gbl.Prefs.Menu,Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update your preference about menu");
DB_BuildQuery ("UPDATE usr_data SET Menu=%u WHERE UsrCod=%ld",
(unsigned) Gbl.Prefs.Menu,Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE_new ("can not update your preference about menu");
}
/***** Set preferences from current IP *****/

View File

@ -180,13 +180,10 @@ static long Not_InsertNoticeInDB (const char *Content)
static void Not_UpdateNumUsrsNotifiedByEMailAboutNotice (long NotCod,unsigned NumUsrsToBeNotifiedByEMail)
{
char *Query;
/***** Update number of users notified *****/
if (asprintf (&Query,"UPDATE notices SET NumNotif=%u WHERE NotCod=%ld",
NumUsrsToBeNotifiedByEMail,NotCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the number of notifications of a notice");
DB_BuildQuery ("UPDATE notices SET NumNotif=%u WHERE NotCod=%ld",
NumUsrsToBeNotifiedByEMail,NotCod);
DB_QueryUPDATE_new ("can not update the number of notifications of a notice");
}
/*****************************************************************************/
@ -224,19 +221,17 @@ void Not_ListFullNotices (void)
void Not_HideActiveNotice (void)
{
char *Query;
long NotCod;
/***** Get the code of the notice to hide *****/
NotCod = Not_GetParamNotCod ();
/***** Set notice as hidden *****/
if (asprintf (&Query,"UPDATE notices SET Status=%u"
" WHERE NotCod=%ld AND CrsCod=%ld",
(unsigned) Not_OBSOLETE_NOTICE,
NotCod,Gbl.CurrentCrs.Crs.CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not hide notice");
DB_BuildQuery ("UPDATE notices SET Status=%u"
" WHERE NotCod=%ld AND CrsCod=%ld",
(unsigned) Not_OBSOLETE_NOTICE,
NotCod,Gbl.CurrentCrs.Crs.CrsCod);
DB_QueryUPDATE_new ("can not hide notice");
/***** Update RSS of current course *****/
RSS_UpdateRSSFileForACrs (&Gbl.CurrentCrs.Crs);
@ -248,19 +243,17 @@ void Not_HideActiveNotice (void)
void Not_RevealHiddenNotice (void)
{
char *Query;
long NotCod;
/***** Get the code of the notice to reveal *****/
NotCod = Not_GetParamNotCod ();
/***** Set notice as active *****/
if (asprintf (&Query,"UPDATE notices SET Status=%u"
" WHERE NotCod=%ld AND CrsCod=%ld",
(unsigned) Not_ACTIVE_NOTICE,
NotCod,Gbl.CurrentCrs.Crs.CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not reveal notice");
DB_BuildQuery ("UPDATE notices SET Status=%u"
" WHERE NotCod=%ld AND CrsCod=%ld",
(unsigned) Not_ACTIVE_NOTICE,
NotCod,Gbl.CurrentCrs.Crs.CrsCod);
DB_QueryUPDATE_new ("can not reveal notice");
/***** Update RSS of current course *****/
RSS_UpdateRSSFileForACrs (&Gbl.CurrentCrs.Crs);

View File

@ -953,36 +953,25 @@ void Ntf_GetNotifSummaryAndContent (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
void Ntf_MarkNotifAsSeen (Ntf_NotifyEvent_t NotifyEvent,long Cod,long CrsCod,long ToUsrCod)
{
char *Query;
/***** Set notification as seen by me *****/
if (ToUsrCod > 0) // If the user code is specified
{
if (Cod > 0) // Set only one notification for the user as seen
{
if (asprintf (&Query,"UPDATE notif SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld AND NotifyEvent=%u AND Cod=%ld",
(unsigned) Ntf_STATUS_BIT_READ,
ToUsrCod,(unsigned) NotifyEvent,Cod) < 0)
Lay_NotEnoughMemoryExit ();
}
DB_BuildQuery ("UPDATE notif SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld AND NotifyEvent=%u AND Cod=%ld",
(unsigned) Ntf_STATUS_BIT_READ,
ToUsrCod,(unsigned) NotifyEvent,Cod);
else if (CrsCod > 0) // Set all notifications of this type in the current course for the user as seen
{
if (asprintf (&Query,"UPDATE notif SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld AND NotifyEvent=%u AND CrsCod=%ld",
(unsigned) Ntf_STATUS_BIT_READ,
ToUsrCod,(unsigned) NotifyEvent,Gbl.CurrentCrs.Crs.CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
}
DB_BuildQuery ("UPDATE notif SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld AND NotifyEvent=%u AND CrsCod=%ld",
(unsigned) Ntf_STATUS_BIT_READ,
ToUsrCod,(unsigned) NotifyEvent,Gbl.CurrentCrs.Crs.CrsCod);
else // Set all notifications of this type for the user as seen
{
if (asprintf (&Query,"UPDATE notif SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld AND NotifyEvent=%u",
(unsigned) Ntf_STATUS_BIT_READ,
ToUsrCod,(unsigned) NotifyEvent) < 0)
Lay_NotEnoughMemoryExit ();
}
DB_QueryUPDATE_free (Query,"can not set notification(s) as seen");
DB_BuildQuery ("UPDATE notif SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld AND NotifyEvent=%u",
(unsigned) Ntf_STATUS_BIT_READ,
ToUsrCod,(unsigned) NotifyEvent);
DB_QueryUPDATE_new ("can not set notification(s) as seen");
}
}
@ -992,15 +981,12 @@ void Ntf_MarkNotifAsSeen (Ntf_NotifyEvent_t NotifyEvent,long Cod,long CrsCod,lon
void Ntf_MarkNotifAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod)
{
char *Query;
/***** Set notification as removed *****/
if (asprintf (&Query,"UPDATE notif SET Status=(Status | %u)"
" WHERE NotifyEvent=%u AND Cod=%ld",
(unsigned) Ntf_STATUS_BIT_REMOVED,
(unsigned) NotifyEvent,Cod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not set notification(s) as removed");
DB_BuildQuery ("UPDATE notif SET Status=(Status | %u)"
" WHERE NotifyEvent=%u AND Cod=%ld",
(unsigned) Ntf_STATUS_BIT_REMOVED,
(unsigned) NotifyEvent,Cod);
DB_QueryUPDATE_new ("can not set notification(s) as removed");
}
/*****************************************************************************/
@ -1009,26 +995,18 @@ void Ntf_MarkNotifAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod)
void Ntf_MarkNotifToOneUsrAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod,long ToUsrCod)
{
char *Query;
/***** Set notification as removed *****/
if (Cod > 0) // Set only one notification as removed
{
if (asprintf (&Query,"UPDATE notif SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld AND NotifyEvent=%u AND Cod=%ld",
(unsigned) Ntf_STATUS_BIT_REMOVED,
ToUsrCod,(unsigned) NotifyEvent,Cod) < 0)
Lay_NotEnoughMemoryExit ();
}
DB_BuildQuery ("UPDATE notif SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld AND NotifyEvent=%u AND Cod=%ld",
(unsigned) Ntf_STATUS_BIT_REMOVED,
ToUsrCod,(unsigned) NotifyEvent,Cod);
else // Set all notifications of this type, in the current course for the user, as removed
{
if (asprintf (&Query,"UPDATE notif SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld AND NotifyEvent=%u AND CrsCod=%ld",
(unsigned) Ntf_STATUS_BIT_REMOVED,
ToUsrCod,(unsigned) NotifyEvent,Gbl.CurrentCrs.Crs.CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
}
DB_QueryUPDATE_free (Query,"can not set notification(s) as removed");
DB_BuildQuery ("UPDATE notif SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld AND NotifyEvent=%u AND CrsCod=%ld",
(unsigned) Ntf_STATUS_BIT_REMOVED,
ToUsrCod,(unsigned) NotifyEvent,Gbl.CurrentCrs.Crs.CrsCod);
DB_QueryUPDATE_new ("can not set notification(s) as removed");
}
/*****************************************************************************/
@ -1041,31 +1019,23 @@ void Ntf_MarkNotifToOneUsrAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod,long
void Ntf_MarkNotifInCrsAsRemoved (long ToUsrCod,long CrsCod)
{
char *Query;
/***** Set all notifications from the course as removed,
except notifications about new messages *****/
if (ToUsrCod > 0) // If the user code is specified
{
if (asprintf (&Query,"UPDATE notif SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld"
" AND CrsCod=%ld"
" AND NotifyEvent<>%u", // messages will remain available
(unsigned) Ntf_STATUS_BIT_REMOVED,
ToUsrCod,
CrsCod,(unsigned) Ntf_EVENT_MESSAGE) < 0)
Lay_NotEnoughMemoryExit ();
}
DB_BuildQuery ("UPDATE notif SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld"
" AND CrsCod=%ld"
" AND NotifyEvent<>%u", // messages will remain available
(unsigned) Ntf_STATUS_BIT_REMOVED,
ToUsrCod,
CrsCod,(unsigned) Ntf_EVENT_MESSAGE);
else // User code not specified ==> any user
{
if (asprintf (&Query,"UPDATE notif SET Status=(Status | %u)"
" WHERE CrsCod=%ld"
" AND NotifyEvent<>%u", // messages will remain available
(unsigned) Ntf_STATUS_BIT_REMOVED,
CrsCod,(unsigned) Ntf_EVENT_MESSAGE) < 0)
Lay_NotEnoughMemoryExit ();
}
DB_QueryUPDATE_free (Query,"can not set notification(s) as removed");
DB_BuildQuery ("UPDATE notif SET Status=(Status | %u)"
" WHERE CrsCod=%ld"
" AND NotifyEvent<>%u", // messages will remain available
(unsigned) Ntf_STATUS_BIT_REMOVED,
CrsCod,(unsigned) Ntf_EVENT_MESSAGE);
DB_QueryUPDATE_new ("can not set notification(s) as removed");
}
/*****************************************************************************/
@ -1132,7 +1102,6 @@ void Ntf_MarkNotifChildrenOfFolderAsRemoved (const char *Path)
extern const Brw_FileBrowser_t Brw_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
Brw_FileBrowser_t FileBrowser = Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type];
long Cod = Brw_GetCodForFiles ();
char *Query;
Ntf_NotifyEvent_t NotifyEvent;
switch (FileBrowser)
@ -1167,17 +1136,16 @@ void Ntf_MarkNotifChildrenOfFolderAsRemoved (const char *Path)
default:
return;
}
if (asprintf (&Query,"UPDATE notif SET Status=(Status | %u)"
" WHERE NotifyEvent=%u AND Cod IN"
" (SELECT FilCod FROM files"
" WHERE FileBrowser=%u AND Cod=%ld"
" AND Path LIKE '%s/%%')",
(unsigned) Ntf_STATUS_BIT_REMOVED,
(unsigned) NotifyEvent,
(unsigned) FileBrowser,Cod,
Path) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not set notification(s) as removed");
DB_BuildQuery ("UPDATE notif SET Status=(Status | %u)"
" WHERE NotifyEvent=%u AND Cod IN"
" (SELECT FilCod FROM files"
" WHERE FileBrowser=%u AND Cod=%ld"
" AND Path LIKE '%s/%%')",
(unsigned) Ntf_STATUS_BIT_REMOVED,
(unsigned) NotifyEvent,
(unsigned) FileBrowser,Cod,
Path);
DB_QueryUPDATE_new ("can not set notification(s) as removed");
break;
default:
break;
@ -1190,25 +1158,22 @@ void Ntf_MarkNotifChildrenOfFolderAsRemoved (const char *Path)
void Ntf_MarkNotifFilesInGroupAsRemoved (long GrpCod)
{
char *Query;
/***** Set notifications as removed *****/
if (asprintf (&Query,"UPDATE notif SET Status=(Status | %u)"
" WHERE NotifyEvent IN (%u,%u,%u,%u) AND Cod IN"
" (SELECT FilCod FROM files"
" WHERE FileBrowser IN (%u,%u,%u,%u) AND Cod=%ld)",
(unsigned) Ntf_STATUS_BIT_REMOVED,
(unsigned) Ntf_EVENT_DOCUMENT_FILE,
(unsigned) Ntf_EVENT_TEACHERS_FILE,
(unsigned) Ntf_EVENT_SHARED_FILE,
(unsigned) Ntf_EVENT_MARKS_FILE,
(unsigned) Brw_ADMI_DOC_GRP,
(unsigned) Brw_ADMI_TCH_GRP,
(unsigned) Brw_ADMI_SHR_GRP,
(unsigned) Brw_ADMI_MRK_GRP,
GrpCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not set notification(s) as removed");
DB_BuildQuery ("UPDATE notif SET Status=(Status | %u)"
" WHERE NotifyEvent IN (%u,%u,%u,%u) AND Cod IN"
" (SELECT FilCod FROM files"
" WHERE FileBrowser IN (%u,%u,%u,%u) AND Cod=%ld)",
(unsigned) Ntf_STATUS_BIT_REMOVED,
(unsigned) Ntf_EVENT_DOCUMENT_FILE,
(unsigned) Ntf_EVENT_TEACHERS_FILE,
(unsigned) Ntf_EVENT_SHARED_FILE,
(unsigned) Ntf_EVENT_MARKS_FILE,
(unsigned) Brw_ADMI_DOC_GRP,
(unsigned) Brw_ADMI_TCH_GRP,
(unsigned) Brw_ADMI_SHR_GRP,
(unsigned) Brw_ADMI_MRK_GRP,
GrpCod);
DB_QueryUPDATE_new ("can not set notification(s) as removed");
}
/*****************************************************************************/
@ -1528,14 +1493,11 @@ void Ntf_StoreNotifyEventToOneUser (Ntf_NotifyEvent_t NotifyEvent,
static void Ntf_UpdateMyLastAccessToNotifications (void)
{
char *Query;
/***** Reset to 0 my number of new received messages *****/
if (asprintf (&Query,"UPDATE usr_last SET LastAccNotif=NOW()"
" WHERE UsrCod=%ld",
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update last access to notifications");
DB_BuildQuery ("UPDATE usr_last SET LastAccNotif=NOW()"
" WHERE UsrCod=%ld",
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE_new ("can not update last access to notifications");
}
/*****************************************************************************/
@ -1620,7 +1582,6 @@ static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsign
extern const char *Txt_TAB_Messages_NO_HTML[1 + Txt_NUM_LANGUAGES];
extern const char *Txt_Notifications_NO_HTML[1 + Txt_NUM_LANGUAGES];
extern const char *Txt_If_you_no_longer_wish_to_receive_email_notifications_NO_HTML[1 + Txt_NUM_LANGUAGES];
char *Query;
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRow;
@ -1817,15 +1778,14 @@ static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsign
}
/***** Mark all the pending notifications of this user as 'sent' *****/
if (asprintf (&Query,"UPDATE notif SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld"
" AND (Status & %u)<>0 AND (Status & %u)=0 AND (Status & %u)=0",
(unsigned) Ntf_STATUS_BIT_SENT,ToUsrDat->UsrCod,
(unsigned) Ntf_STATUS_BIT_EMAIL,
(unsigned) Ntf_STATUS_BIT_SENT,
(unsigned) (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED)) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not set pending notifications of a user as sent");
DB_BuildQuery ("UPDATE notif SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld"
" AND (Status & %u)<>0 AND (Status & %u)=0 AND (Status & %u)=0",
(unsigned) Ntf_STATUS_BIT_SENT,ToUsrDat->UsrCod,
(unsigned) Ntf_STATUS_BIT_EMAIL,
(unsigned) Ntf_STATUS_BIT_SENT,
(unsigned) (Ntf_STATUS_BIT_READ | Ntf_STATUS_BIT_REMOVED));
DB_QueryUPDATE_new ("can not set pending notifications of a user as sent");
}
/***** Free structure that stores the query result *****/
@ -1913,15 +1873,12 @@ static void Ntf_UpdateNumNotifSent (long DegCod,long CrsCod,
void Ntf_MarkAllNotifAsSeen (void)
{
char *Query;
/***** Set all my notifications as seen *****/
if (asprintf (&Query,"UPDATE notif SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld",
(unsigned) Ntf_STATUS_BIT_READ,
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not set notification(s) as seen");
DB_BuildQuery ("UPDATE notif SET Status=(Status | %u)"
" WHERE ToUsrCod=%ld",
(unsigned) Ntf_STATUS_BIT_READ,
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE_new ("can not set notification(s) as seen");
/***** Show my notifications again *****/
Ntf_ShowMyNotifications ();
@ -2042,20 +1999,18 @@ static void Ntf_GetParamsNotifyEvents (void)
void Ntf_ChangeNotifyEvents (void)
{
extern const char *Txt_Your_preferences_about_notifications_have_changed;
char *Query;
/***** Get param with whether notify me about events *****/
Ntf_GetParamsNotifyEvents ();
/***** Store preferences about notify events *****/
if (asprintf (&Query,"UPDATE usr_data"
" SET NotifNtfEvents=%u,EmailNtfEvents=%u"
" WHERE UsrCod=%ld",
Gbl.Usrs.Me.UsrDat.Prefs.NotifNtfEvents,
Gbl.Usrs.Me.UsrDat.Prefs.EmailNtfEvents,
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update user's preferences");
DB_BuildQuery ("UPDATE usr_data"
" SET NotifNtfEvents=%u,EmailNtfEvents=%u"
" WHERE UsrCod=%ld",
Gbl.Usrs.Me.UsrDat.Prefs.NotifNtfEvents,
Gbl.Usrs.Me.UsrDat.Prefs.EmailNtfEvents,
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE_new ("can not update user's preferences");
/***** Show message *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_Your_preferences_about_notifications_have_changed);

View File

@ -800,15 +800,12 @@ unsigned Pag_GetParamPagNum (Pag_WhatPaginate_t WhatPaginate)
void Pag_SaveLastPageMsgIntoSession (Pag_WhatPaginate_t WhatPaginate,unsigned NumPage)
{
char *Query;
/***** Save last page of received/sent messages *****/
if (asprintf (&Query,"UPDATE sessions SET %s=%u WHERE SessionId='%s'",
WhatPaginate == Pag_MESSAGES_RECEIVED ? "LastPageMsgRcv" :
"LastPageMsgSnt",
NumPage,Gbl.Session.Id) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update last page of messages");
DB_BuildQuery ("UPDATE sessions SET %s=%u WHERE SessionId='%s'",
WhatPaginate == Pag_MESSAGES_RECEIVED ? "LastPageMsgRcv" :
"LastPageMsgSnt",
NumPage,Gbl.Session.Id);
DB_QueryUPDATE_new ("can not update last page of messages");
}
/*****************************************************************************/

View File

@ -145,15 +145,12 @@ bool Pwd_CheckPendingPassword (void)
void Pwd_AssignMyPendingPasswordToMyCurrentPassword (void)
{
char *Query;
/***** Update my current password in database *****/
if (asprintf (&Query,"UPDATE usr_data SET Password='%s'"
" WHERE UsrCod=%ld",
Gbl.Usrs.Me.PendingPassword,
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update your password");
DB_BuildQuery ("UPDATE usr_data SET Password='%s'"
" WHERE UsrCod=%ld",
Gbl.Usrs.Me.PendingPassword,
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE_new ("can not update your password");
/***** Update my current password *****/
Str_Copy (Gbl.Usrs.Me.UsrDat.Password,Gbl.Usrs.Me.PendingPassword,

View File

@ -977,7 +977,6 @@ static void Pho_UpdatePhoto2 (void)
unsigned Pho_UpdateMyClicksWithoutPhoto (void)
{
char *Query;
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRows;
@ -999,11 +998,10 @@ unsigned Pho_UpdateMyClicksWithoutPhoto (void)
/* Update number of clicks */
if (NumClicks <= Pho_MAX_CLICKS_WITHOUT_PHOTO)
{
if (asprintf (&Query,"UPDATE clicks_without_photo"
" SET NumClicks=NumClicks+1 WHERE UsrCod=%ld",
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update number of clicks without photo");
DB_BuildQuery ("UPDATE clicks_without_photo"
" SET NumClicks=NumClicks+1 WHERE UsrCod=%ld",
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE_new ("can not update number of clicks without photo");
NumClicks++;
}
}
@ -1190,14 +1188,9 @@ bool Pho_RemovePhoto (struct UsrData *UsrDat)
static void Pho_ClearPhotoName (long UsrCod)
{
char *Query;
/***** Clear photo name in user's data *****/
if (asprintf (&Query,"UPDATE usr_data SET Photo=''"
" WHERE UsrCod=%ld",
UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not clear the name of a user's photo");
DB_BuildQuery ("UPDATE usr_data SET Photo='' WHERE UsrCod=%ld",UsrCod);
DB_QueryUPDATE_new ("can not clear the name of a user's photo");
}
/*****************************************************************************/
@ -1206,15 +1199,12 @@ static void Pho_ClearPhotoName (long UsrCod)
void Pho_UpdatePhotoName (struct UsrData *UsrDat)
{
char *Query;
char PathPublPhoto[PATH_MAX + 1];
/***** Update photo name in database *****/
if (asprintf (&Query,"UPDATE usr_data SET Photo='%s'"
" WHERE UsrCod=%ld",
Gbl.UniqueNameEncrypted,UsrDat->UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the name of a user's photo");
DB_BuildQuery ("UPDATE usr_data SET Photo='%s' WHERE UsrCod=%ld",
Gbl.UniqueNameEncrypted,UsrDat->UsrCod);
DB_QueryUPDATE_new ("can not update the name of a user's photo");
/***** Remove the old symbolic link to photo *****/
snprintf (PathPublPhoto,sizeof (PathPublPhoto),
@ -1336,18 +1326,15 @@ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL,
void Pho_ChangePhotoVisibility (void)
{
extern const char *Pri_VisibilityDB[Pri_NUM_OPTIONS_PRIVACY];
char *Query;
/***** Get param with public/private photo *****/
Gbl.Usrs.Me.UsrDat.PhotoVisibility = Pri_GetParamVisibility ("VisPho");
/***** Store public/private photo in database *****/
if (asprintf (&Query,"UPDATE usr_data SET PhotoVisibility='%s'"
" WHERE UsrCod=%ld",
Pri_VisibilityDB[Gbl.Usrs.Me.UsrDat.PhotoVisibility],
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update your preference about photo visibility");
DB_BuildQuery ("UPDATE usr_data SET PhotoVisibility='%s' WHERE UsrCod=%ld",
Pri_VisibilityDB[Gbl.Usrs.Me.UsrDat.PhotoVisibility],
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE_new ("can not update your preference about photo visibility");
/***** Show form again *****/
Pre_EditPrefs ();

View File

@ -718,13 +718,10 @@ static bool Plc_CheckIfPlaceNameExists (const char *FieldName,const char *Name,l
static void Plc_UpdatePlcNameDB (long PlcCod,const char *FieldName,const char *NewPlcName)
{
char *Query;
/***** Update place changing old name by new name */
if (asprintf (&Query,"UPDATE places SET %s='%s' WHERE PlcCod=%ld",
FieldName,NewPlcName,PlcCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the name of a place");
DB_BuildQuery ("UPDATE places SET %s='%s' WHERE PlcCod=%ld",
FieldName,NewPlcName,PlcCod);
DB_QueryUPDATE_new ("can not update the name of a place");
}
/*****************************************************************************/

View File

@ -522,7 +522,6 @@ void Plg_RenamePlugin (void)
extern const char *Txt_The_plugin_X_already_exists;
extern const char *Txt_The_plugin_X_has_been_renamed_as_Y;
extern const char *Txt_The_name_of_the_plugin_X_has_not_changed;
char *Query;
struct Plugin *Plg;
char NewPlgName[Plg_MAX_BYTES_PLUGIN_NAME + 1];
@ -563,10 +562,9 @@ void Plg_RenamePlugin (void)
else
{
/* Update the table changing old name by new name */
if (asprintf (&Query,"UPDATE plugins SET Name='%s' WHERE PlgCod=%ld",
NewPlgName,Plg->PlgCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the name of a plugin");
DB_BuildQuery ("UPDATE plugins SET Name='%s' WHERE PlgCod=%ld",
NewPlgName,Plg->PlgCod);
DB_QueryUPDATE_new ("can not update the name of a plugin");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -612,7 +610,6 @@ void Plg_ChangePlgDescription (void)
extern const char *Txt_The_new_description_is_X;
extern const char *Txt_You_can_not_leave_the_description_empty;
struct Plugin *Plg;
char *Query;
char NewDescription[Plg_MAX_BYTES_PLUGIN_DESCRIPTION + 1];
Plg = &Gbl.Plugins.EditingPlg;
@ -629,10 +626,9 @@ void Plg_ChangePlgDescription (void)
if (NewDescription[0])
{
/* Update the table changing old description by new description */
if (asprintf (&Query,"UPDATE plugins SET Description='%s' WHERE PlgCod=%ld",
NewDescription,Plg->PlgCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the description of a plugin");
DB_BuildQuery ("UPDATE plugins SET Description='%s' WHERE PlgCod=%ld",
NewDescription,Plg->PlgCod);
DB_QueryUPDATE_new ("can not update the description of a plugin");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -658,7 +654,6 @@ void Plg_ChangePlgLogo (void)
extern const char *Txt_The_new_logo_is_X;
extern const char *Txt_You_can_not_leave_the_logo_empty;
struct Plugin *Plg;
char *Query;
char NewLogo[Plg_MAX_BYTES_PLUGIN_LOGO + 1];
Plg = &Gbl.Plugins.EditingPlg;
@ -675,10 +670,9 @@ void Plg_ChangePlgLogo (void)
if (NewLogo[0])
{
/* Update the table changing old logo by new logo */
if (asprintf (&Query,"UPDATE plugins SET Logo='%s' WHERE PlgCod=%ld",
NewLogo,Plg->PlgCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the logo of a plugin");
DB_BuildQuery ("UPDATE plugins SET Logo='%s' WHERE PlgCod=%ld",
NewLogo,Plg->PlgCod);
DB_QueryUPDATE_new ("can not update the logo of a plugin");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -704,7 +698,6 @@ void Plg_ChangePlgAppKey (void)
extern const char *Txt_The_new_logo_is_X; // TODO: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
extern const char *Txt_You_can_not_leave_the_logo_empty;// TODO: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
struct Plugin *Plg;
char *Query;
char NewAppKey[Plg_MAX_BYTES_PLUGIN_APP_KEY + 1];
Plg = &Gbl.Plugins.EditingPlg;
@ -721,10 +714,9 @@ void Plg_ChangePlgAppKey (void)
if (NewAppKey[0])
{
/* Update the table changing old application key by new application key */
if (asprintf (&Query,"UPDATE plugins SET AppKey='%s' WHERE PlgCod=%ld",
NewAppKey,Plg->PlgCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the application key of a plugin");
DB_BuildQuery ("UPDATE plugins SET AppKey='%s' WHERE PlgCod=%ld",
NewAppKey,Plg->PlgCod);
DB_QueryUPDATE_new ("can not update the application key of a plugin");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -750,7 +742,6 @@ void Plg_ChangePlgURL (void)
extern const char *Txt_The_new_URL_is_X;
extern const char *Txt_You_can_not_leave_the_URL_empty;
struct Plugin *Plg;
char *Query;
char NewURL[Cns_MAX_BYTES_WWW + 1];
Plg = &Gbl.Plugins.EditingPlg;
@ -767,10 +758,9 @@ void Plg_ChangePlgURL (void)
if (NewURL[0])
{
/* Update the table changing old WWW by new WWW */
if (asprintf (&Query,"UPDATE plugins SET URL='%s' WHERE PlgCod=%ld",
NewURL,Plg->PlgCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the URL of a plugin");
DB_BuildQuery ("UPDATE plugins SET URL='%s' WHERE PlgCod=%ld",
NewURL,Plg->PlgCod);
DB_QueryUPDATE_new ("can not update the URL of a plugin");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -796,7 +786,6 @@ void Plg_ChangePlgIP (void)
extern const char *Txt_The_new_IP_address_is_X;
extern const char *Txt_You_can_not_leave_the_IP_address_empty;
struct Plugin *Plg;
char *Query;
char NewIP[Cns_MAX_BYTES_IP + 1];
Plg = &Gbl.Plugins.EditingPlg;
@ -813,10 +802,9 @@ void Plg_ChangePlgIP (void)
if (NewIP[0])
{
/* Update the table changing old IP by new IP */
if (asprintf (&Query,"UPDATE plugins SET IP='%s' WHERE PlgCod=%ld",
NewIP,Plg->PlgCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the IP address of a plugin");
DB_BuildQuery ("UPDATE plugins SET IP='%s' WHERE PlgCod=%ld",
NewIP,Plg->PlgCod);
DB_QueryUPDATE_new ("can not update the IP address of a plugin");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),

View File

@ -352,13 +352,10 @@ void Pre_ShowRightCol (void)
static void Pre_UpdateSideColsOnUsrDataTable (void)
{
char *Query;
if (asprintf (&Query,"UPDATE usr_data SET SideCols=%u"
" WHERE UsrCod=%ld",
Gbl.Prefs.SideCols,Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update your preference about side columns");
DB_BuildQuery ("UPDATE usr_data SET SideCols=%u"
" WHERE UsrCod=%ld",
Gbl.Prefs.SideCols,Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE_new ("can not update your preference about side columns");
}
/*****************************************************************************/

View File

@ -332,18 +332,16 @@ bool Prf_ShowUserProfile (struct UsrData *UsrDat)
void Prf_ChangeProfileVisibility (void)
{
extern const char *Pri_VisibilityDB[Pri_NUM_OPTIONS_PRIVACY];
char *Query;
/***** Get param with public/private photo *****/
Gbl.Usrs.Me.UsrDat.ProfileVisibility = Pri_GetParamVisibility ("VisPrf");
/***** Store public/private photo in database *****/
if (asprintf (&Query,"UPDATE usr_data SET ProfileVisibility='%s'"
" WHERE UsrCod=%ld",
Pri_VisibilityDB[Gbl.Usrs.Me.UsrDat.ProfileVisibility],
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update your preference about public profile visibility");
DB_BuildQuery ("UPDATE usr_data SET ProfileVisibility='%s'"
" WHERE UsrCod=%ld",
Pri_VisibilityDB[Gbl.Usrs.Me.UsrDat.ProfileVisibility],
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE_new ("can not update your preference about public profile visibility");
/***** Show form again *****/
Pre_EditPrefs ();
@ -830,7 +828,6 @@ bool Prf_GetAndStoreAllUsrFigures (long UsrCod,struct UsrFigures *UsrFigures)
static void Prf_GetFirstClickFromLogAndStoreAsUsrFigure (long UsrCod)
{
char *Query;
MYSQL_RES *mysql_res;
MYSQL_ROW row;
struct UsrFigures UsrFigures;
@ -860,12 +857,11 @@ static void Prf_GetFirstClickFromLogAndStoreAsUsrFigure (long UsrCod)
/***** Update first click time in user's figures *****/
if (Prf_CheckIfUsrFiguresExists (UsrCod))
{
if (asprintf (&Query,"UPDATE usr_figures"
" SET FirstClickTime=FROM_UNIXTIME(%ld)"
" WHERE UsrCod=%ld",
(long) UsrFigures.FirstClickTimeUTC,UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update user's figures");
DB_BuildQuery ("UPDATE usr_figures"
" SET FirstClickTime=FROM_UNIXTIME(%ld)"
" WHERE UsrCod=%ld",
(long) UsrFigures.FirstClickTimeUTC,UsrCod);
DB_QueryUPDATE_new ("can not update user's figures");
}
else // User entry does not exist
Prf_CreateUsrFigures (UsrCod,&UsrFigures,false);
@ -878,7 +874,6 @@ static void Prf_GetFirstClickFromLogAndStoreAsUsrFigure (long UsrCod)
static void Prf_GetNumClicksAndStoreAsUsrFigure (long UsrCod)
{
char *Query;
struct UsrFigures UsrFigures;
if (Usr_ChkIfUsrCodExists (UsrCod))
@ -893,11 +888,10 @@ static void Prf_GetNumClicksAndStoreAsUsrFigure (long UsrCod)
/***** Update number of clicks in user's figures *****/
if (Prf_CheckIfUsrFiguresExists (UsrCod))
{
if (asprintf (&Query,"UPDATE usr_figures SET NumClicks=%ld"
" WHERE UsrCod=%ld",
UsrFigures.NumClicks,UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update user's figures");
DB_BuildQuery ("UPDATE usr_figures SET NumClicks=%ld"
" WHERE UsrCod=%ld",
UsrFigures.NumClicks,UsrCod);
DB_QueryUPDATE_new ("can not update user's figures");
}
else // User entry does not exist
Prf_CreateUsrFigures (UsrCod,&UsrFigures,false);
@ -910,7 +904,6 @@ static void Prf_GetNumClicksAndStoreAsUsrFigure (long UsrCod)
static void Prf_GetNumFileViewsAndStoreAsUsrFigure (long UsrCod)
{
char *Query;
struct UsrFigures UsrFigures;
if (Usr_ChkIfUsrCodExists (UsrCod))
@ -924,11 +917,10 @@ static void Prf_GetNumFileViewsAndStoreAsUsrFigure (long UsrCod)
/***** Update number of file views in user's figures *****/
if (Prf_CheckIfUsrFiguresExists (UsrCod))
{
if (asprintf (&Query,"UPDATE usr_figures SET NumFileViews=%ld"
" WHERE UsrCod=%ld",
UsrFigures.NumFileViews,UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update user's figures");
DB_BuildQuery ("UPDATE usr_figures SET NumFileViews=%ld"
" WHERE UsrCod=%ld",
UsrFigures.NumFileViews,UsrCod);
DB_QueryUPDATE_new ("can not update user's figures");
}
else // User entry does not exist
Prf_CreateUsrFigures (UsrCod,&UsrFigures,false);
@ -941,7 +933,6 @@ static void Prf_GetNumFileViewsAndStoreAsUsrFigure (long UsrCod)
static void Prf_GetNumForPstAndStoreAsUsrFigure (long UsrCod)
{
char *Query;
struct UsrFigures UsrFigures;
if (Usr_ChkIfUsrCodExists (UsrCod))
@ -955,11 +946,10 @@ static void Prf_GetNumForPstAndStoreAsUsrFigure (long UsrCod)
/***** Update number of forum posts in user's figures *****/
if (Prf_CheckIfUsrFiguresExists (UsrCod))
{
if (asprintf (&Query,"UPDATE usr_figures SET NumForPst=%ld"
" WHERE UsrCod=%ld",
UsrFigures.NumForPst,UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update user's figures");
DB_BuildQuery ("UPDATE usr_figures SET NumForPst=%ld"
" WHERE UsrCod=%ld",
UsrFigures.NumForPst,UsrCod);
DB_QueryUPDATE_new ("can not update user's figures");
}
else // User entry does not exist
Prf_CreateUsrFigures (UsrCod,&UsrFigures,false);
@ -972,7 +962,6 @@ static void Prf_GetNumForPstAndStoreAsUsrFigure (long UsrCod)
static void Prf_GetNumMsgSntAndStoreAsUsrFigure (long UsrCod)
{
char *Query;
struct UsrFigures UsrFigures;
if (Usr_ChkIfUsrCodExists (UsrCod))
@ -986,11 +975,10 @@ static void Prf_GetNumMsgSntAndStoreAsUsrFigure (long UsrCod)
/***** Update number of messages sent in user's figures *****/
if (Prf_CheckIfUsrFiguresExists (UsrCod))
{
if (asprintf (&Query,"UPDATE usr_figures SET NumMsgSnt=%ld"
" WHERE UsrCod=%ld",
UsrFigures.NumMsgSnt,UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update user's figures");
DB_BuildQuery ("UPDATE usr_figures SET NumMsgSnt=%ld"
" WHERE UsrCod=%ld",
UsrFigures.NumMsgSnt,UsrCod);
DB_QueryUPDATE_new ("can not update user's figures");
}
else // User entry does not exist
Prf_CreateUsrFigures (UsrCod,&UsrFigures,false);

View File

@ -2828,7 +2828,6 @@ void Prj_RemoveProject (void)
void Prj_HideProject (void)
{
extern const char *Txt_Project_X_is_now_hidden;
char *Query;
struct Project Prj;
/***** Allocate memory for the project *****/
@ -2845,11 +2844,10 @@ void Prj_HideProject (void)
if (Prj_CheckIfICanEditProject (Prj.PrjCod))
{
/***** Hide project *****/
if (asprintf (&Query,"UPDATE projects SET Hidden='Y'"
" WHERE PrjCod=%ld AND CrsCod=%ld",
Prj.PrjCod,Gbl.CurrentCrs.Crs.CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not hide project");
DB_BuildQuery ("UPDATE projects SET Hidden='Y'"
" WHERE PrjCod=%ld AND CrsCod=%ld",
Prj.PrjCod,Gbl.CurrentCrs.Crs.CrsCod);
DB_QueryUPDATE_new ("can not hide project");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -2874,7 +2872,6 @@ void Prj_HideProject (void)
void Prj_ShowProject (void)
{
extern const char *Txt_Project_X_is_now_visible;
char *Query;
struct Project Prj;
/***** Allocate memory for the project *****/
@ -2891,11 +2888,10 @@ void Prj_ShowProject (void)
if (Prj_CheckIfICanEditProject (Prj.PrjCod))
{
/***** Show project *****/
if (asprintf (&Query,"UPDATE projects SET Hidden='N'"
" WHERE PrjCod=%ld AND CrsCod=%ld",
Prj.PrjCod,Gbl.CurrentCrs.Crs.CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not show project");
DB_BuildQuery ("UPDATE projects SET Hidden='N'"
" WHERE PrjCod=%ld AND CrsCod=%ld",
Prj.PrjCod,Gbl.CurrentCrs.Crs.CrsCod);
DB_QueryUPDATE_new ("can not show project");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -3402,34 +3398,31 @@ static void Prj_CreateProject (struct Project *Prj)
static void Prj_UpdateProject (struct Project *Prj)
{
char *Query;
/***** Adjust date of last edition to now *****/
Prj->ModifTime = Gbl.StartExecutionTimeUTC;
/***** Update the data of the project *****/
if (asprintf (&Query,"UPDATE projects SET "
"DptCod=%ld,Hidden='%c',Preassigned='%c',NumStds=%u,Proposal='%s',"
"ModifTime=FROM_UNIXTIME(%ld),"
"Title='%s',"
"Description='%s',Knowledge='%s',Materials='%s',URL='%s'"
" WHERE PrjCod=%ld AND CrsCod=%ld",
Prj->DptCod,
Prj->Hidden == Prj_HIDDEN ? 'Y' :
'N',
Prj->Preassigned == Prj_PREASSIGNED ? 'Y' :
'N',
Prj->NumStds,
Prj_Proposal_DB[Prj->Proposal],
Prj->ModifTime,
Prj->Title,
Prj->Description,
Prj->Knowledge,
Prj->Materials,
Prj->URL,
Prj->PrjCod,Gbl.CurrentCrs.Crs.CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update project");
DB_BuildQuery ("UPDATE projects SET "
"DptCod=%ld,Hidden='%c',Preassigned='%c',NumStds=%u,Proposal='%s',"
"ModifTime=FROM_UNIXTIME(%ld),"
"Title='%s',"
"Description='%s',Knowledge='%s',Materials='%s',URL='%s'"
" WHERE PrjCod=%ld AND CrsCod=%ld",
Prj->DptCod,
Prj->Hidden == Prj_HIDDEN ? 'Y' :
'N',
Prj->Preassigned == Prj_PREASSIGNED ? 'Y' :
'N',
Prj->NumStds,
Prj_Proposal_DB[Prj->Proposal],
Prj->ModifTime,
Prj->Title,
Prj->Description,
Prj->Knowledge,
Prj->Materials,
Prj->URL,
Prj->PrjCod,Gbl.CurrentCrs.Crs.CrsCod);
DB_QueryUPDATE_new ("can not update project");
}
/*****************************************************************************/

View File

@ -790,7 +790,6 @@ void Rec_RenameField (void)
extern const char *Txt_The_record_field_X_already_exists;
extern const char *Txt_The_record_field_X_has_been_renamed_as_Y;
extern const char *Txt_The_name_of_the_field_X_has_not_changed;
char *Query;
char NewFieldName[Rec_MAX_BYTES_NAME_FIELD + 1];
/***** Get parameters of the form *****/
@ -832,11 +831,10 @@ void Rec_RenameField (void)
else
{
/* Update the table of fields changing then old name by the new one */
if (asprintf (&Query,"UPDATE crs_record_fields SET FieldName='%s'"
" WHERE FieldCod=%ld",
NewFieldName,Gbl.CurrentCrs.Records.Field.FieldCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update name of field of record");
DB_BuildQuery ("UPDATE crs_record_fields SET FieldName='%s'"
" WHERE FieldCod=%ld",
NewFieldName,Gbl.CurrentCrs.Records.Field.FieldCod);
DB_QueryUPDATE_new ("can not update name of field of record");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -868,7 +866,6 @@ void Rec_ChangeLinesField (void)
{
extern const char *Txt_The_number_of_editing_lines_in_the_record_field_X_has_not_changed;
extern const char *Txt_From_now_on_the_number_of_editing_lines_of_the_field_X_is_Y;
char *Query;
unsigned NewNumLines;
/***** Get parameters of the form *****/
@ -898,11 +895,10 @@ void Rec_ChangeLinesField (void)
else
{
/***** Update of the table of fields changing the old maximum of students by the new one *****/
if (asprintf (&Query,"UPDATE crs_record_fields SET NumLines=%u"
" WHERE FieldCod=%ld",
NewNumLines,Gbl.CurrentCrs.Records.Field.FieldCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the number of lines of a field of record");
DB_BuildQuery ("UPDATE crs_record_fields SET NumLines=%u"
" WHERE FieldCod=%ld",
NewNumLines,Gbl.CurrentCrs.Records.Field.FieldCod);
DB_QueryUPDATE_new ("can not update the number of lines of a field of record");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -924,7 +920,6 @@ void Rec_ChangeVisibilityField (void)
{
extern const char *Txt_The_visibility_of_the_record_field_X_has_not_changed;
extern const char *Txt_RECORD_FIELD_VISIBILITY_MSG[Rec_NUM_TYPES_VISIBILITY];
char *Query;
Rec_VisibilityRecordFields_t NewVisibility;
/***** Get parameters of the form *****/
@ -954,11 +949,10 @@ void Rec_ChangeVisibilityField (void)
else
{
/***** Update of the table of fields changing the old visibility by the new *****/
if (asprintf (&Query,"UPDATE crs_record_fields SET Visibility=%u"
" WHERE FieldCod=%ld",
(unsigned) NewVisibility,Gbl.CurrentCrs.Records.Field.FieldCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the visibility of a field of record");
DB_BuildQuery ("UPDATE crs_record_fields SET Visibility=%u"
" WHERE FieldCod=%ld",
(unsigned) NewVisibility,Gbl.CurrentCrs.Records.Field.FieldCod);
DB_QueryUPDATE_new ("can not update the visibility of a field of record");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -1985,7 +1979,6 @@ void Rec_GetFieldsCrsRecordFromForm (void)
void Rec_UpdateCrsRecord (long UsrCod)
{
unsigned NumField;
char *Query;
MYSQL_RES *mysql_res;
bool FieldAlreadyExists;
@ -2002,21 +1995,20 @@ void Rec_UpdateCrsRecord (long UsrCod)
if (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text[0])
{
/***** Update text of the field of record course *****/
if (asprintf (&Query,"UPDATE crs_records SET Txt='%s'"
" WHERE UsrCod=%ld AND FieldCod=%ld",
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text,
UsrCod,Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update field of record");
DB_BuildQuery ("UPDATE crs_records SET Txt='%s'"
" WHERE UsrCod=%ld AND FieldCod=%ld",
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text,
UsrCod,
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod);
DB_QueryUPDATE_new ("can not update field of record");
}
else
{
/***** Remove text of the field of record course *****/
if (asprintf (&Query,"DELETE FROM crs_records"
" WHERE UsrCod=%ld AND FieldCod=%ld",
UsrCod,Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryDELETE_free (Query,"can not remove field of record");
DB_BuildQuery ("DELETE FROM crs_records"
" WHERE UsrCod=%ld AND FieldCod=%ld",
UsrCod,Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod);
DB_QueryDELETE_new ("can not remove field of record");
}
}
else if (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text[0])
@ -4406,17 +4398,14 @@ void Rec_UpdateMyDepartment (void)
void Rec_UpdateMyOffice (void)
{
char *Query;
/***** Get my office *****/
Par_GetParToText ("Office",Gbl.Usrs.Me.UsrDat.Tch.Office,Usr_MAX_BYTES_ADDRESS);
/***** Update office *****/
if (asprintf (&Query,"UPDATE usr_data SET Office='%s' WHERE UsrCod=%ld",
Gbl.Usrs.Me.UsrDat.Tch.Office,
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update office");
DB_BuildQuery ("UPDATE usr_data SET Office='%s' WHERE UsrCod=%ld",
Gbl.Usrs.Me.UsrDat.Tch.Office,
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE_new ("can not update office");
/***** Show form again *****/
Rec_ShowMySharedRecordAndMore ();
@ -4428,17 +4417,14 @@ void Rec_UpdateMyOffice (void)
void Rec_UpdateMyOfficePhone (void)
{
char *Query;
/***** Get my office *****/
Par_GetParToText ("OfficePhone",Gbl.Usrs.Me.UsrDat.Tch.OfficePhone,Usr_MAX_BYTES_PHONE);
/***** Update office phone *****/
if (asprintf (&Query,"UPDATE usr_data SET OfficePhone='%s' WHERE UsrCod=%ld",
Gbl.Usrs.Me.UsrDat.Tch.OfficePhone,
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update office phone");
DB_BuildQuery ("UPDATE usr_data SET OfficePhone='%s' WHERE UsrCod=%ld",
Gbl.Usrs.Me.UsrDat.Tch.OfficePhone,
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE_new ("can not update office phone");
/***** Show form again *****/
Rec_ShowMySharedRecordAndMore ();

View File

@ -280,7 +280,6 @@ void The_ChangeTheme (void)
char Path[PATH_MAX + 1 +
NAME_MAX + 1 +
NAME_MAX + 1];
char *Query;
/***** Get param theme *****/
Gbl.Prefs.Theme = The_GetParamTheme ();
@ -295,11 +294,10 @@ void The_ChangeTheme (void)
/***** Store theme in database *****/
if (Gbl.Usrs.Me.Logged)
{
if (asprintf (&Query,"UPDATE usr_data SET Theme='%s'"
" WHERE UsrCod=%ld",
The_ThemeId[Gbl.Prefs.Theme],Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update your preference about theme");
DB_BuildQuery ("UPDATE usr_data SET Theme='%s'"
" WHERE UsrCod=%ld",
The_ThemeId[Gbl.Prefs.Theme],Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE_new ("can not update your preference about theme");
}
/***** Set preferences from current IP *****/