mirror of https://github.com/acanas/swad-core.git
Version 21.57.4: Nov 17, 2021 Code refactoring in timeline.
This commit is contained in:
parent
b911c3480a
commit
71c8bf59e9
|
@ -602,13 +602,15 @@ TODO: FIX BUG, URGENT! En las fechas como par
|
||||||
|
|
||||||
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
|
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 21.57.2 (2021-11-14)"
|
#define Log_PLATFORM_VERSION "SWAD 21.57.4 (2021-11-18)"
|
||||||
#define CSS_FILE "swad21.57.css"
|
#define CSS_FILE "swad21.57.css"
|
||||||
#define JS_FILE "swad21.57.js"
|
#define JS_FILE "swad21.57.js"
|
||||||
/*
|
/*
|
||||||
TODO: Rename CENTRE to CENTER in help wiki.
|
TODO: Rename CENTRE to CENTER in help wiki.
|
||||||
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
||||||
|
|
||||||
|
Version 21.57.4: Nov 17, 2021 Code refactoring in timeline. (319235 lines)
|
||||||
|
Version 21.57.3: Nov 17, 2021 Code refactoring in timeline. (319225 lines)
|
||||||
Version 21.57.2: Nov 14, 2021 Code refactoring in timeline. (319257 lines)
|
Version 21.57.2: Nov 14, 2021 Code refactoring in timeline. (319257 lines)
|
||||||
Version 21.57.1: Nov 12, 2021 Code refactoring in multimedia. (319241 lines)
|
Version 21.57.1: Nov 12, 2021 Code refactoring in multimedia. (319241 lines)
|
||||||
Version 21.57: Nov 11, 2021 Code refactoring in timeline. (319208 lines)
|
Version 21.57: Nov 11, 2021 Code refactoring in timeline. (319208 lines)
|
||||||
|
|
|
@ -693,7 +693,6 @@ void Fol_DB_RemoveUsrFromUsrFollow (long UsrCod)
|
||||||
|
|
||||||
void Fol_DB_CreateTmpTableMeAndUsrsIFollow (void)
|
void Fol_DB_CreateTmpTableMeAndUsrsIFollow (void)
|
||||||
{
|
{
|
||||||
/***** Create temporary table with me and the users I follow *****/
|
|
||||||
DB_Query ("can not create temporary table",
|
DB_Query ("can not create temporary table",
|
||||||
"CREATE TEMPORARY TABLE fol_tmp_me_and_followed "
|
"CREATE TEMPORARY TABLE fol_tmp_me_and_followed "
|
||||||
"(UsrCod INT NOT NULL,"
|
"(UsrCod INT NOT NULL,"
|
||||||
|
@ -710,7 +709,6 @@ void Fol_DB_CreateTmpTableMeAndUsrsIFollow (void)
|
||||||
|
|
||||||
void Fol_DB_DropTmpTableMeAndUsrsIFollow (void)
|
void Fol_DB_DropTmpTableMeAndUsrsIFollow (void)
|
||||||
{
|
{
|
||||||
/***** Drop temporary table with me and the users I follow *****/
|
|
||||||
DB_Query ("can not remove temporary table",
|
DB_Query ("can not remove temporary table",
|
||||||
"DROP TEMPORARY TABLE IF EXISTS fol_tmp_me_and_followed");
|
"DROP TEMPORARY TABLE IF EXISTS fol_tmp_me_and_followed");
|
||||||
}
|
}
|
||||||
|
|
42
swad_text.c
42
swad_text.c
|
@ -52922,27 +52922,6 @@ const char *Txt_TIMELINE_NOTE_TOP_MESSAGES[Tml_NUM_TOP_MESSAGES] =
|
||||||
"oznaczone jako ulubiony"
|
"oznaczone jako ulubiony"
|
||||||
#elif L==9 // pt
|
#elif L==9 // pt
|
||||||
"marcou como favorito"
|
"marcou como favorito"
|
||||||
#endif
|
|
||||||
,
|
|
||||||
[Tml_TOP_MESSAGE_UNFAVED] =
|
|
||||||
#if L==1 // ca
|
|
||||||
"ha desmarcat com favorit"
|
|
||||||
#elif L==2 // de
|
|
||||||
"hat als Favorit unmarkiert"
|
|
||||||
#elif L==3 // en
|
|
||||||
"has unmarked as favourite"
|
|
||||||
#elif L==4 // es
|
|
||||||
"ha desmarcado como favorito"
|
|
||||||
#elif L==5 // fr
|
|
||||||
"a pas marqué en tant que favori"
|
|
||||||
#elif L==6 // gn
|
|
||||||
"ha desmarcado como favorito" // Okoteve traducción
|
|
||||||
#elif L==7 // it
|
|
||||||
"ha smarcato come preferito"
|
|
||||||
#elif L==8 // pl
|
|
||||||
"nieoznaczonych jako ulubiony"
|
|
||||||
#elif L==9 // pt
|
|
||||||
"desmarcou como favorito"
|
|
||||||
#endif
|
#endif
|
||||||
,
|
,
|
||||||
[Tml_TOP_MESSAGE_SHARED] =
|
[Tml_TOP_MESSAGE_SHARED] =
|
||||||
|
@ -52964,27 +52943,6 @@ const char *Txt_TIMELINE_NOTE_TOP_MESSAGES[Tml_NUM_TOP_MESSAGES] =
|
||||||
"podzielił"
|
"podzielił"
|
||||||
#elif L==9 // pt
|
#elif L==9 // pt
|
||||||
"compartilhou"
|
"compartilhou"
|
||||||
#endif
|
|
||||||
,
|
|
||||||
[Tml_TOP_MESSAGE_UNSHARED] =
|
|
||||||
#if L==1 // ca
|
|
||||||
"ha deixat de compartir"
|
|
||||||
#elif L==2 // de
|
|
||||||
"hat Sharing gestoppt"
|
|
||||||
#elif L==3 // en
|
|
||||||
"has stopped sharing"
|
|
||||||
#elif L==4 // es
|
|
||||||
"ha dejado de compartir"
|
|
||||||
#elif L==5 // fr
|
|
||||||
"a cessé de partage"
|
|
||||||
#elif L==6 // gn
|
|
||||||
"ha dejado de compartir" // Okoteve traducción
|
|
||||||
#elif L==7 // it
|
|
||||||
"ha smesso di condividere"
|
|
||||||
#elif L==8 // pl
|
|
||||||
"przestał udostępniania"
|
|
||||||
#elif L==9 // pt
|
|
||||||
"parou compartilhar"
|
|
||||||
#endif
|
#endif
|
||||||
,
|
,
|
||||||
[Tml_TOP_MESSAGE_MENTIONED] =
|
[Tml_TOP_MESSAGE_MENTIONED] =
|
||||||
|
|
|
@ -155,7 +155,7 @@ static void Tml_GetAndShowOldTimeline (struct Tml_Timeline *Timeline);
|
||||||
static void Tml_ShowTimeline (struct Tml_Timeline *Timeline,
|
static void Tml_ShowTimeline (struct Tml_Timeline *Timeline,
|
||||||
long NotCodToHighlight,const char *Title);
|
long NotCodToHighlight,const char *Title);
|
||||||
static void Tml_PutIconsTimeline (__attribute__((unused)) void *Args);
|
static void Tml_PutIconsTimeline (__attribute__((unused)) void *Args);
|
||||||
static unsigned Tml_ListRecentPubs (struct Tml_Timeline *Timeline,
|
static unsigned Tml_ListRecentPubs (const struct Tml_Timeline *Timeline,
|
||||||
long NotCodToHighlight);
|
long NotCodToHighlight);
|
||||||
|
|
||||||
static void Tml_PutHiddenList (const char *Id);
|
static void Tml_PutHiddenList (const char *Id);
|
||||||
|
@ -184,7 +184,7 @@ void Tml_ResetTimeline (struct Tml_Timeline *Timeline)
|
||||||
{
|
{
|
||||||
Timeline->UsrOrGbl = Tml_Usr_TIMELINE_GBL;
|
Timeline->UsrOrGbl = Tml_Usr_TIMELINE_GBL;
|
||||||
Timeline->Who = Tml_Who_DEFAULT_WHO;
|
Timeline->Who = Tml_Who_DEFAULT_WHO;
|
||||||
Timeline->WhatToGet = Tml_GET_RECENT_PUBS;
|
Timeline->WhatToGet = Tml_GET_REC_PUBS;
|
||||||
Timeline->Pubs.Top =
|
Timeline->Pubs.Top =
|
||||||
Timeline->Pubs.Bottom = NULL,
|
Timeline->Pubs.Bottom = NULL,
|
||||||
Timeline->NotCod = -1L;
|
Timeline->NotCod = -1L;
|
||||||
|
@ -218,21 +218,17 @@ void Tml_ShowNoteAndTimelineGbl (struct Tml_Timeline *Timeline)
|
||||||
long PubCod;
|
long PubCod;
|
||||||
struct Tml_Not_Note Not;
|
struct Tml_Not_Note Not;
|
||||||
|
|
||||||
/***** Initialize note code to -1 ==> no highlighted note *****/
|
|
||||||
Not.NotCod = -1L;
|
|
||||||
|
|
||||||
/***** Get parameter with the code of a publication *****/
|
/***** Get parameter with the code of a publication *****/
|
||||||
// This parameter is optional. It can be provided by a notification.
|
// This parameter is optional. It can be provided by a notification.
|
||||||
// If > 0 ==> the note is shown highlighted above the timeline
|
// If > 0 ==> the associated note will be shown highlighted
|
||||||
PubCod = Tml_Pub_GetParamPubCod ();
|
// get its code from database and show it above the timeline
|
||||||
|
if ((PubCod = Tml_Pub_GetParamPubCod ()) > 0)
|
||||||
/***** If a note should be highlighted ==> get code of note from database *****/
|
{
|
||||||
if (PubCod > 0)
|
if ((Not.NotCod = Tml_DB_GetNotCodFromPubCod (PubCod)) > 0)
|
||||||
Not.NotCod = Tml_DB_GetNotCodFromPubCod (PubCod);
|
Tml_Not_ShowHighlightedNote (Timeline,&Not);
|
||||||
|
}
|
||||||
/***** If a note should be highlighted ==> show it above the timeline *****/
|
else
|
||||||
if (Not.NotCod > 0)
|
Not.NotCod = -1L; // ==> no highlighted note
|
||||||
Tml_Not_ShowHighlightedNote (Timeline,&Not);
|
|
||||||
|
|
||||||
/***** Show timeline with possible highlighted note *****/
|
/***** Show timeline with possible highlighted note *****/
|
||||||
Tml_ShowTimelineGblHighlighting (Timeline,Not.NotCod);
|
Tml_ShowTimelineGblHighlighting (Timeline,Not.NotCod);
|
||||||
|
@ -248,7 +244,7 @@ void Tml_ShowTimelineGblHighlighting (struct Tml_Timeline *Timeline,long NotCod)
|
||||||
|
|
||||||
/***** Get list of pubications to show in timeline *****/
|
/***** Get list of pubications to show in timeline *****/
|
||||||
Timeline->UsrOrGbl = Tml_Usr_TIMELINE_GBL;
|
Timeline->UsrOrGbl = Tml_Usr_TIMELINE_GBL;
|
||||||
Timeline->WhatToGet = Tml_GET_RECENT_PUBS;
|
Timeline->WhatToGet = Tml_GET_REC_PUBS;
|
||||||
Tml_Pub_GetListPubsToShowInTimeline (Timeline);
|
Tml_Pub_GetListPubsToShowInTimeline (Timeline);
|
||||||
|
|
||||||
/***** Show timeline *****/
|
/***** Show timeline *****/
|
||||||
|
@ -277,7 +273,7 @@ void Tml_ShowTimelineUsrHighlighting (struct Tml_Timeline *Timeline,long NotCod)
|
||||||
|
|
||||||
/***** Get list of pubications to show in timeline *****/
|
/***** Get list of pubications to show in timeline *****/
|
||||||
Timeline->UsrOrGbl = Tml_Usr_TIMELINE_USR;
|
Timeline->UsrOrGbl = Tml_Usr_TIMELINE_USR;
|
||||||
Timeline->WhatToGet = Tml_GET_RECENT_PUBS;
|
Timeline->WhatToGet = Tml_GET_REC_PUBS;
|
||||||
Tml_Pub_GetListPubsToShowInTimeline (Timeline);
|
Tml_Pub_GetListPubsToShowInTimeline (Timeline);
|
||||||
|
|
||||||
/***** Show timeline *****/
|
/***** Show timeline *****/
|
||||||
|
@ -411,7 +407,6 @@ static void Tml_ShowTimeline (struct Tml_Timeline *Timeline,
|
||||||
{
|
{
|
||||||
extern const char *Hlp_START_Timeline;
|
extern const char *Hlp_START_Timeline;
|
||||||
bool GlobalTimeline = (Gbl.Usrs.Other.UsrDat.UsrCod <= 0);
|
bool GlobalTimeline = (Gbl.Usrs.Other.UsrDat.UsrCod <= 0);
|
||||||
unsigned NumNotesShown;
|
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
Box_BoxBegin (NULL,Title,
|
Box_BoxBegin (NULL,Title,
|
||||||
|
@ -439,12 +434,10 @@ static void Tml_ShowTimeline (struct Tml_Timeline *Timeline,
|
||||||
Tml_PutHiddenList ("new_timeline_list");
|
Tml_PutHiddenList ("new_timeline_list");
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** List recent publications in timeline *****/
|
/***** List recent publications in timeline.
|
||||||
NumNotesShown = Tml_ListRecentPubs (Timeline,NotCodToHighlight);
|
If the number of publications shown is the maximum,
|
||||||
|
|
||||||
/***** If the number of publications shown is the maximum,
|
|
||||||
probably there will be more, so show link to get more *****/
|
probably there will be more, so show link to get more *****/
|
||||||
if (NumNotesShown == Tml_Pub_MAX_REC_PUBS_TO_GET_AND_SHOW)
|
if (Tml_ListRecentPubs (Timeline,NotCodToHighlight) == Tml_Pub_MAX_REC_PUBS_TO_GET_AND_SHOW)
|
||||||
{
|
{
|
||||||
/* Link to view old publications via AJAX */
|
/* Link to view old publications via AJAX */
|
||||||
Tml_Pub_PutLinkToViewOldPubs ();
|
Tml_Pub_PutLinkToViewOldPubs ();
|
||||||
|
@ -472,12 +465,12 @@ static void Tml_PutIconsTimeline (__attribute__((unused)) void *Args)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// Returns number of notes shown
|
// Returns number of notes shown
|
||||||
|
|
||||||
static unsigned Tml_ListRecentPubs (struct Tml_Timeline *Timeline,
|
static unsigned Tml_ListRecentPubs (const struct Tml_Timeline *Timeline,
|
||||||
long NotCodToHighlight)
|
long NotCodToHighlight)
|
||||||
{
|
{
|
||||||
unsigned NumNotesShown;
|
const struct Tml_Pub_Publication *Pub;
|
||||||
struct Tml_Pub_Publication *Pub;
|
|
||||||
struct Tml_Not_Note Not;
|
struct Tml_Not_Note Not;
|
||||||
|
unsigned NumNotesShown;
|
||||||
|
|
||||||
/***** Begin list *****/
|
/***** Begin list *****/
|
||||||
HTM_UL_Begin ("id=\"timeline_list\" class=\"Tml_LIST\"");
|
HTM_UL_Begin ("id=\"timeline_list\" class=\"Tml_LIST\"");
|
||||||
|
|
|
@ -54,16 +54,14 @@
|
||||||
/******************************** Public types *******************************/
|
/******************************** Public types *******************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define Tml_NUM_TOP_MESSAGES (1 + 6)
|
#define Tml_NUM_TOP_MESSAGES (1 + 4)
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
Tml_TOP_MESSAGE_NONE = 0,
|
Tml_TOP_MESSAGE_NONE = 0, // 0 to avoid need of explicit inicialization
|
||||||
Tml_TOP_MESSAGE_COMMENTED = 1,
|
Tml_TOP_MESSAGE_COMMENTED = 1,
|
||||||
Tml_TOP_MESSAGE_FAVED = 2,
|
Tml_TOP_MESSAGE_FAVED = 2,
|
||||||
Tml_TOP_MESSAGE_UNFAVED = 3,
|
Tml_TOP_MESSAGE_SHARED = 3,
|
||||||
Tml_TOP_MESSAGE_SHARED = 4,
|
Tml_TOP_MESSAGE_MENTIONED = 4,
|
||||||
Tml_TOP_MESSAGE_UNSHARED = 5,
|
|
||||||
Tml_TOP_MESSAGE_MENTIONED = 6,
|
|
||||||
} Tml_TopMessage_t;
|
} Tml_TopMessage_t;
|
||||||
|
|
||||||
#define Tml_NUM_WHAT_TO_GET 3
|
#define Tml_NUM_WHAT_TO_GET 3
|
||||||
|
@ -71,7 +69,7 @@ typedef enum
|
||||||
{
|
{
|
||||||
Tml_GET_NEW_PUBS, // New publications are retrieved via AJAX...
|
Tml_GET_NEW_PUBS, // New publications are retrieved via AJAX...
|
||||||
// automatically from time to time
|
// automatically from time to time
|
||||||
Tml_GET_RECENT_PUBS, // Recent timeline is shown...
|
Tml_GET_REC_PUBS, // Recent timeline is shown...
|
||||||
// when the user clicks on action menu,...
|
// when the user clicks on action menu,...
|
||||||
// or after editing timeline
|
// or after editing timeline
|
||||||
Tml_GET_OLD_PUBS, // Old publications are retrieved via AJAX...
|
Tml_GET_OLD_PUBS, // Old publications are retrieved via AJAX...
|
||||||
|
|
|
@ -875,35 +875,36 @@ static long Tml_DB_GetMedCod (const char *Table,const char *Field,long Cod)
|
||||||
/******* Create temporary table and subquery with potential publishers *******/
|
/******* Create temporary table and subquery with potential publishers *******/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Tml_DB_CreateSubQueryPublishers (const struct Tml_Timeline *Timeline,
|
void Tml_DB_CreateSubQueryPublishers (Tml_Usr_UsrOrGbl_t UsrOrGbl,Usr_Who_t Who,
|
||||||
struct Tml_Pub_SubQueries *SubQueries)
|
char **Table,
|
||||||
|
char SubQuery[Tml_Pub_MAX_BYTES_SUBQUERY + 1])
|
||||||
{
|
{
|
||||||
switch (Timeline->UsrOrGbl)
|
switch (UsrOrGbl)
|
||||||
{
|
{
|
||||||
case Tml_Usr_TIMELINE_USR: // Show the timeline of a user
|
case Tml_Usr_TIMELINE_USR: // Show the timeline of a user
|
||||||
SubQueries->TablePublishers = "";
|
*Table = "";
|
||||||
sprintf (SubQueries->Publishers,"tml_pubs.PublisherCod=%ld AND ",
|
sprintf (SubQuery,"tml_pubs.PublisherCod=%ld AND ",
|
||||||
Gbl.Usrs.Other.UsrDat.UsrCod);
|
Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||||
break;
|
break;
|
||||||
case Tml_Usr_TIMELINE_GBL: // Show the global timeline
|
case Tml_Usr_TIMELINE_GBL: // Show the global timeline
|
||||||
switch (Timeline->Who)
|
switch (Who)
|
||||||
{
|
{
|
||||||
case Usr_WHO_ME: // Show my timeline
|
case Usr_WHO_ME: // Show my timeline
|
||||||
SubQueries->TablePublishers = "";
|
*Table = "";
|
||||||
snprintf (SubQueries->Publishers,sizeof (SubQueries->Publishers),
|
snprintf (SubQuery,Tml_Pub_MAX_BYTES_SUBQUERY + 1,
|
||||||
"tml_pubs.PublisherCod=%ld AND ",
|
"tml_pubs.PublisherCod=%ld AND ",
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
break;
|
break;
|
||||||
case Usr_WHO_FOLLOWED: // Show the timeline of the users I follow
|
case Usr_WHO_FOLLOWED: // Show the timeline of the users I follow
|
||||||
Fol_DB_CreateTmpTableMeAndUsrsIFollow ();
|
Fol_DB_CreateTmpTableMeAndUsrsIFollow ();
|
||||||
SubQueries->TablePublishers = ",fol_tmp_me_and_followed";
|
*Table = ",fol_tmp_me_and_followed";
|
||||||
Str_Copy (SubQueries->Publishers,
|
Str_Copy (SubQuery,
|
||||||
"tml_pubs.PublisherCod=fol_tmp_me_and_followed.UsrCod AND ",
|
"tml_pubs.PublisherCod=fol_tmp_me_and_followed.UsrCod AND ",
|
||||||
sizeof (SubQueries->Publishers) - 1);
|
Tml_Pub_MAX_BYTES_SUBQUERY);
|
||||||
break;
|
break;
|
||||||
case Usr_WHO_ALL: // Show the timeline of all users
|
case Usr_WHO_ALL: // Show the timeline of all users
|
||||||
SubQueries->TablePublishers = "";
|
*Table = "";
|
||||||
SubQueries->Publishers[0] = '\0';
|
SubQuery[0] = '\0';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Err_WrongWhoExit ();
|
Err_WrongWhoExit ();
|
||||||
|
@ -917,41 +918,45 @@ void Tml_DB_CreateSubQueryPublishers (const struct Tml_Timeline *Timeline,
|
||||||
/********* Create subquery to get only notes not present in timeline *********/
|
/********* Create subquery to get only notes not present in timeline *********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Tml_DB_CreateSubQueryAlreadyExists (const struct Tml_Timeline *Timeline,
|
void Tml_DB_CreateSubQueryAlreadyExists (Tml_WhatToGet_t WhatToGet,
|
||||||
struct Tml_Pub_SubQueries *SubQueries)
|
char AlreadyExists[Tml_Pub_MAX_BYTES_SUBQUERY + 1])
|
||||||
{
|
{
|
||||||
static const char *Table[Tml_NUM_WHAT_TO_GET] =
|
static const char *Table[Tml_NUM_WHAT_TO_GET] =
|
||||||
{
|
{
|
||||||
[Tml_GET_NEW_PUBS ] = "tml_tmp_just_retrieved_notes", // Avoid notes just retrieved
|
[Tml_GET_NEW_PUBS] = "tml_tmp_just_retrieved_notes", // Avoid notes just retrieved
|
||||||
[Tml_GET_RECENT_PUBS] = "tml_tmp_just_retrieved_notes", // Avoid notes just retrieved
|
[Tml_GET_REC_PUBS] = "tml_tmp_just_retrieved_notes", // Avoid notes just retrieved
|
||||||
[Tml_GET_OLD_PUBS ] = "tml_tmp_visible_timeline", // Avoid notes already shown
|
[Tml_GET_OLD_PUBS] = "tml_tmp_visible_timeline", // Avoid notes already shown
|
||||||
};
|
};
|
||||||
|
|
||||||
snprintf (SubQueries->AlreadyExists,sizeof (SubQueries->AlreadyExists),
|
snprintf (AlreadyExists,Tml_Pub_MAX_BYTES_SUBQUERY + 1,
|
||||||
" tml_pubs.NotCod NOT IN"
|
" tml_pubs.NotCod NOT IN"
|
||||||
" (SELECT NotCod"
|
" (SELECT NotCod"
|
||||||
" FROM %s)",
|
" FROM %s)",
|
||||||
Table[Timeline->WhatToGet]);
|
Table[WhatToGet]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***** Create subqueries with range of publications to get from tml_pubs *****/
|
/***** Create subqueries with range of publications to get from tml_pubs *****/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Tml_DB_CreateSubQueryRangeBottom (long Bottom,struct Tml_Pub_SubQueries *SubQueries)
|
void Tml_DB_CreateSubQueryRangeBottom (long Bottom,
|
||||||
|
char SubQuery[Tml_Pub_MAX_BYTES_SUBQUERY + 1])
|
||||||
{
|
{
|
||||||
if (Bottom > 0)
|
if (Bottom > 0)
|
||||||
sprintf (SubQueries->RangeBottom,"tml_pubs.PubCod>%ld AND ",Bottom);
|
snprintf (SubQuery,Tml_Pub_MAX_BYTES_SUBQUERY + 1,
|
||||||
|
"tml_pubs.PubCod>%ld AND ",Bottom);
|
||||||
else
|
else
|
||||||
SubQueries->RangeBottom[0] = '\0';
|
SubQuery[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tml_DB_CreateSubQueryRangeTop (long Top,struct Tml_Pub_SubQueries *SubQueries)
|
void Tml_DB_CreateSubQueryRangeTop (long Top,
|
||||||
|
char SubQuery[Tml_Pub_MAX_BYTES_SUBQUERY + 1])
|
||||||
{
|
{
|
||||||
if (Top > 0)
|
if (Top > 0)
|
||||||
sprintf (SubQueries->RangeTop,"tml_pubs.PubCod<%ld AND ",Top);
|
snprintf (SubQuery,Tml_Pub_MAX_BYTES_SUBQUERY + 1,
|
||||||
|
"tml_pubs.PubCod<%ld AND ",Top);
|
||||||
else
|
else
|
||||||
SubQueries->RangeTop[0] = '\0';
|
SubQuery[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -959,8 +964,8 @@ void Tml_DB_CreateSubQueryRangeTop (long Top,struct Tml_Pub_SubQueries *SubQueri
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// Returns the number of rows got
|
// Returns the number of rows got
|
||||||
|
|
||||||
unsigned Tml_DB_SelectTheMostRecentPub (const struct Tml_Pub_SubQueries *SubQueries,
|
unsigned Tml_DB_SelectTheMostRecentPub (MYSQL_RES **mysql_res,
|
||||||
MYSQL_RES **mysql_res)
|
const struct Tml_Pub_SubQueries *SubQueries)
|
||||||
{
|
{
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
DB_QuerySELECT (mysql_res,"can not get publication",
|
DB_QuerySELECT (mysql_res,"can not get publication",
|
||||||
|
@ -972,10 +977,10 @@ unsigned Tml_DB_SelectTheMostRecentPub (const struct Tml_Pub_SubQueries *SubQuer
|
||||||
" WHERE %s%s%s%s"
|
" WHERE %s%s%s%s"
|
||||||
" ORDER BY tml_pubs.PubCod DESC"
|
" ORDER BY tml_pubs.PubCod DESC"
|
||||||
" LIMIT 1",
|
" LIMIT 1",
|
||||||
SubQueries->TablePublishers,
|
SubQueries->Publishers.Table,
|
||||||
SubQueries->RangeBottom,
|
SubQueries->RangeBottom,
|
||||||
SubQueries->RangeTop,
|
SubQueries->RangeTop,
|
||||||
SubQueries->Publishers,
|
SubQueries->Publishers.SubQuery,
|
||||||
SubQueries->AlreadyExists);
|
SubQueries->AlreadyExists);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1016,14 +1021,16 @@ long Tml_DB_GetNotCodFromPubCod (long PubCod)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************* Get last/first publication code stored in session *************/
|
/************* Get first/last publication code stored in session *************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// FieldName can be:
|
|
||||||
// "LastPubCod"
|
|
||||||
// "FirstPubCod"
|
|
||||||
|
|
||||||
long Tml_DB_GetPubCodFromSession (const char *FieldName)
|
long Tml_DB_GetPubCodFromSession (Tml_Pub_FirstLast_t FirstLast)
|
||||||
{
|
{
|
||||||
|
static const char *FieldName[Tml_Pub_NUM_FIRST_LAST] =
|
||||||
|
{
|
||||||
|
[Tml_Pub_FIRST] = "FirstPubCod",
|
||||||
|
[Tml_Pub_LAST ] = "LastPubCod",
|
||||||
|
};
|
||||||
long PubCod;
|
long PubCod;
|
||||||
|
|
||||||
/***** Get last publication code from database *****/
|
/***** Get last publication code from database *****/
|
||||||
|
@ -1031,7 +1038,7 @@ long Tml_DB_GetPubCodFromSession (const char *FieldName)
|
||||||
"SELECT %s" // row[0]
|
"SELECT %s" // row[0]
|
||||||
" FROM ses_sessions"
|
" FROM ses_sessions"
|
||||||
" WHERE SessionId='%s'",
|
" WHERE SessionId='%s'",
|
||||||
FieldName,
|
FieldName[FirstLast],
|
||||||
Gbl.Session.Id);
|
Gbl.Session.Id);
|
||||||
if (PubCod < 0)
|
if (PubCod < 0)
|
||||||
PubCod = 0;
|
PubCod = 0;
|
||||||
|
|
|
@ -97,17 +97,20 @@ void Tml_DB_RemoveAllCommsInAllNotesOf (long UsrCod);
|
||||||
void Tml_DB_RemoveAllCommsMadeBy (long UsrCod);
|
void Tml_DB_RemoveAllCommsMadeBy (long UsrCod);
|
||||||
|
|
||||||
/****************************** Publications *********************************/
|
/****************************** Publications *********************************/
|
||||||
void Tml_DB_CreateSubQueryPublishers (const struct Tml_Timeline *Timeline,
|
void Tml_DB_CreateSubQueryPublishers (Tml_Usr_UsrOrGbl_t UsrOrGbl,Usr_Who_t Who,
|
||||||
struct Tml_Pub_SubQueries *SubQueries);
|
char **Table,
|
||||||
void Tml_DB_CreateSubQueryAlreadyExists (const struct Tml_Timeline *Timeline,
|
char SubQuery[Tml_Pub_MAX_BYTES_SUBQUERY + 1]);
|
||||||
struct Tml_Pub_SubQueries *SubQueries);
|
void Tml_DB_CreateSubQueryAlreadyExists (Tml_WhatToGet_t WhatToGet,
|
||||||
void Tml_DB_CreateSubQueryRangeBottom (long Bottom,struct Tml_Pub_SubQueries *SubQueries);
|
char AlreadyExists[Tml_Pub_MAX_BYTES_SUBQUERY + 1]);
|
||||||
void Tml_DB_CreateSubQueryRangeTop (long Top,struct Tml_Pub_SubQueries *SubQueries);
|
void Tml_DB_CreateSubQueryRangeBottom (long Bottom,
|
||||||
unsigned Tml_DB_SelectTheMostRecentPub (const struct Tml_Pub_SubQueries *SubQueries,
|
char SubQuery[Tml_Pub_MAX_BYTES_SUBQUERY + 1]);
|
||||||
MYSQL_RES **mysql_res);
|
void Tml_DB_CreateSubQueryRangeTop (long Top,
|
||||||
|
char SubQuery[Tml_Pub_MAX_BYTES_SUBQUERY + 1]);
|
||||||
|
unsigned Tml_DB_SelectTheMostRecentPub (MYSQL_RES **mysql_res,
|
||||||
|
const struct Tml_Pub_SubQueries *SubQueries);
|
||||||
unsigned Tml_DB_GetDataOfPubByCod (long PubCod,MYSQL_RES **mysql_res);
|
unsigned Tml_DB_GetDataOfPubByCod (long PubCod,MYSQL_RES **mysql_res);
|
||||||
long Tml_DB_GetNotCodFromPubCod (long PubCod);
|
long Tml_DB_GetNotCodFromPubCod (long PubCod);
|
||||||
long Tml_DB_GetPubCodFromSession (const char *FieldName);
|
long Tml_DB_GetPubCodFromSession (Tml_Pub_FirstLast_t FirstLast);
|
||||||
unsigned Tml_DB_GetNumPubsUsr (long UsrCod);
|
unsigned Tml_DB_GetNumPubsUsr (long UsrCod);
|
||||||
unsigned Tml_DB_GetPublishersInNoteExceptMe (MYSQL_RES **mysql_res,long PubCod);
|
unsigned Tml_DB_GetPublishersInNoteExceptMe (MYSQL_RES **mysql_res,long PubCod);
|
||||||
long Tml_DB_CreateNewPub (const struct Tml_Pub_Publication *Pub);
|
long Tml_DB_CreateNewPub (const struct Tml_Pub_Publication *Pub);
|
||||||
|
|
|
@ -129,40 +129,10 @@ void Tml_Not_ShowHighlightedNote (struct Tml_Timeline *Timeline,
|
||||||
Ntf_NotifyEvent_t NotifyEvent;
|
Ntf_NotifyEvent_t NotifyEvent;
|
||||||
static const Tml_TopMessage_t TopMessages[Ntf_NUM_NOTIFY_EVENTS] =
|
static const Tml_TopMessage_t TopMessages[Ntf_NUM_NOTIFY_EVENTS] =
|
||||||
{
|
{
|
||||||
[Ntf_EVENT_UNKNOWN ] = Tml_TOP_MESSAGE_NONE,
|
[Ntf_EVENT_TML_COMMENT] = Tml_TOP_MESSAGE_COMMENTED,
|
||||||
/* Start tab */
|
[Ntf_EVENT_TML_FAV ] = Tml_TOP_MESSAGE_FAVED,
|
||||||
[Ntf_EVENT_TML_COMMENT ] = Tml_TOP_MESSAGE_COMMENTED,
|
[Ntf_EVENT_TML_SHARE ] = Tml_TOP_MESSAGE_SHARED,
|
||||||
[Ntf_EVENT_TML_FAV ] = Tml_TOP_MESSAGE_FAVED,
|
[Ntf_EVENT_TML_MENTION] = Tml_TOP_MESSAGE_MENTIONED,
|
||||||
[Ntf_EVENT_TML_SHARE ] = Tml_TOP_MESSAGE_SHARED,
|
|
||||||
[Ntf_EVENT_TML_MENTION ] = Tml_TOP_MESSAGE_MENTIONED,
|
|
||||||
[Ntf_EVENT_FOLLOWER ] = Tml_TOP_MESSAGE_NONE,
|
|
||||||
/* System tab */
|
|
||||||
/* Country tab */
|
|
||||||
/* Institution tab */
|
|
||||||
/* Center tab */
|
|
||||||
/* Degree tab */
|
|
||||||
/* Course tab */
|
|
||||||
/* Assessment tab */
|
|
||||||
[Ntf_EVENT_ASSIGNMENT ] = Tml_TOP_MESSAGE_NONE,
|
|
||||||
[Ntf_EVENT_SURVEY ] = Tml_TOP_MESSAGE_NONE,
|
|
||||||
[Ntf_EVENT_CALL_FOR_EXAM ] = Tml_TOP_MESSAGE_NONE,
|
|
||||||
/* Files tab */
|
|
||||||
[Ntf_EVENT_DOCUMENT_FILE ] = Tml_TOP_MESSAGE_NONE,
|
|
||||||
[Ntf_EVENT_TEACHERS_FILE ] = Tml_TOP_MESSAGE_NONE,
|
|
||||||
[Ntf_EVENT_SHARED_FILE ] = Tml_TOP_MESSAGE_NONE,
|
|
||||||
[Ntf_EVENT_MARKS_FILE ] = Tml_TOP_MESSAGE_NONE,
|
|
||||||
/* Users tab */
|
|
||||||
[Ntf_EVENT_ENROLMENT_STD ] = Tml_TOP_MESSAGE_NONE,
|
|
||||||
[Ntf_EVENT_ENROLMENT_NET ] = Tml_TOP_MESSAGE_NONE,
|
|
||||||
[Ntf_EVENT_ENROLMENT_TCH ] = Tml_TOP_MESSAGE_NONE,
|
|
||||||
[Ntf_EVENT_ENROLMENT_REQUEST] = Tml_TOP_MESSAGE_NONE,
|
|
||||||
/* Messages tab */
|
|
||||||
[Ntf_EVENT_NOTICE ] = Tml_TOP_MESSAGE_NONE,
|
|
||||||
[Ntf_EVENT_FORUM_POST_COURSE] = Tml_TOP_MESSAGE_NONE,
|
|
||||||
[Ntf_EVENT_FORUM_REPLY ] = Tml_TOP_MESSAGE_NONE,
|
|
||||||
[Ntf_EVENT_MESSAGE ] = Tml_TOP_MESSAGE_NONE,
|
|
||||||
/* Analytics tab */
|
|
||||||
/* Profile tab */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/***** Get other parameters *****/
|
/***** Get other parameters *****/
|
||||||
|
@ -1307,7 +1277,7 @@ void Tml_Not_GetDataOfNoteByCod (struct Tml_Not_Note *Not)
|
||||||
/***** Trivial check: note code should be > 0 *****/
|
/***** Trivial check: note code should be > 0 *****/
|
||||||
if (Not->NotCod <= 0)
|
if (Not->NotCod <= 0)
|
||||||
{
|
{
|
||||||
/***** Reset fields of note *****/
|
/* Reset fields of note */
|
||||||
Tml_Not_ResetNote (Not);
|
Tml_Not_ResetNote (Not);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1315,12 +1285,12 @@ void Tml_Not_GetDataOfNoteByCod (struct Tml_Not_Note *Not)
|
||||||
/***** Get data of note from database *****/
|
/***** Get data of note from database *****/
|
||||||
if (Tml_DB_GetDataOfNoteByCod (Not->NotCod,&mysql_res))
|
if (Tml_DB_GetDataOfNoteByCod (Not->NotCod,&mysql_res))
|
||||||
{
|
{
|
||||||
/***** Get data of note *****/
|
/* Get data of note */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
Tml_Not_GetDataOfNoteFromRow (row,Not);
|
Tml_Not_GetDataOfNoteFromRow (row,Not);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/***** Reset fields of note *****/
|
/* Reset fields of note */
|
||||||
Tml_Not_ResetNote (Not);
|
Tml_Not_ResetNote (Not);
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
|
|
@ -93,7 +93,7 @@ void Tml_Pub_GetListPubsToShowInTimeline (struct Tml_Timeline *Timeline)
|
||||||
Tml_Pub_InitializeRangeOfPubs (Timeline->WhatToGet,&RangePubsToGet);
|
Tml_Pub_InitializeRangeOfPubs (Timeline->WhatToGet,&RangePubsToGet);
|
||||||
|
|
||||||
/***** Clear timeline for this session in database *****/
|
/***** Clear timeline for this session in database *****/
|
||||||
if (Timeline->WhatToGet == Tml_GET_RECENT_PUBS)
|
if (Timeline->WhatToGet == Tml_GET_REC_PUBS)
|
||||||
Tml_DB_ClearTimelineNotesOfSessionFromDB ();
|
Tml_DB_ClearTimelineNotesOfSessionFromDB ();
|
||||||
|
|
||||||
/***** Create temporary tables *****/
|
/***** Create temporary tables *****/
|
||||||
|
@ -106,14 +106,18 @@ void Tml_Pub_GetListPubsToShowInTimeline (struct Tml_Timeline *Timeline)
|
||||||
|
|
||||||
/***** Create subqueries *****/
|
/***** Create subqueries *****/
|
||||||
/* Create subquery with potential publishers */
|
/* Create subquery with potential publishers */
|
||||||
Tml_DB_CreateSubQueryPublishers (Timeline,&SubQueries);
|
Tml_DB_CreateSubQueryPublishers (Timeline->UsrOrGbl,Timeline->Who,
|
||||||
|
&SubQueries.Publishers.Table,
|
||||||
|
SubQueries.Publishers.SubQuery);
|
||||||
|
|
||||||
/* Create subquery to get only notes not present in timeline */
|
/* Create subquery to get only notes not present in timeline */
|
||||||
Tml_DB_CreateSubQueryAlreadyExists (Timeline,&SubQueries);
|
Tml_DB_CreateSubQueryAlreadyExists (Timeline->WhatToGet,
|
||||||
|
SubQueries.AlreadyExists);
|
||||||
|
|
||||||
/* Create subquery with bottom range of publications to get from tml_pubs.
|
/* Create subquery with bottom range of publications to get from tml_pubs.
|
||||||
Bottom pub. code remains unchanged in all iterations of the loop. */
|
Bottom pub. code remains unchanged in all iterations of the loop. */
|
||||||
Tml_DB_CreateSubQueryRangeBottom (RangePubsToGet.Bottom,&SubQueries);
|
Tml_DB_CreateSubQueryRangeBottom (RangePubsToGet.Bottom,
|
||||||
|
SubQueries.RangeBottom);
|
||||||
|
|
||||||
/***** Initialize list of publications *****/
|
/***** Initialize list of publications *****/
|
||||||
/* Chained list of publications:
|
/* Chained list of publications:
|
||||||
|
@ -160,7 +164,7 @@ void Tml_Pub_GetListPubsToShowInTimeline (struct Tml_Timeline *Timeline)
|
||||||
{
|
{
|
||||||
/* Create subquery with top range of publications to get from tml_pubs
|
/* Create subquery with top range of publications to get from tml_pubs
|
||||||
In each iteration of this loop, top publication code is changed to a lower value */
|
In each iteration of this loop, top publication code is changed to a lower value */
|
||||||
Tml_DB_CreateSubQueryRangeTop (RangePubsToGet.Top,&SubQueries);
|
Tml_DB_CreateSubQueryRangeTop (RangePubsToGet.Top,SubQueries.RangeTop);
|
||||||
|
|
||||||
/* Select the most recent publication from tml_pubs */
|
/* Select the most recent publication from tml_pubs */
|
||||||
Pub = Tml_Pub_SelectTheMostRecentPub (&SubQueries);
|
Pub = Tml_Pub_SelectTheMostRecentPub (&SubQueries);
|
||||||
|
@ -211,10 +215,8 @@ void Tml_Pub_GetListPubsToShowInTimeline (struct Tml_Timeline *Timeline)
|
||||||
static void Tml_Pub_InitializeRangeOfPubs (Tml_WhatToGet_t WhatToGet,
|
static void Tml_Pub_InitializeRangeOfPubs (Tml_WhatToGet_t WhatToGet,
|
||||||
struct Tml_Pub_RangePubsToGet *RangePubsToGet)
|
struct Tml_Pub_RangePubsToGet *RangePubsToGet)
|
||||||
{
|
{
|
||||||
/* Initialize range of pubs:
|
/* tml_pubs
|
||||||
|
_____ 0
|
||||||
tml_pubs
|
|
||||||
_____
|
|
||||||
|_____|11
|
|_____|11
|
||||||
|_____|10
|
|_____|10
|
||||||
_|_____| 9 <-- RangePubsToGet.Top
|
_|_____| 9 <-- RangePubsToGet.Top
|
||||||
|
@ -226,33 +228,67 @@ static void Tml_Pub_InitializeRangeOfPubs (Tml_WhatToGet_t WhatToGet,
|
||||||
|_____| 3 <-- RangePubsToGet.Bottom
|
|_____| 3 <-- RangePubsToGet.Bottom
|
||||||
|_____| 2
|
|_____| 2
|
||||||
|_____| 1
|
|_____| 1
|
||||||
0
|
0 */
|
||||||
*/
|
|
||||||
|
|
||||||
switch (WhatToGet)
|
switch (WhatToGet)
|
||||||
{
|
{
|
||||||
case Tml_GET_NEW_PUBS: // Get the publications (without limit)
|
case Tml_GET_NEW_PUBS: // Get the publications (without limit)
|
||||||
// newer than LastPubCod
|
// newer than last pub. code
|
||||||
/* This query is made via AJAX automatically from time to time */
|
/* Via AJAX automatically from time to time */
|
||||||
RangePubsToGet->Top = 0; // +Infinite
|
RangePubsToGet->Top = 0;
|
||||||
RangePubsToGet->Bottom = Tml_DB_GetPubCodFromSession ("LastPubCod");
|
/* _ _____ 0 <-- RangePubsToGet.Top = +infinite
|
||||||
|
Get / |_____|11
|
||||||
|
these < |_____|10
|
||||||
|
pubs \_|_____| 9
|
||||||
|
/ |_____| 8 <-- RangePubsToGet.Bottom = last pub. code
|
||||||
|
Pubs | |_____| 7
|
||||||
|
already < |_____| 6
|
||||||
|
shown | |_____| 5
|
||||||
|
| |_____| 4
|
||||||
|
. |_____| .
|
||||||
|
. |_____| .
|
||||||
|
. |_____| .
|
||||||
|
*/
|
||||||
|
RangePubsToGet->Bottom = Tml_DB_GetPubCodFromSession (Tml_Pub_LAST);
|
||||||
break;
|
break;
|
||||||
case Tml_GET_RECENT_PUBS: // Get some limited recent publications
|
case Tml_GET_REC_PUBS: // Get some limited recent publications
|
||||||
/* This is the first query to get initial timeline shown
|
/* First query to get initial timeline shown
|
||||||
==> no notes yet in current timeline table */
|
==> no notes yet in current timeline table */
|
||||||
RangePubsToGet->Top = 0; // +Infinite
|
RangePubsToGet->Top = 0;
|
||||||
RangePubsToGet->Bottom = 0; // -Infinite
|
/* _ _____ 0 <-- RangePubsToGet.Top = +infinite
|
||||||
|
/ |_____| 8
|
||||||
|
Get | |_____| 7
|
||||||
|
pubs < |_____| 6
|
||||||
|
from | |_____| 5
|
||||||
|
all . |_____| 4
|
||||||
|
range . |_____| 3
|
||||||
|
. |_____| 2
|
||||||
|
|_____| 1
|
||||||
|
0 <-- RangePubsToGet.Bottom = -infinite */
|
||||||
|
RangePubsToGet->Bottom = 0;
|
||||||
break;
|
break;
|
||||||
case Tml_GET_OLD_PUBS: // Get some limited publications
|
case Tml_GET_OLD_PUBS: // Get some limited publications
|
||||||
// older than FirstPubCod
|
// older than first pub. code
|
||||||
/* This query is made via AJAX
|
/* Via AJAX when I click in link to get old publications */
|
||||||
when I click in link to get old publications */
|
RangePubsToGet->Top = Tml_DB_GetPubCodFromSession (Tml_Pub_FIRST);
|
||||||
RangePubsToGet->Top = Tml_DB_GetPubCodFromSession ("FirstPubCod");
|
/* _____
|
||||||
RangePubsToGet->Bottom = 0; // -Infinite
|
. |_____| .
|
||||||
|
. |_____| .
|
||||||
|
. |_____| .
|
||||||
|
Pubs | |_____| 8
|
||||||
|
already < |_____| 7
|
||||||
|
shown | |_____| 6
|
||||||
|
| |_____| 5
|
||||||
|
Get \_|_____| 4 <-- RangePubsToGet.Top = first pub. code
|
||||||
|
pubs / |_____| 3
|
||||||
|
from < |_____| 2
|
||||||
|
this \_|_____| 1
|
||||||
|
rage 0 <-- RangePubsToGet.Bottom = -infinite */
|
||||||
|
RangePubsToGet->Bottom = 0;
|
||||||
|
break;
|
||||||
|
default: // Not reached
|
||||||
|
RangePubsToGet->Top =
|
||||||
|
RangePubsToGet->Bottom = 0; // Initialized to avoid warning
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
RangePubsToGet->Top = 0; // +Infinite
|
|
||||||
RangePubsToGet->Bottom = 0; // -Infinite
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,9 +300,9 @@ static unsigned Tml_Pub_GetMaxPubsToGet (const struct Tml_Timeline *Timeline)
|
||||||
{
|
{
|
||||||
static const unsigned MaxPubsToGet[Tml_NUM_WHAT_TO_GET] =
|
static const unsigned MaxPubsToGet[Tml_NUM_WHAT_TO_GET] =
|
||||||
{
|
{
|
||||||
[Tml_GET_NEW_PUBS ] = Tml_Pub_MAX_NEW_PUBS_TO_GET_AND_SHOW,
|
[Tml_GET_NEW_PUBS] = Tml_Pub_MAX_NEW_PUBS_TO_GET_AND_SHOW,
|
||||||
[Tml_GET_RECENT_PUBS] = Tml_Pub_MAX_REC_PUBS_TO_GET_AND_SHOW,
|
[Tml_GET_REC_PUBS] = Tml_Pub_MAX_REC_PUBS_TO_GET_AND_SHOW,
|
||||||
[Tml_GET_OLD_PUBS ] = Tml_Pub_MAX_OLD_PUBS_TO_GET_AND_SHOW,
|
[Tml_GET_OLD_PUBS] = Tml_Pub_MAX_OLD_PUBS_TO_GET_AND_SHOW,
|
||||||
};
|
};
|
||||||
|
|
||||||
return MaxPubsToGet[Timeline->WhatToGet];
|
return MaxPubsToGet[Timeline->WhatToGet];
|
||||||
|
@ -286,12 +322,12 @@ static void Tml_Pub_UpdateFirstLastPubCodesIntoSession (const struct Tml_Timelin
|
||||||
case Tml_GET_NEW_PUBS: // Get only new publications
|
case Tml_GET_NEW_PUBS: // Get only new publications
|
||||||
Tml_DB_UpdateLastPubCodInSession ();
|
Tml_DB_UpdateLastPubCodInSession ();
|
||||||
break;
|
break;
|
||||||
case Tml_GET_RECENT_PUBS: // Get last publications
|
case Tml_GET_REC_PUBS: // Get recent publications
|
||||||
case Tml_GET_OLD_PUBS: // Get only old publications
|
case Tml_GET_OLD_PUBS: // Get only old publications
|
||||||
// The oldest publication code retrieved and shown
|
// The oldest publication code retrieved and shown
|
||||||
FirstPubCod = Timeline->Pubs.Bottom ? Timeline->Pubs.Bottom->PubCod :
|
FirstPubCod = Timeline->Pubs.Bottom ? Timeline->Pubs.Bottom->PubCod :
|
||||||
0;
|
0;
|
||||||
if (Timeline->WhatToGet == Tml_GET_RECENT_PUBS)
|
if (Timeline->WhatToGet == Tml_GET_REC_PUBS)
|
||||||
Tml_DB_UpdateFirstLastPubCodsInSession (FirstPubCod);
|
Tml_DB_UpdateFirstLastPubCodsInSession (FirstPubCod);
|
||||||
else
|
else
|
||||||
Tml_DB_UpdateFirstPubCodInSession (FirstPubCod);
|
Tml_DB_UpdateFirstPubCodInSession (FirstPubCod);
|
||||||
|
@ -335,7 +371,7 @@ static struct Tml_Pub_Publication *Tml_Pub_SelectTheMostRecentPub (const struct
|
||||||
struct Tml_Pub_Publication *Pub;
|
struct Tml_Pub_Publication *Pub;
|
||||||
|
|
||||||
/***** Select the most recent publication from database *****/
|
/***** Select the most recent publication from database *****/
|
||||||
if (Tml_DB_SelectTheMostRecentPub (SubQueries,&mysql_res) == 1)
|
if (Tml_DB_SelectTheMostRecentPub (&mysql_res,SubQueries) == 1)
|
||||||
{
|
{
|
||||||
/* Allocate space for publication */
|
/* Allocate space for publication */
|
||||||
if ((Pub = malloc (sizeof (*Pub))) == NULL)
|
if ((Pub = malloc (sizeof (*Pub))) == NULL)
|
||||||
|
@ -421,8 +457,6 @@ Tml_TopMessage_t Tml_Pub_GetTopMessage (Tml_Pub_Type_t PubType)
|
||||||
{
|
{
|
||||||
static const Tml_TopMessage_t TopMessages[Tml_Pub_NUM_PUB_TYPES] =
|
static const Tml_TopMessage_t TopMessages[Tml_Pub_NUM_PUB_TYPES] =
|
||||||
{
|
{
|
||||||
[Tml_Pub_UNKNOWN ] = Tml_TOP_MESSAGE_NONE,
|
|
||||||
[Tml_Pub_ORIGINAL_NOTE ] = Tml_TOP_MESSAGE_NONE,
|
|
||||||
[Tml_Pub_SHARED_NOTE ] = Tml_TOP_MESSAGE_SHARED,
|
[Tml_Pub_SHARED_NOTE ] = Tml_TOP_MESSAGE_SHARED,
|
||||||
[Tml_Pub_COMMENT_TO_NOTE] = Tml_TOP_MESSAGE_COMMENTED,
|
[Tml_Pub_COMMENT_TO_NOTE] = Tml_TOP_MESSAGE_COMMENTED,
|
||||||
};
|
};
|
||||||
|
|
|
@ -67,15 +67,25 @@ struct Tml_Pub_Publication
|
||||||
|
|
||||||
struct Tml_Pub_RangePubsToGet
|
struct Tml_Pub_RangePubsToGet
|
||||||
{
|
{
|
||||||
long Top;
|
long Top; // Top pub code
|
||||||
long Bottom;
|
long Bottom; // Bottom pub code
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define Tml_Pub_NUM_FIRST_LAST 2
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
Tml_Pub_FIRST = 0,
|
||||||
|
Tml_Pub_LAST = 1,
|
||||||
|
} Tml_Pub_FirstLast_t;
|
||||||
|
|
||||||
#define Tml_Pub_MAX_BYTES_SUBQUERY (128 - 1)
|
#define Tml_Pub_MAX_BYTES_SUBQUERY (128 - 1)
|
||||||
struct Tml_Pub_SubQueries
|
struct Tml_Pub_SubQueries
|
||||||
{
|
{
|
||||||
char *TablePublishers;
|
struct
|
||||||
char Publishers [Tml_Pub_MAX_BYTES_SUBQUERY + 1];
|
{
|
||||||
|
char *Table;
|
||||||
|
char SubQuery[Tml_Pub_MAX_BYTES_SUBQUERY + 1];
|
||||||
|
} Publishers;
|
||||||
char RangeBottom [Tml_Pub_MAX_BYTES_SUBQUERY + 1];
|
char RangeBottom [Tml_Pub_MAX_BYTES_SUBQUERY + 1];
|
||||||
char RangeTop [Tml_Pub_MAX_BYTES_SUBQUERY + 1];
|
char RangeTop [Tml_Pub_MAX_BYTES_SUBQUERY + 1];
|
||||||
char AlreadyExists[Tml_Pub_MAX_BYTES_SUBQUERY + 1];
|
char AlreadyExists[Tml_Pub_MAX_BYTES_SUBQUERY + 1];
|
||||||
|
|
Loading…
Reference in New Issue