diff --git a/swad_action.c b/swad_action.c index f7859d3d..7dab7091 100644 --- a/swad_action.c +++ b/swad_action.c @@ -2629,8 +2629,8 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActCalNumForPst */{1408,-1,TabUnk,ActSeeSocPrf ,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Prf_CalculateFigures ,NULL}, /* ActCalNumMsgSnt */{1407,-1,TabUnk,ActSeeSocPrf ,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Prf_CalculateFigures ,NULL}, - /* ActFolUsr */{1410,-1,TabUnk,ActSeeSocPrf ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Fol_FollowUsr ,NULL}, - /* ActUnfUsr */{1411,-1,TabUnk,ActSeeSocPrf ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Fol_UnfollowUsr ,NULL}, + /* ActFolUsr */{1410,-1,TabUnk,ActSeeSocPrf ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Fol_FollowUsr1 ,Fol_FollowUsr2 ,NULL}, + /* ActUnfUsr */{1411,-1,TabUnk,ActSeeSocPrf ,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Fol_UnfollowUsr1 ,Fol_UnfollowUsr2 ,NULL}, /* ActSeeFlg */{1412,-1,TabUnk,ActSeeSocPrf ,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Fol_ListFollowing ,NULL}, /* ActSeeFlr */{1413,-1,TabUnk,ActSeeSocPrf ,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,0x1FF,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Fol_ListFollowers ,NULL}, diff --git a/swad_changelog.h b/swad_changelog.h index 84cf1276..358429fb 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -195,19 +195,18 @@ // TODO: Bajo la foto de cada usuario el país // TODO: Permitir elegir entre "Ver actividad de quienes sigo" o "Ver actividad de todos" -// TODO: On right column show only users to follow who have photo (pass a parameter to function) - /*****************************************************************************/ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.137 (2017-02-17)" +#define Log_PLATFORM_VERSION "SWAD 16.138 (2017-02-17)" #define CSS_FILE "swad16.136.css" #define JS_FILE "swad16.123.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.138: Feb 17, 2017 On right column show only users to follow with visible photo. (212873 lines) Version 16.137: Feb 17, 2017 Link to view my public profile. (212808 lines) 1 change necessary in database: INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1637','es','N','Ver mi perfil público'); diff --git a/swad_follow.c b/swad_follow.c index 104ab603..b16c28f3 100644 --- a/swad_follow.c +++ b/swad_follow.c @@ -66,6 +66,7 @@ extern struct Globals Gbl; /*****************************************************************************/ static unsigned Fol_GetUsrsWhoToFollow (unsigned MaxUsrsToShow, + bool OnlyUsrsWithPhotos, MYSQL_RES **mysql_res); static void Fol_PutIconsWhoToFollow (void); @@ -124,6 +125,7 @@ void Fol_SuggestUsrsToFollowMainZone (void) /***** Get users *****/ if ((NumUsrs = Fol_GetUsrsWhoToFollow (Fol_MAX_USRS_TO_FOLLOW_MAIN_ZONE, + false, &mysql_res))) { /***** Start frame *****/ @@ -186,6 +188,7 @@ void Fol_SuggestUsrsToFollowMainZoneOnRightColumn (void) /***** Get users *****/ if ((NumUsrs = Fol_GetUsrsWhoToFollow (Fol_MAX_USRS_TO_FOLLOW_RIGHT_COLUMN, + true, &mysql_res))) { /***** Start container *****/ @@ -238,10 +241,51 @@ void Fol_SuggestUsrsToFollowMainZoneOnRightColumn (void) /*****************************************************************************/ static unsigned Fol_GetUsrsWhoToFollow (unsigned MaxUsrsToShow, + bool OnlyUsrsWithPhotos, MYSQL_RES **mysql_res) { extern const char *Pri_VisibilityDB[Pri_NUM_OPTIONS_PRIVACY]; - char Query[2048]; + char Query[4096]; + char SubQuery1[256]; + char SubQuery2[256]; + char SubQuery3[256]; + char SubQuery4[256]; + + /***** Build subqueries related to photos *****/ + if (OnlyUsrsWithPhotos) + { + // Photo visibility should be >= profile visibility in every subquery + sprintf (SubQuery1, + " AND usr_data.PhotoVisibility IN ('%s','%s')" + " AND usr_data.Photo<>''", + Pri_VisibilityDB[Pri_VISIBILITY_SYSTEM], + Pri_VisibilityDB[Pri_VISIBILITY_WORLD ]); + sprintf (SubQuery2, + " AND usr_data.PhotoVisibility IN ('%s','%s','%s')" + " AND usr_data.Photo<>''", + Pri_VisibilityDB[Pri_VISIBILITY_COURSE], + Pri_VisibilityDB[Pri_VISIBILITY_SYSTEM], + Pri_VisibilityDB[Pri_VISIBILITY_WORLD ]); + sprintf (SubQuery3, + " AND usr_data.PhotoVisibility IN ('%s','%s','%s','%s')" + " AND usr_data.Photo<>''", + Pri_VisibilityDB[Pri_VISIBILITY_USER ], + Pri_VisibilityDB[Pri_VISIBILITY_COURSE], + Pri_VisibilityDB[Pri_VISIBILITY_SYSTEM], + Pri_VisibilityDB[Pri_VISIBILITY_WORLD ]); + sprintf (SubQuery4, + " AND usr_data.PhotoVisibility IN ('%s','%s')" + " AND usr_data.Photo<>''", + Pri_VisibilityDB[Pri_VISIBILITY_SYSTEM], + Pri_VisibilityDB[Pri_VISIBILITY_WORLD ]); + } + else + { + SubQuery1[0] = '\0'; + SubQuery2[0] = '\0'; + SubQuery3[0] = '\0'; + SubQuery4[0] = '\0'; + } /***** Build query to get users to follow *****/ // Get only users with surname 1 and first name @@ -264,6 +308,7 @@ static unsigned Fol_GetUsrsWhoToFollow (unsigned MaxUsrsToShow, " AND usr_data.ProfileVisibility IN ('%s','%s')" " AND usr_data.Surname1<>''" // Surname 1 not empty " AND usr_data.FirstName<>''" // First name not empty + "%s" // SubQuery1 ")" " UNION " // Users who share any course with me @@ -281,6 +326,7 @@ static unsigned Fol_GetUsrsWhoToFollow (unsigned MaxUsrsToShow, " AND usr_data.ProfileVisibility IN ('%s','%s','%s')" " AND usr_data.Surname1<>''" // Surname 1 not empty " AND usr_data.FirstName<>''" // First name not empty + "%s" // SubQuery2 ")" " UNION " // Users who share any course with me with another role @@ -297,6 +343,7 @@ static unsigned Fol_GetUsrsWhoToFollow (unsigned MaxUsrsToShow, " AND usr_data.ProfileVisibility='%s'" " AND usr_data.Surname1<>''" // Surname 1 not empty " AND usr_data.FirstName<>''" // First name not empty + "%s" // SubQuery3 ")" ") AS LikelyKnownUsrsToFollow" // Do not select my followed @@ -314,8 +361,9 @@ static unsigned Fol_GetUsrsWhoToFollow (unsigned MaxUsrsToShow, "SELECT UsrCod FROM usr_data" " WHERE UsrCod<>'%ld'" " AND ProfileVisibility IN ('%s','%s')" - " AND Surname1<>''" // Surname 1 not empty - " AND FirstName<>''" // First name not empty + " AND Surname1<>''" // Surname 1 not empty + " AND FirstName<>''" // First name not empty + "%s" // SubQuery4 // Do not select my followed " AND UsrCod NOT IN" " (SELECT FollowedCod FROM usr_follow" @@ -331,19 +379,23 @@ static unsigned Fol_GetUsrsWhoToFollow (unsigned MaxUsrsToShow, Gbl.Usrs.Me.UsrDat.UsrCod, Pri_VisibilityDB[Pri_VISIBILITY_SYSTEM], Pri_VisibilityDB[Pri_VISIBILITY_WORLD ], + SubQuery1, Gbl.Usrs.Me.UsrDat.UsrCod, Gbl.Usrs.Me.UsrDat.UsrCod, Pri_VisibilityDB[Pri_VISIBILITY_COURSE], Pri_VisibilityDB[Pri_VISIBILITY_SYSTEM], Pri_VisibilityDB[Pri_VISIBILITY_WORLD ], + SubQuery2, Gbl.Usrs.Me.UsrDat.UsrCod, Pri_VisibilityDB[Pri_VISIBILITY_USER ], + SubQuery3, Gbl.Usrs.Me.UsrDat.UsrCod, MaxUsrsToShow * 2, // 2/3 likely known users Gbl.Usrs.Me.UsrDat.UsrCod, Pri_VisibilityDB[Pri_VISIBILITY_SYSTEM], Pri_VisibilityDB[Pri_VISIBILITY_WORLD ], + SubQuery4, Gbl.Usrs.Me.UsrDat.UsrCod, MaxUsrsToShow, // 1/3 likely unknown users @@ -921,11 +973,11 @@ static void Fol_PutIconToUnfollow (struct UsrData *UsrDat) extern const char *Txt_Unfollow; /* Form to follow */ - Act_FormStart (ActFolUsr); + Act_FormStart (ActUnfUsr); Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); Act_LinkFormSubmit (Txt_Unfollow,NULL,NULL); fprintf (Gbl.F.Out,"