Version 18.8.13

This commit is contained in:
Antonio Cañas Vargas 2018-10-27 22:08:01 +02:00
parent d90d736fa8
commit b60c71b5a6
22 changed files with 539 additions and 780 deletions

View File

@ -1359,7 +1359,6 @@ void Agd_RemoveEvent (void)
void Agd_HideEvent (void)
{
extern const char *Txt_Event_X_is_now_hidden;
char *Query;
struct AgendaEvent AgdEvent;
/***** Get event code *****/
@ -1371,11 +1370,10 @@ void Agd_HideEvent (void)
Agd_GetDataOfEventByCod (&AgdEvent);
/***** Set event private *****/
if (asprintf (&Query,"UPDATE agendas SET Hidden='Y'"
" WHERE AgdCod=%ld AND UsrCod=%ld",
AgdEvent.AgdCod,AgdEvent.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not hide event");
DB_BuildQuery ("UPDATE agendas SET Hidden='Y'"
" WHERE AgdCod=%ld AND UsrCod=%ld",
AgdEvent.AgdCod,AgdEvent.UsrCod);
DB_QueryUPDATE_new ("can not hide event");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -1394,7 +1392,6 @@ void Agd_HideEvent (void)
void Agd_UnhideEvent (void)
{
extern const char *Txt_Event_X_is_now_visible;
char *Query;
struct AgendaEvent AgdEvent;
/***** Get event code *****/
@ -1406,11 +1403,10 @@ void Agd_UnhideEvent (void)
Agd_GetDataOfEventByCod (&AgdEvent);
/***** Set event public *****/
if (asprintf (&Query,"UPDATE agendas SET Hidden='N'"
" WHERE AgdCod=%ld AND UsrCod=%ld",
AgdEvent.AgdCod,AgdEvent.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not show event");
DB_BuildQuery ("UPDATE agendas SET Hidden='N'"
" WHERE AgdCod=%ld AND UsrCod=%ld",
AgdEvent.AgdCod,AgdEvent.UsrCod);
DB_QueryUPDATE_new ("can not show event");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -1429,7 +1425,6 @@ void Agd_UnhideEvent (void)
void Agd_MakeEventPrivate (void)
{
extern const char *Txt_Event_X_is_now_private;
char *Query;
struct AgendaEvent AgdEvent;
/***** Get event code *****/
@ -1441,11 +1436,10 @@ void Agd_MakeEventPrivate (void)
Agd_GetDataOfEventByCod (&AgdEvent);
/***** Make event private *****/
if (asprintf (&Query,"UPDATE agendas SET Public='N'"
" WHERE AgdCod=%ld AND UsrCod=%ld",
AgdEvent.AgdCod,AgdEvent.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not make event private");
DB_BuildQuery ("UPDATE agendas SET Public='N'"
" WHERE AgdCod=%ld AND UsrCod=%ld",
AgdEvent.AgdCod,AgdEvent.UsrCod);
DB_QueryUPDATE_new ("can not make event private");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -1464,7 +1458,6 @@ void Agd_MakeEventPrivate (void)
void Agd_MakeEventPublic (void)
{
extern const char *Txt_Event_X_is_now_visible_to_users_of_your_courses;
char *Query;
struct AgendaEvent AgdEvent;
/***** Get event code *****/
@ -1476,11 +1469,10 @@ void Agd_MakeEventPublic (void)
Agd_GetDataOfEventByCod (&AgdEvent);
/***** Make event public *****/
if (asprintf (&Query,"UPDATE agendas SET Public='Y'"
" WHERE AgdCod=%ld AND UsrCod=%ld",
AgdEvent.AgdCod,AgdEvent.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not make event public");
DB_BuildQuery ("UPDATE agendas SET Public='Y'"
" WHERE AgdCod=%ld AND UsrCod=%ld",
AgdEvent.AgdCod,AgdEvent.UsrCod);
DB_QueryUPDATE_new ("can not make event public");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -1735,20 +1727,17 @@ static void Agd_CreateEvent (struct AgendaEvent *AgdEvent,const char *Txt)
static void Agd_UpdateEvent (struct AgendaEvent *AgdEvent,const char *Txt)
{
char *Query;
/***** Update the data of the event *****/
if (asprintf (&Query,"UPDATE agendas SET "
"StartTime=FROM_UNIXTIME(%ld),"
"EndTime=FROM_UNIXTIME(%ld),"
"Event='%s',Location='%s',Txt='%s'"
" WHERE AgdCod=%ld AND UsrCod=%ld",
AgdEvent->TimeUTC[Agd_START_TIME],
AgdEvent->TimeUTC[Agd_END_TIME ],
AgdEvent->Event,AgdEvent->Location,Txt,
AgdEvent->AgdCod,AgdEvent->UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update event");
DB_BuildQuery ("UPDATE agendas SET "
"StartTime=FROM_UNIXTIME(%ld),"
"EndTime=FROM_UNIXTIME(%ld),"
"Event='%s',Location='%s',Txt='%s'"
" WHERE AgdCod=%ld AND UsrCod=%ld",
AgdEvent->TimeUTC[Agd_START_TIME],
AgdEvent->TimeUTC[Agd_END_TIME ],
AgdEvent->Event,AgdEvent->Location,Txt,
AgdEvent->AgdCod,AgdEvent->UsrCod);
DB_QueryUPDATE_new ("can not update event");
}
/*****************************************************************************/

View File

@ -527,18 +527,16 @@ static void Ann_CreateAnnouncement (unsigned Roles,const char *Subject,const cha
void Ann_HideActiveAnnouncement (void)
{
char *Query;
long AnnCod;
/***** Get the code of the global announcement to hide *****/
AnnCod = Ann_GetParamAnnCod ();
/***** Set global announcement as hidden *****/
if (asprintf (&Query,"UPDATE announcements SET Status=%u"
" WHERE AnnCod=%ld",
(unsigned) Ann_OBSOLETE_ANNOUNCEMENT,AnnCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not hide announcement");
DB_BuildQuery ("UPDATE announcements SET Status=%u"
" WHERE AnnCod=%ld",
(unsigned) Ann_OBSOLETE_ANNOUNCEMENT,AnnCod);
DB_QueryUPDATE_new ("can not hide announcement");
}
/*****************************************************************************/
@ -547,18 +545,16 @@ void Ann_HideActiveAnnouncement (void)
void Ann_RevealHiddenAnnouncement (void)
{
char *Query;
long AnnCod;
/***** Get the code of the global announcement to show *****/
AnnCod = Ann_GetParamAnnCod ();
/***** Set global announcement as shown *****/
if (asprintf (&Query,"UPDATE announcements SET Status=%u"
" WHERE AnnCod=%ld",
(unsigned) Ann_ACTIVE_ANNOUNCEMENT,AnnCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not reveal announcement");
DB_BuildQuery ("UPDATE announcements SET Status=%u"
" WHERE AnnCod=%ld",
(unsigned) Ann_ACTIVE_ANNOUNCEMENT,AnnCod);
DB_QueryUPDATE_new ("can not reveal announcement");
}
/*****************************************************************************/

View File

@ -1030,7 +1030,6 @@ void Asg_RemoveAssignment (void)
void Asg_HideAssignment (void)
{
extern const char *Txt_Assignment_X_is_now_hidden;
char *Query;
struct Assignment Asg;
/***** Get assignment code *****/
@ -1041,11 +1040,10 @@ void Asg_HideAssignment (void)
Asg_GetDataOfAssignmentByCod (&Asg);
/***** Hide assignment *****/
if (asprintf (&Query,"UPDATE assignments SET Hidden='Y'"
" WHERE AsgCod=%ld AND CrsCod=%ld",
Asg.AsgCod,Gbl.CurrentCrs.Crs.CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not hide assignment");
DB_BuildQuery ("UPDATE assignments SET Hidden='Y'"
" WHERE AsgCod=%ld AND CrsCod=%ld",
Asg.AsgCod,Gbl.CurrentCrs.Crs.CrsCod);
DB_QueryUPDATE_new ("can not hide assignment");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -1064,7 +1062,6 @@ void Asg_HideAssignment (void)
void Asg_ShowAssignment (void)
{
extern const char *Txt_Assignment_X_is_now_visible;
char *Query;
struct Assignment Asg;
/***** Get assignment code *****/
@ -1075,11 +1072,10 @@ void Asg_ShowAssignment (void)
Asg_GetDataOfAssignmentByCod (&Asg);
/***** Hide assignment *****/
if (asprintf (&Query,"UPDATE assignments SET Hidden='N'"
" WHERE AsgCod=%ld AND CrsCod=%ld",
Asg.AsgCod,Gbl.CurrentCrs.Crs.CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not show assignment");
DB_BuildQuery ("UPDATE assignments SET Hidden='N'"
" WHERE AsgCod=%ld AND CrsCod=%ld",
Asg.AsgCod,Gbl.CurrentCrs.Crs.CrsCod);
DB_QueryUPDATE_new ("can not show assignment");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -1465,14 +1461,11 @@ void Asg_RecFormAssignment (void)
static void Asg_UpdateNumUsrsNotifiedByEMailAboutAssignment (long AsgCod,unsigned NumUsrsToBeNotifiedByEMail)
{
char *Query;
/***** Update number of users notified *****/
if (asprintf (&Query,"UPDATE assignments SET NumNotif=NumNotif+%u"
" WHERE AsgCod=%ld",
NumUsrsToBeNotifiedByEMail,AsgCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the number of notifications of an assignment");
DB_BuildQuery ("UPDATE assignments SET NumNotif=NumNotif+%u"
" WHERE AsgCod=%ld",
NumUsrsToBeNotifiedByEMail,AsgCod);
DB_QueryUPDATE_new ("can not update the number of notifications of an assignment");
}
/*****************************************************************************/
@ -1507,22 +1500,19 @@ static void Asg_CreateAssignment (struct Assignment *Asg,const char *Txt)
static void Asg_UpdateAssignment (struct Assignment *Asg,const char *Txt)
{
char *Query;
/***** Update the data of the assignment *****/
if (asprintf (&Query,"UPDATE assignments SET "
"StartTime=FROM_UNIXTIME(%ld),"
"EndTime=FROM_UNIXTIME(%ld),"
"Title='%s',Folder='%s',Txt='%s'"
" WHERE AsgCod=%ld AND CrsCod=%ld",
Asg->TimeUTC[Dat_START_TIME],
Asg->TimeUTC[Dat_END_TIME ],
Asg->Title,
Asg->Folder,
Txt,
Asg->AsgCod,Gbl.CurrentCrs.Crs.CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update assignment");
DB_BuildQuery ("UPDATE assignments SET "
"StartTime=FROM_UNIXTIME(%ld),"
"EndTime=FROM_UNIXTIME(%ld),"
"Title='%s',Folder='%s',Txt='%s'"
" WHERE AsgCod=%ld AND CrsCod=%ld",
Asg->TimeUTC[Dat_START_TIME],
Asg->TimeUTC[Dat_END_TIME ],
Asg->Title,
Asg->Folder,
Txt,
Asg->AsgCod,Gbl.CurrentCrs.Crs.CrsCod);
DB_QueryUPDATE_new ("can not update assignment");
/***** Update groups *****/
/* Remove old groups */

View File

@ -959,7 +959,6 @@ void Att_RemoveAttEventFromDB (long AttCod)
void Att_HideAttEvent (void)
{
extern const char *Txt_Event_X_is_now_hidden;
char *Query;
struct AttendanceEvent Att;
/***** Get attendance event code *****/
@ -970,11 +969,10 @@ void Att_HideAttEvent (void)
Att_GetDataOfAttEventByCodAndCheckCrs (&Att);
/***** Hide attendance event *****/
if (asprintf (&Query,"UPDATE att_events SET Hidden='Y'"
" WHERE AttCod=%ld AND CrsCod=%ld",
Att.AttCod,Gbl.CurrentCrs.Crs.CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not hide attendance event");
DB_BuildQuery ("UPDATE att_events SET Hidden='Y'"
" WHERE AttCod=%ld AND CrsCod=%ld",
Att.AttCod,Gbl.CurrentCrs.Crs.CrsCod);
DB_QueryUPDATE_new ("can not hide attendance event");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -993,7 +991,6 @@ void Att_HideAttEvent (void)
void Att_ShowAttEvent (void)
{
extern const char *Txt_Event_X_is_now_visible;
char *Query;
struct AttendanceEvent Att;
/***** Get attendance event code *****/
@ -1004,11 +1001,10 @@ void Att_ShowAttEvent (void)
Att_GetDataOfAttEventByCodAndCheckCrs (&Att);
/***** Hide attendance event *****/
if (asprintf (&Query,"UPDATE att_events SET Hidden='N'"
" WHERE AttCod=%ld AND CrsCod=%ld",
Att.AttCod,Gbl.CurrentCrs.Crs.CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not show attendance event");
DB_BuildQuery ("UPDATE att_events SET Hidden='N'"
" WHERE AttCod=%ld AND CrsCod=%ld",
Att.AttCod,Gbl.CurrentCrs.Crs.CrsCod);
DB_QueryUPDATE_new ("can not show attendance event");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -1378,26 +1374,23 @@ void Att_CreateAttEvent (struct AttendanceEvent *Att,const char *Txt)
void Att_UpdateAttEvent (struct AttendanceEvent *Att,const char *Txt)
{
char *Query;
/***** Update the data of the attendance event *****/
if (asprintf (&Query,"UPDATE att_events SET "
"Hidden='%c',"
"StartTime=FROM_UNIXTIME(%ld),"
"EndTime=FROM_UNIXTIME(%ld),"
"CommentTchVisible='%c',Title='%s',Txt='%s'"
" WHERE AttCod=%ld AND CrsCod=%ld",
Att->Hidden ? 'Y' :
'N',
Att->TimeUTC[Att_START_TIME],
Att->TimeUTC[Att_END_TIME ],
Att->CommentTchVisible ? 'Y' :
'N',
Att->Title,
Txt,
Att->AttCod,Gbl.CurrentCrs.Crs.CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update attendance event");
DB_BuildQuery ("UPDATE att_events SET "
"Hidden='%c',"
"StartTime=FROM_UNIXTIME(%ld),"
"EndTime=FROM_UNIXTIME(%ld),"
"CommentTchVisible='%c',Title='%s',Txt='%s'"
" WHERE AttCod=%ld AND CrsCod=%ld",
Att->Hidden ? 'Y' :
'N',
Att->TimeUTC[Att_START_TIME],
Att->TimeUTC[Att_END_TIME ],
Att->CommentTchVisible ? 'Y' :
'N',
Att->Title,
Txt,
Att->AttCod,Gbl.CurrentCrs.Crs.CrsCod);
DB_QueryUPDATE_new ("can not update attendance event");
/***** Update groups *****/
/* Remove old groups */
@ -2584,7 +2577,6 @@ static bool Att_CheckIfUsrIsPresentInAttEventAndGetComments (long AttCod,long Us
void Att_RegUsrInAttEventNotChangingComments (long AttCod,long UsrCod)
{
bool Present;
char *Query;
/***** Check if user is already in table att_usr (present or not) *****/
if (Att_CheckIfUsrIsInTableAttUsr (AttCod,UsrCod,&Present)) // User is in table att_usr
@ -2593,11 +2585,10 @@ void Att_RegUsrInAttEventNotChangingComments (long AttCod,long UsrCod)
if (!Present)
{
/***** Set user as present in database *****/
if (asprintf (&Query,"UPDATE att_usr SET Present='Y'"
" WHERE AttCod=%ld AND UsrCod=%ld",
AttCod,UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not set user as present in an event");
DB_BuildQuery ("UPDATE att_usr SET Present='Y'"
" WHERE AttCod=%ld AND UsrCod=%ld",
AttCod,UsrCod);
DB_QueryUPDATE_new ("can not set user as present in an event");
}
}
else // User is not in table att_usr

View File

@ -73,7 +73,8 @@ static void Ban_ShowOrHideBanner (bool Hide);
static void Ban_RenameBanner (Cns_ShrtOrFullName_t ShrtOrFullName);
static bool Ban_CheckIfBannerNameExists (const char *FieldName,const char *Name,long BanCod);
static void Ban_UpdateBanNameDB (long BanCod,const char *FieldName,const char *NewBanName);
static void Ban_UpdateBanNameDB (long BanCod,const char *FieldName,
const char *NewBanName);
static void Ban_PutFormToCreateBanner (void);
static void Ban_PutHeadBanners (void);
@ -562,7 +563,6 @@ static void Ban_ShowOrHideBanner (bool Hide)
{
extern const char *Txt_The_banner_X_is_now_hidden;
extern const char *Txt_The_banner_X_is_now_visible;
char *Query;
struct Banner Ban;
/***** Get banner code *****/
@ -575,13 +575,12 @@ static void Ban_ShowOrHideBanner (bool Hide)
/***** Mark file as hidden/visible in database *****/
if (Ban.Hidden != Hide)
{
if (asprintf (&Query,"UPDATE banners SET Hidden='%c'"
" WHERE BanCod=%ld",
Hide ? 'Y' :
'N',
Ban.BanCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not change status of a banner in database");
DB_BuildQuery ("UPDATE banners SET Hidden='%c'"
" WHERE BanCod=%ld",
Hide ? 'Y' :
'N',
Ban.BanCod);
DB_QueryUPDATE_new ("can not change status of a banner in database");
}
/***** Write message to show the change made *****/
@ -724,15 +723,13 @@ static bool Ban_CheckIfBannerNameExists (const char *FieldName,const char *Name,
/***************** Update banner name in table of banners ********************/
/*****************************************************************************/
static void Ban_UpdateBanNameDB (long BanCod,const char *FieldName,const char *NewBanName)
static void Ban_UpdateBanNameDB (long BanCod,const char *FieldName,
const char *NewBanName)
{
char *Query;
/***** Update banner changing old name by new name *****/
if (asprintf (&Query,"UPDATE banners SET %s='%s' WHERE BanCod=%ld",
FieldName,NewBanName,BanCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the name of a banner");
DB_BuildQuery ("UPDATE banners SET %s='%s' WHERE BanCod=%ld",
FieldName,NewBanName,BanCod);
DB_QueryUPDATE_new ("can not update the name of a banner");
}
/*****************************************************************************/
@ -744,7 +741,6 @@ void Ban_ChangeBannerImg (void)
extern const char *Txt_The_new_image_is_X;
extern const char *Txt_You_can_not_leave_the_image_empty;
struct Banner *Ban;
char *Query;
char NewImg[Ban_MAX_BYTES_IMAGE + 1];
Ban = &Gbl.Banners.EditingBan;
@ -761,10 +757,9 @@ void Ban_ChangeBannerImg (void)
if (NewImg[0])
{
/* Update the table changing old image by new image */
if (asprintf (&Query,"UPDATE banners SET Img='%s' WHERE BanCod=%ld",
NewImg,Ban->BanCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the image of a banner");
DB_BuildQuery ("UPDATE banners SET Img='%s' WHERE BanCod=%ld",
NewImg,Ban->BanCod);
DB_QueryUPDATE_new ("can not update the image of a banner");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -791,7 +786,6 @@ void Ban_ChangeBannerWWW (void)
extern const char *Txt_The_new_web_address_is_X;
extern const char *Txt_You_can_not_leave_the_web_address_empty;
struct Banner *Ban;
char *Query;
char NewWWW[Cns_MAX_BYTES_WWW + 1];
Ban = &Gbl.Banners.EditingBan;
@ -808,10 +802,9 @@ void Ban_ChangeBannerWWW (void)
if (NewWWW[0])
{
/* Update the table changing old WWW by new WWW */
if (asprintf (&Query,"UPDATE banners SET WWW='%s' WHERE BanCod=%ld",
NewWWW,Ban->BanCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the web of a banner");
DB_BuildQuery ("UPDATE banners SET WWW='%s' WHERE BanCod=%ld",
NewWWW,Ban->BanCod);
DB_QueryUPDATE_new ("can not update the web of a banner");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),

View File

@ -146,20 +146,17 @@ void Cal_ShowFormToSelFirstDayOfWeek (Act_Action_t Action,void (*FuncParams) (),
void Cal_ChangeFirstDayOfWeek (void)
{
char *Query;
/***** Get param with icon set *****/
Gbl.Prefs.FirstDayOfWeek = Cal_GetParamFirstDayOfWeek ();
/***** Store icon first day of week database *****/
if (Gbl.Usrs.Me.Logged)
{
if (asprintf (&Query,"UPDATE usr_data SET FirstDayOfWeek=%u"
" WHERE UsrCod=%ld",
Gbl.Prefs.FirstDayOfWeek,
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update your preference about first day of week");
DB_BuildQuery ("UPDATE usr_data SET FirstDayOfWeek=%u"
" WHERE UsrCod=%ld",
Gbl.Prefs.FirstDayOfWeek,
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE_new ("can not update your preference about first day of week");
}
/***** Set preferences from current IP *****/

View File

@ -1869,13 +1869,10 @@ void Ctr_ContEditAfterChgCtrInConfig (void)
static void Ctr_UpdateCtrInsDB (long CtrCod,long InsCod)
{
char *Query;
/***** Update institution in table of centres *****/
if (asprintf (&Query,"UPDATE centres SET InsCod=%ld WHERE CtrCod=%ld",
InsCod,CtrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the institution of a centre");
DB_BuildQuery ("UPDATE centres SET InsCod=%ld WHERE CtrCod=%ld",
InsCod,CtrCod);
DB_QueryUPDATE_new ("can not update the institution of a centre");
}
/*****************************************************************************/
@ -1936,12 +1933,9 @@ void Ctr_ChangeCtrPlcInConfig (void)
static void Ctr_UpdateCtrPlcDB (long CtrCod,long NewPlcCod)
{
char *Query;
if (asprintf (&Query,"UPDATE centres SET PlcCod=%ld WHERE CtrCod=%ld",
NewPlcCod,CtrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the place of a centre");
DB_BuildQuery ("UPDATE centres SET PlcCod=%ld WHERE CtrCod=%ld",
NewPlcCod,CtrCod);
DB_QueryUPDATE_new ("can not update the place of a centre");
}
/*****************************************************************************/
@ -2078,13 +2072,10 @@ static bool Ctr_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Nam
static void Ctr_UpdateInsNameDB (long CtrCod,const char *FieldName,const char *NewCtrName)
{
char *Query;
/***** Update centre changing old name by new name */
if (asprintf (&Query,"UPDATE centres SET %s='%s' WHERE CtrCod=%ld",
FieldName,NewCtrName,CtrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the name of a centre");
DB_BuildQuery ("UPDATE centres SET %s='%s' WHERE CtrCod=%ld",
FieldName,NewCtrName,CtrCod);
DB_QueryUPDATE_new ("can not update the name of a centre");
}
/*****************************************************************************/
@ -2167,13 +2158,10 @@ void Ctr_ChangeCtrWWWInConfig (void)
static void Ctr_UpdateCtrWWWDB (long CtrCod,
const char NewWWW[Cns_MAX_BYTES_WWW + 1])
{
char *Query;
/***** Update database changing old WWW by new WWW *****/
if (asprintf (&Query,"UPDATE centres SET WWW='%s' WHERE CtrCod=%ld",
NewWWW,CtrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the web of a centre");
DB_BuildQuery ("UPDATE centres SET WWW='%s' WHERE CtrCod=%ld",
NewWWW,CtrCod);
DB_QueryUPDATE_new ("can not update the web of a centre");
}
/*****************************************************************************/
@ -2183,7 +2171,6 @@ static void Ctr_UpdateCtrWWWDB (long CtrCod,
void Ctr_ChangeCtrStatus (void)
{
extern const char *Txt_The_status_of_the_centre_X_has_changed;
char *Query;
Ctr_Status_t Status;
Ctr_StatusTxt_t StatusTxt;
@ -2205,10 +2192,9 @@ void Ctr_ChangeCtrStatus (void)
Ctr_GetDataOfCentreByCod (&Gbl.Ctrs.EditingCtr);
/***** Update status in table of centres *****/
if (asprintf (&Query,"UPDATE centres SET Status=%u WHERE CtrCod=%ld",
(unsigned) Status,Gbl.Ctrs.EditingCtr.CtrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the status of a centre");
DB_BuildQuery ("UPDATE centres SET Status=%u WHERE CtrCod=%ld",
(unsigned) Status,Gbl.Ctrs.EditingCtr.CtrCod);
DB_QueryUPDATE_new ("can not update the status of a centre");
Gbl.Ctrs.EditingCtr.Status = Status;
/***** Write message to show the change made
@ -2481,7 +2467,6 @@ void Ctr_ReceivePhoto (void)
void Ctr_ChangeCtrPhotoAttribution (void)
{
char *Query;
char NewPhotoAttribution[Img_MAX_BYTES_ATTRIBUTION + 1];
/***** Get parameters from form *****/
@ -2489,11 +2474,10 @@ void Ctr_ChangeCtrPhotoAttribution (void)
Par_GetParToText ("Attribution",NewPhotoAttribution,Img_MAX_BYTES_ATTRIBUTION);
/***** Update the table changing old attribution by new attribution *****/
if (asprintf (&Query,"UPDATE centres SET PhotoAttribution='%s'"
" WHERE CtrCod=%ld",
NewPhotoAttribution,Gbl.CurrentCtr.Ctr.CtrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the photo attribution of the current centre");
DB_BuildQuery ("UPDATE centres SET PhotoAttribution='%s'"
" WHERE CtrCod=%ld",
NewPhotoAttribution,Gbl.CurrentCtr.Ctr.CtrCod);
DB_QueryUPDATE_new ("can not update the photo attribution of the current centre");
/***** Show the centre information again *****/
Ctr_ShowConfiguration ();

View File

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

View File

@ -1861,13 +1861,10 @@ static bool Cty_CheckIfCountryNameExists (Txt_Language_t Language,const char *Na
static void Cty_UpdateCtyNameDB (long CtyCod,const char *FieldName,const char *NewCtyName)
{
char *Query;
/***** Update country changing old name by new name */
if (asprintf (&Query,"UPDATE countries SET %s='%s' WHERE CtyCod='%03ld'",
FieldName,NewCtyName,CtyCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the name of a country");
DB_BuildQuery ("UPDATE countries SET %s='%s' WHERE CtyCod='%03ld'",
FieldName,NewCtyName,CtyCod);
DB_QueryUPDATE_new ("can not update the name of a country");
/***** Flush cache *****/
Cty_FlushCacheCountryName ();
@ -1881,7 +1878,6 @@ void Cty_ChangeCtyWWW (void)
{
extern const char *Txt_The_new_web_address_is_X;
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
char *Query;
struct Country *Cty;
char NewWWW[Cns_MAX_BYTES_WWW + 1];
Txt_Language_t Language;
@ -1901,11 +1897,10 @@ void Cty_ChangeCtyWWW (void)
Cty_GetDataOfCountryByCod (Cty,Cty_GET_EXTRA_DATA);
/***** Update the table changing old WWW by new WWW *****/
if (asprintf (&Query,"UPDATE countries SET WWW_%s='%s'"
" WHERE CtyCod='%03ld'",
Txt_STR_LANG_ID[Language],NewWWW,Cty->CtyCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the web of a country");
DB_BuildQuery ("UPDATE countries SET WWW_%s='%s'"
" WHERE CtyCod='%03ld'",
Txt_STR_LANG_ID[Language],NewWWW,Cty->CtyCod);
DB_QueryUPDATE_new ("can not update the web of a country");
Str_Copy (Cty->WWW[Language],NewWWW,
Cns_MAX_BYTES_WWW);
@ -1925,7 +1920,6 @@ void Cty_ChangeCtyWWW (void)
void Cty_ChangeCtyMapAttribution (void)
{
char *Query;
char NewMapAttribution[Img_MAX_BYTES_ATTRIBUTION + 1];
/***** Get parameters from form *****/
@ -1933,11 +1927,10 @@ void Cty_ChangeCtyMapAttribution (void)
Par_GetParToText ("Attribution",NewMapAttribution,Img_MAX_BYTES_ATTRIBUTION);
/***** Update the table changing old attribution by new attribution *****/
if (asprintf (&Query,"UPDATE countries SET MapAttribution='%s'"
" WHERE CtyCod='%03ld'",
NewMapAttribution,Gbl.CurrentCty.Cty.CtyCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the map attribution of a country");
DB_BuildQuery ("UPDATE countries SET MapAttribution='%s'"
" WHERE CtyCod='%03ld'",
NewMapAttribution,Gbl.CurrentCty.Cty.CtyCod);
DB_QueryUPDATE_new ("can not update the map attribution of a country");
/***** Show the country information again *****/
Cty_ShowConfiguration ();

View File

@ -2179,11 +2179,10 @@ static void Crs_EmptyCourseCompletely (long CrsCod)
/***** Remove exam announcements in the course *****/
/* Mark all exam announcements in the course as deleted */
if (asprintf (&Query,"UPDATE exam_announcements SET Status=%u"
" WHERE CrsCod=%ld",
(unsigned) Exa_DELETED_EXAM_ANNOUNCEMENT,CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not remove exam announcements of a course");
DB_BuildQuery ("UPDATE exam_announcements SET Status=%u"
" WHERE CrsCod=%ld",
(unsigned) Exa_DELETED_EXAM_ANNOUNCEMENT,CrsCod);
DB_QueryUPDATE_new ("can not remove exam announcements of a course");
/***** Remove course cards of the course *****/
/* Remove content of course cards */
@ -2447,13 +2446,10 @@ void Crs_ContEditAfterChgCrsInConfig (void)
static void Crs_UpdateCrsDegDB (long CrsCod,long DegCod)
{
char *Query;
/***** Update degree in table of courses *****/
if (asprintf (&Query,"UPDATE courses SET DegCod=%ld WHERE CrsCod=%ld",
DegCod,CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not move course to another degree");
DB_BuildQuery ("UPDATE courses SET DegCod=%ld WHERE CrsCod=%ld",
DegCod,CrsCod);
DB_QueryUPDATE_new ("can not move course to another degree");
}
/*****************************************************************************/
@ -2596,13 +2592,10 @@ void Crs_ChangeCrsYear (void)
static void Crs_UpdateCrsYear (struct Course *Crs,unsigned NewYear)
{
char *Query;
/***** Update year/semester in table of courses *****/
if (asprintf (&Query,"UPDATE courses SET Year=%u WHERE CrsCod=%ld",
NewYear,Crs->CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the year of a course");
DB_BuildQuery ("UPDATE courses SET Year=%u WHERE CrsCod=%ld",
NewYear,Crs->CrsCod);
DB_QueryUPDATE_new ("can not update the year of a course");
/***** Copy course year/semester *****/
Crs->Year = NewYear;
@ -2777,13 +2770,10 @@ static bool Crs_CheckIfCrsNameExistsInYearOfDeg (const char *FieldName,const cha
static void Crs_UpdateCrsNameDB (long CrsCod,const char *FieldName,const char *NewCrsName)
{
char *Query;
/***** Update course changing old name by new name *****/
if (asprintf (&Query,"UPDATE courses SET %s='%s' WHERE CrsCod=%ld",
FieldName,NewCrsName,CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the name of a course");
DB_BuildQuery ("UPDATE courses SET %s='%s' WHERE CrsCod=%ld",
FieldName,NewCrsName,CrsCod);
DB_QueryUPDATE_new ("can not update the name of a course");
}
/*****************************************************************************/
@ -2793,7 +2783,6 @@ static void Crs_UpdateCrsNameDB (long CrsCod,const char *FieldName,const char *N
void Crs_ChangeCrsStatus (void)
{
extern const char *Txt_The_status_of_the_course_X_has_changed;
char *Query;
Crs_Status_t Status;
Crs_StatusTxt_t StatusTxt;
@ -2816,10 +2805,9 @@ void Crs_ChangeCrsStatus (void)
Crs_GetDataOfCourseByCod (&Gbl.Degs.EditingCrs);
/***** Update status in table of courses *****/
if (asprintf (&Query,"UPDATE courses SET Status=%u WHERE CrsCod=%ld",
(unsigned) Status,Gbl.Degs.EditingCrs.CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the status of a course");
DB_BuildQuery ("UPDATE courses SET Status=%u WHERE CrsCod=%ld",
(unsigned) Status,Gbl.Degs.EditingCrs.CrsCod);
DB_QueryUPDATE_new ("can not update the status of a course");
Gbl.Degs.EditingCrs.Status = Status;
/***** Create message to show the change made *****/
@ -3369,17 +3357,14 @@ static void Crs_WriteRowCrsData (unsigned NumCrs,MYSQL_ROW row,bool WriteColumnA
void Crs_UpdateCrsLast (void)
{
char *Query;
if (Gbl.CurrentCrs.Crs.CrsCod > 0 &&
Gbl.Usrs.Me.Role.Logged >= Rol_STD)
{
/***** Update my last access to current course *****/
if (asprintf (&Query,"REPLACE INTO crs_last (CrsCod,LastTime)"
" VALUES (%ld,NOW())",
Gbl.CurrentCrs.Crs.CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update last access to current course");
DB_BuildQuery ("REPLACE INTO crs_last (CrsCod,LastTime)"
" VALUES (%ld,NOW())",
Gbl.CurrentCrs.Crs.CrsCod);
DB_QueryUPDATE_new ("can not update last access to current course");
}
}

View File

@ -3269,17 +3269,6 @@ void DB_QueryREPLACE_new (const char *MsgError)
DB_ExitOnMySQLError (MsgError);
}
void DB_QueryREPLACE_free (const char *Query,const char *MsgError)
{
int Result;
/***** Query database *****/
Result = mysql_query (&Gbl.mysql,Query); // Returns 0 on success
free ((void *) Query);
if (Result)
DB_ExitOnMySQLError (MsgError);
}
void DB_QueryREPLACE (const char *Query,const char *MsgError)
{
/***** Query database *****/

View File

@ -52,7 +52,6 @@ long DB_QueryINSERTandReturnCode_new (const char *MsgError);
long DB_QueryINSERTandReturnCode (const char *Query,const char *MsgError);
void DB_QueryREPLACE_new (const char *MsgError);
void DB_QueryREPLACE_free (const char *Query,const char *MsgError);
void DB_QueryREPLACE (const char *Query,const char *MsgError);
void DB_QueryUPDATE_new (const char *MsgError);

View File

@ -179,20 +179,17 @@ void Dat_PutScriptDateFormat (Dat_Format_t Format)
void Dat_ChangeDateFormat (void)
{
char *Query;
/***** Get param with date format *****/
Gbl.Prefs.DateFormat = Dat_GetParamDateFormat ();
/***** Store date format in database *****/
if (Gbl.Usrs.Me.Logged)
{
if (asprintf (&Query,"UPDATE usr_data SET DateFormat=%u"
" WHERE UsrCod=%ld",
(unsigned) Gbl.Prefs.DateFormat,
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update your preference about date format");
DB_BuildQuery ("UPDATE usr_data SET DateFormat=%u"
" WHERE UsrCod=%ld",
(unsigned) Gbl.Prefs.DateFormat,
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE_new ("can not update your preference about date format");
}
/***** Set preferences from current IP *****/

View File

@ -2030,13 +2030,10 @@ static bool Deg_CheckIfDegNameExistsInCtr (const char *FieldName,const char *Nam
static void Deg_UpdateDegNameDB (long DegCod,const char *FieldName,const char *NewDegName)
{
char *Query;
/***** Update degree changing old name by new name *****/
if (asprintf (&Query,"UPDATE degrees SET %s='%s' WHERE DegCod=%ld",
FieldName,NewDegName,DegCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the name of a degree");
DB_BuildQuery ("UPDATE degrees SET %s='%s' WHERE DegCod=%ld",
FieldName,NewDegName,DegCod);
DB_QueryUPDATE_new ("can not update the name of a degree");
}
/*****************************************************************************/
@ -2112,13 +2109,10 @@ void Deg_ContEditAfterChgDegInConfig (void)
static void Deg_UpdateDegCtrDB (long DegCod,long CtrCod)
{
char *Query;
/***** Update centre in table of degrees *****/
if (asprintf (&Query,"UPDATE degrees SET CtrCod=%ld WHERE DegCod=%ld",
CtrCod,DegCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the centre of a degree");
DB_BuildQuery ("UPDATE degrees SET CtrCod=%ld WHERE DegCod=%ld",
CtrCod,DegCod);
DB_QueryUPDATE_new ("can not update the centre of a degree");
}
/*****************************************************************************/
@ -2201,13 +2195,10 @@ void Deg_ChangeDegWWWInConfig (void)
static void Deg_UpdateDegWWWDB (long DegCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1])
{
char *Query;
/***** Update database changing old WWW by new WWW *****/
if (asprintf (&Query,"UPDATE degrees SET WWW='%s' WHERE DegCod=%ld",
NewWWW,DegCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the web of a degree");
DB_BuildQuery ("UPDATE degrees SET WWW='%s' WHERE DegCod=%ld",
NewWWW,DegCod);
DB_QueryUPDATE_new ("can not update the web of a degree");
}
/*****************************************************************************/
@ -2217,7 +2208,6 @@ static void Deg_UpdateDegWWWDB (long DegCod,const char NewWWW[Cns_MAX_BYTES_WWW
void Deg_ChangeDegStatus (void)
{
extern const char *Txt_The_status_of_the_degree_X_has_changed;
char *Query;
Deg_Status_t Status;
Deg_StatusTxt_t StatusTxt;
@ -2240,10 +2230,9 @@ void Deg_ChangeDegStatus (void)
Deg_GetDataOfDegreeByCod (&Gbl.Degs.EditingDeg);
/***** Update status in table of degrees *****/
if (asprintf (&Query,"UPDATE degrees SET Status=%u WHERE DegCod=%ld",
(unsigned) Status,Gbl.Degs.EditingDeg.DegCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the status of a degree");
DB_BuildQuery ("UPDATE degrees SET Status=%u WHERE DegCod=%ld",
(unsigned) Status,Gbl.Degs.EditingDeg.DegCod);
DB_QueryUPDATE_new ("can not update the status of a degree");
Gbl.Degs.EditingDeg.Status = Status;

View File

@ -915,7 +915,6 @@ void DT_RenameDegreeType (void)
extern const char *Txt_The_type_of_degree_X_has_been_renamed_as_Y;
extern const char *Txt_The_name_of_the_type_of_degree_X_has_not_changed;
struct DegreeType *DegTyp;
char *Query;
char NewNameDegTyp[Deg_MAX_BYTES_DEGREE_TYPE_NAME + 1];
DegTyp = &Gbl.Degs.EditingDegTyp;
@ -955,11 +954,10 @@ void DT_RenameDegreeType (void)
else
{
/* Update the table changing old name by new name */
if (asprintf (&Query,"UPDATE deg_types SET DegTypName='%s'"
" WHERE DegTypCod=%ld",
NewNameDegTyp,DegTyp->DegTypCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the type of a degree");
DB_BuildQuery ("UPDATE deg_types SET DegTypName='%s'"
" WHERE DegTypCod=%ld",
NewNameDegTyp,DegTyp->DegTypCod);
DB_QueryUPDATE_new ("can not update the type of a degree");
/* Write message to show the change made */
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -1004,7 +1002,6 @@ void DT_ChangeDegreeType (void)
{
extern const char *Txt_The_type_of_degree_of_the_degree_X_has_changed;
long NewDegTypCod;
char *Query;
/***** Get parameters from form *****/
/* Get degree code */
@ -1017,10 +1014,9 @@ void DT_ChangeDegreeType (void)
Deg_GetDataOfDegreeByCod (&Gbl.Degs.EditingDeg);
/***** Update the table of degrees changing old type by new type *****/
if (asprintf (&Query,"UPDATE degrees SET DegTypCod=%ld WHERE DegCod=%ld",
NewDegTypCod,Gbl.Degs.EditingDeg.DegCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the type of a degree");
DB_BuildQuery ("UPDATE degrees SET DegTypCod=%ld WHERE DegCod=%ld",
NewDegTypCod,Gbl.Degs.EditingDeg.DegCod);
DB_QueryUPDATE_new ("can not update the type of a degree");
/***** Write message to show the change made
and put button to go to degree changed *****/

View File

@ -645,7 +645,6 @@ void Dpt_ChangeDepartIns (void)
{
extern const char *Txt_The_institution_of_the_department_has_changed;
struct Department *Dpt;
char *Query;
Dpt = &Gbl.Dpts.EditingDpt;
@ -657,10 +656,9 @@ void Dpt_ChangeDepartIns (void)
Dpt->InsCod = Ins_GetAndCheckParamOtherInsCod (1);
/***** Update institution in table of departments *****/
if (asprintf (&Query,"UPDATE departments SET InsCod=%ld WHERE DptCod=%ld",
Dpt->InsCod,Dpt->DptCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the institution of a department");
DB_BuildQuery ("UPDATE departments SET InsCod=%ld WHERE DptCod=%ld",
Dpt->InsCod,Dpt->DptCod);
DB_QueryUPDATE_new ("can not update the institution of a department");
/***** Write message to show the change made *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_The_institution_of_the_department_has_changed);
@ -799,13 +797,10 @@ static bool Dpt_CheckIfDepartmentNameExists (const char *FieldName,const char *N
static void Dpt_UpdateDegNameDB (long DptCod,const char *FieldName,const char *NewDptName)
{
char *Query;
/***** Update department changing old name by new name *****/
if (asprintf (&Query,"UPDATE departments SET %s='%s' WHERE DptCod=%ld",
FieldName,NewDptName,DptCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the name of a department");
DB_BuildQuery ("UPDATE departments SET %s='%s' WHERE DptCod=%ld",
FieldName,NewDptName,DptCod);
DB_QueryUPDATE_new ("can not update the name of a department");
}
/******************************************************************************/
@ -817,7 +812,6 @@ void Dpt_ChangeDptWWW (void)
extern const char *Txt_The_new_web_address_is_X;
extern const char *Txt_You_can_not_leave_the_web_address_empty;
struct Department *Dpt;
char *Query;
char NewWWW[Cns_MAX_BYTES_WWW + 1];
Dpt = &Gbl.Dpts.EditingDpt;
@ -833,10 +827,9 @@ void Dpt_ChangeDptWWW (void)
if (NewWWW[0])
{
/* Update the table changing old WWW by new WWW */
if (asprintf (&Query,"UPDATE departments SET WWW='%s' WHERE DptCod=%ld",
NewWWW,Dpt->DptCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the web of a department");
DB_BuildQuery ("UPDATE departments SET WWW='%s' WHERE DptCod=%ld",
NewWWW,Dpt->DptCod);
DB_QueryUPDATE_new ("can not update the web of a department");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),

View File

@ -209,8 +209,6 @@ void Enr_PutLinkToRequestSignUp (void)
void Enr_ModifyRoleInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole)
{
char *Query;
/***** Check if user's role is allowed *****/
switch (NewRole)
{
@ -223,11 +221,10 @@ void Enr_ModifyRoleInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole)
}
/***** Update the role of a user in a course *****/
if (asprintf (&Query,"UPDATE crs_usr SET Role=%u"
" WHERE CrsCod=%ld AND UsrCod=%ld",
(unsigned) NewRole,Gbl.CurrentCrs.Crs.CrsCod,UsrDat->UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not modify user's role in course");
DB_BuildQuery ("UPDATE crs_usr SET Role=%u"
" WHERE CrsCod=%ld AND UsrCod=%ld",
(unsigned) NewRole,Gbl.CurrentCrs.Crs.CrsCod,UsrDat->UsrCod);
DB_QueryUPDATE_new ("can not modify user's role in course");
/***** Flush caches *****/
Usr_FlushCachesUsr ();
@ -519,7 +516,6 @@ void Enr_UpdateUsrData (struct UsrData *UsrDat)
{
extern const char *Usr_StringsSexDB[Usr_NUM_SEXS];
char BirthdayStrDB[Usr_BIRTHDAY_STR_DB_LENGTH + 1];
char *Query;
/***** Check if user's code is initialized *****/
if (UsrDat->UsrCod <= 0)
@ -530,28 +526,27 @@ void Enr_UpdateUsrData (struct UsrData *UsrDat)
/***** Update user's common data *****/
Usr_CreateBirthdayStrDB (UsrDat,BirthdayStrDB); // It can include start and ending apostrophes
if (asprintf (&Query,"UPDATE usr_data"
" SET Password='%s',"
"Surname1='%s',Surname2='%s',FirstName='%s',Sex='%s',"
"CtyCod=%ld,"
"LocalAddress='%s',LocalPhone='%s',"
"FamilyAddress='%s',FamilyPhone='%s',"
"OriginPlace='%s',Birthday=%s,"
"Comments='%s'"
" WHERE UsrCod=%ld",
UsrDat->Password,
UsrDat->Surname1,UsrDat->Surname2,UsrDat->FirstName,
Usr_StringsSexDB[UsrDat->Sex],
UsrDat->CtyCod,
UsrDat->LocalAddress,UsrDat->LocalPhone,
UsrDat->FamilyAddress,UsrDat->FamilyPhone,
UsrDat->OriginPlace,
BirthdayStrDB,
UsrDat->Comments ? UsrDat->Comments :
"",
UsrDat->UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update user's data");
DB_BuildQuery ("UPDATE usr_data"
" SET Password='%s',"
"Surname1='%s',Surname2='%s',FirstName='%s',Sex='%s',"
"CtyCod=%ld,"
"LocalAddress='%s',LocalPhone='%s',"
"FamilyAddress='%s',FamilyPhone='%s',"
"OriginPlace='%s',Birthday=%s,"
"Comments='%s'"
" WHERE UsrCod=%ld",
UsrDat->Password,
UsrDat->Surname1,UsrDat->Surname2,UsrDat->FirstName,
Usr_StringsSexDB[UsrDat->Sex],
UsrDat->CtyCod,
UsrDat->LocalAddress,UsrDat->LocalPhone,
UsrDat->FamilyAddress,UsrDat->FamilyPhone,
UsrDat->OriginPlace,
BirthdayStrDB,
UsrDat->Comments ? UsrDat->Comments :
"",
UsrDat->UsrCod);
DB_QueryUPDATE_new ("can not update user's data");
}
/*****************************************************************************/
@ -574,18 +569,15 @@ void Enr_FilterUsrDat (struct UsrData *UsrDat)
void Enr_UpdateInstitutionCentreDepartment (void)
{
char *Query;
if (asprintf (&Query,"UPDATE usr_data"
" SET InsCtyCod=%ld,InsCod=%ld,CtrCod=%ld,DptCod=%ld"
" WHERE UsrCod=%ld",
Gbl.Usrs.Me.UsrDat.InsCtyCod,
Gbl.Usrs.Me.UsrDat.InsCod,
Gbl.Usrs.Me.UsrDat.Tch.CtrCod,
Gbl.Usrs.Me.UsrDat.Tch.DptCod,
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update institution, centre and department");
DB_BuildQuery ("UPDATE usr_data"
" SET InsCtyCod=%ld,InsCod=%ld,CtrCod=%ld,DptCod=%ld"
" WHERE UsrCod=%ld",
Gbl.Usrs.Me.UsrDat.InsCtyCod,
Gbl.Usrs.Me.UsrDat.InsCod,
Gbl.Usrs.Me.UsrDat.Tch.CtrCod,
Gbl.Usrs.Me.UsrDat.Tch.DptCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE_new ("can not update institution, centre and department");
}
/*****************************************************************************/
@ -3031,27 +3023,23 @@ static void Enr_RemoveEnrolmentRequest (long CrsCod,long UsrCod)
static void Enr_RemoveExpiredEnrolmentRequests (void)
{
char *Query;
/***** Mark possible notifications as removed
Important: do this before removing the request *****/
if (asprintf (&Query,"UPDATE notif,crs_usr_requests"
" SET notif.Status=(notif.Status | %u)"
" WHERE notif.NotifyEvent=%u"
" AND notif.Cod=crs_usr_requests.ReqCod"
" AND crs_usr_requests.RequestTime<FROM_UNIXTIME(UNIX_TIMESTAMP()-'%lu')",
(unsigned) Ntf_STATUS_BIT_REMOVED,
(unsigned) Ntf_EVENT_ENROLMENT_REQUEST,
Cfg_TIME_TO_DELETE_ENROLMENT_REQUESTS) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not set notification(s) as removed");
DB_BuildQuery ("UPDATE notif,crs_usr_requests"
" SET notif.Status=(notif.Status | %u)"
" WHERE notif.NotifyEvent=%u"
" AND notif.Cod=crs_usr_requests.ReqCod"
" AND crs_usr_requests.RequestTime<FROM_UNIXTIME(UNIX_TIMESTAMP()-'%lu')",
(unsigned) Ntf_STATUS_BIT_REMOVED,
(unsigned) Ntf_EVENT_ENROLMENT_REQUEST,
Cfg_TIME_TO_DELETE_ENROLMENT_REQUESTS);
DB_QueryUPDATE_new ("can not set notification(s) as removed");
/***** Remove expired requests for enrolment *****/
if (asprintf (&Query,"DELETE FROM crs_usr_requests"
" WHERE RequestTime<FROM_UNIXTIME(UNIX_TIMESTAMP()-'%lu')",
Cfg_TIME_TO_DELETE_ENROLMENT_REQUESTS) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryDELETE_free (Query,"can not remove expired requests for enrolment");
DB_BuildQuery ("DELETE FROM crs_usr_requests"
" WHERE RequestTime<FROM_UNIXTIME(UNIX_TIMESTAMP()-'%lu')",
Cfg_TIME_TO_DELETE_ENROLMENT_REQUESTS);
DB_QueryDELETE_new ("can not remove expired requests for enrolment");
}
/*****************************************************************************/
@ -4102,14 +4090,11 @@ void Enr_ModifyUsr2 (void)
void Enr_AcceptUsrInCrs (long UsrCod)
{
char *Query;
/***** Set enrolment of a user to "accepted" in the current course *****/
if (asprintf (&Query,"UPDATE crs_usr SET Accepted='Y'"
" WHERE CrsCod=%ld AND UsrCod=%ld",
Gbl.CurrentCrs.Crs.CrsCod,UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not confirm user's enrolment");
DB_BuildQuery ("UPDATE crs_usr SET Accepted='Y'"
" WHERE CrsCod=%ld AND UsrCod=%ld",
Gbl.CurrentCrs.Crs.CrsCod,UsrCod);
DB_QueryUPDATE_new ("can not confirm user's enrolment");
}
/*****************************************************************************/

View File

@ -318,14 +318,11 @@ void Exa_ReceiveExamAnnouncement2 (void)
static void Exa_UpdateNumUsrsNotifiedByEMailAboutExamAnnouncement (long ExaCod,unsigned NumUsrsToBeNotifiedByEMail)
{
char *Query;
/***** Update number of users notified *****/
if (asprintf (&Query,"UPDATE exam_announcements SET NumNotif=NumNotif+%u"
" WHERE ExaCod=%ld",
NumUsrsToBeNotifiedByEMail,ExaCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the number of notifications of an exam announcement");
DB_BuildQuery ("UPDATE exam_announcements SET NumNotif=NumNotif+%u"
" WHERE ExaCod=%ld",
NumUsrsToBeNotifiedByEMail,ExaCod);
DB_QueryUPDATE_new ("can not update the number of notifications of an exam announcement");
}
/*****************************************************************************/
@ -387,7 +384,6 @@ void Exa_ReqRemoveExamAnnouncement (void)
void Exa_RemoveExamAnnouncement1 (void)
{
char *Query;
long ExaCod;
/***** Get the code of the exam announcement *****/
@ -395,12 +391,11 @@ void Exa_RemoveExamAnnouncement1 (void)
Lay_ShowErrorAndExit ("Code of exam announcement is missing.");
/***** Mark the exam announcement as deleted in the database *****/
if (asprintf (&Query,"UPDATE exam_announcements SET Status=%u"
" WHERE ExaCod=%ld AND CrsCod=%ld",
(unsigned) Exa_DELETED_EXAM_ANNOUNCEMENT,
ExaCod,Gbl.CurrentCrs.Crs.CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not remove exam announcement");
DB_BuildQuery ("UPDATE exam_announcements SET Status=%u"
" WHERE ExaCod=%ld AND CrsCod=%ld",
(unsigned) Exa_DELETED_EXAM_ANNOUNCEMENT,
ExaCod,Gbl.CurrentCrs.Crs.CrsCod);
DB_QueryUPDATE_new ("can not remove exam announcement");
/***** Mark possible notifications as removed *****/
Ntf_MarkNotifAsRemoved (Ntf_EVENT_EXAM_ANNOUNCEMENT,ExaCod);
@ -431,7 +426,6 @@ void Exa_RemoveExamAnnouncement2 (void)
void Exa_HideExamAnnouncement1 (void)
{
char *Query;
long ExaCod;
/***** Get the code of the exam announcement *****/
@ -439,12 +433,11 @@ void Exa_HideExamAnnouncement1 (void)
Lay_ShowErrorAndExit ("Code of exam announcement is missing.");
/***** Mark the exam announcement as hidden in the database *****/
if (asprintf (&Query,"UPDATE exam_announcements SET Status=%u"
" WHERE ExaCod=%ld AND CrsCod=%ld",
(unsigned) Exa_HIDDEN_EXAM_ANNOUNCEMENT,
ExaCod,Gbl.CurrentCrs.Crs.CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not hide exam announcement");
DB_BuildQuery ("UPDATE exam_announcements SET Status=%u"
" WHERE ExaCod=%ld AND CrsCod=%ld",
(unsigned) Exa_HIDDEN_EXAM_ANNOUNCEMENT,
ExaCod,Gbl.CurrentCrs.Crs.CrsCod);
DB_QueryUPDATE_new ("can not hide exam announcement");
}
void Exa_HideExamAnnouncement2 (void)
@ -466,7 +459,6 @@ void Exa_HideExamAnnouncement2 (void)
void Exa_UnhideExamAnnouncement1 (void)
{
char *Query;
long ExaCod;
/***** Get the code of the exam announcement *****/
@ -474,12 +466,11 @@ void Exa_UnhideExamAnnouncement1 (void)
Lay_ShowErrorAndExit ("Code of exam announcement is missing.");
/***** Mark the exam announcement as visible in the database *****/
if (asprintf (&Query,"UPDATE exam_announcements SET Status=%u"
" WHERE ExaCod=%ld AND CrsCod=%ld",
(unsigned) Exa_VISIBLE_EXAM_ANNOUNCEMENT,
ExaCod,Gbl.CurrentCrs.Crs.CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not unhide exam announcement");
DB_BuildQuery ("UPDATE exam_announcements SET Status=%u"
" WHERE ExaCod=%ld AND CrsCod=%ld",
(unsigned) Exa_VISIBLE_EXAM_ANNOUNCEMENT,
ExaCod,Gbl.CurrentCrs.Crs.CrsCod);
DB_QueryUPDATE_new ("can not unhide exam announcement");
}
void Exa_UnhideExamAnnouncement2 (void)
@ -780,36 +771,33 @@ static long Exa_AddExamAnnouncementToDB (void)
static void Exa_ModifyExamAnnouncementInDB (void)
{
char *Query;
/***** Modify exam announcement *****/
if (asprintf (&Query,"UPDATE exam_announcements"
" SET CrsFullName='%s',Year=%u,ExamSession='%s',"
"ExamDate='%04u-%02u-%02u %02u:%02u:00',"
"Duration='%02u:%02u:00',"
"Place='%s',ExamMode='%s',Structure='%s',"
"DocRequired='%s',MatRequired='%s',MatAllowed='%s',OtherInfo='%s'"
" WHERE ExaCod=%ld",
Gbl.ExamAnns.ExaDat.CrsFullName,
Gbl.ExamAnns.ExaDat.Year,
Gbl.ExamAnns.ExaDat.Session,
Gbl.ExamAnns.ExaDat.ExamDate.Year,
Gbl.ExamAnns.ExaDat.ExamDate.Month,
Gbl.ExamAnns.ExaDat.ExamDate.Day,
Gbl.ExamAnns.ExaDat.StartTime.Hour,
Gbl.ExamAnns.ExaDat.StartTime.Minute,
Gbl.ExamAnns.ExaDat.Duration.Hour,
Gbl.ExamAnns.ExaDat.Duration.Minute,
Gbl.ExamAnns.ExaDat.Place,
Gbl.ExamAnns.ExaDat.Mode,
Gbl.ExamAnns.ExaDat.Structure,
Gbl.ExamAnns.ExaDat.DocRequired,
Gbl.ExamAnns.ExaDat.MatRequired,
Gbl.ExamAnns.ExaDat.MatAllowed,
Gbl.ExamAnns.ExaDat.OtherInfo,
Gbl.ExamAnns.ExaDat.ExaCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update an exam announcement");
DB_BuildQuery ("UPDATE exam_announcements"
" SET CrsFullName='%s',Year=%u,ExamSession='%s',"
"ExamDate='%04u-%02u-%02u %02u:%02u:00',"
"Duration='%02u:%02u:00',"
"Place='%s',ExamMode='%s',Structure='%s',"
"DocRequired='%s',MatRequired='%s',MatAllowed='%s',OtherInfo='%s'"
" WHERE ExaCod=%ld",
Gbl.ExamAnns.ExaDat.CrsFullName,
Gbl.ExamAnns.ExaDat.Year,
Gbl.ExamAnns.ExaDat.Session,
Gbl.ExamAnns.ExaDat.ExamDate.Year,
Gbl.ExamAnns.ExaDat.ExamDate.Month,
Gbl.ExamAnns.ExaDat.ExamDate.Day,
Gbl.ExamAnns.ExaDat.StartTime.Hour,
Gbl.ExamAnns.ExaDat.StartTime.Minute,
Gbl.ExamAnns.ExaDat.Duration.Hour,
Gbl.ExamAnns.ExaDat.Duration.Minute,
Gbl.ExamAnns.ExaDat.Place,
Gbl.ExamAnns.ExaDat.Mode,
Gbl.ExamAnns.ExaDat.Structure,
Gbl.ExamAnns.ExaDat.DocRequired,
Gbl.ExamAnns.ExaDat.MatRequired,
Gbl.ExamAnns.ExaDat.MatAllowed,
Gbl.ExamAnns.ExaDat.OtherInfo,
Gbl.ExamAnns.ExaDat.ExaCod);
DB_QueryUPDATE_new ("can not update an exam announcement");
}
/*****************************************************************************/

View File

@ -4255,15 +4255,12 @@ static void Brw_UpdateLastAccess (void)
static void Brw_UpdateGrpLastAccZone (const char *FieldNameDB,long GrpCod)
{
char *Query;
/***** Update the group of my last access to a common zone *****/
if (asprintf (&Query,"UPDATE crs_usr SET %s=%ld"
" WHERE CrsCod=%ld AND UsrCod=%ld",
FieldNameDB,GrpCod,
Gbl.CurrentCrs.Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the group of the last access to a file browser");
DB_BuildQuery ("UPDATE crs_usr SET %s=%ld"
" WHERE CrsCod=%ld AND UsrCod=%ld",
FieldNameDB,GrpCod,
Gbl.CurrentCrs.Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE_new ("can not update the group of the last access to a file browser");
}
/*****************************************************************************/
@ -7895,19 +7892,17 @@ static void Brw_UpdatePathInClipboard (void)
{
long Cod = Brw_GetCodForClipboard ();
long WorksUsrCod = Brw_GetWorksUsrCodForClipboard ();
char *Query;
/***** Update path in my clipboard *****/
if (asprintf (&Query,"UPDATE clipboard SET FileBrowser=%u,"
"Cod=%ld,WorksUsrCod=%ld,"
"FileType=%u,Path='%s'"
" WHERE UsrCod=%ld",
(unsigned) Gbl.FileBrowser.Type,
Cod,WorksUsrCod,
(unsigned) Gbl.FileBrowser.FileType,Gbl.FileBrowser.Priv.FullPathInTree,
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update source of copy in clipboard");
DB_BuildQuery ("UPDATE clipboard SET FileBrowser=%u,"
"Cod=%ld,WorksUsrCod=%ld,"
"FileType=%u,Path='%s'"
" WHERE UsrCod=%ld",
(unsigned) Gbl.FileBrowser.Type,
Cod,WorksUsrCod,
(unsigned) Gbl.FileBrowser.FileType,Gbl.FileBrowser.Priv.FullPathInTree,
Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE_new ("can not update source of copy in clipboard");
}
/*****************************************************************************/
@ -8048,43 +8043,33 @@ static void Brw_UpdateClickTimeOfThisFileBrowserInExpandedFolders (void)
{
long Cod = Brw_GetCodForExpandedFolders ();
long WorksUsrCod = Brw_GetWorksUsrCodForExpandedFolders ();
char *Query;
Brw_FileBrowser_t FileBrowserForExpandedFolders = Brw_FileBrowserForDB_expanded_folders[Gbl.FileBrowser.Type];
/***** Update click time in table of expanded folders *****/
if (Cod > 0)
{
if (WorksUsrCod > 0)
{
if (asprintf (&Query,"UPDATE expanded_folders SET ClickTime=NOW()"
" WHERE UsrCod=%ld AND FileBrowser=%u"
" AND Cod=%ld AND WorksUsrCod=%ld",
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) FileBrowserForExpandedFolders,
Cod,
WorksUsrCod) < 0)
Lay_NotEnoughMemoryExit ();
}
DB_BuildQuery ("UPDATE expanded_folders SET ClickTime=NOW()"
" WHERE UsrCod=%ld AND FileBrowser=%u"
" AND Cod=%ld AND WorksUsrCod=%ld",
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) FileBrowserForExpandedFolders,
Cod,
WorksUsrCod);
else
{
if (asprintf (&Query,"UPDATE expanded_folders SET ClickTime=NOW()"
" WHERE UsrCod=%ld AND FileBrowser=%u"
" AND Cod=%ld",
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) FileBrowserForExpandedFolders,
Cod) < 0)
Lay_NotEnoughMemoryExit ();
}
DB_BuildQuery ("UPDATE expanded_folders SET ClickTime=NOW()"
" WHERE UsrCod=%ld AND FileBrowser=%u"
" AND Cod=%ld",
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) FileBrowserForExpandedFolders,
Cod);
}
else // Briefcase
{
if (asprintf (&Query,"UPDATE expanded_folders SET ClickTime=NOW()"
" WHERE UsrCod=%ld AND FileBrowser=%u",
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) FileBrowserForExpandedFolders) < 0)
Lay_NotEnoughMemoryExit ();
}
DB_QueryUPDATE_free (Query,"can not update expanded folder");
DB_BuildQuery ("UPDATE expanded_folders SET ClickTime=NOW()"
" WHERE UsrCod=%ld AND FileBrowser=%u",
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) FileBrowserForExpandedFolders);
DB_QueryUPDATE_new ("can not update expanded folder");
}
/*****************************************************************************/
@ -8188,7 +8173,6 @@ static void Brw_RenameAffectedExpandedFolders (Brw_FileBrowser_t FileBrowser,
const char *OldPath,const char *NewPath)
{
long Cod = Brw_GetCodForExpandedFolders ();
char *Query;
Brw_FileBrowser_t FileBrowserForExpandedFolders = Brw_FileBrowserForDB_expanded_folders[FileBrowser];
unsigned StartFinalSubpathNotChanged = strlen (OldPath) + 2;
@ -8198,68 +8182,53 @@ static void Brw_RenameAffectedExpandedFolders (Brw_FileBrowser_t FileBrowser,
if (MyUsrCod > 0)
{
if (WorksUsrCod > 0)
{
if (asprintf (&Query,"UPDATE expanded_folders SET Path=CONCAT('%s','/',SUBSTRING(Path,%u))"
" WHERE UsrCod=%ld AND FileBrowser=%u"
" AND Cod=%ld AND WorksUsrCod=%ld"
" AND Path LIKE '%s/%%'",
NewPath,StartFinalSubpathNotChanged,
MyUsrCod,(unsigned) FileBrowserForExpandedFolders,
Cod,WorksUsrCod,
OldPath) < 0)
Lay_NotEnoughMemoryExit ();
}
DB_BuildQuery ("UPDATE expanded_folders SET Path=CONCAT('%s','/',SUBSTRING(Path,%u))"
" WHERE UsrCod=%ld AND FileBrowser=%u"
" AND Cod=%ld AND WorksUsrCod=%ld"
" AND Path LIKE '%s/%%'",
NewPath,StartFinalSubpathNotChanged,
MyUsrCod,(unsigned) FileBrowserForExpandedFolders,
Cod,WorksUsrCod,
OldPath);
else
{
if (asprintf (&Query,"UPDATE expanded_folders SET Path=CONCAT('%s','/',SUBSTRING(Path,%u))"
" WHERE UsrCod=%ld AND FileBrowser=%u"
" AND Cod=%ld"
" AND Path LIKE '%s/%%'",
NewPath,StartFinalSubpathNotChanged,
MyUsrCod,(unsigned) FileBrowserForExpandedFolders,
Cod,
OldPath) < 0)
Lay_NotEnoughMemoryExit ();
}
DB_BuildQuery ("UPDATE expanded_folders SET Path=CONCAT('%s','/',SUBSTRING(Path,%u))"
" WHERE UsrCod=%ld AND FileBrowser=%u"
" AND Cod=%ld"
" AND Path LIKE '%s/%%'",
NewPath,StartFinalSubpathNotChanged,
MyUsrCod,(unsigned) FileBrowserForExpandedFolders,
Cod,
OldPath);
}
else // MyUsrCod <= 0 means expanded folders for any user
{
if (WorksUsrCod > 0)
{
if (asprintf (&Query,"UPDATE expanded_folders SET Path=CONCAT('%s','/',SUBSTRING(Path,%u))"
" WHERE FileBrowser=%u AND Cod=%ld"
" AND WorksUsrCod=%ld"
" AND Path LIKE '%s/%%'",
NewPath,StartFinalSubpathNotChanged,
(unsigned) FileBrowserForExpandedFolders,Cod,
WorksUsrCod,
OldPath) < 0)
Lay_NotEnoughMemoryExit ();
}
DB_BuildQuery ("UPDATE expanded_folders SET Path=CONCAT('%s','/',SUBSTRING(Path,%u))"
" WHERE FileBrowser=%u AND Cod=%ld"
" AND WorksUsrCod=%ld"
" AND Path LIKE '%s/%%'",
NewPath,StartFinalSubpathNotChanged,
(unsigned) FileBrowserForExpandedFolders,Cod,
WorksUsrCod,
OldPath);
else
{
if (asprintf (&Query,"UPDATE expanded_folders SET Path=CONCAT('%s','/',SUBSTRING(Path,%u))"
" WHERE FileBrowser=%u AND Cod=%ld"
" AND Path LIKE '%s/%%'",
NewPath,StartFinalSubpathNotChanged,
(unsigned) FileBrowserForExpandedFolders,Cod,
OldPath) < 0)
Lay_NotEnoughMemoryExit ();
}
DB_BuildQuery ("UPDATE expanded_folders SET Path=CONCAT('%s','/',SUBSTRING(Path,%u))"
" WHERE FileBrowser=%u AND Cod=%ld"
" AND Path LIKE '%s/%%'",
NewPath,StartFinalSubpathNotChanged,
(unsigned) FileBrowserForExpandedFolders,Cod,
OldPath);
}
}
else // Briefcase
{
if (asprintf (&Query,"UPDATE expanded_folders SET Path=CONCAT('%s','/',SUBSTRING(Path,%u))"
" WHERE UsrCod=%ld AND FileBrowser=%u"
" AND Path LIKE '%s/%%'",
NewPath,StartFinalSubpathNotChanged,
MyUsrCod,
(unsigned) FileBrowserForExpandedFolders,
OldPath) < 0)
Lay_NotEnoughMemoryExit ();
}
DB_QueryUPDATE_free (Query,"can not update expanded folders");
DB_BuildQuery ("UPDATE expanded_folders SET Path=CONCAT('%s','/',SUBSTRING(Path,%u))"
" WHERE UsrCod=%ld AND FileBrowser=%u"
" AND Path LIKE '%s/%%'",
NewPath,StartFinalSubpathNotChanged,
MyUsrCod,
(unsigned) FileBrowserForExpandedFolders,
OldPath);
DB_QueryUPDATE_new ("can not update expanded folders");
}
/*****************************************************************************/
@ -11745,19 +11714,17 @@ static void Brw_ChangeFileOrFolderHiddenInDB (const char Path[PATH_MAX + 1],bool
{
long Cod = Brw_GetCodForFiles ();
long ZoneUsrCod = Brw_GetZoneUsrCodForFiles ();
char *Query;
/***** Mark file as hidden in database *****/
if (asprintf (&Query,"UPDATE files SET Hidden='%c'"
" WHERE FileBrowser=%u AND Cod=%ld AND ZoneUsrCod=%ld"
" AND Path='%s'",
IsHidden ? 'Y' :
'N',
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
Cod,ZoneUsrCod,
Path) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not change status of a file in database");
DB_BuildQuery ("UPDATE files SET Hidden='%c'"
" WHERE FileBrowser=%u AND Cod=%ld AND ZoneUsrCod=%ld"
" AND Path='%s'",
IsHidden ? 'Y' :
'N',
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
Cod,ZoneUsrCod,
Path);
DB_QueryUPDATE_new ("can not change status of a file in database");
}
/*****************************************************************************/
@ -11769,21 +11736,19 @@ static void Brw_ChangeFilePublicInDB (long PublisherUsrCod,const char *Path,
{
long Cod = Brw_GetCodForFiles ();
long ZoneUsrCod = Brw_GetZoneUsrCodForFiles ();
char *Query;
/***** Change publisher, public and license of file in database *****/
if (asprintf (&Query,"UPDATE files SET PublisherUsrCod=%ld,Public='%c',License=%u"
" WHERE FileBrowser=%u AND Cod=%ld AND ZoneUsrCod=%ld"
" AND Path='%s'",
PublisherUsrCod,
IsPublic ? 'Y' :
'N',
(unsigned) License,
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
Cod,ZoneUsrCod,
Path) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not change metadata of a file in database");
DB_BuildQuery ("UPDATE files SET PublisherUsrCod=%ld,Public='%c',License=%u"
" WHERE FileBrowser=%u AND Cod=%ld AND ZoneUsrCod=%ld"
" AND Path='%s'",
PublisherUsrCod,
IsPublic ? 'Y' :
'N',
(unsigned) License,
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
Cod,ZoneUsrCod,
Path);
DB_QueryUPDATE_new ("can not change metadata of a file in database");
}
/*****************************************************************************/
@ -12075,17 +12040,15 @@ static void Brw_RenameOneFolderInDB (const char OldPath[PATH_MAX + 1],
{
long Cod = Brw_GetCodForFiles ();
long ZoneUsrCod = Brw_GetZoneUsrCodForFiles ();
char *Query;
/***** Update file or folder in table of common files *****/
if (asprintf (&Query,"UPDATE files SET Path='%s'"
" WHERE FileBrowser=%u AND Cod=%ld AND ZoneUsrCod=%ld AND Path='%s'",
NewPath,
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
Cod,ZoneUsrCod,
OldPath) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update folder name in a common zone");
DB_BuildQuery ("UPDATE files SET Path='%s'"
" WHERE FileBrowser=%u AND Cod=%ld AND ZoneUsrCod=%ld AND Path='%s'",
NewPath,
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
Cod,ZoneUsrCod,
OldPath);
DB_QueryUPDATE_new ("can not update folder name in a common zone");
}
/*****************************************************************************/
@ -12097,19 +12060,17 @@ static void Brw_RenameChildrenFilesOrFoldersInDB (const char OldPath[PATH_MAX +
{
long Cod = Brw_GetCodForFiles ();
long ZoneUsrCod = Brw_GetZoneUsrCodForFiles ();
char *Query;
unsigned StartFinalSubpathNotChanged = strlen (OldPath) + 2;
/***** Update children of a folder in table of files *****/
if (asprintf (&Query,"UPDATE files SET Path=CONCAT('%s','/',SUBSTRING(Path,%u))"
" WHERE FileBrowser=%u AND Cod=%ld AND ZoneUsrCod=%ld"
" AND Path LIKE '%s/%%'",
NewPath,StartFinalSubpathNotChanged,
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
Cod,ZoneUsrCod,
OldPath) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not rename file or folder names in a common zone");
DB_BuildQuery ("UPDATE files SET Path=CONCAT('%s','/',SUBSTRING(Path,%u))"
" WHERE FileBrowser=%u AND Cod=%ld AND ZoneUsrCod=%ld"
" AND Path LIKE '%s/%%'",
NewPath,StartFinalSubpathNotChanged,
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
Cod,ZoneUsrCod,
OldPath);
DB_QueryUPDATE_new ("can not rename file or folder names in a common zone");
}
/*****************************************************************************/

View File

@ -729,14 +729,11 @@ void For_GetForumTypeAndLocationOfAPost (long PstCod,struct Forum *Forum)
static void For_UpdateThrFirstAndLastPst (long ThrCod,long FirstPstCod,long LastPstCod)
{
char *Query;
/***** Update the code of the first and last posts of a thread *****/
if (asprintf (&Query,"UPDATE forum_thread SET FirstPstCod=%ld,LastPstCod=%ld"
" WHERE ThrCod=%ld",
FirstPstCod,LastPstCod,ThrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update a thread of a forum");
DB_BuildQuery ("UPDATE forum_thread SET FirstPstCod=%ld,LastPstCod=%ld"
" WHERE ThrCod=%ld",
FirstPstCod,LastPstCod,ThrCod);
DB_QueryUPDATE_new ("can not update a thread of a forum");
}
/*****************************************************************************/
@ -745,14 +742,11 @@ static void For_UpdateThrFirstAndLastPst (long ThrCod,long FirstPstCod,long Last
static void For_UpdateThrLastPst (long ThrCod,long LastPstCod)
{
char *Query;
/***** Update the code of the last post of a thread *****/
if (asprintf (&Query,"UPDATE forum_thread SET LastPstCod=%ld"
" WHERE ThrCod=%ld",
LastPstCod,ThrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update a thread of a forum");
DB_BuildQuery ("UPDATE forum_thread SET LastPstCod=%ld"
" WHERE ThrCod=%ld",
LastPstCod,ThrCod);
DB_QueryUPDATE_new ("can not update a thread of a forum");
}
/*****************************************************************************/
@ -4027,14 +4021,11 @@ void For_ReceiveForumPost (void)
static void For_UpdateNumUsrsNotifiedByEMailAboutPost (long PstCod,unsigned NumUsrsToBeNotifiedByEMail)
{
char *Query;
/***** Update number of users notified *****/
if (asprintf (&Query,"UPDATE forum_post SET NumNotif=NumNotif+%u"
" WHERE PstCod=%ld",
NumUsrsToBeNotifiedByEMail,PstCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the number of notifications of a post");
DB_BuildQuery ("UPDATE forum_post SET NumNotif=NumNotif+%u"
" WHERE PstCod=%ld",
NumUsrsToBeNotifiedByEMail,PstCod);
DB_QueryUPDATE_new ("can not update the number of notifications of a post");
}
/*****************************************************************************/
@ -4368,8 +4359,6 @@ static bool For_CheckIfThrBelongsToForum (long ThrCod,struct Forum *Forum)
static void For_MoveThrToCurrentForum (long ThrCod)
{
char *Query;
/***** Move a thread to current forum *****/
switch (Gbl.Forum.ForumSelected.Type)
{
@ -4377,58 +4366,53 @@ static void For_MoveThrToCurrentForum (long ThrCod)
case For_FORUM_GLOBAL_TCHS:
case For_FORUM__SWAD__USRS:
case For_FORUM__SWAD__TCHS:
if (asprintf (&Query,"UPDATE forum_thread"
" SET ForumType=%u,Location=-1"
" WHERE ThrCod=%ld",
(unsigned) Gbl.Forum.ForumSelected.Type,
ThrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_BuildQuery ("UPDATE forum_thread"
" SET ForumType=%u,Location=-1"
" WHERE ThrCod=%ld",
(unsigned) Gbl.Forum.ForumSelected.Type,
ThrCod);
break;
case For_FORUM_INSTIT_USRS:
case For_FORUM_INSTIT_TCHS:
if (asprintf (&Query,"UPDATE forum_thread"
" SET ForumType=%u,Location=%ld"
" WHERE ThrCod=%ld",
(unsigned) Gbl.Forum.ForumSelected.Type,
Gbl.Forum.ForumSelected.Location,
ThrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_BuildQuery ("UPDATE forum_thread"
" SET ForumType=%u,Location=%ld"
" WHERE ThrCod=%ld",
(unsigned) Gbl.Forum.ForumSelected.Type,
Gbl.Forum.ForumSelected.Location,
ThrCod);
break;
case For_FORUM_CENTRE_USRS:
case For_FORUM_CENTRE_TCHS:
if (asprintf (&Query,"UPDATE forum_thread"
" SET ForumType=%u,Location=%ld"
" WHERE ThrCod=%ld",
(unsigned) Gbl.Forum.ForumSelected.Type,
Gbl.Forum.ForumSelected.Location,
ThrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_BuildQuery ("UPDATE forum_thread"
" SET ForumType=%u,Location=%ld"
" WHERE ThrCod=%ld",
(unsigned) Gbl.Forum.ForumSelected.Type,
Gbl.Forum.ForumSelected.Location,
ThrCod);
break;
case For_FORUM_DEGREE_USRS:
case For_FORUM_DEGREE_TCHS:
if (asprintf (&Query,"UPDATE forum_thread"
" SET ForumType=%u,Location=%ld"
" WHERE ThrCod=%ld",
(unsigned) Gbl.Forum.ForumSelected.Type,
Gbl.Forum.ForumSelected.Location,
ThrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_BuildQuery ("UPDATE forum_thread"
" SET ForumType=%u,Location=%ld"
" WHERE ThrCod=%ld",
(unsigned) Gbl.Forum.ForumSelected.Type,
Gbl.Forum.ForumSelected.Location,
ThrCod);
break;
case For_FORUM_COURSE_USRS:
case For_FORUM_COURSE_TCHS:
if (asprintf (&Query,"UPDATE forum_thread"
" SET ForumType=%u,Location=%ld"
" WHERE ThrCod=%ld",
(unsigned) Gbl.Forum.ForumSelected.Type,
Gbl.Forum.ForumSelected.Location,
ThrCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_BuildQuery ("UPDATE forum_thread"
" SET ForumType=%u,Location=%ld"
" WHERE ThrCod=%ld",
(unsigned) Gbl.Forum.ForumSelected.Type,
Gbl.Forum.ForumSelected.Location,
ThrCod);
break;
default:
Lay_ShowErrorAndExit ("Wrong forum.");
break;
}
DB_QueryUPDATE_free (Query,"can not move a thread to current forum");
DB_QueryUPDATE_new ("can not move a thread to current forum");
}
/*****************************************************************************/

View File

@ -1633,12 +1633,11 @@ void Gam_ResetGame (void)
DB_QueryDELETE_free (Query,"can not remove users who are answered a game");
/***** Reset all the answers in this game *****/
if (asprintf (&Query,"UPDATE gam_answers,gam_questions SET gam_answers.NumUsrs=0"
" WHERE gam_questions.GamCod=%ld"
" AND gam_questions.QstCod=gam_answers.QstCod",
Game.GamCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not reset answers of a game");
DB_BuildQuery ("UPDATE gam_answers,gam_questions SET gam_answers.NumUsrs=0"
" WHERE gam_questions.GamCod=%ld"
" AND gam_questions.QstCod=gam_answers.QstCod",
Game.GamCod);
DB_QueryUPDATE_new ("can not reset answers of a game");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -1657,7 +1656,6 @@ void Gam_ResetGame (void)
void Gam_HideGame (void)
{
extern const char *Txt_Game_X_is_now_hidden;
char *Query;
struct Game Game;
/***** Get game code *****/
@ -1670,10 +1668,8 @@ void Gam_HideGame (void)
Lay_ShowErrorAndExit ("You can not hide this game.");
/***** Hide game *****/
if (asprintf (&Query,"UPDATE games SET Hidden='Y' WHERE GamCod=%ld",
Game.GamCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not hide game");
DB_BuildQuery ("UPDATE games SET Hidden='Y' WHERE GamCod=%ld",Game.GamCod);
DB_QueryUPDATE_new ("can not hide game");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -1692,7 +1688,6 @@ void Gam_HideGame (void)
void Gam_UnhideGame (void)
{
extern const char *Txt_Game_X_is_now_visible;
char *Query;
struct Game Game;
/***** Get game code *****/
@ -1705,10 +1700,8 @@ void Gam_UnhideGame (void)
Lay_ShowErrorAndExit ("You can not unhide this game.");
/***** Show game *****/
if (asprintf (&Query,"UPDATE games SET Hidden='N' WHERE GamCod=%ld",
Game.GamCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not show game");
DB_BuildQuery ("UPDATE games SET Hidden='N' WHERE GamCod=%ld",Game.GamCod);
DB_QueryUPDATE_new ("can not show game");
/***** Write message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -2231,24 +2224,22 @@ static void Gam_UpdateGame (struct Game *Game,const char *Txt)
{
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
extern const char *Txt_The_game_has_been_modified;
char *Query;
/***** Update the data of the game *****/
if (asprintf (&Query,"UPDATE games"
" SET Scope='%s',Cod=%ld,Roles=%u,"
"StartTime=FROM_UNIXTIME(%ld),"
"EndTime=FROM_UNIXTIME(%ld),"
"Title='%s',Txt='%s'"
" WHERE GamCod=%ld",
Sco_ScopeDB[Game->Scope],Game->Cod,
Game->Roles,
Game->TimeUTC[Gam_START_TIME],
Game->TimeUTC[Gam_END_TIME ],
Game->Title,
Txt,
Game->GamCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update game");
DB_BuildQuery ("UPDATE games"
" SET Scope='%s',Cod=%ld,Roles=%u,"
"StartTime=FROM_UNIXTIME(%ld),"
"EndTime=FROM_UNIXTIME(%ld),"
"Title='%s',Txt='%s'"
" WHERE GamCod=%ld",
Sco_ScopeDB[Game->Scope],Game->Cod,
Game->Roles,
Game->TimeUTC[Gam_START_TIME],
Game->TimeUTC[Gam_END_TIME ],
Game->Title,
Txt,
Game->GamCod);
DB_QueryUPDATE_new ("can not update game");
/***** Update groups *****/
/* Remove old groups */
@ -3296,7 +3287,6 @@ void Gam_RequestRemoveQst (void)
void Gam_RemoveQst (void)
{
extern const char *Txt_Question_removed;
char *Query;
struct Game Game;
long QstCod;
unsigned QstInd;
@ -3318,19 +3308,16 @@ void Gam_RemoveQst (void)
Gam_RemAnswersOfAQuestion (QstCod);
/* Remove the question itself */
if (asprintf (&Query,"DELETE FROM gam_questions WHERE QstCod=%ld",
QstCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryDELETE_free (Query,"can not remove a question");
DB_BuildQuery ("DELETE FROM gam_questions WHERE QstCod=%ld",QstCod);
DB_QueryDELETE_new ("can not remove a question");
if (!mysql_affected_rows (&Gbl.mysql))
Lay_ShowErrorAndExit ("The question to be removed does not exist.");
/* Change index of questions greater than this */
if (asprintf (&Query,"UPDATE gam_questions SET QstInd=QstInd-1"
" WHERE GamCod=%ld AND QstInd>%u",
Game.GamCod,QstInd) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update indexes of questions");
DB_BuildQuery ("UPDATE gam_questions SET QstInd=QstInd-1"
" WHERE GamCod=%ld AND QstInd>%u",
Game.GamCod,QstInd);
DB_QueryUPDATE_new ("can not update indexes of questions");
/***** Write message *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_Question_removed);
@ -3475,18 +3462,17 @@ static void Gam_ExchangeQuestions (long GamCod,
| 2 | 232 | | 2 | 232 | | 2 | 232 |
+--------+--------+ +--------+--------+ +--------+--------+
*/
if (asprintf (&Query,"UPDATE gam_questions SET QstInd=%u"
" WHERE GamCod=%ld AND QstCod=%ld",
QstIndBottom,
GamCod,QstCodTop) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not exchange indexes of questions");
if (asprintf (&Query,"UPDATE gam_questions SET QstInd=%u"
" WHERE GamCod=%ld AND QstCod=%ld",
QstIndTop,
GamCod,QstCodBottom) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not exchange indexes of questions");
DB_BuildQuery ("UPDATE gam_questions SET QstInd=%u"
" WHERE GamCod=%ld AND QstCod=%ld",
QstIndBottom,
GamCod,QstCodTop);
DB_QueryUPDATE_new ("can not exchange indexes of questions");
DB_BuildQuery ("UPDATE gam_questions SET QstInd=%u"
" WHERE GamCod=%ld AND QstCod=%ld",
QstIndTop,
GamCod,QstCodBottom);
DB_QueryUPDATE_new ("can not exchange indexes of questions");
/***** Unlock table *****/
Gbl.DB.LockedTables = false; // Set to false before the following unlock...

View File

@ -2799,7 +2799,6 @@ void Grp_GetListGrpTypesInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
void Grp_OpenGroupsAutomatically (void)
{
char *Query;
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned NumGrpTypes;
@ -2824,18 +2823,16 @@ void Grp_OpenGroupsAutomatically (void)
{
/***** Open all the closed groups in this course the must be opened
and with open time in the past ****/
if (asprintf (&Query,"UPDATE crs_grp SET Open='Y'"
" WHERE GrpTypCod=%ld AND Open='N'",
GrpTypCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not open groups");
DB_BuildQuery ("UPDATE crs_grp SET Open='Y'"
" WHERE GrpTypCod=%ld AND Open='N'",
GrpTypCod);
DB_QueryUPDATE_new ("can not open groups");
/***** To not try to open groups again, set MustBeOpened to false *****/
if (asprintf (&Query,"UPDATE crs_grp_types SET MustBeOpened='N'"
" WHERE GrpTypCod=%ld",
GrpTypCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the opening of a type of group");
DB_BuildQuery ("UPDATE crs_grp_types SET MustBeOpened='N'"
" WHERE GrpTypCod=%ld",
GrpTypCod);
DB_QueryUPDATE_new ("can not update the opening of a type of group");
}
}
@ -4039,12 +4036,11 @@ static void Grp_RemoveGroupTypeCompletely (void)
Svy_RemoveGroupsOfType (Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod);
/***** Change all groups of this type in course timetable *****/
if (asprintf (&Query,"UPDATE timetable_crs SET GrpCod=-1"
" WHERE GrpCod IN"
" (SELECT GrpCod FROM crs_grp WHERE GrpTypCod=%ld)",
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update all groups of a type in course timetable");
DB_BuildQuery ("UPDATE timetable_crs SET GrpCod=-1"
" WHERE GrpCod IN"
" (SELECT GrpCod FROM crs_grp WHERE GrpTypCod=%ld)",
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod);
DB_QueryUPDATE_new ("can not update all groups of a type in course timetable");
/***** Remove all the students in groups of this type *****/
if (asprintf (&Query,"DELETE FROM crs_grp_usr WHERE GrpCod IN"
@ -4102,10 +4098,9 @@ static void Grp_RemoveGroupCompletely (void)
Svy_RemoveGroup (GrpDat.GrpCod);
/***** Change this group in course timetable *****/
if (asprintf (&Query,"UPDATE timetable_crs SET GrpCod=-1 WHERE GrpCod=%ld",
Gbl.CurrentCrs.Grps.GrpCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update a group in course timetable");
DB_BuildQuery ("UPDATE timetable_crs SET GrpCod=-1 WHERE GrpCod=%ld",
Gbl.CurrentCrs.Grps.GrpCod);
DB_QueryUPDATE_new ("can not update a group in course timetable");
/***** Remove all the students in this group *****/
if (asprintf (&Query,"DELETE FROM crs_grp_usr WHERE GrpCod=%ld",
@ -4137,7 +4132,6 @@ void Grp_OpenGroup (void)
{
extern const char *Txt_The_group_X_is_now_open;
struct GroupData GrpDat;
char *Query;
/***** Get group code *****/
if ((Gbl.CurrentCrs.Grps.GrpCod = Grp_GetParamGrpCod ()) == -1)
@ -4148,10 +4142,9 @@ void Grp_OpenGroup (void)
Grp_GetDataOfGroupByCod (&GrpDat);
/***** Update the table of groups changing open/close status *****/
if (asprintf (&Query,"UPDATE crs_grp SET Open='Y' WHERE GrpCod=%ld",
Gbl.CurrentCrs.Grps.GrpCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not open a group");
DB_BuildQuery ("UPDATE crs_grp SET Open='Y' WHERE GrpCod=%ld",
Gbl.CurrentCrs.Grps.GrpCod);
DB_QueryUPDATE_new ("can not open a group");
/***** Create message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -4172,7 +4165,6 @@ void Grp_CloseGroup (void)
{
extern const char *Txt_The_group_X_is_now_closed;
struct GroupData GrpDat;
char *Query;
/***** Get group code *****/
if ((Gbl.CurrentCrs.Grps.GrpCod = Grp_GetParamGrpCod ()) == -1)
@ -4183,10 +4175,9 @@ void Grp_CloseGroup (void)
Grp_GetDataOfGroupByCod (&GrpDat);
/***** Update the table of groups changing open/close status *****/
if (asprintf (&Query,"UPDATE crs_grp SET Open='N' WHERE GrpCod=%ld",
Gbl.CurrentCrs.Grps.GrpCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not close a group");
DB_BuildQuery ("UPDATE crs_grp SET Open='N' WHERE GrpCod=%ld",
Gbl.CurrentCrs.Grps.GrpCod);
DB_QueryUPDATE_new ("can not close a group");
/***** Create message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -4207,7 +4198,6 @@ void Grp_EnableFileZonesGrp (void)
{
extern const char *Txt_File_zones_of_the_group_X_are_now_enabled;
struct GroupData GrpDat;
char *Query;
/***** Get group code *****/
if ((Gbl.CurrentCrs.Grps.GrpCod = Grp_GetParamGrpCod ()) == -1)
@ -4218,10 +4208,9 @@ void Grp_EnableFileZonesGrp (void)
Grp_GetDataOfGroupByCod (&GrpDat);
/***** Update the table of groups changing file zones status *****/
if (asprintf (&Query,"UPDATE crs_grp SET FileZones='Y' WHERE GrpCod=%ld",
Gbl.CurrentCrs.Grps.GrpCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not enable file zones of a group");
DB_BuildQuery ("UPDATE crs_grp SET FileZones='Y' WHERE GrpCod=%ld",
Gbl.CurrentCrs.Grps.GrpCod);
DB_QueryUPDATE_new ("can not enable file zones of a group");
/***** Create message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -4242,7 +4231,6 @@ void Grp_DisableFileZonesGrp (void)
{
extern const char *Txt_File_zones_of_the_group_X_are_now_disabled;
struct GroupData GrpDat;
char *Query;
/***** Get group code *****/
if ((Gbl.CurrentCrs.Grps.GrpCod = Grp_GetParamGrpCod ()) == -1)
@ -4253,10 +4241,9 @@ void Grp_DisableFileZonesGrp (void)
Grp_GetDataOfGroupByCod (&GrpDat);
/***** Update the table of groups changing file zones status *****/
if (asprintf (&Query,"UPDATE crs_grp SET FileZones='N' WHERE GrpCod=%ld",
Gbl.CurrentCrs.Grps.GrpCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not disable file zones of a group");
DB_BuildQuery ("UPDATE crs_grp SET FileZones='N' WHERE GrpCod=%ld",
Gbl.CurrentCrs.Grps.GrpCod);
DB_QueryUPDATE_new ("can not disable file zones of a group");
/***** Create message to show the change made *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
@ -4279,7 +4266,6 @@ void Grp_ChangeGroupType (void)
extern const char *Txt_The_type_of_group_of_the_group_X_has_changed;
long NewGrpTypCod;
struct GroupData GrpDat;
char *Query;
Ale_AlertType_t AlertType;
/***** Get parameters from form *****/
@ -4306,10 +4292,9 @@ void Grp_ChangeGroupType (void)
else // Group is not in database
{
/* Update the table of groups changing old type by new type */
if (asprintf (&Query,"UPDATE crs_grp SET GrpTypCod=%ld WHERE GrpCod=%ld",
NewGrpTypCod,Gbl.CurrentCrs.Grps.GrpCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the type of a group");
DB_BuildQuery ("UPDATE crs_grp SET GrpTypCod=%ld WHERE GrpCod=%ld",
NewGrpTypCod,Gbl.CurrentCrs.Grps.GrpCod);
DB_QueryUPDATE_new ("can not update the type of a group");
/* Create message to show the change made */
AlertType = Ale_SUCCESS;
@ -4333,7 +4318,6 @@ void Grp_ChangeMandatGrpTyp (void)
extern const char *Txt_The_type_of_enrolment_of_the_type_of_group_X_has_not_changed;
extern const char *Txt_The_enrolment_of_students_into_groups_of_type_X_is_now_mandatory;
extern const char *Txt_The_enrolment_of_students_into_groups_of_type_X_is_now_voluntary;
char *Query;
bool NewMandatoryEnrolment;
Ale_AlertType_t AlertType;
@ -4360,12 +4344,11 @@ void Grp_ChangeMandatGrpTyp (void)
else
{
/***** Update of the table of types of group changing the old type of enrolment by the new *****/
if (asprintf (&Query,"UPDATE crs_grp_types SET Mandatory='%c' WHERE GrpTypCod=%ld",
NewMandatoryEnrolment ? 'Y' :
'N',
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update enrolment type of a type of group");
DB_BuildQuery ("UPDATE crs_grp_types SET Mandatory='%c' WHERE GrpTypCod=%ld",
NewMandatoryEnrolment ? 'Y' :
'N',
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod);
DB_QueryUPDATE_new ("can not update enrolment type of a type of group");
/***** Write message to show the change made *****/
AlertType = Ale_SUCCESS;
@ -4390,7 +4373,6 @@ void Grp_ChangeMultiGrpTyp (void)
extern const char *Txt_The_type_of_enrolment_of_the_type_of_group_X_has_not_changed;
extern const char *Txt_Now_each_student_can_belong_to_multiple_groups_of_type_X;
extern const char *Txt_Now_each_student_can_only_belong_to_a_group_of_type_X;
char *Query;
bool NewMultipleEnrolment;
Ale_AlertType_t AlertType;
@ -4417,13 +4399,12 @@ void Grp_ChangeMultiGrpTyp (void)
else
{
/***** Update of the table of types of group changing the old type of enrolment by the new *****/
if (asprintf (&Query,"UPDATE crs_grp_types SET Multiple='%c'"
" WHERE GrpTypCod=%ld",
NewMultipleEnrolment ? 'Y' :
'N',
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update enrolment type of a type of group");
DB_BuildQuery ("UPDATE crs_grp_types SET Multiple='%c'"
" WHERE GrpTypCod=%ld",
NewMultipleEnrolment ? 'Y' :
'N',
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod);
DB_QueryUPDATE_new ("can not update enrolment type of a type of group");
/***** Write message to show the change made *****/
AlertType = Ale_SUCCESS;
@ -4446,7 +4427,6 @@ void Grp_ChangeMultiGrpTyp (void)
void Grp_ChangeOpenTimeGrpTyp (void)
{
extern const char *Txt_The_date_time_of_opening_of_groups_has_changed;
char *Query;
/***** Get the code of type of group *****/
if ((Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) < 0)
@ -4461,15 +4441,14 @@ void Grp_ChangeOpenTimeGrpTyp (void)
/***** Update the table of types of group
changing the old open time of enrolment by the new *****/
if (asprintf (&Query,"UPDATE crs_grp_types"
" SET MustBeOpened='%c',OpenTime=FROM_UNIXTIME(%ld)"
" WHERE GrpTypCod=%ld",
Gbl.CurrentCrs.Grps.GrpTyp.MustBeOpened ? 'Y' :
'N',
(long) Gbl.CurrentCrs.Grps.GrpTyp.OpenTimeUTC,
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update enrolment type of a type of group");
DB_BuildQuery ("UPDATE crs_grp_types"
" SET MustBeOpened='%c',OpenTime=FROM_UNIXTIME(%ld)"
" WHERE GrpTypCod=%ld",
Gbl.CurrentCrs.Grps.GrpTyp.MustBeOpened ? 'Y' :
'N',
(long) Gbl.CurrentCrs.Grps.GrpTyp.OpenTimeUTC,
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod);
DB_QueryUPDATE_new ("can not update enrolment type of a type of group");
/***** Write message to show the change made *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_The_date_time_of_opening_of_groups_has_changed);
@ -4489,7 +4468,6 @@ void Grp_ChangeMaxStdsGrp (void)
extern const char *Txt_The_group_X_now_has_no_limit_of_students;
extern const char *Txt_The_maximum_number_of_students_in_the_group_X_is_now_Y;
struct GroupData GrpDat;
char *Query;
unsigned NewMaxStds;
Ale_AlertType_t AlertType;
@ -4520,10 +4498,9 @@ void Grp_ChangeMaxStdsGrp (void)
else
{
/***** Update the table of groups changing the old maximum of students to the new *****/
if (asprintf (&Query,"UPDATE crs_grp SET MaxStudents=%u WHERE GrpCod=%ld",
NewMaxStds,Gbl.CurrentCrs.Grps.GrpCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the maximum number of students in a group");
DB_BuildQuery ("UPDATE crs_grp SET MaxStudents=%u WHERE GrpCod=%ld",
NewMaxStds,Gbl.CurrentCrs.Grps.GrpCod);
DB_QueryUPDATE_new ("can not update the maximum number of students in a group");
/***** Write message to show the change made *****/
AlertType = Ale_SUCCESS;
@ -4578,7 +4555,6 @@ void Grp_RenameGroupType (void)
extern const char *Txt_The_type_of_group_X_already_exists;
extern const char *Txt_The_type_of_group_X_has_been_renamed_as_Y;
extern const char *Txt_The_name_of_the_type_of_group_X_has_not_changed;
char *Query;
char NewNameGrpTyp[Grp_MAX_BYTES_GROUP_TYPE_NAME + 1];
Ale_AlertType_t AlertType;
@ -4617,12 +4593,11 @@ void Grp_RenameGroupType (void)
else
{
/* Update the table changing old name by new name */
if (asprintf (&Query,"UPDATE crs_grp_types SET GrpTypName='%s'"
" WHERE GrpTypCod=%ld",
NewNameGrpTyp,
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the type of a group");
DB_BuildQuery ("UPDATE crs_grp_types SET GrpTypName='%s'"
" WHERE GrpTypCod=%ld",
NewNameGrpTyp,
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod);
DB_QueryUPDATE_new ("can not update the type of a group");
/***** Write message to show the change made *****/
AlertType = Ale_SUCCESS;
@ -4658,7 +4633,6 @@ void Grp_RenameGroup (void)
extern const char *Txt_The_group_X_has_been_renamed_as_Y;
extern const char *Txt_The_name_of_the_group_X_has_not_changed;
struct GroupData GrpDat;
char *Query;
char NewNameGrp[Grp_MAX_BYTES_GROUP_NAME + 1];
Ale_AlertType_t AlertType;
@ -4698,10 +4672,9 @@ void Grp_RenameGroup (void)
else
{
/* Update the table changing old name by new name */
if (asprintf (&Query,"UPDATE crs_grp SET GrpName='%s' WHERE GrpCod=%ld",
NewNameGrp,Gbl.CurrentCrs.Grps.GrpCod) < 0)
Lay_NotEnoughMemoryExit ();
DB_QueryUPDATE_free (Query,"can not update the name of a group");
DB_BuildQuery ("UPDATE crs_grp SET GrpName='%s' WHERE GrpCod=%ld",
NewNameGrp,Gbl.CurrentCrs.Grps.GrpCod);
DB_QueryUPDATE_new ("can not update the name of a group");
/***** Write message to show the change made *****/
AlertType = Ale_SUCCESS;