Version 20.34: Feb 23, 2021 Code refactoring in timeline related to sharing and faving. (305011 lines)

This commit is contained in:
acanas 2021-02-23 09:17:09 +01:00
parent bb14ad098c
commit 8b27481510
9 changed files with 333 additions and 329 deletions

View File

@ -553,7 +553,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
En OpenSWAD: En OpenSWAD:
ps2pdf source.ps destination.pdf ps2pdf source.ps destination.pdf
*/ */
#define Log_PLATFORM_VERSION "SWAD 20.33.11 (2021-02-23)" #define Log_PLATFORM_VERSION "SWAD 20.34 (2021-02-23)"
#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"
/* /*
@ -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: 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
Version 20.34: Feb 23, 2021 Code refactoring in timeline related to sharing and faving. (305011 lines)
Version 20.33.11: Feb 23, 2021 Code refactoring in timeline. (305001 lines) Version 20.33.11: Feb 23, 2021 Code refactoring in timeline. (305001 lines)
Version 20.33.10: Feb 23, 2021 Code refactoring related to writing a timeline notes and comments. (305038 lines) Version 20.33.10: Feb 23, 2021 Code refactoring related to writing a timeline notes and comments. (305038 lines)
Version 20.33.9: Feb 22, 2021 Code refactoring related to writing a timeline comment. (304949 lines) Version 20.33.9: Feb 22, 2021 Code refactoring related to writing a timeline comment. (304949 lines)

View File

@ -42027,27 +42027,6 @@ const char *Txt_SEX_SINGULAR_Abc[Usr_NUM_SEXS] =
#endif #endif
}; };
const char *Txt_Share =
#if L==1 // ca
"Compartir";
#elif L==2 // de
"Teilen";
#elif L==3 // en
"Share";
#elif L==4 // es
"Compartir";
#elif L==5 // fr
"Partager";
#elif L==6 // gn
"Compartir"; // Okoteve traducción
#elif L==7 // it
"Condividere";
#elif L==8 // pl
"Dzielić";
#elif L==9 // pt
"Compartilhar";
#endif
const char *Txt_Shared_files_area = const char *Txt_Shared_files_area =
#if L==1 // ca #if L==1 // ca
"Zona d'arxius compartits"; "Zona d'arxius compartits";
@ -52546,6 +52525,89 @@ const char *Txt_Timeline_OF_A_USER = // Warning: it is very important to include
"Timeline de %s"; "Timeline de %s";
#endif #endif
const char *Txt_TIMELINE_Favourite =
#if L==1 // ca
"Favorit";
#elif L==2 // de
"Favorit";
#elif L==3 // en
"Favourite";
#elif L==4 // es
"Favorito";
#elif L==5 // fr
"Favori";
#elif L==6 // gn
"Favorito"; // Okoteve traducción
#elif L==7 // it
"Preferito";
#elif L==8 // pl
"Ulubiony";
#elif L==9 // pt
"Favorito";
#endif
const char *Txt_TIMELINE_Favourited_by_X_USERS = // Warning: it is very important to include %ld in the following sentences
#if L==1 // ca
"Marcat com favorit per %ld";
#elif L==2 // de
"Von %ld vorgemerkt";
#elif L==3 // en
"Favourited by %ld";
#elif L==4 // es
"Marcado como favorito por %ld";
#elif L==5 // fr
"Ajouté aux favoris par %ld";
#elif L==6 // gn
"Marcado como favorito por %ld"; // Okoteve traducción
#elif L==7 // it
"Preferiti da %ld";
#elif L==8 // pl
"Dodane do ulubionych przez %ld";
#elif L==9 // pt
"Marcado como favorito por %ld";
#endif
const char *Txt_TIMELINE_Not_favourited_by_anyone = // No favourited
#if L==1 // ca
"No marcat com favorit per ningú";
#elif L==2 // de
"Niemand hat sie als Favorit markiert";
#elif L==3 // en
"Not favourited by anyone";
#elif L==4 // es
"No marcado como favorito por nadie";
#elif L==5 // fr
"Personne n'a marqué comme favori";
#elif L==6 // gn
"No marcado como favorito por nadie"; // Okoteve traducción
#elif L==7 // it
"Non preferiti da chiunque";
#elif L==8 // pl
"Nie przez nikogo ulubionych";
#elif L==9 // pt
"Não marcado como favorito por qualquer pessoa";
#endif
const char *Txt_TIMELINE_Not_shared_by_anyone = // No shared
#if L==1 // ca
"No compartit per ningú";
#elif L==2 // de
"Nicht durch Dritte freigegebenen";
#elif L==3 // en
"Not shared by anyone";
#elif L==4 // es
"No compartido por nadie";
#elif L==5 // fr
"Personne n'a partagé";
#elif L==6 // gn
"No compartido por nadie"; // Okoteve traducción
#elif L==7 // it
"Non condiviso da chiunque";
#elif L==8 // pl
"Nie jest dzielona przez nikogo";
#elif L==9 // pt
"Não compartilhado por qualquer pessoa";
#endif
const char *Txt_TIMELINE_NOTE[TL_NOT_NUM_NOTE_TYPES] = const char *Txt_TIMELINE_NOTE[TL_NOT_NUM_NOTE_TYPES] =
{ {
@ -52823,132 +52885,6 @@ const char *Txt_TIMELINE_NOTE[TL_NOT_NUM_NOTE_TYPES] =
#endif #endif
}; };
const char *Txt_TIMELINE_NOTE_Favourite =
#if L==1 // ca
"Favorit";
#elif L==2 // de
"Favorit";
#elif L==3 // en
"Favourite";
#elif L==4 // es
"Favorito";
#elif L==5 // fr
"Favori";
#elif L==6 // gn
"Favorito"; // Okoteve traducción
#elif L==7 // it
"Preferito";
#elif L==8 // pl
"Ulubiony";
#elif L==9 // pt
"Favorito";
#endif
const char *Txt_TIMELINE_NOTE_Favourited_by_X_USERS = // Warning: it is very important to include %ld in the following sentences
#if L==1 // ca
"Marcat com favorit per %ld";
#elif L==2 // de
"Von %ld vorgemerkt";
#elif L==3 // en
"Favourited by %ld";
#elif L==4 // es
"Marcado como favorito por %ld";
#elif L==5 // fr
"Ajouté aux favoris par %ld";
#elif L==6 // gn
"Marcado como favorito por %ld"; // Okoteve traducción
#elif L==7 // it
"Preferiti da %ld";
#elif L==8 // pl
"Dodane do ulubionych przez %ld";
#elif L==9 // pt
"Marcado como favorito por %ld";
#endif
const char *Txt_TIMELINE_NOTE_Shared =
#if L==1 // ca
"Compartit";
#elif L==2 // de
"Geteilt";
#elif L==3 // en
"Shared";
#elif L==4 // es
"Compartido";
#elif L==5 // fr
"Partagé";
#elif L==6 // gn
"Compartido"; // Okoteve traducción
#elif L==7 // it
"Condiviso";
#elif L==8 // pl
"Udostępnione";
#elif L==9 // pt
"Compartilhado";
#endif
const char *Txt_TIMELINE_NOTE_Shared_by_X_USERS = // Warning: it is very important to include %ld in the following sentences
#if L==1 // ca
"Compartit per %ld";
#elif L==2 // de
"Von %ld geteilt";
#elif L==3 // en
"Shared by %ld";
#elif L==4 // es
"Compartido por %ld";
#elif L==5 // fr
"Partagé par %ld";
#elif L==6 // gn
"Compartido por %ld"; // Okoteve traducción
#elif L==7 // it
"Condiviso da %ld";
#elif L==8 // pl
"Udostępnione przez %ld";
#elif L==9 // pt
"Compartilhado por %ld";
#endif
const char *Txt_TIMELINE_NOTE_Not_favourited_by_anyone = // No longer shared
#if L==1 // ca
"No marcat com favorit per ningú";
#elif L==2 // de
"Niemand hat sie als Favorit markiert";
#elif L==3 // en
"Not favourited by anyone";
#elif L==4 // es
"No marcado como favorito por nadie";
#elif L==5 // fr
"Personne n'a marqué comme favori";
#elif L==6 // gn
"No marcado como favorito por nadie"; // Okoteve traducción
#elif L==7 // it
"Non preferiti da chiunque";
#elif L==8 // pl
"Nie przez nikogo ulubionych";
#elif L==9 // pt
"Não marcado como favorito por qualquer pessoa";
#endif
const char *Txt_TIMELINE_NOTE_Not_shared_by_anyone = // No longer shared
#if L==1 // ca
"No compartit per ningú";
#elif L==2 // de
"Nicht durch Dritte freigegebenen";
#elif L==3 // en
"Not shared by anyone";
#elif L==4 // es
"No compartido por nadie";
#elif L==5 // fr
"Personne n'a partagé";
#elif L==6 // gn
"No compartido por nadie"; // Okoteve traducción
#elif L==7 // it
"Non condiviso da chiunque";
#elif L==8 // pl
"Nie jest dzielona przez nikogo";
#elif L==9 // pt
"Não compartilhado por qualquer pessoa";
#endif
const char *Txt_TIMELINE_NOTE_TOP_MESSAGES[TL_NUM_TOP_MESSAGES] = const char *Txt_TIMELINE_NOTE_TOP_MESSAGES[TL_NUM_TOP_MESSAGES] =
{ {
[TL_TOP_MESSAGE_NONE] = [TL_TOP_MESSAGE_NONE] =
@ -53210,6 +53146,69 @@ const char *Txt_TIMETABLE_TYPES[TT_NUM_TIMETABLE_TYPES] =
#endif #endif
}; };
const char *Txt_TIMELINE_Share =
#if L==1 // ca
"Compartir";
#elif L==2 // de
"Teilen";
#elif L==3 // en
"Share";
#elif L==4 // es
"Compartir";
#elif L==5 // fr
"Partager";
#elif L==6 // gn
"Compartir"; // Okoteve traducción
#elif L==7 // it
"Condividere";
#elif L==8 // pl
"Dzielić";
#elif L==9 // pt
"Compartilhar";
#endif
const char *Txt_TIMELINE_Shared =
#if L==1 // ca
"Compartit";
#elif L==2 // de
"Geteilt";
#elif L==3 // en
"Shared";
#elif L==4 // es
"Compartido";
#elif L==5 // fr
"Partagé";
#elif L==6 // gn
"Compartido"; // Okoteve traducción
#elif L==7 // it
"Condiviso";
#elif L==8 // pl
"Udostępnione";
#elif L==9 // pt
"Compartilhado";
#endif
const char *Txt_TIMELINE_Shared_by_X_USERS = // Warning: it is very important to include %ld in the following sentences
#if L==1 // ca
"Compartit per %ld";
#elif L==2 // de
"Von %ld geteilt";
#elif L==3 // en
"Shared by %ld";
#elif L==4 // es
"Compartido por %ld";
#elif L==5 // fr
"Partagé par %ld";
#elif L==6 // gn
"Compartido por %ld"; // Okoteve traducción
#elif L==7 // it
"Condiviso da %ld";
#elif L==8 // pl
"Udostępnione przez %ld";
#elif L==9 // pt
"Compartilhado por %ld";
#endif
const char *Txt_TIMETABLE_CLASS_TYPES[TT_NUM_CLASS_TYPES] = const char *Txt_TIMETABLE_CLASS_TYPES[TT_NUM_CLASS_TYPES] =
{ {
[TT_FREE] = [TT_FREE] =

View File

@ -645,7 +645,7 @@ static void TL_Com_WriteContent (struct TL_Com_Comment *Com)
static void TL_Com_WriteButtons (const struct TL_Timeline *Timeline, static void TL_Com_WriteButtons (const struct TL_Timeline *Timeline,
const struct TL_Com_Comment *Com, const struct TL_Com_Comment *Com,
const struct UsrData *UsrDat) const struct UsrData *UsrDat) // Author
{ {
static unsigned NumDiv = 0; // Used to create unique div id for fav static unsigned NumDiv = 0; // Used to create unique div id for fav
@ -657,7 +657,7 @@ 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_PutFormToFavUnfComment (Com,TL_Usr_SHOW_FEW_USRS); TL_Fav_PutIconToFavUnfComment (Com,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 *****/
@ -758,8 +758,8 @@ static long TL_Com_ReceiveComment (void)
Med_GetMediaFromForm (-1L,-1L,-1,&Content.Media,NULL,NULL); Med_GetMediaFromForm (-1L,-1L,-1,&Content.Media,NULL,NULL);
Ale_ShowAlerts (NULL); Ale_ShowAlerts (NULL);
if (Content.Txt[0] || // Text not empty if (Content.Txt[0] || // Text not empty
Content.Media.Status == Med_PROCESSED) // A media is attached Content.Media.Status == Med_PROCESSED) // A media is attached
{ {
/***** Store media in filesystem and database *****/ /***** Store media in filesystem and database *****/
Med_RemoveKeepOrStoreMedia (-1L,&Content.Media); Med_RemoveKeepOrStoreMedia (-1L,&Content.Media);

View File

@ -58,20 +58,16 @@ extern struct Globals Gbl;
/***************************** Private prototypes ****************************/ /***************************** Private prototypes ****************************/
/*****************************************************************************/ /*****************************************************************************/
static void TL_Fav_PutDisabledIconFav (unsigned NumFavs);
static void TL_Fav_PutFormToFavNote (long ParamCod);
static void TL_Fav_PutFormToUnfNote (long ParamCod);
static void TL_Fav_PutFormToFavComment (long ParamCod);
static void TL_Fav_PutFormToUnfComment (long ParamCod);
static void TL_Fav_FavNote (struct TL_Not_Note *Not); static void TL_Fav_FavNote (struct TL_Not_Note *Not);
static void TL_Fav_UnfNote (struct TL_Not_Note *Not); static void TL_Fav_UnfNote (struct TL_Not_Note *Not);
static void TL_Fav_FavComment (struct TL_Com_Comment *Com); static void TL_Fav_FavComment (struct TL_Com_Comment *Com);
static void TL_Fav_UnfComment (struct TL_Com_Comment *Com); static void TL_Fav_UnfComment (struct TL_Com_Comment *Com);
static void TL_Fav_PutDisabledIconFav (unsigned NumFavs);
static void TL_Fav_PutFormToFavUnfNote (long NotCod);
static void TL_Fav_PutFormToFavUnfComm (long PubCod);
static bool TL_Fav_CheckIfNoteIsFavedByUsr (long NotCod,long UsrCod); static bool TL_Fav_CheckIfNoteIsFavedByUsr (long NotCod,long UsrCod);
static bool TL_Fav_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod); static bool TL_Fav_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod);
@ -80,72 +76,6 @@ static void TL_Fav_ShowUsrsWhoHaveMarkedNoteAsFav (const struct TL_Not_Note *Not
static void TL_Fav_ShowUsrsWhoHaveMarkedCommAsFav (const struct TL_Com_Comment *Com, static void TL_Fav_ShowUsrsWhoHaveMarkedCommAsFav (const struct TL_Com_Comment *Com,
TL_Usr_HowManyUsrs_t HowManyUsrs); TL_Usr_HowManyUsrs_t HowManyUsrs);
/*****************************************************************************/
/****************** Put disabled icon to mark as favourite *******************/
/*****************************************************************************/
static void TL_Fav_PutDisabledIconFav (unsigned NumFavs)
{
extern const char *Txt_TIMELINE_NOTE_Favourited_by_X_USERS;
extern const char *Txt_TIMELINE_NOTE_Not_favourited_by_anyone;
/***** Disabled icon to mark as favourite *****/
if (NumFavs)
{
Ico_PutDivIcon ("TL_ICO_DISABLED",TL_Fav_ICON_FAV,
Str_BuildStringLong (Txt_TIMELINE_NOTE_Favourited_by_X_USERS,
(long) NumFavs));
Str_FreeString ();
}
else
Ico_PutDivIcon ("TL_ICO_DISABLED",TL_Fav_ICON_FAV,
Txt_TIMELINE_NOTE_Not_favourited_by_anyone);
}
/*****************************************************************************/
/************************** Form to fav/unfav note ***************************/
/*****************************************************************************/
static void TL_Fav_PutFormToFavNote (long ParamCod)
{
extern const char *Txt_Mark_as_favourite;
/***** Form and icon to mark note as favourite *****/
TL_Frm_FormFavSha (TL_Frm_FAV_NOTE,"NotCod=%ld",ParamCod,
TL_Fav_ICON_FAV,Txt_Mark_as_favourite);
}
static void TL_Fav_PutFormToUnfNote (long ParamCod)
{
extern const char *Txt_TIMELINE_NOTE_Favourite;
/***** Form and icon to unfav (remove mark as favourite) note *****/
TL_Frm_FormFavSha (TL_Frm_UNF_NOTE,"NotCod=%ld",ParamCod,
TL_Fav_ICON_FAVED,Txt_TIMELINE_NOTE_Favourite);
}
/*****************************************************************************/
/************************** Form to fav/unfav comment ************************/
/*****************************************************************************/
static void TL_Fav_PutFormToFavComment (long ParamCod)
{
extern const char *Txt_Mark_as_favourite;
/***** Form and icon to mark comment as favourite *****/
TL_Frm_FormFavSha (TL_Frm_FAV_COMM,"PubCod=%ld",ParamCod,
TL_Fav_ICON_FAV,Txt_Mark_as_favourite);
}
static void TL_Fav_PutFormToUnfComment (long ParamCod)
{
extern const char *Txt_TIMELINE_NOTE_Favourite;
/***** Form and icon to unfav (remove mark as favourite) comment *****/
TL_Frm_FormFavSha (TL_Frm_UNF_COMM,"PubCod=%ld",ParamCod,
TL_Fav_ICON_FAVED,Txt_TIMELINE_NOTE_Favourite);
}
/*****************************************************************************/ /*****************************************************************************/
/********************** Mark/unmark a note as favourite **********************/ /********************** Mark/unmark a note as favourite **********************/
/*****************************************************************************/ /*****************************************************************************/
@ -168,7 +98,7 @@ 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_PutFormToFavUnfNote (&Not,TL_Usr_SHOW_ALL_USRS); TL_Fav_PutIconToFavUnfNote (&Not,TL_Usr_SHOW_ALL_USRS);
} }
void TL_Fav_FavNoteUsr (void) void TL_Fav_FavNoteUsr (void)
@ -188,7 +118,7 @@ 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_PutFormToFavUnfNote (&Not,TL_Usr_SHOW_FEW_USRS); TL_Fav_PutIconToFavUnfNote (&Not,TL_Usr_SHOW_FEW_USRS);
} }
void TL_Fav_UnfNoteUsr (void) void TL_Fav_UnfNoteUsr (void)
@ -208,10 +138,10 @@ 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_PutFormToFavUnfNote (&Not,TL_Usr_SHOW_FEW_USRS); TL_Fav_PutIconToFavUnfNote (&Not,TL_Usr_SHOW_FEW_USRS);
} }
void TL_Fav_PutFormToFavUnfNote (const struct TL_Not_Note *Not, void TL_Fav_PutIconToFavUnfNote (const struct TL_Not_Note *Not,
TL_Usr_HowManyUsrs_t HowManyUsrs) TL_Usr_HowManyUsrs_t HowManyUsrs)
{ {
/***** Put form to fav/unfav this note *****/ /***** Put form to fav/unfav this note *****/
@ -221,14 +151,7 @@ void TL_Fav_PutFormToFavUnfNote (const struct TL_Not_Note *Not,
/* Put disabled icon */ /* Put disabled icon */
TL_Fav_PutDisabledIconFav (Not->NumFavs); TL_Fav_PutDisabledIconFav (Not->NumFavs);
else // Available and I am not the author else // Available and I am not the author
{ TL_Fav_PutFormToFavUnfNote (Not->NotCod);
/* Put icon to fav/unfav */
if (TL_Fav_CheckIfNoteIsFavedByUsr (Not->NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited this note
TL_Fav_PutFormToUnfNote (Not->NotCod);
else // I am not a faver of this note
TL_Fav_PutFormToFavNote (Not->NotCod);
}
HTM_DIV_End (); HTM_DIV_End ();
/***** Show who have marked this note as favourite *****/ /***** Show who have marked this note as favourite *****/
@ -245,8 +168,8 @@ static void TL_Fav_FavNote (struct TL_Not_Note *Not)
if (Not->NotCod > 0) if (Not->NotCod > 0)
{ {
if (Gbl.Usrs.Me.Logged && if (Gbl.Usrs.Me.Logged && // I am logged...
!Usr_ItsMe (Not->UsrCod)) // I am not the author !Usr_ItsMe (Not->UsrCod)) // ...but I am not the author
if (!TL_Fav_CheckIfNoteIsFavedByUsr (Not->NotCod, if (!TL_Fav_CheckIfNoteIsFavedByUsr (Not->NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have not yet favourited the note Gbl.Usrs.Me.UsrDat.UsrCod)) // I have not yet favourited the note
{ {
@ -282,8 +205,8 @@ static void TL_Fav_UnfNote (struct TL_Not_Note *Not)
if (Not->NotCod > 0) if (Not->NotCod > 0)
if (Not->NumFavs && if (Not->NumFavs &&
Gbl.Usrs.Me.Logged && Gbl.Usrs.Me.Logged && // I am logged...
!Usr_ItsMe (Not->UsrCod)) // I am not the author !Usr_ItsMe (Not->UsrCod)) // ...but I am not the author
if (TL_Fav_CheckIfNoteIsFavedByUsr (Not->NotCod, if (TL_Fav_CheckIfNoteIsFavedByUsr (Not->NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited the note Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited the note
{ {
@ -305,7 +228,7 @@ static void TL_Fav_UnfNote (struct TL_Not_Note *Not)
} }
/*****************************************************************************/ /*****************************************************************************/
/********************* Mark/unmark a comment as favourite ************************/ /********************* Mark/unmark a comment as favourite ********************/
/*****************************************************************************/ /*****************************************************************************/
void TL_Fav_ShowAllFaversComUsr (void) void TL_Fav_ShowAllFaversComUsr (void)
@ -328,7 +251,7 @@ 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_PutFormToFavUnfComment (&Com,TL_Usr_SHOW_ALL_USRS); TL_Fav_PutIconToFavUnfComment (&Com,TL_Usr_SHOW_ALL_USRS);
} }
void TL_Fav_FavCommentUsr (void) void TL_Fav_FavCommentUsr (void)
@ -348,7 +271,7 @@ void TL_Fav_FavCommentGbl (void)
TL_Fav_FavComment (&Com); TL_Fav_FavComment (&Com);
/***** Write HTML inside DIV with form to unfav *****/ /***** Write HTML inside DIV with form to unfav *****/
TL_Fav_PutFormToFavUnfComment (&Com,TL_Usr_SHOW_FEW_USRS); TL_Fav_PutIconToFavUnfComment (&Com,TL_Usr_SHOW_FEW_USRS);
} }
void TL_Fav_UnfCommentUsr (void) void TL_Fav_UnfCommentUsr (void)
@ -368,10 +291,10 @@ void TL_Fav_UnfCommentGbl (void)
TL_Fav_UnfComment (&Com); TL_Fav_UnfComment (&Com);
/***** Write HTML inside DIV with form to fav *****/ /***** Write HTML inside DIV with form to fav *****/
TL_Fav_PutFormToFavUnfComment (&Com,TL_Usr_SHOW_FEW_USRS); TL_Fav_PutIconToFavUnfComment (&Com,TL_Usr_SHOW_FEW_USRS);
} }
void TL_Fav_PutFormToFavUnfComment (const struct TL_Com_Comment *Com, void TL_Fav_PutIconToFavUnfComment (const struct TL_Com_Comment *Com,
TL_Usr_HowManyUsrs_t HowManyUsrs) TL_Usr_HowManyUsrs_t HowManyUsrs)
{ {
/***** Put form to fav/unfav this comment *****/ /***** Put form to fav/unfav this comment *****/
@ -380,16 +303,7 @@ void TL_Fav_PutFormToFavUnfComment (const struct TL_Com_Comment *Com,
/* Put disabled icon */ /* Put disabled icon */
TL_Fav_PutDisabledIconFav (Com->NumFavs); TL_Fav_PutDisabledIconFav (Com->NumFavs);
else // I am not the author else // I am not the author
{ TL_Fav_PutFormToFavUnfComm (Com->PubCod);
/* Put icon to mark this comment as favourite */
if (TL_Fav_CheckIfCommIsFavedByUsr (Com->PubCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited this comment
/* Put icon to unfav this publication and list of users */
TL_Fav_PutFormToUnfComment (Com->PubCod);
else // I am not a favouriter
/* Put icon to fav this publication and list of users */
TL_Fav_PutFormToFavComment (Com->PubCod);
}
HTM_DIV_End (); HTM_DIV_End ();
/***** Show who have marked this comment as favourite *****/ /***** Show who have marked this comment as favourite *****/
@ -465,6 +379,95 @@ static void TL_Fav_UnfComment (struct TL_Com_Comment *Com)
Med_MediaDestructor (&Com->Content.Media); Med_MediaDestructor (&Com->Content.Media);
} }
/*****************************************************************************/
/****************** Put disabled icon to mark as favourite *******************/
/*****************************************************************************/
static void TL_Fav_PutDisabledIconFav (unsigned NumFavs)
{
extern const char *Txt_TIMELINE_Favourited_by_X_USERS;
extern const char *Txt_TIMELINE_Not_favourited_by_anyone;
/***** Disabled icon to mark as favourite *****/
if (NumFavs)
{
Ico_PutDivIcon ("TL_ICO_DISABLED",TL_Fav_ICON_FAV,
Str_BuildStringLong (Txt_TIMELINE_Favourited_by_X_USERS,
(long) NumFavs));
Str_FreeString ();
}
else
Ico_PutDivIcon ("TL_ICO_DISABLED",TL_Fav_ICON_FAV,
Txt_TIMELINE_Not_favourited_by_anyone);
}
/*****************************************************************************/
/************************** Form to fav/unfav note ***************************/
/*****************************************************************************/
static void TL_Fav_PutFormToFavUnfNote (long NotCod)
{
extern const char *Txt_TIMELINE_Favourite;
extern const char *Txt_Mark_as_favourite;
TL_Frm_Action_t Action;
const char *Icon;
const char *Title;
/***** Select whether fav/unfav *****/
if (TL_Fav_CheckIfNoteIsFavedByUsr (NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited this note
{
/* Faved ==> put form and icon to unfav */
Action = TL_Frm_UNF_NOTE;
Icon = TL_Fav_ICON_FAVED;
Title = Txt_TIMELINE_Favourite;
}
else
{
/* Not faved ==> put form and icon to fav */
Action = TL_Frm_FAV_NOTE;
Icon = TL_Fav_ICON_FAV;
Title = Txt_Mark_as_favourite;
}
/***** Form and icon to fav/unfav note *****/
TL_Frm_FormFavSha (Action,"NotCod=%ld",NotCod,Icon,Title);
}
/*****************************************************************************/
/************************** Form to fav/unfav comment ************************/
/*****************************************************************************/
static void TL_Fav_PutFormToFavUnfComm (long PubCod)
{
extern const char *Txt_TIMELINE_Favourite;
extern const char *Txt_Mark_as_favourite;
TL_Frm_Action_t Action;
const char *Icon;
const char *Title;
/***** Select whether fav/unfav *****/
if (TL_Fav_CheckIfCommIsFavedByUsr (PubCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited this comment
{
/* Faved ==> put form and icon to unfav */
Action = TL_Frm_UNF_COMM;
Icon = TL_Fav_ICON_FAVED;
Title = Txt_TIMELINE_Favourite;
}
else
{
/* Not faved ==> put form and icon to fav */
Action = TL_Frm_FAV_COMM;
Icon = TL_Fav_ICON_FAV;
Title = Txt_Mark_as_favourite;
}
/***** Form and icon to fav/unfav *****/
TL_Frm_FormFavSha (Action,"PubCod=%ld",PubCod,Icon,Title);
}
/*****************************************************************************/ /*****************************************************************************/
/****************** Check if a user has favourited a note ********************/ /****************** Check if a user has favourited a note ********************/
/*****************************************************************************/ /*****************************************************************************/

View File

@ -53,7 +53,7 @@ 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_PutFormToFavUnfNote (const struct TL_Not_Note *Not, void TL_Fav_PutIconToFavUnfNote (const struct TL_Not_Note *Not,
TL_Usr_HowManyUsrs_t HowManyUsrs); TL_Usr_HowManyUsrs_t HowManyUsrs);
void TL_Fav_ShowAllFaversComUsr (void); void TL_Fav_ShowAllFaversComUsr (void);
@ -62,7 +62,7 @@ void TL_Fav_FavCommentUsr (void);
void TL_Fav_FavCommentGbl (void); void TL_Fav_FavCommentGbl (void);
void TL_Fav_UnfCommentUsr (void); void TL_Fav_UnfCommentUsr (void);
void TL_Fav_UnfCommentGbl (void); void TL_Fav_UnfCommentGbl (void);
void TL_Fav_PutFormToFavUnfComment (const struct TL_Com_Comment *Com, void TL_Fav_PutIconToFavUnfComment (const struct TL_Com_Comment *Com,
TL_Usr_HowManyUsrs_t HowManyUsrs); TL_Usr_HowManyUsrs_t HowManyUsrs);
void TL_Fav_GetNumTimesANoteHasBeenFav (struct TL_Not_Note *Not); void TL_Fav_GetNumTimesANoteHasBeenFav (struct TL_Not_Note *Not);

View File

@ -820,13 +820,13 @@ static void TL_Not_WriteFavShaRem (const struct TL_Timeline *Timeline,
/***** Foot column 1: fav zone *****/ /***** Foot column 1: fav zone *****/
HTM_DIV_Begin ("id=\"fav_not_%s_%u\" class=\"TL_FAV_NOT TL_FAV_NOT_WIDTH\"", HTM_DIV_Begin ("id=\"fav_not_%s_%u\" class=\"TL_FAV_NOT TL_FAV_NOT_WIDTH\"",
Gbl.UniqueNameEncrypted,NumDiv); Gbl.UniqueNameEncrypted,NumDiv);
TL_Fav_PutFormToFavUnfNote (Not,TL_Usr_SHOW_FEW_USRS); TL_Fav_PutIconToFavUnfNote (Not,TL_Usr_SHOW_FEW_USRS);
HTM_DIV_End (); HTM_DIV_End ();
/***** Foot column 2: share zone *****/ /***** Foot column 2: share zone *****/
HTM_DIV_Begin ("id=\"sha_not_%s_%u\" class=\"TL_SHA_NOT TL_SHA_NOT_WIDTH\"", HTM_DIV_Begin ("id=\"sha_not_%s_%u\" class=\"TL_SHA_NOT TL_SHA_NOT_WIDTH\"",
Gbl.UniqueNameEncrypted,NumDiv); Gbl.UniqueNameEncrypted,NumDiv);
TL_Sha_PutFormToShaUnsNote (Not,TL_Usr_SHOW_FEW_USRS); TL_Sha_PutIconToShaUnsNote (Not,TL_Usr_SHOW_FEW_USRS);
HTM_DIV_End (); HTM_DIV_End ();
/***** Foot column 3: icon to remove this note *****/ /***** Foot column 3: icon to remove this note *****/

View File

@ -58,65 +58,17 @@ extern struct Globals Gbl;
/***************************** Private prototypes ****************************/ /***************************** Private prototypes ****************************/
/*****************************************************************************/ /*****************************************************************************/
static void TL_Sha_PutDisabledIconShare (unsigned NumShared);
static void TL_Sha_PutFormToShaNote (long ParamCod);
static void TL_Sha_PutFormToUnsNote (long ParamCod);
static void TL_Sha_ShaNote (struct TL_Not_Note *Not); static void TL_Sha_ShaNote (struct TL_Not_Note *Not);
static void TL_Sha_UnsNote (struct TL_Not_Note *Not); 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 bool TL_Sha_CheckIfNoteIsSharedByUsr (long NotCod,long UsrCod);
static void TL_Sha_ShowUsrsWhoHaveSharedNote (const struct TL_Not_Note *Not, static void TL_Sha_ShowUsrsWhoHaveSharedNote (const struct TL_Not_Note *Not,
TL_Usr_HowManyUsrs_t HowManyUsrs); TL_Usr_HowManyUsrs_t HowManyUsrs);
/*****************************************************************************/
/*********************** Put disabled icon to share **************************/
/*****************************************************************************/
static void TL_Sha_PutDisabledIconShare (unsigned NumShared)
{
extern const char *Txt_TIMELINE_NOTE_Shared_by_X_USERS;
extern const char *Txt_TIMELINE_NOTE_Not_shared_by_anyone;
/***** Disabled icon to share *****/
if (NumShared)
{
Ico_PutDivIcon ("TL_ICO_DISABLED",TL_Sha_ICON_SHARE,
Str_BuildStringLong (Txt_TIMELINE_NOTE_Shared_by_X_USERS,
(long) NumShared));
Str_FreeString ();
}
else
Ico_PutDivIcon ("TL_ICO_DISABLED",TL_Sha_ICON_SHARE,
Txt_TIMELINE_NOTE_Not_shared_by_anyone);
}
/*****************************************************************************/
/*********************** Form to share/unshare note **************************/
/*****************************************************************************/
static void TL_Sha_PutFormToShaNote (long ParamCod)
{
extern const char *Txt_Share;
/***** Form and icon to mark note as favourite *****/
TL_Frm_FormFavSha (TL_Frm_SHA_NOTE,
"NotCod=%ld",ParamCod,
TL_Sha_ICON_SHARE,Txt_Share);
}
static void TL_Sha_PutFormToUnsNote (long ParamCod)
{
extern const char *Txt_TIMELINE_NOTE_Shared;
/***** Form and icon to mark note as favourite *****/
TL_Frm_FormFavSha (TL_Frm_UNS_NOTE,
"NotCod=%ld",ParamCod,
TL_Sha_ICON_SHARED,Txt_TIMELINE_NOTE_Shared);
}
/*****************************************************************************/ /*****************************************************************************/
/******************************** Share a note *******************************/ /******************************** Share a note *******************************/
/*****************************************************************************/ /*****************************************************************************/
@ -139,7 +91,7 @@ void TL_Sha_ShowAllSharersNoteGbl (void)
TL_Not_GetDataOfNoteByCod (&Not); TL_Not_GetDataOfNoteByCod (&Not);
/***** Write HTML inside DIV with form to share/unshare *****/ /***** Write HTML inside DIV with form to share/unshare *****/
TL_Sha_PutFormToShaUnsNote (&Not,TL_Usr_SHOW_ALL_USRS); TL_Sha_PutIconToShaUnsNote (&Not,TL_Usr_SHOW_ALL_USRS);
} }
void TL_Sha_ShaNoteUsr (void) void TL_Sha_ShaNoteUsr (void)
@ -159,7 +111,7 @@ void TL_Sha_ShaNoteGbl (void)
TL_Sha_ShaNote (&Not); TL_Sha_ShaNote (&Not);
/***** Write HTML inside DIV with form to unshare *****/ /***** Write HTML inside DIV with form to unshare *****/
TL_Sha_PutFormToShaUnsNote (&Not,TL_Usr_SHOW_FEW_USRS); TL_Sha_PutIconToShaUnsNote (&Not,TL_Usr_SHOW_FEW_USRS);
} }
static void TL_Sha_ShaNote (struct TL_Not_Note *Not) static void TL_Sha_ShaNote (struct TL_Not_Note *Not)
@ -172,8 +124,8 @@ static void TL_Sha_ShaNote (struct TL_Not_Note *Not)
TL_Not_GetDataOfNoteByCod (Not); TL_Not_GetDataOfNoteByCod (Not);
if (Not->NotCod > 0) if (Not->NotCod > 0)
if (Gbl.Usrs.Me.Logged && if (Gbl.Usrs.Me.Logged && // I am logged...
!Usr_ItsMe (Not->UsrCod)) // I am not the author !Usr_ItsMe (Not->UsrCod)) // ...but I am not the author
if (!TL_Sha_CheckIfNoteIsSharedByUsr (Not->NotCod, if (!TL_Sha_CheckIfNoteIsSharedByUsr (Not->NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // Not yet shared by me Gbl.Usrs.Me.UsrDat.UsrCod)) // Not yet shared by me
{ {
@ -216,7 +168,7 @@ void TL_Sha_UnsNoteGbl (void)
TL_Sha_UnsNote (&Not); TL_Sha_UnsNote (&Not);
/***** Write HTML inside DIV with form to share *****/ /***** Write HTML inside DIV with form to share *****/
TL_Sha_PutFormToShaUnsNote (&Not,TL_Usr_SHOW_FEW_USRS); TL_Sha_PutIconToShaUnsNote (&Not,TL_Usr_SHOW_FEW_USRS);
} }
static void TL_Sha_UnsNote (struct TL_Not_Note *Not) static void TL_Sha_UnsNote (struct TL_Not_Note *Not)
@ -229,8 +181,8 @@ static void TL_Sha_UnsNote (struct TL_Not_Note *Not)
if (Not->NotCod > 0) if (Not->NotCod > 0)
if (Not->NumShared && if (Not->NumShared &&
Gbl.Usrs.Me.Logged && Gbl.Usrs.Me.Logged && // I am logged...
!Usr_ItsMe (Not->UsrCod)) // I am not the author !Usr_ItsMe (Not->UsrCod)) // ...but I am not the author
if (TL_Sha_CheckIfNoteIsSharedByUsr (Not->NotCod, if (TL_Sha_CheckIfNoteIsSharedByUsr (Not->NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // I am a sharer Gbl.Usrs.Me.UsrDat.UsrCod)) // I am a sharer
{ {
@ -254,7 +206,7 @@ static void TL_Sha_UnsNote (struct TL_Not_Note *Not)
} }
} }
void TL_Sha_PutFormToShaUnsNote (const struct TL_Not_Note *Not, void TL_Sha_PutIconToShaUnsNote (const struct TL_Not_Note *Not,
TL_Usr_HowManyUsrs_t HowManyUsrs) TL_Usr_HowManyUsrs_t HowManyUsrs)
{ {
/***** Put form to share/unshare this note *****/ /***** Put form to share/unshare this note *****/
@ -264,20 +216,69 @@ void TL_Sha_PutFormToShaUnsNote (const struct TL_Not_Note *Not,
/* Put disabled icon */ /* Put disabled icon */
TL_Sha_PutDisabledIconShare (Not->NumShared); TL_Sha_PutDisabledIconShare (Not->NumShared);
else // Available and I am not the author else // Available and I am not the author
{
/* Put icon to share/unshare */ /* Put icon to share/unshare */
if (TL_Sha_CheckIfNoteIsSharedByUsr (Not->NotCod, TL_Sha_PutFormToShaUnsNote (Not->NotCod);
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have shared this note
TL_Sha_PutFormToUnsNote (Not->NotCod);
else // I have not shared this note
TL_Sha_PutFormToShaNote (Not->NotCod);
}
HTM_DIV_End (); HTM_DIV_End ();
/***** Show who have shared this note *****/ /***** Show who have shared this note *****/
TL_Sha_ShowUsrsWhoHaveSharedNote (Not,HowManyUsrs); TL_Sha_ShowUsrsWhoHaveSharedNote (Not,HowManyUsrs);
} }
/*****************************************************************************/
/*********************** Put disabled icon to share **************************/
/*****************************************************************************/
static void TL_Sha_PutDisabledIconShare (unsigned NumShared)
{
extern const char *Txt_TIMELINE_Shared_by_X_USERS;
extern const char *Txt_TIMELINE_Not_shared_by_anyone;
/***** Disabled icon to share *****/
if (NumShared)
{
Ico_PutDivIcon ("TL_ICO_DISABLED",TL_Sha_ICON_SHARE,
Str_BuildStringLong (Txt_TIMELINE_Shared_by_X_USERS,
(long) NumShared));
Str_FreeString ();
}
else
Ico_PutDivIcon ("TL_ICO_DISABLED",TL_Sha_ICON_SHARE,
Txt_TIMELINE_Not_shared_by_anyone);
}
/*****************************************************************************/
/*********************** Form to share/unshare note **************************/
/*****************************************************************************/
static void TL_Sha_PutFormToShaUnsNote (long NotCod)
{
extern const char *Txt_TIMELINE_Shared;
extern const char *Txt_TIMELINE_Share;
TL_Frm_Action_t Action;
const char *Icon;
const char *Title;
/***** Select whether share/unshare *****/
if (TL_Sha_CheckIfNoteIsSharedByUsr (NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have shared this note
{
/* Shared ==> put form and icon to unshare */
Action = TL_Frm_UNS_NOTE;
Icon = TL_Sha_ICON_SHARED;
Title = Txt_TIMELINE_Shared;
}
else
{
/* Not shared ==> put form and icon to share */
Action = TL_Frm_SHA_NOTE;
Icon = TL_Sha_ICON_SHARE;
Title = Txt_TIMELINE_Share;
}
/***** Form and icon to share/unshare note *****/
TL_Frm_FormFavSha (Action,"NotCod=%ld",NotCod,Icon,Title);
}
/*****************************************************************************/ /*****************************************************************************/
/****************** Check if a user has published a note *********************/ /****************** Check if a user has published a note *********************/
/*****************************************************************************/ /*****************************************************************************/

View File

@ -47,7 +47,7 @@ void TL_Sha_ShaNoteUsr (void);
void TL_Sha_ShaNoteGbl (void); void TL_Sha_ShaNoteGbl (void);
void TL_Sha_UnsNoteUsr (void); void TL_Sha_UnsNoteUsr (void);
void TL_Sha_UnsNoteGbl (void); void TL_Sha_UnsNoteGbl (void);
void TL_Sha_PutFormToShaUnsNote (const struct TL_Not_Note *Not, void TL_Sha_PutIconToShaUnsNote (const struct TL_Not_Note *Not,
TL_Usr_HowManyUsrs_t HowManyUsrs); TL_Usr_HowManyUsrs_t HowManyUsrs);
void TL_Sha_UpdateNumTimesANoteHasBeenShared (struct TL_Not_Note *Not); void TL_Sha_UpdateNumTimesANoteHasBeenShared (struct TL_Not_Note *Not);

View File

@ -159,7 +159,7 @@ static Usr_Who_t TL_Who_GetWhoFromDB (void)
void TL_Who_SaveWhoInDB (struct TL_Timeline *Timeline) void TL_Who_SaveWhoInDB (struct TL_Timeline *Timeline)
{ {
if (Gbl.Usrs.Me.Logged) if (Gbl.Usrs.Me.Logged) // Save only if I am logged
{ {
if (Timeline->Who == Usr_WHO_UNKNOWN) if (Timeline->Who == Usr_WHO_UNKNOWN)
Timeline->Who = TL_Who_DEFAULT_WHO; Timeline->Who = TL_Who_DEFAULT_WHO;