From 6bc7833226662a58613be9e9f92e39072f495535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Thu, 21 Sep 2017 12:43:35 +0200 Subject: [PATCH] Version 17.5.1 --- swad_changelog.h | 4 +++- swad_project.c | 29 ++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index df2261633..ce471df70 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -252,13 +252,15 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 17.5 (2017-09-21)" +#define Log_PLATFORM_VERSION "SWAD 17.5.1 (2017-09-21)" #define CSS_FILE "swad17.0.css" #define JS_FILE "swad16.206.3.js" // Number of lines (includes comments but not blank lines) has been got with the following command: // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1 /* + Version 17.5.2: Sep 21, 2017 Do not display users when creating a new project. (? lines) + Version 17.5.1: Sep 21, 2017 Fixed bug when removing a project. (230267 lines) Version 17.5: Sep 21, 2017 Users can be added to a project. (230250 lines) Version 17.4.3: Sep 21, 2017 Changes in listing and edition of projects. (230222 lines) Version 17.4.2: Sep 20, 2017 Changes in listing and edition of projects. (230203 lines) diff --git a/swad_project.c b/swad_project.c index 607190cd7..e2c9c35dc 100644 --- a/swad_project.c +++ b/swad_project.c @@ -1117,7 +1117,7 @@ long Prj_GetParamPrjCod (void) } /*****************************************************************************/ -/*************** Ask for confirmation of removing a project ******************/ +/**************** Ask for confirmation of removing a project *****************/ /*****************************************************************************/ void Prj_ReqRemProject (void) @@ -1126,11 +1126,12 @@ void Prj_ReqRemProject (void) extern const char *Txt_Remove_project; struct Project Prj; + /***** Allocate memory for the project *****/ + Prj_AllocMemProject (&Prj); + /***** Get parameters *****/ Prj_GetParamPrjOrder (); Gbl.Prjs.CurrentPage = Pag_GetParamPagNum (Pag_PROJECTS); - - /***** Get project code *****/ if ((Prj.PrjCod = Prj_GetParamPrjCod ()) == -1L) Lay_ShowErrorAndExit ("Code of project is missing."); @@ -1145,6 +1146,9 @@ void Prj_ReqRemProject (void) ActRemPrj,NULL,NULL,Prj_PutParams, Btn_REMOVE_BUTTON,Txt_Remove_project); + /***** Free memory of the project *****/ + Prj_FreeMemProject (&Prj); + /***** Show projects again *****/ Prj_SeeProjects (); } @@ -1156,16 +1160,28 @@ void Prj_ReqRemProject (void) void Prj_RemoveProject (void) { extern const char *Txt_Project_X_removed; - char Query[512]; + char Query[256]; struct Project Prj; - /***** Get project code *****/ + /***** Allocate memory for the project *****/ + Prj_AllocMemProject (&Prj); + + /***** Get parameters *****/ + Prj_GetParamPrjOrder (); + Gbl.Prjs.CurrentPage = Pag_GetParamPagNum (Pag_PROJECTS); if ((Prj.PrjCod = Prj_GetParamPrjCod ()) == -1L) Lay_ShowErrorAndExit ("Code of project is missing."); /***** Get data of the project from database *****/ Prj_GetDataOfProjectByCod (&Prj); // Inside this function, the course is checked to be the current one + /***** Remove users in project *****/ + sprintf (Query,"DELETE FROM prj_usr USING projects,prj_usr" + " WHERE projects.PrjCod=%ld AND projects.CrsCod=%ld" + " AND projects.PrjCod=prj_usr.PrjCod", + Prj.PrjCod,Gbl.CurrentCrs.Crs.CrsCod); + DB_QueryDELETE (Query,"can not remove project"); + /***** Remove project *****/ sprintf (Query,"DELETE FROM projects" " WHERE PrjCod=%ld AND CrsCod=%ld", @@ -1177,6 +1193,9 @@ void Prj_RemoveProject (void) Prj.Title); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); + /***** Free memory of the project *****/ + Prj_FreeMemProject (&Prj); + /***** Show projects again *****/ Prj_SeeProjects (); }