From 9d7b46ffc32a70abc4018321a44fa53fa9e66827 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Sun, 28 Oct 2018 21:10:00 +0100 Subject: [PATCH] Version 18.8.16 --- swad_banner.c | 6 +- swad_centre.c | 7 +- swad_changelog.h | 3 +- swad_connected.c | 9 +- swad_country.c | 7 +- swad_course.c | 96 ++- swad_degree.c | 14 +- swad_degree_type.c | 7 +- swad_department.c | 7 +- swad_duplicate.c | 8 +- swad_enrolment.c | 30 +- swad_file_browser.c | 1402 ++++++++++++++++++++----------------------- 12 files changed, 710 insertions(+), 886 deletions(-) diff --git a/swad_banner.c b/swad_banner.c index c72174d2b..320db16da 100644 --- a/swad_banner.c +++ b/swad_banner.c @@ -510,7 +510,6 @@ long Ban_GetParamBanCod (void) void Ban_RemoveBanner (void) { extern const char *Txt_Banner_X_removed; - char *Query; struct Banner Ban; /***** Get banner code *****/ @@ -521,9 +520,8 @@ void Ban_RemoveBanner (void) Ban_GetDataOfBannerByCod (&Ban); /***** Remove banner *****/ - if (asprintf (&Query,"DELETE FROM banners WHERE BanCod=%ld",Ban.BanCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove a banner"); + DB_BuildQuery ("DELETE FROM banners WHERE BanCod=%ld",Ban.BanCod); + DB_QueryDELETE_new ("can not remove a banner"); /***** Write message to show the change made *****/ snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), diff --git a/swad_centre.c b/swad_centre.c index fb2fdef78..5a4859a22 100644 --- a/swad_centre.c +++ b/swad_centre.c @@ -1740,7 +1740,6 @@ void Ctr_RemoveCentre (void) { extern const char *Txt_To_remove_a_centre_you_must_first_remove_all_degrees_and_teachers_in_the_centre; extern const char *Txt_Centre_X_removed; - char *Query; struct Centre Ctr; char PathCtr[PATH_MAX + 1]; @@ -1775,10 +1774,8 @@ void Ctr_RemoveCentre (void) Fil_RemoveTree (PathCtr); /***** Remove centre *****/ - if (asprintf (&Query,"DELETE FROM centres WHERE CtrCod=%ld", - Ctr.CtrCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove a centre"); + DB_BuildQuery ("DELETE FROM centres WHERE CtrCod=%ld",Ctr.CtrCod); + DB_QueryDELETE_new ("can not remove a centre"); /***** Write message to show the change made *****/ snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), diff --git a/swad_changelog.h b/swad_changelog.h index c9c085f21..564c709cb 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -355,10 +355,11 @@ En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 18.8.15 (2018-10-28)" +#define Log_PLATFORM_VERSION "SWAD 18.8.16 (2018-10-28)" #define CSS_FILE "swad18.4.css" #define JS_FILE "swad17.17.1.js" /* + Version 18.8.16: Oct 28, 2018 Some asprintf for database queries changed by internal function. (236263 lines) Version 18.8.15: Oct 28, 2018 Some asprintf for database queries changed by internal function. (236425 lines) Version 18.8.14: Oct 28, 2018 Some asprintf for database queries changed by internal function. (236493 lines) Version 18.8.13: Oct 27, 2018 Some asprintf for database queries changed by internal function. (236661 lines) diff --git a/swad_connected.c b/swad_connected.c index 7266b5b6b..c6f346ce7 100644 --- a/swad_connected.c +++ b/swad_connected.c @@ -658,13 +658,10 @@ void Con_UpdateMeInConnectedList (void) void Con_RemoveOldConnected (void) { - char *Query; - /***** Remove old users from connected list *****/ - if (asprintf (&Query,"DELETE FROM connected WHERE UsrCod NOT IN" - " (SELECT DISTINCT(UsrCod) FROM sessions)") < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove old users from list of connected users"); + DB_BuildQuery ("DELETE FROM connected WHERE UsrCod NOT IN" + " (SELECT DISTINCT(UsrCod) FROM sessions)"); + DB_QueryDELETE_new ("can not remove old users from list of connected users"); } /*****************************************************************************/ diff --git a/swad_country.c b/swad_country.c index 1d5a1e305..f8bef5c3c 100644 --- a/swad_country.c +++ b/swad_country.c @@ -1693,7 +1693,6 @@ void Cty_RemoveCountry (void) { extern const char *Txt_You_can_not_remove_a_country_with_institutions_or_users; extern const char *Txt_Country_X_removed; - char *Query; struct Country Cty; /***** Get country code *****/ @@ -1713,10 +1712,8 @@ void Cty_RemoveCountry (void) Svy_RemoveSurveys (Sco_SCOPE_CTY,Cty.CtyCod); /***** Remove country *****/ - if (asprintf (&Query,"DELETE FROM countries WHERE CtyCod='%03ld'", - Cty.CtyCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove a country"); + DB_BuildQuery ("DELETE FROM countries WHERE CtyCod='%03ld'",Cty.CtyCod); + DB_QueryDELETE_new ("can not remove a country"); /***** Flush cache *****/ Cty_FlushCacheCountryName (); diff --git a/swad_course.c b/swad_course.c index 39f68cce8..7ee43c5c2 100644 --- a/swad_course.c +++ b/swad_course.c @@ -2118,22 +2118,18 @@ static void Crs_GetShortNamesByCod (long CrsCod, void Crs_RemoveCourseCompletely (long CrsCod) { - char *Query; - if (CrsCod > 0) { /***** Empty course *****/ Crs_EmptyCourseCompletely (CrsCod); /***** Remove course from table of last accesses to courses in database *****/ - if (asprintf (&Query,"DELETE FROM crs_last WHERE CrsCod=%ld",CrsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove a course"); + DB_BuildQuery ("DELETE FROM crs_last WHERE CrsCod=%ld",CrsCod); + DB_QueryDELETE_new ("can not remove a course"); /***** Remove course from table of courses in database *****/ - if (asprintf (&Query,"DELETE FROM courses WHERE CrsCod=%ld",CrsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove a course"); + DB_BuildQuery ("DELETE FROM courses WHERE CrsCod=%ld",CrsCod); + DB_QueryDELETE_new ("can not remove a course"); } } @@ -2146,7 +2142,6 @@ void Crs_RemoveCourseCompletely (long CrsCod) static void Crs_EmptyCourseCompletely (long CrsCod) { struct Course Crs; - char *Query; char PathRelCrs[PATH_MAX + 1]; if (CrsCod > 0) @@ -2164,18 +2159,15 @@ static void Crs_EmptyCourseCompletely (long CrsCod) /***** Remove information of the course ****/ /* Remove timetable of the course */ - if (asprintf (&Query,"DELETE FROM timetable_crs WHERE CrsCod=%ld",CrsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove the timetable of a course"); + DB_BuildQuery ("DELETE FROM timetable_crs WHERE CrsCod=%ld",CrsCod); + DB_QueryDELETE_new ("can not remove the timetable of a course"); /* Remove other information of the course */ - if (asprintf (&Query,"DELETE FROM crs_info_src WHERE CrsCod=%ld",CrsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove info sources of a course"); + DB_BuildQuery ("DELETE FROM crs_info_src WHERE CrsCod=%ld",CrsCod); + DB_QueryDELETE_new ("can not remove info sources of a course"); - if (asprintf (&Query,"DELETE FROM crs_info_txt WHERE CrsCod=%ld",CrsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove info of a course"); + DB_BuildQuery ("DELETE FROM crs_info_txt WHERE CrsCod=%ld",CrsCod); + DB_QueryDELETE_new ("can not remove info of a course"); /***** Remove exam announcements in the course *****/ /* Mark all exam announcements in the course as deleted */ @@ -2186,17 +2178,15 @@ static void Crs_EmptyCourseCompletely (long CrsCod) /***** Remove course cards of the course *****/ /* Remove content of course cards */ - if (asprintf (&Query,"DELETE FROM crs_records USING crs_record_fields,crs_records" - " WHERE crs_record_fields.CrsCod=%ld" - " AND crs_record_fields.FieldCod=crs_records.FieldCod", - CrsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove content of cards in a course"); + DB_BuildQuery ("DELETE FROM crs_records USING crs_record_fields,crs_records" + " WHERE crs_record_fields.CrsCod=%ld" + " AND crs_record_fields.FieldCod=crs_records.FieldCod", + CrsCod); + DB_QueryDELETE_new ("can not remove content of cards in a course"); /* Remove definition of fields in course cards */ - if (asprintf (&Query,"DELETE FROM crs_record_fields WHERE CrsCod=%ld",CrsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove fields of cards in a course"); + DB_BuildQuery ("DELETE FROM crs_record_fields WHERE CrsCod=%ld",CrsCod); + DB_QueryDELETE_new ("can not remove fields of cards in a course"); /***** Remove information related to files in course, including groups and projects, @@ -2224,9 +2214,8 @@ static void Crs_EmptyCourseCompletely (long CrsCod) DB_QueryINSERT_new ("can not remove notices in a course"); /* Remove all notices from the course */ - if (asprintf (&Query,"DELETE FROM notices WHERE CrsCod=%ld",CrsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove notices in a course"); + DB_BuildQuery ("DELETE FROM notices WHERE CrsCod=%ld",CrsCod); + DB_QueryDELETE_new ("can not remove notices in a course"); /***** Remove all the threads and posts in forums of the course *****/ For_RemoveForums (Sco_SCOPE_CRS,CrsCod); @@ -2242,42 +2231,33 @@ static void Crs_EmptyCourseCompletely (long CrsCod) /***** Remove groups in the course *****/ /* Remove all the users in groups in the course */ - if (asprintf (&Query,"DELETE FROM crs_grp_usr" - " USING crs_grp_types,crs_grp,crs_grp_usr" - " WHERE crs_grp_types.CrsCod=%ld" - " AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod" - " AND crs_grp.GrpCod=crs_grp_usr.GrpCod", - CrsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove users from groups of a course"); + DB_BuildQuery ("DELETE FROM crs_grp_usr" + " USING crs_grp_types,crs_grp,crs_grp_usr" + " WHERE crs_grp_types.CrsCod=%ld" + " AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod" + " AND crs_grp.GrpCod=crs_grp_usr.GrpCod", + CrsCod); + DB_QueryDELETE_new ("can not remove users from groups of a course"); /* Remove all the groups in the course */ - if (asprintf (&Query,"DELETE FROM crs_grp" - " USING crs_grp_types,crs_grp" - " WHERE crs_grp_types.CrsCod=%ld" - " AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod", - CrsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove groups of a course"); + DB_BuildQuery ("DELETE FROM crs_grp" + " USING crs_grp_types,crs_grp" + " WHERE crs_grp_types.CrsCod=%ld" + " AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod", + CrsCod); + DB_QueryDELETE_new ("can not remove groups of a course"); /* Remove all the group types in the course */ - if (asprintf (&Query,"DELETE FROM crs_grp_types" - " WHERE CrsCod=%ld", - CrsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove types of group of a course"); + DB_BuildQuery ("DELETE FROM crs_grp_types WHERE CrsCod=%ld",CrsCod); + DB_QueryDELETE_new ("can not remove types of group of a course"); /***** Remove users' requests for inscription in the course *****/ - if (asprintf (&Query,"DELETE FROM crs_usr_requests WHERE CrsCod=%ld", - CrsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove requests for inscription to a course"); + DB_BuildQuery ("DELETE FROM crs_usr_requests WHERE CrsCod=%ld",CrsCod); + DB_QueryDELETE_new ("can not remove requests for inscription to a course"); /***** Remove possible users remaining in the course (teachers) *****/ - if (asprintf (&Query,"DELETE FROM crs_usr WHERE CrsCod=%ld", - CrsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove users from a course"); + DB_BuildQuery ("DELETE FROM crs_usr WHERE CrsCod=%ld",CrsCod); + DB_QueryDELETE_new ("can not remove users from a course"); /***** Remove directories of the course *****/ snprintf (PathRelCrs,sizeof (PathRelCrs), diff --git a/swad_degree.c b/swad_degree.c index 48a082e48..a9f4e4ee0 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -1831,7 +1831,6 @@ long Deg_GetInsCodOfDegreeByCod (long DegCod) void Deg_RemoveDegreeCompletely (long DegCod) { extern const char *Sco_ScopeDB[Sco_NUM_SCOPES]; - char *Query; MYSQL_RES *mysql_res; MYSQL_ROW row; unsigned long NumRow,NumRows; @@ -1879,16 +1878,13 @@ void Deg_RemoveDegreeCompletely (long DegCod) Fil_RemoveTree (PathDeg); /***** Remove administrators of this degree *****/ - if (asprintf (&Query,"DELETE FROM admin WHERE Scope='%s' AND Cod=%ld", - Sco_ScopeDB[Sco_SCOPE_DEG],DegCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove administrators of a degree"); + DB_BuildQuery ("DELETE FROM admin WHERE Scope='%s' AND Cod=%ld", + Sco_ScopeDB[Sco_SCOPE_DEG],DegCod); + DB_QueryDELETE_new ("can not remove administrators of a degree"); /***** Remove the degree *****/ - if (asprintf (&Query,"DELETE FROM degrees WHERE DegCod=%ld", - DegCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove a degree"); + DB_BuildQuery ("DELETE FROM degrees WHERE DegCod=%ld",DegCod); + DB_QueryDELETE_new ("can not remove a degree"); /***** Delete all the degrees in sta_degrees table not present in degrees table *****/ Pho_RemoveObsoleteStatDegrees (); diff --git a/swad_degree_type.c b/swad_degree_type.c index 306fa62ab..df13ecae7 100644 --- a/swad_degree_type.c +++ b/swad_degree_type.c @@ -867,7 +867,6 @@ bool DT_GetDataOfDegreeTypeByCod (struct DegreeType *DegTyp) static void DT_RemoveDegreeTypeCompletely (long DegTypCod) { - char *Query; MYSQL_RES *mysql_res; MYSQL_ROW row; unsigned long NumRow,NumRows; @@ -898,10 +897,8 @@ static void DT_RemoveDegreeTypeCompletely (long DegTypCod) DB_FreeMySQLResult (&mysql_res); /***** Remove the degree type *****/ - if (asprintf (&Query,"DELETE FROM deg_types WHERE DegTypCod=%ld", - DegTypCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove a type of degree"); + DB_BuildQuery ("DELETE FROM deg_types WHERE DegTypCod=%ld",DegTypCod); + DB_QueryDELETE_new ("can not remove a type of degree"); } /*****************************************************************************/ diff --git a/swad_department.c b/swad_department.c index 80618d0a7..ab521eedf 100644 --- a/swad_department.c +++ b/swad_department.c @@ -606,7 +606,6 @@ void Dpt_RemoveDepartment (void) { extern const char *Txt_To_remove_a_department_you_must_first_remove_all_teachers_in_the_department; extern const char *Txt_Department_X_removed; - char *Query; struct Department Dpt; /***** Get department code *****/ @@ -621,10 +620,8 @@ void Dpt_RemoveDepartment (void) else // Department has no teachers ==> remove it { /***** Remove department *****/ - if (asprintf (&Query,"DELETE FROM departments WHERE DptCod=%ld", - Dpt.DptCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove a department"); + DB_BuildQuery ("DELETE FROM departments WHERE DptCod=%ld",Dpt.DptCod); + DB_QueryDELETE_new ("can not remove a department"); /***** Write message to show the change made *****/ snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), diff --git a/swad_duplicate.c b/swad_duplicate.c index a4cf6f007..bdfaa8255 100644 --- a/swad_duplicate.c +++ b/swad_duplicate.c @@ -466,11 +466,7 @@ void Dup_RemoveUsrFromListDupUsrs (void) void Dup_RemoveUsrFromDuplicated (long UsrCod) { - char *Query; - /***** Remove user from list of duplicated users *****/ - if (asprintf (&Query,"DELETE FROM usr_duplicated WHERE UsrCod=%ld", - UsrCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove a user from possible duplicates"); + DB_BuildQuery ("DELETE FROM usr_duplicated WHERE UsrCod=%ld",UsrCod); + DB_QueryDELETE_new ("can not remove a user from possible duplicates"); } diff --git a/swad_enrolment.c b/swad_enrolment.c index 26615456a..6c4549e1f 100644 --- a/swad_enrolment.c +++ b/swad_enrolment.c @@ -2986,7 +2986,6 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) static void Enr_RemoveEnrolmentRequest (long CrsCod,long UsrCod) { - char *Query; MYSQL_RES *mysql_res; MYSQL_ROW row; long ReqCod; @@ -3010,11 +3009,10 @@ static void Enr_RemoveEnrolmentRequest (long CrsCod,long UsrCod) DB_FreeMySQLResult (&mysql_res); /***** Remove enrolment request *****/ - if (asprintf (&Query,"DELETE FROM crs_usr_requests" - " WHERE CrsCod=%ld AND UsrCod=%ld", - CrsCod,UsrCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove a request for enrolment"); + DB_BuildQuery ("DELETE FROM crs_usr_requests" + " WHERE CrsCod=%ld AND UsrCod=%ld", + CrsCod,UsrCod); + DB_QueryDELETE_new ("can not remove a request for enrolment"); } /*****************************************************************************/ @@ -4166,7 +4164,6 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,struct Course * { extern const char *Txt_THE_USER_X_has_been_removed_from_the_course_Y; extern const char *Txt_User_not_found_or_you_do_not_have_permission_; - char *Query; bool ItsMe = Usr_ItsMe (UsrDat->UsrCod); if (Usr_CheckIfUsrBelongsToCurrentCrs (UsrDat)) @@ -4198,11 +4195,10 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,struct Course * Ntf_MarkNotifInCrsAsRemoved (UsrDat->UsrCod,Crs->CrsCod); /***** Remove user from the table of courses-users *****/ - if (asprintf (&Query,"DELETE FROM crs_usr" - " WHERE CrsCod=%ld AND UsrCod=%ld", - Crs->CrsCod,UsrDat->UsrCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove a user from a course"); + DB_BuildQuery ("DELETE FROM crs_usr" + " WHERE CrsCod=%ld AND UsrCod=%ld", + Crs->CrsCod,UsrDat->UsrCod); + DB_QueryDELETE_new ("can not remove a user from a course"); /***** Flush caches *****/ Usr_FlushCachesUsr (); @@ -4307,16 +4303,14 @@ static void Enr_EffectivelyRemAdm (struct UsrData *UsrDat,Sco_Scope_t Scope, extern const char *Sco_ScopeDB[Sco_NUM_SCOPES]; extern const char *Txt_THE_USER_X_has_been_removed_as_administrator_of_Y; extern const char *Txt_THE_USER_X_is_not_an_administrator_of_Y; - char *Query; if (Usr_CheckIfUsrIsAdm (UsrDat->UsrCod,Scope,Cod)) // User is administrator of current institution/centre/degree { /***** Remove user from the table of admins *****/ - if (asprintf (&Query,"DELETE FROM admin" - " WHERE UsrCod=%ld AND Scope='%s' AND Cod=%ld", - UsrDat->UsrCod,Sco_ScopeDB[Scope],Cod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove an administrator"); + DB_BuildQuery ("DELETE FROM admin" + " WHERE UsrCod=%ld AND Scope='%s' AND Cod=%ld", + UsrDat->UsrCod,Sco_ScopeDB[Scope],Cod); + DB_QueryDELETE_new ("can not remove an administrator"); snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), Txt_THE_USER_X_has_been_removed_as_administrator_of_Y, diff --git a/swad_file_browser.c b/swad_file_browser.c index 8ed3ab32e..c5c310922 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -4547,64 +4547,56 @@ static void Brw_StoreSizeOfFileTreeInDB (void) void Brw_RemoveInsFilesFromDB (long InsCod) { - char *Query; - /***** Remove from database the entries that store the file views *****/ - if (asprintf (&Query,"DELETE FROM file_view USING file_view,files" - " WHERE files.FileBrowser IN (%u,%u) AND files.Cod=%ld" - " AND files.FilCod=file_view.FilCod", - (unsigned) Brw_ADMI_DOC_INS, - (unsigned) Brw_ADMI_SHR_INS, - InsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove file views to files of an institution"); + DB_BuildQuery ("DELETE FROM file_view USING file_view,files" + " WHERE files.FileBrowser IN (%u,%u) AND files.Cod=%ld" + " AND files.FilCod=file_view.FilCod", + (unsigned) Brw_ADMI_DOC_INS, + (unsigned) Brw_ADMI_SHR_INS, + InsCod); + DB_QueryDELETE_new ("can not remove file views to files of an institution"); /***** Remove from database expanded folders *****/ - if (asprintf (&Query,"DELETE LOW_PRIORITY FROM expanded_folders" - " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_INS, - (unsigned) Brw_ADMI_SHR_INS, - InsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove expanded folders of an institution"); + DB_BuildQuery ("DELETE LOW_PRIORITY FROM expanded_folders" + " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_INS, + (unsigned) Brw_ADMI_SHR_INS, + InsCod); + DB_QueryDELETE_new ("can not remove expanded folders of an institution"); /***** Remove from database the entries that store clipboards *****/ - if (asprintf (&Query,"DELETE FROM clipboard" - " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_INS, - (unsigned) Brw_ADMI_SHR_INS, - InsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove clipboards related to files of an institution"); + DB_BuildQuery ("DELETE FROM clipboard" + " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_INS, + (unsigned) Brw_ADMI_SHR_INS, + InsCod); + DB_QueryDELETE_new ("can not remove clipboards related to files of an institution"); /***** Remove from database the entries that store the last time users visited file zones *****/ - if (asprintf (&Query,"DELETE FROM file_browser_last" - " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_INS, - (unsigned) Brw_ADMI_SHR_INS, - InsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove file last visits to files of an institution"); + DB_BuildQuery ("DELETE FROM file_browser_last" + " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_INS, + (unsigned) Brw_ADMI_SHR_INS, + InsCod); + DB_QueryDELETE_new ("can not remove file last visits to files of an institution"); /***** Remove from database the entries that store the sizes of the file zones *****/ - if (asprintf (&Query,"DELETE FROM file_browser_size" - " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_INS, - (unsigned) Brw_ADMI_SHR_INS, - InsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove sizes of file zones of an institution"); + DB_BuildQuery ("DELETE FROM file_browser_size" + " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_INS, + (unsigned) Brw_ADMI_SHR_INS, + InsCod); + DB_QueryDELETE_new ("can not remove sizes of file zones of an institution"); /***** Remove from database the entries that store the data files *****/ - if (asprintf (&Query,"DELETE FROM files" - " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_INS, - (unsigned) Brw_ADMI_SHR_INS, - InsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove files of an institution"); + DB_BuildQuery ("DELETE FROM files" + " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_INS, + (unsigned) Brw_ADMI_SHR_INS, + InsCod); + DB_QueryDELETE_new ("can not remove files of an institution"); } /*****************************************************************************/ @@ -4613,62 +4605,54 @@ void Brw_RemoveInsFilesFromDB (long InsCod) void Brw_RemoveCtrFilesFromDB (long CtrCod) { - char *Query; - /***** Remove from database the entries that store the file views *****/ - if (asprintf (&Query,"DELETE FROM file_view USING file_view,files" - " WHERE files.FileBrowser IN (%u,%u) AND files.Cod=%ld" - " AND files.FilCod=file_view.FilCod", - (unsigned) Brw_ADMI_DOC_CTR, - (unsigned) Brw_ADMI_SHR_CTR, - CtrCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove file views to files of a centre"); + DB_BuildQuery ("DELETE FROM file_view USING file_view,files" + " WHERE files.FileBrowser IN (%u,%u) AND files.Cod=%ld" + " AND files.FilCod=file_view.FilCod", + (unsigned) Brw_ADMI_DOC_CTR, + (unsigned) Brw_ADMI_SHR_CTR, + CtrCod); + DB_QueryDELETE_new ("can not remove file views to files of a centre"); /***** Remove from database expanded folders *****/ - if (asprintf (&Query,"DELETE LOW_PRIORITY FROM expanded_folders" - " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_CTR, - (unsigned) Brw_ADMI_SHR_CTR, - CtrCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove expanded folders of a centre"); + DB_BuildQuery ("DELETE LOW_PRIORITY FROM expanded_folders" + " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_CTR, + (unsigned) Brw_ADMI_SHR_CTR, + CtrCod); + DB_QueryDELETE_new ("can not remove expanded folders of a centre"); /***** Remove from database the entries that store clipboards *****/ - if (asprintf (&Query,"DELETE FROM clipboard" - " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_CTR, - (unsigned) Brw_ADMI_SHR_CTR, - CtrCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove clipboards related to files of a centre"); + DB_BuildQuery ("DELETE FROM clipboard" + " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_CTR, + (unsigned) Brw_ADMI_SHR_CTR, + CtrCod); + DB_QueryDELETE_new ("can not remove clipboards related to files of a centre"); /***** Remove from database the entries that store the last time users visited file zones *****/ - if (asprintf (&Query,"DELETE FROM file_browser_last" - " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_CTR, - (unsigned) Brw_ADMI_SHR_CTR, - CtrCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove file last visits to files of a centre"); + DB_BuildQuery ("DELETE FROM file_browser_last" + " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_CTR, + (unsigned) Brw_ADMI_SHR_CTR, + CtrCod); + DB_QueryDELETE_new ("can not remove file last visits to files of a centre"); /***** Remove from database the entries that store the sizes of the file zones *****/ - if (asprintf (&Query,"DELETE FROM file_browser_size" - " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_CTR, - (unsigned) Brw_ADMI_SHR_CTR, - CtrCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove sizes of file zones of a centre"); + DB_BuildQuery ("DELETE FROM file_browser_size" + " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_CTR, + (unsigned) Brw_ADMI_SHR_CTR, + CtrCod); + DB_QueryDELETE_new ("can not remove sizes of file zones of a centre"); /***** Remove from database the entries that store the data files *****/ - if (asprintf (&Query,"DELETE FROM files" - " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_CTR, - (unsigned) Brw_ADMI_SHR_CTR, - CtrCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove files of a centre"); + DB_BuildQuery ("DELETE FROM files" + " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_CTR, + (unsigned) Brw_ADMI_SHR_CTR, + CtrCod); + DB_QueryDELETE_new ("can not remove files of a centre"); } /*****************************************************************************/ @@ -4677,62 +4661,54 @@ void Brw_RemoveCtrFilesFromDB (long CtrCod) void Brw_RemoveDegFilesFromDB (long DegCod) { - char *Query; - /***** Remove from database the entries that store the file views *****/ - if (asprintf (&Query,"DELETE FROM file_view USING file_view,files" - " WHERE files.FileBrowser IN (%u,%u) AND files.Cod=%ld" - " AND files.FilCod=file_view.FilCod", - (unsigned) Brw_ADMI_DOC_DEG, - (unsigned) Brw_ADMI_SHR_DEG, - DegCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove file views to files of a degree"); + DB_BuildQuery ("DELETE FROM file_view USING file_view,files" + " WHERE files.FileBrowser IN (%u,%u) AND files.Cod=%ld" + " AND files.FilCod=file_view.FilCod", + (unsigned) Brw_ADMI_DOC_DEG, + (unsigned) Brw_ADMI_SHR_DEG, + DegCod); + DB_QueryDELETE_new ("can not remove file views to files of a degree"); /***** Remove from database expanded folders *****/ - if (asprintf (&Query,"DELETE LOW_PRIORITY FROM expanded_folders" - " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_DEG, - (unsigned) Brw_ADMI_SHR_DEG, - DegCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove expanded folders of a degree"); + DB_BuildQuery ("DELETE LOW_PRIORITY FROM expanded_folders" + " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_DEG, + (unsigned) Brw_ADMI_SHR_DEG, + DegCod); + DB_QueryDELETE_new ("can not remove expanded folders of a degree"); /***** Remove from database the entries that store clipboards *****/ - if (asprintf (&Query,"DELETE FROM clipboard" - " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_DEG, - (unsigned) Brw_ADMI_SHR_DEG, - DegCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove clipboards related to files of a degree"); + DB_BuildQuery ("DELETE FROM clipboard" + " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_DEG, + (unsigned) Brw_ADMI_SHR_DEG, + DegCod); + DB_QueryDELETE_new ("can not remove clipboards related to files of a degree"); /***** Remove from database the entries that store the last time users visited file zones *****/ - if (asprintf (&Query,"DELETE FROM file_browser_last" - " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_DEG, - (unsigned) Brw_ADMI_SHR_DEG, - DegCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove file last visits to files of a degree"); + DB_BuildQuery ("DELETE FROM file_browser_last" + " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_DEG, + (unsigned) Brw_ADMI_SHR_DEG, + DegCod); + DB_QueryDELETE_new ("can not remove file last visits to files of a degree"); /***** Remove from database the entries that store the sizes of the file zones *****/ - if (asprintf (&Query,"DELETE FROM file_browser_size" - " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_DEG, - (unsigned) Brw_ADMI_SHR_DEG, - DegCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove sizes of file zones of a degree"); + DB_BuildQuery ("DELETE FROM file_browser_size" + " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_DEG, + (unsigned) Brw_ADMI_SHR_DEG, + DegCod); + DB_QueryDELETE_new ("can not remove sizes of file zones of a degree"); /***** Remove from database the entries that store the data files *****/ - if (asprintf (&Query,"DELETE FROM files" - " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_DEG, - (unsigned) Brw_ADMI_SHR_DEG, - DegCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove files of a degree"); + DB_BuildQuery ("DELETE FROM files" + " WHERE FileBrowser IN (%u,%u) AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_DEG, + (unsigned) Brw_ADMI_SHR_DEG, + DegCod); + DB_QueryDELETE_new ("can not remove files of a degree"); } /*****************************************************************************/ @@ -4747,7 +4723,6 @@ void Brw_RemoveCrsFilesFromDB (long CrsCod) { char SubqueryGrp[256]; char SubqueryPrj[128]; - char *Query; /***** Build subquery for groups *****/ sprintf (SubqueryGrp,"(SELECT crs_grp.GrpCod FROM crs_grp_types,crs_grp" @@ -4760,244 +4735,225 @@ void Brw_RemoveCrsFilesFromDB (long CrsCod) CrsCod); /***** Remove format of files of marks *****/ - if (asprintf (&Query,"DELETE FROM marks_properties USING files,marks_properties" - " WHERE files.FileBrowser=%u" - " AND files.Cod=%ld" - " AND files.FilCod=marks_properties.FilCod", - (unsigned) Brw_ADMI_MRK_CRS, - CrsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove the properties of marks associated to a course"); + DB_BuildQuery ("DELETE FROM marks_properties USING files,marks_properties" + " WHERE files.FileBrowser=%u" + " AND files.Cod=%ld" + " AND files.FilCod=marks_properties.FilCod", + (unsigned) Brw_ADMI_MRK_CRS, + CrsCod); + DB_QueryDELETE_new ("can not remove the properties of marks associated to a course"); /***** Remove from database the entries that store the file views *****/ /* Remove from course file zones */ - if (asprintf (&Query,"DELETE FROM file_view USING file_view,files" - " WHERE files.FileBrowser IN (%u,%u,%u,%u,%u,%u)" - " AND files.Cod=%ld" - " AND files.FilCod=file_view.FilCod", - (unsigned) Brw_ADMI_DOC_CRS, - (unsigned) Brw_ADMI_TCH_CRS, - (unsigned) Brw_ADMI_SHR_CRS, - (unsigned) Brw_ADMI_ASG_USR, - (unsigned) Brw_ADMI_WRK_USR, - (unsigned) Brw_ADMI_MRK_CRS, - CrsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove file views to files of a course"); + DB_BuildQuery ("DELETE FROM file_view USING file_view,files" + " WHERE files.FileBrowser IN (%u,%u,%u,%u,%u,%u)" + " AND files.Cod=%ld" + " AND files.FilCod=file_view.FilCod", + (unsigned) Brw_ADMI_DOC_CRS, + (unsigned) Brw_ADMI_TCH_CRS, + (unsigned) Brw_ADMI_SHR_CRS, + (unsigned) Brw_ADMI_ASG_USR, + (unsigned) Brw_ADMI_WRK_USR, + (unsigned) Brw_ADMI_MRK_CRS, + CrsCod); + DB_QueryDELETE_new ("can not remove file views to files of a course"); /* Remove from group file zones */ - if (asprintf (&Query,"DELETE FROM file_view USING file_view,files" - " WHERE files.FileBrowser IN (%u,%u,%u,%u)" - " AND files.Cod IN %s" - " AND files.FilCod=file_view.FilCod", - (unsigned) Brw_ADMI_DOC_GRP, - (unsigned) Brw_ADMI_TCH_GRP, - (unsigned) Brw_ADMI_SHR_GRP, - (unsigned) Brw_ADMI_MRK_GRP, - SubqueryGrp) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove file views to files of a course"); + DB_BuildQuery ("DELETE FROM file_view USING file_view,files" + " WHERE files.FileBrowser IN (%u,%u,%u,%u)" + " AND files.Cod IN %s" + " AND files.FilCod=file_view.FilCod", + (unsigned) Brw_ADMI_DOC_GRP, + (unsigned) Brw_ADMI_TCH_GRP, + (unsigned) Brw_ADMI_SHR_GRP, + (unsigned) Brw_ADMI_MRK_GRP, + SubqueryGrp); + DB_QueryDELETE_new ("can not remove file views to files of a course"); /* Remove from project file zones */ - if (asprintf (&Query,"DELETE FROM file_view USING file_view,files" - " WHERE files.FileBrowser IN (%u,%u)" - " AND files.Cod IN %s" - " AND files.FilCod=file_view.FilCod", - (unsigned) Brw_ADMI_DOC_PRJ, - (unsigned) Brw_ADMI_ASS_PRJ, - SubqueryPrj) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove file views to files of a course"); + DB_BuildQuery ("DELETE FROM file_view USING file_view,files" + " WHERE files.FileBrowser IN (%u,%u)" + " AND files.Cod IN %s" + " AND files.FilCod=file_view.FilCod", + (unsigned) Brw_ADMI_DOC_PRJ, + (unsigned) Brw_ADMI_ASS_PRJ, + SubqueryPrj); + DB_QueryDELETE_new ("can not remove file views to files of a course"); /***** Remove from database expanded folders *****/ /* Remove from course file zones */ - if (asprintf (&Query,"DELETE LOW_PRIORITY FROM expanded_folders" - " WHERE FileBrowser IN (%u,%u,%u,%u,%u,%u,%u,%u)" - " AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_CRS, - (unsigned) Brw_ADMI_TCH_CRS, - (unsigned) Brw_ADMI_SHR_CRS, - (unsigned) Brw_ADMI_ASG_USR, - (unsigned) Brw_ADMI_ASG_CRS, - (unsigned) Brw_ADMI_WRK_USR, - (unsigned) Brw_ADMI_WRK_CRS, - (unsigned) Brw_ADMI_MRK_CRS, - CrsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove expanded folders of a course"); + DB_BuildQuery ("DELETE LOW_PRIORITY FROM expanded_folders" + " WHERE FileBrowser IN (%u,%u,%u,%u,%u,%u,%u,%u)" + " AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_CRS, + (unsigned) Brw_ADMI_TCH_CRS, + (unsigned) Brw_ADMI_SHR_CRS, + (unsigned) Brw_ADMI_ASG_USR, + (unsigned) Brw_ADMI_ASG_CRS, + (unsigned) Brw_ADMI_WRK_USR, + (unsigned) Brw_ADMI_WRK_CRS, + (unsigned) Brw_ADMI_MRK_CRS, + CrsCod); + DB_QueryDELETE_new ("can not remove expanded folders of a course"); /* Remove from group file zones */ - if (asprintf (&Query,"DELETE LOW_PRIORITY FROM expanded_folders" - " WHERE FileBrowser IN (%u,%u,%u,%u)" - " AND Cod IN %s", + DB_BuildQuery ("DELETE LOW_PRIORITY FROM expanded_folders" + " WHERE FileBrowser IN (%u,%u,%u,%u)" + " AND Cod IN %s", (unsigned) Brw_ADMI_DOC_GRP, - (unsigned) Brw_ADMI_TCH_GRP, - (unsigned) Brw_ADMI_SHR_GRP, - (unsigned) Brw_ADMI_MRK_GRP, - SubqueryGrp) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove expanded folders of a course"); + (unsigned) Brw_ADMI_TCH_GRP, + (unsigned) Brw_ADMI_SHR_GRP, + (unsigned) Brw_ADMI_MRK_GRP, + SubqueryGrp); + DB_QueryDELETE_new ("can not remove expanded folders of a course"); /* Remove from project file zones */ - if (asprintf (&Query,"DELETE LOW_PRIORITY FROM expanded_folders" - " WHERE FileBrowser IN (%u,%u)" - " AND Cod IN %s", - (unsigned) Brw_ADMI_DOC_PRJ, - (unsigned) Brw_ADMI_ASS_PRJ, - SubqueryPrj) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove expanded folders of a course"); + DB_BuildQuery ("DELETE LOW_PRIORITY FROM expanded_folders" + " WHERE FileBrowser IN (%u,%u)" + " AND Cod IN %s", + (unsigned) Brw_ADMI_DOC_PRJ, + (unsigned) Brw_ADMI_ASS_PRJ, + SubqueryPrj); + DB_QueryDELETE_new ("can not remove expanded folders of a course"); /***** Remove from database the entries that store clipboards *****/ /* Remove from course file zones */ - if (asprintf (&Query,"DELETE FROM clipboard" - " WHERE FileBrowser IN (%u,%u,%u,%u,%u,%u,%u,%u)" - " AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_CRS, - (unsigned) Brw_ADMI_TCH_CRS, - (unsigned) Brw_ADMI_SHR_CRS, - (unsigned) Brw_ADMI_ASG_USR, - (unsigned) Brw_ADMI_ASG_CRS, - (unsigned) Brw_ADMI_WRK_USR, - (unsigned) Brw_ADMI_WRK_CRS, - (unsigned) Brw_ADMI_MRK_CRS, - CrsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove clipboards related to files of a course"); + DB_BuildQuery ("DELETE FROM clipboard" + " WHERE FileBrowser IN (%u,%u,%u,%u,%u,%u,%u,%u)" + " AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_CRS, + (unsigned) Brw_ADMI_TCH_CRS, + (unsigned) Brw_ADMI_SHR_CRS, + (unsigned) Brw_ADMI_ASG_USR, + (unsigned) Brw_ADMI_ASG_CRS, + (unsigned) Brw_ADMI_WRK_USR, + (unsigned) Brw_ADMI_WRK_CRS, + (unsigned) Brw_ADMI_MRK_CRS, + CrsCod); + DB_QueryDELETE_new ("can not remove clipboards related to files of a course"); /* Remove from group file zones */ - if (asprintf (&Query,"DELETE FROM clipboard" - " WHERE FileBrowser IN (%u,%u,%u,%u)" - " AND Cod IN %s", - (unsigned) Brw_ADMI_DOC_GRP, - (unsigned) Brw_ADMI_TCH_GRP, - (unsigned) Brw_ADMI_SHR_GRP, - (unsigned) Brw_ADMI_MRK_GRP, - SubqueryGrp) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove clipboards related to files of a course"); + DB_BuildQuery ("DELETE FROM clipboard" + " WHERE FileBrowser IN (%u,%u,%u,%u)" + " AND Cod IN %s", + (unsigned) Brw_ADMI_DOC_GRP, + (unsigned) Brw_ADMI_TCH_GRP, + (unsigned) Brw_ADMI_SHR_GRP, + (unsigned) Brw_ADMI_MRK_GRP, + SubqueryGrp); + DB_QueryDELETE_new ("can not remove clipboards related to files of a course"); /* Remove from project file zones */ - if (asprintf (&Query,"DELETE FROM clipboard" - " WHERE FileBrowser IN (%u,%u)" - " AND Cod IN %s", - (unsigned) Brw_ADMI_DOC_PRJ, - (unsigned) Brw_ADMI_ASS_PRJ, - SubqueryPrj) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove clipboards related to files of a course"); + DB_BuildQuery ("DELETE FROM clipboard" + " WHERE FileBrowser IN (%u,%u)" + " AND Cod IN %s", + (unsigned) Brw_ADMI_DOC_PRJ, + (unsigned) Brw_ADMI_ASS_PRJ, + SubqueryPrj); + DB_QueryDELETE_new ("can not remove clipboards related to files of a course"); /***** Remove from database the entries that store the last time users visited file zones *****/ // Assignments and works are stored as one in file_browser_last... // ...because a user views them at the same time /* Remove from course file zones */ - if (asprintf (&Query,"DELETE FROM file_browser_last" - " WHERE FileBrowser IN (%u,%u,%u,%u,%u)" - " AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_CRS, - (unsigned) Brw_ADMI_TCH_CRS, - (unsigned) Brw_ADMI_SHR_CRS, - (unsigned) Brw_ADMI_ASG_USR, - (unsigned) Brw_ADMI_MRK_CRS, - CrsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove file last visits to files of a course"); + DB_BuildQuery ("DELETE FROM file_browser_last" + " WHERE FileBrowser IN (%u,%u,%u,%u,%u)" + " AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_CRS, + (unsigned) Brw_ADMI_TCH_CRS, + (unsigned) Brw_ADMI_SHR_CRS, + (unsigned) Brw_ADMI_ASG_USR, + (unsigned) Brw_ADMI_MRK_CRS, + CrsCod); + DB_QueryDELETE_new ("can not remove file last visits to files of a course"); /* Remove from group file zones */ - if (asprintf (&Query,"DELETE FROM file_browser_last" - " WHERE FileBrowser IN (%u,%u,%u,%u)" - " AND Cod IN %s", - (unsigned) Brw_ADMI_DOC_GRP, - (unsigned) Brw_ADMI_TCH_GRP, - (unsigned) Brw_ADMI_SHR_GRP, - (unsigned) Brw_ADMI_MRK_GRP, - SubqueryGrp) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove file last visits to files of a course"); + DB_BuildQuery ("DELETE FROM file_browser_last" + " WHERE FileBrowser IN (%u,%u,%u,%u)" + " AND Cod IN %s", + (unsigned) Brw_ADMI_DOC_GRP, + (unsigned) Brw_ADMI_TCH_GRP, + (unsigned) Brw_ADMI_SHR_GRP, + (unsigned) Brw_ADMI_MRK_GRP, + SubqueryGrp); + DB_QueryDELETE_new ("can not remove file last visits to files of a course"); /* Remove from project file zones */ - if (asprintf (&Query,"DELETE FROM file_browser_last" - " WHERE FileBrowser IN (%u,%u)" - " AND Cod IN %s", - (unsigned) Brw_ADMI_DOC_PRJ, - (unsigned) Brw_ADMI_ASS_PRJ, - SubqueryPrj) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove file last visits to files of a course"); + DB_BuildQuery ("DELETE FROM file_browser_last" + " WHERE FileBrowser IN (%u,%u)" + " AND Cod IN %s", + (unsigned) Brw_ADMI_DOC_PRJ, + (unsigned) Brw_ADMI_ASS_PRJ, + SubqueryPrj); + DB_QueryDELETE_new ("can not remove file last visits to files of a course"); /***** Remove from database the entries that store the sizes of the file zones *****/ /* Remove from course file zones */ - if (asprintf (&Query,"DELETE FROM file_browser_size" - " WHERE FileBrowser IN (%u,%u,%u,%u,%u,%u)" - " AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_CRS, - (unsigned) Brw_ADMI_TCH_CRS, - (unsigned) Brw_ADMI_SHR_CRS, - (unsigned) Brw_ADMI_ASG_USR, - (unsigned) Brw_ADMI_WRK_USR, - (unsigned) Brw_ADMI_MRK_CRS, - CrsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove sizes of file zones of a course"); + DB_BuildQuery ("DELETE FROM file_browser_size" + " WHERE FileBrowser IN (%u,%u,%u,%u,%u,%u)" + " AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_CRS, + (unsigned) Brw_ADMI_TCH_CRS, + (unsigned) Brw_ADMI_SHR_CRS, + (unsigned) Brw_ADMI_ASG_USR, + (unsigned) Brw_ADMI_WRK_USR, + (unsigned) Brw_ADMI_MRK_CRS, + CrsCod); + DB_QueryDELETE_new ("can not remove sizes of file zones of a course"); /* Remove from group file zones */ - if (asprintf (&Query,"DELETE FROM file_browser_size" - " WHERE FileBrowser IN (%u,%u,%u,%u)" - " AND Cod IN %s", - (unsigned) Brw_ADMI_DOC_GRP, - (unsigned) Brw_ADMI_TCH_GRP, - (unsigned) Brw_ADMI_SHR_GRP, - (unsigned) Brw_ADMI_MRK_GRP, - SubqueryGrp) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove sizes of file zones of a course"); + DB_BuildQuery ("DELETE FROM file_browser_size" + " WHERE FileBrowser IN (%u,%u,%u,%u)" + " AND Cod IN %s", + (unsigned) Brw_ADMI_DOC_GRP, + (unsigned) Brw_ADMI_TCH_GRP, + (unsigned) Brw_ADMI_SHR_GRP, + (unsigned) Brw_ADMI_MRK_GRP, + SubqueryGrp); + DB_QueryDELETE_new ("can not remove sizes of file zones of a course"); /* Remove from project file zones */ - if (asprintf (&Query,"DELETE FROM file_browser_size" - " WHERE FileBrowser IN (%u,%u)" - " AND Cod IN %s", - (unsigned) Brw_ADMI_DOC_PRJ, - (unsigned) Brw_ADMI_ASS_PRJ, - SubqueryPrj) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove sizes of file zones of a course"); + DB_BuildQuery ("DELETE FROM file_browser_size" + " WHERE FileBrowser IN (%u,%u)" + " AND Cod IN %s", + (unsigned) Brw_ADMI_DOC_PRJ, + (unsigned) Brw_ADMI_ASS_PRJ, + SubqueryPrj); + DB_QueryDELETE_new ("can not remove sizes of file zones of a course"); /***** Remove from database the entries that store the data files *****/ /* Remove from course file zones */ - if (asprintf (&Query,"DELETE FROM files" - " WHERE FileBrowser IN (%u,%u,%u,%u,%u,%u)" - " AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_CRS, - (unsigned) Brw_ADMI_TCH_CRS, - (unsigned) Brw_ADMI_SHR_CRS, - (unsigned) Brw_ADMI_ASG_USR, - (unsigned) Brw_ADMI_WRK_USR, - (unsigned) Brw_ADMI_MRK_CRS, - CrsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove files of a course"); + DB_BuildQuery ("DELETE FROM files" + " WHERE FileBrowser IN (%u,%u,%u,%u,%u,%u)" + " AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_CRS, + (unsigned) Brw_ADMI_TCH_CRS, + (unsigned) Brw_ADMI_SHR_CRS, + (unsigned) Brw_ADMI_ASG_USR, + (unsigned) Brw_ADMI_WRK_USR, + (unsigned) Brw_ADMI_MRK_CRS, + CrsCod); + DB_QueryDELETE_new ("can not remove files of a course"); /* Remove from group file zones */ - if (asprintf (&Query,"DELETE FROM files" - " WHERE FileBrowser IN (%u,%u,%u,%u)" - " AND Cod IN %s", - (unsigned) Brw_ADMI_DOC_GRP, - (unsigned) Brw_ADMI_TCH_GRP, - (unsigned) Brw_ADMI_SHR_GRP, - (unsigned) Brw_ADMI_MRK_GRP, - SubqueryGrp) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove files of a course"); + DB_BuildQuery ("DELETE FROM files" + " WHERE FileBrowser IN (%u,%u,%u,%u)" + " AND Cod IN %s", + (unsigned) Brw_ADMI_DOC_GRP, + (unsigned) Brw_ADMI_TCH_GRP, + (unsigned) Brw_ADMI_SHR_GRP, + (unsigned) Brw_ADMI_MRK_GRP, + SubqueryGrp); + DB_QueryDELETE_new ("can not remove files of a course"); /* Remove from project file zones */ - if (asprintf (&Query,"DELETE FROM files" - " WHERE FileBrowser IN (%u,%u)" - " AND Cod IN %s", - (unsigned) Brw_ADMI_DOC_PRJ, - (unsigned) Brw_ADMI_ASS_PRJ, - SubqueryPrj) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove files of a course"); + DB_BuildQuery ("DELETE FROM files" + " WHERE FileBrowser IN (%u,%u)" + " AND Cod IN %s", + (unsigned) Brw_ADMI_DOC_PRJ, + (unsigned) Brw_ADMI_ASS_PRJ, + SubqueryPrj); + DB_QueryDELETE_new ("can not remove files of a course"); } /*****************************************************************************/ @@ -5006,90 +4962,81 @@ void Brw_RemoveCrsFilesFromDB (long CrsCod) void Brw_RemoveGrpFilesFromDB (long GrpCod) { - char *Query; - /***** Remove format of files of marks *****/ - if (asprintf (&Query,"DELETE FROM marks_properties USING files,marks_properties" - " WHERE files.FileBrowser=%u" - " AND files.Cod=%ld" - " AND files.FilCod=marks_properties.FilCod", - (unsigned) Brw_ADMI_MRK_GRP, - GrpCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove the properties of marks associated to a group"); + DB_BuildQuery ("DELETE FROM marks_properties USING files,marks_properties" + " WHERE files.FileBrowser=%u" + " AND files.Cod=%ld" + " AND files.FilCod=marks_properties.FilCod", + (unsigned) Brw_ADMI_MRK_GRP, + GrpCod); + DB_QueryDELETE_new ("can not remove the properties of marks associated to a group"); /***** Remove from database the entries that store the file views *****/ - if (asprintf (&Query,"DELETE FROM file_view USING file_view,files" - " WHERE files.FileBrowser IN (%u,%u,%u,%u)" - " AND files.Cod=%ld" - " AND files.FilCod=file_view.FilCod", - (unsigned) Brw_ADMI_DOC_GRP, - (unsigned) Brw_ADMI_TCH_GRP, - (unsigned) Brw_ADMI_SHR_GRP, - (unsigned) Brw_ADMI_MRK_GRP, - GrpCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove file views to files of a group"); + DB_BuildQuery ("DELETE FROM file_view USING file_view,files" + " WHERE files.FileBrowser IN (%u,%u,%u,%u)" + " AND files.Cod=%ld" + " AND files.FilCod=file_view.FilCod", + (unsigned) Brw_ADMI_DOC_GRP, + (unsigned) Brw_ADMI_TCH_GRP, + (unsigned) Brw_ADMI_SHR_GRP, + (unsigned) Brw_ADMI_MRK_GRP, + GrpCod); + DB_QueryDELETE_new ("can not remove file views to files of a group"); /***** Remove from database expanded folders *****/ - if (asprintf (&Query,"DELETE LOW_PRIORITY FROM expanded_folders" - " WHERE FileBrowser IN (%u,%u,%u,%u)" - " AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_GRP, - (unsigned) Brw_ADMI_TCH_GRP, - (unsigned) Brw_ADMI_SHR_GRP, - (unsigned) Brw_ADMI_MRK_GRP, - GrpCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove expanded folders of a group"); + DB_BuildQuery ("DELETE LOW_PRIORITY FROM expanded_folders" + " WHERE FileBrowser IN (%u,%u,%u,%u)" + " AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_GRP, + (unsigned) Brw_ADMI_TCH_GRP, + (unsigned) Brw_ADMI_SHR_GRP, + (unsigned) Brw_ADMI_MRK_GRP, + GrpCod); + DB_QueryDELETE_new ("can not remove expanded folders of a group"); /***** Remove from database the entries that store clipboards *****/ - if (asprintf (&Query,"DELETE FROM clipboard" - " WHERE FileBrowser IN (%u,%u,%u,%u)" - " AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_GRP, - (unsigned) Brw_ADMI_TCH_GRP, - (unsigned) Brw_ADMI_SHR_GRP, - (unsigned) Brw_ADMI_MRK_GRP, - GrpCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove clipboards related to files of a group"); + DB_BuildQuery ("DELETE FROM clipboard" + " WHERE FileBrowser IN (%u,%u,%u,%u)" + " AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_GRP, + (unsigned) Brw_ADMI_TCH_GRP, + (unsigned) Brw_ADMI_SHR_GRP, + (unsigned) Brw_ADMI_MRK_GRP, + GrpCod); + DB_QueryDELETE_new ("can not remove clipboards related to files of a group"); /***** Remove from database the entries that store the last time users visited file zones *****/ - if (asprintf (&Query,"DELETE FROM file_browser_last" - " WHERE FileBrowser IN (%u,%u,%u,%u)" - " AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_GRP, - (unsigned) Brw_ADMI_TCH_GRP, - (unsigned) Brw_ADMI_SHR_GRP, - (unsigned) Brw_ADMI_MRK_GRP, - GrpCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove file last visits to files of a group"); + DB_BuildQuery ("DELETE FROM file_browser_last" + " WHERE FileBrowser IN (%u,%u,%u,%u)" + " AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_GRP, + (unsigned) Brw_ADMI_TCH_GRP, + (unsigned) Brw_ADMI_SHR_GRP, + (unsigned) Brw_ADMI_MRK_GRP, + GrpCod); + DB_QueryDELETE_new ("can not remove file last visits to files of a group"); /***** Remove from database the entries that store the sizes of the file zones *****/ - if (asprintf (&Query,"DELETE FROM file_browser_size" - " WHERE FileBrowser IN (%u,%u,%u,%u)" - " AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_GRP, - (unsigned) Brw_ADMI_TCH_GRP, - (unsigned) Brw_ADMI_SHR_GRP, - (unsigned) Brw_ADMI_MRK_GRP, - GrpCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove sizes of file zones of a group"); + DB_BuildQuery ("DELETE FROM file_browser_size" + " WHERE FileBrowser IN (%u,%u,%u,%u)" + " AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_GRP, + (unsigned) Brw_ADMI_TCH_GRP, + (unsigned) Brw_ADMI_SHR_GRP, + (unsigned) Brw_ADMI_MRK_GRP, + GrpCod); + DB_QueryDELETE_new ("can not remove sizes of file zones of a group"); /***** Remove from database the entries that store the data files *****/ - if (asprintf (&Query,"DELETE FROM files" - " WHERE FileBrowser IN (%u,%u,%u,%u)" - " AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_GRP, - (unsigned) Brw_ADMI_TCH_GRP, - (unsigned) Brw_ADMI_SHR_GRP, - (unsigned) Brw_ADMI_MRK_GRP, - GrpCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove files of a group"); + DB_BuildQuery ("DELETE FROM files" + " WHERE FileBrowser IN (%u,%u,%u,%u)" + " AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_GRP, + (unsigned) Brw_ADMI_TCH_GRP, + (unsigned) Brw_ADMI_SHR_GRP, + (unsigned) Brw_ADMI_MRK_GRP, + GrpCod); + DB_QueryDELETE_new ("can not remove files of a group"); } /*****************************************************************************/ @@ -5098,68 +5045,60 @@ void Brw_RemoveGrpFilesFromDB (long GrpCod) void Brw_RemovePrjFilesFromDB (long PrjCod) { - char *Query; - /***** Remove from database the entries that store the file views *****/ - if (asprintf (&Query,"DELETE FROM file_view USING file_view,files" - " WHERE files.FileBrowser IN (%u,%u)" - " AND files.Cod=%ld" - " AND files.FilCod=file_view.FilCod", - (unsigned) Brw_ADMI_DOC_PRJ, - (unsigned) Brw_ADMI_ASS_PRJ, - PrjCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove file views to files of a project"); + DB_BuildQuery ("DELETE FROM file_view USING file_view,files" + " WHERE files.FileBrowser IN (%u,%u)" + " AND files.Cod=%ld" + " AND files.FilCod=file_view.FilCod", + (unsigned) Brw_ADMI_DOC_PRJ, + (unsigned) Brw_ADMI_ASS_PRJ, + PrjCod); + DB_QueryDELETE_new ("can not remove file views to files of a project"); /***** Remove from database expanded folders *****/ - if (asprintf (&Query,"DELETE LOW_PRIORITY FROM expanded_folders" + DB_BuildQuery ("DELETE LOW_PRIORITY FROM expanded_folders" " WHERE FileBrowser IN (%u,%u)" " AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_PRJ, - (unsigned) Brw_ADMI_ASS_PRJ, - PrjCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove expanded folders of a project"); + (unsigned) Brw_ADMI_DOC_PRJ, + (unsigned) Brw_ADMI_ASS_PRJ, + PrjCod); + DB_QueryDELETE_new ("can not remove expanded folders of a project"); /***** Remove from database the entries that store clipboards *****/ - if (asprintf (&Query,"DELETE FROM clipboard" - " WHERE FileBrowser IN (%u,%u)" - " AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_PRJ, - (unsigned) Brw_ADMI_ASS_PRJ, - PrjCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove clipboards related to files of a project"); + DB_BuildQuery ("DELETE FROM clipboard" + " WHERE FileBrowser IN (%u,%u)" + " AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_PRJ, + (unsigned) Brw_ADMI_ASS_PRJ, + PrjCod); + DB_QueryDELETE_new ("can not remove clipboards related to files of a project"); /***** Remove from database the entries that store the last time users visited file zones *****/ - if (asprintf (&Query,"DELETE FROM file_browser_last" - " WHERE FileBrowser IN (%u,%u)" - " AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_PRJ, - (unsigned) Brw_ADMI_ASS_PRJ, - PrjCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove file last visits to files of a project"); + DB_BuildQuery ("DELETE FROM file_browser_last" + " WHERE FileBrowser IN (%u,%u)" + " AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_PRJ, + (unsigned) Brw_ADMI_ASS_PRJ, + PrjCod); + DB_QueryDELETE_new ("can not remove file last visits to files of a project"); /***** Remove from database the entries that store the sizes of the file zones *****/ - if (asprintf (&Query,"DELETE FROM file_browser_size" - " WHERE FileBrowser IN (%u,%u)" - " AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_PRJ, - (unsigned) Brw_ADMI_ASS_PRJ, - PrjCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove sizes of file zones of a project"); + DB_BuildQuery ("DELETE FROM file_browser_size" + " WHERE FileBrowser IN (%u,%u)" + " AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_PRJ, + (unsigned) Brw_ADMI_ASS_PRJ, + PrjCod); + DB_QueryDELETE_new ("can not remove sizes of file zones of a project"); /***** Remove from database the entries that store the data files *****/ - if (asprintf (&Query,"DELETE FROM files" - " WHERE FileBrowser IN (%u,%u)" - " AND Cod=%ld", - (unsigned) Brw_ADMI_DOC_PRJ, - (unsigned) Brw_ADMI_ASS_PRJ, - PrjCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove files of a project"); + DB_BuildQuery ("DELETE FROM files" + " WHERE FileBrowser IN (%u,%u)" + " AND Cod=%ld", + (unsigned) Brw_ADMI_DOC_PRJ, + (unsigned) Brw_ADMI_ASS_PRJ, + PrjCod); + DB_QueryDELETE_new ("can not remove files of a project"); } /*****************************************************************************/ @@ -5168,96 +5107,91 @@ void Brw_RemovePrjFilesFromDB (long PrjCod) void Brw_RemoveSomeInfoAboutCrsUsrFilesFromDB (long UsrCod,long CrsCod) { - char *Query; - /***** Remove from database expanded folders *****/ - if (asprintf (&Query,"DELETE LOW_PRIORITY FROM expanded_folders" - " WHERE UsrCod=%ld AND (" - "(FileBrowser IN (%u,%u,%u,%u,%u,%u,%u,%u)" - " AND Cod=%ld)" - " OR " - "(FileBrowser IN (%u,%u,%u,%u)" - " AND Cod IN" - " (SELECT crs_grp.GrpCod FROM crs_grp_types,crs_grp" - " WHERE crs_grp_types.CrsCod=%ld" - " AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod))" - ")", - UsrCod, - (unsigned) Brw_ADMI_DOC_CRS, - (unsigned) Brw_ADMI_TCH_CRS, - (unsigned) Brw_ADMI_SHR_CRS, - (unsigned) Brw_ADMI_ASG_USR, - (unsigned) Brw_ADMI_ASG_CRS, - (unsigned) Brw_ADMI_WRK_USR, - (unsigned) Brw_ADMI_WRK_CRS, - (unsigned) Brw_ADMI_MRK_CRS, - CrsCod, - (unsigned) Brw_ADMI_DOC_GRP, - (unsigned) Brw_ADMI_TCH_GRP, - (unsigned) Brw_ADMI_SHR_GRP, - (unsigned) Brw_ADMI_MRK_GRP, - CrsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove expanded folders for a user in a course"); + DB_BuildQuery ("DELETE LOW_PRIORITY FROM expanded_folders" + " WHERE UsrCod=%ld AND (" + "(FileBrowser IN (%u,%u,%u,%u,%u,%u,%u,%u)" + " AND Cod=%ld)" + " OR " + "(FileBrowser IN (%u,%u,%u,%u)" + " AND Cod IN" + " (SELECT crs_grp.GrpCod FROM crs_grp_types,crs_grp" + " WHERE crs_grp_types.CrsCod=%ld" + " AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod))" + ")", + UsrCod, + (unsigned) Brw_ADMI_DOC_CRS, + (unsigned) Brw_ADMI_TCH_CRS, + (unsigned) Brw_ADMI_SHR_CRS, + (unsigned) Brw_ADMI_ASG_USR, + (unsigned) Brw_ADMI_ASG_CRS, + (unsigned) Brw_ADMI_WRK_USR, + (unsigned) Brw_ADMI_WRK_CRS, + (unsigned) Brw_ADMI_MRK_CRS, + CrsCod, + (unsigned) Brw_ADMI_DOC_GRP, + (unsigned) Brw_ADMI_TCH_GRP, + (unsigned) Brw_ADMI_SHR_GRP, + (unsigned) Brw_ADMI_MRK_GRP, + CrsCod); + DB_QueryDELETE_new ("can not remove expanded folders for a user in a course"); /***** Remove from database the entries that store clipboards *****/ - if (asprintf (&Query,"DELETE FROM clipboard" - " WHERE UsrCod=%ld AND (" - "(FileBrowser IN (%u,%u,%u,%u,%u,%u,%u,%u)" - " AND Cod=%ld)" - " OR " - "(FileBrowser IN (%u,%u,%u,%u)" - " AND Cod IN" - " (SELECT crs_grp.GrpCod FROM crs_grp_types,crs_grp" - " WHERE crs_grp_types.CrsCod=%ld" - " AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod))" - ")", - UsrCod, - (unsigned) Brw_ADMI_DOC_CRS, - (unsigned) Brw_ADMI_TCH_CRS, - (unsigned) Brw_ADMI_SHR_CRS, - (unsigned) Brw_ADMI_ASG_USR, - (unsigned) Brw_ADMI_ASG_CRS, - (unsigned) Brw_ADMI_WRK_USR, - (unsigned) Brw_ADMI_WRK_CRS, - (unsigned) Brw_ADMI_MRK_CRS, - CrsCod, - (unsigned) Brw_ADMI_DOC_GRP, - (unsigned) Brw_ADMI_TCH_GRP, - (unsigned) Brw_ADMI_SHR_GRP, - (unsigned) Brw_ADMI_MRK_GRP, - CrsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove source of copy for a user in a course"); + DB_BuildQuery ("DELETE FROM clipboard" + " WHERE UsrCod=%ld AND (" + "(FileBrowser IN (%u,%u,%u,%u,%u,%u,%u,%u)" + " AND Cod=%ld)" + " OR " + "(FileBrowser IN (%u,%u,%u,%u)" + " AND Cod IN" + " (SELECT crs_grp.GrpCod FROM crs_grp_types,crs_grp" + " WHERE crs_grp_types.CrsCod=%ld" + " AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod))" + ")", + UsrCod, + (unsigned) Brw_ADMI_DOC_CRS, + (unsigned) Brw_ADMI_TCH_CRS, + (unsigned) Brw_ADMI_SHR_CRS, + (unsigned) Brw_ADMI_ASG_USR, + (unsigned) Brw_ADMI_ASG_CRS, + (unsigned) Brw_ADMI_WRK_USR, + (unsigned) Brw_ADMI_WRK_CRS, + (unsigned) Brw_ADMI_MRK_CRS, + CrsCod, + (unsigned) Brw_ADMI_DOC_GRP, + (unsigned) Brw_ADMI_TCH_GRP, + (unsigned) Brw_ADMI_SHR_GRP, + (unsigned) Brw_ADMI_MRK_GRP, + CrsCod); + DB_QueryDELETE_new ("can not remove source of copy for a user in a course"); /***** Remove from database the entries that store the last time user visited file zones *****/ // Assignments and works are stored as one in file_browser_last... // ...because a user views them at the same time - if (asprintf (&Query,"DELETE FROM file_browser_last" - " WHERE UsrCod=%ld AND (" - "(FileBrowser IN (%u,%u,%u,%u,%u)" - " AND Cod=%ld)" - " OR " - "(FileBrowser IN (%u,%u,%u,%u)" - " AND Cod IN" - " (SELECT crs_grp.GrpCod FROM crs_grp_types,crs_grp" - " WHERE crs_grp_types.CrsCod=%ld" - " AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod))" - ")", - UsrCod, - (unsigned) Brw_ADMI_DOC_CRS, - (unsigned) Brw_ADMI_TCH_CRS, - (unsigned) Brw_ADMI_SHR_CRS, - (unsigned) Brw_ADMI_ASG_USR, - (unsigned) Brw_ADMI_MRK_CRS, - CrsCod, - (unsigned) Brw_ADMI_DOC_GRP, - (unsigned) Brw_ADMI_TCH_GRP, - (unsigned) Brw_ADMI_SHR_GRP, - (unsigned) Brw_ADMI_MRK_GRP, - CrsCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove file last visits to files of a course from a user"); + DB_BuildQuery ("DELETE FROM file_browser_last" + " WHERE UsrCod=%ld AND (" + "(FileBrowser IN (%u,%u,%u,%u,%u)" + " AND Cod=%ld)" + " OR " + "(FileBrowser IN (%u,%u,%u,%u)" + " AND Cod IN" + " (SELECT crs_grp.GrpCod FROM crs_grp_types,crs_grp" + " WHERE crs_grp_types.CrsCod=%ld" + " AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod))" + ")", + UsrCod, + (unsigned) Brw_ADMI_DOC_CRS, + (unsigned) Brw_ADMI_TCH_CRS, + (unsigned) Brw_ADMI_SHR_CRS, + (unsigned) Brw_ADMI_ASG_USR, + (unsigned) Brw_ADMI_MRK_CRS, + CrsCod, + (unsigned) Brw_ADMI_DOC_GRP, + (unsigned) Brw_ADMI_TCH_GRP, + (unsigned) Brw_ADMI_SHR_GRP, + (unsigned) Brw_ADMI_MRK_GRP, + CrsCod); + DB_QueryDELETE_new ("can not remove file last visits to files of a course from a user"); } /*****************************************************************************/ @@ -5266,58 +5200,51 @@ void Brw_RemoveSomeInfoAboutCrsUsrFilesFromDB (long UsrCod,long CrsCod) void Brw_RemoveWrkFilesFromDB (long CrsCod,long UsrCod) { - char *Query; - /***** Remove from database the entries that store the file views *****/ - if (asprintf (&Query,"DELETE FROM file_view USING file_view,files" - " WHERE files.FileBrowser IN (%u,%u)" - " AND files.Cod=%ld AND files.ZoneUsrCod=%ld" - " AND files.FilCod=file_view.FilCod", - (unsigned) Brw_ADMI_ASG_USR, - (unsigned) Brw_ADMI_WRK_USR, - CrsCod,UsrCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove file views"); + DB_BuildQuery ("DELETE FROM file_view USING file_view,files" + " WHERE files.FileBrowser IN (%u,%u)" + " AND files.Cod=%ld AND files.ZoneUsrCod=%ld" + " AND files.FilCod=file_view.FilCod", + (unsigned) Brw_ADMI_ASG_USR, + (unsigned) Brw_ADMI_WRK_USR, + CrsCod,UsrCod); + DB_QueryDELETE_new ("can not remove file views"); /***** Remove from database expanded folders *****/ - if (asprintf (&Query,"DELETE LOW_PRIORITY FROM expanded_folders" - " WHERE FileBrowser IN (%u,%u)" - " AND Cod=%ld AND WorksUsrCod=%ld", - (unsigned) Brw_ADMI_ASG_CRS, - (unsigned) Brw_ADMI_WRK_CRS, - CrsCod,UsrCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove expanded folders of a group"); + DB_BuildQuery ("DELETE LOW_PRIORITY FROM expanded_folders" + " WHERE FileBrowser IN (%u,%u)" + " AND Cod=%ld AND WorksUsrCod=%ld", + (unsigned) Brw_ADMI_ASG_CRS, + (unsigned) Brw_ADMI_WRK_CRS, + CrsCod,UsrCod); + DB_QueryDELETE_new ("can not remove expanded folders of a group"); /***** Remove from database the entries that store clipboards *****/ - if (asprintf (&Query,"DELETE FROM clipboard" - " WHERE FileBrowser IN (%u,%u)" - " AND Cod=%ld AND WorksUsrCod=%ld", - (unsigned) Brw_ADMI_ASG_CRS, - (unsigned) Brw_ADMI_WRK_CRS, - CrsCod,UsrCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove clipboards"); + DB_BuildQuery ("DELETE FROM clipboard" + " WHERE FileBrowser IN (%u,%u)" + " AND Cod=%ld AND WorksUsrCod=%ld", + (unsigned) Brw_ADMI_ASG_CRS, + (unsigned) Brw_ADMI_WRK_CRS, + CrsCod,UsrCod); + DB_QueryDELETE_new ("can not remove clipboards"); /***** Remove from database the entries that store the sizes of the file zones *****/ - if (asprintf (&Query,"DELETE FROM file_browser_size" - " WHERE FileBrowser IN (%u,%u)" - " AND Cod=%ld AND ZoneUsrCod=%ld", - (unsigned) Brw_ADMI_ASG_USR, - (unsigned) Brw_ADMI_WRK_USR, - CrsCod,UsrCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove file browser sizes"); + DB_BuildQuery ("DELETE FROM file_browser_size" + " WHERE FileBrowser IN (%u,%u)" + " AND Cod=%ld AND ZoneUsrCod=%ld", + (unsigned) Brw_ADMI_ASG_USR, + (unsigned) Brw_ADMI_WRK_USR, + CrsCod,UsrCod); + DB_QueryDELETE_new ("can not remove file browser sizes"); /***** Remove from database the entries that store the data files *****/ - if (asprintf (&Query,"DELETE FROM files" - " WHERE FileBrowser IN (%u,%u)" - " AND Cod=%ld AND ZoneUsrCod=%ld", - (unsigned) Brw_ADMI_ASG_USR, - (unsigned) Brw_ADMI_WRK_USR, - CrsCod,UsrCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove files"); + DB_BuildQuery ("DELETE FROM files" + " WHERE FileBrowser IN (%u,%u)" + " AND Cod=%ld AND ZoneUsrCod=%ld", + (unsigned) Brw_ADMI_ASG_USR, + (unsigned) Brw_ADMI_WRK_USR, + CrsCod,UsrCod); + DB_QueryDELETE_new ("can not remove files"); } /*****************************************************************************/ @@ -5326,52 +5253,44 @@ void Brw_RemoveWrkFilesFromDB (long CrsCod,long UsrCod) void Brw_RemoveUsrFilesFromDB (long UsrCod) { - char *Query; - /***** Remove from database the entries that store the file views *****/ // User is not removed from file_view table, // in order to take into account his/her views - if (asprintf (&Query,"DELETE FROM file_view USING file_view,files" - " WHERE files.ZoneUsrCod=%ld" - " AND files.FilCod=file_view.FilCod", - UsrCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove file views to files of a user"); + DB_BuildQuery ("DELETE FROM file_view USING file_view,files" + " WHERE files.ZoneUsrCod=%ld" + " AND files.FilCod=file_view.FilCod", + UsrCod); + DB_QueryDELETE_new ("can not remove file views to files of a user"); /***** Remove from database expanded folders *****/ - if (asprintf (&Query,"DELETE LOW_PRIORITY FROM expanded_folders" - " WHERE UsrCod=%ld", - UsrCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove expanded folders for a user"); + DB_BuildQuery ("DELETE LOW_PRIORITY FROM expanded_folders" + " WHERE UsrCod=%ld", + UsrCod); + DB_QueryDELETE_new ("can not remove expanded folders for a user"); /***** Remove from database the entries that store clipboards *****/ - if (asprintf (&Query,"DELETE FROM clipboard" - " WHERE UsrCod=%ld", // User's clipboard - UsrCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove user's clipboards"); + DB_BuildQuery ("DELETE FROM clipboard" + " WHERE UsrCod=%ld", // User's clipboard + UsrCod); + DB_QueryDELETE_new ("can not remove user's clipboards"); /***** Remove from database the entries that store the last time users visited file zones *****/ - if (asprintf (&Query,"DELETE FROM file_browser_last" - " WHERE UsrCod=%ld", // User's last visits to all zones - UsrCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove user's last visits to file zones"); + DB_BuildQuery ("DELETE FROM file_browser_last" + " WHERE UsrCod=%ld", // User's last visits to all zones + UsrCod); + DB_QueryDELETE_new ("can not remove user's last visits to file zones"); /***** Remove from database the entries that store the sizes of the file zones *****/ - if (asprintf (&Query,"DELETE FROM file_browser_size" - " WHERE ZoneUsrCod=%ld", - UsrCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove sizes of user's file zones"); + DB_BuildQuery ("DELETE FROM file_browser_size" + " WHERE ZoneUsrCod=%ld", + UsrCod); + DB_QueryDELETE_new ("can not remove sizes of user's file zones"); /***** Remove from database the entries that store the data files *****/ - if (asprintf (&Query,"DELETE FROM files" - " WHERE ZoneUsrCod=%ld", - UsrCod) < 0) - Lay_NotEnoughMemoryExit (); - DB_QueryDELETE_free (Query,"can not remove files in user's file zones"); + DB_BuildQuery ("DELETE FROM files" + " WHERE ZoneUsrCod=%ld", + UsrCod); + DB_QueryDELETE_new ("can not remove files in user's file zones"); } /*****************************************************************************/ @@ -8080,42 +7999,32 @@ static void Brw_RemoveFolderFromExpandedFolders (const char Path[PATH_MAX + 1]) { long Cod = Brw_GetCodForExpandedFolders (); long WorksUsrCod = Brw_GetWorksUsrCodForExpandedFolders (); - char *Query; Brw_FileBrowser_t FileBrowserForExpandedFolders = Brw_FileBrowserForDB_expanded_folders[Gbl.FileBrowser.Type]; /***** Remove expanded folders associated to a file browser *****/ if (Cod > 0) { if (WorksUsrCod > 0) - { - if (asprintf (&Query,"DELETE FROM expanded_folders" - " WHERE UsrCod=%ld AND FileBrowser=%u" - " AND Cod=%ld AND WorksUsrCod=%ld AND Path='%s/'", - Gbl.Usrs.Me.UsrDat.UsrCod,(unsigned) FileBrowserForExpandedFolders, - Cod,WorksUsrCod,Path) < 0) - Lay_NotEnoughMemoryExit (); - } + DB_BuildQuery ("DELETE FROM expanded_folders" + " WHERE UsrCod=%ld AND FileBrowser=%u" + " AND Cod=%ld AND WorksUsrCod=%ld AND Path='%s/'", + Gbl.Usrs.Me.UsrDat.UsrCod,(unsigned) FileBrowserForExpandedFolders, + Cod,WorksUsrCod,Path); else - { - if (asprintf (&Query,"DELETE FROM expanded_folders" - " WHERE UsrCod=%ld AND FileBrowser=%u" - " AND Cod=%ld AND Path='%s/'", - Gbl.Usrs.Me.UsrDat.UsrCod, - (unsigned) FileBrowserForExpandedFolders, - Cod,Path) < 0) - Lay_NotEnoughMemoryExit (); - } + DB_BuildQuery ("DELETE FROM expanded_folders" + " WHERE UsrCod=%ld AND FileBrowser=%u" + " AND Cod=%ld AND Path='%s/'", + Gbl.Usrs.Me.UsrDat.UsrCod, + (unsigned) FileBrowserForExpandedFolders, + Cod,Path); } else // Briefcase - { - if (asprintf (&Query,"DELETE FROM expanded_folders" - " WHERE UsrCod=%ld AND FileBrowser=%u" - " AND Path='%s/'", - Gbl.Usrs.Me.UsrDat.UsrCod,(unsigned) FileBrowserForExpandedFolders, - Path) < 0) - Lay_NotEnoughMemoryExit (); - } - DB_QueryDELETE_free (Query,"can not contract the content of a folder"); + DB_BuildQuery ("DELETE FROM expanded_folders" + " WHERE UsrCod=%ld AND FileBrowser=%u" + " AND Path='%s/'", + Gbl.Usrs.Me.UsrDat.UsrCod,(unsigned) FileBrowserForExpandedFolders, + Path); + DB_QueryDELETE_new ("can not contract the content of a folder"); } /*****************************************************************************/ @@ -8126,42 +8035,32 @@ static void Brw_RemoveAffectedExpandedFolders (const char Path[PATH_MAX + 1]) { long Cod = Brw_GetCodForExpandedFolders (); long WorksUsrCod = Brw_GetWorksUsrCodForExpandedFolders (); - char *Query; Brw_FileBrowser_t FileBrowserForExpandedFolders = Brw_FileBrowserForDB_expanded_folders[Gbl.FileBrowser.Type]; /***** Remove expanded folders associated to a file browser from a course or from a user *****/ if (Cod > 0) { if (WorksUsrCod > 0) - { - if (asprintf (&Query,"DELETE FROM expanded_folders" - " WHERE UsrCod=%ld AND FileBrowser=%u" - " AND Cod=%ld AND WorksUsrCod=%ld AND Path LIKE '%s/%%'", - Gbl.Usrs.Me.UsrDat.UsrCod,(unsigned) FileBrowserForExpandedFolders, - Cod,WorksUsrCod,Path) < 0) - Lay_NotEnoughMemoryExit (); - } + DB_BuildQuery ("DELETE FROM expanded_folders" + " WHERE UsrCod=%ld AND FileBrowser=%u" + " AND Cod=%ld AND WorksUsrCod=%ld AND Path LIKE '%s/%%'", + Gbl.Usrs.Me.UsrDat.UsrCod,(unsigned) FileBrowserForExpandedFolders, + Cod,WorksUsrCod,Path); else - { - if (asprintf (&Query,"DELETE FROM expanded_folders" - " WHERE UsrCod=%ld AND FileBrowser=%u" - " AND Cod=%ld AND Path LIKE '%s/%%'", - Gbl.Usrs.Me.UsrDat.UsrCod, - (unsigned) FileBrowserForExpandedFolders, - Cod,Path) < 0) - Lay_NotEnoughMemoryExit (); - } + DB_BuildQuery ("DELETE FROM expanded_folders" + " WHERE UsrCod=%ld AND FileBrowser=%u" + " AND Cod=%ld AND Path LIKE '%s/%%'", + Gbl.Usrs.Me.UsrDat.UsrCod, + (unsigned) FileBrowserForExpandedFolders, + Cod,Path); } else // Briefcase - { - if (asprintf (&Query,"DELETE FROM expanded_folders" - " WHERE UsrCod=%ld AND FileBrowser=%u" - " AND Path LIKE '%s/%%'", - Gbl.Usrs.Me.UsrDat.UsrCod,(unsigned) FileBrowserForExpandedFolders, - Path) < 0) - Lay_NotEnoughMemoryExit (); - } - DB_QueryDELETE_free (Query,"can not remove expanded folders"); + DB_BuildQuery ("DELETE FROM expanded_folders" + " WHERE UsrCod=%ld AND FileBrowser=%u" + " AND Path LIKE '%s/%%'", + Gbl.Usrs.Me.UsrDat.UsrCod,(unsigned) FileBrowserForExpandedFolders, + Path); + DB_QueryDELETE_new ("can not remove expanded folders"); } /*****************************************************************************/ @@ -8331,14 +8230,11 @@ static long Brw_GetWorksUsrCodForExpandedFolders (void) void Brw_RemoveExpiredExpandedFolders (void) { - char *Query; - /***** Remove all expired clipboards *****/ - if (asprintf (&Query,"DELETE LOW_PRIORITY FROM expanded_folders" - " WHERE ClickTime