From ad76b621318b62312cbfc995188a4ec63e6270f9 Mon Sep 17 00:00:00 2001 From: acanas Date: Sat, 27 Feb 2021 16:16:46 +0100 Subject: [PATCH] Version 20.36.12: Feb 27, 2021 Queries moved to module swad_timeline_database. --- swad_changelog.h | 3 ++- swad_timeline_database.c | 54 ++++++++++++++++++++++++++++++++++++++++ swad_timeline_database.h | 4 +++ swad_timeline_note.c | 25 ++++--------------- 4 files changed, 65 insertions(+), 21 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index b9717075d..a99f5abb5 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.11 (2021-02-07)" +#define Log_PLATFORM_VERSION "SWAD 20.36.12 (2021-02-07)" #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.12: Feb 27, 2021 Queries moved to module swad_timeline_database. (305282 lines) Version 20.36.11: Feb 27, 2021 Query moved to module swad_timeline_database. (305246 lines) Version 20.36.10: Feb 27, 2021 Query moved to module swad_timeline_database. (305243 lines) Version 20.36.9: Feb 27, 2021 Query moved to module swad_timeline_database. (305233 lines) diff --git a/swad_timeline_database.c b/swad_timeline_database.c index 529f01bac..a66fcade4 100644 --- a/swad_timeline_database.c +++ b/swad_timeline_database.c @@ -130,6 +130,47 @@ void TL_DB_InsertNoteInVisibleTimeline (long NotCod) NotCod); } +/*****************************************************************************/ +/*************************** Remove favs for a note **************************/ +/*****************************************************************************/ + +void TL_DB_RemoveNoteFavs (long NotCod) + { + /***** Remove favs for note *****/ + DB_QueryDELETE ("can not remove favs for note", + "DELETE FROM tl_notes_fav" + " WHERE NotCod=%ld", + NotCod); + } + +/*****************************************************************************/ +/******************** Remove all publications of this note *******************/ +/*****************************************************************************/ + +void TL_DB_RemoveNotePubs (long NotCod) + { + /***** Remove all publications of this note *****/ + DB_QueryDELETE ("can not remove a publication", + "DELETE FROM tl_pubs" + " WHERE NotCod=%ld", + NotCod); + } + +/*****************************************************************************/ +/******************* Remove note publication from database *******************/ +/*****************************************************************************/ + +void TL_DB_RemoveNote (long NotCod,long PublisherCod) + { + /***** Remove note *****/ + DB_QueryDELETE ("can not remove a note", + "DELETE FROM tl_notes" + " WHERE NotCod=%ld" + " AND UsrCod=%ld", // Extra check: author + NotCod, + PublisherCod); + } + /*****************************************************************************/ /***************** Get code of media associated to post **********************/ /*****************************************************************************/ @@ -139,6 +180,19 @@ long TL_DB_GetMedCodFromPost (long PubCod) return TL_DB_GetMedCodFromPub (PubCod,"tl_posts"); } +/*****************************************************************************/ +/************************* Remove post from database *************************/ +/*****************************************************************************/ + +void TL_DB_RemovePost (long PstCod) + { + /***** Remove post *****/ + DB_QueryDELETE ("can not remove a post", + "DELETE FROM tl_posts" + " WHERE PstCod=%ld", + PstCod); + } + /*****************************************************************************/ /********************* Get number of comments in a note **********************/ /*****************************************************************************/ diff --git a/swad_timeline_database.h b/swad_timeline_database.h index 330e79c8f..4b21ffce2 100644 --- a/swad_timeline_database.h +++ b/swad_timeline_database.h @@ -54,9 +54,13 @@ void TL_DB_MarkNotesChildrenOfFolderAsUnavailable (TL_Not_NoteType_t NoteType, const char *Path); void TL_DB_InsertNoteInJustRetrievedNotes (long NotCod); void TL_DB_InsertNoteInVisibleTimeline (long NotCod); +void TL_DB_RemoveNoteFavs (long NotCod); +void TL_DB_RemoveNotePubs (long NotCod); +void TL_DB_RemoveNote (long NotCod,long PublisherCod); /* Posts */ long TL_DB_GetMedCodFromPost (long PubCod); +void TL_DB_RemovePost (long PstCod); /* Comments */ unsigned TL_DB_GetNumCommentsInNote (long NotCod); diff --git a/swad_timeline_note.c b/swad_timeline_note.c index 8a2f5caac..28c7b4356 100644 --- a/swad_timeline_note.c +++ b/swad_timeline_note.c @@ -1233,7 +1233,6 @@ static void TL_Not_RemoveNoteMediaAndDBEntries (struct TL_Not_Note *Not) /***** Mark possible notifications on the publications of this note as removed *****/ - /* Mark notifications of the original note as removed */ PubCod = TL_Not_GetPubCodOfOriginalNote (Not->NotCod); if (PubCod > 0) { @@ -1243,31 +1242,17 @@ static void TL_Not_RemoveNoteMediaAndDBEntries (struct TL_Not_Note *Not) } /***** Remove favs for this note *****/ - DB_QueryDELETE ("can not remove favs for note", - "DELETE FROM tl_notes_fav" - " WHERE NotCod=%ld", - Not->NotCod); + TL_DB_RemoveNoteFavs (Not->NotCod); - /***** Remove all the publications of this note *****/ - DB_QueryDELETE ("can not remove a publication", - "DELETE FROM tl_pubs" - " WHERE NotCod=%ld", - Not->NotCod); + /***** Remove all publications of this note *****/ + TL_DB_RemoveNotePubs (Not->NotCod); /***** Remove note *****/ - DB_QueryDELETE ("can not remove a note", - "DELETE FROM tl_notes" - " WHERE NotCod=%ld" - " AND UsrCod=%ld", // Extra check: I am the author - Not->NotCod, - Gbl.Usrs.Me.UsrDat.UsrCod); + TL_DB_RemoveNote (Not->NotCod,Gbl.Usrs.Me.UsrDat.UsrCod); if (Not->NoteType == TL_NOTE_POST) /***** Remove post *****/ - DB_QueryDELETE ("can not remove a post", - "DELETE FROM tl_posts" - " WHERE PstCod=%ld", - Not->Cod); + TL_DB_RemovePost (Not->Cod); } /*****************************************************************************/