mirror of https://github.com/acanas/swad-core.git
Version 18.7.23
This commit is contained in:
parent
662aca0ef6
commit
594de1477c
|
@ -355,10 +355,11 @@ En OpenSWAD:
|
|||
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 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.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)
|
||||
|
|
116
swad_follow.c
116
swad_follow.c
|
@ -25,8 +25,9 @@
|
|||
/*********************************** Headers *********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _GNU_SOURCE // For asprintf
|
||||
#include <stdbool.h> // For boolean type
|
||||
#include <stdio.h> // For sprintf
|
||||
#include <stdio.h> // For asprintf
|
||||
#include <string.h> // For string functions
|
||||
|
||||
#include "swad_box.h"
|
||||
|
@ -247,7 +248,7 @@ static unsigned Fol_GetUsrsWhoToFollow (unsigned MaxUsrsToShow,
|
|||
MYSQL_RES **mysql_res)
|
||||
{
|
||||
extern const char *Pri_VisibilityDB[Pri_NUM_OPTIONS_PRIVACY];
|
||||
char Query[4096];
|
||||
char *Query;
|
||||
char SubQuery1[256];
|
||||
char SubQuery2[256];
|
||||
char SubQuery3[256];
|
||||
|
@ -291,7 +292,7 @@ static unsigned Fol_GetUsrsWhoToFollow (unsigned MaxUsrsToShow,
|
|||
|
||||
/***** Build query to get users to follow *****/
|
||||
// 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 *****/
|
||||
"(SELECT DISTINCT UsrCod FROM"
|
||||
|
@ -401,9 +402,10 @@ static unsigned Fol_GetUsrsWhoToFollow (unsigned MaxUsrsToShow,
|
|||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
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)
|
||||
{
|
||||
char Query[256];
|
||||
char *Query;
|
||||
|
||||
if (FollowerCod == FollowedCod)
|
||||
return false;
|
||||
|
||||
/***** 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",
|
||||
FollowerCod,FollowedCod);
|
||||
return (DB_QueryCOUNT (Query,"can not get if a user is a follower of another one") != 0);
|
||||
FollowerCod,FollowedCod) < 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)
|
||||
{
|
||||
char Query[128];
|
||||
char *Query;
|
||||
|
||||
/***** 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");
|
||||
if (asprintf (&Query,"SELECT COUNT(*) FROM usr_follow WHERE FollowerCod=%ld",
|
||||
UsrCod) < 0)
|
||||
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)
|
||||
{
|
||||
char Query[128];
|
||||
char *Query;
|
||||
|
||||
/***** 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");
|
||||
if (asprintf (&Query,"SELECT COUNT(*) FROM usr_follow WHERE FollowedCod=%ld",
|
||||
UsrCod) < 0)
|
||||
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_User_not_found_or_you_do_not_have_permission_;
|
||||
char Query[256];
|
||||
char *Query;
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumUsrs;
|
||||
|
@ -676,10 +681,11 @@ static void Fol_ListFollowingUsr (struct UsrData *UsrDat)
|
|||
if (Prf_ShowUserProfile (UsrDat))
|
||||
{
|
||||
/***** 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",
|
||||
UsrDat->UsrCod);
|
||||
NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get followed users");
|
||||
UsrDat->UsrCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
NumUsrs = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get followed users");
|
||||
if (NumUsrs)
|
||||
{
|
||||
/***** 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_User_not_found_or_you_do_not_have_permission_;
|
||||
char Query[256];
|
||||
char *Query;
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumUsrs;
|
||||
|
@ -761,10 +767,11 @@ static void Fol_ListFollowersUsr (struct UsrData *UsrDat)
|
|||
if (Prf_ShowUserProfile (UsrDat))
|
||||
{
|
||||
/***** 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",
|
||||
UsrDat->UsrCod);
|
||||
NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get followers");
|
||||
UsrDat->UsrCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
NumUsrs = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get followers");
|
||||
if (NumUsrs)
|
||||
{
|
||||
/***** Initialize structure with user's data *****/
|
||||
|
@ -1006,7 +1013,7 @@ static void Fol_PutIconToUnfollow (struct UsrData *UsrDat)
|
|||
void Fol_FollowUsr1 (void)
|
||||
{
|
||||
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
||||
char Query[256];
|
||||
char *Query;
|
||||
bool CreateNotif;
|
||||
bool NotifyByEmail;
|
||||
|
||||
|
@ -1020,13 +1027,14 @@ void Fol_FollowUsr1 (void)
|
|||
Gbl.Usrs.Other.UsrDat.UsrCod))
|
||||
{
|
||||
/***** Follow user in database *****/
|
||||
sprintf (Query,"REPLACE INTO usr_follow"
|
||||
if (asprintf (&Query,"REPLACE INTO usr_follow"
|
||||
" (FollowerCod,FollowedCod,FollowTime)"
|
||||
" VALUES"
|
||||
" (%ld,%ld,NOW())",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||
DB_QueryREPLACE (Query,"can not follow user");
|
||||
Gbl.Usrs.Other.UsrDat.UsrCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
DB_QueryREPLACE_free (Query,"can not follow user");
|
||||
|
||||
/***** This follow must be notified by email? *****/
|
||||
CreateNotif = (Gbl.Usrs.Other.UsrDat.Prefs.NotifNtfEvents & (1 << Ntf_EVENT_FOLLOWER));
|
||||
|
@ -1074,7 +1082,7 @@ void Fol_FollowUsr2 (void)
|
|||
void Fol_UnfollowUsr1 (void)
|
||||
{
|
||||
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
||||
char Query[256];
|
||||
char *Query;
|
||||
|
||||
/***** Get user to be unfollowed *****/
|
||||
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
||||
|
@ -1084,11 +1092,12 @@ void Fol_UnfollowUsr1 (void)
|
|||
Gbl.Usrs.Other.UsrDat.UsrCod))
|
||||
{
|
||||
/***** Unfollow user in database *****/
|
||||
sprintf (Query,"DELETE FROM usr_follow"
|
||||
if (asprintf (&Query,"DELETE FROM usr_follow"
|
||||
" WHERE FollowerCod=%ld AND FollowedCod=%ld",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||
DB_QueryREPLACE (Query,"can not unfollow user");
|
||||
Gbl.Usrs.Other.UsrDat.UsrCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
DB_QueryREPLACE_free (Query,"can not unfollow user");
|
||||
}
|
||||
Gbl.Alert.Type = Ale_SUCCESS;
|
||||
}
|
||||
|
@ -1122,19 +1131,20 @@ void Fol_UnfollowUsr2 (void)
|
|||
|
||||
void Fol_GetAndShowRankingFollowers (void)
|
||||
{
|
||||
char Query[512];
|
||||
char *Query;
|
||||
|
||||
/***** Get ranking from database *****/
|
||||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
sprintf (Query,"SELECT FollowedCod,COUNT(FollowerCod) AS N"
|
||||
if (asprintf (&Query,"SELECT FollowedCod,COUNT(FollowerCod) AS N"
|
||||
" FROM usr_follow"
|
||||
" GROUP BY FollowedCod"
|
||||
" ORDER BY N DESC,FollowedCod LIMIT 100");
|
||||
" ORDER BY N DESC,FollowedCod LIMIT 100") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
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"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
|
@ -1144,10 +1154,11 @@ void Fol_GetAndShowRankingFollowers (void)
|
|||
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
||||
" GROUP BY usr_follow.FollowedCod"
|
||||
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
||||
Gbl.CurrentCty.Cty.CtyCod);
|
||||
Gbl.CurrentCty.Cty.CtyCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
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"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
|
@ -1156,10 +1167,11 @@ void Fol_GetAndShowRankingFollowers (void)
|
|||
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
||||
" GROUP BY usr_follow.FollowedCod"
|
||||
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
||||
Gbl.CurrentIns.Ins.InsCod);
|
||||
Gbl.CurrentIns.Ins.InsCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
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"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
|
@ -1167,26 +1179,29 @@ void Fol_GetAndShowRankingFollowers (void)
|
|||
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
||||
" GROUP BY usr_follow.FollowedCod"
|
||||
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
||||
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||
Gbl.CurrentCtr.Ctr.CtrCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
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"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
||||
" GROUP BY usr_follow.FollowedCod"
|
||||
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
||||
Gbl.CurrentDeg.Deg.DegCod);
|
||||
Gbl.CurrentDeg.Deg.DegCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
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"
|
||||
" WHERE crs_usr.CrsCod=%ld"
|
||||
" AND crs_usr.UsrCod=usr_follow.FollowedCod"
|
||||
" GROUP BY usr_follow.FollowedCod"
|
||||
" ORDER BY N DESC,usr_follow.FollowedCod LIMIT 100",
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
Gbl.CurrentCrs.Crs.CrsCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
default:
|
||||
Lay_ShowErrorAndExit ("Wrong scope.");
|
||||
|
@ -1215,10 +1230,11 @@ void Fol_GetNotifFollower (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
|||
|
||||
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",
|
||||
UsrCod,UsrCod);
|
||||
DB_QueryDELETE (Query,"can not remove user from followers and followed");
|
||||
UsrCod,UsrCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
DB_QueryDELETE_free (Query,"can not remove user from followers and followed");
|
||||
}
|
||||
|
|
|
@ -25,7 +25,9 @@
|
|||
/*********************************** Headers *********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _GNU_SOURCE // For asprintf
|
||||
#include <linux/stddef.h> // For NULL
|
||||
#include <stdio.h> // For asprintf
|
||||
#include <string.h> // For string functions
|
||||
|
||||
#include "swad_box.h"
|
||||
|
@ -1184,22 +1186,23 @@ void Prf_GetAndShowRankingMsgSnt (void)
|
|||
|
||||
static void Prf_GetAndShowRankingFigure (const char *FieldName)
|
||||
{
|
||||
char Query[1024];
|
||||
char *Query;
|
||||
|
||||
/***** Get ranking from database *****/
|
||||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
sprintf (Query,"SELECT UsrCod,%s"
|
||||
if (asprintf (&Query,"SELECT UsrCod,%s"
|
||||
" FROM usr_figures"
|
||||
" WHERE %s>=0"
|
||||
" AND UsrCod NOT IN (SELECT UsrCod FROM usr_banned)"
|
||||
" ORDER BY %s DESC,UsrCod LIMIT 100",
|
||||
FieldName,
|
||||
FieldName,FieldName);
|
||||
FieldName,FieldName) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
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"
|
||||
" WHERE institutions.CtyCod=%ld"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
|
@ -1212,10 +1215,11 @@ static void Prf_GetAndShowRankingFigure (const char *FieldName)
|
|||
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
||||
FieldName,
|
||||
Gbl.CurrentCty.Cty.CtyCod,
|
||||
FieldName,FieldName);
|
||||
FieldName,FieldName) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
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"
|
||||
" WHERE centres.InsCod=%ld"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
|
@ -1227,10 +1231,11 @@ static void Prf_GetAndShowRankingFigure (const char *FieldName)
|
|||
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
||||
FieldName,
|
||||
Gbl.CurrentIns.Ins.InsCod,
|
||||
FieldName,FieldName);
|
||||
FieldName,FieldName) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
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"
|
||||
" WHERE degrees.CtrCod=%ld"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
|
@ -1241,10 +1246,11 @@ static void Prf_GetAndShowRankingFigure (const char *FieldName)
|
|||
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
||||
FieldName,
|
||||
Gbl.CurrentCtr.Ctr.CtrCod,
|
||||
FieldName,FieldName);
|
||||
FieldName,FieldName) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
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"
|
||||
" WHERE courses.DegCod=%ld"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
|
@ -1254,10 +1260,11 @@ static void Prf_GetAndShowRankingFigure (const char *FieldName)
|
|||
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
||||
FieldName,
|
||||
Gbl.CurrentDeg.Deg.DegCod,
|
||||
FieldName,FieldName);
|
||||
FieldName,FieldName) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
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"
|
||||
" WHERE crs_usr.CrsCod=%ld"
|
||||
" AND crs_usr.UsrCod=usr_figures.UsrCod"
|
||||
|
@ -1266,7 +1273,8 @@ static void Prf_GetAndShowRankingFigure (const char *FieldName)
|
|||
" ORDER BY usr_figures.%s DESC,usr_figures.UsrCod LIMIT 100",
|
||||
FieldName,
|
||||
Gbl.CurrentCrs.Crs.CrsCod,
|
||||
FieldName,FieldName);
|
||||
FieldName,FieldName) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
default:
|
||||
Lay_ShowErrorAndExit ("Wrong scope.");
|
||||
|
@ -1286,7 +1294,7 @@ void Prf_ShowRankingFigure (const char *Query)
|
|||
long FigureHigh = LONG_MAX;
|
||||
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)
|
||||
{
|
||||
/***** Initialize structure with user's data *****/
|
||||
|
|
Loading…
Reference in New Issue