diff --git a/swad_changelog.h b/swad_changelog.h index ede4f7ad..9e4dfd6f 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.27 (2021-02-28)" +#define Log_PLATFORM_VERSION "SWAD 20.36.28 (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.28: Feb 28, 2021 Functions moved to module swad_timeline_database. (305426 lines) 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) diff --git a/swad_timeline_comment.c b/swad_timeline_comment.c index 1fcb19ec..e551c220 100644 --- a/swad_timeline_comment.c +++ b/swad_timeline_comment.c @@ -1016,7 +1016,7 @@ static void TL_Com_GetDataOfCommentFromRow (MYSQL_ROW row, Med_GetMediaDataByCod (&Com->Content.Media); /***** Get number of times this comment has been favourited *****/ - TL_Fav_GetNumTimesACommHasBeenFav (Com); + Com->NumFavs = TL_DB_GetNumTimesACommHasBeenFav (Com); } /*****************************************************************************/ diff --git a/swad_timeline_database.c b/swad_timeline_database.c index d2bfbc93..dd4ed28e 100644 --- a/swad_timeline_database.c +++ b/swad_timeline_database.c @@ -875,6 +875,40 @@ bool TL_DB_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod) PubCod,UsrCod) != 0); } +/*****************************************************************************/ +/*************** Get number of times a note has been favourited **************/ +/*****************************************************************************/ + +unsigned TL_DB_GetNumTimesANoteHasBeenFav (const struct TL_Not_Note *Not) + { + /***** Get number of times (users) this note has been favourited *****/ + return (unsigned) + DB_QueryCOUNT ("can not get number of times" + " a note has been favourited", + "SELECT COUNT(*) FROM tl_notes_fav" + " WHERE NotCod=%ld" + " AND UsrCod<>%ld", // Extra check + Not->NotCod, + Not->UsrCod); // The author + } + +/*****************************************************************************/ +/************ Get number of times a comment has been favourited **************/ +/*****************************************************************************/ + +unsigned TL_DB_GetNumTimesACommHasBeenFav (const struct TL_Com_Comment *Com) + { + /***** Get number of times (users) this comment has been favourited *****/ + return (unsigned) + DB_QueryCOUNT ("can not get number of times" + " a comment has been favourited", + "SELECT COUNT(*) FROM tl_comments_fav" + " WHERE PubCod=%ld" + " AND UsrCod<>%ld", // Extra check + Com->PubCod, + Com->UsrCod); // The author + } + /*****************************************************************************/ /********************** Mark note as favourite in database *******************/ /*****************************************************************************/ diff --git a/swad_timeline_database.h b/swad_timeline_database.h index 178c0a3a..4a34775b 100644 --- a/swad_timeline_database.h +++ b/swad_timeline_database.h @@ -29,6 +29,7 @@ #include "swad_database.h" #include "swad_file_browser.h" +#include "swad_timeline_comment.h" #include "swad_timeline_note.h" #include "swad_timeline_post.h" #include "swad_timeline_publication.h" @@ -113,6 +114,8 @@ void TL_DB_UpdateFirstLastPubCodsInSession (long FirstPubCod); /****************************** Favourites ***********************************/ bool TL_DB_CheckIfNoteIsFavedByUsr (long NotCod,long UsrCod); bool TL_DB_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod); +unsigned TL_DB_GetNumTimesANoteHasBeenFav (const struct TL_Not_Note *Not); +unsigned TL_DB_GetNumTimesACommHasBeenFav (const struct TL_Com_Comment *Com); 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 b881f330..94b4ab6e 100644 --- a/swad_timeline_favourite.c +++ b/swad_timeline_favourite.c @@ -175,7 +175,7 @@ static void TL_Fav_FavNote (struct TL_Not_Note *Not) TL_DB_MarkNoteAsFav (Not->NotCod); /***** Update number of times this note is favourited *****/ - TL_Fav_GetNumTimesANoteHasBeenFav (Not); + TL_DB_GetNumTimesANoteHasBeenFav (Not); /***** Create notification about favourite post for the author of the post *****/ @@ -206,7 +206,7 @@ static void TL_Fav_UnfNote (struct TL_Not_Note *Not) TL_DB_UnmarkNoteAsFav (Not->NotCod); /***** Update number of times this note is favourited *****/ - TL_Fav_GetNumTimesANoteHasBeenFav (Not); + TL_DB_GetNumTimesANoteHasBeenFav (Not); /***** Mark possible notifications on this note as removed *****/ OriginalPubCod = TL_DB_GetPubCodOfOriginalNote (Not->NotCod); @@ -316,7 +316,7 @@ static void TL_Fav_FavComment (struct TL_Com_Comment *Com) TL_DB_MarkCommAsFav (Com->PubCod); /* Update number of times this comment is favourited */ - TL_Fav_GetNumTimesACommHasBeenFav (Com); + TL_DB_GetNumTimesACommHasBeenFav (Com); /**** Create notification about favourite post for the author of the post ***/ @@ -347,7 +347,7 @@ static void TL_Fav_UnfComment (struct TL_Com_Comment *Com) TL_DB_UnmarkCommAsFav (Com->PubCod); /***** Update number of times this comment is favourited *****/ - TL_Fav_GetNumTimesACommHasBeenFav (Com); + TL_DB_GetNumTimesACommHasBeenFav (Com); /***** Mark possible notifications on this comment as removed *****/ Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV,Com->PubCod); @@ -444,40 +444,6 @@ static void TL_Fav_PutFormToFavUnfComm (long PubCod) TL_Frm_FormFavSha (&Form[TL_DB_CheckIfNoteIsFavedByUsr (PubCod,Gbl.Usrs.Me.UsrDat.UsrCod)]); } -/*****************************************************************************/ -/*************** Get number of times a note has been favourited **************/ -/*****************************************************************************/ - -void TL_Fav_GetNumTimesANoteHasBeenFav (struct TL_Not_Note *Not) - { - /***** Get number of times (users) this note has been favourited *****/ - Not->NumFavs = - (unsigned) DB_QueryCOUNT ("can not get number of times" - " a note has been favourited", - "SELECT COUNT(*) FROM tl_notes_fav" - " WHERE NotCod=%ld" - " AND UsrCod<>%ld", // Extra check - Not->NotCod, - Not->UsrCod); // The author - } - -/*****************************************************************************/ -/************ Get number of times a comment has been favourited **************/ -/*****************************************************************************/ - -void TL_Fav_GetNumTimesACommHasBeenFav (struct TL_Com_Comment *Com) - { - /***** Get number of times (users) this comment has been favourited *****/ - Com->NumFavs = - (unsigned) DB_QueryCOUNT ("can not get number of times" - " a comment has been favourited", - "SELECT COUNT(*) FROM tl_comments_fav" - " WHERE PubCod=%ld" - " AND UsrCod<>%ld", // Extra check - Com->PubCod, - Com->UsrCod); // The author - } - /*****************************************************************************/ /************ Show users who have marked this note as favourite **************/ /*****************************************************************************/ diff --git a/swad_timeline_favourite.h b/swad_timeline_favourite.h index c66d7bb5..2bdabb41 100644 --- a/swad_timeline_favourite.h +++ b/swad_timeline_favourite.h @@ -65,7 +65,4 @@ void TL_Fav_UnfCommentGbl (void); void TL_Fav_PutIconToFavUnfComment (const struct TL_Com_Comment *Com, TL_Usr_HowManyUsrs_t HowManyUsrs); -void TL_Fav_GetNumTimesANoteHasBeenFav (struct TL_Not_Note *Not); -void TL_Fav_GetNumTimesACommHasBeenFav (struct TL_Com_Comment *Com); - #endif diff --git a/swad_timeline_note.c b/swad_timeline_note.c index e2b75859..8cf70f56 100644 --- a/swad_timeline_note.c +++ b/swad_timeline_note.c @@ -1294,7 +1294,7 @@ static void TL_Not_GetDataOfNoteFromRow (MYSQL_ROW row,struct TL_Not_Note *Not) TL_Sha_UpdateNumTimesANoteHasBeenShared (Not); /***** Get number of times this note has been favourited *****/ - TL_Fav_GetNumTimesANoteHasBeenFav (Not); + Not->NumFavs = TL_DB_GetNumTimesANoteHasBeenFav (Not); } /*****************************************************************************/