From f7a717e0dfd5c65e45dce00358c99f9a8c87caef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Sat, 9 Jan 2016 21:55:06 +0100 Subject: [PATCH] Version 15.104.4 --- js/swad15.104.js | 26 ++++++++++++++++++++------ swad_action.c | 2 +- swad_changelog.h | 3 ++- swad_global.c | 1 - swad_global.h | 4 ++++ swad_layout.c | 6 ++++-- swad_social.c | 38 ++++++++++++++++++++++++++++++++++++-- swad_social.h | 1 + 8 files changed, 68 insertions(+), 13 deletions(-) diff --git a/js/swad15.104.js b/js/swad15.104.js index e666ac883..b34673a91 100644 --- a/js/swad15.104.js +++ b/js/swad15.104.js @@ -26,6 +26,9 @@ var Gbl_HTMLContent; // Global variable used to call SWAD via AJAX var ActionAJAX; +// Global variable that stores last publishing code got from database in timeline +var LastPubCod = 0; + // Global variables used in writeLocalClock() var secondsSince1970UTC; @@ -322,7 +325,10 @@ var objXMLHttpReqCon = false; function refreshConnected() { objXMLHttpReqCon = AJAXCreateObject(); if (objXMLHttpReqCon) { - var RefreshParams = RefreshParamNxtActCon + '&' + RefreshParamIdSes + '&' + RefreshParamCrsCod; + var RefreshParams = RefreshParamNxtActCon + '&' + + RefreshParamIdSes + '&' + + RefreshParamCrsCod; + objXMLHttpReqCon.onreadystatechange = readConnUsrsData; // onreadystatechange must be lowercase objXMLHttpReqCon.open('POST',ActionAJAX,true); objXMLHttpReqCon.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); @@ -335,7 +341,10 @@ var objXMLHttpReqLog = false; function refreshLastClicks() { objXMLHttpReqLog = AJAXCreateObject(); if (objXMLHttpReqLog) { - var RefreshParams = RefreshParamNxtActLog + '&' + RefreshParamIdSes + '&' + RefreshParamCrsCod; + var RefreshParams = RefreshParamNxtActLog + '&' + + RefreshParamIdSes + '&' + + RefreshParamCrsCod; + objXMLHttpReqLog.onreadystatechange = readLastClicksData; // onreadystatechange must be lowercase objXMLHttpReqLog.open('POST',ActionAJAX,true); objXMLHttpReqLog.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); @@ -348,7 +357,10 @@ var objXMLHttpReqSoc = false; function refreshSocialTimeline() { objXMLHttpReqSoc = AJAXCreateObject(); if (objXMLHttpReqSoc) { - var RefreshParams = RefreshParamNxtActSoc + '&' + RefreshParamIdSes + '&' + RefreshParamCrsCod; + var RefreshParams = RefreshParamNxtActSoc + '&' + + RefreshParamIdSes + '&' + + 'LastPubCod=' + LastPubCod; + objXMLHttpReqSoc.onreadystatechange = readSocialTimelineData; // onreadystatechange must be lowercase objXMLHttpReqSoc.open('POST',ActionAJAX,true); objXMLHttpReqSoc.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); @@ -442,10 +454,12 @@ function readLastClicksData() { function readSocialTimelineData() { if (objXMLHttpReqSoc.readyState == 4) { // Check if data have been received if (objXMLHttpReqSoc.status == 200) { - var endOfDelay = objXMLHttpReqSoc.responseText.indexOf('|',0); // Get separator position + var endOfDelay = objXMLHttpReqSoc.responseText.indexOf('|',0); // Get separator position + var endOfLastPubCod = objXMLHttpReqSoc.responseText.indexOf('|',endOfDelay+1); // Get separator position - var delay = parseInt(objXMLHttpReqSoc.responseText.substring(0,endOfDelay)); // Get refresh delay - var htmlRecentTimeline = objXMLHttpReqSoc.responseText.substring(endOfDelay+1); // Get HTML code for social timeline + var delay = parseInt(objXMLHttpReqSoc.responseText.substring(0,endOfDelay)); // Get refresh delay + LastPubCod = parseInt(objXMLHttpReqSoc.responseText.substring(endOfDelay+1,endOfLastPubCod)); // Get last publishing code + var htmlRecentTimeline = objXMLHttpReqSoc.responseText.substring(endOfLastPubCod+1); // Get HTML code for social timeline var recentTimeline = document.getElementById('recent_timeline'); // Access to UL with the recent timeline if (recentTimeline) { diff --git a/swad_action.c b/swad_action.c index a81dd0267..9a956bcab 100644 --- a/swad_action.c +++ b/swad_action.c @@ -1339,7 +1339,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActMnu */{ 2,-1,TabUnk,ActMnu ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,NULL ,NULL}, /* ActRefCon */{ 845,-1,TabUnk,ActRefCon ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Lay_RefreshNotifsAndConnected ,NULL}, /* ActRefLstClk */{ 994,-1,TabUnk,ActRefLstClk ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Lay_RefreshLastClicks ,NULL}, - /* ActRefSocTim */{1509,-1,TabUnk,ActRefSocTim ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Lay_RefreshSocialTimeline ,NULL}, + /* ActRefSocTim */{1509,-1,TabUnk,ActRefSocTim ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,Soc_GetParamLastPubCod ,Lay_RefreshSocialTimeline ,NULL}, /* ActWebSvc */{ 892,-1,TabUnk,ActWebSvc ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Plg_WebService ,NULL}, // TabSys ****************************************************************** diff --git a/swad_changelog.h b/swad_changelog.h index ac824bbb5..52fd4a4f6 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -118,13 +118,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.104.3 (2016-01-09)" +#define Log_PLATFORM_VERSION "SWAD 15.104.4 (2016-01-09)" #define CSS_FILE "swad15.102.css" #define JS_FILE "swad15.104.js" // Number of lines (includes comments but not blank lines) has been got with the following command: // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1 /* + Version 15.104.4: Jan 09, 2016 Last social publishing code is sent and got via AJAX. (191831 lines) Version 15.104.3: Jan 09, 2016 Changes in layout of social timeline. (191784 lines) Version 15.104.2: Jan 09, 2016 Refresh recent social timeline via AJAX. (191769 lines) Version 15.104.1: Jan 09, 2016 Refresh recent social timeline via AJAX. (191727 lines) diff --git a/swad_global.c b/swad_global.c index e707f632a..c784269b0 100644 --- a/swad_global.c +++ b/swad_global.c @@ -214,7 +214,6 @@ void Gbl_InitializeGlobals (void) Gbl.CurrentIns.Ins.ShortName[0] = '\0'; Gbl.CurrentIns.Ins.FullName[0] = '\0'; Gbl.CurrentIns.Ins.WWW[0] = '\0'; - // Gbl.CurrentIns.Ins.NumStds = Gbl.CurrentIns.Ins.NumTchs = Gbl.CurrentIns.Ins.NumUsrs = Gbl.CurrentIns.Ins.NumCtrs = Gbl.CurrentIns.Ins.NumDpts = Gbl.CurrentIns.Ins.NumDegs = 0; Gbl.CurrentIns.Ins.NumUsrs = 0; diff --git a/swad_global.h b/swad_global.h index 4ee752597..8ad311d8a 100644 --- a/swad_global.h +++ b/swad_global.h @@ -382,6 +382,10 @@ struct Globals bool Error; // To signal that an error has happened const char *NicknameForQR; // Used as parameter in contextual links } Usrs; + struct + { + long LastPubCod; // Last code of publishing got from database when refreshing timeline via AJAX + } Social; struct { Sco_Scope_t Current; diff --git a/swad_layout.c b/swad_layout.c index b032d566d..1302b39e3 100644 --- a/swad_layout.c +++ b/swad_layout.c @@ -1497,8 +1497,10 @@ void Lay_RefreshLastClicks (void) void Lay_RefreshSocialTimeline (void) { - // Send, before the HTML, the refresh time - fprintf (Gbl.F.Out,"%lu|",Cfg_TIME_TO_REFRESH_SOCIAL_TIMELINE); + // Send, before the HTML, the refresh time and the last publishing got from database + fprintf (Gbl.F.Out,"%lu|%ld|", + Cfg_TIME_TO_REFRESH_SOCIAL_TIMELINE, + Gbl.Social.LastPubCod); Soc_GetAndShowRecentTimelineGbl (); /***** All the output is made, so don't write anymore *****/ diff --git a/swad_social.c b/swad_social.c index 5dbd210fb..390b51ac7 100644 --- a/swad_social.c +++ b/swad_social.c @@ -315,14 +315,39 @@ void Soc_ShowTimelineGbl (void) DB_ExitOnMySQLError ("can not remove temporary tables"); } +/*****************************************************************************/ +/**** Get parameter with the more recent publishing code got from database ***/ +/*****************************************************************************/ +// This parameter is sent and receiveda again via AJAX +// As an alternative, it could be stored in database with the code of session + +void Soc_GetParamLastPubCod (void) + { + char LongStr[1+10+1]; + long LongNum; + + /***** Get the more recent publishing code *****/ + Gbl.Social.LastPubCod = 0; + Par_GetParToText ("LastPubCod",LongStr,1+10); + if (LongStr[0]) // Parameter "LastPubCod" available + if (sscanf (LongStr,"%ld",&LongNum) == 1) + Gbl.Social.LastPubCod = LongNum; + } + /*****************************************************************************/ /******* Get and show recent timeline including all the users I follow *******/ /*****************************************************************************/ void Soc_GetAndShowRecentTimelineGbl (void) { - fprintf (Gbl.F.Out,"
  • PID = %lu; Time = %s
  • ", - (unsigned long) Gbl.PID,Gbl.Now.YYYYMMDDHHMMSS); + fprintf (Gbl.F.Out,"
  • " + "PID = %lu; " + "Time = %s; " + "Gbl.Social.LastPubCod = %ld" + "
  • ", + (unsigned long) Gbl.PID, + Gbl.Now.YYYYMMDDHHMMSS, + Gbl.Social.LastPubCod); } /*****************************************************************************/ @@ -367,6 +392,9 @@ static void Soc_ShowTimeline (const char *Query,const char *Title) row = mysql_fetch_row (mysql_res); Soc_GetDataOfSocialPublishingFromRow (row,&SocPub); + if (NumPub == 0) // The more recent publishing + Gbl.Social.LastPubCod = SocPub.PubCod; // Last publishing code got from database + /* Get data of social note */ SocNot.NotCod = SocPub.NotCod; Soc_GetDataOfSocialNoteByCod (&SocNot); @@ -384,6 +412,12 @@ static void Soc_ShowTimeline (const char *Query,const char *Title) /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); + + /***** Initialize javascript global variable with the code of the last punlishing *****/ + fprintf (Gbl.F.Out,"\n", + Gbl.Social.LastPubCod); } /*****************************************************************************/ diff --git a/swad_social.h b/swad_social.h index 9c47edd06..a1d4f74a0 100644 --- a/swad_social.h +++ b/swad_social.h @@ -83,6 +83,7 @@ typedef enum void Soc_ShowTimelineUsr (void); void Soc_ShowTimelineGbl (void); +void Soc_GetParamLastPubCod (void); void Soc_GetAndShowRecentTimelineGbl (void); void Soc_StoreAndPublishSocialNote (Soc_NoteType_t NoteType,long Cod);