diff --git a/swad_changelog.h b/swad_changelog.h index 41206442..e95254ac 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -598,11 +598,12 @@ 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 */ -#define Log_PLATFORM_VERSION "SWAD 20.41.2 (2021-03-03)" +#define Log_PLATFORM_VERSION "SWAD 20.41.3 (2021-03-03)" #define CSS_FILE "swad20.33.9.css" #define JS_FILE "swad20.6.2.js" /* - Version 20.41.2: Mar 03, 2021 Code refactoring in timeline. (? lines) + Version 20.41.3: Mar 03, 2021 Code refactoring in timeline publications. (305580 lines) + Version 20.41.2: Mar 03, 2021 Code refactoring in timeline. (305569 lines) Version 20.41.1: Mar 03, 2021 Code refactoring in timeline posts. (305563 lines) Version 20.41: Mar 03, 2021 Code refactoring in timeline comments. (305542 lines) Version 20.40.3: Mar 03, 2021 Code refactoring in timeline. (305528 lines) diff --git a/swad_timeline_publication.c b/swad_timeline_publication.c index cbbca7f1..6893f58b 100644 --- a/swad_timeline_publication.c +++ b/swad_timeline_publication.c @@ -58,6 +58,9 @@ extern struct Globals Gbl; /***************************** Private prototypes ****************************/ /*****************************************************************************/ +static void TL_Pub_InitializeRangeOfPubs (TL_WhatToGet_t WhatToGet, + struct TL_Pub_RangePubsToGet *RangePubsToGet); + static unsigned TL_Pub_GetMaxPubsToGet (const struct TL_Timeline *Timeline); static void TL_Pub_UpdateFirstLastPubCodesIntoSession (const struct TL_Timeline *Timeline); @@ -98,46 +101,9 @@ void TL_Pub_GetListPubsToShowInTimeline (struct TL_Timeline *Timeline) TL_DB_CreateSubQueryAlreadyExists (Timeline,&SubQueries); /***** Get the publications in timeline *****/ - /* Initialize range of pubs: + /* Initialize range of pubs */ + TL_Pub_InitializeRangeOfPubs (Timeline->WhatToGet,&RangePubsToGet); - tl_pubs - _____ - |_____|11 - |_____|10 - _|_____| 9 <-- RangePubsToGet.Top - Get / |_____| 8 - pubs | |_____| 7 - from < |_____| 6 - this | |_____| 5 - range \_|_____| 4 - |_____| 3 <-- RangePubsToGet.Bottom - |_____| 2 - |_____| 1 - 0 - */ - switch (Timeline->WhatToGet) - { - case TL_GET_ONLY_NEW_PUBS: // Get the publications (without limit) - // newer than LastPubCod - /* This query is made via AJAX automatically from time to time */ - RangePubsToGet.Top = 0; // +Infinite - RangePubsToGet.Bottom = TL_DB_GetPubCodFromSession ("LastPubCod"); - break; - case TL_GET_ONLY_OLD_PUBS: // Get some limited publications - // older than FirstPubCod - /* This query is made via AJAX - when I click in link to get old publications */ - RangePubsToGet.Top = TL_DB_GetPubCodFromSession ("FirstPubCod"); - RangePubsToGet.Bottom = 0; // -Infinite - break; - case TL_GET_RECENT_TIMELINE: // Get some limited recent publications - default: - /* This is the first query to get initial timeline shown - ==> no notes yet in current timeline table */ - RangePubsToGet.Top = 0; // +Infinite - RangePubsToGet.Bottom = 0; // -Infinite - break; - } /* Create subquery with bottom range of publications to get from tl_pubs. Bottom pub. code remains unchanged in all iterations of the next loop. */ TL_DB_CreateSubQueryRangeBottom (&RangePubsToGet,&SubQueries); @@ -226,6 +192,55 @@ void TL_Pub_GetListPubsToShowInTimeline (struct TL_Timeline *Timeline) Fol_DropTmpTableMeAndUsrsIFollow (); } +/*****************************************************************************/ +/*************** Get list of pubications to show in timeline *****************/ +/*****************************************************************************/ + +static void TL_Pub_InitializeRangeOfPubs (TL_WhatToGet_t WhatToGet, + struct TL_Pub_RangePubsToGet *RangePubsToGet) + { + /* Initialize range of pubs: + + tl_pubs + _____ + |_____|11 + |_____|10 + _|_____| 9 <-- RangePubsToGet.Top + Get / |_____| 8 + pubs | |_____| 7 + from < |_____| 6 + this | |_____| 5 + range \_|_____| 4 + |_____| 3 <-- RangePubsToGet.Bottom + |_____| 2 + |_____| 1 + 0 + */ + /* Default range */ + RangePubsToGet->Top = 0; // +Infinite + RangePubsToGet->Bottom = 0; // -Infinite + + switch (WhatToGet) + { + case TL_GET_ONLY_NEW_PUBS: // Get the publications (without limit) + // newer than LastPubCod + /* This query is made via AJAX automatically from time to time */ + RangePubsToGet->Bottom = TL_DB_GetPubCodFromSession ("LastPubCod"); + break; + case TL_GET_ONLY_OLD_PUBS: // Get some limited publications + // older than FirstPubCod + /* This query is made via AJAX + when I click in link to get old publications */ + RangePubsToGet->Top = TL_DB_GetPubCodFromSession ("FirstPubCod"); + break; + case TL_GET_RECENT_TIMELINE: // Get some limited recent publications + default: + /* This is the first query to get initial timeline shown + ==> no notes yet in current timeline table */ + break; + } + } + /*****************************************************************************/ /********* Get maximum number of publications to get from database ***********/ /*****************************************************************************/