Version 18.11.19

This commit is contained in:
Antonio Cañas Vargas 2018-11-02 19:37:11 +01:00
parent c364d4ea76
commit 8ec272448b
41 changed files with 620 additions and 654 deletions

View File

@ -1015,14 +1015,14 @@ static void ID_NewUsrID (const struct UsrData *UsrDat,bool ItsMe)
static void ID_InsertANewUsrIDInDB (long UsrCod,const char *NewID,bool Confirmed)
{
/***** Update my nickname in database *****/
DB_BuildQuery ("INSERT INTO usr_IDs"
" (UsrCod,UsrID,CreatTime,Confirmed)"
" VALUES"
" (%ld,'%s',NOW(),'%c')",
UsrCod,NewID,
Confirmed ? 'Y' :
'N');
DB_QueryINSERT_new ("can not insert a new ID");
DB_QueryINSERT ("can not insert a new ID",
"INSERT INTO usr_IDs"
" (UsrCod,UsrID,CreatTime,Confirmed)"
" VALUES"
" (%ld,'%s',NOW(),'%c')",
UsrCod,NewID,
Confirmed ? 'Y' :
'N');
}
/*****************************************************************************/
@ -1148,8 +1148,8 @@ void ID_ConfirmOtherUsrID (void)
void ID_ConfirmUsrID (const struct UsrData *UsrDat,const char *UsrID)
{
/***** Update database *****/
DB_BuildQuery ("UPDATE usr_IDs SET Confirmed='Y'"
" WHERE UsrCod=%ld AND UsrID='%s' AND Confirmed<>'Y'",
UsrDat->UsrCod,UsrID);
DB_QueryINSERT_new ("can not confirm a user's ID");
DB_QueryINSERT ("can not confirm a user's ID",
"UPDATE usr_IDs SET Confirmed='Y'"
" WHERE UsrCod=%ld AND UsrID='%s' AND Confirmed<>'Y'",
UsrDat->UsrCod,UsrID);
}

View File

@ -775,15 +775,15 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount)
NumID++)
{
Str_ConvertToUpperText (UsrDat->IDs.List[NumID].ID);
DB_BuildQuery ("INSERT INTO usr_IDs"
" (UsrCod,UsrID,CreatTime,Confirmed)"
" VALUES"
" (%ld,'%s',NOW(),'%c')",
UsrDat->UsrCod,
UsrDat->IDs.List[NumID].ID,
UsrDat->IDs.List[NumID].Confirmed ? 'Y' :
'N');
DB_QueryINSERT_new ("can not store user's ID when creating user");
DB_QueryINSERT ("can not store user's ID when creating user",
"INSERT INTO usr_IDs"
" (UsrCod,UsrID,CreatTime,Confirmed)"
" VALUES"
" (%ld,'%s',NOW(),'%c')",
UsrDat->UsrCod,
UsrDat->IDs.List[NumID].ID,
UsrDat->IDs.List[NumID].Confirmed ? 'Y' :
'N');
}
/***** Create directory for the user, if not exists *****/

View File

@ -512,12 +512,12 @@ void Ann_ReceiveAnnouncement (void)
static void Ann_CreateAnnouncement (unsigned Roles,const char *Subject,const char *Content)
{
/***** Select announcements not seen *****/
DB_BuildQuery ("INSERT INTO announcements"
" (Roles,Subject,Content)"
" VALUES"
" (%u,'%s','%s')",
Roles,Subject,Content);
DB_QueryINSERT_new ("can not create announcement");
DB_QueryINSERT ("can not create announcement",
"INSERT INTO announcements"
" (Roles,Subject,Content)"
" VALUES"
" (%u,'%s','%s')",
Roles,Subject,Content);
}
/*****************************************************************************/

View File

@ -1617,15 +1617,14 @@ static void Asg_CreateGrps (long AsgCod)
for (NumGrpSel = 0;
NumGrpSel < Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps;
NumGrpSel++)
{
/* Create group */
DB_BuildQuery ("INSERT INTO asg_grp"
" (AsgCod,GrpCod)"
" VALUES"
" (%ld,%ld)",
AsgCod,Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]);
DB_QueryINSERT_new ("can not associate a group to an assignment");
}
DB_QueryINSERT ("can not associate a group to an assignment",
"INSERT INTO asg_grp"
" (AsgCod,GrpCod)"
" VALUES"
" (%ld,%ld)",
AsgCod,
Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]);
}
/*****************************************************************************/

View File

@ -1483,15 +1483,14 @@ static void Att_CreateGrps (long AttCod)
for (NumGrpSel = 0;
NumGrpSel < Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps;
NumGrpSel++)
{
/* Create group */
DB_BuildQuery ("INSERT INTO att_grp"
" (AttCod,GrpCod)"
" VALUES"
" (%ld,%ld)",
AttCod,Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]);
DB_QueryINSERT_new ("can not associate a group to an attendance event");
}
DB_QueryINSERT ("can not associate a group to an attendance event",
"INSERT INTO att_grp"
" (AttCod,GrpCod)"
" VALUES"
" (%ld,%ld)",
AttCod,
Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]);
}
/*****************************************************************************/

View File

@ -986,12 +986,12 @@ static void Ban_CreateBanner (struct Banner *Ban)
extern const char *Txt_Created_new_banner_X;
/***** Create a new banner *****/
DB_BuildQuery ("INSERT INTO banners"
" (Hidden,ShortName,FullName,Img,WWW)"
" VALUES"
" ('N','%s','%s','%s','%s')",
Ban->ShrtName,Ban->FullName,Ban->Img,Ban->WWW);
DB_QueryINSERT_new ("can not create banner");
DB_QueryINSERT ("can not create banner",
"INSERT INTO banners"
" (Hidden,ShortName,FullName,Img,WWW)"
" VALUES"
" ('N','%s','%s','%s','%s')",
Ban->ShrtName,Ban->FullName,Ban->Img,Ban->WWW);
/***** Write success message *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),

View File

@ -355,10 +355,11 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
#define Log_PLATFORM_VERSION "SWAD 18.11.18 (2018-11-02)"
#define Log_PLATFORM_VERSION "SWAD 18.11.19 (2018-11-02)"
#define CSS_FILE "swad18.4.css"
#define JS_FILE "swad17.17.1.js"
/*
Version 18.11.19: Nov 02, 2018 Joining building and performing query into one function. (236465 lines)
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)

View File

@ -2255,13 +2255,13 @@ static void Cty_CreateCountry (struct Country *Cty)
Str_Concat (SubQueryWWW2,"'",
Cty_MAX_BYTES_SUBQUERY_CTYS_WWW);
}
DB_BuildQuery ("INSERT INTO countries"
" (CtyCod,Alpha2%s%s)"
" VALUES"
" ('%03ld','%s'%s%s)",
SubQueryNam1,SubQueryWWW1,
Cty->CtyCod,Cty->Alpha2,SubQueryNam2,SubQueryWWW2);
DB_QueryINSERT_new ("can not create country");
DB_QueryINSERT ("can not create country",
"INSERT INTO countries"
" (CtyCod,Alpha2%s%s)"
" VALUES"
" ('%03ld','%s'%s%s)",
SubQueryNam1,SubQueryWWW1,
Cty->CtyCod,Cty->Alpha2,SubQueryNam2,SubQueryWWW2);
/***** Write success message *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),

View File

@ -2208,13 +2208,13 @@ static void Crs_EmptyCourseCompletely (long CrsCod)
/***** Remove notices in the course *****/
/* Copy all notices from the course to table of deleted notices */
DB_BuildQuery ("INSERT INTO notices_deleted"
" (NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif)"
" SELECT NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif"
" FROM notices"
" WHERE CrsCod=%ld",
CrsCod);
DB_QueryINSERT_new ("can not remove notices in a course");
DB_QueryINSERT ("can not remove notices in a course",
"INSERT INTO notices_deleted"
" (NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif)"
" SELECT NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif"
" FROM notices"
" WHERE CrsCod=%ld",
CrsCod);
/* Remove all notices from the course */
DB_BuildQuery ("DELETE FROM notices WHERE CrsCod=%ld",CrsCod);

View File

@ -3154,8 +3154,7 @@ unsigned long DB_QuerySELECT_old (char **Query,MYSQL_RES **mysql_res,const char
/**************** Make a SELECT COUNT query from database ********************/
/*****************************************************************************/
unsigned long DB_QueryCOUNT (const char *MsgError,
const char *fmt,...)
unsigned long DB_QueryCOUNT (const char *MsgError,const char *fmt,...)
{
va_list ap;
int NumBytesPrinted;
@ -3202,21 +3201,22 @@ unsigned long DB_QueryCOUNT_old (char **Query,const char *MsgError)
/******************** Make an INSERT query in database ***********************/
/*****************************************************************************/
void DB_QueryINSERT_new (const char *MsgError)
void DB_QueryINSERT (const char *MsgError,const char *fmt,...)
{
int Result;
va_list ap;
int NumBytesPrinted;
char *Query = NULL;
/***** Check that query string pointer
does point to an allocated string *****/
if (Gbl.DB.QueryPtr == NULL)
Lay_ShowErrorAndExit ("Wrong query string.");
va_start (ap,fmt);
NumBytesPrinted = vasprintf (&Query,fmt,ap);
va_end (ap);
/***** Query database and free query string pointer *****/
Result = mysql_query (&Gbl.mysql,Gbl.DB.QueryPtr); // Returns 0 on success
free ((void *) Gbl.DB.QueryPtr);
Gbl.DB.QueryPtr = NULL;
if (Result)
DB_ExitOnMySQLError (MsgError);
if (NumBytesPrinted < 0) // If memory allocation wasn't possible,
// or some other error occurs,
// vasprintf will return -1
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_old (&Query,MsgError);
}
/*****************************************************************************/

View File

@ -44,12 +44,11 @@ unsigned long DB_QuerySELECT (MYSQL_RES **mysql_res,const char *MsgError,
const char *fmt,...);
unsigned long DB_QuerySELECT_old (char **Query,MYSQL_RES **mysql_res,const char *MsgError);
unsigned long DB_QueryCOUNT (const char *MsgError,
const char *fmt,...);
unsigned long DB_QueryCOUNT (const char *MsgError,const char *fmt,...);
unsigned long DB_QueryCOUNT_new (const char *MsgError);
unsigned long DB_QueryCOUNT_old (char **Query,const char *MsgError);
void DB_QueryINSERT_new (const char *MsgError);
void DB_QueryINSERT (const char *MsgError,const char *fmt,...);
void DB_QueryINSERT_old (char **Query,const char *MsgError);
long DB_QueryINSERTandReturnCode_new (const char *MsgError);

View File

@ -546,9 +546,9 @@ static void DT_CreateDegreeType (struct DegreeType *DegTyp)
extern const char *Txt_Created_new_type_of_degree_X;
/***** Create a new degree type *****/
DB_BuildQuery ("INSERT INTO deg_types SET DegTypName='%s'",
DegTyp->DegTypName);
DB_QueryINSERT_new ("can not create a new type of degree");
DB_QueryINSERT ("can not create a new type of degree",
"INSERT INTO deg_types SET DegTypName='%s'",
DegTyp->DegTypName);
/***** Write success message *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),

View File

@ -1051,12 +1051,12 @@ static void Dpt_CreateDepartment (struct Department *Dpt)
extern const char *Txt_Created_new_department_X;
/***** Create a new department *****/
DB_BuildQuery ("INSERT INTO departments"
" (InsCod,ShortName,FullName,WWW)"
" VALUES"
" (%ld,'%s','%s','%s')",
Dpt->InsCod,Dpt->ShrtName,Dpt->FullName,Dpt->WWW);
DB_QueryINSERT_new ("can not create a new department");
DB_QueryINSERT ("can not create a new department",
"INSERT INTO departments"
" (InsCod,ShortName,FullName,WWW)"
" VALUES"
" (%ld,'%s','%s','%s')",
Dpt->InsCod,Dpt->ShrtName,Dpt->FullName,Dpt->WWW);
/***** Write success message *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),

View File

@ -92,13 +92,13 @@ void Dup_ReportUsrAsPossibleDuplicate (void)
if (!ItsMe && Gbl.Usrs.Me.Role.Logged >= Rol_TCH)
{
/***** Insert possible duplicate into database *****/
DB_BuildQuery ("REPLACE INTO usr_duplicated"
" (UsrCod,InformerCod,InformTime)"
" VALUES"
" (%ld,%ld,NOW())",
Gbl.Usrs.Other.UsrDat.UsrCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryINSERT_new ("can not report duplicate");
DB_QueryINSERT ("can not report duplicate",
"REPLACE INTO usr_duplicated"
" (UsrCod,InformerCod,InformTime)"
" VALUES"
" (%ld,%ld,NOW())",
Gbl.Usrs.Other.UsrDat.UsrCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
/***** Show feedback message *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_Thank_you_for_reporting_a_possible_duplicate_user);

View File

@ -264,25 +264,25 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole,
}
/***** Register user in current course in database *****/
DB_BuildQuery ("INSERT INTO crs_usr"
" (CrsCod,UsrCod,Role,Accepted,"
"LastDowGrpCod,LastComGrpCod,LastAssGrpCod,"
"NumAccTst,LastAccTst,NumQstsLastTst,"
"UsrListType,ColsClassPhoto,ListWithPhotos)"
" VALUES"
" (%ld,%ld,%u,'%c',"
"-1,-1,-1,"
"0,FROM_UNIXTIME(%ld),0,"
"'%s',%u,'%c')",
Gbl.CurrentCrs.Crs.CrsCod,UsrDat->UsrCod,(unsigned) NewRole,
KeepOrSetAccepted == Enr_SET_ACCEPTED_TO_TRUE ? 'Y' :
'N',
(long) (time_t) 0, // The user never accessed to tests in this course
Usr_StringsUsrListTypeInDB[Usr_SHOW_USRS_TYPE_DEFAULT],
Usr_CLASS_PHOTO_COLS_DEF,
Usr_LIST_WITH_PHOTOS_DEF ? 'Y' :
'N');
DB_QueryINSERT_new ("can not register user in course");
DB_QueryINSERT ("can not register user in course",
"INSERT INTO crs_usr"
" (CrsCod,UsrCod,Role,Accepted,"
"LastDowGrpCod,LastComGrpCod,LastAssGrpCod,"
"NumAccTst,LastAccTst,NumQstsLastTst,"
"UsrListType,ColsClassPhoto,ListWithPhotos)"
" VALUES"
" (%ld,%ld,%u,'%c',"
"-1,-1,-1,"
"0,FROM_UNIXTIME(%ld),0,"
"'%s',%u,'%c')",
Gbl.CurrentCrs.Crs.CrsCod,UsrDat->UsrCod,(unsigned) NewRole,
KeepOrSetAccepted == Enr_SET_ACCEPTED_TO_TRUE ? 'Y' :
'N',
(long) (time_t) 0, // The user never accessed to tests in this course
Usr_StringsUsrListTypeInDB[Usr_SHOW_USRS_TYPE_DEFAULT],
Usr_CLASS_PHOTO_COLS_DEF,
Usr_LIST_WITH_PHOTOS_DEF ? 'Y' :
'N');
/***** Flush caches *****/
Usr_FlushCachesUsr ();

View File

@ -7806,14 +7806,14 @@ static void Brw_AddPathToClipboards (void)
long WorksUsrCod = Brw_GetWorksUsrCodForClipboard ();
/***** Add path to clipboards *****/
DB_BuildQuery ("INSERT INTO clipboard"
" (UsrCod,FileBrowser,Cod,WorksUsrCod,FileType,Path)"
" VALUES"
" (%ld,%u,%ld,%ld,%u,'%s')",
Gbl.Usrs.Me.UsrDat.UsrCod,(unsigned) Gbl.FileBrowser.Type,
Cod,WorksUsrCod,
(unsigned) Gbl.FileBrowser.FileType,Gbl.FileBrowser.Priv.FullPathInTree);
DB_QueryINSERT_new ("can not add source of copy to clipboard");
DB_QueryINSERT ("can not add source of copy to clipboard",
"INSERT INTO clipboard"
" (UsrCod,FileBrowser,Cod,WorksUsrCod,FileType,Path)"
" VALUES"
" (%ld,%u,%ld,%ld,%u,'%s')",
Gbl.Usrs.Me.UsrDat.UsrCod,(unsigned) Gbl.FileBrowser.Type,
Cod,WorksUsrCod,
(unsigned) Gbl.FileBrowser.FileType,Gbl.FileBrowser.Priv.FullPathInTree);
}
/*****************************************************************************/
@ -7956,15 +7956,15 @@ static void Brw_InsertFolderInExpandedFolders (const char Path[PATH_MAX + 1])
/***** Update path time in table of expanded folders *****/
// Path must be stored with final '/'
DB_BuildQuery ("INSERT INTO expanded_folders"
" (UsrCod,FileBrowser,Cod,WorksUsrCod,Path,ClickTime)"
" VALUES"
" (%ld,%u,%ld,%ld,'%s/',NOW())",
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) Brw_FileBrowserForDB_expanded_folders[Gbl.FileBrowser.Type],
Cod,WorksUsrCod,
Path);
DB_QueryINSERT_new ("can not expand the content of a folder");
DB_QueryINSERT ("can not expand the content of a folder",
"INSERT INTO expanded_folders"
" (UsrCod,FileBrowser,Cod,WorksUsrCod,Path,ClickTime)"
" VALUES"
" (%ld,%u,%ld,%ld,'%s/',NOW())",
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) Brw_FileBrowserForDB_expanded_folders[Gbl.FileBrowser.Type],
Cod,WorksUsrCod,
Path);
}
/*****************************************************************************/
@ -11542,15 +11542,13 @@ static void Brw_UpdateFileViews (unsigned NumViews,long FilCod)
DB_QueryUPDATE_new ("can not update number of views of a file");
}
else // NumViews == 0
{
/* Insert number of views in database */
DB_BuildQuery ("INSERT INTO file_view"
" (FilCod,UsrCod,NumViews)"
" VALUES"
" (%ld,%ld,1)",
FilCod,Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryINSERT_new ("can not insert number of views of a file");
}
DB_QueryINSERT ("can not insert number of views of a file",
"INSERT INTO file_view"
" (FilCod,UsrCod,NumViews)"
" VALUES"
" (%ld,%ld,1)",
FilCod,Gbl.Usrs.Me.UsrDat.UsrCod);
}
/*****************************************************************************/

View File

@ -2313,15 +2313,13 @@ static void Gam_CreateGrps (long GamCod)
for (NumGrpSel = 0;
NumGrpSel < Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps;
NumGrpSel++)
{
/* Create group */
DB_BuildQuery ("INSERT INTO gam_grp"
" (GamCod,GrpCod)"
" VALUES"
" (%ld,%ld)",
GamCod,Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]);
DB_QueryINSERT_new ("can not associate a group to a game");
}
DB_QueryINSERT ("can not associate a group to a game",
"INSERT INTO gam_grp"
" (GamCod,GrpCod)"
" VALUES"
" (%ld,%ld)",
GamCod,Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]);
}
/*****************************************************************************/
@ -3031,12 +3029,12 @@ void Gam_AddTstQuestionsToGame (void)
MaxQstInd = Gam_GetMaxQuestionIndexInGame (Game.GamCod); // -1 if no questions
/* Insert question in the table of questions */
DB_BuildQuery ("INSERT INTO gam_questions"
" (GamCod,QstCod,QstInd)"
" VALUES"
" (%ld,%ld,%u)",
Game.GamCod,QstCod,(unsigned) (MaxQstInd + 1));
DB_QueryINSERT_new ("can not create question");
DB_QueryINSERT ("can not create question",
"INSERT INTO gam_questions"
" (GamCod,QstCod,QstInd)"
" VALUES"
" (%ld,%ld,%u)",
Game.GamCod,QstCod,(unsigned) (MaxQstInd + 1));
}
/***** Free space for selected question codes *****/
@ -3750,10 +3748,10 @@ static void Gam_IncreaseAnswerInDB (long QstCod,unsigned AnsInd)
{
/***** Increase number of users who have selected
the answer AnsInd in the question QstCod *****/
DB_BuildQuery ("UPDATE gam_answers SET NumUsrs=NumUsrs+1"
" WHERE QstCod=%ld AND AnsInd=%u",
QstCod,AnsInd);
DB_QueryINSERT_new ("can not register your answer to the game");
DB_QueryINSERT ("can not register your answer to the game",
"UPDATE gam_answers SET NumUsrs=NumUsrs+1"
" WHERE QstCod=%ld AND AnsInd=%u",
QstCod,AnsInd);
}
/*****************************************************************************/
@ -3762,12 +3760,12 @@ static void Gam_IncreaseAnswerInDB (long QstCod,unsigned AnsInd)
static void Gam_RegisterIHaveAnsweredGame (long GamCod)
{
DB_BuildQuery ("INSERT INTO gam_users"
" (GamCod,UsrCod)"
" VALUES"
" (%ld,%ld)",
GamCod,Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryINSERT_new ("can not register that you have answered the game");
DB_QueryINSERT ("can not register that you have answered the game",
"INSERT INTO gam_users"
" (GamCod,UsrCod)"
" VALUES"
" (%ld,%ld)",
GamCod,Gbl.Usrs.Me.UsrDat.UsrCod);
}
/*****************************************************************************/

View File

@ -1266,12 +1266,12 @@ static void Grp_RemoveUsrFromGroup (long UsrCod,long GrpCod)
static void Grp_AddUsrToGroup (struct UsrData *UsrDat,long GrpCod)
{
/***** Register in group *****/
DB_BuildQuery ("INSERT INTO crs_grp_usr"
" (GrpCod,UsrCod)"
" VALUES"
" (%ld,%ld)",
GrpCod,UsrDat->UsrCod);
DB_QueryINSERT_new ("can not add a user to a group");
DB_QueryINSERT ("can not add a user to a group",
"INSERT INTO crs_grp_usr"
" (GrpCod,UsrCod)"
" VALUES"
" (%ld,%ld)",
GrpCod,UsrDat->UsrCod);
}
/*****************************************************************************/
@ -3846,14 +3846,14 @@ static void Grp_CreateGroupType (void)
static void Grp_CreateGroup (void)
{
/***** Create a new group *****/
DB_BuildQuery ("INSERT INTO crs_grp"
" (GrpTypCod,GrpName,MaxStudents,Open,FileZones)"
" VALUES"
" (%ld,'%s',%u,'N','N')",
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod,
Gbl.CurrentCrs.Grps.GrpName,
Gbl.CurrentCrs.Grps.MaxStudents);
DB_QueryINSERT_new ("can not create group");
DB_QueryINSERT ("can not create group",
"INSERT INTO crs_grp"
" (GrpTypCod,GrpName,MaxStudents,Open,FileZones)"
" VALUES"
" (%ld,'%s',%u,'N','N')",
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod,
Gbl.CurrentCrs.Grps.GrpName,
Gbl.CurrentCrs.Grps.MaxStudents);
}
/*****************************************************************************/

View File

@ -1199,17 +1199,17 @@ void Hld_RecFormNewHoliday2 (void)
static void Hld_CreateHoliday (struct Holiday *Hld)
{
/***** Create a new holiday or no school period *****/
DB_BuildQuery ("INSERT INTO holidays"
" (InsCod,PlcCod,HldTyp,StartDate,EndDate,Name)"
" VALUES"
" (%ld,%ld,%u,'%04u%02u%02u','%04u%02u%02u','%s')",
Gbl.CurrentIns.Ins.InsCod,Hld->PlcCod,(unsigned) Hld->HldTyp,
Hld->StartDate.Year,
Hld->StartDate.Month,
Hld->StartDate.Day,
Hld->EndDate.Year,
Hld->EndDate.Month,
Hld->EndDate.Day,
Hld->Name);
DB_QueryINSERT_new ("can not create holiday");
DB_QueryINSERT ("can not create holiday",
"INSERT INTO holidays"
" (InsCod,PlcCod,HldTyp,StartDate,EndDate,Name)"
" VALUES"
" (%ld,%ld,%u,'%04u%02u%02u','%04u%02u%02u','%s')",
Gbl.CurrentIns.Ins.InsCod,Hld->PlcCod,(unsigned) Hld->HldTyp,
Hld->StartDate.Year,
Hld->StartDate.Month,
Hld->StartDate.Day,
Hld->EndDate.Year,
Hld->EndDate.Month,
Hld->EndDate.Day,
Hld->Name);
}

View File

@ -1502,16 +1502,14 @@ void Inf_SetInfoSrcIntoDB (Inf_InfoSrc_t InfoSrc)
DB_QueryUPDATE_new ("can not update info source");
}
else // Info is not stored in database, so insert it
{
DB_BuildQuery ("INSERT INTO crs_info_src"
" (CrsCod,InfoType,InfoSrc,MustBeRead)"
" VALUES"
" (%ld,'%s','%s','N')",
Gbl.CurrentCrs.Crs.CrsCod,
Inf_NamesInDBForInfoType[Gbl.CurrentCrs.Info.Type],
Inf_NamesInDBForInfoSrc[InfoSrc]);
DB_QueryINSERT_new ("can not insert info source");
}
DB_QueryINSERT ("can not insert info source",
"INSERT INTO crs_info_src"
" (CrsCod,InfoType,InfoSrc,MustBeRead)"
" VALUES"
" (%ld,'%s','%s','N')",
Gbl.CurrentCrs.Crs.CrsCod,
Inf_NamesInDBForInfoType[Gbl.CurrentCrs.Info.Type],
Inf_NamesInDBForInfoSrc[InfoSrc]);
}

View File

@ -846,12 +846,12 @@ static void Lnk_CreateLink (struct Link *Lnk)
extern const char *Txt_Created_new_link_X;
/***** Create a new link *****/
DB_BuildQuery ("INSERT INTO links"
" (ShortName,FullName,WWW)"
" VALUES"
" ('%s','%s','%s')",
Lnk->ShrtName,Lnk->FullName,Lnk->WWW);
DB_QueryINSERT_new ("can not create institutional link");
DB_QueryINSERT ("can not create institutional link",
"INSERT INTO links"
" (ShortName,FullName,WWW)"
" VALUES"
" ('%s','%s','%s')",
Lnk->ShrtName,Lnk->FullName,Lnk->WWW);
/***** Write success message *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),

View File

@ -856,12 +856,12 @@ static void Mai_CreateMailDomain (struct Mail *Mai)
extern const char *Txt_Created_new_email_domain_X;
/***** Create a new mail *****/
DB_BuildQuery ("INSERT INTO mail_domains"
" (Domain,Info)"
" VALUES"
" ('%s','%s')",
Mai->Domain,Mai->Info);
DB_QueryINSERT_new ("can not create mail domain");
DB_QueryINSERT ("can not create mail domain",
"INSERT INTO mail_domains"
" (Domain,Info)"
" VALUES"
" ('%s','%s')",
Mai->Domain,Mai->Info);
/***** Write success message *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),

View File

@ -88,16 +88,16 @@ static bool Mrk_GetUsrMarks (FILE *FileUsrMarks,struct UsrData *UsrDat,
void Mrk_AddMarksToDB (long FilCod,struct MarksProperties *Marks)
{
/***** Add file of marks to the database *****/
DB_BuildQuery ("INSERT INTO marks_properties"
" (FilCod,%s,%s)"
" VALUES"
" (%ld,%u,%u)",
Mrk_HeadOrFootStr[Brw_HEADER],
Mrk_HeadOrFootStr[Brw_FOOTER],
FilCod,
Marks->Header,
Marks->Footer);
DB_QueryINSERT_new ("can not add properties of marks to database");
DB_QueryINSERT ("can not add properties of marks to database",
"INSERT INTO marks_properties"
" (FilCod,%s,%s)"
" VALUES"
" (%ld,%u,%u)",
Mrk_HeadOrFootStr[Brw_HEADER],
Mrk_HeadOrFootStr[Brw_FOOTER],
FilCod,
Marks->Header,
Marks->Footer);
}
/*****************************************************************************/

View File

@ -1324,14 +1324,14 @@ static long Msg_InsertNewMsg (const char *Subject,const char *Content,
MsgCod = DB_QueryINSERTandReturnCode_new ("can not create message");
/***** Insert message in sent messages *****/
DB_BuildQuery ("INSERT INTO msg_snt"
" (MsgCod,CrsCod,UsrCod,Expanded,CreatTime)"
" VALUES"
" (%ld,%ld,%ld,'N',NOW())",
MsgCod,
Gbl.CurrentCrs.Crs.CrsCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryINSERT_new ("can not create message");
DB_QueryINSERT ("can not create message",
"INSERT INTO msg_snt"
" (MsgCod,CrsCod,UsrCod,Expanded,CreatTime)"
" VALUES"
" (%ld,%ld,%ld,'N',NOW())",
MsgCod,
Gbl.CurrentCrs.Crs.CrsCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
/***** Increment number of messages sent by me *****/
Prf_IncrementNumMsgSntUsr (Gbl.Usrs.Me.UsrDat.UsrCod);
@ -1393,11 +1393,12 @@ void Msg_DelAllRecAndSntMsgsUsr (long UsrCod)
{
/***** Move messages from msg_rcv to msg_rcv_deleted *****/
/* Insert messages into msg_rcv_deleted */
DB_BuildQuery ("INSERT IGNORE INTO msg_rcv_deleted"
" (MsgCod,UsrCod,Notified,Open,Replied)"
" SELECT MsgCod,UsrCod,Notified,Open,Replied FROM msg_rcv WHERE UsrCod=%ld",
UsrCod);
DB_QueryINSERT_new ("can not remove received messages");
DB_QueryINSERT ("can not remove received messages",
"INSERT IGNORE INTO msg_rcv_deleted"
" (MsgCod,UsrCod,Notified,Open,Replied)"
" SELECT MsgCod,UsrCod,Notified,Open,Replied FROM msg_rcv"
" WHERE UsrCod=%ld",
UsrCod);
/* Delete messages from msg_rcv *****/
DB_BuildQuery ("DELETE FROM msg_rcv WHERE UsrCod=%ld",UsrCod);
@ -1405,12 +1406,12 @@ void Msg_DelAllRecAndSntMsgsUsr (long UsrCod)
/***** Move message from msg_snt to msg_snt_deleted *****/
/* Insert message into msg_snt_deleted */
DB_BuildQuery ("INSERT IGNORE INTO msg_snt_deleted"
" (MsgCod,CrsCod,UsrCod,CreatTime)"
" SELECT MsgCod,CrsCod,UsrCod,CreatTime"
" FROM msg_snt WHERE UsrCod=%ld",
UsrCod);
DB_QueryINSERT_new ("can not remove sent messages");
DB_QueryINSERT ("can not remove sent messages",
"INSERT IGNORE INTO msg_snt_deleted"
" (MsgCod,CrsCod,UsrCod,CreatTime)"
" SELECT MsgCod,CrsCod,UsrCod,CreatTime"
" FROM msg_snt WHERE UsrCod=%ld",
UsrCod);
/* Delete message from msg_snt *****/
DB_BuildQuery ("DELETE FROM msg_snt WHERE UsrCod=%ld",UsrCod);
@ -1424,14 +1425,14 @@ void Msg_DelAllRecAndSntMsgsUsr (long UsrCod)
static void Msg_InsertReceivedMsgIntoDB (long MsgCod,long UsrCod,bool NotifyByEmail)
{
/***** Insert message received in the database *****/
DB_BuildQuery ("INSERT INTO msg_rcv"
" (MsgCod,UsrCod,Notified,Open,Replied,Expanded)"
" VALUES"
" (%ld,%ld,'%c','N','N','N')",
MsgCod,UsrCod,
NotifyByEmail ? 'Y' :
'N');
DB_QueryINSERT_new ("can not create received message");
DB_QueryINSERT ("can not create received message",
"INSERT INTO msg_rcv"
" (MsgCod,UsrCod,Notified,Open,Replied,Expanded)"
" VALUES"
" (%ld,%ld,'%c','N','N','N')",
MsgCod,UsrCod,
NotifyByEmail ? 'Y' :
'N');
}
/*****************************************************************************/
@ -1455,12 +1456,12 @@ static void Msg_MoveReceivedMsgToDeleted (long MsgCod,long UsrCod)
{
/***** Move message from msg_rcv to msg_rcv_deleted *****/
/* Insert message into msg_rcv_deleted */
DB_BuildQuery ("INSERT IGNORE INTO msg_rcv_deleted"
" (MsgCod,UsrCod,Notified,Open,Replied)"
" SELECT MsgCod,UsrCod,Notified,Open,Replied"
" FROM msg_rcv WHERE MsgCod=%ld AND UsrCod=%ld",
MsgCod,UsrCod);
DB_QueryINSERT_new ("can not remove a received message");
DB_QueryINSERT ("can not remove a received message",
"INSERT IGNORE INTO msg_rcv_deleted"
" (MsgCod,UsrCod,Notified,Open,Replied)"
" SELECT MsgCod,UsrCod,Notified,Open,Replied"
" FROM msg_rcv WHERE MsgCod=%ld AND UsrCod=%ld",
MsgCod,UsrCod);
/* Delete message from msg_rcv *****/
DB_BuildQuery ("DELETE FROM msg_rcv WHERE MsgCod=%ld AND UsrCod=%ld",
@ -1484,12 +1485,12 @@ static void Msg_MoveSentMsgToDeleted (long MsgCod)
{
/***** Move message from msg_snt to msg_snt_deleted *****/
/* Insert message into msg_snt_deleted */
DB_BuildQuery ("INSERT IGNORE INTO msg_snt_deleted"
" (MsgCod,CrsCod,UsrCod,CreatTime)"
" SELECT MsgCod,CrsCod,UsrCod,CreatTime"
" FROM msg_snt WHERE MsgCod=%ld",
MsgCod);
DB_QueryINSERT_new ("can not remove a sent message");
DB_QueryINSERT ("can not remove a sent message",
"INSERT IGNORE INTO msg_snt_deleted"
" (MsgCod,CrsCod,UsrCod,CreatTime)"
" SELECT MsgCod,CrsCod,UsrCod,CreatTime"
" FROM msg_snt WHERE MsgCod=%ld",
MsgCod);
/* Delete message from msg_snt *****/
DB_BuildQuery ("DELETE FROM msg_snt WHERE MsgCod=%ld",MsgCod);
@ -1508,12 +1509,12 @@ static void Msg_MoveMsgContentToDeleted (long MsgCod)
{
/***** Move message from msg_content to msg_content_deleted *****/
/* Insert message content into msg_content_deleted */
DB_BuildQuery ("INSERT IGNORE INTO msg_content_deleted"
" (MsgCod,Subject,Content,ImageName,ImageTitle,ImageURL)"
" SELECT MsgCod,Subject,Content,ImageName,ImageTitle,ImageURL"
" FROM msg_content WHERE MsgCod=%ld",
MsgCod);
DB_QueryINSERT_new ("can not remove the content of a message");
DB_QueryINSERT ("can not remove the content of a message",
"INSERT IGNORE INTO msg_content_deleted"
" (MsgCod,Subject,Content,ImageName,ImageTitle,ImageURL)"
" SELECT MsgCod,Subject,Content,ImageName,ImageTitle,ImageURL"
" FROM msg_content WHERE MsgCod=%ld",
MsgCod);
/* TODO: Messages in msg_content_deleted older than a certain time
should be deleted to ensure the protection of personal data */
@ -1531,12 +1532,12 @@ void Msg_MoveUnusedMsgsContentToDeleted (void)
{
/***** Move messages from msg_content to msg_content_deleted *****/
/* Insert message content into msg_content_deleted */
DB_BuildQuery ("INSERT IGNORE INTO msg_content_deleted"
" (MsgCod,Subject,Content)"
" SELECT MsgCod,Subject,Content FROM msg_content"
" WHERE MsgCod NOT IN (SELECT MsgCod FROM msg_snt)"
" AND MsgCod NOT IN (SELECT DISTINCT MsgCod FROM msg_rcv)");
DB_QueryINSERT_new ("can not remove the content of some messages");
DB_QueryINSERT ("can not remove the content of some messages",
"INSERT IGNORE INTO msg_content_deleted"
" (MsgCod,Subject,Content)"
" SELECT MsgCod,Subject,Content FROM msg_content"
" WHERE MsgCod NOT IN (SELECT MsgCod FROM msg_snt)"
" AND MsgCod NOT IN (SELECT DISTINCT MsgCod FROM msg_rcv)");
/* Messages in msg_content_deleted older than a certain time
should be deleted to ensure the protection of personal data */

View File

@ -299,13 +299,13 @@ void Not_RemoveNotice (void)
/***** Remove notice *****/
/* Copy notice to table of deleted notices */
DB_BuildQuery ("INSERT IGNORE INTO notices_deleted"
" (NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif)"
" SELECT NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif"
" FROM notices"
" WHERE NotCod=%ld AND CrsCod=%ld",
NotCod,Gbl.CurrentCrs.Crs.CrsCod);
DB_QueryINSERT_new ("can not remove notice");
DB_QueryINSERT ("can not remove notice",
"INSERT IGNORE INTO notices_deleted"
" (NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif)"
" SELECT NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif"
" FROM notices"
" WHERE NotCod=%ld AND CrsCod=%ld",
NotCod,Gbl.CurrentCrs.Crs.CrsCod);
/* Remove notice */
DB_BuildQuery ("DELETE FROM notices"

View File

@ -1494,15 +1494,16 @@ void Ntf_StoreNotifyEventToOneUser (Ntf_NotifyEvent_t NotifyEvent,
}
/***** Store notify event *****/
DB_BuildQuery ("INSERT INTO notif"
" (NotifyEvent,ToUsrCod,FromUsrCod,"
"InsCod,CtrCod,DegCod,CrsCod,Cod,TimeNotif,Status)"
" VALUES"
" (%u,%ld,%ld,"
"%ld,%ld,%ld,%ld,%ld,NOW(),%u)",
(unsigned) NotifyEvent,UsrDat->UsrCod,Gbl.Usrs.Me.UsrDat.UsrCod,
InsCod,CtrCod,DegCod,CrsCod,Cod,(unsigned) Status);
DB_QueryINSERT_new ("can not create new notification event");
DB_QueryINSERT ("can not create new notification event",
"INSERT INTO notif"
" (NotifyEvent,ToUsrCod,FromUsrCod,"
"InsCod,CtrCod,DegCod,CrsCod,Cod,TimeNotif,Status)"
" VALUES"
" (%u,%ld,%ld,"
"%ld,%ld,%ld,%ld,%ld,NOW(),%u)",
(unsigned) NotifyEvent,
UsrDat->UsrCod,Gbl.Usrs.Me.UsrDat.UsrCod,
InsCod,CtrCod,DegCod,CrsCod,Cod,(unsigned) Status);
}
/*****************************************************************************/

View File

@ -1009,12 +1009,12 @@ unsigned Pho_UpdateMyClicksWithoutPhoto (void)
else // The user does not exist ==> add him/her
{
/* Add the user, with one access */
DB_BuildQuery ("INSERT INTO clicks_without_photo"
" (UsrCod,NumClicks)"
" VALUES"
" (%ld,1)",
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryINSERT_new ("can not create number of clicks without photo");
DB_QueryINSERT ("can not create number of clicks without photo",
"INSERT INTO clicks_without_photo"
" (UsrCod,NumClicks)"
" VALUES"
" (%ld,1)",
Gbl.Usrs.Me.UsrDat.UsrCod);
NumClicks = 1;
}

View File

@ -880,12 +880,12 @@ static void Plc_CreatePlace (struct Place *Plc)
extern const char *Txt_Created_new_place_X;
/***** Create a new place *****/
DB_BuildQuery ("INSERT INTO places"
" (InsCod,ShortName,FullName)"
" VALUES"
" (%ld,'%s','%s')",
Gbl.CurrentIns.Ins.InsCod,Plc->ShrtName,Plc->FullName);
DB_QueryINSERT_new ("can not create place");
DB_QueryINSERT ("can not create place",
"INSERT INTO places"
" (InsCod,ShortName,FullName)"
" VALUES"
" (%ld,'%s','%s')",
Gbl.CurrentIns.Ins.InsCod,Plc->ShrtName,Plc->FullName);
/***** Write success message *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),

View File

@ -1041,15 +1041,15 @@ static void Plg_CreatePlugin (struct Plugin *Plg)
extern const char *Txt_Created_new_plugin_X;
/***** Create a new plugin *****/
DB_BuildQuery ("INSERT INTO plugins"
" (Name,Description,Logo,"
"AppKey,URL,IP)"
" VALUES"
" ('%s','%s','%s',"
"'%s','%s','%s')",
Plg->Name,Plg->Description,Plg->Logo,
Plg->AppKey,Plg->URL,Plg->IP);
DB_QueryINSERT_new ("can not create plugin");
DB_QueryINSERT ("can not create plugin",
"INSERT INTO plugins"
" (Name,Description,Logo,"
"AppKey,URL,IP)"
" VALUES"
" ('%s','%s','%s',"
"'%s','%s','%s')",
Plg->Name,Plg->Description,Plg->Logo,
Plg->AppKey,Plg->URL,Plg->IP);
/***** Write success message *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),

View File

@ -1040,17 +1040,17 @@ static void Prf_CreateUsrFigures (long UsrCod,const struct UsrFigures *UsrFigure
(long) UsrFigures->FirstClickTimeUTC); // 0 ==> unknown first click time or user never logged
/***** Create user's figures *****/
DB_BuildQuery ("INSERT INTO usr_figures"
" (UsrCod,FirstClickTime,NumClicks,NumFileViews,NumForPst,NumMsgSnt)"
" VALUES"
" (%ld,%s,%ld,%ld,%ld,%ld)",
UsrCod,
SubQueryFirstClickTime,
UsrFigures->NumClicks, // -1L ==> unknown number of clicks
UsrFigures->NumFileViews, // -1L ==> unknown number of file views
UsrFigures->NumForPst, // -1L ==> unknown number of forum posts
UsrFigures->NumMsgSnt); // -1L ==> unknown number of messages sent
DB_QueryINSERT_new ("can not create user's figures");
DB_QueryINSERT ("can not create user's figures",
"INSERT INTO usr_figures"
" (UsrCod,FirstClickTime,NumClicks,NumFileViews,NumForPst,NumMsgSnt)"
" VALUES"
" (%ld,%s,%ld,%ld,%ld,%ld)",
UsrCod,
SubQueryFirstClickTime,
UsrFigures->NumClicks, // -1L ==> unknown number of clicks
UsrFigures->NumFileViews, // -1L ==> unknown number of file views
UsrFigures->NumForPst, // -1L ==> unknown number of forum posts
UsrFigures->NumMsgSnt); // -1L ==> unknown number of messages sent
}
/*****************************************************************************/
@ -1082,10 +1082,10 @@ void Prf_IncrementNumClicksUsr (long UsrCod)
{
/***** Increment number of clicks *****/
// If NumClicks < 0 ==> not yet calculated, so do nothing
DB_BuildQuery ("UPDATE IGNORE usr_figures SET NumClicks=NumClicks+1"
" WHERE UsrCod=%ld AND NumClicks>=0",
UsrCod);
DB_QueryINSERT_new ("can not increment user's clicks");
DB_QueryINSERT ("can not increment user's clicks",
"UPDATE IGNORE usr_figures SET NumClicks=NumClicks+1"
" WHERE UsrCod=%ld AND NumClicks>=0",
UsrCod);
}
/*****************************************************************************/
@ -1096,10 +1096,10 @@ void Prf_IncrementNumFileViewsUsr (long UsrCod)
{
/***** Increment number of file views *****/
// If NumFileViews < 0 ==> not yet calculated, so do nothing
DB_BuildQuery ("UPDATE IGNORE usr_figures SET NumFileViews=NumFileViews+1"
" WHERE UsrCod=%ld AND NumFileViews>=0",
UsrCod);
DB_QueryINSERT_new ("can not increment user's file views");
DB_QueryINSERT ("can not increment user's file views",
"UPDATE IGNORE usr_figures SET NumFileViews=NumFileViews+1"
" WHERE UsrCod=%ld AND NumFileViews>=0",
UsrCod);
}
/*****************************************************************************/
@ -1110,10 +1110,10 @@ void Prf_IncrementNumForPstUsr (long UsrCod)
{
/***** Increment number of forum posts *****/
// If NumForPst < 0 ==> not yet calculated, so do nothing
DB_BuildQuery ("UPDATE IGNORE usr_figures SET NumForPst=NumForPst+1"
" WHERE UsrCod=%ld AND NumForPst>=0",
UsrCod);
DB_QueryINSERT_new ("can not increment user's forum posts");
DB_QueryINSERT ("can not increment user's forum posts",
"UPDATE IGNORE usr_figures SET NumForPst=NumForPst+1"
" WHERE UsrCod=%ld AND NumForPst>=0",
UsrCod);
}
/*****************************************************************************/
@ -1124,10 +1124,10 @@ void Prf_IncrementNumMsgSntUsr (long UsrCod)
{
/***** Increment number of messages sent *****/
// If NumMsgSnt < 0 ==> not yet calculated, so do nothing
DB_BuildQuery ("UPDATE IGNORE usr_figures SET NumMsgSnt=NumMsgSnt+1"
" WHERE UsrCod=%ld AND NumMsgSnt>=0",
UsrCod);
DB_QueryINSERT_new ("can not increment user's messages sent");
DB_QueryINSERT ("can not increment user's messages sent",
"UPDATE IGNORE usr_figures SET NumMsgSnt=NumMsgSnt+1"
" WHERE UsrCod=%ld AND NumMsgSnt>=0",
UsrCod);
}
/*****************************************************************************/

View File

@ -3339,14 +3339,14 @@ static void Prj_CreateProject (struct Project *Prj)
Prj->PrjCod = DB_QueryINSERTandReturnCode_new ("can not create new project");
/***** Insert creator as first tutor *****/
DB_BuildQuery ("INSERT INTO prj_usr"
" (PrjCod,RoleInProject,UsrCod)"
" VALUES"
" (%ld,%u,%ld)",
Prj->PrjCod,
(unsigned) Prj_ROLE_TUT,
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryINSERT_new ("can not add tutor");
DB_QueryINSERT ("can not add tutor",
"INSERT INTO prj_usr"
" (PrjCod,RoleInProject,UsrCod)"
" VALUES"
" (%ld,%u,%ld)",
Prj->PrjCod,
(unsigned) Prj_ROLE_TUT,
Gbl.Usrs.Me.UsrDat.UsrCod);
/***** Flush cache *****/
Prj_FlushCacheMyRoleInProject ();

View File

@ -577,15 +577,15 @@ void Rec_CreateRecordField (void)
extern const char *Txt_Created_new_record_field_X;
/***** Create the new field *****/
DB_BuildQuery ("INSERT INTO crs_record_fields"
" (CrsCod,FieldName,NumLines,Visibility)"
" VALUES"
" (%ld,'%s',%u,%u)",
Gbl.CurrentCrs.Crs.CrsCod,
Gbl.CurrentCrs.Records.Field.Name,
Gbl.CurrentCrs.Records.Field.NumLines,
(unsigned) Gbl.CurrentCrs.Records.Field.Visibility);
DB_QueryINSERT_new ("can not create field of record");
DB_QueryINSERT ("can not create field of record",
"INSERT INTO crs_record_fields"
" (CrsCod,FieldName,NumLines,Visibility)"
" VALUES"
" (%ld,'%s',%u,%u)",
Gbl.CurrentCrs.Crs.CrsCod,
Gbl.CurrentCrs.Records.Field.Name,
Gbl.CurrentCrs.Records.Field.NumLines,
(unsigned) Gbl.CurrentCrs.Records.Field.Visibility);
/***** Write message of success *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -2014,17 +2014,15 @@ void Rec_UpdateCrsRecord (long UsrCod)
}
}
else if (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text[0])
{
/***** Insert text field of record course *****/
DB_BuildQuery ("INSERT INTO crs_records"
" (FieldCod,UsrCod,Txt)"
" VALUES"
" (%ld,%ld,'%s')",
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod,
UsrCod,
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text);
DB_QueryINSERT_new ("can not create field of record");
}
DB_QueryINSERT ("can not create field of record",
"INSERT INTO crs_records"
" (FieldCod,UsrCod,Txt)"
" VALUES"
" (%ld,%ld,'%s')",
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod,
UsrCod,
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text);
}
}

View File

@ -427,24 +427,24 @@ static void Rep_CreateNewReportFile (struct Rep_Report *Report)
static void Rep_CreateNewReportEntryIntoDB (const struct Rep_Report *Report)
{
/***** Insert a new user's usage report into database *****/
DB_BuildQuery ("INSERT INTO usr_report"
" (UsrCod,ReportTimeUTC,"
"UniqueDirL,UniqueDirR,Filename,Permalink)"
" VALUES"
" (%ld,'%04d-%02d-%02d %02d:%02d:%02d',"
"'%c%c','%s','%s','%s')",
Gbl.Usrs.Me.UsrDat.UsrCod,
1900 + Report->tm_CurrentTime.tm_year, // year
1 + Report->tm_CurrentTime.tm_mon, // month
Report->tm_CurrentTime.tm_mday, // day of the month
Report->tm_CurrentTime.tm_hour, // hours
Report->tm_CurrentTime.tm_min, // minutes
Report->tm_CurrentTime.tm_sec, // seconds
Gbl.UniqueNameEncrypted[0], // 2 leftmost chars from a unique 43 chars base64url codified from a unique SHA-256 string
Gbl.UniqueNameEncrypted[1],
&Gbl.UniqueNameEncrypted[2], // 41 rightmost chars from a unique 43 chars base64url codified from a unique SHA-256 string
Report->FilenameReport,Report->Permalink);
DB_QueryINSERT_new ("can not create new user's usage report");
DB_QueryINSERT ("can not create new user's usage report",
"INSERT INTO usr_report"
" (UsrCod,ReportTimeUTC,"
"UniqueDirL,UniqueDirR,Filename,Permalink)"
" VALUES"
" (%ld,'%04d-%02d-%02d %02d:%02d:%02d',"
"'%c%c','%s','%s','%s')",
Gbl.Usrs.Me.UsrDat.UsrCod,
1900 + Report->tm_CurrentTime.tm_year, // year
1 + Report->tm_CurrentTime.tm_mon, // month
Report->tm_CurrentTime.tm_mday, // day of the month
Report->tm_CurrentTime.tm_hour, // hours
Report->tm_CurrentTime.tm_min, // minutes
Report->tm_CurrentTime.tm_sec, // seconds
Gbl.UniqueNameEncrypted[0], // 2 leftmost chars from a unique 43 chars base64url codified from a unique SHA-256 string
Gbl.UniqueNameEncrypted[1],
&Gbl.UniqueNameEncrypted[2], // 41 rightmost chars from a unique 43 chars base64url codified from a unique SHA-256 string
Report->FilenameReport,Report->Permalink);
}
/*****************************************************************************/

View File

@ -155,23 +155,23 @@ void Ses_InsertSessionInDB (void)
if (Gbl.Search.WhatToSearch == Sch_SEARCH_UNKNOWN)
Gbl.Search.WhatToSearch = Sch_WHAT_TO_SEARCH_DEFAULT;
DB_BuildQuery ("INSERT INTO sessions"
" (SessionId,UsrCod,Password,Role,"
"CtyCod,InsCod,CtrCod,DegCod,CrsCod,LastTime,LastRefresh,WhatToSearch)"
" VALUES"
" ('%s',%ld,'%s',%u,"
"%ld,%ld,%ld,%ld,%ld,NOW(),NOW(),%u)",
Gbl.Session.Id,
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Me.UsrDat.Password,
(unsigned) Gbl.Usrs.Me.Role.Logged,
Gbl.CurrentCty.Cty.CtyCod,
Gbl.CurrentIns.Ins.InsCod,
Gbl.CurrentCtr.Ctr.CtrCod,
Gbl.CurrentDeg.Deg.DegCod,
Gbl.CurrentCrs.Crs.CrsCod,
Gbl.Search.WhatToSearch);
DB_QueryINSERT_new ("can not create session");
DB_QueryINSERT ("can not create session",
"INSERT INTO sessions"
" (SessionId,UsrCod,Password,Role,"
"CtyCod,InsCod,CtrCod,DegCod,CrsCod,LastTime,LastRefresh,WhatToSearch)"
" VALUES"
" ('%s',%ld,'%s',%u,"
"%ld,%ld,%ld,%ld,%ld,NOW(),NOW(),%u)",
Gbl.Session.Id,
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Me.UsrDat.Password,
(unsigned) Gbl.Usrs.Me.Role.Logged,
Gbl.CurrentCty.Cty.CtyCod,
Gbl.CurrentIns.Ins.InsCod,
Gbl.CurrentCtr.Ctr.CtrCod,
Gbl.CurrentDeg.Deg.DegCod,
Gbl.CurrentCrs.Crs.CrsCod,
Gbl.Search.WhatToSearch);
}
/*****************************************************************************/
@ -343,16 +343,16 @@ void Ses_InsertHiddenParInDB (Act_Action_t NextAction,
if (!Ses_CheckIfHiddenParIsAlreadyInDB (NextAction,ParamName))
{
/***** Insert parameter in the database *****/
DB_BuildQuery ("INSERT INTO hidden_params"
" (SessionId,Action,ParamName,ParamValue)"
" VALUES"
" ('%s',%ld,'%s','%s')",
Gbl.Session.Id,
Act_GetActCod (NextAction),
ParamName,
ParamValue ? ParamValue :
"");
DB_QueryINSERT_new ("can not create hidden parameter");
DB_QueryINSERT ("can not create hidden parameter",
"INSERT INTO hidden_params"
" (SessionId,Action,ParamName,ParamValue)"
" VALUES"
" ('%s',%ld,'%s','%s')",
Gbl.Session.Id,
Act_GetActCod (NextAction),
ParamName,
ParamValue ? ParamValue :
"");
Gbl.HiddenParamsInsertedIntoDB = true;
}
}

View File

@ -777,16 +777,19 @@ static void Soc_BuildQueryToGetTimeline (char **Query,
if (PubCod > 0)
{
DB_BuildQuery ("INSERT INTO pub_codes SET PubCod=%ld",PubCod);
DB_QueryINSERT_new ("can not store publishing code");
DB_QueryINSERT ("can not store publishing code",
"INSERT INTO pub_codes SET PubCod=%ld",
PubCod);
RangePubsToGet.Top = PubCod; // Narrow the range for the next iteration
/* Get social note code (row[1]) */
NotCod = Str_ConvertStrCodToLongCod (row[1]);
DB_BuildQuery ("INSERT INTO not_codes SET NotCod=%ld",NotCod);
DB_QueryINSERT_new ("can not store note code");
DB_BuildQuery ("INSERT INTO current_timeline SET NotCod=%ld",NotCod);
DB_QueryINSERT_new ("can not store note code");
DB_QueryINSERT ("can not store note code",
"INSERT INTO not_codes SET NotCod=%ld",
NotCod);
DB_QueryINSERT ("can not store note code",
"INSERT INTO current_timeline SET NotCod=%ld",
NotCod);
}
else // Nothing got ==> abort loop
break; // Last publishing
@ -2998,18 +3001,18 @@ static long Soc_ReceiveComment (void)
Soc_PublishSocialNoteInTimeline (&SocPub); // Set SocPub.PubCod
/* Insert comment content in the database */
DB_BuildQuery ("INSERT INTO social_comments"
" (PubCod,Content,ImageName,ImageTitle,ImageURL)"
" VALUES"
" (%ld,'%s','%s','%s','%s')",
SocPub.PubCod,
Content,
Image.Name,
(Image.Name[0] && // Save image title only if image attached
Image.Title) ? Image.Title : "",
(Image.Name[0] && // Save image URL only if image attached
Image.URL ) ? Image.URL : "");
DB_QueryINSERT_new ("can not store comment content");
DB_QueryINSERT ("can not store comment content",
"INSERT INTO social_comments"
" (PubCod,Content,ImageName,ImageTitle,ImageURL)"
" VALUES"
" (%ld,'%s','%s','%s','%s')",
SocPub.PubCod,
Content,
Image.Name,
(Image.Name[0] && // Save image title only if image attached
Image.Title) ? Image.Title : "",
(Image.Name[0] && // Save image URL only if image attached
Image.URL ) ? Image.URL : "");
/***** Store notifications about the new comment *****/
Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_TIMELINE_COMMENT,SocPub.PubCod);
@ -3168,13 +3171,13 @@ static long Soc_FavSocialNote (void)
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have not yet favourited the note
{
/***** Mark as favourite in database *****/
DB_BuildQuery ("INSERT IGNORE INTO social_notes_fav"
" (NotCod,UsrCod,TimeFav)"
" VALUES"
" (%ld,%ld,NOW())",
SocNot.NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryINSERT_new ("can not favourite social note");
DB_QueryINSERT ("can not favourite social note",
"INSERT IGNORE INTO social_notes_fav"
" (NotCod,UsrCod,TimeFav)"
" VALUES"
" (%ld,%ld,NOW())",
SocNot.NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
/* Update number of times this social note is favourited */
SocNot.NumFavs = Soc_GetNumTimesANoteHasBeenFav (&SocNot);
@ -3256,13 +3259,13 @@ static long Soc_FavSocialComment (void)
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have not yet favourited the comment
{
/***** Mark as favourite in database *****/
DB_BuildQuery ("INSERT IGNORE INTO social_comments_fav"
" (PubCod,UsrCod,TimeFav)"
" VALUES"
" (%ld,%ld,NOW())",
SocCom.PubCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryINSERT_new ("can not favourite social comment");
DB_QueryINSERT ("can not favourite social comment",
"INSERT IGNORE INTO social_comments_fav"
" (PubCod,UsrCod,TimeFav)"
" VALUES"
" (%ld,%ld,NOW())",
SocCom.PubCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
/* Update number of times this social comment is favourited */
SocCom.NumFavs = Soc_GetNumTimesACommHasBeenFav (&SocCom);
@ -4756,11 +4759,11 @@ static void Soc_ClearTimelineThisSession (void)
static void Soc_AddNotesJustRetrievedToTimelineThisSession (void)
{
DB_BuildQuery ("INSERT IGNORE INTO social_timelines"
" (SessionId,NotCod)"
" SELECT DISTINCTROW '%s',NotCod FROM not_codes",
Gbl.Session.Id);
DB_QueryINSERT_new ("can not insert social notes in timeline");
DB_QueryINSERT ("can not insert social notes in timeline",
"INSERT IGNORE INTO social_timelines"
" (SessionId,NotCod)"
" SELECT DISTINCTROW '%s',NotCod FROM not_codes",
Gbl.Session.Id);
}
/*****************************************************************************/

View File

@ -313,24 +313,24 @@ void Sta_LogAccess (const char *Comments)
LogCod = DB_QueryINSERTandReturnCode_new ("can not log access (full)");
/* Log access in recent log (log_recent) */
DB_BuildQuery ("INSERT INTO log_recent "
"(LogCod,ActCod,CtyCod,InsCod,CtrCod,DegCod,CrsCod,UsrCod,"
"Role,ClickTime,TimeToGenerate,TimeToSend,IP)"
" VALUES "
"(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,"
"%u,NOW(),%ld,%ld,'%s')",
LogCod,ActCod,
Gbl.CurrentCty.Cty.CtyCod,
Gbl.CurrentIns.Ins.InsCod,
Gbl.CurrentCtr.Ctr.CtrCod,
Gbl.CurrentDeg.Deg.DegCod,
Gbl.CurrentCrs.Crs.CrsCod,
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) RoleToStore,
Gbl.TimeGenerationInMicroseconds,
Gbl.TimeSendInMicroseconds,
Gbl.IP);
DB_QueryINSERT_new ("can not log access (recent)");
DB_QueryINSERT ("can not log access (recent)",
"INSERT INTO log_recent "
"(LogCod,ActCod,CtyCod,InsCod,CtrCod,DegCod,CrsCod,UsrCod,"
"Role,ClickTime,TimeToGenerate,TimeToSend,IP)"
" VALUES "
"(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,"
"%u,NOW(),%ld,%ld,'%s')",
LogCod,ActCod,
Gbl.CurrentCty.Cty.CtyCod,
Gbl.CurrentIns.Ins.InsCod,
Gbl.CurrentCtr.Ctr.CtrCod,
Gbl.CurrentDeg.Deg.DegCod,
Gbl.CurrentCrs.Crs.CrsCod,
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) RoleToStore,
Gbl.TimeGenerationInMicroseconds,
Gbl.TimeSendInMicroseconds,
Gbl.IP);
if (Comments)
{
@ -375,27 +375,22 @@ void Sta_LogAccess (const char *Comments)
}
if (Gbl.WebService.IsWebService)
{
/* Log web service plugin and function */
DB_BuildQuery ("INSERT INTO log_ws"
" (LogCod,PlgCod,FunCod)"
" VALUES"
" (%ld,%ld,%u)",
LogCod,Gbl.WebService.PlgCod,
(unsigned) Gbl.WebService.Function);
DB_QueryINSERT_new ("can not log access (comments)");
}
DB_QueryINSERT ("can not log access (comments)",
"INSERT INTO log_ws"
" (LogCod,PlgCod,FunCod)"
" VALUES"
" (%ld,%ld,%u)",
LogCod,Gbl.WebService.PlgCod,
(unsigned) Gbl.WebService.Function);
else if (Gbl.Banners.BanCodClicked > 0)
{
/* Log banner clicked */
DB_BuildQuery ("INSERT INTO log_banners"
" (LogCod,BanCod)"
" VALUES"
" (%ld,%ld)",
LogCod,Gbl.Banners.BanCodClicked);
DB_QueryINSERT_new ("can not log banner clicked");
}
DB_QueryINSERT ("can not log banner clicked",
"INSERT INTO log_banners"
" (LogCod,BanCod)"
" VALUES"
" (%ld,%ld)",
LogCod,Gbl.Banners.BanCodClicked);
/***** Increment my number of clicks *****/
if (Gbl.Usrs.Me.Logged)

View File

@ -2390,15 +2390,13 @@ static void Svy_CreateGrps (long SvyCod)
for (NumGrpSel = 0;
NumGrpSel < Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps;
NumGrpSel++)
{
/* Create group */
DB_BuildQuery ("INSERT INTO svy_grp"
" (SvyCod,GrpCod)"
" VALUES"
" (%ld,%ld)",
SvyCod,Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]);
DB_QueryINSERT_new ("can not associate a group to a survey");
}
DB_QueryINSERT ("can not associate a group to a survey",
"INSERT INTO svy_grp"
" (SvyCod,GrpCod)"
" VALUES"
" (%ld,%ld)",
SvyCod,Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]);
}
/*****************************************************************************/
@ -3062,15 +3060,13 @@ void Svy_ReceiveQst (void)
else // If this answer does not exist...
{
if (SvyQst.AnsChoice[NumAns].Text[0]) // Answer is not empty
{
/* Create answer into database */
DB_BuildQuery ("INSERT INTO svy_answers"
" (QstCod,AnsInd,NumUsrs,Answer)"
" VALUES"
" (%ld,%u,0,'%s')",
SvyQst.QstCod,NumAns,SvyQst.AnsChoice[NumAns].Text);
DB_QueryINSERT_new ("can not create answer");
}
DB_QueryINSERT ("can not create answer",
"INSERT INTO svy_answers"
" (QstCod,AnsInd,NumUsrs,Answer)"
" VALUES"
" (%ld,%u,0,'%s')",
SvyQst.QstCod,NumAns,SvyQst.AnsChoice[NumAns].Text);
}
/***** List the questions of this survey, including the new one just inserted into the database *****/
@ -3733,12 +3729,12 @@ static void Svy_IncreaseAnswerInDB (long QstCod,unsigned AnsInd)
static void Svy_RegisterIHaveAnsweredSvy (long SvyCod)
{
DB_BuildQuery ("INSERT INTO svy_users"
" (SvyCod,UsrCod)"
" VALUES"
" (%ld,%ld)",
SvyCod,Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryINSERT_new ("can not register that you have answered the survey");
DB_QueryINSERT ("can not register that you have answered the survey",
"INSERT INTO svy_users"
" (SvyCod,UsrCod)"
" VALUES"
" (%ld,%ld)",
SvyCod,Gbl.Usrs.Me.UsrDat.UsrCod);
}
/*****************************************************************************/

View File

@ -6615,12 +6615,12 @@ static void Tst_InsertTagsIntoDB (void)
TagCod = Tst_CreateNewTag (Gbl.CurrentCrs.Crs.CrsCod,Gbl.Test.Tags.Txt[NumTag]);
/***** Insert tag in tst_question_tags *****/
DB_BuildQuery ("INSERT INTO tst_question_tags"
" (QstCod,TagCod,TagInd)"
" VALUES"
" (%ld,%ld,%u)",
Gbl.Test.QstCod,TagCod,TagIdx);
DB_QueryINSERT_new ("can not create tag");
DB_QueryINSERT ("can not create tag",
"INSERT INTO tst_question_tags"
" (QstCod,TagCod,TagInd)"
" VALUES"
" (%ld,%ld,%u)",
Gbl.Test.QstCod,TagCod,TagIdx);
TagIdx++;
}
@ -6648,41 +6648,39 @@ static void Tst_InsertAnswersIntoDB (void)
switch (Gbl.Test.AnswerType)
{
case Tst_ANS_INT:
DB_BuildQuery ("INSERT INTO tst_answers"
" (QstCod,AnsInd,Answer,Feedback,"
"ImageName,ImageTitle,ImageURL,Correct)"
" VALUES"
" (%ld,0,%ld,'','','','','Y')",
Gbl.Test.QstCod,
Gbl.Test.Answer.Integer);
DB_QueryINSERT_new ("can not create answer");
DB_QueryINSERT ("can not create answer",
"INSERT INTO tst_answers"
" (QstCod,AnsInd,Answer,Feedback,"
"ImageName,ImageTitle,ImageURL,Correct)"
" VALUES"
" (%ld,0,%ld,'','','','','Y')",
Gbl.Test.QstCod,
Gbl.Test.Answer.Integer);
break;
case Tst_ANS_FLOAT:
Str_SetDecimalPointToUS (); // To print the floating point as a dot
for (i = 0;
i < 2;
i++)
{
DB_BuildQuery ("INSERT INTO tst_answers"
" (QstCod,AnsInd,Answer,Feedback,"
"ImageName,ImageTitle,ImageURL,Correct)"
" VALUES"
" (%ld,%u,'%lg','','','','','Y')",
Gbl.Test.QstCod,i,
Gbl.Test.Answer.FloatingPoint[i]);
DB_QueryINSERT_new ("can not create answer");
}
DB_QueryINSERT ("can not create answer",
"INSERT INTO tst_answers"
" (QstCod,AnsInd,Answer,Feedback,"
"ImageName,ImageTitle,ImageURL,Correct)"
" VALUES"
" (%ld,%u,'%lg','','','','','Y')",
Gbl.Test.QstCod,i,
Gbl.Test.Answer.FloatingPoint[i]);
Str_SetDecimalPointToLocal (); // Return to local system
break;
case Tst_ANS_TRUE_FALSE:
DB_BuildQuery ("INSERT INTO tst_answers"
" (QstCod,AnsInd,Answer,Feedback,"
"ImageName,ImageTitle,ImageURL,Correct)"
" VALUES"
" (%ld,0,'%c','','','','','Y')",
Gbl.Test.QstCod,
Gbl.Test.Answer.TF);
DB_QueryINSERT_new ("can not create answer");
DB_QueryINSERT ("can not create answer",
"INSERT INTO tst_answers"
" (QstCod,AnsInd,Answer,Feedback,"
"ImageName,ImageTitle,ImageURL,Correct)"
" VALUES"
" (%ld,0,'%c','','','','','Y')",
Gbl.Test.QstCod,
Gbl.Test.Answer.TF);
break;
case Tst_ANS_UNIQUE_CHOICE:
case Tst_ANS_MULTIPLE_CHOICE:
@ -6692,20 +6690,20 @@ static void Tst_InsertAnswersIntoDB (void)
NumOpt++)
if (Gbl.Test.Answer.Options[NumOpt].Text[0])
{
DB_BuildQuery ("INSERT INTO tst_answers"
" (QstCod,AnsInd,Answer,Feedback,"
"ImageName,ImageTitle,ImageURL,Correct)"
" VALUES"
" (%ld,%u,'%s','%s','%s','%s','%s','%c')",
Gbl.Test.QstCod,NumOpt,
Gbl.Test.Answer.Options[NumOpt].Text,
Gbl.Test.Answer.Options[NumOpt].Feedback ? Gbl.Test.Answer.Options[NumOpt].Feedback : "",
Gbl.Test.Answer.Options[NumOpt].Image.Name,
Gbl.Test.Answer.Options[NumOpt].Image.Title ? Gbl.Test.Answer.Options[NumOpt].Image.Title : "",
Gbl.Test.Answer.Options[NumOpt].Image.URL ? Gbl.Test.Answer.Options[NumOpt].Image.URL : "",
Gbl.Test.Answer.Options[NumOpt].Correct ? 'Y' :
'N');
DB_QueryINSERT_new ("can not create answer");
DB_QueryINSERT ("can not create answer",
"INSERT INTO tst_answers"
" (QstCod,AnsInd,Answer,Feedback,"
"ImageName,ImageTitle,ImageURL,Correct)"
" VALUES"
" (%ld,%u,'%s','%s','%s','%s','%s','%c')",
Gbl.Test.QstCod,NumOpt,
Gbl.Test.Answer.Options[NumOpt].Text,
Gbl.Test.Answer.Options[NumOpt].Feedback ? Gbl.Test.Answer.Options[NumOpt].Feedback : "",
Gbl.Test.Answer.Options[NumOpt].Image.Name,
Gbl.Test.Answer.Options[NumOpt].Image.Title ? Gbl.Test.Answer.Options[NumOpt].Image.Title : "",
Gbl.Test.Answer.Options[NumOpt].Image.URL ? Gbl.Test.Answer.Options[NumOpt].Image.URL : "",
Gbl.Test.Answer.Options[NumOpt].Correct ? 'Y' :
'N');
/* Update image status */
if (Gbl.Test.Answer.Options[NumOpt].Image.Name[0])
@ -8503,17 +8501,17 @@ static void Tst_StoreOneTestResultQstInDB (long TstCod,long QstCod,unsigned NumQ
/***** Insert question and user's answers into database *****/
Str_SetDecimalPointToUS (); // To print the floating point as a dot
DB_BuildQuery ("INSERT INTO tst_exam_questions"
" (TstCod,QstCod,QstInd,Score,Indexes,Answers)"
" VALUES"
" (%ld,%ld,%u,'%lf','%s','%s')",
TstCod,QstCod,
NumQst, // 0, 1, 2, 3...
Score,
Indexes,
Answers);
DB_QueryINSERT ("can not insert a question of a test result",
"INSERT INTO tst_exam_questions"
" (TstCod,QstCod,QstInd,Score,Indexes,Answers)"
" VALUES"
" (%ld,%ld,%u,'%lf','%s','%s')",
TstCod,QstCod,
NumQst, // 0, 1, 2, 3...
Score,
Indexes,
Answers);
Str_SetDecimalPointToLocal (); // Return to local system
DB_QueryINSERT_new ("can not insert a question of a test result");
}
/*****************************************************************************/

View File

@ -583,24 +583,22 @@ static void TT_WriteCrsTimeTableIntoDB (long CrsCod)
Column++)
if (TT_TimeTable[Weekday][Interval].Columns[Column].IntervalType == TT_FIRST_INTERVAL &&
TT_TimeTable[Weekday][Interval].Columns[Column].DurationIntervals)
{
DB_BuildQuery ("INSERT INTO timetable_crs"
" (CrsCod,GrpCod,Weekday,StartTime,Duration,"
"ClassType,Place,GroupName)"
" VALUES"
" (%ld,%ld,%u,'%02u:%02u:00',SEC_TO_TIME(%u),"
"'%s','%s','%s')",
CrsCod,
TT_TimeTable[Weekday][Interval].Columns[Column].GrpCod,
Weekday,
Hour,Min,
TT_TimeTable[Weekday][Interval].Columns[Column].DurationIntervals *
Gbl.TimeTable.Config.SecondsPerInterval,
TT_ClassTypeDB[TT_TimeTable[Weekday][Interval].Columns[Column].ClassType],
TT_TimeTable[Weekday][Interval].Columns[Column].Place,
TT_TimeTable[Weekday][Interval].Columns[Column].Group);
DB_QueryINSERT_new ("can not create course timetable");
}
DB_QueryINSERT ("can not create course timetable",
"INSERT INTO timetable_crs"
" (CrsCod,GrpCod,Weekday,StartTime,Duration,"
"ClassType,Place,GroupName)"
" VALUES"
" (%ld,%ld,%u,'%02u:%02u:00',SEC_TO_TIME(%u),"
"'%s','%s','%s')",
CrsCod,
TT_TimeTable[Weekday][Interval].Columns[Column].GrpCod,
Weekday,
Hour,Min,
TT_TimeTable[Weekday][Interval].Columns[Column].DurationIntervals *
Gbl.TimeTable.Config.SecondsPerInterval,
TT_ClassTypeDB[TT_TimeTable[Weekday][Interval].Columns[Column].ClassType],
TT_TimeTable[Weekday][Interval].Columns[Column].Place,
TT_TimeTable[Weekday][Interval].Columns[Column].Group);
}
/*****************************************************************************/
@ -633,19 +631,17 @@ static void TT_WriteTutTimeTableIntoDB (long UsrCod)
Column++)
if (TT_TimeTable[Weekday][Interval].Columns[Column].IntervalType == TT_FIRST_INTERVAL &&
TT_TimeTable[Weekday][Interval].Columns[Column].DurationIntervals)
{
DB_BuildQuery ("INSERT INTO timetable_tut"
" (UsrCod,Weekday,StartTime,Duration,Place)"
" VALUES"
" (%ld,%u,'%02u:%02u:00',SEC_TO_TIME(%u),'%s')",
UsrCod,
Weekday,
Hour,Min,
TT_TimeTable[Weekday][Interval].Columns[Column].DurationIntervals *
Gbl.TimeTable.Config.SecondsPerInterval,
TT_TimeTable[Weekday][Interval].Columns[Column].Place);
DB_QueryINSERT_new ("can not create office timetable");
}
DB_QueryINSERT ("can not create office timetable",
"INSERT INTO timetable_tut"
" (UsrCod,Weekday,StartTime,Duration,Place)"
" VALUES"
" (%ld,%u,'%02u:%02u:00',SEC_TO_TIME(%u),'%s')",
UsrCod,
Weekday,
Hour,Min,
TT_TimeTable[Weekday][Interval].Columns[Column].DurationIntervals *
Gbl.TimeTable.Config.SecondsPerInterval,
TT_TimeTable[Weekday][Interval].Columns[Column].Place);
}
/*****************************************************************************/

View File

@ -2585,12 +2585,12 @@ static void Usr_InsertMyBirthday (void)
DB_QueryDELETE_new ("can not delete old birthdays");
/***** Insert new birthday *****/
DB_BuildQuery ("INSERT INTO birthdays_today"
" (UsrCod,Today)"
" VALUES"
" (%ld,CURDATE())",
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryINSERT_new ("can not insert birthday");
DB_QueryINSERT ("can not insert birthday",
"INSERT INTO birthdays_today"
" (UsrCod,Today)"
" VALUES"
" (%ld,CURDATE())",
Gbl.Usrs.Me.UsrDat.UsrCod);
}
/*****************************************************************************/
@ -3413,16 +3413,16 @@ void Usr_UpdateMyLastData (void)
static void Usr_InsertMyLastData (void)
{
/***** Insert my last accessed course, tab and time of click in database *****/
DB_BuildQuery ("INSERT INTO usr_last"
" (UsrCod,WhatToSearch,LastCrs,LastTab,LastTime,LastAccNotif)"
" VALUES"
" (%ld,%u,%ld,%u,NOW(),FROM_UNIXTIME(%ld))",
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) Sch_SEARCH_ALL,
Gbl.CurrentCrs.Crs.CrsCod,
(unsigned) Gbl.Action.Tab,
(long) (time_t) 0); // The user never accessed to notifications
DB_QueryINSERT_new ("can not insert last user's data");
DB_QueryINSERT ("can not insert last user's data",
"INSERT INTO usr_last"
" (UsrCod,WhatToSearch,LastCrs,LastTab,LastTime,LastAccNotif)"
" VALUES"
" (%ld,%u,%ld,%u,NOW(),FROM_UNIXTIME(%ld))",
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) Sch_SEARCH_ALL,
Gbl.CurrentCrs.Crs.CrsCod,
(unsigned) Gbl.Action.Tab,
(long) (time_t) 0); // The user never accessed to notifications
}
/*****************************************************************************/

View File

@ -461,12 +461,12 @@ static int Svc_GenerateNewWSKey (long UsrCod,
"Generated key already existed in database");
/***** Insert key into database *****/
DB_BuildQuery ("INSERT INTO ws_keys"
" (WSKey,UsrCod,PlgCod,LastTime)"
" VALUES"
" ('%s',%ld,%ld,NOW())",
WSKey,UsrCod,Gbl.WebService.PlgCod);
DB_QueryINSERT_new ("can not insert new key");
DB_QueryINSERT ("can not insert new key",
"INSERT INTO ws_keys"
" (WSKey,UsrCod,PlgCod,LastTime)"
" VALUES"
" ('%s',%ld,%ld,NOW())",
WSKey,UsrCod,Gbl.WebService.PlgCod);
return SOAP_OK;
}
@ -3434,39 +3434,39 @@ static int Svc_SendMessageToUsr (long OriginalMsgCod,
NewMsgCod = DB_QueryINSERTandReturnCode_new ("can not create message");
/***** Insert message in sent messages *****/
DB_BuildQuery ("INSERT INTO msg_snt"
" (MsgCod,CrsCod,UsrCod,Expanded,CreatTime)"
" VALUES"
" (%ld,-1,%ld,'N',NOW())",
NewMsgCod,SenderUsrCod);
DB_QueryINSERT_new ("can not create message");
DB_QueryINSERT ("can not create message",
"INSERT INTO msg_snt"
" (MsgCod,CrsCod,UsrCod,Expanded,CreatTime)"
" VALUES"
" (%ld,-1,%ld,'N',NOW())",
NewMsgCod,SenderUsrCod);
MsgAlreadyInserted = true;
}
/***** Insert message received in the database *****/
DB_BuildQuery ("INSERT INTO msg_rcv"
" (MsgCod,UsrCod,Notified,Open,Replied,Expanded)"
" VALUES"
" (%ld,%ld,'%c','N','N','N')",
NewMsgCod,RecipientUsrCod,
NotifyByEmail ? 'Y' :
'N');
DB_QueryINSERT_new ("can not create received message");
DB_QueryINSERT ("can not create received message",
"INSERT INTO msg_rcv"
" (MsgCod,UsrCod,Notified,Open,Replied,Expanded)"
" VALUES"
" (%ld,%ld,'%c','N','N','N')",
NewMsgCod,RecipientUsrCod,
NotifyByEmail ? 'Y' :
'N');
/***** Create notification for this recipient.
If this recipient wants to receive notifications by email, activate the sending of a notification *****/
DB_BuildQuery ("INSERT INTO notif"
" (NotifyEvent,ToUsrCod,FromUsrCod,InsCod,DegCod,CrsCod,Cod,TimeNotif,Status)"
" VALUES"
" (%u,%ld,%ld,-1,-1,-1,%ld,NOW(),%u)",
(unsigned) Ntf_EVENT_MESSAGE,
RecipientUsrCod,
SenderUsrCod,
NewMsgCod,
(unsigned) (NotifyByEmail ? Ntf_STATUS_BIT_EMAIL :
0));
DB_QueryINSERT_new ("can not create new notification event");
DB_QueryINSERT ("can not create new notification event",
"INSERT INTO notif"
" (NotifyEvent,ToUsrCod,FromUsrCod,InsCod,DegCod,CrsCod,Cod,TimeNotif,Status)"
" VALUES"
" (%u,%ld,%ld,-1,-1,-1,%ld,NOW(),%u)",
(unsigned) Ntf_EVENT_MESSAGE,
RecipientUsrCod,
SenderUsrCod,
NewMsgCod,
(unsigned) (NotifyByEmail ? Ntf_STATUS_BIT_EMAIL :
0));
/***** If this recipient is the original sender of a message been replied... *****/
if (RecipientUsrCod == ReplyUsrCod)
@ -4111,13 +4111,6 @@ int swad__getTrivialQuestion (struct soap *soap,
/***** Loop over recipients' nicknames building query *****/
DegreesStr[0] = '\0';
Ptr = degrees;
/*
if (Gbl.Usrs.Me.UsrDat.UsrCod == 19543)
{
DB_BuildQuery ("INSERT INTO debug (DebugTime,Txt) VALUES (NOW(),'degrees = %s')",degrees);
DB_QueryINSERT_new ("Error inserting in debug table");
}
*/
while (*Ptr)
{
/* Find next string in text until comma (leading and trailing spaces are removed) */
@ -4187,13 +4180,6 @@ int swad__getTrivialQuestion (struct soap *soap,
if (NumRows == 1) // Question found
{
/*
if (Gbl.Usrs.Me.UsrDat.UsrCod == 19543)
{
DB_BuildQuery ("INSERT INTO debug (DebugTime,Txt) VALUES (NOW(),'Una pregunta devuelta')");
DB_QueryINSERT_new ("Error inserting in debug table");
}
*/
/* Get next question */
row = mysql_fetch_row (mysql_res);