mirror of https://github.com/acanas/swad-core.git
Version 18.8.10
This commit is contained in:
parent
187ac31346
commit
6979650877
30
swad_ID.c
30
swad_ID.c
|
@ -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)
|
static void ID_InsertANewUsrIDInDB (long UsrCod,const char *NewID,bool Confirmed)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Update my nickname in database *****/
|
/***** Update my nickname in database *****/
|
||||||
if (asprintf (&Query,"INSERT INTO usr_IDs"
|
DB_BuildQuery ("INSERT INTO usr_IDs"
|
||||||
" (UsrCod,UsrID,CreatTime,Confirmed)"
|
" (UsrCod,UsrID,CreatTime,Confirmed)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,'%s',NOW(),'%c')",
|
" (%ld,'%s',NOW(),'%c')",
|
||||||
UsrCod,NewID,
|
UsrCod,NewID,
|
||||||
Confirmed ? 'Y' :
|
Confirmed ? 'Y' :
|
||||||
'N') < 0)
|
'N');
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not insert a new ID");
|
||||||
DB_QueryINSERT_free (Query,"can not insert a new ID");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1156,12 +1153,9 @@ void ID_ConfirmOtherUsrID (void)
|
||||||
|
|
||||||
void ID_ConfirmUsrID (const struct UsrData *UsrDat,const char *UsrID)
|
void ID_ConfirmUsrID (const struct UsrData *UsrDat,const char *UsrID)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Update database *****/
|
/***** Update database *****/
|
||||||
if (asprintf (&Query,"UPDATE usr_IDs SET Confirmed='Y'"
|
DB_BuildQuery ("UPDATE usr_IDs SET Confirmed='Y'"
|
||||||
" WHERE UsrCod=%ld AND UsrID='%s' AND Confirmed<>'Y'",
|
" WHERE UsrCod=%ld AND UsrID='%s' AND Confirmed<>'Y'",
|
||||||
UsrDat->UsrCod,UsrID) < 0)
|
UsrDat->UsrCod,UsrID);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not confirm a user's ID");
|
||||||
DB_QueryINSERT_free (Query,"can not confirm a user's ID");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -712,7 +712,6 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount)
|
||||||
char BirthdayStrDB[Usr_BIRTHDAY_STR_DB_LENGTH + 1];
|
char BirthdayStrDB[Usr_BIRTHDAY_STR_DB_LENGTH + 1];
|
||||||
char *QueryUsrData;
|
char *QueryUsrData;
|
||||||
size_t CommentsLength;
|
size_t CommentsLength;
|
||||||
char *QueryUsrIDs;
|
|
||||||
char PathRelUsr[PATH_MAX + 1];
|
char PathRelUsr[PATH_MAX + 1];
|
||||||
unsigned NumID;
|
unsigned NumID;
|
||||||
|
|
||||||
|
@ -781,16 +780,15 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount)
|
||||||
NumID++)
|
NumID++)
|
||||||
{
|
{
|
||||||
Str_ConvertToUpperText (UsrDat->IDs.List[NumID].ID);
|
Str_ConvertToUpperText (UsrDat->IDs.List[NumID].ID);
|
||||||
if (asprintf (&QueryUsrIDs,"INSERT INTO usr_IDs"
|
DB_BuildQuery ("INSERT INTO usr_IDs"
|
||||||
" (UsrCod,UsrID,CreatTime,Confirmed)"
|
" (UsrCod,UsrID,CreatTime,Confirmed)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,'%s',NOW(),'%c')",
|
" (%ld,'%s',NOW(),'%c')",
|
||||||
UsrDat->UsrCod,
|
UsrDat->UsrCod,
|
||||||
UsrDat->IDs.List[NumID].ID,
|
UsrDat->IDs.List[NumID].ID,
|
||||||
UsrDat->IDs.List[NumID].Confirmed ? 'Y' :
|
UsrDat->IDs.List[NumID].Confirmed ? 'Y' :
|
||||||
'N') < 0)
|
'N');
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not store user's ID when creating user");
|
||||||
DB_QueryINSERT_free (QueryUsrIDs,"can not store user's ID when creating user");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Create directory for the user, if not exists *****/
|
/***** Create directory for the user, if not exists *****/
|
||||||
|
|
|
@ -512,16 +512,13 @@ void Ann_ReceiveAnnouncement (void)
|
||||||
|
|
||||||
static void Ann_CreateAnnouncement (unsigned Roles,const char *Subject,const char *Content)
|
static void Ann_CreateAnnouncement (unsigned Roles,const char *Subject,const char *Content)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Select announcements not seen *****/
|
/***** Select announcements not seen *****/
|
||||||
if (asprintf (&Query,"INSERT INTO announcements"
|
DB_BuildQuery ("INSERT INTO announcements"
|
||||||
" (Roles,Subject,Content)"
|
" (Roles,Subject,Content)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%u,'%s','%s')",
|
" (%u,'%s','%s')",
|
||||||
Roles,Subject,Content) < 0)
|
Roles,Subject,Content);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not create announcement");
|
||||||
DB_QueryINSERT_free (Query,"can not create announcement");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -1612,7 +1612,6 @@ void Asg_RemoveGroupsOfType (long GrpTypCod)
|
||||||
static void Asg_CreateGrps (long AsgCod)
|
static void Asg_CreateGrps (long AsgCod)
|
||||||
{
|
{
|
||||||
unsigned NumGrpSel;
|
unsigned NumGrpSel;
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Create groups of the assignment *****/
|
/***** Create groups of the assignment *****/
|
||||||
for (NumGrpSel = 0;
|
for (NumGrpSel = 0;
|
||||||
|
@ -1620,13 +1619,12 @@ static void Asg_CreateGrps (long AsgCod)
|
||||||
NumGrpSel++)
|
NumGrpSel++)
|
||||||
{
|
{
|
||||||
/* Create group */
|
/* Create group */
|
||||||
if (asprintf (&Query,"INSERT INTO asg_grp"
|
DB_BuildQuery ("INSERT INTO asg_grp"
|
||||||
" (AsgCod,GrpCod)"
|
" (AsgCod,GrpCod)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,%ld)",
|
" (%ld,%ld)",
|
||||||
AsgCod,Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]) < 0)
|
AsgCod,Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not associate a group to an assignment");
|
||||||
DB_QueryINSERT_free (Query,"can not associate a group to an assignment");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1487,7 +1487,6 @@ void Att_RemoveGroupsOfType (long GrpTypCod)
|
||||||
static void Att_CreateGrps (long AttCod)
|
static void Att_CreateGrps (long AttCod)
|
||||||
{
|
{
|
||||||
unsigned NumGrpSel;
|
unsigned NumGrpSel;
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Create groups of the attendance event *****/
|
/***** Create groups of the attendance event *****/
|
||||||
for (NumGrpSel = 0;
|
for (NumGrpSel = 0;
|
||||||
|
@ -1495,13 +1494,12 @@ static void Att_CreateGrps (long AttCod)
|
||||||
NumGrpSel++)
|
NumGrpSel++)
|
||||||
{
|
{
|
||||||
/* Create group */
|
/* Create group */
|
||||||
if (asprintf (&Query,"INSERT INTO att_grp"
|
DB_BuildQuery ("INSERT INTO att_grp"
|
||||||
" (AttCod,GrpCod)"
|
" (AttCod,GrpCod)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,%ld)",
|
" (%ld,%ld)",
|
||||||
AttCod,Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]) < 0)
|
AttCod,Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not associate a group to an attendance event");
|
||||||
DB_QueryINSERT_free (Query,"can not associate a group to an attendance event");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -994,16 +994,14 @@ void Ban_RecFormNewBanner (void)
|
||||||
static void Ban_CreateBanner (struct Banner *Ban)
|
static void Ban_CreateBanner (struct Banner *Ban)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Created_new_banner_X;
|
extern const char *Txt_Created_new_banner_X;
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Create a new banner *****/
|
/***** Create a new banner *****/
|
||||||
if (asprintf (&Query,"INSERT INTO banners"
|
DB_BuildQuery ("INSERT INTO banners"
|
||||||
" (Hidden,ShortName,FullName,Img,WWW)"
|
" (Hidden,ShortName,FullName,Img,WWW)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" ('N','%s','%s','%s','%s')",
|
" ('N','%s','%s','%s','%s')",
|
||||||
Ban->ShrtName,Ban->FullName,Ban->Img,Ban->WWW) < 0)
|
Ban->ShrtName,Ban->FullName,Ban->Img,Ban->WWW);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not create banner");
|
||||||
DB_QueryINSERT_free (Query,"can not create banner");
|
|
||||||
|
|
||||||
/***** Write success message *****/
|
/***** Write success message *****/
|
||||||
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
||||||
|
|
|
@ -355,10 +355,11 @@ En OpenSWAD:
|
||||||
ps2pdf source.ps destination.pdf
|
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 CSS_FILE "swad18.4.css"
|
||||||
#define JS_FILE "swad17.17.1.js"
|
#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.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.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)
|
Version 18.8.7: Oct 26, 2018 Some asprintf for database queries changed by internal function. (237172 lines)
|
||||||
|
|
|
@ -2221,7 +2221,6 @@ static void Cty_CreateCountry (struct Country *Cty)
|
||||||
char SubQueryNam2[Cty_MAX_BYTES_SUBQUERY_CTYS_NAME + 1];
|
char SubQueryNam2[Cty_MAX_BYTES_SUBQUERY_CTYS_NAME + 1];
|
||||||
char SubQueryWWW1[Cty_MAX_BYTES_SUBQUERY_CTYS + 1];
|
char SubQueryWWW1[Cty_MAX_BYTES_SUBQUERY_CTYS + 1];
|
||||||
char SubQueryWWW2[Cty_MAX_BYTES_SUBQUERY_CTYS_WWW + 1];
|
char SubQueryWWW2[Cty_MAX_BYTES_SUBQUERY_CTYS_WWW + 1];
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Create a new country *****/
|
/***** Create a new country *****/
|
||||||
SubQueryNam1[0] = '\0';
|
SubQueryNam1[0] = '\0';
|
||||||
|
@ -2258,14 +2257,13 @@ static void Cty_CreateCountry (struct Country *Cty)
|
||||||
Str_Concat (SubQueryWWW2,"'",
|
Str_Concat (SubQueryWWW2,"'",
|
||||||
Cty_MAX_BYTES_SUBQUERY_CTYS_WWW);
|
Cty_MAX_BYTES_SUBQUERY_CTYS_WWW);
|
||||||
}
|
}
|
||||||
if (asprintf (&Query,"INSERT INTO countries"
|
DB_BuildQuery ("INSERT INTO countries"
|
||||||
" (CtyCod,Alpha2%s%s)"
|
" (CtyCod,Alpha2%s%s)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" ('%03ld','%s'%s%s)",
|
" ('%03ld','%s'%s%s)",
|
||||||
SubQueryNam1,SubQueryWWW1,
|
SubQueryNam1,SubQueryWWW1,
|
||||||
Cty->CtyCod,Cty->Alpha2,SubQueryNam2,SubQueryWWW2) < 0)
|
Cty->CtyCod,Cty->Alpha2,SubQueryNam2,SubQueryWWW2);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not create country");
|
||||||
DB_QueryINSERT_free (Query,"can not create country");
|
|
||||||
|
|
||||||
/***** Write success message *****/
|
/***** Write success message *****/
|
||||||
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
||||||
|
|
|
@ -2218,14 +2218,14 @@ static void Crs_EmptyCourseCompletely (long CrsCod)
|
||||||
|
|
||||||
/***** Remove notices in the course *****/
|
/***** Remove notices in the course *****/
|
||||||
/* Copy all notices from the course to table of deleted notices */
|
/* Copy all notices from the course to table of deleted notices */
|
||||||
if (asprintf (&Query,"INSERT INTO notices_deleted"
|
DB_BuildQuery ("INSERT INTO notices_deleted"
|
||||||
" (NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif)"
|
" (NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif)"
|
||||||
" SELECT NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif"
|
" SELECT NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif"
|
||||||
" FROM notices"
|
" FROM notices"
|
||||||
" WHERE CrsCod=%ld",
|
" WHERE CrsCod=%ld",
|
||||||
CrsCod) < 0)
|
CrsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not remove notices in a course");
|
||||||
DB_QueryINSERT_free (Query,"can not remove notices in a course");
|
|
||||||
/* Remove all notices from the course */
|
/* Remove all notices from the course */
|
||||||
if (asprintf (&Query,"DELETE FROM notices WHERE CrsCod=%ld",CrsCod) < 0)
|
if (asprintf (&Query,"DELETE FROM notices WHERE CrsCod=%ld",CrsCod) < 0)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
|
@ -3128,24 +3128,6 @@ unsigned long DB_QuerySELECT_new (MYSQL_RES **mysql_res,const char *MsgError)
|
||||||
return (unsigned long) mysql_num_rows (*mysql_res);
|
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)
|
unsigned long DB_QuerySELECT (const char *Query,MYSQL_RES **mysql_res,const char *MsgError)
|
||||||
{
|
{
|
||||||
/***** Query database *****/
|
/***** Query database *****/
|
||||||
|
@ -3184,26 +3166,6 @@ unsigned long DB_QueryCOUNT_new (const char *MsgError)
|
||||||
return NumRows;
|
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)
|
unsigned long DB_QueryCOUNT (const char *Query,const char *MsgError)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
|
|
|
@ -40,11 +40,9 @@ void DB_CloseDBConnection (void);
|
||||||
void DB_BuildQuery (const char *fmt,...);
|
void DB_BuildQuery (const char *fmt,...);
|
||||||
|
|
||||||
unsigned long DB_QuerySELECT_new (MYSQL_RES **mysql_res,const char *MsgError);
|
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_QuerySELECT (const char *Query,MYSQL_RES **mysql_res,const char *MsgError);
|
||||||
|
|
||||||
unsigned long DB_QueryCOUNT_new (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);
|
unsigned long DB_QueryCOUNT (const char *Query,const char *MsgError);
|
||||||
|
|
||||||
void DB_QueryINSERT_new (const char *MsgError);
|
void DB_QueryINSERT_new (const char *MsgError);
|
||||||
|
|
|
@ -544,13 +544,11 @@ static void DT_PutHeadDegreeTypesForEdition (void)
|
||||||
static void DT_CreateDegreeType (struct DegreeType *DegTyp)
|
static void DT_CreateDegreeType (struct DegreeType *DegTyp)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Created_new_type_of_degree_X;
|
extern const char *Txt_Created_new_type_of_degree_X;
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Create a new degree type *****/
|
/***** Create a new degree type *****/
|
||||||
if (asprintf (&Query,"INSERT INTO deg_types SET DegTypName='%s'",
|
DB_BuildQuery ("INSERT INTO deg_types SET DegTypName='%s'",
|
||||||
DegTyp->DegTypName) < 0)
|
DegTyp->DegTypName);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not create a new type of degree");
|
||||||
DB_QueryINSERT_free (Query,"can not create a new type of degree");
|
|
||||||
|
|
||||||
/***** Write success message *****/
|
/***** Write success message *****/
|
||||||
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
||||||
|
|
|
@ -1061,16 +1061,14 @@ void Dpt_RecFormNewDpt (void)
|
||||||
static void Dpt_CreateDepartment (struct Department *Dpt)
|
static void Dpt_CreateDepartment (struct Department *Dpt)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Created_new_department_X;
|
extern const char *Txt_Created_new_department_X;
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Create a new department *****/
|
/***** Create a new department *****/
|
||||||
if (asprintf (&Query,"INSERT INTO departments"
|
DB_BuildQuery ("INSERT INTO departments"
|
||||||
" (InsCod,ShortName,FullName,WWW)"
|
" (InsCod,ShortName,FullName,WWW)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,'%s','%s','%s')",
|
" (%ld,'%s','%s','%s')",
|
||||||
Dpt->InsCod,Dpt->ShrtName,Dpt->FullName,Dpt->WWW) < 0)
|
Dpt->InsCod,Dpt->ShrtName,Dpt->FullName,Dpt->WWW);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not create a new department");
|
||||||
DB_QueryINSERT_free (Query,"can not create a new department");
|
|
||||||
|
|
||||||
/***** Write success message *****/
|
/***** Write success message *****/
|
||||||
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
||||||
|
|
|
@ -82,7 +82,6 @@ void Dup_ReportUsrAsPossibleDuplicate (void)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Thank_you_for_reporting_a_possible_duplicate_user;
|
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_;
|
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
||||||
char *Query;
|
|
||||||
bool ItsMe;
|
bool ItsMe;
|
||||||
|
|
||||||
/***** Get user to be reported as possible duplicate *****/
|
/***** 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)
|
if (!ItsMe && Gbl.Usrs.Me.Role.Logged >= Rol_TCH)
|
||||||
{
|
{
|
||||||
/***** Insert possible duplicate into database *****/
|
/***** Insert possible duplicate into database *****/
|
||||||
if (asprintf (&Query,"REPLACE INTO usr_duplicated"
|
DB_BuildQuery ("REPLACE INTO usr_duplicated"
|
||||||
" (UsrCod,InformerCod,InformTime)"
|
" (UsrCod,InformerCod,InformTime)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,%ld,NOW())",
|
" (%ld,%ld,NOW())",
|
||||||
Gbl.Usrs.Other.UsrDat.UsrCod,
|
Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not report duplicate");
|
||||||
DB_QueryINSERT_free (Query,"can not report duplicate");
|
|
||||||
|
|
||||||
/***** Show feedback message *****/
|
/***** Show feedback message *****/
|
||||||
Ale_ShowAlert (Ale_SUCCESS,Txt_Thank_you_for_reporting_a_possible_duplicate_user);
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Thank_you_for_reporting_a_possible_duplicate_user);
|
||||||
|
|
|
@ -254,7 +254,6 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole,
|
||||||
Enr_KeepOrSetAccepted_t KeepOrSetAccepted)
|
Enr_KeepOrSetAccepted_t KeepOrSetAccepted)
|
||||||
{
|
{
|
||||||
extern const char *Usr_StringsUsrListTypeInDB[Usr_NUM_USR_LIST_TYPES];
|
extern const char *Usr_StringsUsrListTypeInDB[Usr_NUM_USR_LIST_TYPES];
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Check if user's role is allowed *****/
|
/***** Check if user's role is allowed *****/
|
||||||
switch (NewRole)
|
switch (NewRole)
|
||||||
|
@ -268,26 +267,25 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole,
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Register user in current course in database *****/
|
/***** Register user in current course in database *****/
|
||||||
if (asprintf (&Query,"INSERT INTO crs_usr"
|
DB_BuildQuery ("INSERT INTO crs_usr"
|
||||||
" (CrsCod,UsrCod,Role,Accepted,"
|
" (CrsCod,UsrCod,Role,Accepted,"
|
||||||
"LastDowGrpCod,LastComGrpCod,LastAssGrpCod,"
|
"LastDowGrpCod,LastComGrpCod,LastAssGrpCod,"
|
||||||
"NumAccTst,LastAccTst,NumQstsLastTst,"
|
"NumAccTst,LastAccTst,NumQstsLastTst,"
|
||||||
"UsrListType,ColsClassPhoto,ListWithPhotos)"
|
"UsrListType,ColsClassPhoto,ListWithPhotos)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,%ld,%u,'%c',"
|
" (%ld,%ld,%u,'%c',"
|
||||||
"-1,-1,-1,"
|
"-1,-1,-1,"
|
||||||
"0,FROM_UNIXTIME(%ld),0,"
|
"0,FROM_UNIXTIME(%ld),0,"
|
||||||
"'%s',%u,'%c')",
|
"'%s',%u,'%c')",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,UsrDat->UsrCod,(unsigned) NewRole,
|
Gbl.CurrentCrs.Crs.CrsCod,UsrDat->UsrCod,(unsigned) NewRole,
|
||||||
KeepOrSetAccepted == Enr_SET_ACCEPTED_TO_TRUE ? 'Y' :
|
KeepOrSetAccepted == Enr_SET_ACCEPTED_TO_TRUE ? 'Y' :
|
||||||
'N',
|
'N',
|
||||||
(long) (time_t) 0, // The user never accessed to tests in this course
|
(long) (time_t) 0, // The user never accessed to tests in this course
|
||||||
Usr_StringsUsrListTypeInDB[Usr_SHOW_USRS_TYPE_DEFAULT],
|
Usr_StringsUsrListTypeInDB[Usr_SHOW_USRS_TYPE_DEFAULT],
|
||||||
Usr_CLASS_PHOTO_COLS_DEF,
|
Usr_CLASS_PHOTO_COLS_DEF,
|
||||||
Usr_LIST_WITH_PHOTOS_DEF ? 'Y' :
|
Usr_LIST_WITH_PHOTOS_DEF ? 'Y' :
|
||||||
'N') < 0)
|
'N');
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not register user in course");
|
||||||
DB_QueryINSERT_free (Query,"can not register user in course");
|
|
||||||
|
|
||||||
/***** Flush caches *****/
|
/***** Flush caches *****/
|
||||||
Usr_FlushCachesUsr ();
|
Usr_FlushCachesUsr ();
|
||||||
|
|
|
@ -7879,18 +7879,16 @@ static void Brw_AddPathToClipboards (void)
|
||||||
{
|
{
|
||||||
long Cod = Brw_GetCodForClipboard ();
|
long Cod = Brw_GetCodForClipboard ();
|
||||||
long WorksUsrCod = Brw_GetWorksUsrCodForClipboard ();
|
long WorksUsrCod = Brw_GetWorksUsrCodForClipboard ();
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Add path to clipboards *****/
|
/***** Add path to clipboards *****/
|
||||||
if (asprintf (&Query,"INSERT INTO clipboard"
|
DB_BuildQuery ("INSERT INTO clipboard"
|
||||||
" (UsrCod,FileBrowser,Cod,WorksUsrCod,FileType,Path)"
|
" (UsrCod,FileBrowser,Cod,WorksUsrCod,FileType,Path)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,%u,%ld,%ld,%u,'%s')",
|
" (%ld,%u,%ld,%ld,%u,'%s')",
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,(unsigned) Gbl.FileBrowser.Type,
|
Gbl.Usrs.Me.UsrDat.UsrCod,(unsigned) Gbl.FileBrowser.Type,
|
||||||
Cod,WorksUsrCod,
|
Cod,WorksUsrCod,
|
||||||
(unsigned) Gbl.FileBrowser.FileType,Gbl.FileBrowser.Priv.FullPathInTree) < 0)
|
(unsigned) Gbl.FileBrowser.FileType,Gbl.FileBrowser.Priv.FullPathInTree);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not add source of copy to clipboard");
|
||||||
DB_QueryINSERT_free (Query,"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 Cod = Brw_GetCodForExpandedFolders ();
|
||||||
long WorksUsrCod = Brw_GetWorksUsrCodForExpandedFolders ();
|
long WorksUsrCod = Brw_GetWorksUsrCodForExpandedFolders ();
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Update path time in table of expanded folders *****/
|
/***** Update path time in table of expanded folders *****/
|
||||||
// Path must be stored with final '/'
|
// Path must be stored with final '/'
|
||||||
if (asprintf (&Query,"INSERT INTO expanded_folders"
|
DB_BuildQuery ("INSERT INTO expanded_folders"
|
||||||
" (UsrCod,FileBrowser,Cod,WorksUsrCod,Path,ClickTime)"
|
" (UsrCod,FileBrowser,Cod,WorksUsrCod,Path,ClickTime)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,%u,%ld,%ld,'%s/',NOW())",
|
" (%ld,%u,%ld,%ld,'%s/',NOW())",
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
(unsigned) Brw_FileBrowserForDB_expanded_folders[Gbl.FileBrowser.Type],
|
(unsigned) Brw_FileBrowserForDB_expanded_folders[Gbl.FileBrowser.Type],
|
||||||
Cod,WorksUsrCod,
|
Cod,WorksUsrCod,
|
||||||
Path) < 0)
|
Path);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not expand the content of a folder");
|
||||||
DB_QueryINSERT_free (Query,"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)
|
static void Brw_UpdateFileViews (unsigned NumViews,long FilCod)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
|
|
||||||
if (NumViews)
|
if (NumViews)
|
||||||
{
|
{
|
||||||
/* Update number of views in database */
|
/* Update number of views in database */
|
||||||
if (asprintf (&Query,"UPDATE file_view SET NumViews=NumViews+1"
|
DB_BuildQuery ("UPDATE file_view SET NumViews=NumViews+1"
|
||||||
" WHERE FilCod=%ld AND UsrCod=%ld",
|
" WHERE FilCod=%ld AND UsrCod=%ld",
|
||||||
FilCod,Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
FilCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryUPDATE_new ("can not update number of views of a file");
|
||||||
DB_QueryUPDATE_free (Query,"can not update number of views of a file");
|
|
||||||
}
|
}
|
||||||
else // NumViews == 0
|
else // NumViews == 0
|
||||||
{
|
{
|
||||||
/* Insert number of views in database */
|
/* Insert number of views in database */
|
||||||
if (asprintf (&Query,"INSERT INTO file_view"
|
DB_BuildQuery ("INSERT INTO file_view"
|
||||||
" (FilCod,UsrCod,NumViews)"
|
" (FilCod,UsrCod,NumViews)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,%ld,1)",
|
" (%ld,%ld,1)",
|
||||||
FilCod,Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
FilCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not insert number of views of a file");
|
||||||
DB_QueryINSERT_free (Query,"can not insert number of views of a file");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
54
swad_game.c
54
swad_game.c
|
@ -2344,7 +2344,6 @@ void Gam_RemoveGroupsOfType (long GrpTypCod)
|
||||||
static void Gam_CreateGrps (long GamCod)
|
static void Gam_CreateGrps (long GamCod)
|
||||||
{
|
{
|
||||||
unsigned NumGrpSel;
|
unsigned NumGrpSel;
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Create groups of the game *****/
|
/***** Create groups of the game *****/
|
||||||
for (NumGrpSel = 0;
|
for (NumGrpSel = 0;
|
||||||
|
@ -2352,13 +2351,12 @@ static void Gam_CreateGrps (long GamCod)
|
||||||
NumGrpSel++)
|
NumGrpSel++)
|
||||||
{
|
{
|
||||||
/* Create group */
|
/* Create group */
|
||||||
if (asprintf (&Query,"INSERT INTO gam_grp"
|
DB_BuildQuery ("INSERT INTO gam_grp"
|
||||||
" (GamCod,GrpCod)"
|
" (GamCod,GrpCod)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,%ld)",
|
" (%ld,%ld)",
|
||||||
GamCod,Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]) < 0)
|
GamCod,Gbl.CurrentCrs.Grps.LstGrpsSel.GrpCods[NumGrpSel]);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not associate a group to a game");
|
||||||
DB_QueryINSERT_free (Query,"can not associate a group to a game");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3045,7 +3043,6 @@ void Gam_AddTstQuestionsToGame (void)
|
||||||
char LongStr[1 + 10 + 1];
|
char LongStr[1 + 10 + 1];
|
||||||
long QstCod;
|
long QstCod;
|
||||||
int MaxQstInd;
|
int MaxQstInd;
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Get game code *****/
|
/***** Get game code *****/
|
||||||
if ((Game.GamCod = Gam_GetParamGameCod ()) == -1L)
|
if ((Game.GamCod = Gam_GetParamGameCod ()) == -1L)
|
||||||
|
@ -3080,13 +3077,12 @@ void Gam_AddTstQuestionsToGame (void)
|
||||||
MaxQstInd = Gam_GetMaxQuestionIndexInGame (Game.GamCod); // -1 if no questions
|
MaxQstInd = Gam_GetMaxQuestionIndexInGame (Game.GamCod); // -1 if no questions
|
||||||
|
|
||||||
/* Insert question in the table of questions */
|
/* Insert question in the table of questions */
|
||||||
if (asprintf (&Query,"INSERT INTO gam_questions"
|
DB_BuildQuery ("INSERT INTO gam_questions"
|
||||||
" (GamCod,QstCod,QstInd)"
|
" (GamCod,QstCod,QstInd)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,%ld,%u)",
|
" (%ld,%ld,%u)",
|
||||||
Game.GamCod,QstCod,(unsigned) (MaxQstInd + 1)) < 0)
|
Game.GamCod,QstCod,(unsigned) (MaxQstInd + 1));
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not create question");
|
||||||
DB_QueryINSERT_free (Query,"can not create question");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free space for selected question codes *****/
|
/***** Free space for selected question codes *****/
|
||||||
|
@ -3805,15 +3801,12 @@ static void Gam_ReceiveAndStoreUserAnswersToAGame (long GamCod)
|
||||||
|
|
||||||
static void Gam_IncreaseAnswerInDB (long QstCod,unsigned AnsInd)
|
static void Gam_IncreaseAnswerInDB (long QstCod,unsigned AnsInd)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Increase number of users who have selected
|
/***** Increase number of users who have selected
|
||||||
the answer AnsInd in the question QstCod *****/
|
the answer AnsInd in the question QstCod *****/
|
||||||
if (asprintf (&Query,"UPDATE gam_answers SET NumUsrs=NumUsrs+1"
|
DB_BuildQuery ("UPDATE gam_answers SET NumUsrs=NumUsrs+1"
|
||||||
" WHERE QstCod=%ld AND AnsInd=%u",
|
" WHERE QstCod=%ld AND AnsInd=%u",
|
||||||
QstCod,AnsInd) < 0)
|
QstCod,AnsInd);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not register your answer to the game");
|
||||||
DB_QueryINSERT_free (Query,"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)
|
static void Gam_RegisterIHaveAnsweredGame (long GamCod)
|
||||||
{
|
{
|
||||||
char *Query;
|
DB_BuildQuery ("INSERT INTO gam_users"
|
||||||
|
" (GamCod,UsrCod)"
|
||||||
if (asprintf (&Query,"INSERT INTO gam_users"
|
" VALUES"
|
||||||
" (GamCod,UsrCod)"
|
" (%ld,%ld)",
|
||||||
" VALUES"
|
GamCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
" (%ld,%ld)",
|
DB_QueryINSERT_new ("can not register that you have answered the game");
|
||||||
GamCod,Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
DB_QueryINSERT_free (Query,"can not register that you have answered the game");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
34
swad_group.c
34
swad_group.c
|
@ -1278,16 +1278,13 @@ static void Grp_RemoveUsrFromGroup (long UsrCod,long GrpCod)
|
||||||
|
|
||||||
static void Grp_AddUsrToGroup (struct UsrData *UsrDat,long GrpCod)
|
static void Grp_AddUsrToGroup (struct UsrData *UsrDat,long GrpCod)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Register in group *****/
|
/***** Register in group *****/
|
||||||
if (asprintf (&Query,"INSERT INTO crs_grp_usr"
|
DB_BuildQuery ("INSERT INTO crs_grp_usr"
|
||||||
" (GrpCod,UsrCod)"
|
" (GrpCod,UsrCod)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,%ld)",
|
" (%ld,%ld)",
|
||||||
GrpCod,UsrDat->UsrCod) < 0)
|
GrpCod,UsrDat->UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not add a user to a group");
|
||||||
DB_QueryINSERT_free (Query,"can not add a user to a group");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -3849,18 +3846,15 @@ static void Grp_CreateGroupType (void)
|
||||||
|
|
||||||
static void Grp_CreateGroup (void)
|
static void Grp_CreateGroup (void)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Create a new group *****/
|
/***** Create a new group *****/
|
||||||
if (asprintf (&Query,"INSERT INTO crs_grp"
|
DB_BuildQuery ("INSERT INTO crs_grp"
|
||||||
" (GrpTypCod,GrpName,MaxStudents,Open,FileZones)"
|
" (GrpTypCod,GrpName,MaxStudents,Open,FileZones)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,'%s',%u,'N','N')",
|
" (%ld,'%s',%u,'N','N')",
|
||||||
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod,
|
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod,
|
||||||
Gbl.CurrentCrs.Grps.GrpName,
|
Gbl.CurrentCrs.Grps.GrpName,
|
||||||
Gbl.CurrentCrs.Grps.MaxStudents) < 0)
|
Gbl.CurrentCrs.Grps.MaxStudents);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not create group");
|
||||||
DB_QueryINSERT_free (Query,"can not create group");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -1193,21 +1193,18 @@ void Hld_RecFormNewHoliday2 (void)
|
||||||
|
|
||||||
static void Hld_CreateHoliday (struct Holiday *Hld)
|
static void Hld_CreateHoliday (struct Holiday *Hld)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Create a new holiday or no school period *****/
|
/***** Create a new holiday or no school period *****/
|
||||||
if (asprintf (&Query,"INSERT INTO holidays"
|
DB_BuildQuery ("INSERT INTO holidays"
|
||||||
" (InsCod,PlcCod,HldTyp,StartDate,EndDate,Name)"
|
" (InsCod,PlcCod,HldTyp,StartDate,EndDate,Name)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,%ld,%u,'%04u%02u%02u','%04u%02u%02u','%s')",
|
" (%ld,%ld,%u,'%04u%02u%02u','%04u%02u%02u','%s')",
|
||||||
Gbl.CurrentIns.Ins.InsCod,Hld->PlcCod,(unsigned) Hld->HldTyp,
|
Gbl.CurrentIns.Ins.InsCod,Hld->PlcCod,(unsigned) Hld->HldTyp,
|
||||||
Hld->StartDate.Year,
|
Hld->StartDate.Year,
|
||||||
Hld->StartDate.Month,
|
Hld->StartDate.Month,
|
||||||
Hld->StartDate.Day,
|
Hld->StartDate.Day,
|
||||||
Hld->EndDate.Year,
|
Hld->EndDate.Year,
|
||||||
Hld->EndDate.Month,
|
Hld->EndDate.Month,
|
||||||
Hld->EndDate.Day,
|
Hld->EndDate.Day,
|
||||||
Hld->Name) < 0)
|
Hld->Name);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not create holiday");
|
||||||
DB_QueryINSERT_free (Query,"can not create holiday");
|
|
||||||
}
|
}
|
||||||
|
|
17
swad_info.c
17
swad_info.c
|
@ -1518,15 +1518,14 @@ void Inf_SetInfoSrcIntoDB (Inf_InfoSrc_t InfoSrc)
|
||||||
}
|
}
|
||||||
else // Info is not stored in database, so insert it
|
else // Info is not stored in database, so insert it
|
||||||
{
|
{
|
||||||
if (asprintf (&Query,"INSERT INTO crs_info_src"
|
DB_BuildQuery ("INSERT INTO crs_info_src"
|
||||||
" (CrsCod,InfoType,InfoSrc,MustBeRead)"
|
" (CrsCod,InfoType,InfoSrc,MustBeRead)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,'%s','%s','N')",
|
" (%ld,'%s','%s','N')",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
Inf_NamesInDBForInfoType[Gbl.CurrentCrs.Info.Type],
|
Inf_NamesInDBForInfoType[Gbl.CurrentCrs.Info.Type],
|
||||||
Inf_NamesInDBForInfoSrc[InfoSrc]) < 0)
|
Inf_NamesInDBForInfoSrc[InfoSrc]);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not insert info source");
|
||||||
DB_QueryINSERT_free (Query,"can not insert info source");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
swad_link.c
14
swad_link.c
|
@ -851,16 +851,14 @@ void Lnk_RecFormNewLink (void)
|
||||||
static void Lnk_CreateLink (struct Link *Lnk)
|
static void Lnk_CreateLink (struct Link *Lnk)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Created_new_link_X;
|
extern const char *Txt_Created_new_link_X;
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Create a new link *****/
|
/***** Create a new link *****/
|
||||||
if (asprintf (&Query,"INSERT INTO links"
|
DB_BuildQuery ("INSERT INTO links"
|
||||||
" (ShortName,FullName,WWW)"
|
" (ShortName,FullName,WWW)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" ('%s','%s','%s')",
|
" ('%s','%s','%s')",
|
||||||
Lnk->ShrtName,Lnk->FullName,Lnk->WWW) < 0)
|
Lnk->ShrtName,Lnk->FullName,Lnk->WWW);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not create institutional link");
|
||||||
DB_QueryINSERT_free (Query,"can not create institutional link");
|
|
||||||
|
|
||||||
/***** Write success message *****/
|
/***** Write success message *****/
|
||||||
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
||||||
|
|
14
swad_mail.c
14
swad_mail.c
|
@ -855,16 +855,14 @@ void Mai_RecFormNewMailDomain (void)
|
||||||
static void Mai_CreateMailDomain (struct Mail *Mai)
|
static void Mai_CreateMailDomain (struct Mail *Mai)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Created_new_email_domain_X;
|
extern const char *Txt_Created_new_email_domain_X;
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Create a new mail *****/
|
/***** Create a new mail *****/
|
||||||
if (asprintf (&Query,"INSERT INTO mail_domains"
|
DB_BuildQuery ("INSERT INTO mail_domains"
|
||||||
" (Domain,Info)"
|
" (Domain,Info)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" ('%s','%s')",
|
" ('%s','%s')",
|
||||||
Mai->Domain,Mai->Info) < 0)
|
Mai->Domain,Mai->Info);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not create mail domain");
|
||||||
DB_QueryINSERT_free (Query,"can not create mail domain");
|
|
||||||
|
|
||||||
/***** Write success message *****/
|
/***** Write success message *****/
|
||||||
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
||||||
|
|
23
swad_mark.c
23
swad_mark.c
|
@ -87,20 +87,17 @@ static bool Mrk_GetUsrMarks (FILE *FileUsrMarks,struct UsrData *UsrDat,
|
||||||
|
|
||||||
void Mrk_AddMarksToDB (long FilCod,struct MarksProperties *Marks)
|
void Mrk_AddMarksToDB (long FilCod,struct MarksProperties *Marks)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Add file of marks to the database *****/
|
/***** Add file of marks to the database *****/
|
||||||
if (asprintf (&Query,"INSERT INTO marks_properties"
|
DB_BuildQuery ("INSERT INTO marks_properties"
|
||||||
" (FilCod,%s,%s)"
|
" (FilCod,%s,%s)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,%u,%u)",
|
" (%ld,%u,%u)",
|
||||||
Mrk_HeadOrFootStr[Brw_HEADER],
|
Mrk_HeadOrFootStr[Brw_HEADER],
|
||||||
Mrk_HeadOrFootStr[Brw_FOOTER],
|
Mrk_HeadOrFootStr[Brw_FOOTER],
|
||||||
FilCod,
|
FilCod,
|
||||||
Marks->Header,
|
Marks->Header,
|
||||||
Marks->Footer) < 0)
|
Marks->Footer);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not add properties of marks to database");
|
||||||
DB_QueryINSERT_free (Query,"can not add properties of marks to database");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -310,14 +310,13 @@ void Not_RemoveNotice (void)
|
||||||
|
|
||||||
/***** Remove notice *****/
|
/***** Remove notice *****/
|
||||||
/* Copy notice to table of deleted notices */
|
/* Copy notice to table of deleted notices */
|
||||||
if (asprintf (&Query,"INSERT IGNORE INTO notices_deleted"
|
DB_BuildQuery ("INSERT IGNORE INTO notices_deleted"
|
||||||
" (NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif)"
|
" (NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif)"
|
||||||
" SELECT NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif"
|
" SELECT NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif"
|
||||||
" FROM notices"
|
" FROM notices"
|
||||||
" WHERE NotCod=%ld AND CrsCod=%ld",
|
" WHERE NotCod=%ld AND CrsCod=%ld",
|
||||||
NotCod,Gbl.CurrentCrs.Crs.CrsCod) < 0)
|
NotCod,Gbl.CurrentCrs.Crs.CrsCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not remove notice");
|
||||||
DB_QueryINSERT_free (Query,"can not remove notice");
|
|
||||||
|
|
||||||
/* Remove notice */
|
/* Remove notice */
|
||||||
if (asprintf (&Query,"DELETE FROM notices"
|
if (asprintf (&Query,"DELETE FROM notices"
|
||||||
|
|
|
@ -1471,7 +1471,6 @@ void Ntf_StoreNotifyEventToOneUser (Ntf_NotifyEvent_t NotifyEvent,
|
||||||
struct UsrData *UsrDat,
|
struct UsrData *UsrDat,
|
||||||
long Cod,Ntf_Status_t Status)
|
long Cod,Ntf_Status_t Status)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
long InsCod;
|
long InsCod;
|
||||||
long CtrCod;
|
long CtrCod;
|
||||||
long DegCod;
|
long DegCod;
|
||||||
|
@ -1512,16 +1511,15 @@ void Ntf_StoreNotifyEventToOneUser (Ntf_NotifyEvent_t NotifyEvent,
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Store notify event *****/
|
/***** Store notify event *****/
|
||||||
if (asprintf (&Query,"INSERT INTO notif"
|
DB_BuildQuery ("INSERT INTO notif"
|
||||||
" (NotifyEvent,ToUsrCod,FromUsrCod,"
|
" (NotifyEvent,ToUsrCod,FromUsrCod,"
|
||||||
"InsCod,CtrCod,DegCod,CrsCod,Cod,TimeNotif,Status)"
|
"InsCod,CtrCod,DegCod,CrsCod,Cod,TimeNotif,Status)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%u,%ld,%ld,"
|
" (%u,%ld,%ld,"
|
||||||
"%ld,%ld,%ld,%ld,%ld,NOW(),%u)",
|
"%ld,%ld,%ld,%ld,%ld,NOW(),%u)",
|
||||||
(unsigned) NotifyEvent,UsrDat->UsrCod,Gbl.Usrs.Me.UsrDat.UsrCod,
|
(unsigned) NotifyEvent,UsrDat->UsrCod,Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
InsCod,CtrCod,DegCod,CrsCod,Cod,(unsigned) Status) < 0)
|
InsCod,CtrCod,DegCod,CrsCod,Cod,(unsigned) Status);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not create new notification event");
|
||||||
DB_QueryINSERT_free (Query,"can not create new notification event");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
13
swad_photo.c
13
swad_photo.c
|
@ -1010,13 +1010,12 @@ unsigned Pho_UpdateMyClicksWithoutPhoto (void)
|
||||||
else // The user does not exist ==> add him/her
|
else // The user does not exist ==> add him/her
|
||||||
{
|
{
|
||||||
/* Add the user, with one access */
|
/* Add the user, with one access */
|
||||||
if (asprintf (&Query,"INSERT INTO clicks_without_photo"
|
DB_BuildQuery ("INSERT INTO clicks_without_photo"
|
||||||
" (UsrCod,NumClicks)"
|
" (UsrCod,NumClicks)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,1)",
|
" (%ld,1)",
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not create number of clicks without photo");
|
||||||
DB_QueryINSERT_free (Query,"can not create number of clicks without photo");
|
|
||||||
NumClicks = 1;
|
NumClicks = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
swad_place.c
14
swad_place.c
|
@ -873,16 +873,14 @@ void Plc_RecFormNewPlace (void)
|
||||||
static void Plc_CreatePlace (struct Place *Plc)
|
static void Plc_CreatePlace (struct Place *Plc)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Created_new_place_X;
|
extern const char *Txt_Created_new_place_X;
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Create a new place *****/
|
/***** Create a new place *****/
|
||||||
if (asprintf (&Query,"INSERT INTO places"
|
DB_BuildQuery ("INSERT INTO places"
|
||||||
" (InsCod,ShortName,FullName)"
|
" (InsCod,ShortName,FullName)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,'%s','%s')",
|
" (%ld,'%s','%s')",
|
||||||
Gbl.CurrentIns.Ins.InsCod,Plc->ShrtName,Plc->FullName) < 0)
|
Gbl.CurrentIns.Ins.InsCod,Plc->ShrtName,Plc->FullName);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not create place");
|
||||||
DB_QueryINSERT_free (Query,"can not create place");
|
|
||||||
|
|
||||||
/***** Write success message *****/
|
/***** Write success message *****/
|
||||||
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
||||||
|
|
|
@ -1054,19 +1054,17 @@ void Plg_RecFormNewPlg (void)
|
||||||
static void Plg_CreatePlugin (struct Plugin *Plg)
|
static void Plg_CreatePlugin (struct Plugin *Plg)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Created_new_plugin_X;
|
extern const char *Txt_Created_new_plugin_X;
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Create a new plugin *****/
|
/***** Create a new plugin *****/
|
||||||
if (asprintf (&Query,"INSERT INTO plugins"
|
DB_BuildQuery ("INSERT INTO plugins"
|
||||||
" (Name,Description,Logo,"
|
" (Name,Description,Logo,"
|
||||||
"AppKey,URL,IP)"
|
"AppKey,URL,IP)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" ('%s','%s','%s',"
|
" ('%s','%s','%s',"
|
||||||
"'%s','%s','%s')",
|
"'%s','%s','%s')",
|
||||||
Plg->Name,Plg->Description,Plg->Logo,
|
Plg->Name,Plg->Description,Plg->Logo,
|
||||||
Plg->AppKey,Plg->URL,Plg->IP) < 0)
|
Plg->AppKey,Plg->URL,Plg->IP);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not create plugin");
|
||||||
DB_QueryINSERT_free (Query,"can not create plugin");
|
|
||||||
|
|
||||||
/***** Write success message *****/
|
/***** Write success message *****/
|
||||||
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
||||||
|
|
|
@ -1039,7 +1039,6 @@ static void Prf_ResetUsrFigures (struct UsrFigures *UsrFigures)
|
||||||
static void Prf_CreateUsrFigures (long UsrCod,const struct UsrFigures *UsrFigures,
|
static void Prf_CreateUsrFigures (long UsrCod,const struct UsrFigures *UsrFigures,
|
||||||
bool CreatingMyOwnAccount)
|
bool CreatingMyOwnAccount)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
char SubQueryFirstClickTime[Prf_MAX_BYTES_SUBQUERY_FIRST_CLICK_TIME + 1];
|
char SubQueryFirstClickTime[Prf_MAX_BYTES_SUBQUERY_FIRST_CLICK_TIME + 1];
|
||||||
|
|
||||||
if (CreatingMyOwnAccount)
|
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
|
(long) UsrFigures->FirstClickTimeUTC); // 0 ==> unknown first click time or user never logged
|
||||||
|
|
||||||
/***** Create user's figures *****/
|
/***** Create user's figures *****/
|
||||||
if (asprintf (&Query,"INSERT INTO usr_figures"
|
DB_BuildQuery ("INSERT INTO usr_figures"
|
||||||
" (UsrCod,FirstClickTime,NumClicks,NumFileViews,NumForPst,NumMsgSnt)"
|
" (UsrCod,FirstClickTime,NumClicks,NumFileViews,NumForPst,NumMsgSnt)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,%s,%ld,%ld,%ld,%ld)",
|
" (%ld,%s,%ld,%ld,%ld,%ld)",
|
||||||
UsrCod,
|
UsrCod,
|
||||||
SubQueryFirstClickTime,
|
SubQueryFirstClickTime,
|
||||||
UsrFigures->NumClicks, // -1L ==> unknown number of clicks
|
UsrFigures->NumClicks, // -1L ==> unknown number of clicks
|
||||||
UsrFigures->NumFileViews, // -1L ==> unknown number of file views
|
UsrFigures->NumFileViews, // -1L ==> unknown number of file views
|
||||||
UsrFigures->NumForPst, // -1L ==> unknown number of forum posts
|
UsrFigures->NumForPst, // -1L ==> unknown number of forum posts
|
||||||
UsrFigures->NumMsgSnt) < 0) // -1L ==> unknown number of messages sent
|
UsrFigures->NumMsgSnt); // -1L ==> unknown number of messages sent
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not create user's figures");
|
||||||
DB_QueryINSERT_free (Query,"can not create user's figures");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1096,15 +1094,12 @@ static bool Prf_CheckIfUsrFiguresExists (long UsrCod)
|
||||||
|
|
||||||
void Prf_IncrementNumClicksUsr (long UsrCod)
|
void Prf_IncrementNumClicksUsr (long UsrCod)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Increment number of clicks *****/
|
/***** Increment number of clicks *****/
|
||||||
// If NumClicks < 0 ==> not yet calculated, so do nothing
|
// If NumClicks < 0 ==> not yet calculated, so do nothing
|
||||||
if (asprintf (&Query,"UPDATE IGNORE usr_figures SET NumClicks=NumClicks+1"
|
DB_BuildQuery ("UPDATE IGNORE usr_figures SET NumClicks=NumClicks+1"
|
||||||
" WHERE UsrCod=%ld AND NumClicks>=0",
|
" WHERE UsrCod=%ld AND NumClicks>=0",
|
||||||
UsrCod) < 0)
|
UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not increment user's clicks");
|
||||||
DB_QueryINSERT_free (Query,"can not increment user's clicks");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1113,15 +1108,12 @@ void Prf_IncrementNumClicksUsr (long UsrCod)
|
||||||
|
|
||||||
void Prf_IncrementNumFileViewsUsr (long UsrCod)
|
void Prf_IncrementNumFileViewsUsr (long UsrCod)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Increment number of file views *****/
|
/***** Increment number of file views *****/
|
||||||
// If NumFileViews < 0 ==> not yet calculated, so do nothing
|
// If NumFileViews < 0 ==> not yet calculated, so do nothing
|
||||||
if (asprintf (&Query,"UPDATE IGNORE usr_figures SET NumFileViews=NumFileViews+1"
|
DB_BuildQuery ("UPDATE IGNORE usr_figures SET NumFileViews=NumFileViews+1"
|
||||||
" WHERE UsrCod=%ld AND NumFileViews>=0",
|
" WHERE UsrCod=%ld AND NumFileViews>=0",
|
||||||
UsrCod) < 0)
|
UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not increment user's file views");
|
||||||
DB_QueryINSERT_free (Query,"can not increment user's file views");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1130,15 +1122,12 @@ void Prf_IncrementNumFileViewsUsr (long UsrCod)
|
||||||
|
|
||||||
void Prf_IncrementNumForPstUsr (long UsrCod)
|
void Prf_IncrementNumForPstUsr (long UsrCod)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Increment number of forum posts *****/
|
/***** Increment number of forum posts *****/
|
||||||
// If NumForPst < 0 ==> not yet calculated, so do nothing
|
// If NumForPst < 0 ==> not yet calculated, so do nothing
|
||||||
if (asprintf (&Query,"UPDATE IGNORE usr_figures SET NumForPst=NumForPst+1"
|
DB_BuildQuery ("UPDATE IGNORE usr_figures SET NumForPst=NumForPst+1"
|
||||||
" WHERE UsrCod=%ld AND NumForPst>=0",
|
" WHERE UsrCod=%ld AND NumForPst>=0",
|
||||||
UsrCod) < 0)
|
UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not increment user's forum posts");
|
||||||
DB_QueryINSERT_free (Query,"can not increment user's forum posts");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1147,15 +1136,12 @@ void Prf_IncrementNumForPstUsr (long UsrCod)
|
||||||
|
|
||||||
void Prf_IncrementNumMsgSntUsr (long UsrCod)
|
void Prf_IncrementNumMsgSntUsr (long UsrCod)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Increment number of messages sent *****/
|
/***** Increment number of messages sent *****/
|
||||||
// If NumMsgSnt < 0 ==> not yet calculated, so do nothing
|
// If NumMsgSnt < 0 ==> not yet calculated, so do nothing
|
||||||
if (asprintf (&Query,"UPDATE IGNORE usr_figures SET NumMsgSnt=NumMsgSnt+1"
|
DB_BuildQuery ("UPDATE IGNORE usr_figures SET NumMsgSnt=NumMsgSnt+1"
|
||||||
" WHERE UsrCod=%ld AND NumMsgSnt>=0",
|
" WHERE UsrCod=%ld AND NumMsgSnt>=0",
|
||||||
UsrCod) < 0)
|
UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not increment user's messages sent");
|
||||||
DB_QueryINSERT_free (Query,"can not increment user's messages sent");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -3354,49 +3354,45 @@ void Prj_RecFormProject (void)
|
||||||
|
|
||||||
static void Prj_CreateProject (struct Project *Prj)
|
static void Prj_CreateProject (struct Project *Prj)
|
||||||
{
|
{
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Set dates to now *****/
|
/***** Set dates to now *****/
|
||||||
Prj->CreatTime =
|
Prj->CreatTime =
|
||||||
Prj->ModifTime = Gbl.StartExecutionTimeUTC;
|
Prj->ModifTime = Gbl.StartExecutionTimeUTC;
|
||||||
|
|
||||||
/***** Create a new project *****/
|
/***** Create a new project *****/
|
||||||
if (asprintf (&Query,"INSERT INTO projects"
|
DB_BuildQuery ("INSERT INTO projects"
|
||||||
" (CrsCod,DptCod,Hidden,Preassigned,NumStds,Proposal,"
|
" (CrsCod,DptCod,Hidden,Preassigned,NumStds,Proposal,"
|
||||||
"CreatTime,ModifTime,"
|
"CreatTime,ModifTime,"
|
||||||
"Title,Description,Knowledge,Materials,URL)"
|
"Title,Description,Knowledge,Materials,URL)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,%ld,'%c','%c',%u,'%s',"
|
" (%ld,%ld,'%c','%c',%u,'%s',"
|
||||||
"FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld),"
|
"FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld),"
|
||||||
"'%s','%s','%s','%s','%s')",
|
"'%s','%s','%s','%s','%s')",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
Prj->DptCod,
|
Prj->DptCod,
|
||||||
Prj->Hidden == Prj_HIDDEN ? 'Y' :
|
Prj->Hidden == Prj_HIDDEN ? 'Y' :
|
||||||
'N',
|
'N',
|
||||||
Prj->Preassigned == Prj_PREASSIGNED ? 'Y' :
|
Prj->Preassigned == Prj_PREASSIGNED ? 'Y' :
|
||||||
'N',
|
'N',
|
||||||
Prj->NumStds,
|
Prj->NumStds,
|
||||||
Prj_Proposal_DB[Prj->Proposal],
|
Prj_Proposal_DB[Prj->Proposal],
|
||||||
Prj->CreatTime,
|
Prj->CreatTime,
|
||||||
Prj->ModifTime,
|
Prj->ModifTime,
|
||||||
Prj->Title,
|
Prj->Title,
|
||||||
Prj->Description,
|
Prj->Description,
|
||||||
Prj->Knowledge,
|
Prj->Knowledge,
|
||||||
Prj->Materials,
|
Prj->Materials,
|
||||||
Prj->URL) < 0)
|
Prj->URL);
|
||||||
Lay_NotEnoughMemoryExit ();
|
Prj->PrjCod = DB_QueryINSERTandReturnCode_new ("can not create new project");
|
||||||
Prj->PrjCod = DB_QueryINSERTandReturnCode_free (Query,"can not create new project");
|
|
||||||
|
|
||||||
/***** Insert creator as first tutor *****/
|
/***** Insert creator as first tutor *****/
|
||||||
if (asprintf (&Query,"INSERT INTO prj_usr"
|
DB_BuildQuery ("INSERT INTO prj_usr"
|
||||||
" (PrjCod,RoleInProject,UsrCod)"
|
" (PrjCod,RoleInProject,UsrCod)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,%u,%ld)",
|
" (%ld,%u,%ld)",
|
||||||
Prj->PrjCod,
|
Prj->PrjCod,
|
||||||
(unsigned) Prj_ROLE_TUT,
|
(unsigned) Prj_ROLE_TUT,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not add tutor");
|
||||||
DB_QueryINSERT_free (Query,"can not add tutor");
|
|
||||||
|
|
||||||
/***** Flush cache *****/
|
/***** Flush cache *****/
|
||||||
Prj_FlushCacheMyRoleInProject ();
|
Prj_FlushCacheMyRoleInProject ();
|
||||||
|
|
|
@ -573,19 +573,17 @@ unsigned long Rec_GetAllFieldsInCurrCrs (MYSQL_RES **mysql_res)
|
||||||
void Rec_CreateRecordField (void)
|
void Rec_CreateRecordField (void)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Created_new_record_field_X;
|
extern const char *Txt_Created_new_record_field_X;
|
||||||
char *Query;
|
|
||||||
|
|
||||||
/***** Create the new field *****/
|
/***** Create the new field *****/
|
||||||
if (asprintf (&Query,"INSERT INTO crs_record_fields"
|
DB_BuildQuery ("INSERT INTO crs_record_fields"
|
||||||
" (CrsCod,FieldName,NumLines,Visibility)"
|
" (CrsCod,FieldName,NumLines,Visibility)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,'%s',%u,%u)",
|
" (%ld,'%s',%u,%u)",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
Gbl.CurrentCrs.Records.Field.Name,
|
Gbl.CurrentCrs.Records.Field.Name,
|
||||||
Gbl.CurrentCrs.Records.Field.NumLines,
|
Gbl.CurrentCrs.Records.Field.NumLines,
|
||||||
(unsigned) Gbl.CurrentCrs.Records.Field.Visibility) < 0)
|
(unsigned) Gbl.CurrentCrs.Records.Field.Visibility);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not create field of record");
|
||||||
DB_QueryINSERT_free (Query,"can not create field of record");
|
|
||||||
|
|
||||||
/***** Write message of success *****/
|
/***** Write message of success *****/
|
||||||
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
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])
|
else if (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text[0])
|
||||||
{
|
{
|
||||||
/***** Insert text field of record course *****/
|
/***** Insert text field of record course *****/
|
||||||
if (asprintf (&Query,"INSERT INTO crs_records"
|
DB_BuildQuery ("INSERT INTO crs_records"
|
||||||
" (FieldCod,UsrCod,Txt)"
|
" (FieldCod,UsrCod,Txt)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,%ld,'%s')",
|
" (%ld,%ld,'%s')",
|
||||||
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod,
|
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod,
|
||||||
UsrCod,
|
UsrCod,
|
||||||
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text) < 0)
|
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text);
|
||||||
Lay_NotEnoughMemoryExit ();
|
DB_QueryINSERT_new ("can not create field of record");
|
||||||
DB_QueryINSERT_free (Query,"can not create field of record");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -537,8 +537,8 @@ void Sta_AskShowCrsHits (void)
|
||||||
|
|
||||||
/***** Option a) Listing of clicks distributed by some metric *****/
|
/***** Option a) Listing of clicks distributed by some metric *****/
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
"<td class=\"RIGHT_TOP %s\">%s:</td>"
|
"<td class=\"RIGHT_MIDDLE %s\">%s:</td>"
|
||||||
"<td colspan=\"2\" class=\"LEFT_TOP\">",
|
"<td colspan=\"2\" class=\"LEFT_MIDDLE\">",
|
||||||
The_ClassForm[Gbl.Prefs.Theme],Txt_Show);
|
The_ClassForm[Gbl.Prefs.Theme],Txt_Show);
|
||||||
|
|
||||||
if ((Gbl.Stat.ClicksGroupedBy < Sta_CLICKS_CRS_PER_USR ||
|
if ((Gbl.Stat.ClicksGroupedBy < Sta_CLICKS_CRS_PER_USR ||
|
||||||
|
@ -735,10 +735,10 @@ void Sta_AskShowGblHits (void)
|
||||||
|
|
||||||
/***** Count type for the statistic *****/
|
/***** Count type for the statistic *****/
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
"<td class=\"RIGHT_TOP\">"
|
"<td class=\"RIGHT_MIDDLE\">"
|
||||||
"<label for=\"CountType\" class=\"%s\">%s:</label>"
|
"<label for=\"CountType\" class=\"%s\">%s:</label>"
|
||||||
"</td>"
|
"</td>"
|
||||||
"<td colspan=\"2\" class=\"LEFT_TOP\">",
|
"<td colspan=\"2\" class=\"LEFT_MIDDLE\">",
|
||||||
The_ClassForm[Gbl.Prefs.Theme],Txt_Show);
|
The_ClassForm[Gbl.Prefs.Theme],Txt_Show);
|
||||||
Sta_WriteSelectorCountType ();
|
Sta_WriteSelectorCountType ();
|
||||||
|
|
||||||
|
@ -816,10 +816,10 @@ static void Sta_WriteSelectorAction (void)
|
||||||
char ActTxt[Act_MAX_BYTES_ACTION_TXT + 1];
|
char ActTxt[Act_MAX_BYTES_ACTION_TXT + 1];
|
||||||
|
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
"<td class=\"RIGHT_TOP\">"
|
"<td class=\"RIGHT_MIDDLE\">"
|
||||||
"<label for=\"StatAct\" class=\"%s\">%s:</label>"
|
"<label for=\"StatAct\" class=\"%s\">%s:</label>"
|
||||||
"</td>"
|
"</td>"
|
||||||
"<td colspan=\"2\" class=\"LEFT_TOP\">"
|
"<td colspan=\"2\" class=\"LEFT_MIDDLE\">"
|
||||||
"<select id=\"StatAct\" name=\"StatAct\""
|
"<select id=\"StatAct\" name=\"StatAct\""
|
||||||
" style=\"width:375px;\">",
|
" style=\"width:375px;\">",
|
||||||
The_ClassForm[Gbl.Prefs.Theme],Txt_Action);
|
The_ClassForm[Gbl.Prefs.Theme],Txt_Action);
|
||||||
|
|
Loading…
Reference in New Issue