From 3cad8a3f0a7de4fa273efe5cc69b80606a8b08b1 Mon Sep 17 00:00:00 2001 From: acanas Date: Mon, 1 Mar 2021 15:23:18 +0100 Subject: [PATCH] Version 20.36.45: Mar 01, 2021 Queries moved to module swad_timeline_database. --- swad_changelog.h | 3 ++- swad_timeline_database.c | 42 ++++++++++++++++++++++++++++++++++++---- swad_timeline_database.h | 2 ++ swad_timeline_user.c | 38 ++++++++---------------------------- 4 files changed, 50 insertions(+), 35 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 3916bd73..3a64ba57 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -553,7 +553,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 20.36.44 (2021-03-01)" +#define Log_PLATFORM_VERSION "SWAD 20.36.45 (2021-03-01)" #define CSS_FILE "swad20.33.9.css" #define JS_FILE "swad20.6.2.js" /* @@ -601,6 +601,7 @@ TODO: DNI de un estudiante sale err TODO: BUG: Cuando un tipo de grupo sólo tiene un grupo, inscribirse es voluntario, el estudiante sólo puede pertenecer a un grupo, y se inscribe en él, debería poder desapuntarse. Ahora no puede. TODO: Salvador Romero Cortés: @acanas opción para editar posts + Version 20.36.45: Mar 01, 2021 Queries moved to module swad_timeline_database. (305528 lines) Version 20.36.44: Mar 01, 2021 Query moved to module swad_timeline_database. (305516 lines) Version 20.36.43: Mar 01, 2021 Query moved to module swad_timeline_database. (305489 lines) Version 20.36.42: Mar 01, 2021 Query moved to module swad_timeline_database. (305476 lines) diff --git a/swad_timeline_database.c b/swad_timeline_database.c index c97e6950..ce4d871e 100644 --- a/swad_timeline_database.c +++ b/swad_timeline_database.c @@ -614,6 +614,39 @@ void TL_DB_RemoveCommentPub (long PubCod) (unsigned) TL_Pub_COMMENT_TO_NOTE); } +/*****************************************************************************/ +/*********** Remove all comments in all the notes of a given user ************/ +/*****************************************************************************/ + +void TL_DB_RemoveAllCommentsInAllNotesOf (long UsrCod) + { + /***** Remove all comments in all notes of the user *****/ + DB_QueryDELETE ("can not remove comments", + "DELETE FROM tl_comments" + " USING tl_notes,tl_pubs,tl_comments" + " WHERE tl_notes.UsrCod=%ld" + " AND tl_notes.NotCod=tl_pubs.NotCod" + " AND tl_pubs.PubType=%u" + " AND tl_pubs.PubCod=tl_comments.PubCod", + UsrCod,(unsigned) TL_Pub_COMMENT_TO_NOTE); + } + +/*****************************************************************************/ +/*********** Remove all comments made by a given user in any note ************/ +/*****************************************************************************/ + +void TL_DB_RemoveAllCommentsMadeBy (long UsrCod) + { + /***** Remove all comments made by this user in any note *****/ + DB_QueryDELETE ("can not remove comments", + "DELETE FROM tl_comments" + " USING tl_pubs,tl_comments" + " WHERE tl_pubs.PublisherCod=%ld" + " AND tl_pubs.PubType=%u" + " AND tl_pubs.PubCod=tl_comments.PubCod", + UsrCod,(unsigned) TL_Pub_COMMENT_TO_NOTE); + } + /*****************************************************************************/ /*************** Get code of media associated to post/comment ****************/ /*****************************************************************************/ @@ -919,14 +952,15 @@ void TL_DB_UpdateFirstLastPubCodsInSession (long FirstPubCod) } /*****************************************************************************/ -/** Remove all publications published by any user & authored by a given user */ +/************** Remove all publications published by any user ****************/ +/************** related to notes authored by a given user ****************/ /*****************************************************************************/ void TL_DB_RemoveAllPubsPublishedByAnyUsrOfNotesAuthoredBy (long UsrCod) { - /***** Remove all publications (original or shared notes) + /***** Remove all publications (original notes, shared notes, comments) published by any user - of notes authored by this user *****/ + and related to notes authored by this user *****/ DB_QueryDELETE ("can not remove publications", "DELETE FROM tl_pubs" " USING tl_notes,tl_pubs" @@ -1040,7 +1074,7 @@ void TL_DB_UnmarkAsFav (TL_Fav_WhatToFav_t WhatToFav,long Cod) void TL_DB_RemoveAllFavsMadeByUsr (TL_Fav_WhatToFav_t WhatToFav,long UsrCod) { - /* Remove all favs made by this user to any comment */ + /* Remove all favs made by this user to any note/comment */ DB_QueryDELETE ("can not remove favs", "DELETE FROM %s WHERE UsrCod=%ld", TL_DB_Table[WhatToFav],UsrCod); diff --git a/swad_timeline_database.h b/swad_timeline_database.h index 626eff2e..30c1a811 100644 --- a/swad_timeline_database.h +++ b/swad_timeline_database.h @@ -94,6 +94,8 @@ long TL_DB_GetMedCodFromComment (long PubCod); void TL_DB_RemoveCommentFavs (long PubCod); void TL_DB_RemoveCommentContent (long PubCod); void TL_DB_RemoveCommentPub (long PubCod); +void TL_DB_RemoveAllCommentsInAllNotesOf (long UsrCod); +void TL_DB_RemoveAllCommentsMadeBy (long UsrCod); /****************************** Publications *********************************/ void TL_DB_CreateSubQueryPublishers (const struct TL_Timeline *Timeline, diff --git a/swad_timeline_user.c b/swad_timeline_user.c index 04954c94..283b5845 100644 --- a/swad_timeline_user.c +++ b/swad_timeline_user.c @@ -30,7 +30,6 @@ #include // For PATH_MAX #include // For asprintf -#include "swad_database.h" #include "swad_global.h" #include "swad_photo.h" #include "swad_timeline.h" @@ -79,48 +78,27 @@ void TL_Usr_RemoveUsrContent (long UsrCod) TL_DB_RemoveAllFavsToAllCommentsInAllNotesBy (UsrCod); /***** Remove favs for notes *****/ - /* Remove all favs made by this user in any note */ + /* Remove all favs made by this user to any note */ TL_DB_RemoveAllFavsMadeByUsr (TL_Fav_NOTE,UsrCod); /* Remove all favs to notes of this user */ TL_DB_RemoveAllFavsToPubsBy (TL_Fav_NOTE,UsrCod); /***** Remove comments *****/ - /* Remove content of all comments in all the notes of the user */ - DB_QueryDELETE ("can not remove comments", - "DELETE FROM tl_comments" - " USING tl_notes,tl_pubs,tl_comments" - " WHERE tl_notes.UsrCod=%ld" - " AND tl_notes.NotCod=tl_pubs.NotCod" - " AND tl_pubs.PubType=%u" - " AND tl_pubs.PubCod=tl_comments.PubCod", - UsrCod,(unsigned) TL_Pub_COMMENT_TO_NOTE); + /* Remove all comments in all the notes of this user */ + TL_DB_RemoveAllCommentsInAllNotesOf (UsrCod); - /* Remove all comments from any user in any note of the user */ - DB_QueryDELETE ("can not remove comments", - "DELETE FROM tl_pubs" - " USING tl_notes,tl_pubs" - " WHERE tl_notes.UsrCod=%ld" - " AND tl_notes.NotCod=tl_pubs.NotCod" - " AND tl_pubs.PubType=%u", - UsrCod,(unsigned) TL_Pub_COMMENT_TO_NOTE); - - /* Remove content of all comments of the user in any note */ - DB_QueryDELETE ("can not remove comments", - "DELETE FROM tl_comments" - " USING tl_pubs,tl_comments" - " WHERE tl_pubs.PublisherCod=%ld" - " AND tl_pubs.PubType=%u" - " AND tl_pubs.PubCod=tl_comments.PubCod", - UsrCod,(unsigned) TL_Pub_COMMENT_TO_NOTE); + /* Remove all comments made by this user in any note */ + TL_DB_RemoveAllCommentsMadeBy (UsrCod); /***** Remove posts *****/ /* Remove all posts of the user */ TL_DB_RemoveAllPostsUsr (UsrCod); /***** Remove publications *****/ - /* Remove all publications (original or shared notes) published by any user - of notes authored by the user */ + /* Remove all publications (original, shared notes, comments) + published by any user + and related to notes authored by the user */ TL_DB_RemoveAllPubsPublishedByAnyUsrOfNotesAuthoredBy (UsrCod); /* Remove all publications published by the user */