Version 18.8.10

This commit is contained in:
Antonio Cañas Vargas 2018-10-27 14:14:34 +02:00
parent 187ac31346
commit 6979650877
32 changed files with 322 additions and 452 deletions

View File

@ -1020,18 +1020,15 @@ static void ID_NewUsrID (const struct UsrData *UsrDat,bool ItsMe)
static void ID_InsertANewUsrIDInDB (long UsrCod,const char *NewID,bool Confirmed)
{
char *Query;
/***** Update my nickname in database *****/
if (asprintf (&Query,"INSERT INTO usr_IDs"
" (UsrCod,UsrID,CreatTime,Confirmed)"
" VALUES"
" (%ld,'%s',NOW(),'%c')",
UsrCod,NewID,
Confirmed ? 'Y' :
'N') < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not insert a new ID");
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");
}
/*****************************************************************************/
@ -1156,12 +1153,9 @@ void ID_ConfirmOtherUsrID (void)
void ID_ConfirmUsrID (const struct UsrData *UsrDat,const char *UsrID)
{
char *Query;
/***** Update database *****/
if (asprintf (&Query,"UPDATE usr_IDs SET Confirmed='Y'"
" WHERE UsrCod=%ld AND UsrID='%s' AND Confirmed<>'Y'",
UsrDat->UsrCod,UsrID) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not confirm a user's ID");
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");
}

View File

@ -712,7 +712,6 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount)
char BirthdayStrDB[Usr_BIRTHDAY_STR_DB_LENGTH + 1];
char *QueryUsrData;
size_t CommentsLength;
char *QueryUsrIDs;
char PathRelUsr[PATH_MAX + 1];
unsigned NumID;
@ -781,16 +780,15 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount)
NumID++)
{
Str_ConvertToUpperText (UsrDat->IDs.List[NumID].ID);
if (asprintf (&QueryUsrIDs,"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') < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (QueryUsrIDs,"can not store user's ID when creating user");
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");
}
/***** Create directory for the user, if not exists *****/

View File

@ -512,16 +512,13 @@ void Ann_ReceiveAnnouncement (void)
static void Ann_CreateAnnouncement (unsigned Roles,const char *Subject,const char *Content)
{
char *Query;
/***** Select announcements not seen *****/
if (asprintf (&Query,"INSERT INTO announcements"
" (Roles,Subject,Content)"
" VALUES"
" (%u,'%s','%s')",
Roles,Subject,Content) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not create announcement");
DB_BuildQuery ("INSERT INTO announcements"
" (Roles,Subject,Content)"
" VALUES"
" (%u,'%s','%s')",
Roles,Subject,Content);
DB_QueryINSERT_new ("can not create announcement");
}
/*****************************************************************************/

View File

@ -1612,7 +1612,6 @@ void Asg_RemoveGroupsOfType (long GrpTypCod)
static void Asg_CreateGrps (long AsgCod)
{
unsigned NumGrpSel;
char *Query;
/***** Create groups of the assignment *****/
for (NumGrpSel = 0;
@ -1620,13 +1619,12 @@ static void Asg_CreateGrps (long AsgCod)
NumGrpSel++)
{
/* Create group */
if (asprintf (&Query,"INSERT INTO asg_grp"
" (AsgCod,GrpCod)"
" VALUES"
" (%ld,%ld)",
AsgCod,Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not associate a group to an assignment");
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");
}
}

View File

@ -1487,7 +1487,6 @@ void Att_RemoveGroupsOfType (long GrpTypCod)
static void Att_CreateGrps (long AttCod)
{
unsigned NumGrpSel;
char *Query;
/***** Create groups of the attendance event *****/
for (NumGrpSel = 0;
@ -1495,13 +1494,12 @@ static void Att_CreateGrps (long AttCod)
NumGrpSel++)
{
/* Create group */
if (asprintf (&Query,"INSERT INTO att_grp"
" (AttCod,GrpCod)"
" VALUES"
" (%ld,%ld)",
AttCod,Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not associate a group to an attendance event");
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");
}
}

View File

@ -994,16 +994,14 @@ void Ban_RecFormNewBanner (void)
static void Ban_CreateBanner (struct Banner *Ban)
{
extern const char *Txt_Created_new_banner_X;
char *Query;
/***** Create a new banner *****/
if (asprintf (&Query,"INSERT INTO banners"
" (Hidden,ShortName,FullName,Img,WWW)"
" VALUES"
" ('N','%s','%s','%s','%s')",
Ban->ShrtName,Ban->FullName,Ban->Img,Ban->WWW) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not create 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");
/***** 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.8.9 (2018-10-26)"
#define Log_PLATFORM_VERSION "SWAD 18.8.10 (2018-10-27)"
#define CSS_FILE "swad18.4.css"
#define JS_FILE "swad17.17.1.js"
/*
Version 18.8.10: Oct 27, 2018 Some asprintf for database queries changed by internal function. (236975 lines)
Version 18.8.9: Oct 26, 2018 Some asprintf for database queries changed by internal function. (237082 lines)
Version 18.8.8: Oct 26, 2018 Some asprintf for database queries changed by internal function. (237154 lines)
Version 18.8.7: Oct 26, 2018 Some asprintf for database queries changed by internal function. (237172 lines)

View File

@ -2221,7 +2221,6 @@ static void Cty_CreateCountry (struct Country *Cty)
char SubQueryNam2[Cty_MAX_BYTES_SUBQUERY_CTYS_NAME + 1];
char SubQueryWWW1[Cty_MAX_BYTES_SUBQUERY_CTYS + 1];
char SubQueryWWW2[Cty_MAX_BYTES_SUBQUERY_CTYS_WWW + 1];
char *Query;
/***** Create a new country *****/
SubQueryNam1[0] = '\0';
@ -2258,14 +2257,13 @@ static void Cty_CreateCountry (struct Country *Cty)
Str_Concat (SubQueryWWW2,"'",
Cty_MAX_BYTES_SUBQUERY_CTYS_WWW);
}
if (asprintf (&Query,"INSERT INTO countries"
" (CtyCod,Alpha2%s%s)"
" VALUES"
" ('%03ld','%s'%s%s)",
SubQueryNam1,SubQueryWWW1,
Cty->CtyCod,Cty->Alpha2,SubQueryNam2,SubQueryWWW2) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not create country");
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");
/***** Write success message *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),

View File

@ -2218,14 +2218,14 @@ static void Crs_EmptyCourseCompletely (long CrsCod)
/***** Remove notices in the course *****/
/* Copy all notices from the course to table of deleted notices */
if (asprintf (&Query,"INSERT INTO notices_deleted"
" (NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif)"
" SELECT NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif"
" FROM notices"
" WHERE CrsCod=%ld",
CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not remove notices in a course");
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");
/* Remove all notices from the course */
if (asprintf (&Query,"DELETE FROM notices WHERE CrsCod=%ld",CrsCod) < 0)
Lay_NotEnoughMemoryExit ();

View File

@ -3128,24 +3128,6 @@ unsigned long DB_QuerySELECT_new (MYSQL_RES **mysql_res,const char *MsgError)
return (unsigned long) mysql_num_rows (*mysql_res);
}
unsigned long DB_QuerySELECT_free (const char *Query,MYSQL_RES **mysql_res,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);
/***** Store query result *****/
if ((*mysql_res = mysql_store_result (&Gbl.mysql)) == NULL)
DB_ExitOnMySQLError (MsgError);
/***** Return number of rows of result *****/
return (unsigned long) mysql_num_rows (*mysql_res);
}
unsigned long DB_QuerySELECT (const char *Query,MYSQL_RES **mysql_res,const char *MsgError)
{
/***** Query database *****/
@ -3184,26 +3166,6 @@ unsigned long DB_QueryCOUNT_new (const char *MsgError)
return NumRows;
}
unsigned long DB_QueryCOUNT_free (const char *Query,const char *MsgError)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRows;
/***** Make query "SELECT COUNT(*) FROM..." *****/
DB_QuerySELECT_free (Query,&mysql_res,MsgError);
/***** Get number of rows *****/
row = mysql_fetch_row (mysql_res);
if (sscanf (row[0],"%lu",&NumRows) != 1)
Lay_ShowErrorAndExit ("Error when counting number of rows.");
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
return NumRows;
}
unsigned long DB_QueryCOUNT (const char *Query,const char *MsgError)
{
MYSQL_RES *mysql_res;

View File

@ -40,11 +40,9 @@ void DB_CloseDBConnection (void);
void DB_BuildQuery (const char *fmt,...);
unsigned long DB_QuerySELECT_new (MYSQL_RES **mysql_res,const char *MsgError);
unsigned long DB_QuerySELECT_free (const char *Query,MYSQL_RES **mysql_res,const char *MsgError);
unsigned long DB_QuerySELECT (const char *Query,MYSQL_RES **mysql_res,const char *MsgError);
unsigned long DB_QueryCOUNT_new (const char *MsgError);
unsigned long DB_QueryCOUNT_free (const char *Query,const char *MsgError);
unsigned long DB_QueryCOUNT (const char *Query,const char *MsgError);
void DB_QueryINSERT_new (const char *MsgError);

View File

@ -544,13 +544,11 @@ static void DT_PutHeadDegreeTypesForEdition (void)
static void DT_CreateDegreeType (struct DegreeType *DegTyp)
{
extern const char *Txt_Created_new_type_of_degree_X;
char *Query;
/***** Create a new degree type *****/
if (asprintf (&Query,"INSERT INTO deg_types SET DegTypName='%s'",
DegTyp->DegTypName) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not create a new type of degree");
DB_BuildQuery ("INSERT INTO deg_types SET DegTypName='%s'",
DegTyp->DegTypName);
DB_QueryINSERT_new ("can not create a new type of degree");
/***** Write success message *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),

View File

@ -1061,16 +1061,14 @@ void Dpt_RecFormNewDpt (void)
static void Dpt_CreateDepartment (struct Department *Dpt)
{
extern const char *Txt_Created_new_department_X;
char *Query;
/***** Create a new department *****/
if (asprintf (&Query,"INSERT INTO departments"
" (InsCod,ShortName,FullName,WWW)"
" VALUES"
" (%ld,'%s','%s','%s')",
Dpt->InsCod,Dpt->ShrtName,Dpt->FullName,Dpt->WWW) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not 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");
/***** Write success message *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),

View File

@ -82,7 +82,6 @@ void Dup_ReportUsrAsPossibleDuplicate (void)
{
extern const char *Txt_Thank_you_for_reporting_a_possible_duplicate_user;
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
char *Query;
bool ItsMe;
/***** Get user to be reported as possible duplicate *****/
@ -93,14 +92,13 @@ void Dup_ReportUsrAsPossibleDuplicate (void)
if (!ItsMe && Gbl.Usrs.Me.Role.Logged >= Rol_TCH)
{
/***** Insert possible duplicate into database *****/
if (asprintf (&Query,"REPLACE INTO usr_duplicated"
" (UsrCod,InformerCod,InformTime)"
" VALUES"
" (%ld,%ld,NOW())",
Gbl.Usrs.Other.UsrDat.UsrCod,
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not report duplicate");
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");
/***** Show feedback message *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_Thank_you_for_reporting_a_possible_duplicate_user);

View File

@ -254,7 +254,6 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole,
Enr_KeepOrSetAccepted_t KeepOrSetAccepted)
{
extern const char *Usr_StringsUsrListTypeInDB[Usr_NUM_USR_LIST_TYPES];
char *Query;
/***** Check if user's role is allowed *****/
switch (NewRole)
@ -268,26 +267,25 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole,
}
/***** Register user in current course in database *****/
if (asprintf (&Query,"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') < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not register user in course");
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");
/***** Flush caches *****/
Usr_FlushCachesUsr ();

View File

@ -7879,18 +7879,16 @@ static void Brw_AddPathToClipboards (void)
{
long Cod = Brw_GetCodForClipboard ();
long WorksUsrCod = Brw_GetWorksUsrCodForClipboard ();
char *Query;
/***** Add path to clipboards *****/
if (asprintf (&Query,"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) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not add source of copy to clipboard");
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");
}
/*****************************************************************************/
@ -8032,20 +8030,18 @@ static void Brw_InsertFolderInExpandedFolders (const char Path[PATH_MAX + 1])
{
long Cod = Brw_GetCodForExpandedFolders ();
long WorksUsrCod = Brw_GetWorksUsrCodForExpandedFolders ();
char *Query;
/***** Update path time in table of expanded folders *****/
// Path must be stored with final '/'
if (asprintf (&Query,"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) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not expand the content of a folder");
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");
}
/*****************************************************************************/
@ -11675,27 +11671,23 @@ static unsigned Brw_GetFileViewsFromMe (long FilCod)
static void Brw_UpdateFileViews (unsigned NumViews,long FilCod)
{
char *Query;
if (NumViews)
{
/* Update number of views in database */
if (asprintf (&Query,"UPDATE file_view SET NumViews=NumViews+1"
" WHERE FilCod=%ld AND UsrCod=%ld",
FilCod,Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update number of views of a file");
DB_BuildQuery ("UPDATE file_view SET NumViews=NumViews+1"
" WHERE FilCod=%ld AND UsrCod=%ld",
FilCod,Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE_new ("can not update number of views of a file");
}
else // NumViews == 0
{
/* Insert number of views in database */
if (asprintf (&Query,"INSERT INTO file_view"
" (FilCod,UsrCod,NumViews)"
" VALUES"
" (%ld,%ld,1)",
FilCod,Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not insert number of views of a file");
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");
}
}

View File

@ -2344,7 +2344,6 @@ void Gam_RemoveGroupsOfType (long GrpTypCod)
static void Gam_CreateGrps (long GamCod)
{
unsigned NumGrpSel;
char *Query;
/***** Create groups of the game *****/
for (NumGrpSel = 0;
@ -2352,13 +2351,12 @@ static void Gam_CreateGrps (long GamCod)
NumGrpSel++)
{
/* Create group */
if (asprintf (&Query,"INSERT INTO gam_grp"
" (GamCod,GrpCod)"
" VALUES"
" (%ld,%ld)",
GamCod,Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not associate a group to a game");
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");
}
}
@ -3045,7 +3043,6 @@ void Gam_AddTstQuestionsToGame (void)
char LongStr[1 + 10 + 1];
long QstCod;
int MaxQstInd;
char *Query;
/***** Get game code *****/
if ((Game.GamCod = Gam_GetParamGameCod ()) == -1L)
@ -3080,13 +3077,12 @@ void Gam_AddTstQuestionsToGame (void)
MaxQstInd = Gam_GetMaxQuestionIndexInGame (Game.GamCod); // -1 if no questions
/* Insert question in the table of questions */
if (asprintf (&Query,"INSERT INTO gam_questions"
" (GamCod,QstCod,QstInd)"
" VALUES"
" (%ld,%ld,%u)",
Game.GamCod,QstCod,(unsigned) (MaxQstInd + 1)) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not create question");
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");
}
/***** Free space for selected question codes *****/
@ -3805,15 +3801,12 @@ static void Gam_ReceiveAndStoreUserAnswersToAGame (long GamCod)
static void Gam_IncreaseAnswerInDB (long QstCod,unsigned AnsInd)
{
char *Query;
/***** Increase number of users who have selected
the answer AnsInd in the question QstCod *****/
if (asprintf (&Query,"UPDATE gam_answers SET NumUsrs=NumUsrs+1"
" WHERE QstCod=%ld AND AnsInd=%u",
QstCod,AnsInd) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not register your answer to the game");
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");
}
/*****************************************************************************/
@ -3822,15 +3815,12 @@ static void Gam_IncreaseAnswerInDB (long QstCod,unsigned AnsInd)
static void Gam_RegisterIHaveAnsweredGame (long GamCod)
{
char *Query;
if (asprintf (&Query,"INSERT INTO gam_users"
" (GamCod,UsrCod)"
" VALUES"
" (%ld,%ld)",
GamCod,Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not register that you have answered the game");
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");
}
/*****************************************************************************/

View File

@ -1278,16 +1278,13 @@ static void Grp_RemoveUsrFromGroup (long UsrCod,long GrpCod)
static void Grp_AddUsrToGroup (struct UsrData *UsrDat,long GrpCod)
{
char *Query;
/***** Register in group *****/
if (asprintf (&Query,"INSERT INTO crs_grp_usr"
" (GrpCod,UsrCod)"
" VALUES"
" (%ld,%ld)",
GrpCod,UsrDat->UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not add a user to a 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");
}
/*****************************************************************************/
@ -3849,18 +3846,15 @@ static void Grp_CreateGroupType (void)
static void Grp_CreateGroup (void)
{
char *Query;
/***** Create a new group *****/
if (asprintf (&Query,"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) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not create 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");
}
/*****************************************************************************/

View File

@ -1193,21 +1193,18 @@ void Hld_RecFormNewHoliday2 (void)
static void Hld_CreateHoliday (struct Holiday *Hld)
{
char *Query;
/***** Create a new holiday or no school period *****/
if (asprintf (&Query,"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) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not create holiday");
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");
}

View File

@ -1518,15 +1518,14 @@ void Inf_SetInfoSrcIntoDB (Inf_InfoSrc_t InfoSrc)
}
else // Info is not stored in database, so insert it
{
if (asprintf (&Query,"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]) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not insert info source");
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");
}
}

View File

@ -851,16 +851,14 @@ void Lnk_RecFormNewLink (void)
static void Lnk_CreateLink (struct Link *Lnk)
{
extern const char *Txt_Created_new_link_X;
char *Query;
/***** Create a new link *****/
if (asprintf (&Query,"INSERT INTO links"
" (ShortName,FullName,WWW)"
" VALUES"
" ('%s','%s','%s')",
Lnk->ShrtName,Lnk->FullName,Lnk->WWW) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not create institutional 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");
/***** Write success message *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),

View File

@ -855,16 +855,14 @@ void Mai_RecFormNewMailDomain (void)
static void Mai_CreateMailDomain (struct Mail *Mai)
{
extern const char *Txt_Created_new_email_domain_X;
char *Query;
/***** Create a new mail *****/
if (asprintf (&Query,"INSERT INTO mail_domains"
" (Domain,Info)"
" VALUES"
" ('%s','%s')",
Mai->Domain,Mai->Info) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not create mail domain");
DB_BuildQuery ("INSERT INTO mail_domains"
" (Domain,Info)"
" VALUES"
" ('%s','%s')",
Mai->Domain,Mai->Info);
DB_QueryINSERT_new ("can not create mail domain");
/***** Write success message *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),

View File

@ -87,20 +87,17 @@ static bool Mrk_GetUsrMarks (FILE *FileUsrMarks,struct UsrData *UsrDat,
void Mrk_AddMarksToDB (long FilCod,struct MarksProperties *Marks)
{
char *Query;
/***** Add file of marks to the database *****/
if (asprintf (&Query,"INSERT INTO marks_properties"
" (FilCod,%s,%s)"
" VALUES"
" (%ld,%u,%u)",
Mrk_HeadOrFootStr[Brw_HEADER],
Mrk_HeadOrFootStr[Brw_FOOTER],
FilCod,
Marks->Header,
Marks->Footer) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not add properties of marks to 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");
}
/*****************************************************************************/

View File

@ -310,14 +310,13 @@ void Not_RemoveNotice (void)
/***** Remove notice *****/
/* Copy notice to table of deleted notices */
if (asprintf (&Query,"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) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not remove notice");
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");
/* Remove notice */
if (asprintf (&Query,"DELETE FROM notices"

View File

@ -1471,7 +1471,6 @@ void Ntf_StoreNotifyEventToOneUser (Ntf_NotifyEvent_t NotifyEvent,
struct UsrData *UsrDat,
long Cod,Ntf_Status_t Status)
{
char *Query;
long InsCod;
long CtrCod;
long DegCod;
@ -1512,16 +1511,15 @@ void Ntf_StoreNotifyEventToOneUser (Ntf_NotifyEvent_t NotifyEvent,
}
/***** Store notify event *****/
if (asprintf (&Query,"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) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not create new notification 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");
}
/*****************************************************************************/

View File

@ -1010,13 +1010,12 @@ unsigned Pho_UpdateMyClicksWithoutPhoto (void)
else // The user does not exist ==> add him/her
{
/* Add the user, with one access */
if (asprintf (&Query,"INSERT INTO clicks_without_photo"
" (UsrCod,NumClicks)"
" VALUES"
" (%ld,1)",
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not create number of clicks without photo");
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");
NumClicks = 1;
}

View File

@ -873,16 +873,14 @@ void Plc_RecFormNewPlace (void)
static void Plc_CreatePlace (struct Place *Plc)
{
extern const char *Txt_Created_new_place_X;
char *Query;
/***** Create a new place *****/
if (asprintf (&Query,"INSERT INTO places"
" (InsCod,ShortName,FullName)"
" VALUES"
" (%ld,'%s','%s')",
Gbl.CurrentIns.Ins.InsCod,Plc->ShrtName,Plc->FullName) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not create 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");
/***** Write success message *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),

View File

@ -1054,19 +1054,17 @@ void Plg_RecFormNewPlg (void)
static void Plg_CreatePlugin (struct Plugin *Plg)
{
extern const char *Txt_Created_new_plugin_X;
char *Query;
/***** Create a new plugin *****/
if (asprintf (&Query,"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) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not create 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");
/***** Write success message *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),

View File

@ -1039,7 +1039,6 @@ static void Prf_ResetUsrFigures (struct UsrFigures *UsrFigures)
static void Prf_CreateUsrFigures (long UsrCod,const struct UsrFigures *UsrFigures,
bool CreatingMyOwnAccount)
{
char *Query;
char SubQueryFirstClickTime[Prf_MAX_BYTES_SUBQUERY_FIRST_CLICK_TIME + 1];
if (CreatingMyOwnAccount)
@ -1051,18 +1050,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 *****/
if (asprintf (&Query,"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) < 0) // -1L ==> unknown number of messages sent
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not 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");
}
/*****************************************************************************/
@ -1096,15 +1094,12 @@ static bool Prf_CheckIfUsrFiguresExists (long UsrCod)
void Prf_IncrementNumClicksUsr (long UsrCod)
{
char *Query;
/***** Increment number of clicks *****/
// If NumClicks < 0 ==> not yet calculated, so do nothing
if (asprintf (&Query,"UPDATE IGNORE usr_figures SET NumClicks=NumClicks+1"
" WHERE UsrCod=%ld AND NumClicks>=0",
UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not increment user's clicks");
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");
}
/*****************************************************************************/
@ -1113,15 +1108,12 @@ void Prf_IncrementNumClicksUsr (long UsrCod)
void Prf_IncrementNumFileViewsUsr (long UsrCod)
{
char *Query;
/***** Increment number of file views *****/
// If NumFileViews < 0 ==> not yet calculated, so do nothing
if (asprintf (&Query,"UPDATE IGNORE usr_figures SET NumFileViews=NumFileViews+1"
" WHERE UsrCod=%ld AND NumFileViews>=0",
UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not increment user's file views");
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");
}
/*****************************************************************************/
@ -1130,15 +1122,12 @@ void Prf_IncrementNumFileViewsUsr (long UsrCod)
void Prf_IncrementNumForPstUsr (long UsrCod)
{
char *Query;
/***** Increment number of forum posts *****/
// If NumForPst < 0 ==> not yet calculated, so do nothing
if (asprintf (&Query,"UPDATE IGNORE usr_figures SET NumForPst=NumForPst+1"
" WHERE UsrCod=%ld AND NumForPst>=0",
UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not increment user's forum posts");
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");
}
/*****************************************************************************/
@ -1147,15 +1136,12 @@ void Prf_IncrementNumForPstUsr (long UsrCod)
void Prf_IncrementNumMsgSntUsr (long UsrCod)
{
char *Query;
/***** Increment number of messages sent *****/
// If NumMsgSnt < 0 ==> not yet calculated, so do nothing
if (asprintf (&Query,"UPDATE IGNORE usr_figures SET NumMsgSnt=NumMsgSnt+1"
" WHERE UsrCod=%ld AND NumMsgSnt>=0",
UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not increment user's messages sent");
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");
}
/*****************************************************************************/

View File

@ -3354,49 +3354,45 @@ void Prj_RecFormProject (void)
static void Prj_CreateProject (struct Project *Prj)
{
char *Query;
/***** Set dates to now *****/
Prj->CreatTime =
Prj->ModifTime = Gbl.StartExecutionTimeUTC;
/***** Create a new project *****/
if (asprintf (&Query,"INSERT INTO projects"
" (CrsCod,DptCod,Hidden,Preassigned,NumStds,Proposal,"
"CreatTime,ModifTime,"
"Title,Description,Knowledge,Materials,URL)"
" VALUES"
" (%ld,%ld,'%c','%c',%u,'%s',"
"FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld),"
"'%s','%s','%s','%s','%s')",
Gbl.CurrentCrs.Crs.CrsCod,
Prj->DptCod,
Prj->Hidden == Prj_HIDDEN ? 'Y' :
'N',
Prj->Preassigned == Prj_PREASSIGNED ? 'Y' :
'N',
Prj->NumStds,
Prj_Proposal_DB[Prj->Proposal],
Prj->CreatTime,
Prj->ModifTime,
Prj->Title,
Prj->Description,
Prj->Knowledge,
Prj->Materials,
Prj->URL) < 0)
Lay_NotEnoughMemoryExit ();
Prj->PrjCod = DB_QueryINSERTandReturnCode_free (Query,"can not create new project");
DB_BuildQuery ("INSERT INTO projects"
" (CrsCod,DptCod,Hidden,Preassigned,NumStds,Proposal,"
"CreatTime,ModifTime,"
"Title,Description,Knowledge,Materials,URL)"
" VALUES"
" (%ld,%ld,'%c','%c',%u,'%s',"
"FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld),"
"'%s','%s','%s','%s','%s')",
Gbl.CurrentCrs.Crs.CrsCod,
Prj->DptCod,
Prj->Hidden == Prj_HIDDEN ? 'Y' :
'N',
Prj->Preassigned == Prj_PREASSIGNED ? 'Y' :
'N',
Prj->NumStds,
Prj_Proposal_DB[Prj->Proposal],
Prj->CreatTime,
Prj->ModifTime,
Prj->Title,
Prj->Description,
Prj->Knowledge,
Prj->Materials,
Prj->URL);
Prj->PrjCod = DB_QueryINSERTandReturnCode_new ("can not create new project");
/***** Insert creator as first tutor *****/
if (asprintf (&Query,"INSERT INTO prj_usr"
" (PrjCod,RoleInProject,UsrCod)"
" VALUES"
" (%ld,%u,%ld)",
Prj->PrjCod,
(unsigned) Prj_ROLE_TUT,
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not add 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");
/***** Flush cache *****/
Prj_FlushCacheMyRoleInProject ();

View File

@ -573,19 +573,17 @@ unsigned long Rec_GetAllFieldsInCurrCrs (MYSQL_RES **mysql_res)
void Rec_CreateRecordField (void)
{
extern const char *Txt_Created_new_record_field_X;
char *Query;
/***** Create the new field *****/
if (asprintf (&Query,"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) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not create field of record");
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");
/***** Write message of success *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -2024,15 +2022,14 @@ void Rec_UpdateCrsRecord (long UsrCod)
else if (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text[0])
{
/***** Insert text field of record course *****/
if (asprintf (&Query,"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) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryINSERT_free (Query,"can not create field of record");
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");
}
}
}

View File

@ -537,8 +537,8 @@ void Sta_AskShowCrsHits (void)
/***** Option a) Listing of clicks distributed by some metric *****/
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"RIGHT_TOP %s\">%s:</td>"
"<td colspan=\"2\" class=\"LEFT_TOP\">",
"<td class=\"RIGHT_MIDDLE %s\">%s:</td>"
"<td colspan=\"2\" class=\"LEFT_MIDDLE\">",
The_ClassForm[Gbl.Prefs.Theme],Txt_Show);
if ((Gbl.Stat.ClicksGroupedBy < Sta_CLICKS_CRS_PER_USR ||
@ -735,10 +735,10 @@ void Sta_AskShowGblHits (void)
/***** Count type for the statistic *****/
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"RIGHT_TOP\">"
"<td class=\"RIGHT_MIDDLE\">"
"<label for=\"CountType\" class=\"%s\">%s:</label>"
"</td>"
"<td colspan=\"2\" class=\"LEFT_TOP\">",
"<td colspan=\"2\" class=\"LEFT_MIDDLE\">",
The_ClassForm[Gbl.Prefs.Theme],Txt_Show);
Sta_WriteSelectorCountType ();
@ -816,10 +816,10 @@ static void Sta_WriteSelectorAction (void)
char ActTxt[Act_MAX_BYTES_ACTION_TXT + 1];
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"RIGHT_TOP\">"
"<td class=\"RIGHT_MIDDLE\">"
"<label for=\"StatAct\" class=\"%s\">%s:</label>"
"</td>"
"<td colspan=\"2\" class=\"LEFT_TOP\">"
"<td colspan=\"2\" class=\"LEFT_MIDDLE\">"
"<select id=\"StatAct\" name=\"StatAct\""
" style=\"width:375px;\">",
The_ClassForm[Gbl.Prefs.Theme],Txt_Action);