mirror of https://github.com/acanas/swad-core.git
Version 20.33.11: Feb 23, 2021 Code refactoring in timeline.
This commit is contained in:
parent
321faa3489
commit
bb14ad098c
|
@ -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.33.10 (2021-02-23)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 20.33.11 (2021-02-23)"
|
||||
#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.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.9: Feb 22, 2021 Code refactoring related to writing a timeline comment. (304949 lines)
|
||||
Version 20.33.8: Feb 22, 2021 Code refactoring related to writing a timeline note. (304971 lines)
|
||||
|
|
|
@ -426,7 +426,6 @@ static void TL_ShowTimeline (struct TL_Timeline *Timeline,
|
|||
struct TL_Not_Note Not;
|
||||
unsigned NumPubs;
|
||||
bool GlobalTimeline = (Gbl.Usrs.Other.UsrDat.UsrCod <= 0);
|
||||
bool ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||
|
||||
/***** Begin box *****/
|
||||
Box_BoxBegin (NULL,Title,
|
||||
|
@ -438,7 +437,8 @@ static void TL_ShowTimeline (struct TL_Timeline *Timeline,
|
|||
TL_Who_PutFormWho (Timeline);
|
||||
|
||||
/***** Form to write a new post *****/
|
||||
if (GlobalTimeline || ItsMe)
|
||||
if (GlobalTimeline ||
|
||||
Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod))
|
||||
TL_Pst_PutFormToWriteNewPost (Timeline);
|
||||
|
||||
/***** New publications refreshed dynamically via AJAX *****/
|
||||
|
|
|
@ -608,13 +608,12 @@ static void TL_Com_WriteAuthorName (const struct UsrData *UsrDat) // Author
|
|||
{
|
||||
extern const char *Txt_My_public_profile;
|
||||
extern const char *Txt_Another_user_s_profile;
|
||||
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
||||
|
||||
/***** Show user's name inside form to go to user's public profile *****/
|
||||
Frm_StartFormUnique (ActSeeOthPubPrf);
|
||||
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||
HTM_BUTTON_SUBMIT_Begin (ItsMe ? Txt_My_public_profile :
|
||||
Txt_Another_user_s_profile,
|
||||
HTM_BUTTON_SUBMIT_Begin (Usr_ItsMe (UsrDat->UsrCod) ? Txt_My_public_profile :
|
||||
Txt_Another_user_s_profile,
|
||||
"BT_LINK TL_COM_AUTHOR TL_COMM_AUTHOR_WIDTH DAT_BOLD",NULL);
|
||||
HTM_Txt (UsrDat->FullName);
|
||||
HTM_BUTTON_End ();
|
||||
|
@ -955,7 +954,6 @@ static void TL_Com_RemoveComment (void)
|
|||
extern const char *Txt_The_comment_no_longer_exists;
|
||||
extern const char *Txt_Comment_removed;
|
||||
struct TL_Com_Comment Com;
|
||||
bool ItsMe;
|
||||
|
||||
/***** Initialize image *****/
|
||||
Med_MediaConstructor (&Com.Content.Media);
|
||||
|
@ -966,8 +964,7 @@ static void TL_Com_RemoveComment (void)
|
|||
|
||||
if (Com.PubCod > 0)
|
||||
{
|
||||
ItsMe = Usr_ItsMe (Com.UsrCod);
|
||||
if (ItsMe) // I am the author of this comment
|
||||
if (Usr_ItsMe (Com.UsrCod)) // I am the author of this comment
|
||||
{
|
||||
/***** Remove media associated to comment
|
||||
and delete comment from database *****/
|
||||
|
|
|
@ -214,24 +214,19 @@ void TL_Fav_UnfNoteGbl (void)
|
|||
void TL_Fav_PutFormToFavUnfNote (const struct TL_Not_Note *Not,
|
||||
TL_Usr_HowManyUsrs_t HowManyUsrs)
|
||||
{
|
||||
bool IAmTheAuthor;
|
||||
bool IAmAFaverOfThisNot;
|
||||
|
||||
/***** Put form to fav/unfav this note *****/
|
||||
HTM_DIV_Begin ("class=\"TL_ICO\"");
|
||||
IAmTheAuthor = Usr_ItsMe (Not->UsrCod);
|
||||
if (Not->Unavailable || // Unavailable notes can not be favourited
|
||||
IAmTheAuthor) // I am the author
|
||||
Usr_ItsMe (Not->UsrCod)) // I am the author
|
||||
/* Put disabled icon */
|
||||
TL_Fav_PutDisabledIconFav (Not->NumFavs);
|
||||
else // Available and I am not the author
|
||||
{
|
||||
/* Put icon to fav/unfav */
|
||||
IAmAFaverOfThisNot = TL_Fav_CheckIfNoteIsFavedByUsr (Not->NotCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
if (IAmAFaverOfThisNot) // I have favourited this note
|
||||
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
|
||||
else // I am not a faver of this note
|
||||
TL_Fav_PutFormToFavNote (Not->NotCod);
|
||||
}
|
||||
HTM_DIV_End ();
|
||||
|
@ -242,7 +237,6 @@ void TL_Fav_PutFormToFavUnfNote (const struct TL_Not_Note *Not,
|
|||
|
||||
static void TL_Fav_FavNote (struct TL_Not_Note *Not)
|
||||
{
|
||||
bool ItsMe;
|
||||
long OriginalPubCod;
|
||||
|
||||
/***** Get data of note *****/
|
||||
|
@ -251,8 +245,8 @@ static void TL_Fav_FavNote (struct TL_Not_Note *Not)
|
|||
|
||||
if (Not->NotCod > 0)
|
||||
{
|
||||
ItsMe = Usr_ItsMe (Not->UsrCod);
|
||||
if (Gbl.Usrs.Me.Logged && !ItsMe) // I am not the author
|
||||
if (Gbl.Usrs.Me.Logged &&
|
||||
!Usr_ItsMe (Not->UsrCod)) // I am not the author
|
||||
if (!TL_Fav_CheckIfNoteIsFavedByUsr (Not->NotCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have not yet favourited the note
|
||||
{
|
||||
|
@ -281,17 +275,15 @@ static void TL_Fav_FavNote (struct TL_Not_Note *Not)
|
|||
static void TL_Fav_UnfNote (struct TL_Not_Note *Not)
|
||||
{
|
||||
long OriginalPubCod;
|
||||
bool ItsMe;
|
||||
|
||||
/***** Get data of note *****/
|
||||
Not->NotCod = TL_Not_GetParamNotCod ();
|
||||
TL_Not_GetDataOfNoteByCod (Not);
|
||||
|
||||
if (Not->NotCod > 0)
|
||||
{
|
||||
ItsMe = Usr_ItsMe (Not->UsrCod);
|
||||
if (Not->NumFavs &&
|
||||
Gbl.Usrs.Me.Logged && !ItsMe) // I am not the author
|
||||
Gbl.Usrs.Me.Logged &&
|
||||
!Usr_ItsMe (Not->UsrCod)) // I am not the author
|
||||
if (TL_Fav_CheckIfNoteIsFavedByUsr (Not->NotCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited the note
|
||||
{
|
||||
|
@ -310,7 +302,6 @@ static void TL_Fav_UnfNote (struct TL_Not_Note *Not)
|
|||
if (OriginalPubCod > 0)
|
||||
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV,OriginalPubCod);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -383,24 +374,19 @@ void TL_Fav_UnfCommentGbl (void)
|
|||
void TL_Fav_PutFormToFavUnfComment (const struct TL_Com_Comment *Com,
|
||||
TL_Usr_HowManyUsrs_t HowManyUsrs)
|
||||
{
|
||||
bool IAmTheAuthor;
|
||||
bool IAmAFaverOfThisCom;
|
||||
|
||||
/***** Put form to fav/unfav this comment *****/
|
||||
HTM_DIV_Begin ("class=\"TL_ICO\"");
|
||||
IAmTheAuthor = Usr_ItsMe (Com->UsrCod);
|
||||
if (IAmTheAuthor) // I am the author
|
||||
if (Usr_ItsMe (Com->UsrCod)) // I am the author
|
||||
/* Put disabled icon */
|
||||
TL_Fav_PutDisabledIconFav (Com->NumFavs);
|
||||
else // I am not the author
|
||||
{
|
||||
/* Put icon to mark this comment as favourite */
|
||||
IAmAFaverOfThisCom = TL_Fav_CheckIfCommIsFavedByUsr (Com->PubCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
if (IAmAFaverOfThisCom) // I have favourited this comment
|
||||
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
|
||||
else // I am not a favouriter
|
||||
/* Put icon to fav this publication and list of users */
|
||||
TL_Fav_PutFormToFavComment (Com->PubCod);
|
||||
}
|
||||
|
@ -412,8 +398,6 @@ void TL_Fav_PutFormToFavUnfComment (const struct TL_Com_Comment *Com,
|
|||
|
||||
static void TL_Fav_FavComment (struct TL_Com_Comment *Com)
|
||||
{
|
||||
bool IAmTheAuthor;
|
||||
|
||||
/***** Initialize image *****/
|
||||
Med_MediaConstructor (&Com->Content.Media);
|
||||
|
||||
|
@ -422,9 +406,7 @@ static void TL_Fav_FavComment (struct TL_Com_Comment *Com)
|
|||
TL_Com_GetDataOfCommByCod (Com);
|
||||
|
||||
if (Com->PubCod > 0)
|
||||
{
|
||||
IAmTheAuthor = Usr_ItsMe (Com->UsrCod);
|
||||
if (!IAmTheAuthor) // I am not the author
|
||||
if (!Usr_ItsMe (Com->UsrCod)) // I am not the author
|
||||
if (!TL_Fav_CheckIfCommIsFavedByUsr (Com->PubCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have not yet favourited the comment
|
||||
{
|
||||
|
@ -445,7 +427,6 @@ static void TL_Fav_FavComment (struct TL_Com_Comment *Com)
|
|||
TL_Ntf_CreateNotifToAuthor (Com->UsrCod,Com->PubCod,
|
||||
Ntf_EVENT_TIMELINE_FAV);
|
||||
}
|
||||
}
|
||||
|
||||
/***** Free image *****/
|
||||
Med_MediaDestructor (&Com->Content.Media);
|
||||
|
@ -453,8 +434,6 @@ static void TL_Fav_FavComment (struct TL_Com_Comment *Com)
|
|||
|
||||
static void TL_Fav_UnfComment (struct TL_Com_Comment *Com)
|
||||
{
|
||||
bool IAmTheAuthor;
|
||||
|
||||
/***** Initialize image *****/
|
||||
Med_MediaConstructor (&Com->Content.Media);
|
||||
|
||||
|
@ -463,10 +442,8 @@ static void TL_Fav_UnfComment (struct TL_Com_Comment *Com)
|
|||
TL_Com_GetDataOfCommByCod (Com);
|
||||
|
||||
if (Com->PubCod > 0)
|
||||
{
|
||||
IAmTheAuthor = Usr_ItsMe (Com->UsrCod);
|
||||
if (Com->NumFavs &&
|
||||
!IAmTheAuthor) // I am not the author
|
||||
!Usr_ItsMe (Com->UsrCod)) // I am not the author
|
||||
if (TL_Fav_CheckIfCommIsFavedByUsr (Com->PubCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod)) // I have favourited the comment
|
||||
{
|
||||
|
@ -483,7 +460,6 @@ static void TL_Fav_UnfComment (struct TL_Com_Comment *Com)
|
|||
/***** Mark possible notifications on this comment as removed *****/
|
||||
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV,Com->PubCod);
|
||||
}
|
||||
}
|
||||
|
||||
/***** Free image *****/
|
||||
Med_MediaDestructor (&Com->Content.Media);
|
||||
|
|
|
@ -267,7 +267,6 @@ static void TL_Not_WriteTopMessage (TL_TopMessage_t TopMessage,long PublisherCod
|
|||
extern const char *Txt_Another_user_s_profile;
|
||||
extern const char *Txt_TIMELINE_NOTE_TOP_MESSAGES[TL_NUM_TOP_MESSAGES];
|
||||
struct UsrData PublisherDat;
|
||||
bool ItsMe = Usr_ItsMe (PublisherCod);
|
||||
|
||||
/***** Initialize structure with user's data *****/
|
||||
Usr_UsrDataConstructor (&PublisherDat);
|
||||
|
@ -281,8 +280,8 @@ static void TL_Not_WriteTopMessage (TL_TopMessage_t TopMessage,long PublisherCod
|
|||
/***** Show user's name inside form to go to user's public profile *****/
|
||||
Frm_StartFormUnique (ActSeeOthPubPrf);
|
||||
Usr_PutParamUsrCodEncrypted (PublisherDat.EnUsrCod);
|
||||
HTM_BUTTON_SUBMIT_Begin (ItsMe ? Txt_My_public_profile :
|
||||
Txt_Another_user_s_profile,
|
||||
HTM_BUTTON_SUBMIT_Begin (Usr_ItsMe (PublisherCod) ? Txt_My_public_profile :
|
||||
Txt_Another_user_s_profile,
|
||||
"BT_LINK TL_TOP_PUBLISHER",NULL);
|
||||
HTM_Txt (PublisherDat.FullName);
|
||||
HTM_BUTTON_End ();
|
||||
|
@ -374,13 +373,12 @@ void TL_Not_WriteAuthorName (const struct UsrData *UsrDat)
|
|||
{
|
||||
extern const char *Txt_My_public_profile;
|
||||
extern const char *Txt_Another_user_s_profile;
|
||||
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
||||
|
||||
/***** Show user's name inside form to go to user's public profile *****/
|
||||
Frm_StartFormUnique (ActSeeOthPubPrf);
|
||||
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||
HTM_BUTTON_SUBMIT_Begin (ItsMe ? Txt_My_public_profile :
|
||||
Txt_Another_user_s_profile,
|
||||
HTM_BUTTON_SUBMIT_Begin (Usr_ItsMe (UsrDat->UsrCod) ? Txt_My_public_profile :
|
||||
Txt_Another_user_s_profile,
|
||||
"BT_LINK TL_RIGHT_AUTHOR TL_RIGHT_AUTHOR_WIDTH DAT_N_BOLD",
|
||||
NULL);
|
||||
HTM_Txt (UsrDat->FullName);
|
||||
|
@ -1222,7 +1220,6 @@ static void TL_Not_RemoveNote (void)
|
|||
extern const char *Txt_The_original_post_no_longer_exists;
|
||||
extern const char *Txt_TIMELINE_Post_removed;
|
||||
struct TL_Not_Note Not;
|
||||
bool ItsMe;
|
||||
|
||||
/***** Get data of note *****/
|
||||
Not.NotCod = TL_Not_GetParamNotCod ();
|
||||
|
@ -1230,8 +1227,7 @@ static void TL_Not_RemoveNote (void)
|
|||
|
||||
if (Not.NotCod > 0)
|
||||
{
|
||||
ItsMe = Usr_ItsMe (Not.UsrCod);
|
||||
if (ItsMe) // I am the author of this note
|
||||
if (Usr_ItsMe (Not.UsrCod)) // I am the author of this note
|
||||
{
|
||||
/***** Delete note from database *****/
|
||||
TL_Not_RemoveNoteMediaAndDBEntries (&Not);
|
||||
|
|
|
@ -165,7 +165,6 @@ void TL_Sha_ShaNoteGbl (void)
|
|||
static void TL_Sha_ShaNote (struct TL_Not_Note *Not)
|
||||
{
|
||||
struct TL_Pub_Publication Pub;
|
||||
bool ItsMe;
|
||||
long OriginalPubCod;
|
||||
|
||||
/***** Get data of note *****/
|
||||
|
@ -173,9 +172,8 @@ static void TL_Sha_ShaNote (struct TL_Not_Note *Not)
|
|||
TL_Not_GetDataOfNoteByCod (Not);
|
||||
|
||||
if (Not->NotCod > 0)
|
||||
{
|
||||
ItsMe = Usr_ItsMe (Not->UsrCod);
|
||||
if (Gbl.Usrs.Me.Logged && !ItsMe) // I am not the author
|
||||
if (Gbl.Usrs.Me.Logged &&
|
||||
!Usr_ItsMe (Not->UsrCod)) // I am not the author
|
||||
if (!TL_Sha_CheckIfNoteIsSharedByUsr (Not->NotCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod)) // Not yet shared by me
|
||||
{
|
||||
|
@ -195,7 +193,6 @@ static void TL_Sha_ShaNote (struct TL_Not_Note *Not)
|
|||
TL_Ntf_CreateNotifToAuthor (Not->UsrCod,OriginalPubCod,
|
||||
Ntf_EVENT_TIMELINE_SHARE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -224,19 +221,16 @@ void TL_Sha_UnsNoteGbl (void)
|
|||
|
||||
static void TL_Sha_UnsNote (struct TL_Not_Note *Not)
|
||||
{
|
||||
// extern const char *Txt_The_original_post_no_longer_exists;
|
||||
long OriginalPubCod;
|
||||
bool ItsMe;
|
||||
|
||||
/***** Get data of note *****/
|
||||
Not->NotCod = TL_Not_GetParamNotCod ();
|
||||
TL_Not_GetDataOfNoteByCod (Not);
|
||||
|
||||
if (Not->NotCod > 0)
|
||||
{
|
||||
ItsMe = Usr_ItsMe (Not->UsrCod);
|
||||
if (Not->NumShared &&
|
||||
Gbl.Usrs.Me.Logged && !ItsMe) // I am not the author
|
||||
Gbl.Usrs.Me.Logged &&
|
||||
!Usr_ItsMe (Not->UsrCod)) // I am not the author
|
||||
if (TL_Sha_CheckIfNoteIsSharedByUsr (Not->NotCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod)) // I am a sharer
|
||||
{
|
||||
|
@ -258,28 +252,22 @@ static void TL_Sha_UnsNote (struct TL_Not_Note *Not)
|
|||
if (OriginalPubCod > 0)
|
||||
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_SHARE,OriginalPubCod);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TL_Sha_PutFormToShaUnsNote (const struct TL_Not_Note *Not,
|
||||
TL_Usr_HowManyUsrs_t HowManyUsrs)
|
||||
{
|
||||
bool IAmTheAuthor;
|
||||
bool IAmASharerOfThisNot;
|
||||
|
||||
/***** Put form to share/unshare this note *****/
|
||||
HTM_DIV_Begin ("class=\"TL_ICO\"");
|
||||
IAmTheAuthor = Usr_ItsMe (Not->UsrCod);
|
||||
if (Not->Unavailable || // Unavailable notes can not be shared
|
||||
IAmTheAuthor) // I am the author
|
||||
Usr_ItsMe (Not->UsrCod)) // I am the author
|
||||
/* Put disabled icon */
|
||||
TL_Sha_PutDisabledIconShare (Not->NumShared);
|
||||
else // Available and I am not the author
|
||||
{
|
||||
/* Put icon to share/unshare */
|
||||
IAmASharerOfThisNot = TL_Sha_CheckIfNoteIsSharedByUsr (Not->NotCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
if (IAmASharerOfThisNot) // I have shared this note
|
||||
if (TL_Sha_CheckIfNoteIsSharedByUsr (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);
|
||||
|
|
Loading…
Reference in New Issue