diff --git a/swad_changelog.h b/swad_changelog.h index fca34879..e9468fcf 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.38 (2021-03-01)" +#define Log_PLATFORM_VERSION "SWAD 20.36.39 (2021-03-01)" #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.39: Mar 01, 2021 Queries moved to module swad_timeline_database. (? lines) Version 20.36.38: Mar 01, 2021 Code refactoring in timeline notifications. (305441 lines) Version 20.36.37: Mar 01, 2021 Query moved to module swad_timeline_database. (305449 lines) Version 20.36.36: Mar 01, 2021 Query moved to module swad_timeline_database. (305429 lines) diff --git a/swad_timeline_database.c b/swad_timeline_database.c index 3e08b653..e1ebda30 100644 --- a/swad_timeline_database.c +++ b/swad_timeline_database.c @@ -973,6 +973,18 @@ void TL_DB_UnmarkAsFav (TL_Fav_WhatToFav_t WhatToFav,long Cod) TL_DB_Field[WhatToFav],Cod,Gbl.Usrs.Me.UsrDat.UsrCod); } +/*****************************************************************************/ +/************* Remove all favs made by this user in any comment **************/ +/*****************************************************************************/ + +void TL_DB_RemoveAllFavsMadeByUsr (TL_Fav_WhatToFav_t WhatToFav,long UsrCod) + { + /* Remove all favs made by this user in any comment */ + DB_QueryDELETE ("can not remove favs", + "DELETE FROM %s WHERE UsrCod=%ld", + TL_DB_Table[WhatToFav],UsrCod); + } + /*****************************************************************************/ /****************** Check if a user has published a note *********************/ /*****************************************************************************/ diff --git a/swad_timeline_database.h b/swad_timeline_database.h index 16863f5b..5e328d5f 100644 --- a/swad_timeline_database.h +++ b/swad_timeline_database.h @@ -124,6 +124,7 @@ unsigned TL_DB_GetListUsrsHaveFaved (TL_Fav_WhatToFav_t WhatToFav, MYSQL_RES **mysql_res); void TL_DB_MarkAsFav (TL_Fav_WhatToFav_t WhatToFav,long Cod); void TL_DB_UnmarkAsFav (TL_Fav_WhatToFav_t WhatToFav,long Cod); +void TL_DB_RemoveAllFavsMadeByUsr (TL_Fav_WhatToFav_t WhatToFav,long UsrCod); /******************************** Shared *************************************/ bool TL_DB_CheckIfNoteIsSharedByUsr (long NotCod,long UsrCod); diff --git a/swad_timeline_notification.c b/swad_timeline_notification.c index 233ab71c..56dbd9ed 100644 --- a/swad_timeline_notification.c +++ b/swad_timeline_notification.c @@ -28,7 +28,6 @@ #include // For boolean type #include // For string functions -#include "swad_database.h" #include "swad_global.h" #include "swad_timeline.h" #include "swad_timeline_database.h" diff --git a/swad_timeline_user.c b/swad_timeline_user.c index 5336ef77..2671198c 100644 --- a/swad_timeline_user.c +++ b/swad_timeline_user.c @@ -34,6 +34,8 @@ #include "swad_global.h" #include "swad_photo.h" #include "swad_timeline.h" +#include "swad_timeline_database.h" +#include "swad_timeline_favourite.h" #include "swad_timeline_note.h" #include "swad_timeline_publication.h" #include "swad_timeline_user.h" @@ -68,10 +70,7 @@ void TL_Usr_RemoveUsrContent (long UsrCod) { /***** Remove favs for comments *****/ /* Remove all favs made by this user in any comment */ - DB_QueryDELETE ("can not remove favs", - "DELETE FROM tl_comments_fav" - " WHERE UsrCod=%ld", - UsrCod); + TL_DB_RemoveAllFavsMadeByUsr (TL_Fav_COMM,UsrCod); /* Remove all favs for all comments of this user */ DB_QueryDELETE ("can not remove favs", @@ -94,10 +93,7 @@ void TL_Usr_RemoveUsrContent (long UsrCod) /***** Remove favs for notes *****/ /* Remove all favs made by this user in any note */ - DB_QueryDELETE ("can not remove favs", - "DELETE FROM tl_notes_fav" - " WHERE UsrCod=%ld", - UsrCod); + TL_DB_RemoveAllFavsMadeByUsr (TL_Fav_NOTE,UsrCod); /* Remove all favs for all notes of this user */ DB_QueryDELETE ("can not remove favs",