Version 18.8.16

This commit is contained in:
Antonio Cañas Vargas 2018-10-28 21:10:00 +01:00
parent 6a40059e0d
commit 9d7b46ffc3
12 changed files with 710 additions and 886 deletions

View File

@ -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),

View File

@ -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),

View File

@ -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)

View File

@ -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");
}
/*****************************************************************************/

View File

@ -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 ();

View File

@ -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),

View File

@ -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 ();

View File

@ -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");
}
/*****************************************************************************/

View File

@ -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),

View File

@ -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");
}

View File

@ -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,

File diff suppressed because it is too large Load Diff