From e081f1fc4d71d16e2a3419696b6fafcd2bf91f11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Thu, 27 Oct 2016 23:38:53 +0200 Subject: [PATCH] Version 16.45.4 --- swad_changelog.h | 3 ++- swad_course.c | 2 +- swad_degree.c | 33 ++------------------------------- swad_forum.c | 40 ++++++++++++++++++++++++++++++++++++++++ swad_forum.h | 1 + 5 files changed, 46 insertions(+), 33 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 9662519dc..bdfe08c6d 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -154,13 +154,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.45.3 (2016-10-27)" +#define Log_PLATFORM_VERSION "SWAD 16.45.4 (2016-10-27)" #define CSS_FILE "swad16.32.1.css" #define JS_FILE "swad15.238.1.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 16.45.4: Oct 27, 2016 Code refactoring in degree forums. (205916 lines) Version 16.45.3: Oct 27, 2016 Code refactoring in course forums. (205906 lines) Version 16.45.2: Oct 27, 2016 Code refactoring related with scopes. (205896 lines) Version 16.45.1: Oct 27, 2016 Fixed bugs in surveys. (? lines) diff --git a/swad_course.c b/swad_course.c index 4841d53da..5e3079418 100644 --- a/swad_course.c +++ b/swad_course.c @@ -2244,7 +2244,7 @@ static void Crs_EmptyCourseCompletely (long CrsCod) sprintf (Query,"DELETE FROM notices WHERE CrsCod='%ld'",CrsCod); DB_QueryDELETE (Query,"can not remove notices in a course"); - /***** Remove all the threads and posts in forums of a course *****/ + /***** Remove all the threads and posts in forums of the course *****/ For_RemoveCrsForums (CrsCod); /***** Remove all test exams made in the course *****/ diff --git a/swad_degree.c b/swad_degree.c index c2ed75255..c28af1921 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -2289,37 +2289,8 @@ void Deg_RemoveDegreeCompletely (long DegCod) already removed) *****/ Svy_RemoveSurveys (Sco_SCOPE_DEG,DegCod); - /***** Remove all the threads and posts in degree forums *****/ - /* Remove disabled posts */ - sprintf (Query,"DELETE FROM forum_disabled_post" - " USING forum_thread,forum_post,forum_disabled_post" - " WHERE (forum_thread.ForumType='%u' OR forum_thread.ForumType='%u')" - " AND forum_thread.Location='%ld' AND forum_thread.ThrCod=forum_post.ThrCod AND forum_post.PstCod=forum_disabled_post.PstCod", - For_FORUM_DEGREE_USRS,For_FORUM_DEGREE_TCHS,DegCod); - DB_QueryDELETE (Query,"can not remove the disabled posts in forums of a degree"); - - /* Remove posts */ - sprintf (Query,"DELETE FROM forum_post" - " USING forum_thread,forum_post" - " WHERE (forum_thread.ForumType='%u' OR forum_thread.ForumType='%u')" - " AND forum_thread.Location='%ld' AND forum_thread.ThrCod=forum_post.ThrCod", - For_FORUM_DEGREE_USRS,For_FORUM_DEGREE_TCHS,DegCod); - DB_QueryDELETE (Query,"can not remove posts in forums of a degree"); - - /* Remove threads read */ - sprintf (Query,"DELETE FROM forum_thr_read" - " USING forum_thread,forum_thr_read" - " WHERE (forum_thread.ForumType='%u' OR forum_thread.ForumType='%u')" - " AND forum_thread.Location='%ld' AND forum_thread.ThrCod=forum_thr_read.ThrCod", - For_FORUM_DEGREE_USRS,For_FORUM_DEGREE_TCHS,DegCod); - DB_QueryDELETE (Query,"can not remove read threads in forums of a degree"); - - /* Remove threads */ - sprintf (Query,"DELETE FROM forum_thread" - " WHERE (forum_thread.ForumType='%u' OR forum_thread.ForumType='%u')" - " AND Location='%ld'", - For_FORUM_DEGREE_USRS,For_FORUM_DEGREE_TCHS,DegCod); - DB_QueryDELETE (Query,"can not remove threads in forums of a degree"); + /***** Remove all the threads and posts in forums of the degree *****/ + For_RemoveDegForums (DegCod); /***** Remove information related to files in degree *****/ Brw_RemoveDegFilesFromDB (DegCod); diff --git a/swad_forum.c b/swad_forum.c index b5e5b8459..4222dfbf8 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -4413,6 +4413,46 @@ void For_RemoveUsrFromThrClipboard (long UsrCod) DB_QueryDELETE (Query,"can not remove a thread from the clipboard of a user"); } +/*****************************************************************************/ +/********** Remove all the threads and posts in forums of a degree ***********/ +/*****************************************************************************/ + +void For_RemoveDegForums (long DegCod) + { + char Query[512]; + + /***** Remove disabled posts *****/ + sprintf (Query,"DELETE FROM forum_disabled_post" + " USING forum_thread,forum_post,forum_disabled_post" + " WHERE (forum_thread.ForumType='%u' OR forum_thread.ForumType='%u')" + " AND forum_thread.Location='%ld' AND forum_thread.ThrCod=forum_post.ThrCod AND forum_post.PstCod=forum_disabled_post.PstCod", + For_FORUM_DEGREE_USRS,For_FORUM_DEGREE_TCHS,DegCod); + DB_QueryDELETE (Query,"can not remove the disabled posts in forums of a degree"); + + /***** Remove posts *****/ + sprintf (Query,"DELETE FROM forum_post" + " USING forum_thread,forum_post" + " WHERE (forum_thread.ForumType='%u' OR forum_thread.ForumType='%u')" + " AND forum_thread.Location='%ld' AND forum_thread.ThrCod=forum_post.ThrCod", + For_FORUM_DEGREE_USRS,For_FORUM_DEGREE_TCHS,DegCod); + DB_QueryDELETE (Query,"can not remove posts in forums of a degree"); + + /***** Remove threads read *****/ + sprintf (Query,"DELETE FROM forum_thr_read" + " USING forum_thread,forum_thr_read" + " WHERE (forum_thread.ForumType='%u' OR forum_thread.ForumType='%u')" + " AND forum_thread.Location='%ld' AND forum_thread.ThrCod=forum_thr_read.ThrCod", + For_FORUM_DEGREE_USRS,For_FORUM_DEGREE_TCHS,DegCod); + DB_QueryDELETE (Query,"can not remove read threads in forums of a degree"); + + /***** Remove threads *****/ + sprintf (Query,"DELETE FROM forum_thread" + " WHERE (forum_thread.ForumType='%u' OR forum_thread.ForumType='%u')" + " AND Location='%ld'", + For_FORUM_DEGREE_USRS,For_FORUM_DEGREE_TCHS,DegCod); + DB_QueryDELETE (Query,"can not remove threads in forums of a degree"); + } + /*****************************************************************************/ /********** Remove all the threads and posts in forums of a course ***********/ /*****************************************************************************/ diff --git a/swad_forum.h b/swad_forum.h index dde44dd4f..d83a5ac95 100644 --- a/swad_forum.h +++ b/swad_forum.h @@ -140,6 +140,7 @@ void For_RemoveExpiredThrsClipboards (void); void For_RemoveThrCodFromThrClipboard (long ThrCod); void For_RemoveUsrFromThrClipboard (long UsrCod); +void For_RemoveDegForums (long DegCod); void For_RemoveCrsForums (long CrsCod); #endif