From 468d2abbde7a79e85a94250c9ffeadca36bfc0d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Fri, 24 Feb 2017 03:38:18 +0100 Subject: [PATCH] Version 16.140 --- css/swad16.139.6.css | 2 +- js/{swad16.123.js => swad16.140.js} | 7 +- swad_action.c | 26 ++-- swad_changelog.h | 7 +- swad_forum.c | 3 +- swad_forum.h | 1 - swad_global.c | 3 + swad_global.h | 5 + swad_layout.c | 6 +- swad_social.c | 206 ++++++++++++++++++++++------ swad_social.h | 11 +- swad_text.c | 49 ++++++- 12 files changed, 261 insertions(+), 65 deletions(-) rename js/{swad16.123.js => swad16.140.js} (99%) diff --git a/css/swad16.139.6.css b/css/swad16.139.6.css index 3a840e0bf..c1bbe8320 100644 --- a/css/swad16.139.6.css +++ b/css/swad16.139.6.css @@ -1556,7 +1556,7 @@ table.CELLS_PAD_10 > tbody > tr > td {padding:10px;} { text-align:center; vertical-align:middle; - margin-bottom:12px; + margin-bottom:8px; } .SEL_BELOW_TITLE ul { diff --git a/js/swad16.123.js b/js/swad16.140.js similarity index 99% rename from js/swad16.123.js rename to js/swad16.140.js index a27c333b6..80effb987 100644 --- a/js/swad16.123.js +++ b/js/swad16.140.js @@ -433,7 +433,8 @@ function refreshNewTimeline () { objXMLHttpReqSoc = AJAXCreateObject(); if (objXMLHttpReqSoc) { var RefreshParams = RefreshParamNxtActNewPub + '&' + - RefreshParamIdSes; + RefreshParamIdSes + '&' + + RefreshParamWhichUsrs; objXMLHttpReqSoc.onreadystatechange = readNewTimelineData; // onreadystatechange must be lowercase objXMLHttpReqSoc.open('POST',ActionAJAX,true); @@ -447,7 +448,9 @@ var objXMLHttpReqSoc = false; function refreshOldTimeline () { objXMLHttpReqSoc = AJAXCreateObject (); if (objXMLHttpReqSoc) { - var RefreshParams = RefreshParamNxtActOldPub + '&' + RefreshParamIdSes; + var RefreshParams = RefreshParamNxtActOldPub + '&' + + RefreshParamIdSes + '&' + + RefreshParamWhichUsrs; if (RefreshParamUsr) if (RefreshParamUsr.length) RefreshParams += '&' + RefreshParamUsr; diff --git a/swad_action.c b/swad_action.c index 853402fe1..d3c5d9db8 100644 --- a/swad_action.c +++ b/swad_action.c @@ -2588,23 +2588,23 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActLstClk */{ 989,-1,TabUnk,ActLstCon ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Con_ShowLastClicks ,NULL}, // TabSoc ****************************************************************** - /* ActSeeSocTmlGbl */{1490, 0,TabSoc,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Soc_MarkMyNotifAsSeen ,Soc_ShowTimelineGbl ,"soc64x64.png" }, + /* ActSeeSocTmlGbl */{1490, 0,TabSoc,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Soc_ShowTimelineGbl1 ,Soc_ShowTimelineGbl2 ,"soc64x64.png" }, /* ActSeeSocPrf */{1520, 1,TabSoc,ActSeeSocPrf ,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Prf_SeeSocialProfiles ,"prf64x64.gif" }, /* ActSeeFor */{ 95, 2,TabSoc,ActSeeFor ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,For_ShowForumList ,"forum64x64.gif" }, /* ActSeeChtRms */{ 51, 3,TabSoc,ActSeeChtRms ,0x1FC,0x1FC,0x1FC,0x1FC,0x1FC,0x1FC,0x1FC,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Cht_ShowChatRooms ,"chat64x64.gif" }, - /* ActRcvSocPstGbl */{1492,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_DATA,Act_THIS_WINDOW,Soc_MarkMyNotifAsSeen ,Soc_ReceiveSocialPostGbl ,NULL}, - /* ActRcvSocComGbl */{1503,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_DATA,Act_THIS_WINDOW,Soc_MarkMyNotifAsSeen ,Soc_ReceiveCommentGbl ,NULL}, - /* ActShaSocNotGbl */{1495,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Soc_MarkMyNotifAsSeen ,Soc_ShareSocialNoteGbl ,NULL}, - /* ActUnsSocNotGbl */{1496,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Soc_MarkMyNotifAsSeen ,Soc_UnshareSocialNoteGbl ,NULL}, - /* ActFavSocNotGbl */{1512,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Soc_MarkMyNotifAsSeen ,Soc_FavSocialNoteGbl ,NULL}, - /* ActUnfSocNotGbl */{1513,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Soc_MarkMyNotifAsSeen ,Soc_UnfavSocialNoteGbl ,NULL}, - /* ActFavSocComGbl */{1516,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Soc_MarkMyNotifAsSeen ,Soc_FavSocialCommentGbl ,NULL}, - /* ActUnfSocComGbl */{1517,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Soc_MarkMyNotifAsSeen ,Soc_UnfavSocialCommentGbl ,NULL}, - /* ActReqRemSocPubGbl*/{1494,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Soc_MarkMyNotifAsSeen ,Soc_RequestRemSocialNoteGbl ,NULL}, - /* ActRemSocPubGbl */{1493,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Soc_MarkMyNotifAsSeen ,Soc_RemoveSocialNoteGbl ,NULL}, - /* ActReqRemSocComGbl*/{1505,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Soc_MarkMyNotifAsSeen ,Soc_RequestRemSocialComGbl ,NULL}, - /* ActRemSocComGbl */{1507,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Soc_MarkMyNotifAsSeen ,Soc_RemoveSocialComGbl ,NULL}, + /* ActRcvSocPstGbl */{1492,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_DATA,Act_THIS_WINDOW,Soc_ShowTimelineGbl1 ,Soc_ReceiveSocialPostGbl ,NULL}, + /* ActRcvSocComGbl */{1503,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_DATA,Act_THIS_WINDOW,Soc_ShowTimelineGbl1 ,Soc_ReceiveCommentGbl ,NULL}, + /* ActShaSocNotGbl */{1495,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Soc_ShowTimelineGbl1 ,Soc_ShareSocialNoteGbl ,NULL}, + /* ActUnsSocNotGbl */{1496,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Soc_ShowTimelineGbl1 ,Soc_UnshareSocialNoteGbl ,NULL}, + /* ActFavSocNotGbl */{1512,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Soc_ShowTimelineGbl1 ,Soc_FavSocialNoteGbl ,NULL}, + /* ActUnfSocNotGbl */{1513,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Soc_ShowTimelineGbl1 ,Soc_UnfavSocialNoteGbl ,NULL}, + /* ActFavSocComGbl */{1516,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Soc_ShowTimelineGbl1 ,Soc_FavSocialCommentGbl ,NULL}, + /* ActUnfSocComGbl */{1517,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Soc_ShowTimelineGbl1 ,Soc_UnfavSocialCommentGbl ,NULL}, + /* ActReqRemSocPubGbl*/{1494,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Soc_ShowTimelineGbl1 ,Soc_RequestRemSocialNoteGbl ,NULL}, + /* ActRemSocPubGbl */{1493,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Soc_ShowTimelineGbl1 ,Soc_RemoveSocialNoteGbl ,NULL}, + /* ActReqRemSocComGbl*/{1505,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Soc_ShowTimelineGbl1 ,Soc_RequestRemSocialComGbl ,NULL}, + /* ActRemSocComGbl */{1507,-1,TabUnk,ActSeeSocTmlGbl ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Soc_ShowTimelineGbl1 ,Soc_RemoveSocialComGbl ,NULL}, /* ActReqOthPubPrf */{1401,-1,TabUnk,ActSeeSocPrf ,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Prf_RequestUserProfile ,NULL}, diff --git a/swad_changelog.h b/swad_changelog.h index 7b810c1e7..d77ad5f74 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -197,17 +197,20 @@ // TODO: Un administrador de institución, ¿debería poder cambiar la contraseña de un usuario de esa institución? No lo tengo claro. +// TODO: Put hidden parameter "WhichUsrs" in all actions related to global timeline + /*****************************************************************************/ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.139.6 (2017-02-24)" +#define Log_PLATFORM_VERSION "SWAD 16.140 (2017-02-24)" #define CSS_FILE "swad16.139.6.css" -#define JS_FILE "swad16.123.js" +#define JS_FILE "swad16.140.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 16.140: Feb 24, 2017 Two global timelines available: users I follow and all users. Not finished. (213039 lines) Version 16.139.6: Feb 24, 2017 Code refactoring in selector of which forums to display. (? lines) Version 16.139.5: Feb 22, 2017 Changed contextual links in my profile. (212832 lines) Version 16.139.4: Feb 17, 2017 Fixed bug in social timeline. (212835 lines) diff --git a/swad_forum.c b/swad_forum.c index e3a255cec..ccb7c3a2c 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -322,6 +322,7 @@ static void For_UpdateNumUsrsNotifiedByEMailAboutPost (long PstCod,unsigned NumU static void For_WriteNumberOfThrs (unsigned NumThrs,unsigned NumThrsWithNewPosts); static void For_WriteNumThrsAndPsts (unsigned NumThrs,unsigned NumThrsWithNewPosts,unsigned NumPosts); static void For_WriteThrSubject (long ThrCod); +static void For_GetParamsForum (void); static long For_GetParamThrCod (void); static void For_PutHiddenParamPstCod (long PstCod); static long For_GetParamPstCod (void); @@ -3726,7 +3727,7 @@ void For_ShowThrPsts (void) /********************* Get parameters related to a forum *********************/ /*****************************************************************************/ -void For_GetParamsForum (void) +static void For_GetParamsForum (void) { /***** Get which forums I want to see *****/ Gbl.Forum.WhichForums = (For_WhichForums_t) diff --git a/swad_forum.h b/swad_forum.h index 006543a75..f65ef6ab4 100644 --- a/swad_forum.h +++ b/swad_forum.h @@ -130,7 +130,6 @@ unsigned For_GetNumPstsInForum (For_ForumType_t ForumType); void For_ListForumThrs (long ThrCods[Pag_ITEMS_PER_PAGE],struct Pagination *PaginationThrs); void For_GetThrData (struct ForumThread *Thr); void For_ShowThrPsts (void); -void For_GetParamsForum (void); void For_PutHiddenParamThrCod (long ThrCod); void For_ShowForumLevel2 (long ThrCod); void For_RecForumPst (void); diff --git a/swad_global.c b/swad_global.c index 7ea37e0c4..77b66dfcd 100644 --- a/swad_global.c +++ b/swad_global.c @@ -403,6 +403,9 @@ void Gbl_InitializeGlobals (void) Gbl.Test.Tags.All = false; Gbl.Test.Tags.List = NULL; + /* Public activity */ + Gbl.Social.WhichUsrs = Soc_DEFAULT_WHICH_USRS; + /* Forums */ Gbl.Forum.ForumType = (For_ForumType_t) 0; Gbl.Forum.WhichForums = For_DEFAULT_WHICH_FORUMS; diff --git a/swad_global.h b/swad_global.h index 4587b802a..8a113ac3a 100644 --- a/swad_global.h +++ b/swad_global.h @@ -68,6 +68,7 @@ #include "swad_record.h" #include "swad_search.h" #include "swad_session.h" +#include "swad_social.h" #include "swad_survey.h" #include "swad_syllabus.h" #include "swad_test.h" @@ -567,6 +568,10 @@ struct Globals char *StrAttCodsSelected; long AttCodToEdit; // Used as parameter in contextual links } AttEvents; + struct + { + Soc_WhichUsrs_t WhichUsrs; + } Social; struct { For_WhichForums_t WhichForums; diff --git a/swad_layout.c b/swad_layout.c index 3fb042828..0755983d3 100644 --- a/swad_layout.c +++ b/swad_layout.c @@ -735,9 +735,11 @@ static void Lay_WriteScriptParamsAJAX (void) put parameters used by AJAX */ fprintf (Gbl.F.Out,"var RefreshParamNxtActNewPub = \"act=%ld\";\n" "var RefreshParamNxtActOldPub = \"act=%ld\";\n" - "var RefreshParamUsr = \"\";\n", // No user specified + "var RefreshParamUsr = \"\";\n" // No user specified + "var RefreshParamWhichUsrs = \"WhichUsrs=%u\";\n", Act_Actions[ActRefNewSocPubGbl].ActCod, - Act_Actions[ActRefOldSocPubGbl].ActCod); + Act_Actions[ActRefOldSocPubGbl].ActCod, + (unsigned) Gbl.Social.WhichUsrs); break; case ActSeeOthPubPrf: case ActRcvSocPstUsr: diff --git a/swad_social.c b/swad_social.c index cd859128a..755e48bb5 100644 --- a/swad_social.c +++ b/swad_social.c @@ -147,6 +147,10 @@ static void Soc_DropTemporaryTablesUsedToQueryTimeline (void); static void Soc_ShowTimeline (const char *Query,const char *Title, long NotCodToHighlight); static void Soc_PutIconsTimeline (void); + +static void Soc_PutFormWhichUsrs (void); +static void Soc_GetParamsWhichUsrs (void); + static void Soc_InsertNewPubsInTimeline (const char *Query); static void Soc_ShowOldPubsInTimeline (const char *Query); @@ -263,7 +267,16 @@ static void Str_AnalyzeTxtAndStoreNotifyEventToMentionedUsrs (long PubCod,const /***** Show social activity (timeline) including all the users I follow ******/ /*****************************************************************************/ -void Soc_ShowTimelineGbl (void) +void Soc_ShowTimelineGbl1 (void) + { + /***** Mark all my notifications about timeline as seen *****/ + Soc_MarkMyNotifAsSeen (); + + /***** Get which users *****/ + Soc_GetParamsWhichUsrs (); + } + +void Soc_ShowTimelineGbl2 (void) { long PubCod; struct SocialNote SocNot; @@ -408,6 +421,9 @@ void Soc_RefreshNewTimelineGbl (void) fprintf (Gbl.F.Out,"%lu|", Cfg_TIME_TO_REFRESH_SOCIAL_TIMELINE); + /***** Get which users *****/ + Soc_GetParamsWhichUsrs (); + /***** Build query to get timeline *****/ Soc_BuildQueryToGetTimeline (Soc_TIMELINE_GBL, Soc_GET_ONLY_NEW_PUBS, @@ -425,11 +441,15 @@ void Soc_RefreshNewTimelineGbl (void) } /*****************************************************************************/ -/************ View new publishings in social timeline via AJAX ***************/ +/************ View old publishings in social timeline via AJAX ***************/ /*****************************************************************************/ void Soc_RefreshOldTimelineGbl (void) { + /***** Get which users *****/ + Soc_GetParamsWhichUsrs (); + + /***** Show old publishings *****/ Soc_GetAndShowOldTimeline (Soc_TIMELINE_GBL); } @@ -467,7 +487,7 @@ static void Soc_GetAndShowOldTimeline (Soc_TimelineUsrOrGbl_t TimelineUsrOrGbl) /*****************************************************************************/ /************ Mark all my notifications about timeline as seen ***************/ /*****************************************************************************/ -// Executed as a priori function +// Must be executed as a priori function void Soc_MarkMyNotifAsSeen (void) { @@ -540,21 +560,29 @@ static void Soc_BuildQueryToGetTimeline (Soc_TimelineUsrOrGbl_t TimelineUsrOrGbl switch (TimelineUsrOrGbl) { case Soc_TIMELINE_USR: // Show the timeline of a user - sprintf (SubQueryPublishers,"PublisherCod='%ld'", + sprintf (SubQueryPublishers,"PublisherCod='%ld' AND ", Gbl.Usrs.Other.UsrDat.UsrCod); break; - case Soc_TIMELINE_GBL: // Show the timeline of the users I follow - sprintf (Query,"CREATE TEMPORARY TABLE publishers " - "(UsrCod INT NOT NULL,UNIQUE INDEX(UsrCod)) ENGINE=MEMORY" - " SELECT '%ld' AS UsrCod" - " UNION" - " SELECT FollowedCod AS UsrCod" - " FROM usr_follow WHERE FollowerCod='%ld'", - Gbl.Usrs.Me.UsrDat.UsrCod, - Gbl.Usrs.Me.UsrDat.UsrCod); - if (mysql_query (&Gbl.mysql,Query)) - DB_ExitOnMySQLError ("can not create temporary table"); - sprintf (SubQueryPublishers,"social_pubs.PublisherCod=publishers.UsrCod"); + case Soc_TIMELINE_GBL: // Show the global timeline + switch (Gbl.Social.WhichUsrs) + { + case Soc_FOLLOWED: // Show the timeline of the users I follow + sprintf (Query,"CREATE TEMPORARY TABLE publishers " + "(UsrCod INT NOT NULL,UNIQUE INDEX(UsrCod)) ENGINE=MEMORY" + " SELECT '%ld' AS UsrCod" + " UNION" + " SELECT FollowedCod AS UsrCod" + " FROM usr_follow WHERE FollowerCod='%ld'", + Gbl.Usrs.Me.UsrDat.UsrCod, + Gbl.Usrs.Me.UsrDat.UsrCod); + if (mysql_query (&Gbl.mysql,Query)) + DB_ExitOnMySQLError ("can not create temporary table"); + sprintf (SubQueryPublishers,"social_pubs.PublisherCod=publishers.UsrCod AND "); + break; + case Soc_ALL_USRS: // Show the timeline of all users + SubQueryPublishers[0] = '\0'; + break; + } break; } @@ -567,13 +595,13 @@ static void Soc_BuildQueryToGetTimeline (Soc_TimelineUsrOrGbl_t TimelineUsrOrGbl case Soc_GET_ONLY_NEW_PUBS: case Soc_GET_RECENT_TIMELINE: Str_Copy (SubQueryAlreadyExists, - " AND NotCod NOT IN" + " NotCod NOT IN" " (SELECT NotCod FROM not_codes)", Soc_MAX_LENGTH_SUBQUERY_ALREADY_EXISTS); break; case Soc_GET_ONLY_OLD_PUBS: Str_Copy (SubQueryAlreadyExists, - " AND NotCod NOT IN" + " NotCod NOT IN" " (SELECT NotCod FROM current_timeline)", Soc_MAX_LENGTH_SUBQUERY_ALREADY_EXISTS); break; @@ -585,13 +613,13 @@ static void Soc_BuildQueryToGetTimeline (Soc_TimelineUsrOrGbl_t TimelineUsrOrGbl case Soc_GET_ONLY_NEW_PUBS: case Soc_GET_RECENT_TIMELINE: Str_Copy (SubQueryAlreadyExists, - " AND social_pubs.NotCod NOT IN" + " social_pubs.NotCod NOT IN" " (SELECT NotCod FROM not_codes)", Soc_MAX_LENGTH_SUBQUERY_ALREADY_EXISTS); break; case Soc_GET_ONLY_OLD_PUBS: Str_Copy (SubQueryAlreadyExists, - " AND social_pubs.NotCod NOT IN" + " social_pubs.NotCod NOT IN" " (SELECT NotCod FROM current_timeline)", Soc_MAX_LENGTH_SUBQUERY_ALREADY_EXISTS); break; @@ -658,17 +686,44 @@ static void Soc_BuildQueryToGetTimeline (Soc_TimelineUsrOrGbl_t TimelineUsrOrGbl { /* Create subqueries with range of publishings to get from social_pubs */ if (RangePubsToGet.Bottom > 0) - sprintf (SubQueryRangeBottom, - TimelineUsrOrGbl == Soc_TIMELINE_USR ? "PubCod>'%ld' AND " : - "social_pubs.PubCod>'%ld' AND ", - RangePubsToGet.Bottom); + switch (TimelineUsrOrGbl) + { + case Soc_TIMELINE_USR: // Show the timeline of a user + sprintf (SubQueryRangeBottom,"PubCod>'%ld' AND ",RangePubsToGet.Bottom); + break; + case Soc_TIMELINE_GBL: // Show the global timeline + switch (Gbl.Social.WhichUsrs) + { + case Soc_FOLLOWED: // Show the timeline of the users I follow + sprintf (SubQueryRangeBottom,"social_pubs.PubCod>'%ld' AND ",RangePubsToGet.Bottom); + break; + case Soc_ALL_USRS: // Show the timeline of all users + sprintf (SubQueryRangeBottom,"PubCod>'%ld' AND ",RangePubsToGet.Bottom); + break; + } + break; + } else SubQueryRangeBottom[0] = '\0'; + if (RangePubsToGet.Top > 0) - sprintf (SubQueryRangeTop, - TimelineUsrOrGbl == Soc_TIMELINE_USR ? "PubCod<'%ld' AND " : - "social_pubs.PubCod<'%ld' AND ", - RangePubsToGet.Top); + switch (TimelineUsrOrGbl) + { + case Soc_TIMELINE_USR: // Show the timeline of a user + sprintf (SubQueryRangeTop,"PubCod<'%ld' AND ",RangePubsToGet.Top); + break; + case Soc_TIMELINE_GBL: // Show the global timeline + switch (Gbl.Social.WhichUsrs) + { + case Soc_FOLLOWED: // Show the timeline of the users I follow + sprintf (SubQueryRangeTop,"social_pubs.PubCod<'%ld' AND ",RangePubsToGet.Top); + break; + case Soc_ALL_USRS: // Show the timeline of all users + sprintf (SubQueryRangeTop,"PubCod<'%ld' AND ",RangePubsToGet.Top); + break; + } + break; + } else SubQueryRangeTop[0] = '\0'; @@ -683,13 +738,25 @@ static void Soc_BuildQueryToGetTimeline (Soc_TimelineUsrOrGbl_t TimelineUsrOrGbl SubQueryPublishers, SubQueryAlreadyExists); break; - case Soc_TIMELINE_GBL: // Show the timeline of the users I follow - sprintf (Query,"SELECT PubCod,NotCod FROM social_pubs,publishers" - " WHERE %s%s%s%s" - " ORDER BY social_pubs.PubCod DESC LIMIT 1", - SubQueryRangeBottom,SubQueryRangeTop, - SubQueryPublishers, - SubQueryAlreadyExists); + case Soc_TIMELINE_GBL: // Show the global timeline + switch (Gbl.Social.WhichUsrs) + { + case Soc_FOLLOWED: // Show the timeline of the users I follow + sprintf (Query,"SELECT PubCod,NotCod FROM social_pubs,publishers" + " WHERE %s%s%s%s" + " ORDER BY social_pubs.PubCod DESC LIMIT 1", + SubQueryRangeBottom,SubQueryRangeTop, + SubQueryPublishers, + SubQueryAlreadyExists); + break; + case Soc_ALL_USRS: // Show the timeline of all users + sprintf (Query,"SELECT PubCod,NotCod FROM social_pubs" + " WHERE %s%s%s" + " ORDER BY PubCod DESC LIMIT 1", + SubQueryRangeBottom,SubQueryRangeTop, + SubQueryAlreadyExists); + break; + } break; } if (DB_QuerySELECT (Query,&mysql_res,"can not get publishing") == 1) @@ -853,6 +920,7 @@ static void Soc_ShowTimeline (const char *Query,const char *Title, unsigned long NumPub; struct SocialPublishing SocPub; struct SocialNote SocNot; + bool GlobalTimeline = (Gbl.Usrs.Other.UsrDat.UsrCod <= 0); /***** Get publishings from database *****/ NumPubsGot = DB_QuerySELECT (Query,&mysql_res,"can not get timeline"); @@ -861,13 +929,17 @@ static void Soc_ShowTimeline (const char *Query,const char *Title, Lay_StartRoundFrame (Soc_WIDTH_TIMELINE,Title, Soc_PutIconsTimeline,Hlp_SOCIAL_Activity); + /***** Put form to select users whom public activity is displayed *****/ + if (GlobalTimeline) + Soc_PutFormWhichUsrs (); + /***** Form to write a new post *****/ - if (Gbl.Usrs.Other.UsrDat.UsrCod <= 0 || // Global timeline + if (GlobalTimeline || Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // It's me Soc_PutFormToWriteNewPost (); /***** New publishings refreshed dynamically via AJAX *****/ - if (Gbl.Usrs.Other.UsrDat.UsrCod <= 0) // Global timeline + if (GlobalTimeline) { /* Link to view new publishings via AJAX */ Soc_PutLinkToViewNewPublishings (); @@ -932,6 +1004,58 @@ static void Soc_PutIconsTimeline (void) Sta_PutIconToShowFigure (); } +/*****************************************************************************/ +/******** Put form to select users whom public activity is displayed *********/ +/*****************************************************************************/ + +static void Soc_PutFormWhichUsrs (void) + { + extern const char *Txt_TIMELINE_WHICH_USERS[Soc_NUM_WHICH_USRS]; + Soc_WhichUsrs_t WhichUsrs; + + /***** Form to select which users I want to see in timeline: + - only the users I follow + - all users *****/ + Act_FormStart (ActSeeSocTmlGbl); + fprintf (Gbl.F.Out,"
" + "" + "
"); + Act_FormEnd (); + } + +/*****************************************************************************/ +/********* Get parameter with which users to view in global timeline *********/ +/*****************************************************************************/ + +static void Soc_GetParamsWhichUsrs (void) + { + /***** Get which users I want to see *****/ + Gbl.Social.WhichUsrs = (Soc_WhichUsrs_t) + Par_GetParToUnsignedLong ("WhichUsrs", + 0, + Soc_NUM_WHICH_USRS - 1, + (unsigned long) Soc_DEFAULT_WHICH_USRS); + } + /*****************************************************************************/ /********** Show new social activity (new publishings in timeline) ***********/ /*****************************************************************************/ @@ -3498,7 +3622,7 @@ void Soc_RequestRemSocialNoteGbl (void) Soc_RequestRemovalSocialNote (); /***** Write timeline again (global) *****/ - Soc_ShowTimelineGbl (); + Soc_ShowTimelineGbl2 (); } void Soc_RequestRemSocialNoteUsr (void) @@ -3578,7 +3702,7 @@ void Soc_RemoveSocialNoteGbl (void) Soc_RemoveSocialNote (); /***** Write updated timeline after removing (global) *****/ - Soc_ShowTimelineGbl (); + Soc_ShowTimelineGbl2 (); } void Soc_RemoveSocialNoteUsr (void) @@ -3825,7 +3949,7 @@ void Soc_RequestRemSocialComGbl (void) Soc_RequestRemovalSocialComment (); /***** Write timeline again (global) *****/ - Soc_ShowTimelineGbl (); + Soc_ShowTimelineGbl2 (); } void Soc_RequestRemSocialComUsr (void) @@ -3910,7 +4034,7 @@ void Soc_RemoveSocialComGbl (void) Soc_RemoveSocialComment (); /***** Write updated timeline after removing (global) *****/ - Soc_ShowTimelineGbl (); + Soc_ShowTimelineGbl2 (); } void Soc_RemoveSocialComUsr (void) diff --git a/swad_social.h b/swad_social.h index 791d55a1f..df1e6afba 100644 --- a/swad_social.h +++ b/swad_social.h @@ -35,6 +35,14 @@ /******************************** Public types *******************************/ /*****************************************************************************/ +#define Soc_NUM_WHICH_USRS 2 +typedef enum + { + Soc_FOLLOWED = 0, + Soc_ALL_USRS = 1, + } Soc_WhichUsrs_t; // Which users I want to see: only users I follow or all users +#define Soc_DEFAULT_WHICH_USRS Soc_FOLLOWED + #define Soc_NUM_PUB_TYPES 4 // If the numbers assigned to each event type change, // it is necessary to change old numbers to new ones in database table social_notes @@ -113,7 +121,8 @@ struct SocialPublishing /****************************** Public prototypes ****************************/ /*****************************************************************************/ -void Soc_ShowTimelineGbl (void); +void Soc_ShowTimelineGbl1 (void); +void Soc_ShowTimelineGbl2 (void); void Soc_ShowTimelineUsr (void); void Soc_RefreshNewTimelineGbl (void); diff --git a/swad_text.c b/swad_text.c index b88fd25d3..fcda39763 100644 --- a/swad_text.c +++ b/swad_text.c @@ -13152,6 +13152,7 @@ const char *Txt_FORUM_THREAD_ORDER[2] = const char *Txt_FORUM_WHICH_FORUM[For_NUM_WHICH_FORUMS] = { + // For_ONLY_CURRENT_FORUMS #if L==1 "Fòrums d'aquest lloc" #elif L==2 @@ -13172,6 +13173,7 @@ const char *Txt_FORUM_WHICH_FORUM[For_NUM_WHICH_FORUMS] = "Fóruns deste site" #endif , + // For_ALL_MY_FORUMS #if L==1 "Tots els meus fòrums" #elif L==2 @@ -13187,7 +13189,7 @@ const char *Txt_FORUM_WHICH_FORUM[For_NUM_WHICH_FORUMS] = #elif L==7 "Tutti i miei forum" #elif L==8 - "wszystkie moje forum" + "Wszystkie moje forum" #elif L==9 "Todos os meus fóruns" #endif @@ -47777,6 +47779,51 @@ const char *Txt_Time_zone_used_in_the_calculation_of_these_statistics = "Fuso horário utilizado no cálculo dessas estatísticas"; #endif +const char *Txt_TIMELINE_WHICH_USERS[Soc_NUM_WHICH_USRS] = + { + // Soc_FOLLOWED +#if L==1 + "Seguits" +#elif L==2 + "Gefolgt" +#elif L==3 + "Followed" +#elif L==4 + "Seguidos" +#elif L==5 + "Suivis" +#elif L==6 + "Seguidos" // Okoteve traducción +#elif L==7 + "Seguiti" +#elif L==8 + "Obserwowani" +#elif L==9 + "Seguidos" +#endif + , + // Soc_ALL_USRS +#if L==1 + "Tots" +#elif L==2 + "Alle" +#elif L==3 + "All" +#elif L==4 + "Todos" +#elif L==5 + "Tous" +#elif L==6 + "Todos" // Okoteve traducción +#elif L==7 + "Tutti" +#elif L==8 + "Wszystkie" +#elif L==9 + "Todos" +#endif + }; + const char *Txt_TIMETABLE_TYPES[TT_NUM_TIMETABLE_TYPES] = { // TT_COURSE_TIMETABLE