diff --git a/swad_account.c b/swad_account.c index 93b4e1b3c..b97fe372f 100644 --- a/swad_account.c +++ b/swad_account.c @@ -998,6 +998,9 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat, /***** Remove the fields of course record in all courses *****/ Rec_RemoveFieldsCrsRecordAll (UsrDat->UsrCod); + /***** Remove user from all his/her projects *****/ + Prj_RemoveUsrFromProjects (UsrDat->UsrCod); + /***** Remove user from all the attendance events *****/ Att_RemoveUsrFromAllAttEvents (UsrDat->UsrCod); diff --git a/swad_changelog.h b/swad_changelog.h index 5a22ff476..6bb3716ef 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -252,13 +252,18 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 17.10 (2017-09-24)" +#define Log_PLATFORM_VERSION "SWAD 17.10.1 (2017-09-24)" #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.10.3: Sep 24, 2017 TODO: Add users to projects even if they don't belong to course. (? lines) + Version 17.10.2: Sep 24, 2017 TODO: Check permission when editing projects. + TODO: Check permission when removing a user from a project. (? lines) + Version 17.10.1: Sep 24, 2017 Remove user in project when removing the user. + Remove projects (and users in them) in a course when removing the course. (231345 lines) Version 17.10: Sep 24, 2017 Changes in permissions to view/edit projects. Show project URL in listings of projects. (231319 lines) Version 17.9.4: Sep 24, 2017 Changes in listing of projects. (231216 lines) diff --git a/swad_course.c b/swad_course.c index 3f7ca8cae..3337f6466 100644 --- a/swad_course.c +++ b/swad_course.c @@ -2194,6 +2194,9 @@ static void Crs_EmptyCourseCompletely (long CrsCod) /***** Remove assignments of the course *****/ Asg_RemoveCrsAssignments (CrsCod); + /***** Remove projects of the course *****/ + Prj_RemoveCrsProjects (CrsCod); + /***** Remove attendance events of the course *****/ Att_RemoveCrsAttEvents (CrsCod); diff --git a/swad_project.c b/swad_project.c index 455e028e7..dc2427a55 100644 --- a/swad_project.c +++ b/swad_project.c @@ -956,7 +956,7 @@ static void Prj_ShowOneProjectWriteUsrs (long PrjCod,Prj_ProjectView_t ProjectVi NumUsrs = Prj_GetUsrsInPrj (PrjCod,RoleInProject,&mysql_res); /***** Start table *****/ - fprintf (Gbl.F.Out,""); + Tbl_StartTable (2); /***** Write users *****/ for (NumUsr = 0; @@ -1025,7 +1025,7 @@ static void Prj_ShowOneProjectWriteUsrs (long PrjCod,Prj_ProjectView_t ProjectVi } /***** End table *****/ - fprintf (Gbl.F.Out,"
"); + Tbl_EndTable (); /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); @@ -2415,18 +2415,38 @@ static void Prj_UpdateProject (struct Project *Prj) } /*****************************************************************************/ -/******************** Remove all the projects of a course ********************/ +/******************** Remove all the projects in a course ********************/ /*****************************************************************************/ void Prj_RemoveCrsProjects (long CrsCod) { - char Query[512]; + char Query[256]; + + /***** Remove users in projects of the course *****/ + sprintf (Query,"DELETE FROM prj_usr USING projects,prj_usr" + " WHERE projects.CrsCod=%ld" + " AND projects.PrjCod=prj_usr.PrjCod", + CrsCod); + DB_QueryDELETE (Query,"can not remove all the projects of a course"); /***** Remove projects *****/ sprintf (Query,"DELETE FROM projects WHERE CrsCod=%ld",CrsCod); DB_QueryDELETE (Query,"can not remove all the projects of a course"); } +/*****************************************************************************/ +/******************* Remove user from all his/her projects *******************/ +/*****************************************************************************/ + +void Prj_RemoveUsrFromProjects (long UsrCod) + { + char Query[128]; + + /***** Remove user from projects *****/ + sprintf (Query,"DELETE FROM prj_usr WHERE UsrCod=%ld",UsrCod); + DB_QueryDELETE (Query,"can not remove user from projects"); + } + /*****************************************************************************/ /******************** Get number of projects in a course *********************/ /*****************************************************************************/ diff --git a/swad_project.h b/swad_project.h index 338c344b0..198352227 100644 --- a/swad_project.h +++ b/swad_project.h @@ -121,9 +121,11 @@ void Prj_RemoveProject (void); void Prj_HideProject (void); void Prj_ShowProject (void); void Prj_RecFormProject (void); -void Prj_RemoveCrsProjects (long CrsCod); -unsigned Prj_GetNumProjectsInCrs(long CrsCod); +void Prj_RemoveCrsProjects (long CrsCod); +void Prj_RemoveUsrFromProjects (long UsrCod); + +unsigned Prj_GetNumProjectsInCrs(long CrsCod); unsigned Prj_GetNumCoursesWithProjects (Sco_Scope_t Scope); unsigned Prj_GetNumProjects (Sco_Scope_t Scope);