Version 20.39.3: Mar 02, 2021 Code refactoring in timeline favourites.

This commit is contained in:
acanas 2021-03-02 12:12:00 +01:00
parent e4f62b80d1
commit aaec25140a
6 changed files with 93 additions and 103 deletions

View File

@ -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: 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 TODO: Salvador Romero Cortés: @acanas opción para editar posts
*/ */
#define Log_PLATFORM_VERSION "SWAD 20.39.2 (2021-03-02)" #define Log_PLATFORM_VERSION "SWAD 20.39.3 (2021-03-02)"
#define CSS_FILE "swad20.33.9.css" #define CSS_FILE "swad20.33.9.css"
#define JS_FILE "swad20.6.2.js" #define JS_FILE "swad20.6.2.js"
/* /*
Version 20.39.3: Mar 02, 2021 Code refactoring in timeline favourites. (305601 lines)
Version 20.39.2: Mar 02, 2021 Code refactoring in timeline database. (305612 lines) Version 20.39.2: Mar 02, 2021 Code refactoring in timeline database. (305612 lines)
Version 20.39.1: Mar 02, 2021 Code refactoring in timeline comments. (305618 lines) Version 20.39.1: Mar 02, 2021 Code refactoring in timeline comments. (305618 lines)
Version 20.39: Mar 02, 2021 Code refactoring in user's photo. (305610 lines) Version 20.39: Mar 02, 2021 Code refactoring in user's photo. (305610 lines)

View File

@ -121,19 +121,25 @@ void TstVis_PutVisibilityCheckboxes (unsigned SelectedVisibility)
TstVis_Visibility_t Visibility; TstVis_Visibility_t Visibility;
bool ItemVisible; bool ItemVisible;
/***** Write list of checkboxes for visibility *****/
for (Visibility = (TstVis_Visibility_t) 0; for (Visibility = (TstVis_Visibility_t) 0;
Visibility <= (TstVis_Visibility_t) (TstVis_NUM_ITEMS_VISIBILITY - 1); Visibility <= (TstVis_Visibility_t) (TstVis_NUM_ITEMS_VISIBILITY - 1);
Visibility++) Visibility++)
{ {
ItemVisible = (SelectedVisibility & (1 << Visibility)) != 0; /* Begin label */
HTM_LABEL_Begin ("class=\"DAT\""); HTM_LABEL_Begin ("class=\"DAT\"");
HTM_INPUT_CHECKBOX ("Visibility",HTM_DONT_SUBMIT_ON_CHANGE,
"value=\"%u\"%s", /* Checkbox with icon and text */
(unsigned) Visibility, ItemVisible = (SelectedVisibility & (1 << Visibility)) != 0;
ItemVisible ? " checked=\"checked\"" : HTM_INPUT_CHECKBOX ("Visibility",HTM_DONT_SUBMIT_ON_CHANGE,
""); "value=\"%u\"%s",
Ico_PutIconOn (Icons[Visibility],Txt_TST_STR_VISIBILITY[Visibility]); (unsigned) Visibility,
HTM_Txt (Txt_TST_STR_VISIBILITY[Visibility]); ItemVisible ? " checked=\"checked\"" :
"");
Ico_PutIconOn (Icons[Visibility],Txt_TST_STR_VISIBILITY[Visibility]);
HTM_Txt (Txt_TST_STR_VISIBILITY[Visibility]);
/* End label */
HTM_LABEL_End (); HTM_LABEL_End ();
HTM_BR (); HTM_BR ();
} }

View File

@ -645,7 +645,8 @@ static void TL_Com_WriteButtons (const struct TL_Timeline *Timeline,
/***** Foot column 1: fav zone *****/ /***** Foot column 1: fav zone *****/
HTM_DIV_Begin ("id=\"fav_com_%s_%u\" class=\"TL_FAV_COM TL_FAV_WIDTH\"", HTM_DIV_Begin ("id=\"fav_com_%s_%u\" class=\"TL_FAV_COM TL_FAV_WIDTH\"",
Gbl.UniqueNameEncrypted,NumDiv); Gbl.UniqueNameEncrypted,NumDiv);
TL_Fav_PutIconToFavUnfComm (Com,TL_Usr_SHOW_FEW_USRS); TL_Fav_PutIconToFavUnf (TL_Fav_COMM,Com->PubCod,Com->UsrCod,Com->NumFavs,
TL_Usr_SHOW_FEW_USRS);
HTM_DIV_End (); HTM_DIV_End ();
/***** Foot column 2: icon to remove this comment *****/ /***** Foot column 2: icon to remove this comment *****/

View File

@ -66,8 +66,7 @@ static void TL_Fav_FavComm (struct TL_Com_Comment *Com);
static void TL_Fav_UnfComm (struct TL_Com_Comment *Com); static void TL_Fav_UnfComm (struct TL_Com_Comment *Com);
static void TL_Fav_PutDisabledIconFav (unsigned NumFavs); static void TL_Fav_PutDisabledIconFav (unsigned NumFavs);
static void TL_Fav_PutFormToFavUnfNote (long NotCod); static void TL_Fav_PutFormToFavUnf (TL_Fav_WhatToFav_t WhatToFav,long Cod);
static void TL_Fav_PutFormToFavUnfComm (long PubCod);
static void TL_Fav_ShowUsrsWhoHaveMarkedAsFav (TL_Fav_WhatToFav_t WhatToFav, static void TL_Fav_ShowUsrsWhoHaveMarkedAsFav (TL_Fav_WhatToFav_t WhatToFav,
long Cod,long UsrCod, long Cod,long UsrCod,
@ -96,7 +95,8 @@ void TL_Fav_ShowAllFaversNoteGbl (void)
TL_Not_GetDataOfNoteByCod (&Not); TL_Not_GetDataOfNoteByCod (&Not);
/***** Write HTML inside DIV with form to fav/unfav *****/ /***** Write HTML inside DIV with form to fav/unfav *****/
TL_Fav_PutIconToFavUnfNote (&Not,TL_Usr_SHOW_ALL_USRS); TL_Fav_PutIconToFavUnf (TL_Fav_NOTE,Not.NotCod,Not.UsrCod,Not.NumFavs,
TL_Usr_SHOW_ALL_USRS);
} }
void TL_Fav_FavNoteUsr (void) void TL_Fav_FavNoteUsr (void)
@ -116,7 +116,8 @@ void TL_Fav_FavNoteGbl (void)
TL_Fav_FavNote (&Not); TL_Fav_FavNote (&Not);
/***** Write HTML inside DIV with form to unfav *****/ /***** Write HTML inside DIV with form to unfav *****/
TL_Fav_PutIconToFavUnfNote (&Not,TL_Usr_SHOW_FEW_USRS); TL_Fav_PutIconToFavUnf (TL_Fav_NOTE,Not.NotCod,Not.UsrCod,Not.NumFavs,
TL_Usr_SHOW_FEW_USRS);
} }
void TL_Fav_UnfNoteUsr (void) void TL_Fav_UnfNoteUsr (void)
@ -136,26 +137,8 @@ void TL_Fav_UnfNoteGbl (void)
TL_Fav_UnfNote (&Not); TL_Fav_UnfNote (&Not);
/***** Write HTML inside DIV with form to fav *****/ /***** Write HTML inside DIV with form to fav *****/
TL_Fav_PutIconToFavUnfNote (&Not,TL_Usr_SHOW_FEW_USRS); TL_Fav_PutIconToFavUnf (TL_Fav_NOTE,Not.NotCod,Not.UsrCod,Not.NumFavs,
} TL_Usr_SHOW_FEW_USRS);
void TL_Fav_PutIconToFavUnfNote (const struct TL_Not_Note *Not,
TL_Usr_HowManyUsrs_t HowManyUsrs)
{
/***** Put form to fav/unfav this note *****/
HTM_DIV_Begin ("class=\"TL_ICO\"");
if (Not->Unavailable || // Unavailable notes can not be favourited
Usr_ItsMe (Not->UsrCod)) // I am the author
/* Put disabled icon */
TL_Fav_PutDisabledIconFav (Not->NumFavs);
else // Available and I am not the author
TL_Fav_PutFormToFavUnfNote (Not->NotCod);
HTM_DIV_End ();
/***** Show who have marked this note as favourite *****/
TL_Fav_ShowUsrsWhoHaveMarkedAsFav (TL_Fav_NOTE,
Not->NotCod,Not->UsrCod,Not->NumFavs,
HowManyUsrs);
} }
static void TL_Fav_FavNote (struct TL_Not_Note *Not) static void TL_Fav_FavNote (struct TL_Not_Note *Not)
@ -282,7 +265,8 @@ void TL_Fav_ShowAllFaversComGbl (void)
Med_MediaDestructor (&Com.Content.Media); Med_MediaDestructor (&Com.Content.Media);
/***** Write HTML inside DIV with form to fav/unfav *****/ /***** Write HTML inside DIV with form to fav/unfav *****/
TL_Fav_PutIconToFavUnfComm (&Com,TL_Usr_SHOW_ALL_USRS); TL_Fav_PutIconToFavUnf (TL_Fav_COMM,Com.PubCod,Com.UsrCod,Com.NumFavs,
TL_Usr_SHOW_ALL_USRS);
} }
void TL_Fav_FavCommUsr (void) void TL_Fav_FavCommUsr (void)
@ -302,7 +286,8 @@ void TL_Fav_FavCommGbl (void)
TL_Fav_FavComm (&Com); TL_Fav_FavComm (&Com);
/***** Write HTML inside DIV with form to unfav *****/ /***** Write HTML inside DIV with form to unfav *****/
TL_Fav_PutIconToFavUnfComm (&Com,TL_Usr_SHOW_FEW_USRS); TL_Fav_PutIconToFavUnf (TL_Fav_COMM,Com.PubCod,Com.UsrCod,Com.NumFavs,
TL_Usr_SHOW_FEW_USRS);
} }
void TL_Fav_UnfCommUsr (void) void TL_Fav_UnfCommUsr (void)
@ -322,25 +307,33 @@ void TL_Fav_UnfCommGbl (void)
TL_Fav_UnfComm (&Com); TL_Fav_UnfComm (&Com);
/***** Write HTML inside DIV with form to fav *****/ /***** Write HTML inside DIV with form to fav *****/
TL_Fav_PutIconToFavUnfComm (&Com,TL_Usr_SHOW_FEW_USRS); TL_Fav_PutIconToFavUnf (TL_Fav_COMM,Com.PubCod,Com.UsrCod,Com.NumFavs,
TL_Usr_SHOW_FEW_USRS);
} }
void TL_Fav_PutIconToFavUnfComm (const struct TL_Com_Comment *Com, /*****************************************************************************/
TL_Usr_HowManyUsrs_t HowManyUsrs) /**************** Put icon to fav/unfav and list of favers *******************/
/*****************************************************************************/
void TL_Fav_PutIconToFavUnf (TL_Fav_WhatToFav_t WhatToFav,
long Cod,long UsrCod,unsigned NumFavs,
TL_Usr_HowManyUsrs_t HowManyUsrs)
{ {
/***** Put form to fav/unfav this comment *****/ /***** Put form to fav/unfav this comment *****/
/* Begin container */
HTM_DIV_Begin ("class=\"TL_ICO\""); HTM_DIV_Begin ("class=\"TL_ICO\"");
if (Usr_ItsMe (Com->UsrCod)) // I am the author
/* Put disabled icon */ /* Icon to fav/unfav */
TL_Fav_PutDisabledIconFav (Com->NumFavs); if (Usr_ItsMe (UsrCod)) // I am the author ==> I can not fav/unfav
else // I am not the author TL_Fav_PutDisabledIconFav (NumFavs);
TL_Fav_PutFormToFavUnfComm (Com->PubCod); else // I am not the author
TL_Fav_PutFormToFavUnf (WhatToFav,Cod);
/* End container */
HTM_DIV_End (); HTM_DIV_End ();
/***** Show who have marked this comment as favourite *****/ /***** Show who have marked this comment as favourite *****/
TL_Fav_ShowUsrsWhoHaveMarkedAsFav (TL_Fav_COMM, TL_Fav_ShowUsrsWhoHaveMarkedAsFav (WhatToFav,Cod,UsrCod,NumFavs,HowManyUsrs);
Com->PubCod,Com->UsrCod,Com->NumFavs,
HowManyUsrs);
} }
static void TL_Fav_FavComm (struct TL_Com_Comment *Com) static void TL_Fav_FavComm (struct TL_Com_Comment *Com)
@ -487,66 +480,54 @@ static void TL_Fav_PutDisabledIconFav (unsigned NumFavs)
/************************** Form to fav/unfav note ***************************/ /************************** Form to fav/unfav note ***************************/
/*****************************************************************************/ /*****************************************************************************/
static void TL_Fav_PutFormToFavUnfNote (long NotCod) static void TL_Fav_PutFormToFavUnf (TL_Fav_WhatToFav_t WhatToFav,long Cod)
{ {
extern const char *Txt_TIMELINE_Favourite; extern const char *Txt_TIMELINE_Favourite;
extern const char *Txt_TIMELINE_Mark_as_favourite; extern const char *Txt_TIMELINE_Mark_as_favourite;
struct TL_Form Form[2] = struct TL_Form Form[TL_Fav_NUM_WHAT_TO_FAV][2] =
{ {
[false] = // I have not faved ==> fav [TL_Fav_NOTE] =
{
.Action = TL_Frm_FAV_NOTE,
.ParamFormat = "NotCod=%ld",
.ParamCod = NotCod,
.Icon = TL_Fav_ICON_FAV,
.Title = Txt_TIMELINE_Mark_as_favourite,
},
[true] = // I have faved ==> unfav
{ {
.Action = TL_Frm_UNF_NOTE, [false] = // I have not faved ==> fav
.ParamFormat = "NotCod=%ld", {
.ParamCod = NotCod, .Action = TL_Frm_FAV_NOTE,
.Icon = TL_Fav_ICON_FAVED, .ParamFormat = "NotCod=%ld",
.Title = Txt_TIMELINE_Favourite, .ParamCod = Cod,
.Icon = TL_Fav_ICON_FAV,
.Title = Txt_TIMELINE_Mark_as_favourite,
},
[true] = // I have faved ==> unfav
{
.Action = TL_Frm_UNF_NOTE,
.ParamFormat = "NotCod=%ld",
.ParamCod = Cod,
.Icon = TL_Fav_ICON_FAVED,
.Title = Txt_TIMELINE_Favourite,
},
},
[TL_Fav_COMM] =
{
[false] = // I have not faved ==> fav
{
.Action = TL_Frm_FAV_COMM,
.ParamFormat = "PubCod=%ld",
.ParamCod = Cod,
.Icon = TL_Fav_ICON_FAV,
.Title = Txt_TIMELINE_Mark_as_favourite,
},
[true] = // I have faved ==> unfav
{
.Action = TL_Frm_UNF_COMM,
.ParamFormat = "PubCod=%ld",
.ParamCod = Cod,
.Icon = TL_Fav_ICON_FAVED,
.Title = Txt_TIMELINE_Favourite,
},
}, },
}; };
/***** Form and icon to fav/unfav note *****/ /***** Form and icon to fav/unfav note *****/
TL_Frm_FormFavSha (&Form[TL_DB_CheckIfFavedByUsr (TL_Fav_NOTE,NotCod, TL_Frm_FormFavSha (&Form[WhatToFav][TL_DB_CheckIfFavedByUsr (WhatToFav,Cod,Gbl.Usrs.Me.UsrDat.UsrCod)]);
Gbl.Usrs.Me.UsrDat.UsrCod)]);
}
/*****************************************************************************/
/************************** Form to fav/unfav comment ************************/
/*****************************************************************************/
static void TL_Fav_PutFormToFavUnfComm (long PubCod)
{
extern const char *Txt_TIMELINE_Favourite;
extern const char *Txt_TIMELINE_Mark_as_favourite;
struct TL_Form Form[2] =
{
[false] = // I have not faved ==> fav
{
.Action = TL_Frm_FAV_COMM,
.ParamFormat = "PubCod=%ld",
.ParamCod = PubCod,
.Icon = TL_Fav_ICON_FAV,
.Title = Txt_TIMELINE_Mark_as_favourite,
},
[true] = // I have faved ==> unfav
{
.Action = TL_Frm_UNF_COMM,
.ParamFormat = "PubCod=%ld",
.ParamCod = PubCod,
.Icon = TL_Fav_ICON_FAVED,
.Title = Txt_TIMELINE_Favourite,
},
};
/***** Form and icon to fav/unfav *****/
TL_Frm_FormFavSha (&Form[TL_DB_CheckIfFavedByUsr (TL_Fav_COMM,PubCod,
Gbl.Usrs.Me.UsrDat.UsrCod)]);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -51,8 +51,6 @@ void TL_Fav_FavNoteUsr (void);
void TL_Fav_FavNoteGbl (void); void TL_Fav_FavNoteGbl (void);
void TL_Fav_UnfNoteUsr (void); void TL_Fav_UnfNoteUsr (void);
void TL_Fav_UnfNoteGbl (void); void TL_Fav_UnfNoteGbl (void);
void TL_Fav_PutIconToFavUnfNote (const struct TL_Not_Note *Not,
TL_Usr_HowManyUsrs_t HowManyUsrs);
void TL_Fav_ShowAllFaversComUsr (void); void TL_Fav_ShowAllFaversComUsr (void);
void TL_Fav_ShowAllFaversComGbl (void); void TL_Fav_ShowAllFaversComGbl (void);
@ -60,7 +58,9 @@ void TL_Fav_FavCommUsr (void);
void TL_Fav_FavCommGbl (void); void TL_Fav_FavCommGbl (void);
void TL_Fav_UnfCommUsr (void); void TL_Fav_UnfCommUsr (void);
void TL_Fav_UnfCommGbl (void); void TL_Fav_UnfCommGbl (void);
void TL_Fav_PutIconToFavUnfComm (const struct TL_Com_Comment *Com,
TL_Usr_HowManyUsrs_t HowManyUsrs); void TL_Fav_PutIconToFavUnf (TL_Fav_WhatToFav_t WhatToFav,
long Cod,long UsrCod,unsigned NumFavs,
TL_Usr_HowManyUsrs_t HowManyUsrs);
#endif #endif

View File

@ -821,7 +821,8 @@ static void TL_Not_WriteFavShaRem (const struct TL_Timeline *Timeline,
HTM_DIV_Begin ("id=\"fav_not_%s_%u\"" HTM_DIV_Begin ("id=\"fav_not_%s_%u\""
" class=\"TL_FAV_NOT TL_FAV_NOT_WIDTH\"", " class=\"TL_FAV_NOT TL_FAV_NOT_WIDTH\"",
Gbl.UniqueNameEncrypted,NumDiv); Gbl.UniqueNameEncrypted,NumDiv);
TL_Fav_PutIconToFavUnfNote (Not,TL_Usr_SHOW_FEW_USRS); TL_Fav_PutIconToFavUnf (TL_Fav_NOTE,Not->NotCod,Not->UsrCod,Not->NumFavs,
TL_Usr_SHOW_FEW_USRS);
HTM_DIV_End (); HTM_DIV_End ();
/***** Foot column 2: share zone *****/ /***** Foot column 2: share zone *****/