mirror of
https://github.com/acanas/swad-core.git
synced 2024-06-05 00:05:23 +02:00
Version 18.7.23
This commit is contained in:
parent
662aca0ef6
commit
594de1477c
|
@ -355,10 +355,11 @@ En OpenSWAD:
|
||||||
ps2pdf source.ps destination.pdf
|
ps2pdf source.ps destination.pdf
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 18.7.22 (2018-10-22)"
|
#define Log_PLATFORM_VERSION "SWAD 18.7.23 (2018-10-22)"
|
||||||
#define CSS_FILE "swad18.4.css"
|
#define CSS_FILE "swad18.4.css"
|
||||||
#define JS_FILE "swad17.17.1.js"
|
#define JS_FILE "swad17.17.1.js"
|
||||||
/*
|
/*
|
||||||
|
Version 18.7.23: Oct 20, 2018 Some sprintf for database queries changed by asprintf. (? lines)
|
||||||
Version 18.7.22: Oct 20, 2018 Some sprintf for database queries changed by asprintf. (237286 lines)
|
Version 18.7.22: Oct 20, 2018 Some sprintf for database queries changed by asprintf. (237286 lines)
|
||||||
Version 18.7.21: Oct 20, 2018 Some sprintf for database queries changed by asprintf. (237157 lines)
|
Version 18.7.21: Oct 20, 2018 Some sprintf for database queries changed by asprintf. (237157 lines)
|
||||||
Version 18.7.20: Oct 20, 2018 Some sprintf for database queries changed by asprintf. (237092 lines)
|
Version 18.7.20: Oct 20, 2018 Some sprintf for database queries changed by asprintf. (237092 lines)
|
||||||
|
|
422
swad_follow.c
422
swad_follow.c
|
@ -25,8 +25,9 @@
|
||||||
/*********************************** Headers *********************************/
|
/*********************************** Headers *********************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#define _GNU_SOURCE // For asprintf
|
||||||
#include <stdbool.h> // For boolean type
|
#include <stdbool.h> // For boolean type
|
||||||
#include <stdio.h> // For sprintf
|
#include <stdio.h> // For asprintf
|
||||||
#include <string.h> // For string functions
|
#include <string.h> // For string functions
|
||||||
|
|
||||||
#include "swad_box.h"
|
#include "swad_box.h"
|
||||||
|
@ -247,7 +248,7 @@ static unsigned Fol_GetUsrsWhoToFollow (unsigned MaxUsrsToShow,
|
||||||
MYSQL_RES **mysql_res)
|
MYSQL_RES **mysql_res)
|
||||||
{
|
{
|
||||||
extern const char *Pri_VisibilityDB[Pri_NUM_OPTIONS_PRIVACY];
|
extern const char *Pri_VisibilityDB[Pri_NUM_OPTIONS_PRIVACY];
|
||||||
char Query[4096];
|
char *Query;
|
||||||
char SubQuery1[256];
|
char SubQuery1[256];
|
||||||
char SubQuery2[256];
|
char SubQuery2[256];
|
||||||
char SubQuery3[256];
|
char SubQuery3[256];
|
||||||
|
@ -291,119 +292,120 @@ static unsigned Fol_GetUsrsWhoToFollow (unsigned MaxUsrsToShow,
|
||||||
|
|
||||||
/***** Build query to get users to follow *****/
|
/***** Build query to get users to follow *****/
|
||||||
// Get only users with surname 1 and first name
|
// Get only users with surname 1 and first name
|
||||||
sprintf (Query,"SELECT DISTINCT UsrCod FROM"
|
if (asprintf (&Query,"SELECT DISTINCT UsrCod FROM"
|
||||||
" ("
|
" ("
|
||||||
/***** Likely known users *****/
|
/***** Likely known users *****/
|
||||||
"(SELECT DISTINCT UsrCod FROM"
|
"(SELECT DISTINCT UsrCod FROM"
|
||||||
" ("
|
" ("
|
||||||
// Users followed by my followed whose privacy is
|
// Users followed by my followed whose privacy is
|
||||||
// Pri_VISIBILITY_SYSTEM or Pri_VISIBILITY_WORLD
|
// Pri_VISIBILITY_SYSTEM or Pri_VISIBILITY_WORLD
|
||||||
"("
|
"("
|
||||||
"SELECT DISTINCT usr_follow.FollowedCod AS UsrCod"
|
"SELECT DISTINCT usr_follow.FollowedCod AS UsrCod"
|
||||||
" FROM usr_follow,"
|
" FROM usr_follow,"
|
||||||
"(SELECT FollowedCod FROM usr_follow"
|
"(SELECT FollowedCod FROM usr_follow"
|
||||||
" WHERE FollowerCod=%ld) AS my_followed,"
|
" WHERE FollowerCod=%ld) AS my_followed,"
|
||||||
" usr_data"
|
" usr_data"
|
||||||
" WHERE usr_follow.FollowerCod=my_followed.FollowedCod"
|
" WHERE usr_follow.FollowerCod=my_followed.FollowedCod"
|
||||||
" AND usr_follow.FollowedCod<>%ld"
|
" AND usr_follow.FollowedCod<>%ld"
|
||||||
" AND usr_follow.FollowedCod=usr_data.UsrCod"
|
" AND usr_follow.FollowedCod=usr_data.UsrCod"
|
||||||
" AND usr_data.ProfileVisibility IN ('%s','%s')"
|
" AND usr_data.ProfileVisibility IN ('%s','%s')"
|
||||||
" AND usr_data.Surname1<>''" // Surname 1 not empty
|
" AND usr_data.Surname1<>''" // Surname 1 not empty
|
||||||
" AND usr_data.FirstName<>''" // First name not empty
|
" AND usr_data.FirstName<>''" // First name not empty
|
||||||
"%s" // SubQuery1
|
"%s" // SubQuery1
|
||||||
")"
|
")"
|
||||||
" UNION "
|
" UNION "
|
||||||
// Users who share any course with me
|
// Users who share any course with me
|
||||||
// and whose privacy is Pri_VISIBILITY_COURSE,
|
// and whose privacy is Pri_VISIBILITY_COURSE,
|
||||||
// Pri_VISIBILITY_SYSTEM or Pri_VISIBILITY_WORLD
|
// Pri_VISIBILITY_SYSTEM or Pri_VISIBILITY_WORLD
|
||||||
"("
|
"("
|
||||||
"SELECT DISTINCT crs_usr.UsrCod"
|
"SELECT DISTINCT crs_usr.UsrCod"
|
||||||
" FROM crs_usr,"
|
" FROM crs_usr,"
|
||||||
"(SELECT CrsCod FROM crs_usr"
|
"(SELECT CrsCod FROM crs_usr"
|
||||||
" WHERE UsrCod=%ld) AS my_crs,"
|
" WHERE UsrCod=%ld) AS my_crs,"
|
||||||
" usr_data"
|
" usr_data"
|
||||||
" WHERE crs_usr.CrsCod=my_crs.CrsCod"
|
" WHERE crs_usr.CrsCod=my_crs.CrsCod"
|
||||||
" AND crs_usr.UsrCod<>%ld"
|
" AND crs_usr.UsrCod<>%ld"
|
||||||
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
||||||
" AND usr_data.ProfileVisibility IN ('%s','%s','%s')"
|
" AND usr_data.ProfileVisibility IN ('%s','%s','%s')"
|
||||||
" AND usr_data.Surname1<>''" // Surname 1 not empty
|
" AND usr_data.Surname1<>''" // Surname 1 not empty
|
||||||
" AND usr_data.FirstName<>''" // First name not empty
|
" AND usr_data.FirstName<>''" // First name not empty
|
||||||
"%s" // SubQuery2
|
"%s" // SubQuery2
|
||||||
")"
|
")"
|
||||||
" UNION "
|
" UNION "
|
||||||
// Users who share any course with me with another role
|
// Users who share any course with me with another role
|
||||||
// and whose privacy is Pri_VISIBILITY_USER
|
// and whose privacy is Pri_VISIBILITY_USER
|
||||||
"("
|
"("
|
||||||
"SELECT DISTINCT crs_usr.UsrCod"
|
"SELECT DISTINCT crs_usr.UsrCod"
|
||||||
" FROM crs_usr,"
|
" FROM crs_usr,"
|
||||||
"(SELECT CrsCod,Role FROM crs_usr"
|
"(SELECT CrsCod,Role FROM crs_usr"
|
||||||
" WHERE UsrCod=%ld) AS my_crs_role,"
|
" WHERE UsrCod=%ld) AS my_crs_role,"
|
||||||
" usr_data"
|
" usr_data"
|
||||||
" WHERE crs_usr.CrsCod=my_crs_role.CrsCod"
|
" WHERE crs_usr.CrsCod=my_crs_role.CrsCod"
|
||||||
" AND crs_usr.Role<>my_crs_role.Role"
|
" AND crs_usr.Role<>my_crs_role.Role"
|
||||||
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
" AND crs_usr.UsrCod=usr_data.UsrCod"
|
||||||
" AND usr_data.ProfileVisibility='%s'"
|
" AND usr_data.ProfileVisibility='%s'"
|
||||||
" AND usr_data.Surname1<>''" // Surname 1 not empty
|
" AND usr_data.Surname1<>''" // Surname 1 not empty
|
||||||
" AND usr_data.FirstName<>''" // First name not empty
|
" AND usr_data.FirstName<>''" // First name not empty
|
||||||
"%s" // SubQuery3
|
"%s" // SubQuery3
|
||||||
")"
|
")"
|
||||||
") AS LikelyKnownUsrsToFollow"
|
") AS LikelyKnownUsrsToFollow"
|
||||||
// Do not select my followed
|
// Do not select my followed
|
||||||
" WHERE UsrCod NOT IN"
|
" WHERE UsrCod NOT IN"
|
||||||
" (SELECT FollowedCod FROM usr_follow"
|
" (SELECT FollowedCod FROM usr_follow"
|
||||||
" WHERE FollowerCod=%ld)"
|
" WHERE FollowerCod=%ld)"
|
||||||
// Get only MaxUsrsToShow * 2 users
|
// Get only MaxUsrsToShow * 2 users
|
||||||
" ORDER BY RAND() LIMIT %u"
|
" ORDER BY RAND() LIMIT %u"
|
||||||
")"
|
")"
|
||||||
" UNION "
|
" UNION "
|
||||||
"("
|
"("
|
||||||
/***** Likely unknown users *****/
|
/***** Likely unknown users *****/
|
||||||
// Add some likely unknown random users with privacy
|
// Add some likely unknown random users with privacy
|
||||||
// Pri_VISIBILITY_SYSTEM or Pri_VISIBILITY_WORLD
|
// Pri_VISIBILITY_SYSTEM or Pri_VISIBILITY_WORLD
|
||||||
"SELECT UsrCod FROM usr_data"
|
"SELECT UsrCod FROM usr_data"
|
||||||
" WHERE UsrCod<>%ld"
|
" WHERE UsrCod<>%ld"
|
||||||
" AND ProfileVisibility IN ('%s','%s')"
|
" AND ProfileVisibility IN ('%s','%s')"
|
||||||
" AND Surname1<>''" // Surname 1 not empty
|
" AND Surname1<>''" // Surname 1 not empty
|
||||||
" AND FirstName<>''" // First name not empty
|
" AND FirstName<>''" // First name not empty
|
||||||
"%s" // SubQuery4
|
"%s" // SubQuery4
|
||||||
// Do not select my followed
|
// Do not select my followed
|
||||||
" AND UsrCod NOT IN"
|
" AND UsrCod NOT IN"
|
||||||
" (SELECT FollowedCod FROM usr_follow"
|
" (SELECT FollowedCod FROM usr_follow"
|
||||||
" WHERE FollowerCod=%ld)"
|
" WHERE FollowerCod=%ld)"
|
||||||
// Get only MaxUsrsToShow users
|
// Get only MaxUsrsToShow users
|
||||||
" ORDER BY RAND() LIMIT %u"
|
" ORDER BY RAND() LIMIT %u"
|
||||||
")"
|
")"
|
||||||
") AS UsrsToFollow"
|
") AS UsrsToFollow"
|
||||||
// Get only MaxUsrsToShow users
|
// Get only MaxUsrsToShow users
|
||||||
" ORDER BY RAND() LIMIT %u",
|
" ORDER BY RAND() LIMIT %u",
|
||||||
|
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Pri_VisibilityDB[Pri_VISIBILITY_SYSTEM],
|
Pri_VisibilityDB[Pri_VISIBILITY_SYSTEM],
|
||||||
Pri_VisibilityDB[Pri_VISIBILITY_WORLD ],
|
Pri_VisibilityDB[Pri_VISIBILITY_WORLD ],
|
||||||
SubQuery1,
|
SubQuery1,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Pri_VisibilityDB[Pri_VISIBILITY_COURSE],
|
Pri_VisibilityDB[Pri_VISIBILITY_COURSE],
|
||||||
Pri_VisibilityDB[Pri_VISIBILITY_SYSTEM],
|
Pri_VisibilityDB[Pri_VISIBILITY_SYSTEM],
|
||||||
Pri_VisibilityDB[Pri_VISIBILITY_WORLD ],
|
Pri_VisibilityDB[Pri_VISIBILITY_WORLD ],
|
||||||
SubQuery2,
|
SubQuery2,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Pri_VisibilityDB[Pri_VISIBILITY_USER ],
|
Pri_VisibilityDB[Pri_VISIBILITY_USER ],
|
||||||
SubQuery3,
|
SubQuery3,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
MaxUsrsToShow * 2, // 2/3 likely known users
|
MaxUsrsToShow * 2, // 2/3 likely known users
|
||||||
|
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Pri_VisibilityDB[Pri_VISIBILITY_SYSTEM],
|
Pri_VisibilityDB[Pri_VISIBILITY_SYSTEM],
|
||||||
Pri_VisibilityDB[Pri_VISIBILITY_WORLD ],
|
Pri_VisibilityDB[Pri_VISIBILITY_WORLD ],
|
||||||
SubQuery4,
|
SubQuery4,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
MaxUsrsToShow, // 1/3 likely unknown users
|
MaxUsrsToShow, // 1/3 likely unknown users
|
||||||
|
|
||||||
MaxUsrsToShow);
|
MaxUsrsToShow) < 0)
|
||||||
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
return DB_QuerySELECT (Query,mysql_res,"can not get users to follow");
|
return DB_QuerySELECT_free (Query,mysql_res,"can not get users to follow");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -442,16 +444,17 @@ static void Fol_PutIconToUpdateWhoToFollow (void)
|
||||||
|
|
||||||
bool Fol_CheckUsrIsFollowerOf (long FollowerCod,long FollowedCod)
|
bool Fol_CheckUsrIsFollowerOf (long FollowerCod,long FollowedCod)
|
||||||
{
|
{
|
||||||
char Query[256];
|
char *Query;
|
||||||
|
|
||||||
if (FollowerCod == FollowedCod)
|
if (FollowerCod == FollowedCod)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/***** Check if a user is a follower of another user *****/
|
/***** Check if a user is a follower of another user *****/
|
||||||
sprintf (Query,"SELECT COUNT(*) FROM usr_follow"
|
if (asprintf (&Query,"SELECT COUNT(*) FROM usr_follow"
|
||||||
" WHERE FollowerCod=%ld AND FollowedCod=%ld",
|
" WHERE FollowerCod=%ld AND FollowedCod=%ld",
|
||||||
FollowerCod,FollowedCod);
|
FollowerCod,FollowedCod) < 0)
|
||||||
return (DB_QueryCOUNT (Query,"can not get if a user is a follower of another one") != 0);
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
return (DB_QueryCOUNT_free (Query,"can not get if a user is a follower of another one") != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -460,12 +463,13 @@ bool Fol_CheckUsrIsFollowerOf (long FollowerCod,long FollowedCod)
|
||||||
|
|
||||||
unsigned Fol_GetNumFollowing (long UsrCod)
|
unsigned Fol_GetNumFollowing (long UsrCod)
|
||||||
{
|
{
|
||||||
char Query[128];
|
char *Query;
|
||||||
|
|
||||||
/***** Check if a user is a follower of another user *****/
|
/***** Check if a user is a follower of another user *****/
|
||||||
sprintf (Query,"SELECT COUNT(*) FROM usr_follow WHERE FollowerCod=%ld",
|
if (asprintf (&Query,"SELECT COUNT(*) FROM usr_follow WHERE FollowerCod=%ld",
|
||||||
UsrCod);
|
UsrCod) < 0)
|
||||||
return DB_QueryCOUNT (Query,"can not get number of followed");
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
return DB_QueryCOUNT_free (Query,"can not get number of followed");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -474,12 +478,13 @@ unsigned Fol_GetNumFollowing (long UsrCod)
|
||||||
|
|
||||||
unsigned Fol_GetNumFollowers (long UsrCod)
|
unsigned Fol_GetNumFollowers (long UsrCod)
|
||||||
{
|
{
|
||||||
char Query[128];
|
char *Query;
|
||||||
|
|
||||||
/***** Check if a user is a follower of another user *****/
|
/***** Check if a user is a follower of another user *****/
|
||||||
sprintf (Query,"SELECT COUNT(*) FROM usr_follow WHERE FollowedCod=%ld",
|
if (asprintf (&Query,"SELECT COUNT(*) FROM usr_follow WHERE FollowedCod=%ld",
|
||||||
UsrCod);
|
UsrCod) < 0)
|
||||||
return DB_QueryCOUNT (Query,"can not get number of followers");
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
return DB_QueryCOUNT_free (Query,"can not get number of followers");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -665,7 +670,7 @@ static void Fol_ListFollowingUsr (struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Following;
|
extern const char *Txt_Following;
|
||||||
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
||||||
char Query[256];
|
char *Query;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumUsrs;
|
unsigned NumUsrs;
|
||||||
|
@ -676,10 +681,11 @@ static void Fol_ListFollowingUsr (struct UsrData *UsrDat)
|
||||||
if (Prf_ShowUserProfile (UsrDat))
|
if (Prf_ShowUserProfile (UsrDat))
|
||||||
{
|
{
|
||||||
/***** Check if a user is a follower of another user *****/
|
/***** Check if a user is a follower of another user *****/
|
||||||
sprintf (Query,"SELECT FollowedCod FROM usr_follow"
|
if (asprintf (&Query,"SELECT FollowedCod FROM usr_follow"
|
||||||
" WHERE FollowerCod=%ld ORDER BY FollowTime DESC",
|
" WHERE FollowerCod=%ld ORDER BY FollowTime DESC",
|
||||||
UsrDat->UsrCod);
|
UsrDat->UsrCod) < 0)
|
||||||
NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get followed users");
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
NumUsrs = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get followed users");
|
||||||
if (NumUsrs)
|
if (NumUsrs)
|
||||||
{
|
{
|
||||||
/***** Initialize structure with user's data *****/
|
/***** Initialize structure with user's data *****/
|
||||||
|
@ -749,7 +755,7 @@ static void Fol_ListFollowersUsr (struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Followers;
|
extern const char *Txt_Followers;
|
||||||
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
||||||
char Query[256];
|
char *Query;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumUsrs;
|
unsigned NumUsrs;
|
||||||
|
@ -761,10 +767,11 @@ static void Fol_ListFollowersUsr (struct UsrData *UsrDat)
|
||||||
if (Prf_ShowUserProfile (UsrDat))
|
if (Prf_ShowUserProfile (UsrDat))
|
||||||
{
|
{
|
||||||
/***** Check if a user is a follower of another user *****/
|
/***** Check if a user is a follower of another user *****/
|
||||||
sprintf (Query,"SELECT FollowerCod FROM usr_follow"
|
if (asprintf (&Query,"SELECT FollowerCod FROM usr_follow"
|
||||||
" WHERE FollowedCod=%ld ORDER BY FollowTime DESC",
|
" WHERE FollowedCod=%ld ORDER BY FollowTime DESC",
|
||||||
UsrDat->UsrCod);
|
UsrDat->UsrCod) < 0)
|
||||||
NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get followers");
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
NumUsrs = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get followers");
|
||||||
if (NumUsrs)
|
if (NumUsrs)
|
||||||
{
|
{
|
||||||
/***** Initialize structure with user's data *****/
|
/***** Initialize structure with user's data *****/
|
||||||
|
@ -1006,7 +1013,7 @@ static void Fol_PutIconToUnfollow (struct UsrData *UsrDat)
|
||||||
void Fol_FollowUsr1 (void)
|
void Fol_FollowUsr1 (void)
|
||||||
{
|
{
|
||||||
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
||||||
char Query[256];
|
char *Query;
|
||||||
bool CreateNotif;
|
bool CreateNotif;
|
||||||
bool NotifyByEmail;
|
bool NotifyByEmail;
|
||||||
|
|
||||||
|
@ -1020,13 +1027,14 @@ void Fol_FollowUsr1 (void)
|
||||||
Gbl.Usrs.Other.UsrDat.UsrCod))
|
Gbl.Usrs.Other.UsrDat.UsrCod))
|
||||||
{
|
{
|
||||||
/***** Follow user in database *****/
|
/***** Follow user in database *****/
|
||||||
sprintf (Query,"REPLACE INTO usr_follow"
|
if (asprintf (&Query,"REPLACE INTO usr_follow"
|
||||||
" (FollowerCod,FollowedCod,FollowTime)"
|
" (FollowerCod,FollowedCod,FollowTime)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,%ld,NOW())",
|
" (%ld,%ld,NOW())",
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Gbl.Usrs.Other.UsrDat.UsrCod);
|
Gbl.Usrs.Other.UsrDat.UsrCod) < 0)
|
||||||
DB_QueryREPLACE (Query,"can not follow user");
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
DB_QueryREPLACE_free (Query,"can not follow user");
|
||||||
|
|
||||||
/***** This follow must be notified by email? *****/
|
/***** This follow must be notified by email? *****/
|
||||||
CreateNotif = (Gbl.Usrs.Other.UsrDat.Prefs.NotifNtfEvents & (1 << Ntf_EVENT_FOLLOWER));
|
CreateNotif = (Gbl.Usrs.Other.UsrDat.Prefs.NotifNtfEvents & (1 << Ntf_EVENT_FOLLOWER));
|
||||||
|
@ -1074,7 +1082,7 @@ void Fol_FollowUsr2 (void)
|
||||||
void Fol_UnfollowUsr1 (void)
|
void Fol_UnfollowUsr1 (void)
|
||||||
{
|
{
|
||||||
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
||||||
char Query[256];
|
char *Query;
|
||||||
|
|
||||||
/***** Get user to be unfollowed *****/
|
/***** Get user to be unfollowed *****/
|
||||||
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
||||||
|
@ -1084,11 +1092,12 @@ void Fol_UnfollowUsr1 (void)
|
||||||
Gbl.Usrs.Other.UsrDat.UsrCod))
|
Gbl.Usrs.Other.UsrDat.UsrCod))
|
||||||
{
|
{
|
||||||
/***** Unfollow user in database *****/
|
/***** Unfollow user in database *****/
|
||||||
sprintf (Query,"DELETE FROM usr_follow"
|
if (asprintf (&Query,"DELETE FROM usr_follow"
|
||||||
" WHERE FollowerCod=%ld AND FollowedCod=%ld",
|
" WHERE FollowerCod=%ld AND FollowedCod=%ld",
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Gbl.Usrs.Other.UsrDat.UsrCod);
|
Gbl.Usrs.Other.UsrDat.UsrCod) < 0)
|
||||||
DB_QueryREPLACE (Query,"can not unfollow user");
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
DB_QueryREPLACE_free (Query,"can not unfollow user");
|
||||||
}
|
}
|
||||||
Gbl.Alert.Type = Ale_SUCCESS;
|
Gbl.Alert.Type = Ale_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1122,71 +1131,77 @@ void Fol_UnfollowUsr2 (void)
|
||||||
|
|
||||||
void Fol_GetAndShowRankingFollowers (void)
|
void Fol_GetAndShowRankingFollowers (void)
|
||||||
{
|
{
|
||||||
char Query[512];
|
char *Query;
|
||||||
|
|
||||||
/***** Get ranking from database *****/
|
/***** Get ranking from database *****/
|
||||||
switch (Gbl.Scope.Current)
|
switch (Gbl.Scope.Current)
|
||||||
{
|
{
|
||||||
case Sco_SCOPE_SYS:
|
case Sco_SCOPE_SYS:
|
||||||
sprintf (Query,"SELECT FollowedCod,COUNT(FollowerCod) AS N"
|
if (asprintf (&Query,"SELECT FollowedCod,COUNT(FollowerCod) AS N"
|
||||||
" FROM usr_follow"
|
" FROM usr_follow"
|
||||||
" GROUP BY FollowedCod"
|
" GROUP BY FollowedCod"
|
||||||
" ORDER BY N DESC,FollowedCod LIMIT 100");
|
" ORDER BY N DESC,FollowedCod LIMIT 100") < 0)
|
||||||
|
Lay_NotEnoughMemoryExit ();
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CTY:
|
case Sco_SCOPE_CTY:
|
||||||
sprintf (Query,"SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
if (asprintf (&Query,"SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
||||||
" FROM institutions,centres,degrees,courses,crs_usr,usr_follow"
|
" FROM institutions,centres,degrees,courses,crs_usr,usr_follow"
|
||||||
" WHERE institutions.CtyCod=%ld"
|
" WHERE institutions.CtyCod=%ld"
|
||||||
" AND institutions.InsCod=centres.InsCod"
|
" AND institutions.InsCod=centres.InsCod"
|
||||||
" AND centres.CtrCod=degrees.CtrCod"
|
" AND centres.CtrCod=degrees.CtrCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
||||||
" GROUP BY usr_follow.FollowedCod"
|
" GROUP BY usr_follow.FollowedCod"
|
||||||
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
||||||
Gbl.CurrentCty.Cty.CtyCod);
|
Gbl.CurrentCty.Cty.CtyCod) < 0)
|
||||||
|
Lay_NotEnoughMemoryExit ();
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_INS:
|
case Sco_SCOPE_INS:
|
||||||
sprintf (Query,"SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
if (asprintf (&Query,"SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
||||||
" FROM centres,degrees,courses,crs_usr,usr_follow"
|
" FROM centres,degrees,courses,crs_usr,usr_follow"
|
||||||
" WHERE centres.InsCod=%ld"
|
" WHERE centres.InsCod=%ld"
|
||||||
" AND centres.CtrCod=degrees.CtrCod"
|
" AND centres.CtrCod=degrees.CtrCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
||||||
" GROUP BY usr_follow.FollowedCod"
|
" GROUP BY usr_follow.FollowedCod"
|
||||||
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
||||||
Gbl.CurrentIns.Ins.InsCod);
|
Gbl.CurrentIns.Ins.InsCod) < 0)
|
||||||
|
Lay_NotEnoughMemoryExit ();
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CTR:
|
case Sco_SCOPE_CTR:
|
||||||
sprintf (Query,"SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
if (asprintf (&Query,"SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
||||||
" FROM degrees,courses,crs_usr,usr_follow"
|
" FROM degrees,courses,crs_usr,usr_follow"
|
||||||
" WHERE degrees.CtrCod=%ld"
|
" WHERE degrees.CtrCod=%ld"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
||||||
" GROUP BY usr_follow.FollowedCod"
|
" GROUP BY usr_follow.FollowedCod"
|
||||||
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
||||||
Gbl.CurrentCtr.Ctr.CtrCod);
|
Gbl.CurrentCtr.Ctr.CtrCod) < 0)
|
||||||
|
Lay_NotEnoughMemoryExit ();
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_DEG:
|
case Sco_SCOPE_DEG:
|
||||||
sprintf (Query,"SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
if (asprintf (&Query,"SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
||||||
" FROM courses,crs_usr,usr_follow"
|
" FROM courses,crs_usr,usr_follow"
|
||||||
" WHERE courses.DegCod=%ld"
|
" WHERE courses.DegCod=%ld"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
||||||
" GROUP BY usr_follow.FollowedCod"
|
" GROUP BY usr_follow.FollowedCod"
|
||||||
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
||||||
Gbl.CurrentDeg.Deg.DegCod);
|
Gbl.CurrentDeg.Deg.DegCod) < 0)
|
||||||
|
Lay_NotEnoughMemoryExit ();
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CRS:
|
case Sco_SCOPE_CRS:
|
||||||
sprintf (Query,"SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
if (asprintf (&Query,"SELECT usr_follow.FollowedCod,COUNT(DISTINCT usr_follow.FollowerCod) AS N"
|
||||||
" FROM crs_usr,usr_follow"
|
" FROM crs_usr,usr_follow"
|
||||||
" WHERE crs_usr.CrsCod=%ld"
|
" WHERE crs_usr.CrsCod=%ld"
|
||||||
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
||||||
" GROUP BY usr_follow.FollowedCod"
|
" GROUP BY usr_follow.FollowedCod"
|
||||||
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod);
|
Gbl.CurrentCrs.Crs.CrsCod) < 0)
|
||||||
|
Lay_NotEnoughMemoryExit ();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Lay_ShowErrorAndExit ("Wrong scope.");
|
Lay_ShowErrorAndExit ("Wrong scope.");
|
||||||
|
@ -1215,10 +1230,11 @@ void Fol_GetNotifFollower (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
||||||
|
|
||||||
void Fol_RemoveUsrFromUsrFollow (long UsrCod)
|
void Fol_RemoveUsrFromUsrFollow (long UsrCod)
|
||||||
{
|
{
|
||||||
char Query[128];
|
char *Query;
|
||||||
|
|
||||||
sprintf (Query,"DELETE FROM usr_follow"
|
if (asprintf (&Query,"DELETE FROM usr_follow"
|
||||||
" WHERE FollowerCod=%ld OR FollowedCod=%ld",
|
" WHERE FollowerCod=%ld OR FollowedCod=%ld",
|
||||||
UsrCod,UsrCod);
|
UsrCod,UsrCod) < 0)
|
||||||
DB_QueryDELETE (Query,"can not remove user from followers and followed");
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
DB_QueryDELETE_free (Query,"can not remove user from followers and followed");
|
||||||
}
|
}
|
||||||
|
|
146
swad_profile.c
146
swad_profile.c
|
@ -25,7 +25,9 @@
|
||||||
/*********************************** Headers *********************************/
|
/*********************************** Headers *********************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#define _GNU_SOURCE // For asprintf
|
||||||
#include <linux/stddef.h> // For NULL
|
#include <linux/stddef.h> // For NULL
|
||||||
|
#include <stdio.h> // For asprintf
|
||||||
#include <string.h> // For string functions
|
#include <string.h> // For string functions
|
||||||
|
|
||||||
#include "swad_box.h"
|
#include "swad_box.h"
|
||||||
|
@ -1184,89 +1186,95 @@ void Prf_GetAndShowRankingMsgSnt (void)
|
||||||
|
|
||||||
static void Prf_GetAndShowRankingFigure (const char *FieldName)
|
static void Prf_GetAndShowRankingFigure (const char *FieldName)
|
||||||
{
|
{
|
||||||
char Query[1024];
|
char *Query;
|
||||||
|
|
||||||
/***** Get ranking from database *****/
|
/***** Get ranking from database *****/
|
||||||
switch (Gbl.Scope.Current)
|
switch (Gbl.Scope.Current)
|
||||||
{
|
{
|
||||||
case Sco_SCOPE_SYS:
|
case Sco_SCOPE_SYS:
|
||||||
sprintf (Query,"SELECT UsrCod,%s"
|
if (asprintf (&Query,"SELECT UsrCod,%s"
|
||||||
" FROM usr_figures"
|
" FROM usr_figures"
|
||||||
" WHERE %s>=0"
|
" WHERE %s>=0"
|
||||||
" AND UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
" AND UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
||||||
" ORDER BY %s DESC,UsrCod LIMIT 100",
|
" ORDER BY %s DESC,UsrCod LIMIT 100",
|
||||||
FieldName,
|
FieldName,
|
||||||
FieldName,FieldName);
|
FieldName,FieldName) < 0)
|
||||||
|
Lay_NotEnoughMemoryExit ();
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CTY:
|
case Sco_SCOPE_CTY:
|
||||||
sprintf (Query,"SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
if (asprintf (&Query,"SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
||||||
" FROM institutions,centres,degrees,courses,crs_usr,usr_figures"
|
" FROM institutions,centres,degrees,courses,crs_usr,usr_figures"
|
||||||
" WHERE institutions.CtyCod=%ld"
|
" WHERE institutions.CtyCod=%ld"
|
||||||
" AND institutions.InsCod=centres.InsCod"
|
" AND institutions.InsCod=centres.InsCod"
|
||||||
" AND centres.CtrCod=degrees.CtrCod"
|
" AND centres.CtrCod=degrees.CtrCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
||||||
" AND usr_figures.%s>=0"
|
" AND usr_figures.%s>=0"
|
||||||
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
||||||
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
||||||
FieldName,
|
FieldName,
|
||||||
Gbl.CurrentCty.Cty.CtyCod,
|
Gbl.CurrentCty.Cty.CtyCod,
|
||||||
FieldName,FieldName);
|
FieldName,FieldName) < 0)
|
||||||
|
Lay_NotEnoughMemoryExit ();
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_INS:
|
case Sco_SCOPE_INS:
|
||||||
sprintf (Query,"SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
if (asprintf (&Query,"SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
||||||
" FROM centres,degrees,courses,crs_usr,usr_figures"
|
" FROM centres,degrees,courses,crs_usr,usr_figures"
|
||||||
" WHERE centres.InsCod=%ld"
|
" WHERE centres.InsCod=%ld"
|
||||||
" AND centres.CtrCod=degrees.CtrCod"
|
" AND centres.CtrCod=degrees.CtrCod"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
||||||
" AND usr_figures.%s>=0"
|
" AND usr_figures.%s>=0"
|
||||||
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
||||||
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
||||||
FieldName,
|
FieldName,
|
||||||
Gbl.CurrentIns.Ins.InsCod,
|
Gbl.CurrentIns.Ins.InsCod,
|
||||||
FieldName,FieldName);
|
FieldName,FieldName) < 0)
|
||||||
|
Lay_NotEnoughMemoryExit ();
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CTR:
|
case Sco_SCOPE_CTR:
|
||||||
sprintf (Query,"SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
if (asprintf (&Query,"SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
||||||
" FROM degrees,courses,crs_usr,usr_figures"
|
" FROM degrees,courses,crs_usr,usr_figures"
|
||||||
" WHERE degrees.CtrCod=%ld"
|
" WHERE degrees.CtrCod=%ld"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
||||||
" AND usr_figures.%s>=0"
|
" AND usr_figures.%s>=0"
|
||||||
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
||||||
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
||||||
FieldName,
|
FieldName,
|
||||||
Gbl.CurrentCtr.Ctr.CtrCod,
|
Gbl.CurrentCtr.Ctr.CtrCod,
|
||||||
FieldName,FieldName);
|
FieldName,FieldName) < 0)
|
||||||
|
Lay_NotEnoughMemoryExit ();
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_DEG:
|
case Sco_SCOPE_DEG:
|
||||||
sprintf (Query,"SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
if (asprintf (&Query,"SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
||||||
" FROM courses,crs_usr,usr_figures"
|
" FROM courses,crs_usr,usr_figures"
|
||||||
" WHERE courses.DegCod=%ld"
|
" WHERE courses.DegCod=%ld"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
||||||
" AND usr_figures.%s>=0"
|
" AND usr_figures.%s>=0"
|
||||||
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
||||||
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
||||||
FieldName,
|
FieldName,
|
||||||
Gbl.CurrentDeg.Deg.DegCod,
|
Gbl.CurrentDeg.Deg.DegCod,
|
||||||
FieldName,FieldName);
|
FieldName,FieldName) < 0)
|
||||||
|
Lay_NotEnoughMemoryExit ();
|
||||||
break;
|
break;
|
||||||
case Sco_SCOPE_CRS:
|
case Sco_SCOPE_CRS:
|
||||||
sprintf (Query,"SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
if (asprintf (&Query,"SELECT DISTINCTROW usr_figures.UsrCod,usr_figures.%s"
|
||||||
" FROM crs_usr,usr_figures"
|
" FROM crs_usr,usr_figures"
|
||||||
" WHERE crs_usr.CrsCod=%ld"
|
" WHERE crs_usr.CrsCod=%ld"
|
||||||
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
||||||
" AND usr_figures.%s>=0"
|
" AND usr_figures.%s>=0"
|
||||||
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
" AND usr_figures.UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
||||||
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
||||||
FieldName,
|
FieldName,
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
FieldName,FieldName);
|
FieldName,FieldName) < 0)
|
||||||
|
Lay_NotEnoughMemoryExit ();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Lay_ShowErrorAndExit ("Wrong scope.");
|
Lay_ShowErrorAndExit ("Wrong scope.");
|
||||||
|
@ -1286,7 +1294,7 @@ void Prf_ShowRankingFigure (const char *Query)
|
||||||
long FigureHigh = LONG_MAX;
|
long FigureHigh = LONG_MAX;
|
||||||
long Figure;
|
long Figure;
|
||||||
|
|
||||||
NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get ranking");
|
NumUsrs = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get ranking");
|
||||||
if (NumUsrs)
|
if (NumUsrs)
|
||||||
{
|
{
|
||||||
/***** Initialize structure with user's data *****/
|
/***** Initialize structure with user's data *****/
|
||||||
|
|
Loading…
Reference in New Issue
Block a user