From 79de994a4b87e678cf08c508690401c575575b71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Thu, 27 Oct 2016 22:26:52 +0200 Subject: [PATCH] Version 16.45.3 --- swad_changelog.h | 3 ++- swad_course.c | 35 ++--------------------------------- swad_forum.c | 42 ++++++++++++++++++++++++++++++++++++++++++ swad_forum.h | 2 ++ swad_survey.h | 2 +- 5 files changed, 49 insertions(+), 35 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index c95490b0d..9662519dc 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -154,13 +154,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.45.2 (2016-10-27)" +#define Log_PLATFORM_VERSION "SWAD 16.45.3 (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.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) Version 16.45: Oct 27, 2016 Changes in database table for surveys. Not finished. (205927 lines) diff --git a/swad_course.c b/swad_course.c index 641926798..4841d53da 100644 --- a/swad_course.c +++ b/swad_course.c @@ -2244,39 +2244,8 @@ 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 course 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_COURSE_USRS,For_FORUM_COURSE_TCHS,CrsCod); - DB_QueryDELETE (Query,"can not remove disabled posts in forums of a course"); - - /* 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_COURSE_USRS,For_FORUM_COURSE_TCHS,CrsCod); - DB_QueryDELETE (Query,"can not remove posts in forums of a course"); - - /* 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_COURSE_USRS,For_FORUM_COURSE_TCHS,CrsCod); - DB_QueryDELETE (Query,"can not remove read threads in forums of a course"); - - /* Remove threads */ - sprintf (Query,"DELETE FROM forum_thread" - " WHERE (forum_thread.ForumType='%u' OR forum_thread.ForumType='%u')" - " AND Location='%ld'", - For_FORUM_COURSE_USRS,For_FORUM_COURSE_TCHS,CrsCod); - DB_QueryDELETE (Query,"can not remove threads in forums of a course"); + /***** Remove all the threads and posts in forums of a course *****/ + For_RemoveCrsForums (CrsCod); /***** Remove all test exams made in the course *****/ Tst_RemoveCrsExams (CrsCod); diff --git a/swad_forum.c b/swad_forum.c index 936a52b73..b5e5b8459 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -4412,3 +4412,45 @@ void For_RemoveUsrFromThrClipboard (long UsrCod) sprintf (Query,"DELETE FROM forum_thr_clip WHERE UsrCod='%ld'",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 course ***********/ +/*****************************************************************************/ + +void For_RemoveCrsForums (long CrsCod) + { + 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_COURSE_USRS,For_FORUM_COURSE_TCHS,CrsCod); + DB_QueryDELETE (Query,"can not remove disabled posts in forums of a course"); + + /***** 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_COURSE_USRS,For_FORUM_COURSE_TCHS,CrsCod); + DB_QueryDELETE (Query,"can not remove posts in forums of a course"); + + /***** 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_COURSE_USRS,For_FORUM_COURSE_TCHS,CrsCod); + DB_QueryDELETE (Query,"can not remove read threads in forums of a course"); + + /***** Remove threads *****/ + sprintf (Query,"DELETE FROM forum_thread" + " WHERE (forum_thread.ForumType='%u' OR forum_thread.ForumType='%u')" + " AND Location='%ld'", + For_FORUM_COURSE_USRS,For_FORUM_COURSE_TCHS,CrsCod); + DB_QueryDELETE (Query,"can not remove threads in forums of a course"); + } diff --git a/swad_forum.h b/swad_forum.h index d55a5fce2..dde44dd4f 100644 --- a/swad_forum.h +++ b/swad_forum.h @@ -140,4 +140,6 @@ void For_RemoveExpiredThrsClipboards (void); void For_RemoveThrCodFromThrClipboard (long ThrCod); void For_RemoveUsrFromThrClipboard (long UsrCod); +void For_RemoveCrsForums (long CrsCod); + #endif diff --git a/swad_survey.h b/swad_survey.h index c7cf704d8..853800184 100644 --- a/swad_survey.h +++ b/swad_survey.h @@ -98,7 +98,7 @@ void Svy_RecFormSurvey (void); bool Svy_CheckIfSvyIsAssociatedToGrp (long SvyCod,long GrpCod); void Svy_RemoveGroup (long GrpCod); void Svy_RemoveGroupsOfType (long GrpTypCod); -void Svy_RemoveSurveys (long CrsCod); +void Svy_RemoveSurveys (Sco_Scope_t Scope,long Cod); void Svy_RequestEditQuestion (void); void Svy_ReceiveQst (void);