diff --git a/css/swad15.77.6.css b/css/swad15.79.css similarity index 99% rename from css/swad15.77.6.css rename to css/swad15.79.css index 34478cea..02c1b885 100644 --- a/css/swad15.77.6.css +++ b/css/swad15.79.css @@ -1671,23 +1671,24 @@ a:hover img.CENTRE_PHOTO_SHOW .SOCIAL_LEFT_PHOTO { display:inline-block; - text-align:left; - vertical-align:top; + box-sizing:border-box; width:60px; height:90px; + text-align:left; + vertical-align:top; } .SOCIAL_RIGHT_CONTAINER { display:inline-block; box-sizing:border-box; padding:0 0 10px 10px; - width:450px; + width:470px; } .SOCIAL_RIGHT_AUTHOR { display:inline-block; box-sizing:border-box; - width:270px; + width:280px; text-align:left; vertical-align:top; } @@ -1695,7 +1696,7 @@ a:hover img.CENTRE_PHOTO_SHOW { display:inline-block; box-sizing:border-box; - width:170px; + width:180px; text-align:right; vertical-align:top; } diff --git a/swad_action.c b/swad_action.c index 9febd83f..ffb6a413 100644 --- a/swad_action.c +++ b/swad_action.c @@ -2302,7 +2302,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActLstClk */{ 989,-1,TabUsr,ActLstCon ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Con_ShowLastClicks ,NULL}, // TabSoc ****************************************************************** - /* ActSeeSocAct */{1490, 0,TabSoc,ActSeeSocAct ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Soc_ShowSocialActivity ,"soc64x64.png" }, + /* ActSeeSocAct */{1490, 0,TabSoc,ActSeeSocAct ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Soc_ShowFollowingTimeline ,"soc64x64.png" }, /* ActReqPubPrf */{1401, 1,TabSoc,ActReqPubPrf ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Prf_RequestUserProfile ,"prf64x64.gif" }, /* ActSeeChtRms */{ 51, 2,TabSoc,ActSeeChtRms ,0x1FC,0x1FC,0x1FC,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Cht_ShowChatRooms ,"chat64x64.gif" }, diff --git a/swad_changelog.h b/swad_changelog.h index 1af169f7..6bb063c5 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -115,13 +115,15 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.78.1 (2015-12-29)" -#define CSS_FILE "swad15.77.6.css" +#define Log_PLATFORM_VERSION "SWAD 15.79 (2015-12-29)" +#define CSS_FILE "swad15.79.css" #define JS_FILE "swad15.77.7.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.79: Dec 29, 2015 Show timeline of a selected user. + Changes in CSS related to social activity. (188834 lines) Version 15.78.1: Dec 29, 2015 Go directly to notice in notifications and social events. (188785 lines) Version 15.78: Dec 29, 2015 Links in social events. Actions related to shared files renamed. (188776 lines) diff --git a/swad_follow.c b/swad_follow.c index 3e21bf76..d6d822b3 100644 --- a/swad_follow.c +++ b/swad_follow.c @@ -68,8 +68,6 @@ static void Fol_ShowNumberOfFollowingOrFollowers (const struct UsrData *UsrDat, unsigned NumUsrs, Act_Action_t Action, const char *Title); -static unsigned Fol_GetNumFollowing (long UsrCod); -static unsigned Fol_GetNumFollowers (long UsrCod); static void Fol_ShowFollowedOrFollower (const struct UsrData *UsrDat); /*****************************************************************************/ @@ -90,11 +88,40 @@ bool Fol_CheckUsrIsFollowerOf (long FollowerCod,long FollowedCod) return (DB_QueryCOUNT (Query,"can not get if a user is a follower of another one") != 0); } +/*****************************************************************************/ +/*************************** Get number of followed **************************/ +/*****************************************************************************/ + +unsigned Fol_GetNumFollowing (long UsrCod) + { + char Query[128]; + + /***** Check if a user is a follower of another user *****/ + sprintf (Query,"SELECT COUNT(*) FROM usr_follow WHERE FollowerCod='%ld'", + UsrCod); + return DB_QueryCOUNT (Query,"can not get number of followed"); + } + +/*****************************************************************************/ +/************************** Get number of followers **************************/ +/*****************************************************************************/ + +unsigned Fol_GetNumFollowers (long UsrCod) + { + char Query[128]; + + /***** Check if a user is a follower of another user *****/ + sprintf (Query,"SELECT COUNT(*) FROM usr_follow WHERE FollowedCod='%ld'", + UsrCod); + return DB_QueryCOUNT (Query,"can not get number of followers"); + } + /*****************************************************************************/ /**************** Show following and followers of a user *********************/ /*****************************************************************************/ -void Fol_ShowFollowingAndFollowers (const struct UsrData *UsrDat) +void Fol_ShowFollowingAndFollowers (const struct UsrData *UsrDat, + unsigned NumFollowing,unsigned NumFollowers) { extern const char *Txt_Following; extern const char *Txt_Followers; @@ -105,14 +132,14 @@ void Fol_ShowFollowingAndFollowers (const struct UsrData *UsrDat) /***** Followed users *****/ fprintf (Gbl.F.Out,"
"); Fol_ShowNumberOfFollowingOrFollowers (UsrDat, - Fol_GetNumFollowing (UsrDat->UsrCod), + NumFollowing, ActSeeFlg,Txt_Following); fprintf (Gbl.F.Out,"
"); /***** Followers *****/ fprintf (Gbl.F.Out,"
"); Fol_ShowNumberOfFollowingOrFollowers (UsrDat, - Fol_GetNumFollowers (UsrDat->UsrCod), + NumFollowers, ActSeeFlr,Txt_Followers); fprintf (Gbl.F.Out,"
"); @@ -183,34 +210,6 @@ static void Fol_ShowNumberOfFollowingOrFollowers (const struct UsrData *UsrDat, fprintf (Gbl.F.Out,""); } -/*****************************************************************************/ -/*************************** Get number of followed **************************/ -/*****************************************************************************/ - -static unsigned Fol_GetNumFollowing (long UsrCod) - { - char Query[128]; - - /***** Check if a user is a follower of another user *****/ - sprintf (Query,"SELECT COUNT(*) FROM usr_follow WHERE FollowerCod='%ld'", - UsrCod); - return DB_QueryCOUNT (Query,"can not get number of followed"); - } - -/*****************************************************************************/ -/************************** Get number of followers **************************/ -/*****************************************************************************/ - -static unsigned Fol_GetNumFollowers (long UsrCod) - { - char Query[128]; - - /***** Check if a user is a follower of another user *****/ - sprintf (Query,"SELECT COUNT(*) FROM usr_follow WHERE FollowedCod='%ld'", - UsrCod); - return DB_QueryCOUNT (Query,"can not get number of followers"); - } - /*****************************************************************************/ /***************************** List followed users ***************************/ /*****************************************************************************/ diff --git a/swad_follow.h b/swad_follow.h index 04e3621a..60787d2c 100644 --- a/swad_follow.h +++ b/swad_follow.h @@ -44,7 +44,10 @@ /*****************************************************************************/ bool Fol_CheckUsrIsFollowerOf (long FollowerCod,long FollowedCod); -void Fol_ShowFollowingAndFollowers (const struct UsrData *UsrDat); +unsigned Fol_GetNumFollowing (long UsrCod); +unsigned Fol_GetNumFollowers (long UsrCod); +void Fol_ShowFollowingAndFollowers (const struct UsrData *UsrDat, + unsigned NumFollowing,unsigned NumFollowers); void Fol_ListFollowing (void); void Fol_ListFollowers (void); diff --git a/swad_global.h b/swad_global.h index c68808cc..94d68871 100644 --- a/swad_global.h +++ b/swad_global.h @@ -334,6 +334,8 @@ struct Globals struct Degree *Lst; } MyAdminDegs; // List of degrees administrated by me Usr_ShowUsrsType_t ListType; // My preference about user's list type + unsigned NumFollowers; // Number of users who follow me + unsigned NumFollowing; // Number of users I follow } Me; // The user logged struct { diff --git a/swad_profile.c b/swad_profile.c index 50b9e16d..4ac56c66 100644 --- a/swad_profile.c +++ b/swad_profile.c @@ -36,6 +36,7 @@ #include "swad_privacy.h" #include "swad_profile.h" #include "swad_role.h" +#include "swad_social.h" #include "swad_text.h" #include "swad_theme.h" #include "swad_user.h" @@ -214,6 +215,9 @@ static void Prf_GetUsrDatAndShowUserProfile (void) bool Prf_ShowUserProfile (void) { + unsigned NumFollowing; + unsigned NumFollowers; + /***** Check if I can see the public profile *****/ if (Pri_ShowIsAllowed (Gbl.Usrs.Other.UsrDat.ProfileVisibility, Gbl.Usrs.Other.UsrDat.UsrCod)) @@ -236,7 +240,13 @@ bool Prf_ShowUserProfile (void) Prf_ShowDetailsUserProfile (&Gbl.Usrs.Other.UsrDat); /***** Show following and followers *****/ - Fol_ShowFollowingAndFollowers (&Gbl.Usrs.Other.UsrDat); + NumFollowing = Fol_GetNumFollowing (Gbl.Usrs.Other.UsrDat.UsrCod); + NumFollowers = Fol_GetNumFollowers (Gbl.Usrs.Other.UsrDat.UsrCod); + Fol_ShowFollowingAndFollowers (&Gbl.Usrs.Other.UsrDat, + NumFollowing,NumFollowers); + + /***** Show social activity (timeline) of a selected user *****/ + Soc_ShowUsrTimeline (Gbl.Usrs.Other.UsrDat.UsrCod); return true; } diff --git a/swad_social.c b/swad_social.c index 256222e3..b34039fb 100644 --- a/swad_social.c +++ b/swad_social.c @@ -32,6 +32,7 @@ #include "swad_constant.h" #include "swad_database.h" #include "swad_exam.h" +#include "swad_follow.h" #include "swad_global.h" #include "swad_layout.h" #include "swad_notice.h" @@ -103,6 +104,7 @@ extern struct Globals Gbl; /***************************** Private prototypes ****************************/ /*****************************************************************************/ +static unsigned long Soc_ShowTimeline (const char *Query); static Soc_SocialEvent_t Soc_GetSocialEventFromDB (const char *Str); static void Soc_WriteEventDate (time_t TimeUTC); static void Soc_StartFormGoToAction (Soc_SocialEvent_t SocialEvent, @@ -110,11 +112,60 @@ static void Soc_StartFormGoToAction (Soc_SocialEvent_t SocialEvent, static void Soc_GetEventSummary (Soc_SocialEvent_t SocialEvent,long Cod, char *SummaryStr,unsigned MaxChars); +/*****************************************************************************/ +/*********** Show social activity (timeline) of a selected user **************/ +/*****************************************************************************/ + +void Soc_ShowUsrTimeline (long UsrCod) + { + char Query[512]; + + /***** Build query to show timeline including the users I am following *****/ + sprintf (Query,"SELECT SocialEvent,UsrCod," + "CtyCod,InsCod,CtrCod,DegCod,CrsCod," + "Cod,UNIX_TIMESTAMP(TimeEvent)" + " FROM social" + " WHERE UsrCod='%ld'" + " ORDER BY SocCod DESC LIMIT 10", + UsrCod); + + /***** Show timeline *****/ + Soc_ShowTimeline (Query); + } + +/*****************************************************************************/ +/***** Show social activity (timeline) including all the users I follow ******/ +/*****************************************************************************/ + +void Soc_ShowFollowingTimeline (void) + { + char Query[512]; + + if (Fol_GetNumFollowing (Gbl.Usrs.Me.UsrDat.UsrCod)) // I follow people + { + /***** Build query to show timeline including the users I am following *****/ + sprintf (Query,"SELECT SocialEvent,UsrCod," + "CtyCod,InsCod,CtrCod,DegCod,CrsCod," + "Cod,UNIX_TIMESTAMP(TimeEvent)" + " FROM social,usr_follow" + " WHERE usr_follow.FollowerCod='%ld'" + " AND usr_follow.FollowedCod=social.UsrCod" + " ORDER BY SocCod DESC LIMIT 10", + Gbl.Usrs.Me.UsrDat.UsrCod); + + /***** Show timeline *****/ + if (!Soc_ShowTimeline (Query)) + Lay_ShowAlert (Lay_INFO,"No hay actividad pública de los usuarios a los que sigue."); // Need translation!!! + } + else // I do not follow people + Lay_ShowAlert (Lay_INFO,"Usted no sigue a ningún usuario."); // Need translation!!! + } + /*****************************************************************************/ /*********************** Show social activity (timeline) *********************/ /*****************************************************************************/ -void Soc_ShowSocialActivity (void) +static unsigned long Soc_ShowTimeline (const char *Query) { extern const char *Txt_Public_activity; extern const char *Txt_SOCIAL_EVENT[Soc_NUM_SOCIAL_EVENTS]; @@ -124,7 +175,6 @@ void Soc_ShowSocialActivity (void) extern const char *Txt_Centre; extern const char *Txt_Institution; extern const char *Txt_Country; - char Query[512]; MYSQL_RES *mysql_res; MYSQL_ROW row; unsigned long NumEvents; @@ -143,15 +193,7 @@ void Soc_ShowSocialActivity (void) char PhotoURL[PATH_MAX+1]; char *SummaryStr; - /***** Get my timeline from database *****/ - sprintf (Query,"SELECT SocialEvent,UsrCod," - "CtyCod,InsCod,CtrCod,DegCod,CrsCod," - "Cod,UNIX_TIMESTAMP(TimeEvent)" - " FROM social,usr_follow" - " WHERE usr_follow.FollowerCod='%ld'" - " AND usr_follow.FollowedCod=social.UsrCod" - " ORDER BY SocCod DESC LIMIT 10", - Gbl.Usrs.Me.UsrDat.UsrCod); + /***** Get timeline from database *****/ NumEvents = DB_QuerySELECT (Query,&mysql_res,"can not get your notifications"); /***** List my timeline *****/ @@ -165,7 +207,7 @@ void Soc_ShowSocialActivity (void) Usr_UsrDataConstructor (&UsrDat); /***** List start *****/ - Lay_StartRoundFrame (NULL,Txt_Public_activity); + Lay_StartRoundFrame ("560px",Txt_Public_activity); fprintf (Gbl.F.Out,"