Version 15.133

This commit is contained in:
Antonio Cañas Vargas 2016-01-27 23:28:53 +01:00
parent fd2be41b04
commit 5106642ec1
3 changed files with 114 additions and 24 deletions

View File

@ -123,13 +123,14 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.132.1 (2016-01-27)"
#define Log_PLATFORM_VERSION "SWAD 15.133 (2016-01-27)"
#define CSS_FILE "swad15.131.2.css"
#define JS_FILE "swad15.131.3.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.133: Jan 27, 2016 List users to follow. (195236 lines)
Version 15.132.1: Jan 27, 2016 Build query to get users to follow. (195158 lines)
Version 15.132: Jan 27, 2016 Put link to suggest users to follow. (195116 lines)
2 changes necessary in database:

View File

@ -46,6 +46,8 @@
#define Fol_NUM_COLUMNS_FOLLOW 3
#define Fol_MAX_USRS_TO_FOLLOW_SUGGESTED (Fol_NUM_COLUMNS_FOLLOW * 3)
/*****************************************************************************/
/****************************** Internal types *******************************/
/*****************************************************************************/
@ -89,12 +91,16 @@ void Fol_PutLinkWhoToFollow (void)
/******************** Put link to suggest users to follow ********************/
/*****************************************************************************/
#define Fol_MAX_USRS_SUGGESTED 1000
void Fol_SuggestWhoToFollow (void)
{
extern const char *Pri_VisibilityDB[Pri_NUM_OPTIONS_PRIVACY];
extern const char *Txt_No_user_to_whom_you_can_follow_Try_again_later;
char Query[2048];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned NumUsrs;
unsigned NumUsr;
struct UsrData UsrDat;
/***** First try: build query to get users to follow *****/
sprintf (Query,"SELECT UsrCod FROM"
@ -147,7 +153,7 @@ void Fol_SuggestWhoToFollow (void)
" (SELECT FollowedCod FROM usr_follow"
" WHERE FollowerCod='%ld')"
// Get only Fol_MAX_USRS_SUGGESTED users
// Get only Fol_MAX_USRS_TO_FOLLOW_SUGGESTED users
" ORDER BY RAND() LIMIT %u",
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Me.UsrDat.UsrCod,
@ -159,31 +165,84 @@ void Fol_SuggestWhoToFollow (void)
Gbl.Usrs.Me.UsrDat.UsrCod,
Pri_VisibilityDB[Pri_VISIBILITY_USER],
Gbl.Usrs.Me.UsrDat.UsrCod,
Fol_MAX_USRS_SUGGESTED);
Fol_MAX_USRS_TO_FOLLOW_SUGGESTED);
Lay_ShowAlert (Lay_INFO,Query);
// Lay_ShowAlert (Lay_INFO,Query);
/***** Second try: build query to get users to follow *****/
sprintf (Query,// Users with privacy
// Pri_VISIBILITY_SYSTEM or Pri_VISIBILITY_WORLD
"SELECT UsrCod FROM usr_data"
" WHERE UsrCod<>'%ld'"
" AND ProfileVisibility IN ('%s','%s')"
/***** Try to get users *****/
NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get followed users");
// Not select my followed
" AND UsrCod NOT IN"
" (SELECT FollowedCod FROM usr_follow"
" WHERE FollowerCod='%ld')"
if (!NumUsrs)
{
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
// Get only Fol_MAX_USRS_SUGGESTED users
" ORDER BY RAND() LIMIT %u",
Gbl.Usrs.Me.UsrDat.UsrCod,
Pri_VisibilityDB[Pri_VISIBILITY_SYSTEM],
Pri_VisibilityDB[Pri_VISIBILITY_WORLD],
Gbl.Usrs.Me.UsrDat.UsrCod,
Fol_MAX_USRS_SUGGESTED);
/***** Second try: build query to get users to follow *****/
sprintf (Query,// Users with privacy
// Pri_VISIBILITY_SYSTEM or Pri_VISIBILITY_WORLD
"SELECT UsrCod FROM usr_data"
" WHERE UsrCod<>'%ld'"
" AND ProfileVisibility IN ('%s','%s')"
Lay_ShowAlert (Lay_INFO,Query);
// Not select my followed
" AND UsrCod NOT IN"
" (SELECT FollowedCod FROM usr_follow"
" WHERE FollowerCod='%ld')"
// Get only Fol_MAX_USRS_TO_FOLLOW_SUGGESTED users
" ORDER BY RAND() LIMIT %u",
Gbl.Usrs.Me.UsrDat.UsrCod,
Pri_VisibilityDB[Pri_VISIBILITY_SYSTEM],
Pri_VisibilityDB[Pri_VISIBILITY_WORLD],
Gbl.Usrs.Me.UsrDat.UsrCod,
Fol_MAX_USRS_TO_FOLLOW_SUGGESTED);
// Lay_ShowAlert (Lay_INFO,Query);
/***** Get users *****/
NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get followed users");
}
if (NumUsrs)
{
/***** Initialize structure with user's data *****/
Usr_UsrDataConstructor (&UsrDat);
/***** Start listing *****/
fprintf (Gbl.F.Out,"<table class=\"CELLS_PAD_2\""
" style=\"margin:12px auto;\">");
for (NumUsr = 0;
NumUsr < NumUsrs;
NumUsr++)
{
/***** Get user *****/
row = mysql_fetch_row (mysql_res);
/* Get user's code (row[0]) */
UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
/***** Show user *****/
if ((NumUsr % Fol_NUM_COLUMNS_FOLLOW) == 0)
fprintf (Gbl.F.Out,"<tr>");
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat))
Fol_ShowFollowedOrFollower (&UsrDat);
if ((NumUsr % Fol_NUM_COLUMNS_FOLLOW) == (Fol_NUM_COLUMNS_FOLLOW-1) ||
NumUsr == NumUsrs - 1)
fprintf (Gbl.F.Out,"</tr>");
}
/***** End listing *****/
fprintf (Gbl.F.Out,"</table>");
/***** Free memory used for user's data *****/
Usr_UsrDataDestructor (&UsrDat);
}
else
Lay_ShowAlert (Lay_INFO,Txt_No_user_to_whom_you_can_follow_Try_again_later);
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/

View File

@ -24223,6 +24223,36 @@ const char *Txt_No_user_has_been_removed =
"No user has been removed."; // Necessita de tradução
#endif
const char *Txt_No_user_to_whom_you_can_follow_Try_again_later =
#if L==1
"No hi ha cap usuari a qui vost&egrave; pugui seguir."
" Intenteu-ho m&eacute;s endavant.";
#elif L==2
"Kein Benutzer dem Sie folgen k&ouml;nnen."
" Versuchen Sie es sp&auml;ter noch einmal.";
#elif L==3
"No user to whom you can follow."
" Try again later.";
#elif L==4
"No hay ning&uacute;n usuario a quien usted pueda seguir."
" Int&eacute;ntelo m&aacute;s adelante.";
#elif L==5
"Aucun utilisateur auquel vous pouvez suivre."
" R&eacute;essayez plus tard.";
#elif L==6
"No hay ning&uacute;n usuario a quien usted pueda seguir."
" Int&eacute;ntelo m&aacute;s adelante."; // Okoteve traducción
#elif L==7
"Nessun utente a cui &egrave; possibile seguire."
" Riprovare pi&ugrave; tardi.";
#elif L==8
"No u&zdot;ytkownika, do kt&oacute;rego mo&zdot;na &sacute;ledzi&cacute;."
" Spr&oacute;buj ponownie p&oacute;&zacute;niej.";
#elif L==9
"Nenhum usu&aacute;rio a quem voc&ecirc; pode seguir."
" Tente novamente mais tarde.";
#endif
const char *Txt_No_users_found[Rol_NUM_ROLES] =
{
#if L==1 // Rol_ROLE_UNKNOWN