From f9b172af6366da4b113e6000c2e392c0bca9568c Mon Sep 17 00:00:00 2001 From: acanas Date: Thu, 11 Feb 2021 17:20:38 +0100 Subject: [PATCH] Version20.28 --- Makefile | 4 +- swad_account.c | 2 +- swad_changelog.h | 3 +- swad_notification.c | 2 +- swad_timeline.c | 319 ++---------------------------------- swad_timeline.h | 36 +--- swad_timeline_comment.c | 41 ++--- swad_timeline_favourite.c | 56 +++---- swad_timeline_favourite.h | 8 +- swad_timeline_note.c | 67 ++++++-- swad_timeline_post.c | 3 +- swad_timeline_publication.c | 14 +- swad_timeline_publication.h | 4 +- swad_timeline_share.c | 28 ++-- swad_timeline_share.h | 2 +- swad_timeline_user.c | 311 +++++++++++++++++++++++++++++++++++ swad_timeline_user.h | 76 +++++++++ 17 files changed, 541 insertions(+), 435 deletions(-) create mode 100644 swad_timeline_user.c create mode 100644 swad_timeline_user.h diff --git a/Makefile b/Makefile index b6df4ec67..9dba67732 100644 --- a/Makefile +++ b/Makefile @@ -63,8 +63,8 @@ OBJS = swad_account.o swad_action.o swad_agenda.o swad_alert.o \ swad_test_import.o swad_test_print.o swad_test_visibility.o \ swad_theme.o swad_timeline.o swad_timeline_comment.o \ swad_timeline_favourite.o swad_timeline_note.o swad_timeline_post.o \ - swad_timeline_publication.o swad_timeline_share.o swad_timeline_who.o \ - swad_timetable.o \ + swad_timeline_publication.o swad_timeline_share.o swad_timeline_user.o \ + swad_timeline_who.o swad_timetable.o \ swad_user.o \ swad_xml.o \ swad_zip.o diff --git a/swad_account.c b/swad_account.c index c96c33f2d..3d92b733d 100644 --- a/swad_account.c +++ b/swad_account.c @@ -1118,7 +1118,7 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat, UsrDat->UsrCod); /***** Remove social content associated to the user *****/ - TL_RemoveUsrContent (UsrDat->UsrCod); + TL_Usr_RemoveUsrContent (UsrDat->UsrCod); /***** Remove user's figures *****/ Prf_RemoveUsrFigures (UsrDat->UsrCod); diff --git a/swad_changelog.h b/swad_changelog.h index 5500e72a3..58224a73b 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.27 (2021-02-11)" +#define Log_PLATFORM_VERSION "SWAD 20.28 (2021-02-11)" #define CSS_FILE "swad20.8.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.28: Feb 11, 2021 New module swad_timeline_user. (305675 lines) Version 20.27: Feb 11, 2021 New module swad_timeline_post. (305593 lines) Version 20.26.1: Feb 11, 2021 Code refactoring in timeline. (305504 lines) Version 20.26: Feb 11, 2021 New module swad_timeline_who. (305540 lines) diff --git a/swad_notification.c b/swad_notification.c index 626bbb395..387f92dfe 100644 --- a/swad_notification.c +++ b/swad_notification.c @@ -878,7 +878,7 @@ void Ntf_GetNotifSummaryAndContent (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], case Ntf_EVENT_TIMELINE_SHARE: case Ntf_EVENT_TIMELINE_MENTION: // Cod is the code of the social publishing - TL_Pub_GetNotifPublication (SummaryStr,ContentStr,Cod,GetContent); + TL_Ntf_GetNotifPublication (SummaryStr,ContentStr,Cod,GetContent); break; case Ntf_EVENT_FOLLOWER: Fol_GetNotifFollower (SummaryStr,ContentStr); diff --git a/swad_timeline.c b/swad_timeline.c index 1fe8cd88d..aecc86a83 100644 --- a/swad_timeline.c +++ b/swad_timeline.c @@ -179,7 +179,7 @@ void TL_InitTimelineGbl (struct TL_Timeline *Timeline) TL_ResetTimeline (Timeline); /***** Mark all my notifications about timeline as seen *****/ - TL_MarkMyNotifAsSeen (); + TL_Ntf_MarkMyNotifAsSeen (); /***** Get which users *****/ Timeline->Who = TL_Who_GetGlobalWho (); @@ -191,7 +191,7 @@ void TL_InitTimelineGbl (struct TL_Timeline *Timeline) void TL_ResetTimeline (struct TL_Timeline *Timeline) { - Timeline->UsrOrGbl = TL_TIMELINE_GBL; + Timeline->UsrOrGbl = TL_Usr_TIMELINE_GBL; Timeline->Who = TL_Who_DEFAULT_WHO; Timeline->WhatToGet = TL_GET_RECENT_TIMELINE; Timeline->Pubs.Top = @@ -258,7 +258,7 @@ void TL_ShowTimelineGblHighlightingNot (struct TL_Timeline *Timeline, extern const char *Txt_Timeline; /***** Get list of pubications to show in timeline *****/ - Timeline->UsrOrGbl = TL_TIMELINE_GBL; + Timeline->UsrOrGbl = TL_Usr_TIMELINE_GBL; Timeline->WhatToGet = TL_GET_RECENT_TIMELINE; TL_Pub_GetListPubsToShowInTimeline (Timeline); @@ -288,7 +288,7 @@ void TL_ShowTimelineUsrHighlightingNot (struct TL_Timeline *Timeline, extern const char *Txt_Timeline_OF_A_USER; /***** Get list of pubications to show in timeline *****/ - Timeline->UsrOrGbl = TL_TIMELINE_USR; + Timeline->UsrOrGbl = TL_Usr_TIMELINE_USR; Timeline->WhatToGet = TL_GET_RECENT_TIMELINE; TL_Pub_GetListPubsToShowInTimeline (Timeline); @@ -320,7 +320,7 @@ void TL_RefreshNewTimelineGbl (void) Timeline.Who = TL_Who_GetGlobalWho (); /***** Get list of pubications to show in timeline *****/ - Timeline.UsrOrGbl = TL_TIMELINE_GBL; + Timeline.UsrOrGbl = TL_Usr_TIMELINE_GBL; Timeline.WhatToGet = TL_GET_ONLY_NEW_PUBS; TL_Pub_GetListPubsToShowInTimeline (&Timeline); @@ -347,7 +347,7 @@ void TL_RefreshOldTimelineGbl (void) Timeline.Who = TL_Who_GetGlobalWho (); /***** Show old publications *****/ - Timeline.UsrOrGbl = TL_TIMELINE_GBL; + Timeline.UsrOrGbl = TL_Usr_TIMELINE_GBL; Timeline.WhatToGet = TL_GET_ONLY_OLD_PUBS; TL_GetAndShowOldTimeline (&Timeline); } @@ -363,7 +363,7 @@ void TL_RefreshOldTimelineUsr (void) TL_ResetTimeline (&Timeline); /***** If user exists, show old publications *****/ - Timeline.UsrOrGbl = TL_TIMELINE_USR; + Timeline.UsrOrGbl = TL_Usr_TIMELINE_USR; Timeline.WhatToGet = TL_GET_ONLY_OLD_PUBS; TL_GetAndShowOldTimeline (&Timeline); } @@ -390,7 +390,7 @@ static void TL_GetAndShowOldTimeline (struct TL_Timeline *Timeline) /*****************************************************************************/ // Must be executed as a priori function -void TL_MarkMyNotifAsSeen (void) +void TL_Ntf_MarkMyNotifAsSeen (void) { Ntf_MarkNotifAsSeen (Ntf_EVENT_TIMELINE_COMMENT,-1L,-1L,Gbl.Usrs.Me.UsrDat.UsrCod); Ntf_MarkNotifAsSeen (Ntf_EVENT_TIMELINE_FAV ,-1L,-1L,Gbl.Usrs.Me.UsrDat.UsrCod); @@ -459,11 +459,13 @@ static void TL_ShowTimeline (struct TL_Timeline *Timeline, /* Link to view new publications via AJAX */ TL_Pub_PutLinkToViewNewPublications (); - /* Hidden list where insert just received (not visible) publications via AJAX */ + /* Hidden list where insert + just received (not visible) publications via AJAX */ HTM_UL_Begin ("id=\"just_now_timeline_list\" class=\"TL_LIST\""); HTM_UL_End (); - /* Hidden list where insert new (not visible) publications via AJAX */ + /* Hidden list where insert + new (not visible) publications via AJAX */ HTM_UL_Begin ("id=\"new_timeline_list\" class=\"TL_LIST\""); HTM_UL_End (); } @@ -480,8 +482,7 @@ static void TL_ShowTimeline (struct TL_Timeline *Timeline, /* Write note */ TL_Not_WriteNote (Timeline,&Not, - Pub->TopMessage, - Pub->PublisherCod, + Pub->TopMessage,Pub->PublisherCod, Not.NotCod == NotCodToHighlight ? TL_HIGHLIGHT : TL_DONT_HIGHLIGHT, TL_DONT_SHOW_ALONE); @@ -534,50 +535,6 @@ void TL_FormStart (const struct TL_Timeline *Timeline, } } -/*****************************************************************************/ -/*************** Write sharer/commenter if distinct to author ****************/ -/*****************************************************************************/ - -void TL_WriteTopMessage (TL_TopMessage_t TopMessage,long PublisherCod) - { - extern const char *Txt_My_public_profile; - 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); - - if (TopMessage != TL_TOP_MESSAGE_NONE) - { - /***** Initialize structure with user's data *****/ - Usr_UsrDataConstructor (&PublisherDat); - - /***** Get user's data *****/ - PublisherDat.UsrCod = PublisherCod; - if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&PublisherDat,Usr_DONT_GET_PREFS)) // Really we only need EncryptedUsrCod and FullName - { - HTM_DIV_Begin ("class=\"TL_TOP_CONT TL_TOP_PUBLISHER TL_WIDTH\""); - - /***** Show user's name inside form to go to user's public profile *****/ - Frm_StartFormUnique (ActSeeOthPubPrf); - Usr_PutParamUsrCodEncrypted (PublisherDat.EncryptedUsrCod); - HTM_BUTTON_SUBMIT_Begin (ItsMe ? Txt_My_public_profile : - Txt_Another_user_s_profile, - "BT_LINK TL_TOP_PUBLISHER",NULL); - HTM_Txt (PublisherDat.FullName); - HTM_BUTTON_End (); - Frm_EndForm (); - - /***** Show action made *****/ - HTM_TxtF (" %s:",Txt_TIMELINE_NOTE_TOP_MESSAGES[TopMessage]); - - HTM_DIV_End (); - } - - /***** Free memory used for user's data *****/ - Usr_UsrDataDestructor (&PublisherDat); - } - } - /*****************************************************************************/ /******************* Write the date of creation of a note ********************/ /*****************************************************************************/ @@ -601,253 +558,3 @@ void TL_WriteDateTime (time_t TimeUTC) Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, true,true,false,0x6); } - -/*****************************************************************************/ -/************* Remove all the content of a user from database ****************/ -/*****************************************************************************/ - -void TL_RemoveUsrContent (long UsrCod) - { - /***** Remove favs for comments *****/ - /* Remove all favs made by this user in any comment */ - DB_QueryDELETE ("can not remove favs", - "DELETE FROM tl_comments_fav" - " WHERE UsrCod=%ld", - UsrCod); - - /* Remove all favs for all comments of this user */ - DB_QueryDELETE ("can not remove favs", - "DELETE FROM tl_comments_fav" - " USING tl_pubs,tl_comments_fav" - " WHERE tl_pubs.PublisherCod=%ld" // Author of the comment - " AND tl_pubs.PubType=%u" - " AND tl_pubs.PubCod=tl_comments_fav.PubCod", - UsrCod,(unsigned) TL_Pub_COMMENT_TO_NOTE); - - /* Remove all favs for all comments in all the notes of the user */ - DB_QueryDELETE ("can not remove comments", - "DELETE FROM tl_comments_fav" - " USING tl_notes,tl_pubs,tl_comments_fav" - " WHERE tl_notes.UsrCod=%ld" // Author of the note - " AND tl_notes.NotCod=tl_pubs.NotCod" - " AND tl_pubs.PubType=%u" - " AND tl_pubs.PubCod=tl_comments_fav.PubCod", - UsrCod,(unsigned) TL_Pub_COMMENT_TO_NOTE); - - /***** Remove favs for notes *****/ - /* Remove all favs made by this user in any note */ - DB_QueryDELETE ("can not remove favs", - "DELETE FROM tl_notes_fav" - " WHERE UsrCod=%ld", - UsrCod); - - /* Remove all favs for all notes of this user */ - DB_QueryDELETE ("can not remove favs", - "DELETE FROM tl_notes_fav" - " USING tl_notes,tl_notes_fav" - " WHERE tl_notes.UsrCod=%ld" // Author of the note - " AND tl_notes.NotCod=tl_notes_fav.NotCod", - UsrCod); - - /***** Remove comments *****/ - /* Remove content of all the comments in all the notes of the user */ - DB_QueryDELETE ("can not remove comments", - "DELETE FROM tl_comments" - " USING tl_notes,tl_pubs,tl_comments" - " WHERE tl_notes.UsrCod=%ld" - " AND tl_notes.NotCod=tl_pubs.NotCod" - " AND tl_pubs.PubType=%u" - " AND tl_pubs.PubCod=tl_comments.PubCod", - UsrCod,(unsigned) TL_Pub_COMMENT_TO_NOTE); - - /* Remove all the comments from any user in any note of the user */ - DB_QueryDELETE ("can not remove comments", - "DELETE FROM tl_pubs" - " USING tl_notes,tl_pubs" - " WHERE tl_notes.UsrCod=%ld" - " AND tl_notes.NotCod=tl_pubs.NotCod" - " AND tl_pubs.PubType=%u", - UsrCod,(unsigned) TL_Pub_COMMENT_TO_NOTE); - - /* Remove content of all the comments of the user in any note */ - DB_QueryDELETE ("can not remove comments", - "DELETE FROM tl_comments" - " USING tl_pubs,tl_comments" - " WHERE tl_pubs.PublisherCod=%ld" - " AND tl_pubs.PubType=%u" - " AND tl_pubs.PubCod=tl_comments.PubCod", - UsrCod,(unsigned) TL_Pub_COMMENT_TO_NOTE); - - /***** Remove all the posts of the user *****/ - DB_QueryDELETE ("can not remove posts", - "DELETE FROM tl_posts" - " WHERE PstCod IN" - " (SELECT Cod FROM tl_notes" - " WHERE UsrCod=%ld AND NoteType=%u)", - UsrCod,(unsigned) TL_NOTE_POST); - - /***** Remove all the publications of any user authored by the user *****/ - DB_QueryDELETE ("can not remove publications", - "DELETE FROM tl_pubs" - " USING tl_notes,tl_pubs" - " WHERE tl_notes.UsrCod=%ld" - " AND tl_notes.NotCod=tl_pubs.NotCod", - UsrCod); - - /***** Remove all the publications of the user *****/ - DB_QueryDELETE ("can not remove publications", - "DELETE FROM tl_pubs" - " WHERE PublisherCod=%ld", - UsrCod); - - /***** Remove all the notes of the user *****/ - DB_QueryDELETE ("can not remove notes", - "DELETE FROM tl_notes" - " WHERE UsrCod=%ld", - UsrCod); - } - -/*****************************************************************************/ -/************************ Show sharers or favouriters ************************/ -/*****************************************************************************/ - -void TL_ShowNumSharersOrFavers (unsigned NumUsrs) - { - /***** Show number of sharers or favers - (users who have shared or marked this note as favourite) *****/ - HTM_TxtF (" %u",NumUsrs); - } - -void TL_ShowSharersOrFavers (MYSQL_RES **mysql_res, - unsigned NumUsrs,unsigned NumFirstUsrs) - { - MYSQL_ROW row; - unsigned NumUsr; - unsigned NumUsrsShown = 0; - struct UsrData UsrDat; - bool ShowPhoto; - char PhotoURL[PATH_MAX + 1]; - - if (NumUsrs) - { - /***** A list of users has been got from database *****/ - if (NumFirstUsrs) - { - /***** Initialize structure with user's data *****/ - Usr_UsrDataConstructor (&UsrDat); - - /***** List users *****/ - for (NumUsr = 0; - NumUsr < NumFirstUsrs; - NumUsr++) - { - /***** Get user *****/ - row = mysql_fetch_row (*mysql_res); - - /* Get user's code (row[0]) */ - UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]); - - /***** Get user's data and show user's photo *****/ - if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS)) - { - HTM_DIV_Begin ("class=\"TL_SHARER\""); - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&UsrDat,PhotoURL); - Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO12x16",Pho_ZOOM,true); // Use unique id - HTM_DIV_End (); - - NumUsrsShown++; - } - } - - /***** Free memory used for user's data *****/ - Usr_UsrDataDestructor (&UsrDat); - } - } - } - -/*****************************************************************************/ -/********************* Form to show all favers/sharers ***********************/ -/*****************************************************************************/ - -void TL_PutFormToSeeAllFaversSharers (Act_Action_t ActionGbl,Act_Action_t ActionUsr, - const char *ParamFormat,long ParamCod, - TL_HowManyUsrs_t HowManyUsrs) - { - extern const char *Txt_View_all_USERS; - - switch (HowManyUsrs) - { - case TL_SHOW_FEW_USRS: - /***** Form and icon to mark note as favourite *****/ - TL_FormFavSha (ActionGbl,ActionUsr, - ParamFormat,ParamCod, - TL_ICON_ELLIPSIS,Txt_View_all_USERS); - break; - case TL_SHOW_ALL_USRS: - Ico_PutIconOff (TL_ICON_ELLIPSIS,Txt_View_all_USERS); - break; - } - } - -/*****************************************************************************/ -/******* Form to fav/unfav or share/unshare in global or user timeline *******/ -/*****************************************************************************/ - -void TL_FormFavSha (Act_Action_t ActionGbl,Act_Action_t ActionUsr, - const char *ParamFormat,long ParamCod, - const char *Icon,const char *Title) - { - char *OnSubmit; - char ParamStr[7 + Cns_MAX_DECIMAL_DIGITS_LONG + 1]; - - /***** Create parameter string *****/ - sprintf (ParamStr,ParamFormat,ParamCod); - - /* - +---------------------------------------------------------------------------+ - | div which content will be updated (parent of parent of form) | - | +---------------------+ +-------+ +-------------------------------------+ | - | | div (parent of form)| | div | | div for users | | - | | +-----------------+ | | for | | +------+ +------+ +------+ +------+ | | - | | | this form | | | num. | | | | | | | | | form | | | - | | | +-------------+ | | | of | | | user | | user | | user | | to | | | - | | | | fav icon | | | | users | | | 1 | | 2 | | 3 | | show | | | - | | | +-------------+ | | | | | | | | | | | | all | | | - | | +-----------------+ | | | | +------+ +------+ +------+ +------+ | | - | +---------------------+ +-------+ +-------------------------------------+ | - +---------------------------------------------------------------------------+ - */ - - /***** Form and icon to mark note as favourite *****/ - /* Form with icon */ - if (Gbl.Usrs.Other.UsrDat.UsrCod > 0) - { - if (asprintf (&OnSubmit,"updateDivFaversSharers(this," - "'act=%ld&ses=%s&%s&OtherUsrCod=%s');" - " return false;", // return false is necessary to not submit form - Act_GetActCod (ActionUsr), - Gbl.Session.Id, - ParamStr, - Gbl.Usrs.Other.UsrDat.EncryptedUsrCod) < 0) - Lay_NotEnoughMemoryExit (); - Frm_StartFormUniqueAnchorOnSubmit (ActUnk,"timeline",OnSubmit); - } - else - { - if (asprintf (&OnSubmit,"updateDivFaversSharers(this," - "'act=%ld&ses=%s&%s');" - " return false;", // return false is necessary to not submit form - Act_GetActCod (ActionGbl), - Gbl.Session.Id, - ParamStr) < 0) - Lay_NotEnoughMemoryExit (); - Frm_StartFormUniqueAnchorOnSubmit (ActUnk,NULL,OnSubmit); - } - Ico_PutIconLink (Icon,Title); - Frm_EndForm (); - - /* Free allocated memory */ - free (OnSubmit); - } diff --git a/swad_timeline.h b/swad_timeline.h index b5a2f85bf..dce1b2e9b 100644 --- a/swad_timeline.h +++ b/swad_timeline.h @@ -31,6 +31,7 @@ #include "swad_media.h" #include "swad_notification.h" #include "swad_user.h" +#include "swad_timeline_user.h" /*****************************************************************************/ /****************************** Public constants *****************************/ @@ -38,11 +39,6 @@ #define TL_TIMELINE_SECTION_ID "timeline" -#define TL_ICON_ELLIPSIS "ellipsis-h.svg" - -#define TL_DEF_USRS_SHOWN 5 // Default maximum number of users shown who have share/fav a note -#define TL_MAX_USRS_SHOWN 1000 // Top maximum number of users shown who have share/fav a note - /* Timeline images will be saved with: · maximum width of TL_IMAGE_SAVED_MAX_HEIGHT @@ -70,12 +66,6 @@ typedef enum TL_TOP_MESSAGE_MENTIONED = 6, } TL_TopMessage_t; -typedef enum - { - TL_TIMELINE_USR, // Show the timeline of a user - TL_TIMELINE_GBL, // Show the timeline of the users follwed by me - } TL_UsrOrGbl_t; - #define TL_NUM_WHAT_TO_GET 3 typedef enum { @@ -89,7 +79,7 @@ typedef enum struct TL_Timeline { - TL_UsrOrGbl_t UsrOrGbl; + TL_Usr_UsrOrGbl_t UsrOrGbl; Usr_Who_t Who; TL_WhatToGet_t WhatToGet; struct @@ -101,12 +91,6 @@ struct TL_Timeline long PubCod; // Used as parameter about social publishing to be edited, removed... }; -typedef enum - { - TL_SHOW_FEW_USRS, // Show a few first favers/sharers - TL_SHOW_ALL_USRS, // Show all favers/sharers - } TL_HowManyUsrs_t; - typedef enum { TL_DONT_HIGHLIGHT, @@ -141,26 +125,12 @@ void TL_RefreshNewTimelineGbl (void); void TL_RefreshOldTimelineGbl (void); void TL_RefreshOldTimelineUsr (void); -void TL_MarkMyNotifAsSeen (void); +void TL_Ntf_MarkMyNotifAsSeen (void); void TL_FormStart (const struct TL_Timeline *Timeline, Act_Action_t ActionGbl, Act_Action_t ActionUsr); -void TL_WriteTopMessage (TL_TopMessage_t TopMessage,long PublisherCod); - void TL_WriteDateTime (time_t TimeUTC); -void TL_RemoveUsrContent (long UsrCod); - -void TL_ShowNumSharersOrFavers (unsigned NumUsrs); -void TL_ShowSharersOrFavers (MYSQL_RES **mysql_res, - unsigned NumUsrs,unsigned NumFirstUsrs); -void TL_PutFormToSeeAllFaversSharers (Act_Action_t ActionGbl,Act_Action_t ActionUsr, - const char *ParamFormat,long ParamCod, - TL_HowManyUsrs_t HowManyUsrs); -void TL_FormFavSha (Act_Action_t ActionGbl,Act_Action_t ActionUsr, - const char *ParamFormat,long ParamCod, - const char *Icon,const char *Title); - #endif diff --git a/swad_timeline_comment.c b/swad_timeline_comment.c index 238cf0ceb..659894e93 100644 --- a/swad_timeline_comment.c +++ b/swad_timeline_comment.c @@ -82,7 +82,6 @@ static void TL_Com_PutIconToToggleComments (const char *UniqueId, const char *Icon,const char *Text); static void TL_Com_WriteComment (struct TL_Timeline *Timeline, struct TL_Com_Comment *Com, - TL_TopMessage_t TopMessage,long UsrCod, TL_ShowAlone_t ShowCommentAlone); // Comment is shown alone, not in a list static void TL_Com_WriteAuthorComment (struct UsrData *UsrDat); @@ -160,7 +159,8 @@ void TL_Com_PutHiddenFormToWriteNewComment (const struct TL_Timeline *Timeline, HTM_DIV_Begin ("class=\"TL_COM_CONT TL_COMM_WIDTH\""); /* Begin form to write the post */ - TL_FormStart (Timeline,ActRcvTL_ComGbl,ActRcvTL_ComUsr); + TL_FormStart (Timeline,ActRcvTL_ComGbl, + ActRcvTL_ComUsr); TL_Not_PutHiddenParamNotCod (NotCod); /* Textarea and button */ @@ -491,8 +491,7 @@ static void TL_Com_WriteOneCommentInList (struct TL_Timeline *Timeline, /***** Write comment *****/ TL_Com_WriteComment (Timeline,&Com, - TL_TOP_MESSAGE_NONE,-1L, - TL_DONT_SHOW_ALONE); + TL_DONT_SHOW_ALONE); /***** Free image *****/ Med_MediaDestructor (&Com.Content.Media); @@ -562,10 +561,9 @@ static void TL_Com_PutIconToToggleComments (const char *UniqueId, static void TL_Com_WriteComment (struct TL_Timeline *Timeline, struct TL_Com_Comment *Com, - TL_TopMessage_t TopMessage,long UsrCod, TL_ShowAlone_t ShowCommentAlone) // Comment is shown alone, not in a list { - struct UsrData UsrDat; + struct UsrData AuthorDat; bool IAmTheAuthor; bool ShowPhoto = false; char PhotoURL[PATH_MAX + 1]; @@ -579,9 +577,6 @@ static void TL_Com_WriteComment (struct TL_Timeline *Timeline, NULL,NULL, NULL,Box_NOT_CLOSABLE); - /***** Write sharer/commenter if distinct to author *****/ - TL_WriteTopMessage (TopMessage,UsrCod); - HTM_DIV_Begin ("class=\"TL_LEFT_PHOTO\""); HTM_DIV_End (); @@ -600,16 +595,16 @@ static void TL_Com_WriteComment (struct TL_Timeline *Timeline, else { /***** Get author's data *****/ - Usr_UsrDataConstructor (&UsrDat); - UsrDat.UsrCod = Com->UsrCod; - Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS); - IAmTheAuthor = Usr_ItsMe (UsrDat.UsrCod); + Usr_UsrDataConstructor (&AuthorDat); + AuthorDat.UsrCod = Com->UsrCod; + Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&AuthorDat,Usr_DONT_GET_PREFS); + IAmTheAuthor = Usr_ItsMe (AuthorDat.UsrCod); /***** Left: write author's photo *****/ HTM_DIV_Begin ("class=\"TL_COM_PHOTO\""); - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&UsrDat,PhotoURL); - Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL : - NULL, + ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&AuthorDat,PhotoURL); + Pho_ShowUsrPhoto (&AuthorDat,ShowPhoto ? PhotoURL : + NULL, "PHOTO30x40",Pho_ZOOM,true); // Use unique id HTM_DIV_End (); @@ -617,7 +612,7 @@ static void TL_Com_WriteComment (struct TL_Timeline *Timeline, HTM_DIV_Begin ("class=\"TL_COM_CONT TL_COMM_WIDTH\""); /* Write author's full name and nickname */ - TL_Com_WriteAuthorComment (&UsrDat); + TL_Com_WriteAuthorComment (&AuthorDat); /* Write date and time */ TL_WriteDateTime (Com->DateTimeUTC); @@ -632,7 +627,7 @@ static void TL_Com_WriteComment (struct TL_Timeline *Timeline, /* Show image */ Med_ShowMedia (&Com->Content.Media,"TL_COM_MED_CONT TL_COMM_WIDTH", - "TL_COM_MED TL_COMM_WIDTH"); + "TL_COM_MED TL_COMM_WIDTH"); /* Start foot container */ HTM_DIV_Begin ("class=\"TL_FOOT TL_COMM_WIDTH\""); @@ -640,7 +635,7 @@ static void TL_Com_WriteComment (struct TL_Timeline *Timeline, /* Fav zone */ HTM_DIV_Begin ("id=\"fav_com_%s_%u\" class=\"TL_FAV_COM TL_FAV_WIDTH\"", Gbl.UniqueNameEncrypted,NumDiv); - TL_Fav_PutFormToFavUnfComment (Com,TL_SHOW_FEW_USRS); + TL_Fav_PutFormToFavUnfComment (Com,TL_Usr_SHOW_FEW_USRS); HTM_DIV_End (); /* Put icon to remove this comment */ @@ -654,7 +649,7 @@ static void TL_Com_WriteComment (struct TL_Timeline *Timeline, HTM_DIV_End (); /***** Free memory used for user's data *****/ - Usr_UsrDataDestructor (&UsrDat); + Usr_UsrDataDestructor (&AuthorDat); } /***** End list item *****/ @@ -699,7 +694,8 @@ static void TL_Com_PutFormToRemoveComment (const struct TL_Timeline *Timeline, extern const char *Txt_Remove; /***** Form to remove publication *****/ - TL_FormStart (Timeline,ActReqRemTL_ComGbl,ActReqRemTL_ComUsr); + TL_FormStart (Timeline,ActReqRemTL_ComGbl, + ActReqRemTL_ComUsr); TL_Pub_PutHiddenParamPubCod (PubCod); Ico_PutIconLink ("trash.svg",Txt_Remove); Frm_EndForm (); @@ -887,8 +883,7 @@ static void TL_Com_RequestRemovalComment (struct TL_Timeline *Timeline) /* Show comment */ TL_Com_WriteComment (Timeline,&Com, - TL_TOP_MESSAGE_NONE,-1L, - TL_SHOW_ALONE); + TL_SHOW_ALONE); /* End alert */ Timeline->PubCod = Com.PubCod; // Publication to be removed diff --git a/swad_timeline_favourite.c b/swad_timeline_favourite.c index 545f9332b..56dcc44f2 100644 --- a/swad_timeline_favourite.c +++ b/swad_timeline_favourite.c @@ -74,9 +74,9 @@ static bool TL_Fav_CheckIfNoteIsFavedByUsr (long NotCod,long UsrCod); static bool TL_Fav_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod); static void TL_Fav_ShowUsrsWhoHaveMarkedNoteAsFav (const struct TL_Not_Note *Not, - TL_HowManyUsrs_t HowManyUsrs); + TL_Usr_HowManyUsrs_t HowManyUsrs); static void TL_Fav_ShowUsrsWhoHaveMarkedCommAsFav (const struct TL_Com_Comment *Com, - TL_HowManyUsrs_t HowManyUsrs); + TL_Usr_HowManyUsrs_t HowManyUsrs); /*****************************************************************************/ /****************** Put disabled icon to mark as favourite *******************/ @@ -109,7 +109,7 @@ static void TL_Fav_PutFormToFavNote (long ParamCod) extern const char *Txt_Mark_as_favourite; /***** Form and icon to mark note as favourite *****/ - TL_FormFavSha (ActFavTL_NotGbl,ActFavTL_NotUsr, + TL_Usr_FormFavSha (ActFavTL_NotGbl,ActFavTL_NotUsr, "NotCod=%ld",ParamCod, TL_ICON_FAV,Txt_Mark_as_favourite); } @@ -119,7 +119,7 @@ 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_FormFavSha (ActUnfTL_NotGbl,ActUnfTL_NotUsr, + TL_Usr_FormFavSha (ActUnfTL_NotGbl,ActUnfTL_NotUsr, "NotCod=%ld",ParamCod, TL_ICON_FAVED,Txt_TIMELINE_NOTE_Favourite); } @@ -133,7 +133,7 @@ static void TL_Fav_PutFormToFavComment (long ParamCod) extern const char *Txt_Mark_as_favourite; /***** Form and icon to mark comment as favourite *****/ - TL_FormFavSha (ActFavTL_ComGbl,ActFavTL_ComUsr, + TL_Usr_FormFavSha (ActFavTL_ComGbl,ActFavTL_ComUsr, "PubCod=%ld",ParamCod, TL_ICON_FAV,Txt_Mark_as_favourite); } @@ -143,7 +143,7 @@ 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_FormFavSha (ActUnfTL_ComGbl,ActUnfTL_ComUsr, + TL_Usr_FormFavSha (ActUnfTL_ComGbl,ActUnfTL_ComUsr, "PubCod=%ld",ParamCod, TL_ICON_FAVED,Txt_TIMELINE_NOTE_Favourite); } @@ -170,7 +170,7 @@ void TL_Fav_ShowAllFaversNoteGbl (void) TL_Not_GetDataOfNoteByCod (&Not); /***** Write HTML inside DIV with form to fav/unfav *****/ - TL_Fav_PutFormToFavUnfNote (&Not,TL_SHOW_ALL_USRS); + TL_Fav_PutFormToFavUnfNote (&Not,TL_Usr_SHOW_ALL_USRS); } void TL_Fav_FavNoteUsr (void) @@ -190,7 +190,7 @@ void TL_Fav_FavNoteGbl (void) TL_Fav_FavNote (&Not); /***** Write HTML inside DIV with form to unfav *****/ - TL_Fav_PutFormToFavUnfNote (&Not,TL_SHOW_FEW_USRS); + TL_Fav_PutFormToFavUnfNote (&Not,TL_Usr_SHOW_FEW_USRS); } void TL_Fav_UnfNoteUsr (void) @@ -210,11 +210,11 @@ void TL_Fav_UnfNoteGbl (void) TL_Fav_UnfNote (&Not); /***** Write HTML inside DIV with form to fav *****/ - TL_Fav_PutFormToFavUnfNote (&Not,TL_SHOW_FEW_USRS); + TL_Fav_PutFormToFavUnfNote (&Not,TL_Usr_SHOW_FEW_USRS); } void TL_Fav_PutFormToFavUnfNote (const struct TL_Not_Note *Not, - TL_HowManyUsrs_t HowManyUsrs) + TL_Usr_HowManyUsrs_t HowManyUsrs) { bool IAmTheAuthor; bool IAmAFaverOfThisNot; @@ -274,7 +274,7 @@ static void TL_Fav_FavNote (struct TL_Not_Note *Not) for the author of the post *****/ OriginalPubCod = TL_Not_GetPubCodOfOriginalNote (Not->NotCod); if (OriginalPubCod > 0) - TL_Pub_CreateNotifToAuthor (Not->UsrCod,OriginalPubCod,Ntf_EVENT_TIMELINE_FAV); + TL_Ntf_CreateNotifToAuthor (Not->UsrCod,OriginalPubCod,Ntf_EVENT_TIMELINE_FAV); } } } @@ -338,7 +338,7 @@ void TL_Fav_ShowAllFaversComGbl (void) Med_MediaDestructor (&Com.Content.Media); /***** Write HTML inside DIV with form to fav/unfav *****/ - TL_Fav_PutFormToFavUnfComment (&Com,TL_SHOW_ALL_USRS); + TL_Fav_PutFormToFavUnfComment (&Com,TL_Usr_SHOW_ALL_USRS); } void TL_Fav_FavCommentUsr (void) @@ -358,7 +358,7 @@ void TL_Fav_FavCommentGbl (void) TL_Fav_FavComment (&Com); /***** Write HTML inside DIV with form to unfav *****/ - TL_Fav_PutFormToFavUnfComment (&Com,TL_SHOW_FEW_USRS); + TL_Fav_PutFormToFavUnfComment (&Com,TL_Usr_SHOW_FEW_USRS); } void TL_Fav_UnfCommentUsr (void) @@ -378,11 +378,11 @@ void TL_Fav_UnfCommentGbl (void) TL_Fav_UnfComment (&Com); /***** Write HTML inside DIV with form to fav *****/ - TL_Fav_PutFormToFavUnfComment (&Com,TL_SHOW_FEW_USRS); + TL_Fav_PutFormToFavUnfComment (&Com,TL_Usr_SHOW_FEW_USRS); } void TL_Fav_PutFormToFavUnfComment (const struct TL_Com_Comment *Com, - TL_HowManyUsrs_t HowManyUsrs) + TL_Usr_HowManyUsrs_t HowManyUsrs) { bool IAmTheAuthor; bool IAmAFaverOfThisCom; @@ -443,7 +443,7 @@ static void TL_Fav_FavComment (struct TL_Com_Comment *Com) /**** Create notification about favourite post for the author of the post ***/ - TL_Pub_CreateNotifToAuthor (Com->UsrCod,Com->PubCod,Ntf_EVENT_TIMELINE_FAV); + TL_Ntf_CreateNotifToAuthor (Com->UsrCod,Com->PubCod,Ntf_EVENT_TIMELINE_FAV); } } @@ -554,7 +554,7 @@ void TL_Fav_GetNumTimesACommHasBeenFav (struct TL_Com_Comment *Com) /*****************************************************************************/ static void TL_Fav_ShowUsrsWhoHaveMarkedNoteAsFav (const struct TL_Not_Note *Not, - TL_HowManyUsrs_t HowManyUsrs) + TL_Usr_HowManyUsrs_t HowManyUsrs) { MYSQL_RES *mysql_res; unsigned NumFirstUsrs; @@ -570,23 +570,23 @@ static void TL_Fav_ShowUsrsWhoHaveMarkedNoteAsFav (const struct TL_Not_Note *Not " ORDER BY FavCod LIMIT %u", Not->NotCod, Not->UsrCod, - HowManyUsrs == TL_SHOW_FEW_USRS ? TL_DEF_USRS_SHOWN : - TL_MAX_USRS_SHOWN); + HowManyUsrs == TL_Usr_SHOW_FEW_USRS ? TL_Usr_DEF_USRS_SHOWN : + TL_Usr_MAX_USRS_SHOWN); else NumFirstUsrs = 0; /***** Show users *****/ /* Number of users */ HTM_DIV_Begin ("class=\"TL_NUM_USRS\""); - TL_ShowNumSharersOrFavers (Not->NumFavs); + TL_Usr_ShowNumSharersOrFavers (Not->NumFavs); HTM_DIV_End (); /* List users one by one */ HTM_DIV_Begin ("class=\"TL_USRS\""); - TL_ShowSharersOrFavers (&mysql_res,Not->NumFavs,NumFirstUsrs); + TL_Usr_ShowSharersOrFavers (&mysql_res,Not->NumFavs,NumFirstUsrs); if (NumFirstUsrs < Not->NumFavs) // Not all are shown /* Clickable ellipsis to show all users */ - TL_PutFormToSeeAllFaversSharers (ActAllFavTL_NotGbl,ActAllFavTL_NotUsr, + TL_Usr_PutFormToSeeAllFaversSharers (ActAllFavTL_NotGbl,ActAllFavTL_NotUsr, "NotCod=%ld",Not->NotCod, HowManyUsrs); HTM_DIV_End (); @@ -601,7 +601,7 @@ static void TL_Fav_ShowUsrsWhoHaveMarkedNoteAsFav (const struct TL_Not_Note *Not /*****************************************************************************/ static void TL_Fav_ShowUsrsWhoHaveMarkedCommAsFav (const struct TL_Com_Comment *Com, - TL_HowManyUsrs_t HowManyUsrs) + TL_Usr_HowManyUsrs_t HowManyUsrs) { MYSQL_RES *mysql_res; unsigned NumFirstUsrs; @@ -617,23 +617,23 @@ static void TL_Fav_ShowUsrsWhoHaveMarkedCommAsFav (const struct TL_Com_Comment * " ORDER BY FavCod LIMIT %u", Com->PubCod, Com->UsrCod, - HowManyUsrs == TL_SHOW_FEW_USRS ? TL_DEF_USRS_SHOWN : - TL_MAX_USRS_SHOWN); + HowManyUsrs == TL_Usr_SHOW_FEW_USRS ? TL_Usr_DEF_USRS_SHOWN : + TL_Usr_MAX_USRS_SHOWN); else NumFirstUsrs = 0; /***** Show users *****/ /* Number of users */ HTM_DIV_Begin ("class=\"TL_NUM_USRS\""); - TL_ShowNumSharersOrFavers (Com->NumFavs); + TL_Usr_ShowNumSharersOrFavers (Com->NumFavs); HTM_DIV_End (); /* List users one by one */ HTM_DIV_Begin ("class=\"TL_USRS\""); - TL_ShowSharersOrFavers (&mysql_res,Com->NumFavs,NumFirstUsrs); + TL_Usr_ShowSharersOrFavers (&mysql_res,Com->NumFavs,NumFirstUsrs); if (NumFirstUsrs < Com->NumFavs) /* Clickable ellipsis to show all users */ - TL_PutFormToSeeAllFaversSharers (ActAllFavTL_ComGbl,ActAllFavTL_ComUsr, + TL_Usr_PutFormToSeeAllFaversSharers (ActAllFavTL_ComGbl,ActAllFavTL_ComUsr, "PubCod=%ld",Com->PubCod, HowManyUsrs); HTM_DIV_End (); diff --git a/swad_timeline_favourite.h b/swad_timeline_favourite.h index 5188f0223..33f7ccf1b 100644 --- a/swad_timeline_favourite.h +++ b/swad_timeline_favourite.h @@ -43,9 +43,9 @@ /*****************************************************************************/ void TL_Fav_PutFormToSeeAllFaversNote (long NotCod, - TL_HowManyUsrs_t HowManyUsrs); + TL_Usr_HowManyUsrs_t HowManyUsrs); void TL_Fav_PutFormToSeeAllFaversComment (long PubCod, - TL_HowManyUsrs_t HowManyUsrs); + TL_Usr_HowManyUsrs_t HowManyUsrs); void TL_Fav_ShowAllFaversNoteUsr (void); void TL_Fav_ShowAllFaversNoteGbl (void); @@ -54,7 +54,7 @@ void TL_Fav_FavNoteGbl (void); void TL_Fav_UnfNoteUsr (void); void TL_Fav_UnfNoteGbl (void); void TL_Fav_PutFormToFavUnfNote (const struct TL_Not_Note *Not, - TL_HowManyUsrs_t HowManyUsrs); + TL_Usr_HowManyUsrs_t HowManyUsrs); void TL_Fav_ShowAllFaversComUsr (void); void TL_Fav_ShowAllFaversComGbl (void); @@ -63,7 +63,7 @@ void TL_Fav_FavCommentGbl (void); void TL_Fav_UnfCommentUsr (void); void TL_Fav_UnfCommentGbl (void); void TL_Fav_PutFormToFavUnfComment (const struct TL_Com_Comment *Com, - TL_HowManyUsrs_t HowManyUsrs); + TL_Usr_HowManyUsrs_t HowManyUsrs); void TL_Fav_GetNumTimesANoteHasBeenFav (struct TL_Not_Note *Not); void TL_Fav_GetNumTimesACommHasBeenFav (struct TL_Com_Comment *Com); diff --git a/swad_timeline_note.c b/swad_timeline_note.c index e4bb9595c..394c78056 100644 --- a/swad_timeline_note.c +++ b/swad_timeline_note.c @@ -66,6 +66,8 @@ extern struct Globals Gbl; /***************************** Private prototypes ****************************/ /*****************************************************************************/ +static void TL_Not_WriteTopMessage (TL_TopMessage_t TopMessage,long PublisherCod); + static void TL_Not_PutFormGoToAction (const struct TL_Not_Note *Not, const struct For_Forums *Forums); @@ -216,9 +218,9 @@ void TL_Not_WriteNote (struct TL_Timeline *Timeline, HTM_LI_Begin ("class=\"%s\"", ShowNoteAlone == TL_SHOW_ALONE ? (Highlight == TL_HIGHLIGHT ? "TL_WIDTH TL_NEW_PUB" : - "TL_WIDTH") : + "TL_WIDTH") : (Highlight == TL_HIGHLIGHT ? "TL_WIDTH TL_SEP TL_NEW_PUB" : - "TL_WIDTH TL_SEP")); + "TL_WIDTH TL_SEP")); if (Not->NotCod <= 0 || Not->NoteType == TL_NOTE_UNKNOWN || @@ -233,7 +235,8 @@ void TL_Not_WriteNote (struct TL_Timeline *Timeline, Crs.CrsCod = -1L; /***** Write sharer/commenter if distinct to author *****/ - TL_WriteTopMessage (TopMessage,PublisherCod); + if (TopMessage != TL_TOP_MESSAGE_NONE) + TL_Not_WriteTopMessage (TopMessage,PublisherCod); /***** Initialize structure with user's data *****/ Usr_UsrDataConstructor (&AuthorDat); @@ -255,8 +258,10 @@ void TL_Not_WriteNote (struct TL_Timeline *Timeline, /* Begin right container */ HTM_DIV_Begin ("class=\"TL_RIGHT_CONT TL_RIGHT_WIDTH\""); - /* Write author's full name and date-time */ + /* Write author's full name and nickname */ TL_Not_WriteAuthorNote (&AuthorDat); + + /* Write date and time */ TL_WriteDateTime (Not->DateTimeUTC); /* Write content of the note */ @@ -388,13 +393,13 @@ void TL_Not_WriteNote (struct TL_Timeline *Timeline, /* Foot column 1: Fav zone */ HTM_DIV_Begin ("id=\"fav_not_%s_%u\" class=\"TL_FAV_NOT TL_FAV_NOT_WIDTH\"", Gbl.UniqueNameEncrypted,NumDiv); - TL_Fav_PutFormToFavUnfNote (Not,TL_SHOW_FEW_USRS); + TL_Fav_PutFormToFavUnfNote (Not,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_PutFormToShaUnsNote (Not,TL_SHOW_FEW_USRS); + TL_Sha_PutFormToShaUnsNote (Not,TL_Usr_SHOW_FEW_USRS); HTM_DIV_End (); /* Foot column 3: Icon to remove this note */ @@ -432,6 +437,47 @@ void TL_Not_WriteNote (struct TL_Timeline *Timeline, } } +/*****************************************************************************/ +/*************** Write sharer/commenter if distinct to author ****************/ +/*****************************************************************************/ + +static void TL_Not_WriteTopMessage (TL_TopMessage_t TopMessage,long PublisherCod) + { + extern const char *Txt_My_public_profile; + 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); + + /***** Get user's data *****/ + PublisherDat.UsrCod = PublisherCod; + if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&PublisherDat,Usr_DONT_GET_PREFS)) // Really we only need EncryptedUsrCod and FullName + { + HTM_DIV_Begin ("class=\"TL_TOP_CONT TL_TOP_PUBLISHER TL_WIDTH\""); + + /***** Show user's name inside form to go to user's public profile *****/ + Frm_StartFormUnique (ActSeeOthPubPrf); + Usr_PutParamUsrCodEncrypted (PublisherDat.EncryptedUsrCod); + HTM_BUTTON_SUBMIT_Begin (ItsMe ? Txt_My_public_profile : + Txt_Another_user_s_profile, + "BT_LINK TL_TOP_PUBLISHER",NULL); + HTM_Txt (PublisherDat.FullName); + HTM_BUTTON_End (); + Frm_EndForm (); + + /***** Show action made *****/ + HTM_TxtF (" %s:",Txt_TIMELINE_NOTE_TOP_MESSAGES[TopMessage]); + + HTM_DIV_End (); + } + + /***** Free memory used for user's data *****/ + Usr_UsrDataDestructor (&PublisherDat); + } + /*****************************************************************************/ /*************** Write name and nickname of author of a note *****************/ /*****************************************************************************/ @@ -863,7 +909,8 @@ static void TL_Not_PutFormToRemoveNote (const struct TL_Timeline *Timeline, extern const char *Txt_Remove; /***** Form to remove publication *****/ - TL_FormStart (Timeline,ActReqRemTL_PubGbl,ActReqRemTL_PubUsr); + TL_FormStart (Timeline,ActReqRemTL_PubGbl, + ActReqRemTL_PubUsr); TL_Not_PutHiddenParamNotCod (NotCod); Ico_PutIconLink ("trash.svg",Txt_Remove); Frm_EndForm (); @@ -955,9 +1002,9 @@ static void TL_Not_RequestRemovalNote (struct TL_Timeline *Timeline) /* Show note */ TL_Not_WriteNote (Timeline,&Not, - TL_TOP_MESSAGE_NONE,-1L, - TL_DONT_HIGHLIGHT, - TL_SHOW_ALONE); + TL_TOP_MESSAGE_NONE,-1L, + TL_DONT_HIGHLIGHT, + TL_SHOW_ALONE); /* End alert */ Timeline->NotCod = Not.NotCod; // Note to be removed diff --git a/swad_timeline_post.c b/swad_timeline_post.c index 0dcb29bf8..518c57fab 100644 --- a/swad_timeline_post.c +++ b/swad_timeline_post.c @@ -150,7 +150,8 @@ void TL_Pst_PutFormToWriteNewPost (struct TL_Timeline *Timeline) /* Form to write the post */ HTM_DIV_Begin ("class=\"TL_FORM_NEW_PST TL_RIGHT_WIDTH\""); - TL_FormStart (Timeline,ActRcvTL_PstGbl,ActRcvTL_PstUsr); + TL_FormStart (Timeline,ActRcvTL_PstGbl, + ActRcvTL_PstUsr); TL_Pst_PutTextarea (Txt_New_TIMELINE_post,"TL_PST_TEXTAREA TL_RIGHT_WIDTH"); Frm_EndForm (); HTM_DIV_End (); diff --git a/swad_timeline_publication.c b/swad_timeline_publication.c index 9ffeeb3b0..dfade5737 100644 --- a/swad_timeline_publication.c +++ b/swad_timeline_publication.c @@ -324,12 +324,12 @@ static void TL_Pub_CreateSubQueryPublishers (const struct TL_Timeline *Timeline, /***** Create temporary table and subquery with potential publishers *****/ switch (Timeline->UsrOrGbl) { - case TL_TIMELINE_USR: // Show the timeline of a user + case TL_Usr_TIMELINE_USR: // Show the timeline of a user SubQueries->TablePublishers = ""; sprintf (SubQueries->Publishers,"tl_pubs.PublisherCod=%ld AND ", Gbl.Usrs.Other.UsrDat.UsrCod); break; - case TL_TIMELINE_GBL: // Show the global timeline + case TL_Usr_TIMELINE_GBL: // Show the global timeline switch (Timeline->Who) { case Usr_WHO_ME: // Show my timeline @@ -579,8 +579,7 @@ void TL_Pub_InsertNewPubsInTimeline (struct TL_Timeline *Timeline) /* Write note */ TL_Not_WriteNote (Timeline,&Not, - Pub->TopMessage, - Pub->PublisherCod, + Pub->TopMessage,Pub->PublisherCod, TL_DONT_HIGHLIGHT, TL_DONT_SHOW_ALONE); } @@ -607,8 +606,7 @@ void TL_Pub_ShowOldPubsInTimeline (struct TL_Timeline *Timeline) /* Write note */ TL_Not_WriteNote (Timeline,&Not, - Pub->TopMessage, - Pub->PublisherCod, + Pub->TopMessage,Pub->PublisherCod, TL_DONT_HIGHLIGHT, TL_DONT_SHOW_ALONE); } @@ -692,7 +690,7 @@ long TL_Pub_GetParamPubCod (void) /*********** Create a notification for the author of a post/comment **********/ /*****************************************************************************/ -void TL_Pub_CreateNotifToAuthor (long AuthorCod,long PubCod, +void TL_Ntf_CreateNotifToAuthor (long AuthorCod,long PubCod, Ntf_NotifyEvent_t NotifyEvent) { struct UsrData UsrDat; @@ -812,7 +810,7 @@ static TL_Pub_PubType_t TL_Pub_GetPubTypeFromStr (const char *Str) /***************** Get notification of a new publication *********************/ /*****************************************************************************/ -void TL_Pub_GetNotifPublication (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], +void TL_Ntf_GetNotifPublication (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long PubCod,bool GetContent) { diff --git a/swad_timeline_publication.h b/swad_timeline_publication.h index ad859e795..db4decaf1 100644 --- a/swad_timeline_publication.h +++ b/swad_timeline_publication.h @@ -82,12 +82,12 @@ void TL_Pub_PutLinkToViewOldPublications (void); void TL_Pub_PutHiddenParamPubCod (long PubCod); long TL_Pub_GetParamPubCod (void); -void TL_Pub_CreateNotifToAuthor (long AuthorCod,long PubCod, +void TL_Ntf_CreateNotifToAuthor (long AuthorCod,long PubCod, Ntf_NotifyEvent_t NotifyEvent); long TL_Pub_GetNotCodFromPubCod (long PubCod); -void TL_Pub_GetNotifPublication (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], +void TL_Ntf_GetNotifPublication (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long PubCod,bool GetContent); diff --git a/swad_timeline_share.c b/swad_timeline_share.c index a8b4dcb28..8ada278d5 100644 --- a/swad_timeline_share.c +++ b/swad_timeline_share.c @@ -67,7 +67,7 @@ static void TL_Sha_UnsNote (struct TL_Not_Note *Not); static bool TL_Sha_CheckIfNoteIsSharedByUsr (long NotCod,long UsrCod); static void TL_Sha_ShowUsrsWhoHaveSharedNote (const struct TL_Not_Note *Not, - TL_HowManyUsrs_t HowManyUsrs); + TL_Usr_HowManyUsrs_t HowManyUsrs); /*****************************************************************************/ /*********************** Put disabled icon to share **************************/ @@ -100,7 +100,7 @@ static void TL_Sha_PutFormToShaNote (long ParamCod) extern const char *Txt_Share; /***** Form and icon to mark note as favourite *****/ - TL_FormFavSha (ActShaTL_NotGbl,ActShaTL_NotUsr, + TL_Usr_FormFavSha (ActShaTL_NotGbl,ActShaTL_NotUsr, "NotCod=%ld",ParamCod, TL_ICON_SHARE,Txt_Share); } @@ -110,7 +110,7 @@ static void TL_Sha_PutFormToUnsNote (long ParamCod) extern const char *Txt_TIMELINE_NOTE_Shared; /***** Form and icon to mark note as favourite *****/ - TL_FormFavSha (ActUnsTL_NotGbl,ActUnsTL_NotUsr, + TL_Usr_FormFavSha (ActUnsTL_NotGbl,ActUnsTL_NotUsr, "NotCod=%ld",ParamCod, TL_ICON_SHARED,Txt_TIMELINE_NOTE_Shared); } @@ -137,7 +137,7 @@ void TL_Sha_ShowAllSharersNoteGbl (void) TL_Not_GetDataOfNoteByCod (&Not); /***** Write HTML inside DIV with form to share/unshare *****/ - TL_Sha_PutFormToShaUnsNote (&Not,TL_SHOW_ALL_USRS); + TL_Sha_PutFormToShaUnsNote (&Not,TL_Usr_SHOW_ALL_USRS); } void TL_Sha_ShaNoteUsr (void) @@ -157,7 +157,7 @@ void TL_Sha_ShaNoteGbl (void) TL_Sha_ShaNote (&Not); /***** Write HTML inside DIV with form to unshare *****/ - TL_Sha_PutFormToShaUnsNote (&Not,TL_SHOW_FEW_USRS); + TL_Sha_PutFormToShaUnsNote (&Not,TL_Usr_SHOW_FEW_USRS); } static void TL_Sha_ShaNote (struct TL_Not_Note *Not) @@ -190,7 +190,7 @@ static void TL_Sha_ShaNote (struct TL_Not_Note *Not) for the author of the post ***/ OriginalPubCod = TL_Not_GetPubCodOfOriginalNote (Not->NotCod); if (OriginalPubCod > 0) - TL_Pub_CreateNotifToAuthor (Not->UsrCod,OriginalPubCod,Ntf_EVENT_TIMELINE_SHARE); + TL_Ntf_CreateNotifToAuthor (Not->UsrCod,OriginalPubCod,Ntf_EVENT_TIMELINE_SHARE); } } } @@ -216,7 +216,7 @@ void TL_Sha_UnsNoteGbl (void) TL_Sha_UnsNote (&Not); /***** Write HTML inside DIV with form to share *****/ - TL_Sha_PutFormToShaUnsNote (&Not,TL_SHOW_FEW_USRS); + TL_Sha_PutFormToShaUnsNote (&Not,TL_Usr_SHOW_FEW_USRS); } static void TL_Sha_UnsNote (struct TL_Not_Note *Not) @@ -259,7 +259,7 @@ static void TL_Sha_UnsNote (struct TL_Not_Note *Not) } void TL_Sha_PutFormToShaUnsNote (const struct TL_Not_Note *Not, - TL_HowManyUsrs_t HowManyUsrs) + TL_Usr_HowManyUsrs_t HowManyUsrs) { bool IAmTheAuthor; bool IAmASharerOfThisNot; @@ -327,7 +327,7 @@ void TL_Sha_UpdateNumTimesANoteHasBeenShared (struct TL_Not_Note *Not) /*****************************************************************************/ static void TL_Sha_ShowUsrsWhoHaveSharedNote (const struct TL_Not_Note *Not, - TL_HowManyUsrs_t HowManyUsrs) + TL_Usr_HowManyUsrs_t HowManyUsrs) { MYSQL_RES *mysql_res; unsigned NumFirstUsrs; @@ -344,23 +344,23 @@ static void TL_Sha_ShowUsrsWhoHaveSharedNote (const struct TL_Not_Note *Not, Not->NotCod, Not->UsrCod, (unsigned) TL_PUB_SHARED_NOTE, - HowManyUsrs == TL_SHOW_FEW_USRS ? TL_DEF_USRS_SHOWN : - TL_MAX_USRS_SHOWN); + HowManyUsrs == TL_Usr_SHOW_FEW_USRS ? TL_Usr_DEF_USRS_SHOWN : + TL_Usr_MAX_USRS_SHOWN); else NumFirstUsrs = 0; /***** Show users *****/ /* Number of users */ HTM_DIV_Begin ("class=\"TL_NUM_USRS\""); - TL_ShowNumSharersOrFavers (Not->NumShared); + TL_Usr_ShowNumSharersOrFavers (Not->NumShared); HTM_DIV_End (); /* List users one by one */ HTM_DIV_Begin ("class=\"TL_USRS\""); - TL_ShowSharersOrFavers (&mysql_res,Not->NumShared,NumFirstUsrs); + TL_Usr_ShowSharersOrFavers (&mysql_res,Not->NumShared,NumFirstUsrs); if (NumFirstUsrs < Not->NumShared) /* Clickable ellipsis to show all users */ - TL_PutFormToSeeAllFaversSharers (ActAllShaTL_NotGbl,ActAllShaTL_NotUsr, + TL_Usr_PutFormToSeeAllFaversSharers (ActAllShaTL_NotGbl,ActAllShaTL_NotUsr, "NotCod=%ld",Not->NotCod, HowManyUsrs); HTM_DIV_End (); diff --git a/swad_timeline_share.h b/swad_timeline_share.h index c3309cdb3..1c514a7cb 100644 --- a/swad_timeline_share.h +++ b/swad_timeline_share.h @@ -48,7 +48,7 @@ void TL_Sha_ShaNoteGbl (void); void TL_Sha_UnsNoteUsr (void); void TL_Sha_UnsNoteGbl (void); void TL_Sha_PutFormToShaUnsNote (const struct TL_Not_Note *Not, - TL_HowManyUsrs_t HowManyUsrs); + TL_Usr_HowManyUsrs_t HowManyUsrs); void TL_Sha_UpdateNumTimesANoteHasBeenShared (struct TL_Not_Note *Not); diff --git a/swad_timeline_user.c b/swad_timeline_user.c new file mode 100644 index 000000000..d6f1996c3 --- /dev/null +++ b/swad_timeline_user.c @@ -0,0 +1,311 @@ +// swad_timeline_user.c: social timeline users + +/* + SWAD (Shared Workspace At a Distance), + is a web platform developed at the University of Granada (Spain), + and used to support university teaching. + + This file is part of SWAD core. + Copyright (C) 1999-2021 Antonio Cañas Vargas + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General 3 License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +/*****************************************************************************/ +/*********************************** Headers *********************************/ +/*****************************************************************************/ + +#define _GNU_SOURCE // For asprintf +#include // For PATH_MAX +#include // For asprintf + +#include "swad_database.h" +#include "swad_global.h" +#include "swad_photo.h" +#include "swad_timeline.h" +#include "swad_timeline_note.h" +#include "swad_timeline_publication.h" +#include "swad_timeline_user.h" + +/*****************************************************************************/ +/****************************** Public constants *****************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/************************* Private constants and types ***********************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/************** External global variables from others modules ****************/ +/*****************************************************************************/ + +extern struct Globals Gbl; + +/*****************************************************************************/ +/************************* Private global variables **************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/***************************** Private prototypes ****************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/************* Remove all the content of a user from database ****************/ +/*****************************************************************************/ + +void TL_Usr_RemoveUsrContent (long UsrCod) + { + /***** Remove favs for comments *****/ + /* Remove all favs made by this user in any comment */ + DB_QueryDELETE ("can not remove favs", + "DELETE FROM tl_comments_fav" + " WHERE UsrCod=%ld", + UsrCod); + + /* Remove all favs for all comments of this user */ + DB_QueryDELETE ("can not remove favs", + "DELETE FROM tl_comments_fav" + " USING tl_pubs,tl_comments_fav" + " WHERE tl_pubs.PublisherCod=%ld" // Author of the comment + " AND tl_pubs.PubType=%u" + " AND tl_pubs.PubCod=tl_comments_fav.PubCod", + UsrCod,(unsigned) TL_Pub_COMMENT_TO_NOTE); + + /* Remove all favs for all comments in all the notes of the user */ + DB_QueryDELETE ("can not remove comments", + "DELETE FROM tl_comments_fav" + " USING tl_notes,tl_pubs,tl_comments_fav" + " WHERE tl_notes.UsrCod=%ld" // Author of the note + " AND tl_notes.NotCod=tl_pubs.NotCod" + " AND tl_pubs.PubType=%u" + " AND tl_pubs.PubCod=tl_comments_fav.PubCod", + UsrCod,(unsigned) TL_Pub_COMMENT_TO_NOTE); + + /***** Remove favs for notes *****/ + /* Remove all favs made by this user in any note */ + DB_QueryDELETE ("can not remove favs", + "DELETE FROM tl_notes_fav" + " WHERE UsrCod=%ld", + UsrCod); + + /* Remove all favs for all notes of this user */ + DB_QueryDELETE ("can not remove favs", + "DELETE FROM tl_notes_fav" + " USING tl_notes,tl_notes_fav" + " WHERE tl_notes.UsrCod=%ld" // Author of the note + " AND tl_notes.NotCod=tl_notes_fav.NotCod", + UsrCod); + + /***** Remove comments *****/ + /* Remove content of all the comments in all the notes of the user */ + DB_QueryDELETE ("can not remove comments", + "DELETE FROM tl_comments" + " USING tl_notes,tl_pubs,tl_comments" + " WHERE tl_notes.UsrCod=%ld" + " AND tl_notes.NotCod=tl_pubs.NotCod" + " AND tl_pubs.PubType=%u" + " AND tl_pubs.PubCod=tl_comments.PubCod", + UsrCod,(unsigned) TL_Pub_COMMENT_TO_NOTE); + + /* Remove all the comments from any user in any note of the user */ + DB_QueryDELETE ("can not remove comments", + "DELETE FROM tl_pubs" + " USING tl_notes,tl_pubs" + " WHERE tl_notes.UsrCod=%ld" + " AND tl_notes.NotCod=tl_pubs.NotCod" + " AND tl_pubs.PubType=%u", + UsrCod,(unsigned) TL_Pub_COMMENT_TO_NOTE); + + /* Remove content of all the comments of the user in any note */ + DB_QueryDELETE ("can not remove comments", + "DELETE FROM tl_comments" + " USING tl_pubs,tl_comments" + " WHERE tl_pubs.PublisherCod=%ld" + " AND tl_pubs.PubType=%u" + " AND tl_pubs.PubCod=tl_comments.PubCod", + UsrCod,(unsigned) TL_Pub_COMMENT_TO_NOTE); + + /***** Remove all the posts of the user *****/ + DB_QueryDELETE ("can not remove posts", + "DELETE FROM tl_posts" + " WHERE PstCod IN" + " (SELECT Cod FROM tl_notes" + " WHERE UsrCod=%ld AND NoteType=%u)", + UsrCod,(unsigned) TL_NOTE_POST); + + /***** Remove all the publications of any user authored by the user *****/ + DB_QueryDELETE ("can not remove publications", + "DELETE FROM tl_pubs" + " USING tl_notes,tl_pubs" + " WHERE tl_notes.UsrCod=%ld" + " AND tl_notes.NotCod=tl_pubs.NotCod", + UsrCod); + + /***** Remove all the publications of the user *****/ + DB_QueryDELETE ("can not remove publications", + "DELETE FROM tl_pubs" + " WHERE PublisherCod=%ld", + UsrCod); + + /***** Remove all the notes of the user *****/ + DB_QueryDELETE ("can not remove notes", + "DELETE FROM tl_notes" + " WHERE UsrCod=%ld", + UsrCod); + } + +/*****************************************************************************/ +/************************ Show sharers or favouriters ************************/ +/*****************************************************************************/ + +void TL_Usr_ShowNumSharersOrFavers (unsigned NumUsrs) + { + /***** Show number of sharers or favers + (users who have shared or marked this note as favourite) *****/ + HTM_TxtF (" %u",NumUsrs); + } + +void TL_Usr_ShowSharersOrFavers (MYSQL_RES **mysql_res, + unsigned NumUsrs,unsigned NumFirstUsrs) + { + MYSQL_ROW row; + unsigned NumUsr; + unsigned NumUsrsShown = 0; + struct UsrData UsrDat; + bool ShowPhoto; + char PhotoURL[PATH_MAX + 1]; + + if (NumUsrs) + { + /***** A list of users has been got from database *****/ + if (NumFirstUsrs) + { + /***** Initialize structure with user's data *****/ + Usr_UsrDataConstructor (&UsrDat); + + /***** List users *****/ + for (NumUsr = 0; + NumUsr < NumFirstUsrs; + NumUsr++) + { + /***** Get user *****/ + row = mysql_fetch_row (*mysql_res); + + /* Get user's code (row[0]) */ + UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]); + + /***** Get user's data and show user's photo *****/ + if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS)) + { + HTM_DIV_Begin ("class=\"TL_SHARER\""); + ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&UsrDat,PhotoURL); + Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL : + NULL, + "PHOTO12x16",Pho_ZOOM,true); // Use unique id + HTM_DIV_End (); + + NumUsrsShown++; + } + } + + /***** Free memory used for user's data *****/ + Usr_UsrDataDestructor (&UsrDat); + } + } + } + +/*****************************************************************************/ +/********************* Form to show all favers/sharers ***********************/ +/*****************************************************************************/ + +void TL_Usr_PutFormToSeeAllFaversSharers (Act_Action_t ActionGbl,Act_Action_t ActionUsr, + const char *ParamFormat,long ParamCod, + TL_Usr_HowManyUsrs_t HowManyUsrs) + { + extern const char *Txt_View_all_USERS; + + switch (HowManyUsrs) + { + case TL_Usr_SHOW_FEW_USRS: + /***** Form and icon to mark note as favourite *****/ + TL_Usr_FormFavSha (ActionGbl,ActionUsr, + ParamFormat,ParamCod, + TL_Usr_ICON_ELLIPSIS,Txt_View_all_USERS); + break; + case TL_Usr_SHOW_ALL_USRS: + Ico_PutIconOff (TL_Usr_ICON_ELLIPSIS,Txt_View_all_USERS); + break; + } + } + +/*****************************************************************************/ +/******* Form to fav/unfav or share/unshare in global or user timeline *******/ +/*****************************************************************************/ + +void TL_Usr_FormFavSha (Act_Action_t ActionGbl,Act_Action_t ActionUsr, + const char *ParamFormat,long ParamCod, + const char *Icon,const char *Title) + { + char *OnSubmit; + char ParamStr[7 + Cns_MAX_DECIMAL_DIGITS_LONG + 1]; + + /***** Create parameter string *****/ + sprintf (ParamStr,ParamFormat,ParamCod); + + /* + +---------------------------------------------------------------------------+ + | div which content will be updated (parent of parent of form) | + | +---------------------+ +-------+ +-------------------------------------+ | + | | div (parent of form)| | div | | div for users | | + | | +-----------------+ | | for | | +------+ +------+ +------+ +------+ | | + | | | this form | | | num. | | | | | | | | | form | | | + | | | +-------------+ | | | of | | | user | | user | | user | | to | | | + | | | | fav icon | | | | users | | | 1 | | 2 | | 3 | | show | | | + | | | +-------------+ | | | | | | | | | | | | all | | | + | | +-----------------+ | | | | +------+ +------+ +------+ +------+ | | + | +---------------------+ +-------+ +-------------------------------------+ | + +---------------------------------------------------------------------------+ + */ + + /***** Form and icon to mark note as favourite *****/ + /* Form with icon */ + if (Gbl.Usrs.Other.UsrDat.UsrCod > 0) + { + if (asprintf (&OnSubmit,"updateDivFaversSharers(this," + "'act=%ld&ses=%s&%s&OtherUsrCod=%s');" + " return false;", // return false is necessary to not submit form + Act_GetActCod (ActionUsr), + Gbl.Session.Id, + ParamStr, + Gbl.Usrs.Other.UsrDat.EncryptedUsrCod) < 0) + Lay_NotEnoughMemoryExit (); + Frm_StartFormUniqueAnchorOnSubmit (ActUnk,"timeline",OnSubmit); + } + else + { + if (asprintf (&OnSubmit,"updateDivFaversSharers(this," + "'act=%ld&ses=%s&%s');" + " return false;", // return false is necessary to not submit form + Act_GetActCod (ActionGbl), + Gbl.Session.Id, + ParamStr) < 0) + Lay_NotEnoughMemoryExit (); + Frm_StartFormUniqueAnchorOnSubmit (ActUnk,NULL,OnSubmit); + } + Ico_PutIconLink (Icon,Title); + Frm_EndForm (); + + /* Free allocated memory */ + free (OnSubmit); + } diff --git a/swad_timeline_user.h b/swad_timeline_user.h new file mode 100644 index 000000000..2f165edb8 --- /dev/null +++ b/swad_timeline_user.h @@ -0,0 +1,76 @@ +// swad_timeline_user.h: social timeline users + +#ifndef _SWAD_TL_USR +#define _SWAD_TL_USR +/* + SWAD (Shared Workspace At a Distance in Spanish), + is a web platform developed at the University of Granada (Spain), + and used to support university teaching. + + This file is part of SWAD core. + Copyright (C) 1999-2021 Antonio Cañas Vargas + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ +/*****************************************************************************/ +/********************************** Headers **********************************/ +/*****************************************************************************/ + +#include "swad_form.h" +#include "swad_media.h" +#include "swad_notification.h" +#include "swad_user.h" + +/*****************************************************************************/ +/****************************** Public constants *****************************/ +/*****************************************************************************/ + +#define TL_Usr_ICON_ELLIPSIS "ellipsis-h.svg" + +#define TL_Usr_DEF_USRS_SHOWN 5 // Default maximum number of users shown who have share/fav a note +#define TL_Usr_MAX_USRS_SHOWN 1000 // Top maximum number of users shown who have share/fav a note + +/*****************************************************************************/ +/******************************** Public types *******************************/ +/*****************************************************************************/ + +typedef enum + { + TL_Usr_TIMELINE_USR, // Show the timeline of a user + TL_Usr_TIMELINE_GBL, // Show the timeline of the users follwed by me + } TL_Usr_UsrOrGbl_t; + +typedef enum + { + TL_Usr_SHOW_FEW_USRS, // Show a few first favers/sharers + TL_Usr_SHOW_ALL_USRS, // Show all favers/sharers + } TL_Usr_HowManyUsrs_t; + +/*****************************************************************************/ +/****************************** Public prototypes ****************************/ +/*****************************************************************************/ + +void TL_Usr_RemoveUsrContent (long UsrCod); + +void TL_Usr_ShowNumSharersOrFavers (unsigned NumUsrs); +void TL_Usr_ShowSharersOrFavers (MYSQL_RES **mysql_res, + unsigned NumUsrs,unsigned NumFirstUsrs); +void TL_Usr_PutFormToSeeAllFaversSharers (Act_Action_t ActionGbl,Act_Action_t ActionUsr, + const char *ParamFormat,long ParamCod, + TL_Usr_HowManyUsrs_t HowManyUsrs); +void TL_Usr_FormFavSha (Act_Action_t ActionGbl,Act_Action_t ActionUsr, + const char *ParamFormat,long ParamCod, + const char *Icon,const char *Title); + +#endif