From 8a1639ff37830aad9d86099f53c51c19d1ef0572 Mon Sep 17 00:00:00 2001 From: acanas Date: Sun, 28 Feb 2021 21:24:49 +0100 Subject: [PATCH] Version 20.36.25: Feb 28, 2021 Queries moved to module swad_timeline_database. --- swad_changelog.h | 3 ++- swad_timeline_database.c | 32 ++++++++++++++++++++++++++++++++ swad_timeline_database.h | 12 ++++++++---- swad_timeline_favourite.c | 20 ++++---------------- 4 files changed, 46 insertions(+), 21 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 59c33f41..a83a26e8 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.24 (2021-02-28)" +#define Log_PLATFORM_VERSION "SWAD 20.36.25 (2021-02-28)" #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.25: Feb 28, 2021 Queries moved to module swad_timeline_database. (305405 lines) Version 20.36.24: Feb 28, 2021 Functions moved to module swad_timeline_database. (305385 lines) Version 20.36.23: Feb 28, 2021 Function moved to module swad_timeline_database. (305387 lines) Version 20.36.22: Feb 28, 2021 Query moved to module swad_timeline_database. (305387 lines) diff --git a/swad_timeline_database.c b/swad_timeline_database.c index 5dc1e82e..0a8aadbf 100644 --- a/swad_timeline_database.c +++ b/swad_timeline_database.c @@ -847,3 +847,35 @@ void TL_DB_UpdateFirstLastPubCodsInSession (long FirstPubCod) FirstPubCod, Gbl.Session.Id); } + +/*****************************************************************************/ +/********************** Mark note as favourite in database *******************/ +/*****************************************************************************/ + +void TL_DB_MarkNoteAsFav (long NotCod) + { + /***** Insert note in favourited in database *****/ + DB_QueryINSERT ("can not favourite note", + "INSERT IGNORE INTO tl_notes_fav" + " (NotCod,UsrCod,TimeFav)" + " VALUES" + " (%ld,%ld,NOW())", + NotCod, + Gbl.Usrs.Me.UsrDat.UsrCod); + } + +/*****************************************************************************/ +/********************** Mark note as favourite in database *******************/ +/*****************************************************************************/ + +void TL_DB_MarkCommAsFav (long PubCod) + { + /***** Insert comment in favourited in database *****/ + DB_QueryINSERT ("can not favourite comment", + "INSERT IGNORE INTO tl_comments_fav" + " (PubCod,UsrCod,TimeFav)" + " VALUES" + " (%ld,%ld,NOW())", + PubCod, + Gbl.Usrs.Me.UsrDat.UsrCod); + } diff --git a/swad_timeline_database.h b/swad_timeline_database.h index 94941914..7d51f6cb 100644 --- a/swad_timeline_database.h +++ b/swad_timeline_database.h @@ -45,7 +45,7 @@ /****************************** Public prototypes ****************************/ /*****************************************************************************/ -/* Notes */ +/*********************************** Notes ***********************************/ unsigned TL_DB_GetDataOfNoteByCod (long NotCod,MYSQL_RES **mysql_res); long TL_DB_GetPubCodOfOriginalNote (long NotCod); long TL_DB_CreateNewNote (TL_Not_NoteType_t NoteType,long Cod, @@ -68,13 +68,13 @@ void TL_DB_RemoveNoteFavs (long NotCod); void TL_DB_RemoveNotePubs (long NotCod); void TL_DB_RemoveNote (long NotCod); -/* Posts */ +/********************************** Posts ************************************/ unsigned TL_DB_GetPostByCod (long PstCod,MYSQL_RES **mysql_res); long TL_DB_GetMedCodFromPost (long PubCod); long TL_DB_CreateNewPost (const struct TL_Pst_PostContent *Content); void TL_DB_RemovePost (long PstCod); -/* Comments */ +/******************************** Comments ***********************************/ unsigned TL_DB_GetNumCommentsInNote (long NotCod); unsigned TL_DB_GetComments (long NotCod,MYSQL_RES **mysql_res); unsigned TL_DB_GetInitialComments (long NotCod, @@ -91,7 +91,7 @@ void TL_DB_RemoveCommentFavs (long PubCod); void TL_DB_RemoveCommentContent (long PubCod); void TL_DB_RemoveCommentPub (long PubCod); -/* Publications */ +/****************************** Publications *********************************/ void TL_DB_CreateSubQueryPublishers (const struct TL_Timeline *Timeline, struct TL_Pub_SubQueries *SubQueries); void TL_DB_CreateSubQueryAlreadyExists (const struct TL_Timeline *Timeline, @@ -110,4 +110,8 @@ void TL_DB_UpdateFirstPubCodInSession (long FirstPubCod); void TL_DB_UpdateLastPubCodInSession (void); void TL_DB_UpdateFirstLastPubCodsInSession (long FirstPubCod); +/****************************** Favourites ***********************************/ +void TL_DB_MarkNoteAsFav (long NotCod); +void TL_DB_MarkCommAsFav (long PubCod); + #endif diff --git a/swad_timeline_favourite.c b/swad_timeline_favourite.c index 5e421873..9c7c56d5 100644 --- a/swad_timeline_favourite.c +++ b/swad_timeline_favourite.c @@ -174,14 +174,8 @@ static void TL_Fav_FavNote (struct TL_Not_Note *Not) if (!TL_Fav_CheckIfNoteIsFavedByUsr (Not->NotCod, Gbl.Usrs.Me.UsrDat.UsrCod)) // I have not yet favourited the note { - /***** Mark as favourite in database *****/ - DB_QueryINSERT ("can not favourite note", - "INSERT IGNORE INTO tl_notes_fav" - " (NotCod,UsrCod,TimeFav)" - " VALUES" - " (%ld,%ld,NOW())", - Not->NotCod, - Gbl.Usrs.Me.UsrDat.UsrCod); + /***** Mark note as favourite in database *****/ + TL_DB_MarkNoteAsFav (Not->NotCod); /***** Update number of times this note is favourited *****/ TL_Fav_GetNumTimesANoteHasBeenFav (Not); @@ -325,14 +319,8 @@ static void TL_Fav_FavComment (struct TL_Com_Comment *Com) if (!TL_Fav_CheckIfCommIsFavedByUsr (Com->PubCod, Gbl.Usrs.Me.UsrDat.UsrCod)) // I have not yet favourited the comment { - /***** Mark as favourite in database *****/ - DB_QueryINSERT ("can not favourite comment", - "INSERT IGNORE INTO tl_comments_fav" - " (PubCod,UsrCod,TimeFav)" - " VALUES" - " (%ld,%ld,NOW())", - Com->PubCod, - Gbl.Usrs.Me.UsrDat.UsrCod); + /***** Mark comment as favourite in database *****/ + TL_DB_MarkCommAsFav (Com->PubCod); /* Update number of times this comment is favourited */ TL_Fav_GetNumTimesACommHasBeenFav (Com);