diff --git a/swad_changelog.h b/swad_changelog.h index 85373b196..c0cfe8cc7 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.32 (2021-03-01)" +#define Log_PLATFORM_VERSION "SWAD 20.36.33 (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.33: Mar 01, 2021 Function moved to module swad_timeline_database. (305446 lines) Version 20.36.32: Mar 01, 2021 Query moved to module swad_timeline_database. (305444 lines) Version 20.36.31: Mar 01, 2021 Code refactoring in timeline favourites. (305432 lines) Version 20.36.30: Feb 28, 2021 Code refactoring in timeline favourites. (305411 lines) diff --git a/swad_timeline_database.c b/swad_timeline_database.c index cd7cb72fd..c4000abda 100644 --- a/swad_timeline_database.c +++ b/swad_timeline_database.c @@ -997,6 +997,22 @@ static void TL_DB_UnmarkAsFav (const char *Table,const char *Field,long Cod) Field,Cod,Gbl.Usrs.Me.UsrDat.UsrCod); } +/*****************************************************************************/ +/****************** Check if a user has published a note *********************/ +/*****************************************************************************/ + +bool TL_DB_CheckIfNoteIsSharedByUsr (long NotCod,long UsrCod) + { + return (DB_QueryCOUNT ("can not check if a user has shared a note", + "SELECT COUNT(*) FROM tl_pubs" + " WHERE NotCod=%ld" + " AND PublisherCod=%ld" + " AND PubType=%u", + NotCod, + UsrCod, + (unsigned) TL_Pub_SHARED_NOTE) != 0); + } + /*****************************************************************************/ /****************** Remove shared publication from database ******************/ /*****************************************************************************/ diff --git a/swad_timeline_database.h b/swad_timeline_database.h index f1a724902..03dd87984 100644 --- a/swad_timeline_database.h +++ b/swad_timeline_database.h @@ -127,6 +127,7 @@ void TL_DB_UnmarkNoteAsFav (long NotCod); void TL_DB_UnmarkCommAsFav (long PubCod); /******************************** Shared *************************************/ +bool TL_DB_CheckIfNoteIsSharedByUsr (long NotCod,long UsrCod); void TL_DB_RemoveSharedPub (long NotCod); #endif diff --git a/swad_timeline_share.c b/swad_timeline_share.c index 4dabcc0a8..ac9078800 100644 --- a/swad_timeline_share.c +++ b/swad_timeline_share.c @@ -65,8 +65,6 @@ static void TL_Sha_UnsNote (struct TL_Not_Note *Not); static void TL_Sha_PutDisabledIconShare (unsigned NumShared); static void TL_Sha_PutFormToShaUnsNote (long NotCod); -static bool TL_Sha_CheckIfNoteIsSharedByUsr (long NotCod,long UsrCod); - static void TL_Sha_ShowUsrsWhoHaveSharedNote (const struct TL_Not_Note *Not, TL_Usr_HowManyUsrs_t HowManyUsrs); @@ -127,8 +125,8 @@ static void TL_Sha_ShaNote (struct TL_Not_Note *Not) if (Not->NotCod > 0) if (Gbl.Usrs.Me.Logged && // I am logged... !Usr_ItsMe (Not->UsrCod)) // ...but I am not the author - if (!TL_Sha_CheckIfNoteIsSharedByUsr (Not->NotCod, - Gbl.Usrs.Me.UsrDat.UsrCod)) // Not yet shared by me + if (!TL_DB_CheckIfNoteIsSharedByUsr (Not->NotCod, + Gbl.Usrs.Me.UsrDat.UsrCod)) // Not yet shared by me { /***** Share (publish note in timeline) *****/ Pub.NotCod = Not->NotCod; @@ -184,8 +182,8 @@ static void TL_Sha_UnsNote (struct TL_Not_Note *Not) if (Not->NumShared && Gbl.Usrs.Me.Logged && // I am logged... !Usr_ItsMe (Not->UsrCod)) // ...but I am not the author - if (TL_Sha_CheckIfNoteIsSharedByUsr (Not->NotCod, - Gbl.Usrs.Me.UsrDat.UsrCod)) // I am a sharer + if (TL_DB_CheckIfNoteIsSharedByUsr (Not->NotCod, + Gbl.Usrs.Me.UsrDat.UsrCod)) // I am a sharer { /***** Delete publication from database *****/ TL_DB_RemoveSharedPub (Not->NotCod); @@ -269,23 +267,8 @@ static void TL_Sha_PutFormToShaUnsNote (long NotCod) }; /***** Form and icon to share/unshare note *****/ - TL_Frm_FormFavSha (&Form[TL_Sha_CheckIfNoteIsSharedByUsr (NotCod,Gbl.Usrs.Me.UsrDat.UsrCod)]); - } - -/*****************************************************************************/ -/****************** Check if a user has published a note *********************/ -/*****************************************************************************/ - -static bool TL_Sha_CheckIfNoteIsSharedByUsr (long NotCod,long UsrCod) - { - return (DB_QueryCOUNT ("can not check if a user has shared a note", - "SELECT COUNT(*) FROM tl_pubs" - " WHERE NotCod=%ld" - " AND PublisherCod=%ld" - " AND PubType=%u", - NotCod, - UsrCod, - (unsigned) TL_Pub_SHARED_NOTE) != 0); + TL_Frm_FormFavSha (&Form[TL_DB_CheckIfNoteIsSharedByUsr (NotCod, + Gbl.Usrs.Me.UsrDat.UsrCod)]); } /*****************************************************************************/