From d388d5552eeeb098d7c8a776396610b73fe40762 Mon Sep 17 00:00:00 2001 From: acanas Date: Sun, 28 Feb 2021 21:47:18 +0100 Subject: [PATCH] Version 20.36.27: Feb 28, 2021 Functions moved to module swad_timeline_database. --- swad_changelog.h | 3 ++- swad_timeline_database.c | 27 ++++++++++++++++++++++++++ swad_timeline_database.h | 2 ++ swad_timeline_favourite.c | 41 ++++++--------------------------------- 4 files changed, 37 insertions(+), 36 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 656624ec4..ede4f7add 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.26 (2021-02-28)" +#define Log_PLATFORM_VERSION "SWAD 20.36.27 (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.27: Feb 28, 2021 Functions moved to module swad_timeline_database. (305424 lines) Version 20.36.26: Feb 28, 2021 Queries moved to module swad_timeline_database. (305423 lines) 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) diff --git a/swad_timeline_database.c b/swad_timeline_database.c index 5df03d536..d2bfbc93a 100644 --- a/swad_timeline_database.c +++ b/swad_timeline_database.c @@ -848,6 +848,33 @@ void TL_DB_UpdateFirstLastPubCodsInSession (long FirstPubCod) Gbl.Session.Id); } + +/*****************************************************************************/ +/****************** Check if a user has favourited a note ********************/ +/*****************************************************************************/ + +bool TL_DB_CheckIfNoteIsFavedByUsr (long NotCod,long UsrCod) + { + return (DB_QueryCOUNT ("can not check if a user" + " has favourited a note", + "SELECT COUNT(*) FROM tl_notes_fav" + " WHERE NotCod=%ld AND UsrCod=%ld", + NotCod,UsrCod) != 0); + } + +/*****************************************************************************/ +/**************** Check if a user has favourited a comment *******************/ +/*****************************************************************************/ + +bool TL_DB_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod) + { + return (DB_QueryCOUNT ("can not check if a user" + " has favourited a comment", + "SELECT COUNT(*) FROM tl_comments_fav" + " WHERE PubCod=%ld AND UsrCod=%ld", + PubCod,UsrCod) != 0); + } + /*****************************************************************************/ /********************** Mark note as favourite in database *******************/ /*****************************************************************************/ diff --git a/swad_timeline_database.h b/swad_timeline_database.h index 4aeaf98e4..178c0a3ad 100644 --- a/swad_timeline_database.h +++ b/swad_timeline_database.h @@ -111,6 +111,8 @@ void TL_DB_UpdateLastPubCodInSession (void); void TL_DB_UpdateFirstLastPubCodsInSession (long FirstPubCod); /****************************** Favourites ***********************************/ +bool TL_DB_CheckIfNoteIsFavedByUsr (long NotCod,long UsrCod); +bool TL_DB_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod); void TL_DB_MarkNoteAsFav (long NotCod); void TL_DB_MarkCommAsFav (long PubCod); void TL_DB_UnmarkNoteAsFav (long NotCod); diff --git a/swad_timeline_favourite.c b/swad_timeline_favourite.c index 54c66ede1..b881f3303 100644 --- a/swad_timeline_favourite.c +++ b/swad_timeline_favourite.c @@ -69,9 +69,6 @@ static void TL_Fav_PutDisabledIconFav (unsigned NumFavs); static void TL_Fav_PutFormToFavUnfNote (long NotCod); static void TL_Fav_PutFormToFavUnfComm (long PubCod); -static bool TL_Fav_CheckIfNoteIsFavedByUsr (long NotCod,long UsrCod); -static bool TL_Fav_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod); - static void TL_Fav_ShowUsrsWhoHaveMarkedNoteAsFav (const struct TL_Not_Note *Not, TL_Usr_HowManyUsrs_t HowManyUsrs); static void TL_Fav_ShowUsrsWhoHaveMarkedCommAsFav (const struct TL_Com_Comment *Com, @@ -171,7 +168,7 @@ static void TL_Fav_FavNote (struct TL_Not_Note *Not) { if (Gbl.Usrs.Me.Logged && // I am logged... !Usr_ItsMe (Not->UsrCod)) // ...but I am not the author - if (!TL_Fav_CheckIfNoteIsFavedByUsr (Not->NotCod, + if (!TL_DB_CheckIfNoteIsFavedByUsr (Not->NotCod, Gbl.Usrs.Me.UsrDat.UsrCod)) // I have not yet favourited the note { /***** Mark note as favourite in database *****/ @@ -202,7 +199,7 @@ static void TL_Fav_UnfNote (struct TL_Not_Note *Not) if (Not->NumFavs && Gbl.Usrs.Me.Logged && // I am logged... !Usr_ItsMe (Not->UsrCod)) // ...but I am not the author - if (TL_Fav_CheckIfNoteIsFavedByUsr (Not->NotCod, + if (TL_DB_CheckIfNoteIsFavedByUsr (Not->NotCod, Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited the note { /***** Delete the mark as favourite from database *****/ @@ -312,7 +309,7 @@ static void TL_Fav_FavComment (struct TL_Com_Comment *Com) if (Com->PubCod > 0) if (!Usr_ItsMe (Com->UsrCod)) // I am not the author - if (!TL_Fav_CheckIfCommIsFavedByUsr (Com->PubCod, + if (!TL_DB_CheckIfCommIsFavedByUsr (Com->PubCod, Gbl.Usrs.Me.UsrDat.UsrCod)) // I have not yet favourited the comment { /***** Mark comment as favourite in database *****/ @@ -343,7 +340,7 @@ static void TL_Fav_UnfComment (struct TL_Com_Comment *Com) if (Com->PubCod > 0) if (Com->NumFavs && !Usr_ItsMe (Com->UsrCod)) // I am not the author - if (TL_Fav_CheckIfCommIsFavedByUsr (Com->PubCod, + if (TL_DB_CheckIfCommIsFavedByUsr (Com->PubCod, Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited the comment { /***** Delete the mark as favourite from database *****/ @@ -412,7 +409,7 @@ static void TL_Fav_PutFormToFavUnfNote (long NotCod) }; /***** Form and icon to fav/unfav note *****/ - TL_Frm_FormFavSha (&Form[TL_Fav_CheckIfNoteIsFavedByUsr (NotCod,Gbl.Usrs.Me.UsrDat.UsrCod)]); + TL_Frm_FormFavSha (&Form[TL_DB_CheckIfNoteIsFavedByUsr (NotCod,Gbl.Usrs.Me.UsrDat.UsrCod)]); } /*****************************************************************************/ @@ -444,33 +441,7 @@ static void TL_Fav_PutFormToFavUnfComm (long PubCod) }; /***** Form and icon to fav/unfav *****/ - TL_Frm_FormFavSha (&Form[TL_Fav_CheckIfNoteIsFavedByUsr (PubCod,Gbl.Usrs.Me.UsrDat.UsrCod)]); - } - -/*****************************************************************************/ -/****************** Check if a user has favourited a note ********************/ -/*****************************************************************************/ - -static bool TL_Fav_CheckIfNoteIsFavedByUsr (long NotCod,long UsrCod) - { - return (DB_QueryCOUNT ("can not check if a user" - " has favourited a note", - "SELECT COUNT(*) FROM tl_notes_fav" - " WHERE NotCod=%ld AND UsrCod=%ld", - NotCod,UsrCod) != 0); - } - -/*****************************************************************************/ -/**************** Check if a user has favourited a comment *******************/ -/*****************************************************************************/ - -static bool TL_Fav_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod) - { - return (DB_QueryCOUNT ("can not check if a user" - " has favourited a comment", - "SELECT COUNT(*) FROM tl_comments_fav" - " WHERE PubCod=%ld AND UsrCod=%ld", - PubCod,UsrCod) != 0); + TL_Frm_FormFavSha (&Form[TL_DB_CheckIfNoteIsFavedByUsr (PubCod,Gbl.Usrs.Me.UsrDat.UsrCod)]); } /*****************************************************************************/