diff --git a/swad_changelog.h b/swad_changelog.h index 869d842a..93401339 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -598,10 +598,11 @@ 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 */ -#define Log_PLATFORM_VERSION "SWAD 20.40.1 (2021-03-03)" +#define Log_PLATFORM_VERSION "SWAD 20.40.2 (2021-03-03)" #define CSS_FILE "swad20.33.9.css" #define JS_FILE "swad20.6.2.js" /* + Version 20.40.2: Mar 03, 2021 Code refactoring in fav/share timeline. (305519 lines) Version 20.40.1: Mar 03, 2021 Code refactoring in fav/share timeline. (305532 lines) Version 20.40: Mar 03, 2021 Code refactoring in fav/share timeline. (305532 lines) Version 20.39.11: Mar 02, 2021 Code refactoring in fav/share timeline. (305525 lines) diff --git a/swad_timeline_comment.c b/swad_timeline_comment.c index 269f89a0..a9c8044b 100644 --- a/swad_timeline_comment.c +++ b/swad_timeline_comment.c @@ -644,9 +644,10 @@ static void TL_Com_WriteButtons (const struct TL_Timeline *Timeline, /***** Foot column 1: fav zone *****/ HTM_DIV_Begin ("id=\"fav_com_%s_%u\" class=\"TL_FAV_COM TL_FAV_WIDTH\"", Gbl.UniqueNameEncrypted,NumDiv); - TL_Fav_PutIconToFavUnf (TL_Usr_FAV_UNF_COMM, - Com->PubCod,Com->UsrCod,Com->NumFavs, - TL_Usr_SHOW_FEW_USRS); + TL_Usr_PutIconFavSha (TL_Usr_FAV_UNF_COMM, + Com->PubCod,Com->UsrCod,Com->NumFavs, + TL_Usr_SHOW_FEW_USRS); + HTM_DIV_End (); /***** Foot column 2: icon to remove this comment *****/ diff --git a/swad_timeline_favourite.c b/swad_timeline_favourite.c index 2755850b..08ec8b99 100644 --- a/swad_timeline_favourite.c +++ b/swad_timeline_favourite.c @@ -84,9 +84,9 @@ void TL_Fav_ShowAllFaversNoteGbl (void) TL_Not_GetDataOfNoteByCod (&Not); /***** Write HTML inside DIV with form to fav/unfav *****/ - TL_Fav_PutIconToFavUnf (TL_Usr_FAV_UNF_NOTE, - Not.NotCod,Not.UsrCod,Not.NumFavs, - TL_Usr_SHOW_ALL_USRS); + TL_Usr_PutIconFavSha (TL_Usr_FAV_UNF_NOTE, + Not.NotCod,Not.UsrCod,Not.NumFavs, + TL_Usr_SHOW_ALL_USRS); } void TL_Fav_FavNoteUsr (void) @@ -106,9 +106,9 @@ void TL_Fav_FavNoteGbl (void) TL_Fav_FavNote (&Not); /***** Write HTML inside DIV with form to unfav *****/ - TL_Fav_PutIconToFavUnf (TL_Usr_FAV_UNF_NOTE, - Not.NotCod,Not.UsrCod,Not.NumFavs, - TL_Usr_SHOW_FEW_USRS); + TL_Usr_PutIconFavSha (TL_Usr_FAV_UNF_NOTE, + Not.NotCod,Not.UsrCod,Not.NumFavs, + TL_Usr_SHOW_FEW_USRS); } void TL_Fav_UnfNoteUsr (void) @@ -128,9 +128,9 @@ void TL_Fav_UnfNoteGbl (void) TL_Fav_UnfNote (&Not); /***** Write HTML inside DIV with form to fav *****/ - TL_Fav_PutIconToFavUnf (TL_Usr_FAV_UNF_NOTE, - Not.NotCod,Not.UsrCod,Not.NumFavs, - TL_Usr_SHOW_FEW_USRS); + TL_Usr_PutIconFavSha (TL_Usr_FAV_UNF_NOTE, + Not.NotCod,Not.UsrCod,Not.NumFavs, + TL_Usr_SHOW_FEW_USRS); } static void TL_Fav_FavNote (struct TL_Not_Note *Not) @@ -219,9 +219,9 @@ void TL_Fav_ShowAllFaversComGbl (void) Med_MediaDestructor (&Com.Content.Media); /***** Write HTML inside DIV with form to fav/unfav *****/ - TL_Fav_PutIconToFavUnf (TL_Usr_FAV_UNF_COMM, - Com.PubCod,Com.UsrCod,Com.NumFavs, - TL_Usr_SHOW_ALL_USRS); + TL_Usr_PutIconFavSha (TL_Usr_FAV_UNF_COMM, + Com.PubCod,Com.UsrCod,Com.NumFavs, + TL_Usr_SHOW_ALL_USRS); } void TL_Fav_FavCommUsr (void) @@ -241,9 +241,9 @@ void TL_Fav_FavCommGbl (void) TL_Fav_FavComm (&Com); /***** Write HTML inside DIV with form to unfav *****/ - TL_Fav_PutIconToFavUnf (TL_Usr_FAV_UNF_COMM, - Com.PubCod,Com.UsrCod,Com.NumFavs, - TL_Usr_SHOW_FEW_USRS); + TL_Usr_PutIconFavSha (TL_Usr_FAV_UNF_COMM, + Com.PubCod,Com.UsrCod,Com.NumFavs, + TL_Usr_SHOW_FEW_USRS); } void TL_Fav_UnfCommUsr (void) @@ -263,9 +263,9 @@ void TL_Fav_UnfCommGbl (void) TL_Fav_UnfComm (&Com); /***** Write HTML inside DIV with form to fav *****/ - TL_Fav_PutIconToFavUnf (TL_Usr_FAV_UNF_COMM, - Com.PubCod,Com.UsrCod,Com.NumFavs, - TL_Usr_SHOW_FEW_USRS); + TL_Usr_PutIconFavSha (TL_Usr_FAV_UNF_COMM, + Com.PubCod,Com.UsrCod,Com.NumFavs, + TL_Usr_SHOW_FEW_USRS); } static void TL_Fav_FavComm (struct TL_Com_Comment *Com) @@ -345,28 +345,3 @@ static void TL_Fav_UnfComm (struct TL_Com_Comment *Com) /***** Free image *****/ Med_MediaDestructor (&Com->Content.Media); } - -/*****************************************************************************/ -/**************** Put icon to fav/unfav and list of favers *******************/ -/*****************************************************************************/ - -void TL_Fav_PutIconToFavUnf (TL_Usr_FavSha_t FavSha, - long Cod,long UsrCod,unsigned NumUsrs, - TL_Usr_HowManyUsrs_t HowManyUsrs) - { - /***** Put form to fav/unfav this comment *****/ - /* Begin container */ - HTM_DIV_Begin ("class=\"TL_ICO\""); - - /* Icon to fav/unfav */ - if (Usr_ItsMe (UsrCod)) // I am the author ==> I can not fav/unfav - TL_Usr_PutDisabledIconFavSha (FavSha,NumUsrs); - else // I am not the author - TL_Frm_PutFormToFavUnfShaUns (FavSha,Cod); - - /* End container */ - HTM_DIV_End (); - - /***** Show who have faved this note/comment *****/ - TL_Usr_GetAndShowSharersOrFavers (FavSha,Cod,UsrCod,NumUsrs,HowManyUsrs); - } diff --git a/swad_timeline_favourite.h b/swad_timeline_favourite.h index 08d3102e..21c5d875 100644 --- a/swad_timeline_favourite.h +++ b/swad_timeline_favourite.h @@ -55,8 +55,4 @@ void TL_Fav_FavCommGbl (void); void TL_Fav_UnfCommUsr (void); void TL_Fav_UnfCommGbl (void); -void TL_Fav_PutIconToFavUnf (TL_Usr_FavSha_t FavSha, - long Cod,long UsrCod,unsigned NumUsrs, - TL_Usr_HowManyUsrs_t HowManyUsrs); - #endif diff --git a/swad_timeline_note.c b/swad_timeline_note.c index 1d86bec7..b84a60af 100644 --- a/swad_timeline_note.c +++ b/swad_timeline_note.c @@ -841,16 +841,18 @@ static void TL_Not_WriteFavShaRem (const struct TL_Timeline *Timeline, HTM_DIV_Begin ("id=\"fav_not_%s_%u\"" " class=\"TL_FAV_NOT TL_FAV_NOT_WIDTH\"", Gbl.UniqueNameEncrypted,NumDiv); - TL_Fav_PutIconToFavUnf (TL_Usr_FAV_UNF_NOTE, - Not->NotCod,Not->UsrCod,Not->NumFavs, - TL_Usr_SHOW_FEW_USRS); + TL_Usr_PutIconFavSha (TL_Usr_FAV_UNF_NOTE, + Not->NotCod,Not->UsrCod,Not->NumFavs, + TL_Usr_SHOW_FEW_USRS); HTM_DIV_End (); /***** Foot column 2: share zone *****/ HTM_DIV_Begin ("id=\"sha_not_%s_%u\"" " class=\"TL_SHA_NOT TL_SHA_NOT_WIDTH\"", Gbl.UniqueNameEncrypted,NumDiv); - TL_Sha_PutIconToShaUnsNote (Not,TL_Usr_SHOW_FEW_USRS); + TL_Usr_PutIconFavSha (TL_Usr_SHA_UNS_NOTE, + Not->NotCod,Not->UsrCod,Not->NumShared, + TL_Usr_SHOW_FEW_USRS); HTM_DIV_End (); /***** Foot column 3: icon to remove this note *****/ diff --git a/swad_timeline_share.c b/swad_timeline_share.c index 15b39261..a83ecc9a 100644 --- a/swad_timeline_share.c +++ b/swad_timeline_share.c @@ -81,7 +81,9 @@ void TL_Sha_ShowAllSharersNoteGbl (void) TL_Not_GetDataOfNoteByCod (&Not); /***** Write HTML inside DIV with form to share/unshare *****/ - TL_Sha_PutIconToShaUnsNote (&Not,TL_Usr_SHOW_ALL_USRS); + TL_Usr_PutIconFavSha (TL_Usr_SHA_UNS_NOTE, + Not.NotCod,Not.UsrCod,Not.NumShared, + TL_Usr_SHOW_ALL_USRS); } void TL_Sha_ShaNoteUsr (void) @@ -101,7 +103,9 @@ void TL_Sha_ShaNoteGbl (void) TL_Sha_ShaNote (&Not); /***** Write HTML inside DIV with form to unshare *****/ - TL_Sha_PutIconToShaUnsNote (&Not,TL_Usr_SHOW_FEW_USRS); + TL_Usr_PutIconFavSha (TL_Usr_SHA_UNS_NOTE, + Not.NotCod,Not.UsrCod,Not.NumShared, + TL_Usr_SHOW_FEW_USRS); } static void TL_Sha_ShaNote (struct TL_Not_Note *Not) @@ -160,7 +164,9 @@ void TL_Sha_UnsNoteGbl (void) TL_Sha_UnsNote (&Not); /***** Write HTML inside DIV with form to share *****/ - TL_Sha_PutIconToShaUnsNote (&Not,TL_Usr_SHOW_FEW_USRS); + TL_Usr_PutIconFavSha (TL_Usr_SHA_UNS_NOTE, + Not.NotCod,Not.UsrCod,Not.NumShared, + TL_Usr_SHOW_FEW_USRS); } static void TL_Sha_UnsNote (struct TL_Not_Note *Not) @@ -186,28 +192,3 @@ static void TL_Sha_UnsNote (struct TL_Not_Note *Not) if (OriginalPubCod > 0) Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_SHARE,OriginalPubCod); } - -void TL_Sha_PutIconToShaUnsNote (const struct TL_Not_Note *Not, - TL_Usr_HowManyUsrs_t HowManyUsrs) - { - /***** Put form to share/unshare this note *****/ - /* Begin container */ - HTM_DIV_Begin ("class=\"TL_ICO\""); - - /* Icon to share */ - if (Not->Unavailable || // Unavailable notes can not be shared - Usr_ItsMe (Not->UsrCod)) // I am the author - /* Put disabled icon */ - TL_Usr_PutDisabledIconFavSha (TL_Usr_SHA_UNS_NOTE,Not->NumShared); - else // Available and I am not the author - /* Put icon to share/unshare */ - TL_Frm_PutFormToFavUnfShaUns (TL_Usr_SHA_UNS_NOTE,Not->NotCod); - - - /* End container */ - HTM_DIV_End (); - - /***** Show who have shared this note *****/ - TL_Usr_GetAndShowSharersOrFavers (TL_Usr_SHA_UNS_NOTE, - Not->NotCod,Not->UsrCod,Not->NumShared,HowManyUsrs); - } diff --git a/swad_timeline_share.h b/swad_timeline_share.h index 9ece93a7..68f5640f 100644 --- a/swad_timeline_share.h +++ b/swad_timeline_share.h @@ -50,7 +50,5 @@ void TL_Sha_ShaNoteUsr (void); void TL_Sha_ShaNoteGbl (void); void TL_Sha_UnsNoteUsr (void); void TL_Sha_UnsNoteGbl (void); -void TL_Sha_PutIconToShaUnsNote (const struct TL_Not_Note *Not, - TL_Usr_HowManyUsrs_t HowManyUsrs); #endif diff --git a/swad_timeline_user.c b/swad_timeline_user.c index 9c267a4e..2db90d3b 100644 --- a/swad_timeline_user.c +++ b/swad_timeline_user.c @@ -287,6 +287,31 @@ unsigned TL_Usr_GetListFaversOrSharers (TL_Usr_FavSha_t FavSha, return 0; // Not reached } +/*****************************************************************************/ +/**************** Put icon to fav/unfav and list of favers *******************/ +/*****************************************************************************/ + +void TL_Usr_PutIconFavSha (TL_Usr_FavSha_t FavSha, + long Cod,long UsrCod,unsigned NumUsrs, + TL_Usr_HowManyUsrs_t HowManyUsrs) + { + /***** Put form to fav/unfav or share/unshare this note/comment *****/ + /* Begin container */ + HTM_DIV_Begin ("class=\"TL_ICO\""); + + /* Icon to fav/unfav or share/unshare this note/comment */ + if (Usr_ItsMe (UsrCod)) // I am the author ==> I can not fav/unfav or share/unshare + TL_Usr_PutDisabledIconFavSha (FavSha,NumUsrs); + else // I am not the author + TL_Frm_PutFormToFavUnfShaUns (FavSha,Cod); + + /* End container */ + HTM_DIV_End (); + + /***** Show who have faved/shared this note/comment *****/ + TL_Usr_GetAndShowSharersOrFavers (FavSha,Cod,UsrCod,NumUsrs,HowManyUsrs); + } + /*****************************************************************************/ /****************** Put disabled icon to mark as favourite *******************/ /*****************************************************************************/ diff --git a/swad_timeline_user.h b/swad_timeline_user.h index b86e6bb9..499167e2 100644 --- a/swad_timeline_user.h +++ b/swad_timeline_user.h @@ -81,6 +81,9 @@ unsigned TL_Usr_GetListFaversOrSharers (TL_Usr_FavSha_t FavSha, long Cod,long UsrCod,unsigned MaxUsrs, MYSQL_RES **mysql_res); +void TL_Usr_PutIconFavSha (TL_Usr_FavSha_t FavSha, + long Cod,long UsrCod,unsigned NumUsrs, + TL_Usr_HowManyUsrs_t HowManyUsrs); void TL_Usr_PutDisabledIconFavSha (TL_Usr_FavSha_t FavSha,unsigned NumUsrs); #endif