From f8bc7f326ee367267785d427c2a92b899e979227 Mon Sep 17 00:00:00 2001 From: acanas Date: Mon, 8 Feb 2021 13:53:19 +0100 Subject: [PATCH] Version20.12.1 --- swad_changelog.h | 3 +- swad_timeline.c | 83 +++++++++++++++++++++++++++++++----------------- 2 files changed, 55 insertions(+), 31 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 4f9181d78..a43b6780c 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.12 (2021-02-08)" +#define Log_PLATFORM_VERSION "SWAD 20.12.1 (2021-02-08)" #define CSS_FILE "swad20.8.css" #define JS_FILE "swad20.6.2.js" /* @@ -600,6 +600,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. + Version 20.12.1: Feb 08, 2021 Code refactoring in timeline. (304900 lines) Version 20.12: Feb 08, 2021 Code refactoring in timeline. (304882 lines) Version 20.11.1: Feb 07, 2021 Fixed bugs in assigments pagination. (304880 lines) Version 20.11: Feb 07, 2021 An editing teacher can access and modify all files in all projects in course. (304875 lines) diff --git a/swad_timeline.c b/swad_timeline.c index 23f705687..5bf8a6a9c 100644 --- a/swad_timeline.c +++ b/swad_timeline.c @@ -240,6 +240,8 @@ Usr_Who_t TL_GlobalWho; /*****************************************************************************/ static void TL_InitTimelineGbl (struct TL_Timeline *Timeline); +static void TL_ShowHighlightedNote (struct TL_Timeline *Timeline, + struct TL_Note *SocNot); static void TL_ShowNoteAndTimelineGbl (struct TL_Timeline *Timeline); static void TL_ShowTimelineGblHighlightingNot (struct TL_Timeline *Timeline, @@ -393,7 +395,7 @@ static void TL_PutParamsRemoveNote (void *Timeline); static void TL_RemoveNote (void); static void TL_RemoveNoteMediaAndDBEntries (struct TL_Note *SocNot); -static long TL_GetNotCodOfPublication (long PubCod); +static long TL_GetNotCodFromPubCod (long PubCod); static long TL_GetPubCodOfOriginalNote (long NotCod); static void TL_RequestRemovalComment (struct TL_Timeline *Timeline); @@ -464,7 +466,7 @@ void TL_ResetTimeline (struct TL_Timeline *Timeline) } /*****************************************************************************/ -/**************************** See global timeline ****************************/ +/**************** Show highlighted note and global timeline ******************/ /*****************************************************************************/ void TL_ShowTimelineGbl (void) @@ -477,14 +479,47 @@ void TL_ShowTimelineGbl (void) /***** Save which users in database *****/ TL_SaveWhoInDB (&Timeline); - /***** Show timeline *****/ + /***** Show highlighted note and global timeline *****/ TL_ShowNoteAndTimelineGbl (&Timeline); } +/*****************************************************************************/ +/**************** Show highlighted note and global timeline ******************/ +/*****************************************************************************/ + static void TL_ShowNoteAndTimelineGbl (struct TL_Timeline *Timeline) { long PubCod; struct TL_Note SocNot; + + /***** Initialize note code to -1 ==> no highlighted note *****/ + SocNot.NotCod = -1L; + + /***** Get parameter with the code of a publication *****/ + // This parameter is optional. It can be provided by a notification. + // If > 0 ==> the note is shown highlighted above the timeline + PubCod = TL_GetParamPubCod (); + + /***** If a note should be highlighted ==> get code of note from database *****/ + if (PubCod > 0) + SocNot.NotCod = TL_GetNotCodFromPubCod (PubCod); + + /***** If a note should be highlighted ==> show it above the timeline *****/ + if (SocNot.NotCod > 0) + /***** Show the note highlighted above the timeline *****/ + TL_ShowHighlightedNote (Timeline,&SocNot); + + /***** Show timeline with possible highlighted note *****/ + TL_ShowTimelineGblHighlightingNot (Timeline,SocNot.NotCod); + } + +/*****************************************************************************/ +/****************** Show highlighted note above timeline *********************/ +/*****************************************************************************/ + +static void TL_ShowHighlightedNote (struct TL_Timeline *Timeline, + struct TL_Note *SocNot) + { struct UsrData UsrDat; Ntf_NotifyEvent_t NotifyEvent; static const TL_TopMessage_t TopMessages[Ntf_NUM_NOTIFY_EVENTS] = @@ -525,36 +560,24 @@ static void TL_ShowNoteAndTimelineGbl (struct TL_Timeline *Timeline) /* Profile tab */ }; - /***** Initialize note code to -1 ==> no highlighted note *****/ - SocNot.NotCod = -1L; + /***** Get other parameters *****/ + /* Get who did the action (publication, commenting, faving, sharing, mentioning) */ + Usr_GetParamOtherUsrCodEncrypted (&UsrDat); - /***** Get parameter with the code of a publication *****/ - // This parameter is optional. It can be provided by a notification. - // If > 0 ==> the note is shown highlighted above the timeline - PubCod = TL_GetParamPubCod (); - if (PubCod > 0) - /***** Get code of note from database *****/ - SocNot.NotCod = TL_GetNotCodOfPublication (PubCod); + /* Get what he/she did */ + NotifyEvent = Ntf_GetParamNotifyEvent (); - if (SocNot.NotCod > 0) - { - /* Get who did the action (publication, commenting, faving, sharing, mentioning) */ - Usr_GetParamOtherUsrCodEncrypted (&UsrDat); - - /* Get what he/she did */ - NotifyEvent = Ntf_GetParamNotifyEvent (); - - /***** Show the note highlighted *****/ - TL_GetDataOfNoteByCod (&SocNot); - TL_WriteNote (Timeline,&SocNot, - TopMessages[NotifyEvent],UsrDat.UsrCod, - true,true); - } - - /***** Show timeline with possible highlighted note *****/ - TL_ShowTimelineGblHighlightingNot (Timeline,SocNot.NotCod); + /***** Show the note highlighted *****/ + TL_GetDataOfNoteByCod (SocNot); + TL_WriteNote (Timeline,SocNot, + TopMessages[NotifyEvent],UsrDat.UsrCod, + true,true); } +/*****************************************************************************/ +/***************************** Show global timeline **************************/ +/*****************************************************************************/ + static void TL_ShowTimelineGblHighlightingNot (struct TL_Timeline *Timeline, long NotCod) { @@ -4453,7 +4476,7 @@ static void TL_RemoveNoteMediaAndDBEntries (struct TL_Note *SocNot) /*********************** Get code of note of a publication *******************/ /*****************************************************************************/ -static long TL_GetNotCodOfPublication (long PubCod) +static long TL_GetNotCodFromPubCod (long PubCod) { MYSQL_RES *mysql_res; MYSQL_ROW row;