From fd781508a234710e66f5e6d13d15bb364b1a2227 Mon Sep 17 00:00:00 2001 From: acanas Date: Fri, 26 Feb 2021 23:58:36 +0100 Subject: [PATCH] Version 20.36.5: Feb 26, 2021 Queries moved to module swad_timeline_database. --- swad_changelog.h | 3 ++- swad_timeline_comment.c | 28 ++++--------------------- swad_timeline_database.c | 45 +++++++++++++++++++++++++++++++++++++++- swad_timeline_database.h | 3 +++ 4 files changed, 53 insertions(+), 26 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 039c2e11c..fa1689bd1 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.4 (2021-02-26)" +#define Log_PLATFORM_VERSION "SWAD 20.36.5 (2021-02-26)" #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.5: Feb 26, 2021 Queries moved to module swad_timeline_database. (305179 lines) Version 20.36.4: Feb 26, 2021 Query moved to module swad_timeline_database. (305156 lines) Version 20.36.3: Feb 26, 2021 Query moved to module swad_timeline_database. (305140 lines) Version 20.36.2: Feb 26, 2021 Query moved to module swad_timeline_database. (305126 lines) diff --git a/swad_timeline_comment.c b/swad_timeline_comment.c index 1455701a6..19a2b80aa 100644 --- a/swad_timeline_comment.c +++ b/swad_timeline_comment.c @@ -938,15 +938,8 @@ static void TL_Com_RemoveComment (void) void TL_Com_RemoveCommentMediaAndDBEntries (long PubCod) { - long MedCod; - /***** Remove media associated to comment *****/ - /* Get media code */ - MedCod = TL_DB_GetMedCodFromComment (PubCod); - - /* Remove media */ - if (MedCod > 0) - Med_RemoveMedia (MedCod); + Med_RemoveMedia (TL_DB_GetMedCodFromComment (PubCod)); /***** Mark possible notifications on this comment as removed *****/ Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_COMMENT,PubCod); @@ -954,26 +947,13 @@ void TL_Com_RemoveCommentMediaAndDBEntries (long PubCod) Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_MENTION,PubCod); /***** Remove favs for this comment *****/ - DB_QueryDELETE ("can not remove favs for comment", - "DELETE FROM tl_comments_fav" - " WHERE PubCod=%ld", - PubCod); + TL_DB_RemoveCommentFavs (PubCod); /***** Remove content of this comment *****/ - DB_QueryDELETE ("can not remove a comment", - "DELETE FROM tl_comments" - " WHERE PubCod=%ld", - PubCod); + TL_DB_RemoveCommentContent (PubCod); /***** Remove this comment *****/ - DB_QueryDELETE ("can not remove a comment", - "DELETE FROM tl_pubs" - " WHERE PubCod=%ld" - " AND PublisherCod=%ld" // Extra check: I am the author - " AND PubType=%u", // Extra check: it's a comment - PubCod, - Gbl.Usrs.Me.UsrDat.UsrCod, - (unsigned) TL_Pub_COMMENT_TO_NOTE); + TL_DB_RemoveCommentPub (PubCod,Gbl.Usrs.Me.UsrDat.UsrCod); } /*****************************************************************************/ diff --git a/swad_timeline_database.c b/swad_timeline_database.c index 853a56f57..d08f7eaff 100644 --- a/swad_timeline_database.c +++ b/swad_timeline_database.c @@ -147,7 +147,7 @@ long TL_DB_GetMedCodFromComment (long PubCod) { MYSQL_RES *mysql_res; MYSQL_ROW row; - long MedCod = -1L; + long MedCod = -1L; // Default value /***** Get code of media associated to comment *****/ if (DB_QuerySELECT (&mysql_res,"can not get media code", @@ -166,3 +166,46 @@ long TL_DB_GetMedCodFromComment (long PubCod) return MedCod; } + +/*****************************************************************************/ +/****************** Remove favs for comment from database ********************/ +/*****************************************************************************/ + +void TL_DB_RemoveCommentFavs (long PubCod) + { + /***** Remove favs for comment *****/ + DB_QueryDELETE ("can not remove favs for comment", + "DELETE FROM tl_comments_fav" + " WHERE PubCod=%ld", + PubCod); + } + +/*****************************************************************************/ +/***************** Remove content of comment from database *******************/ +/*****************************************************************************/ + +void TL_DB_RemoveCommentContent (long PubCod) + { + /***** Remove content of comment *****/ + DB_QueryDELETE ("can not remove a comment", + "DELETE FROM tl_comments" + " WHERE PubCod=%ld", + PubCod); + } + +/*****************************************************************************/ +/***************** Remove comment publication from database ******************/ +/*****************************************************************************/ + +void TL_DB_RemoveCommentPub (long PubCod,long PublisherCod) + { + /***** Remove comment publication *****/ + DB_QueryDELETE ("can not remove a comment", + "DELETE FROM tl_pubs" + " WHERE PubCod=%ld" + " AND PublisherCod=%ld" // Extra check: I am the author + " AND PubType=%u", // Extra check: it's a comment + PubCod, + PublisherCod, + (unsigned) TL_Pub_COMMENT_TO_NOTE); + } diff --git a/swad_timeline_database.h b/swad_timeline_database.h index 4ce68b5e8..543a2ad55 100644 --- a/swad_timeline_database.h +++ b/swad_timeline_database.h @@ -52,5 +52,8 @@ unsigned TL_DB_GetFinalComments (long NotCod, void TL_DB_InsertCommentContent (long PubCod, const struct TL_Pst_PostContent *Content); long TL_DB_GetMedCodFromComment (long PubCod); +void TL_DB_RemoveCommentFavs (long PubCod); +void TL_DB_RemoveCommentContent (long PubCod); +void TL_DB_RemoveCommentPub (long PubCod,long PublisherCod); #endif