2015-03-14 17:39:04 +01:00
|
|
|
|
// swad_profile.c: user's public profile
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
SWAD (Shared Workspace At a Distance),
|
|
|
|
|
is a web platform developed at the University of Granada (Spain),
|
|
|
|
|
and used to support university teaching.
|
|
|
|
|
|
|
|
|
|
This file is part of SWAD core.
|
2021-02-09 12:43:45 +01:00
|
|
|
|
Copyright (C) 1999-2021 Antonio Ca<EFBFBD>as Vargas
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General 3 License as
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************************** Headers *********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-12-30 22:32:06 +01:00
|
|
|
|
#define _GNU_SOURCE // For asprintf
|
2019-12-29 12:39:00 +01:00
|
|
|
|
#include <stddef.h> // For NULL
|
2019-12-30 22:32:06 +01:00
|
|
|
|
#include <stdio.h> // For asprintf
|
2021-05-20 18:44:13 +02:00
|
|
|
|
#include <stdlib.h> // For free
|
2016-11-08 00:58:32 +01:00
|
|
|
|
#include <string.h> // For string functions
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
2017-06-10 21:38:10 +02:00
|
|
|
|
#include "swad_box.h"
|
2021-09-14 23:32:18 +02:00
|
|
|
|
#include "swad_browser_database.h"
|
2015-03-14 17:39:04 +01:00
|
|
|
|
#include "swad_config.h"
|
|
|
|
|
#include "swad_database.h"
|
2021-11-03 21:31:16 +01:00
|
|
|
|
#include "swad_enrolment_database.h"
|
2021-04-26 15:27:27 +02:00
|
|
|
|
#include "swad_error.h"
|
2020-04-14 17:15:17 +02:00
|
|
|
|
#include "swad_figure.h"
|
2021-05-07 19:11:57 +02:00
|
|
|
|
#include "swad_follow_database.h"
|
2018-11-09 20:47:39 +01:00
|
|
|
|
#include "swad_form.h"
|
2021-09-15 20:21:02 +02:00
|
|
|
|
#include "swad_forum_database.h"
|
2015-03-14 17:39:04 +01:00
|
|
|
|
#include "swad_global.h"
|
2021-05-27 23:30:16 +02:00
|
|
|
|
#include "swad_hierarchy_level.h"
|
2019-10-23 19:05:05 +02:00
|
|
|
|
#include "swad_HTML.h"
|
2018-12-08 16:43:13 +01:00
|
|
|
|
#include "swad_language.h"
|
2021-10-07 01:21:23 +02:00
|
|
|
|
#include "swad_log_database.h"
|
2020-04-14 17:15:17 +02:00
|
|
|
|
#include "swad_message.h"
|
2021-09-27 23:59:50 +02:00
|
|
|
|
#include "swad_message_database.h"
|
2016-01-04 16:45:43 +01:00
|
|
|
|
#include "swad_network.h"
|
2015-03-14 17:39:04 +01:00
|
|
|
|
#include "swad_nickname.h"
|
2016-01-20 21:18:38 +01:00
|
|
|
|
#include "swad_notification.h"
|
2021-10-01 09:11:58 +02:00
|
|
|
|
#include "swad_notification_database.h"
|
2015-03-14 17:39:04 +01:00
|
|
|
|
#include "swad_parameter.h"
|
2020-04-14 17:15:17 +02:00
|
|
|
|
#include "swad_photo.h"
|
2015-03-14 17:39:04 +01:00
|
|
|
|
#include "swad_privacy.h"
|
2015-03-18 02:11:23 +01:00
|
|
|
|
#include "swad_profile.h"
|
2021-10-07 01:21:23 +02:00
|
|
|
|
#include "swad_profile_database.h"
|
2015-03-14 17:39:04 +01:00
|
|
|
|
#include "swad_role.h"
|
2016-12-13 13:32:19 +01:00
|
|
|
|
#include "swad_role_type.h"
|
2019-03-26 11:53:21 +01:00
|
|
|
|
#include "swad_setting.h"
|
2021-10-18 23:16:56 +02:00
|
|
|
|
#include "swad_setting_database.h"
|
2015-03-14 17:39:04 +01:00
|
|
|
|
#include "swad_theme.h"
|
2019-03-12 21:25:55 +01:00
|
|
|
|
#include "swad_timeline.h"
|
2021-02-28 19:59:49 +01:00
|
|
|
|
#include "swad_timeline_database.h"
|
2015-03-14 17:39:04 +01:00
|
|
|
|
#include "swad_user.h"
|
2021-11-03 11:35:21 +01:00
|
|
|
|
#include "swad_user_database.h"
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-03-06 23:52:04 +01:00
|
|
|
|
static void Prf_ShowTimeSinceFirstClick (const struct UsrData *UsrDat,
|
2021-10-13 10:42:08 +02:00
|
|
|
|
const struct Prf_UsrFigures *UsrFigures);
|
2019-03-06 22:07:24 +01:00
|
|
|
|
static void Prf_ShowNumCrssWithRole (const struct UsrData *UsrDat,
|
|
|
|
|
Rol_Role_t Role);
|
2019-03-06 23:52:04 +01:00
|
|
|
|
static void Prf_ShowNumFilesCurrentlyPublished (const struct UsrData *UsrDat);
|
|
|
|
|
static void Prf_ShowNumClicks (const struct UsrData *UsrDat,
|
2021-10-13 10:42:08 +02:00
|
|
|
|
const struct Prf_UsrFigures *UsrFigures);
|
2019-03-06 23:52:04 +01:00
|
|
|
|
static void Prf_ShowNumFileViews (const struct UsrData *UsrDat,
|
2021-10-13 10:42:08 +02:00
|
|
|
|
const struct Prf_UsrFigures *UsrFigures);
|
2021-10-07 01:21:23 +02:00
|
|
|
|
static void Prf_ShowNumTimelinePubs (const struct UsrData *UsrDat,
|
2021-10-13 10:42:08 +02:00
|
|
|
|
const struct Prf_UsrFigures *UsrFigures);
|
2019-03-06 23:52:04 +01:00
|
|
|
|
static void Prf_ShowNumForumPosts (const struct UsrData *UsrDat,
|
2021-10-13 10:42:08 +02:00
|
|
|
|
const struct Prf_UsrFigures *UsrFigures);
|
2019-03-06 23:52:04 +01:00
|
|
|
|
static void Prf_ShowNumMessagesSent (const struct UsrData *UsrDat,
|
2021-10-13 10:42:08 +02:00
|
|
|
|
const struct Prf_UsrFigures *UsrFigures);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
static void Prf_BeginListItem (const char *Title,const char *Icon);
|
2019-03-06 23:52:04 +01:00
|
|
|
|
static void Prf_EndListItem (void);
|
2019-03-06 10:13:39 +01:00
|
|
|
|
static void Prf_PutLinkCalculateFigures (const char *EncryptedUsrCod);
|
2015-03-14 18:41:01 +01:00
|
|
|
|
|
2021-04-17 01:08:48 +02:00
|
|
|
|
static void Prf_ShowRanking (unsigned Rank,unsigned NumUsrs);
|
2015-03-14 18:41:01 +01:00
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
static void Prf_GetFirstClickFromLogAndStoreAsUsrFigure (long UsrCod);
|
|
|
|
|
static void Prf_GetNumClicksAndStoreAsUsrFigure (long UsrCod);
|
2021-10-07 01:21:23 +02:00
|
|
|
|
static void Prf_GetNumTimelinePubsAndStoreAsUsrFigure (long UsrCod);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
static void Prf_GetNumFileViewsAndStoreAsUsrFigure (long UsrCod);
|
2019-03-06 10:13:39 +01:00
|
|
|
|
static void Prf_GetNumForumPostsAndStoreAsUsrFigure (long UsrCod);
|
|
|
|
|
static void Prf_GetNumMessagesSentAndStoreAsUsrFigure (long UsrCod);
|
2015-03-14 18:41:01 +01:00
|
|
|
|
|
2021-10-13 10:42:08 +02:00
|
|
|
|
static void Prf_ResetUsrFigures (struct Prf_UsrFigures *UsrFigures);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
2015-03-16 17:46:32 +01:00
|
|
|
|
static void Prf_GetAndShowRankingFigure (const char *FieldName);
|
2019-11-20 15:23:52 +01:00
|
|
|
|
static void Prf_ShowUsrInRanking (struct UsrData *UsrDat,unsigned Rank,bool ItsMe);
|
2015-03-16 17:46:32 +01:00
|
|
|
|
|
2016-02-06 13:45:33 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************* Suggest who to follow or request user's profile ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prf_SeeSocialProfiles (void)
|
|
|
|
|
{
|
|
|
|
|
if (Gbl.Usrs.Me.Logged)
|
2017-02-16 20:22:13 +01:00
|
|
|
|
Fol_SuggestUsrsToFollowMainZone ();
|
2016-02-06 13:45:33 +01:00
|
|
|
|
else
|
|
|
|
|
Prf_RequestUserProfile ();
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Get public profile URL ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2018-10-18 02:02:32 +02:00
|
|
|
|
char *Prf_GetURLPublicProfile (char URL[Cns_MAX_BYTES_WWW + 1],
|
2021-02-15 22:49:44 +01:00
|
|
|
|
const char *NickWithoutArr)
|
2015-03-14 17:39:04 +01:00
|
|
|
|
{
|
2018-12-08 16:43:13 +01:00
|
|
|
|
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
|
|
|
|
/***** Build URL using nickname *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (URL,Cns_MAX_BYTES_WWW + 1,"%s/%s?usr=@%s",
|
|
|
|
|
Cfg_URL_SWAD_CGI,Lan_STR_LANG_ID[Gbl.Prefs.Language],
|
2021-02-15 22:49:44 +01:00
|
|
|
|
NickWithoutArr);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
|
|
|
|
return URL;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-29 00:41:52 +01:00
|
|
|
|
/*****************************************************************************/
|
2017-02-17 01:59:58 +01:00
|
|
|
|
/******************** Put link to view my public profile *********************/
|
2016-01-29 00:41:52 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-02-17 01:59:58 +01:00
|
|
|
|
void Prf_PutLinkMyPublicProfile (void)
|
2016-01-29 00:41:52 +01:00
|
|
|
|
{
|
2017-02-17 01:59:58 +01:00
|
|
|
|
extern const char *Txt_My_public_profile;
|
2016-01-29 00:41:52 +01:00
|
|
|
|
|
2019-01-12 03:00:59 +01:00
|
|
|
|
Lay_PutContextualLinkIconText (ActSeeOthPubPrf,NULL,
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EnUsrCod,
|
2021-12-22 00:20:06 +01:00
|
|
|
|
"user-circle.svg",Ico_BLACK,
|
2021-12-22 18:54:43 +01:00
|
|
|
|
Txt_My_public_profile,NULL);
|
2017-02-17 01:59:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Put link to request another user's profile ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prf_PutLinkRequestAnotherUserProfile (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Another_user_s_profile;
|
|
|
|
|
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Lay_PutContextualLinkIconText (ActReqOthPubPrf,NULL,
|
|
|
|
|
NULL,NULL,
|
2021-12-22 00:20:06 +01:00
|
|
|
|
"user-circle.svg",Ico_BLACK,
|
2021-12-22 18:54:43 +01:00
|
|
|
|
Txt_Another_user_s_profile,NULL);
|
2016-01-29 00:41:52 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Request a user's profile *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prf_RequestUserProfile (void)
|
2015-03-14 18:41:01 +01:00
|
|
|
|
{
|
2019-03-12 21:25:55 +01:00
|
|
|
|
extern const char *Hlp_START_Profiles_view_public_profile;
|
2017-04-03 10:20:09 +02:00
|
|
|
|
extern const char *Txt_Another_user_s_profile;
|
2019-02-22 21:47:50 +01:00
|
|
|
|
extern const char *The_ClassFormInBox[The_NUM_THEMES];
|
2022-03-10 00:32:53 +01:00
|
|
|
|
extern const char *The_ClassInput[The_NUM_THEMES];
|
2017-04-03 10:20:09 +02:00
|
|
|
|
extern const char *Txt_Nickname;
|
|
|
|
|
extern const char *Txt_Continue;
|
2021-10-21 20:33:55 +02:00
|
|
|
|
char NickWithArr[Nck_MAX_BYTES_NICK_WITH_ARROBA + 1];
|
2017-04-03 10:20:09 +02:00
|
|
|
|
|
2016-01-28 19:58:32 +01:00
|
|
|
|
if (Gbl.Usrs.Me.Logged)
|
2017-02-17 01:59:58 +01:00
|
|
|
|
{
|
2019-10-24 09:46:20 +02:00
|
|
|
|
/***** Contextual menu *****/
|
|
|
|
|
Mnu_ContextMenuBegin ();
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Prf_PutLinkMyPublicProfile (); // My public profile
|
|
|
|
|
Fol_PutLinkWhoToFollow (); // Users to follow
|
2019-10-24 09:46:20 +02:00
|
|
|
|
Mnu_ContextMenuEnd ();
|
2017-02-17 01:59:58 +01:00
|
|
|
|
}
|
2016-01-27 22:31:36 +01:00
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin form *****/
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActSeeOthPubPrf);
|
2015-04-11 23:46:21 +02:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Begin box *****/
|
|
|
|
|
Box_BoxBegin (NULL,Txt_Another_user_s_profile,
|
|
|
|
|
NULL,NULL,
|
|
|
|
|
Hlp_START_Profiles_view_public_profile,Box_NOT_CLOSABLE);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Form to request user's @nickname *****/
|
|
|
|
|
/* By default, the nickname is filled with my nickname
|
|
|
|
|
If no user logged ==> the nickname is empty */
|
|
|
|
|
HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
|
|
|
|
|
HTM_TxtColonNBSP (Txt_Nickname);
|
2019-11-04 01:29:46 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
snprintf (NickWithArr,sizeof (NickWithArr),"@%s",
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.Nickname);
|
2021-09-30 20:11:00 +02:00
|
|
|
|
HTM_INPUT_TEXT ("usr",sizeof (NickWithArr) - 1,NickWithArr,
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
2022-03-10 00:32:53 +01:00
|
|
|
|
"size=\"18\" class=\"%s\" required=\"required\"",
|
|
|
|
|
The_ClassInput[Gbl.Prefs.Theme]);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_LABEL_End ();
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Send button and end box *****/
|
|
|
|
|
Box_BoxWithButtonEnd (Btn_CONFIRM_BUTTON,Txt_Continue);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
2015-04-11 23:46:21 +02:00
|
|
|
|
/***** End form *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2015-03-14 17:39:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-17 01:59:58 +01:00
|
|
|
|
/*****************************************************************************/
|
2017-02-17 06:32:57 +01:00
|
|
|
|
/******************** Get user and show a user's profile *********************/
|
2017-02-17 01:59:58 +01:00
|
|
|
|
/*****************************************************************************/
|
2017-02-17 06:32:57 +01:00
|
|
|
|
// Gbl.Usrs.Other.UsrDat.UsrCod may be already taken. If not ==> try to get it
|
2017-02-17 01:59:58 +01:00
|
|
|
|
|
2017-02-17 06:32:57 +01:00
|
|
|
|
void Prf_GetUsrDatAndShowUserProfile (void)
|
2017-02-17 01:59:58 +01:00
|
|
|
|
{
|
2021-03-04 17:47:08 +01:00
|
|
|
|
struct Tml_Timeline Timeline;
|
2017-04-03 10:20:09 +02:00
|
|
|
|
bool ProfileShown = false;
|
|
|
|
|
|
2017-02-17 06:32:57 +01:00
|
|
|
|
/***** Get user's data *****/
|
|
|
|
|
if (Gbl.Usrs.Other.UsrDat.UsrCod <= 0)
|
|
|
|
|
Usr_GetParamOtherUsrCodEncryptedAndGetListIDs ();
|
2017-02-17 01:59:58 +01:00
|
|
|
|
|
2017-02-17 06:32:57 +01:00
|
|
|
|
/***** Show profile and timeline *****/
|
2021-04-24 15:10:07 +02:00
|
|
|
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,
|
|
|
|
|
Usr_DONT_GET_PREFS,
|
|
|
|
|
Usr_DONT_GET_ROLE_IN_CURRENT_CRS))
|
2017-02-17 06:32:57 +01:00
|
|
|
|
/* Show profile */
|
2017-04-03 10:20:09 +02:00
|
|
|
|
if (Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat))
|
2017-02-17 06:32:57 +01:00
|
|
|
|
{
|
2017-04-03 10:20:09 +02:00
|
|
|
|
ProfileShown = true;
|
|
|
|
|
|
|
|
|
|
if (Gbl.Usrs.Me.Logged) // Timeline visible only by logged users
|
|
|
|
|
{
|
2020-04-11 00:57:25 +02:00
|
|
|
|
/* Reset timeline context */
|
2021-03-04 17:47:08 +01:00
|
|
|
|
Tml_ResetTimeline (&Timeline);
|
2020-04-11 00:57:25 +02:00
|
|
|
|
|
2017-04-03 10:20:09 +02:00
|
|
|
|
/* Show timeline */
|
2021-11-12 01:12:15 +01:00
|
|
|
|
HTM_SECTION_Begin (Tml_TIMELINE_SECTION_ID);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Tml_ShowTimelineUsr (&Timeline);
|
2019-10-26 01:56:36 +02:00
|
|
|
|
HTM_SECTION_End ();
|
2017-04-03 10:20:09 +02:00
|
|
|
|
}
|
2017-02-17 06:32:57 +01:00
|
|
|
|
}
|
2017-04-03 10:20:09 +02:00
|
|
|
|
|
|
|
|
|
/***** If profile could not be shown... *****/
|
|
|
|
|
if (!ProfileShown)
|
2015-03-14 17:39:04 +01:00
|
|
|
|
{
|
2016-01-14 01:39:02 +01:00
|
|
|
|
/* Show error message */
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_ShowAlertUserNotFoundOrYouDoNotHavePermission ();
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
2017-04-03 10:20:09 +02:00
|
|
|
|
/* Request a user's profile */
|
|
|
|
|
Prf_RequestUserProfile ();
|
2015-03-14 17:39:04 +01:00
|
|
|
|
}
|
2017-04-03 10:20:09 +02:00
|
|
|
|
|
|
|
|
|
/***** If it's not me, mark possible notification as seen *****/
|
2021-10-07 01:21:23 +02:00
|
|
|
|
if (!Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod)) // Not me
|
2021-11-09 12:36:32 +01:00
|
|
|
|
Ntf_DB_MarkNotifAsSeenUsingCod (Ntf_EVENT_FOLLOWER,
|
|
|
|
|
Gbl.Usrs.Other.UsrDat.UsrCod);
|
2017-04-03 10:20:09 +02:00
|
|
|
|
}
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
2015-03-18 02:11:23 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** Show a user's profile ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Return false on error
|
|
|
|
|
|
2016-06-12 19:55:33 +02:00
|
|
|
|
bool Prf_ShowUserProfile (struct UsrData *UsrDat)
|
2015-03-18 02:11:23 +01:00
|
|
|
|
{
|
2015-12-29 14:24:37 +01:00
|
|
|
|
unsigned NumFollowing;
|
|
|
|
|
unsigned NumFollowers;
|
2015-12-29 19:40:38 +01:00
|
|
|
|
bool UsrFollowsMe;
|
|
|
|
|
bool IFollowUsr;
|
2018-10-10 23:56:42 +02:00
|
|
|
|
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
2015-12-29 14:24:37 +01:00
|
|
|
|
|
2017-04-03 10:20:09 +02:00
|
|
|
|
/***** Check if I can see the public profile *****/
|
2019-03-22 15:21:46 +01:00
|
|
|
|
if (Pri_ShowingIsAllowed (UsrDat->BaPrfVisibility,UsrDat))
|
2016-01-27 23:40:16 +01:00
|
|
|
|
{
|
2017-04-03 10:20:09 +02:00
|
|
|
|
if (Gbl.Usrs.Me.Logged)
|
|
|
|
|
{
|
2019-10-24 09:46:20 +02:00
|
|
|
|
/***** Contextual menu *****/
|
|
|
|
|
Mnu_ContextMenuBegin ();
|
2021-07-08 15:00:17 +02:00
|
|
|
|
if (ItsMe)
|
|
|
|
|
Prf_PutLinkRequestAnotherUserProfile (); // Request another user's profile
|
|
|
|
|
else // Not me
|
|
|
|
|
Prf_PutLinkMyPublicProfile (); // My public profile
|
|
|
|
|
Fol_PutLinkWhoToFollow (); // Users to follow
|
2019-10-24 09:46:20 +02:00
|
|
|
|
Mnu_ContextMenuEnd ();
|
2017-04-03 10:20:09 +02:00
|
|
|
|
}
|
2016-01-27 23:40:16 +01:00
|
|
|
|
|
2017-04-03 10:20:09 +02:00
|
|
|
|
/***** Shared record card *****/
|
2018-10-10 23:56:42 +02:00
|
|
|
|
if (!ItsMe && // If not me...
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Gbl.Hierarchy.Level == HieLvl_CRS) // ...and a course is selected
|
2015-03-18 02:11:23 +01:00
|
|
|
|
{
|
|
|
|
|
/* Get user's role in current course */
|
2021-04-24 15:10:07 +02:00
|
|
|
|
UsrDat->Roles.InCurrentCrs = Rol_GetRoleUsrInCrs (UsrDat->UsrCod,
|
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod);
|
2015-03-18 02:11:23 +01:00
|
|
|
|
|
2017-03-30 11:20:06 +02:00
|
|
|
|
/* Get if user has accepted enrolment in current course */
|
2021-11-03 21:31:16 +01:00
|
|
|
|
UsrDat->Accepted = Enr_CheckIfUsrHasAcceptedInCurrentCrs (UsrDat);
|
2015-03-18 02:11:23 +01:00
|
|
|
|
}
|
2017-05-09 20:56:02 +02:00
|
|
|
|
Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_PUBLIC,UsrDat,NULL);
|
2015-03-18 02:11:23 +01:00
|
|
|
|
|
2019-03-22 15:21:46 +01:00
|
|
|
|
/***** Extended profile *****/
|
|
|
|
|
if (Pri_ShowingIsAllowed (UsrDat->ExPrfVisibility,UsrDat))
|
|
|
|
|
{
|
|
|
|
|
/***** Show details of user's profile *****/
|
|
|
|
|
Prf_ShowDetailsUserProfile (UsrDat);
|
|
|
|
|
|
|
|
|
|
/***** Count following and followers *****/
|
|
|
|
|
Fol_GetNumFollow (UsrDat->UsrCod,&NumFollowing,&NumFollowers);
|
|
|
|
|
UsrFollowsMe = false;
|
|
|
|
|
if (NumFollowing)
|
2021-05-07 19:11:57 +02:00
|
|
|
|
UsrFollowsMe = Fol_DB_CheckUsrIsFollowerOf (UsrDat->UsrCod,
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
2019-03-22 15:21:46 +01:00
|
|
|
|
IFollowUsr = false;
|
|
|
|
|
if (NumFollowers)
|
2021-05-07 19:11:57 +02:00
|
|
|
|
IFollowUsr = Fol_DB_CheckUsrIsFollowerOf (Gbl.Usrs.Me.UsrDat.UsrCod,
|
|
|
|
|
UsrDat->UsrCod);
|
2019-03-22 15:21:46 +01:00
|
|
|
|
|
|
|
|
|
/***** Show following and followers *****/
|
|
|
|
|
Fol_ShowFollowingAndFollowers (UsrDat,
|
|
|
|
|
NumFollowing,NumFollowers,
|
|
|
|
|
UsrFollowsMe,IFollowUsr);
|
|
|
|
|
}
|
2015-12-29 14:24:37 +01:00
|
|
|
|
|
2015-03-18 02:11:23 +01:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Change my public profile visibility ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-03-22 15:21:46 +01:00
|
|
|
|
void Prf_ChangeBasicProfileVis (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Get param with public/private photo *****/
|
2019-03-23 13:10:31 +01:00
|
|
|
|
Gbl.Usrs.Me.UsrDat.BaPrfVisibility = Pri_GetParamVisibility ("VisBasPrf",
|
|
|
|
|
Pri_BASIC_PROFILE_ALLOWED_VIS);
|
2019-03-22 15:21:46 +01:00
|
|
|
|
|
2021-10-07 01:21:23 +02:00
|
|
|
|
/***** Store public/private basic profile visibility in database *****/
|
|
|
|
|
Set_DB_UpdateMySettingsAboutBasicProfile ();
|
2019-03-22 15:21:46 +01:00
|
|
|
|
|
|
|
|
|
/***** Show form again *****/
|
2019-03-26 11:53:21 +01:00
|
|
|
|
Set_EditSettings ();
|
2019-03-22 15:21:46 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Prf_ChangeExtendedProfileVis (void)
|
2015-03-14 17:39:04 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get param with public/private photo *****/
|
2019-03-23 13:10:31 +01:00
|
|
|
|
Gbl.Usrs.Me.UsrDat.ExPrfVisibility = Pri_GetParamVisibility ("VisExtPrf",
|
|
|
|
|
Pri_EXTENDED_PROFILE_ALLOWED_VIS);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
2021-10-07 01:21:23 +02:00
|
|
|
|
/***** Store public/private extended profile visibility in database *****/
|
|
|
|
|
Set_DB_UpdateMySettingsAboutExtendedProfile ();
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
|
|
|
|
/***** Show form again *****/
|
2019-03-26 11:53:21 +01:00
|
|
|
|
Set_EditSettings ();
|
2015-03-14 17:39:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Show details of user's profile ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-06-17 11:13:11 +02:00
|
|
|
|
void Prf_ShowDetailsUserProfile (const struct UsrData *UsrDat)
|
2015-03-14 17:39:04 +01:00
|
|
|
|
{
|
2022-03-26 13:12:22 +01:00
|
|
|
|
extern const char *The_Colors[The_NUM_THEMES];
|
2015-03-29 01:06:00 +01:00
|
|
|
|
bool UsrIsBannedFromRanking;
|
2021-10-13 10:42:08 +02:00
|
|
|
|
struct Prf_UsrFigures UsrFigures;
|
2019-03-06 22:07:24 +01:00
|
|
|
|
Rol_Role_t Role;
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
2019-03-06 13:36:16 +01:00
|
|
|
|
/***** Get figures *****/
|
|
|
|
|
Prf_GetUsrFigures (UsrDat->UsrCod,&UsrFigures);
|
|
|
|
|
|
2019-03-06 23:52:04 +01:00
|
|
|
|
/***** Left list *****/
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/* Begin left list */
|
2019-12-13 00:36:01 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"PRF_FIG_LEFT_CONT\"");
|
2022-03-26 13:12:22 +01:00
|
|
|
|
HTM_UL_Begin ("class=\"PRF_FIG_UL DAT_STRONG_%s NOWRAP\"",
|
|
|
|
|
The_Colors[Gbl.Prefs.Theme]);
|
2015-09-28 18:28:29 +02:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/* Time since first click */
|
|
|
|
|
Prf_ShowTimeSinceFirstClick (UsrDat,&UsrFigures);
|
2019-03-06 13:36:16 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/* Number of courses in which the user has a role */
|
2022-03-26 13:12:22 +01:00
|
|
|
|
for (Role = Rol_TCH;
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Role >= Rol_STD;
|
|
|
|
|
Role--)
|
|
|
|
|
Prf_ShowNumCrssWithRole (UsrDat,Role);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/* Number of files currently published */
|
|
|
|
|
Prf_ShowNumFilesCurrentlyPublished (UsrDat);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/* End left list */
|
|
|
|
|
HTM_UL_End ();
|
2019-10-23 20:07:56 +02:00
|
|
|
|
HTM_DIV_End ();
|
2015-12-12 19:47:10 +01:00
|
|
|
|
|
2019-03-06 23:52:04 +01:00
|
|
|
|
/***** Right list *****/
|
2019-12-13 00:36:01 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"PRF_FIG_RIGHT_CONT\"");
|
2015-12-12 19:47:10 +01:00
|
|
|
|
|
2021-11-03 21:31:16 +01:00
|
|
|
|
UsrIsBannedFromRanking = Prf_DB_CheckIfUsrBanned (UsrDat->UsrCod);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
if (!UsrIsBannedFromRanking)
|
|
|
|
|
{
|
|
|
|
|
/* Begin right list */
|
2022-03-26 13:12:22 +01:00
|
|
|
|
HTM_UL_Begin ("class=\"PRF_FIG_UL DAT_STRONG_%s NOWRAP\"",
|
|
|
|
|
The_Colors[Gbl.Prefs.Theme]);
|
2019-03-06 23:52:04 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/* Number of clicks */
|
|
|
|
|
Prf_ShowNumClicks (UsrDat,&UsrFigures);
|
2015-03-29 01:06:00 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/* Number of file views */
|
|
|
|
|
Prf_ShowNumFileViews (UsrDat,&UsrFigures);
|
2019-03-06 23:52:04 +01:00
|
|
|
|
|
2021-10-07 01:21:23 +02:00
|
|
|
|
/* Number of timeline publications */
|
|
|
|
|
Prf_ShowNumTimelinePubs (UsrDat,&UsrFigures);
|
2019-03-06 23:52:04 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/* Number of posts in forums */
|
|
|
|
|
Prf_ShowNumForumPosts (UsrDat,&UsrFigures);
|
2019-03-06 23:52:04 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/* Number of messages sent */
|
|
|
|
|
Prf_ShowNumMessagesSent (UsrDat,&UsrFigures);
|
2019-03-06 23:52:04 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/* End right list */
|
|
|
|
|
HTM_UL_End ();
|
|
|
|
|
}
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
2019-10-23 20:07:56 +02:00
|
|
|
|
HTM_DIV_End ();
|
2015-03-14 17:39:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-06 22:07:24 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Show time since first click in user's profile ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-03-06 23:52:04 +01:00
|
|
|
|
static void Prf_ShowTimeSinceFirstClick (const struct UsrData *UsrDat,
|
2021-10-13 10:42:08 +02:00
|
|
|
|
const struct Prf_UsrFigures *UsrFigures)
|
2019-03-06 22:07:24 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_TIME_Since;
|
2019-03-07 00:42:52 +01:00
|
|
|
|
extern const char *Txt_year;
|
|
|
|
|
extern const char *Txt_years;
|
|
|
|
|
extern const char *Txt_month;
|
|
|
|
|
extern const char *Txt_months;
|
2019-03-06 22:07:24 +01:00
|
|
|
|
extern const char *Txt_day;
|
|
|
|
|
extern const char *Txt_days;
|
|
|
|
|
char IdFirstClickTime[Frm_MAX_BYTES_ID + 1];
|
2019-03-07 00:42:52 +01:00
|
|
|
|
int NumYears;
|
|
|
|
|
int NumMonths;
|
2019-03-06 22:07:24 +01:00
|
|
|
|
|
2019-03-06 23:52:04 +01:00
|
|
|
|
/***** Time since first click *****/
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Prf_BeginListItem (Txt_TIME_Since,"clock.svg");
|
2019-03-06 23:52:04 +01:00
|
|
|
|
|
2019-03-06 22:07:24 +01:00
|
|
|
|
if (UsrFigures->FirstClickTimeUTC)
|
|
|
|
|
{
|
|
|
|
|
/* Create unique id */
|
|
|
|
|
Frm_SetUniqueId (IdFirstClickTime);
|
|
|
|
|
|
2019-11-07 10:24:00 +01:00
|
|
|
|
HTM_SPAN_Begin ("id=\"%s\"",IdFirstClickTime);
|
|
|
|
|
HTM_SPAN_End ();
|
2019-03-06 22:07:24 +01:00
|
|
|
|
if (UsrFigures->NumDays > 0)
|
2019-03-07 00:42:52 +01:00
|
|
|
|
{
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF (" %s","(");
|
2019-03-07 00:42:52 +01:00
|
|
|
|
NumYears = UsrFigures->NumDays / 365;
|
|
|
|
|
if (NumYears)
|
2019-11-11 00:15:44 +01:00
|
|
|
|
HTM_TxtF ("%d %s",
|
|
|
|
|
NumYears,
|
|
|
|
|
(NumYears == 1) ? Txt_year :
|
|
|
|
|
Txt_years);
|
2019-03-07 00:42:52 +01:00
|
|
|
|
else // Less than one year
|
|
|
|
|
{
|
|
|
|
|
NumMonths = UsrFigures->NumDays / 30;
|
|
|
|
|
if (NumMonths)
|
2019-11-11 00:15:44 +01:00
|
|
|
|
HTM_TxtF ("%d %s",
|
|
|
|
|
NumMonths,
|
|
|
|
|
(NumMonths == 1) ? Txt_month :
|
|
|
|
|
Txt_months);
|
2019-03-07 00:42:52 +01:00
|
|
|
|
else // Less than one month
|
2019-11-11 00:15:44 +01:00
|
|
|
|
HTM_TxtF ("%d %s",
|
|
|
|
|
UsrFigures->NumDays,
|
|
|
|
|
(UsrFigures->NumDays == 1) ? Txt_day :
|
|
|
|
|
Txt_days);
|
2019-03-07 00:42:52 +01:00
|
|
|
|
}
|
2019-11-10 13:51:07 +01:00
|
|
|
|
HTM_Txt (")");
|
2019-03-07 00:42:52 +01:00
|
|
|
|
}
|
2019-11-01 23:35:55 +01:00
|
|
|
|
Dat_WriteLocalDateHMSFromUTC (IdFirstClickTime,UsrFigures->FirstClickTimeUTC,
|
2019-11-02 12:10:58 +01:00
|
|
|
|
Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA,
|
2019-11-02 11:45:41 +01:00
|
|
|
|
true,true,false,0x6);
|
2019-03-06 22:07:24 +01:00
|
|
|
|
}
|
|
|
|
|
else // First click time is unknown or user never logged
|
|
|
|
|
/***** Button to fetch and store user's figures *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Prf_PutLinkCalculateFigures (UsrDat->EnUsrCod);
|
2019-03-06 23:52:04 +01:00
|
|
|
|
|
|
|
|
|
Prf_EndListItem ();
|
2019-03-06 22:07:24 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2019-03-06 23:52:04 +01:00
|
|
|
|
/*** Show number of courses in which the user has a role in user's profile ***/
|
2019-03-06 22:07:24 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prf_ShowNumCrssWithRole (const struct UsrData *UsrDat,
|
|
|
|
|
Rol_Role_t Role)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Rol_Icons[Rol_NUM_ROLES];
|
|
|
|
|
extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
|
|
|
|
extern const char *Txt_courses_ABBREVIATION;
|
|
|
|
|
extern const char *Txt_teachers_ABBREVIATION;
|
|
|
|
|
extern const char *Txt_students_ABBREVIATION;
|
|
|
|
|
unsigned NumCrss;
|
|
|
|
|
|
|
|
|
|
/***** Number of courses in which the user has a given role *****/
|
2021-11-03 21:31:16 +01:00
|
|
|
|
NumCrss = Enr_DB_GetNumCrssOfUsrWithARole (UsrDat->UsrCod,Role);
|
2019-03-06 23:52:04 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Prf_BeginListItem (Txt_ROLES_SINGUL_Abc[Role][UsrDat->Sex],Rol_Icons[Role]);
|
2019-03-06 23:52:04 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_TxtF ("%u %s",NumCrss,Txt_courses_ABBREVIATION);
|
2019-03-06 23:52:04 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
if (NumCrss)
|
|
|
|
|
HTM_TxtF (" (%u %s/%u %s)",
|
2021-11-03 21:31:16 +01:00
|
|
|
|
Enr_DB_GetNumUsrsInCrssOfAUsr (UsrDat->UsrCod,Role,
|
2021-07-08 15:00:17 +02:00
|
|
|
|
(1 << Rol_NET) |
|
|
|
|
|
(1 << Rol_TCH)),
|
|
|
|
|
Txt_teachers_ABBREVIATION,
|
2021-11-03 21:31:16 +01:00
|
|
|
|
Enr_DB_GetNumUsrsInCrssOfAUsr (UsrDat->UsrCod,Role,
|
2021-07-08 15:00:17 +02:00
|
|
|
|
(1 << Rol_STD)),
|
|
|
|
|
Txt_students_ABBREVIATION);
|
2019-03-06 23:52:04 +01:00
|
|
|
|
|
|
|
|
|
Prf_EndListItem ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******** Show number of files currently published in user's profile *********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prf_ShowNumFilesCurrentlyPublished (const struct UsrData *UsrDat)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Files_uploaded;
|
|
|
|
|
extern const char *Txt_file;
|
|
|
|
|
extern const char *Txt_files;
|
|
|
|
|
extern const char *Txt_public_FILES;
|
|
|
|
|
unsigned NumFiles;
|
|
|
|
|
unsigned NumPublicFiles;
|
|
|
|
|
|
|
|
|
|
/***** Number of files currently published *****/
|
2021-06-17 13:26:25 +02:00
|
|
|
|
if ((NumFiles = Brw_DB_GetNumFilesUsr (UsrDat->UsrCod)))
|
|
|
|
|
NumPublicFiles = Brw_DB_GetNumPublicFilesUsr (UsrDat->UsrCod);
|
2019-03-06 23:52:04 +01:00
|
|
|
|
else
|
|
|
|
|
NumPublicFiles = 0;
|
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Prf_BeginListItem (Txt_Files_uploaded,"file.svg");
|
2019-03-06 23:52:04 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_TxtF ("%u %s",NumFiles,(NumFiles == 1) ? Txt_file :
|
2021-11-10 19:28:47 +01:00
|
|
|
|
Txt_files);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_NBSP ();
|
|
|
|
|
HTM_Txt ("(");
|
|
|
|
|
HTM_TxtF ("%u %s",NumPublicFiles,Txt_public_FILES);
|
|
|
|
|
HTM_Txt (")");
|
2019-03-06 23:52:04 +01:00
|
|
|
|
|
|
|
|
|
Prf_EndListItem ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Show number of clicks in user's profile ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prf_ShowNumClicks (const struct UsrData *UsrDat,
|
2021-10-13 10:42:08 +02:00
|
|
|
|
const struct Prf_UsrFigures *UsrFigures)
|
2019-03-06 23:52:04 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Clicks;
|
|
|
|
|
extern const char *Txt_clicks;
|
|
|
|
|
extern const char *Txt_day;
|
|
|
|
|
|
|
|
|
|
/***** Number of clicks *****/
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Prf_BeginListItem (Txt_Clicks,"mouse-pointer.svg");
|
2019-03-06 23:52:04 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
if (UsrFigures->NumClicks >= 0)
|
2019-03-06 23:52:04 +01:00
|
|
|
|
{
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_Long (UsrFigures->NumClicks);
|
|
|
|
|
HTM_TxtF (" %s ",Txt_clicks);
|
2021-10-07 23:29:41 +02:00
|
|
|
|
Prf_ShowRanking (Prf_DB_GetUsrRankingFigure (UsrDat->UsrCod,"NumClicks"),
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Prf_DB_GetNumUsrsWithFigure ("NumClicks"));
|
|
|
|
|
if (UsrFigures->NumDays > 0)
|
|
|
|
|
{
|
|
|
|
|
HTM_TxtF (" %s","(");
|
|
|
|
|
HTM_DoubleFewDigits ((double) UsrFigures->NumClicks /
|
|
|
|
|
(double) UsrFigures->NumDays);
|
|
|
|
|
HTM_TxtF ("/%s ",Txt_day);
|
|
|
|
|
Prf_ShowRanking (Prf_DB_GetRankingNumClicksPerDay (UsrDat->UsrCod),
|
|
|
|
|
Prf_DB_GetNumUsrsWithNumClicksPerDay ());
|
|
|
|
|
HTM_Txt (")");
|
|
|
|
|
}
|
2019-03-06 23:52:04 +01:00
|
|
|
|
}
|
2021-07-08 15:00:17 +02:00
|
|
|
|
else // Number of clicks is unknown
|
|
|
|
|
/***** Button to fetch and store user's figures *****/
|
|
|
|
|
Prf_PutLinkCalculateFigures (UsrDat->EnUsrCod);
|
2019-03-06 23:52:04 +01:00
|
|
|
|
|
|
|
|
|
Prf_EndListItem ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Show number of file views in user's profile *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prf_ShowNumFileViews (const struct UsrData *UsrDat,
|
2021-10-13 10:42:08 +02:00
|
|
|
|
const struct Prf_UsrFigures *UsrFigures)
|
2019-03-06 23:52:04 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Downloads;
|
|
|
|
|
extern const char *Txt_download;
|
|
|
|
|
extern const char *Txt_downloads;
|
|
|
|
|
extern const char *Txt_day;
|
|
|
|
|
|
|
|
|
|
/***** Number of file views *****/
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Prf_BeginListItem (Txt_Downloads,"download.svg");
|
2019-03-06 23:52:04 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
if (UsrFigures->NumFileViews >= 0)
|
2019-03-06 23:52:04 +01:00
|
|
|
|
{
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_Long (UsrFigures->NumFileViews);
|
|
|
|
|
HTM_TxtF (" %s ",(UsrFigures->NumFileViews == 1) ? Txt_download :
|
|
|
|
|
Txt_downloads);
|
2021-10-07 23:29:41 +02:00
|
|
|
|
Prf_ShowRanking (Prf_DB_GetUsrRankingFigure (UsrDat->UsrCod,"NumFileViews"),
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Prf_DB_GetNumUsrsWithFigure ("NumFileViews"));
|
|
|
|
|
if (UsrFigures->NumDays > 0)
|
|
|
|
|
{
|
|
|
|
|
HTM_TxtF (" %s","(");
|
|
|
|
|
HTM_DoubleFewDigits ((double) UsrFigures->NumFileViews /
|
|
|
|
|
(double) UsrFigures->NumDays);
|
|
|
|
|
HTM_TxtF ("/%s)",Txt_day);
|
|
|
|
|
}
|
2019-03-06 23:52:04 +01:00
|
|
|
|
}
|
2021-07-08 15:00:17 +02:00
|
|
|
|
else // Number of file views is unknown
|
|
|
|
|
/***** Button to fetch and store user's figures *****/
|
|
|
|
|
Prf_PutLinkCalculateFigures (UsrDat->EnUsrCod);
|
2019-03-06 23:52:04 +01:00
|
|
|
|
|
|
|
|
|
Prf_EndListItem ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-10-07 01:21:23 +02:00
|
|
|
|
/********* Show number of timeline publications in user's profile ************/
|
2019-03-06 23:52:04 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-10-07 01:21:23 +02:00
|
|
|
|
static void Prf_ShowNumTimelinePubs (const struct UsrData *UsrDat,
|
2021-10-13 10:42:08 +02:00
|
|
|
|
const struct Prf_UsrFigures *UsrFigures)
|
2019-03-06 23:52:04 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Timeline;
|
2019-03-12 21:25:55 +01:00
|
|
|
|
extern const char *Txt_TIMELINE_post;
|
|
|
|
|
extern const char *Txt_TIMELINE_posts;
|
2019-03-06 23:52:04 +01:00
|
|
|
|
extern const char *Txt_day;
|
|
|
|
|
|
2021-10-07 01:21:23 +02:00
|
|
|
|
/***** Number of timeline publications *****/
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Prf_BeginListItem (Txt_Timeline,"comment-dots.svg");
|
2019-03-06 23:52:04 +01:00
|
|
|
|
|
2021-10-07 01:21:23 +02:00
|
|
|
|
if (UsrFigures->NumTimelinePubs >= 0)
|
2019-03-06 23:52:04 +01:00
|
|
|
|
{
|
2021-10-07 01:21:23 +02:00
|
|
|
|
HTM_Int (UsrFigures->NumTimelinePubs);
|
|
|
|
|
HTM_TxtF (" %s ",UsrFigures->NumTimelinePubs == 1 ? Txt_TIMELINE_post :
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Txt_TIMELINE_posts);
|
2021-10-07 23:29:41 +02:00
|
|
|
|
Prf_ShowRanking (Prf_DB_GetUsrRankingFigure (UsrDat->UsrCod,"NumSocPub"),
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Prf_DB_GetNumUsrsWithFigure ("NumSocPub"));
|
|
|
|
|
if (UsrFigures->NumDays > 0)
|
|
|
|
|
{
|
|
|
|
|
HTM_TxtF (" %s","(");
|
2021-10-07 01:21:23 +02:00
|
|
|
|
HTM_DoubleFewDigits ((double) UsrFigures->NumTimelinePubs /
|
2021-07-08 15:00:17 +02:00
|
|
|
|
(double) UsrFigures->NumDays);
|
|
|
|
|
HTM_TxtF ("/%s)",Txt_day);
|
|
|
|
|
}
|
2019-03-06 23:52:04 +01:00
|
|
|
|
}
|
2021-10-07 01:21:23 +02:00
|
|
|
|
else // Number of timeline publications is unknown
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Button to fetch and store user's figures *****/
|
|
|
|
|
Prf_PutLinkCalculateFigures (UsrDat->EnUsrCod);
|
2019-03-06 23:52:04 +01:00
|
|
|
|
|
|
|
|
|
Prf_EndListItem ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-10-07 01:21:23 +02:00
|
|
|
|
/********** Show number of timeline publications in user's profile ***********/
|
2019-03-06 23:52:04 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prf_ShowNumForumPosts (const struct UsrData *UsrDat,
|
2021-10-13 10:42:08 +02:00
|
|
|
|
const struct Prf_UsrFigures *UsrFigures)
|
2019-03-06 23:52:04 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Forums;
|
|
|
|
|
extern const char *Txt_FORUM_post;
|
|
|
|
|
extern const char *Txt_FORUM_posts;
|
|
|
|
|
extern const char *Txt_day;
|
|
|
|
|
|
|
|
|
|
/***** Number of posts in forums *****/
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Prf_BeginListItem (Txt_Forums,"comments.svg");
|
2019-03-06 23:52:04 +01:00
|
|
|
|
|
2021-10-07 01:21:23 +02:00
|
|
|
|
if (UsrFigures->NumForumPosts >= 0)
|
2019-03-06 23:52:04 +01:00
|
|
|
|
{
|
2021-10-07 01:21:23 +02:00
|
|
|
|
HTM_Long (UsrFigures->NumForumPosts);
|
|
|
|
|
HTM_TxtF (" %s ",UsrFigures->NumForumPosts == 1 ? Txt_FORUM_post :
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Txt_FORUM_posts);
|
2021-10-07 23:29:41 +02:00
|
|
|
|
Prf_ShowRanking (Prf_DB_GetUsrRankingFigure (UsrDat->UsrCod,"NumForPst"),
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Prf_DB_GetNumUsrsWithFigure ("NumForPst"));
|
|
|
|
|
if (UsrFigures->NumDays > 0)
|
|
|
|
|
{
|
|
|
|
|
HTM_TxtF (" %s","(");
|
2021-10-07 01:21:23 +02:00
|
|
|
|
HTM_DoubleFewDigits ((double) UsrFigures->NumForumPosts /
|
2021-07-08 15:00:17 +02:00
|
|
|
|
(double) UsrFigures->NumDays);
|
|
|
|
|
HTM_TxtF ("/%s)",Txt_day);
|
|
|
|
|
}
|
2019-03-06 23:52:04 +01:00
|
|
|
|
}
|
2021-07-08 15:00:17 +02:00
|
|
|
|
else // Number of forum posts is unknown
|
|
|
|
|
/***** Button to fetch and store user's figures *****/
|
|
|
|
|
Prf_PutLinkCalculateFigures (UsrDat->EnUsrCod);
|
2019-03-06 23:52:04 +01:00
|
|
|
|
|
|
|
|
|
Prf_EndListItem ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Show number of messages sent in user's profile ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prf_ShowNumMessagesSent (const struct UsrData *UsrDat,
|
2021-10-13 10:42:08 +02:00
|
|
|
|
const struct Prf_UsrFigures *UsrFigures)
|
2019-03-06 23:52:04 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Messages;
|
|
|
|
|
extern const char *Txt_message;
|
|
|
|
|
extern const char *Txt_messages;
|
|
|
|
|
extern const char *Txt_day;
|
|
|
|
|
|
|
|
|
|
/***** Number of messages sent *****/
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Prf_BeginListItem (Txt_Messages,"envelope.svg");
|
2019-03-06 23:52:04 +01:00
|
|
|
|
|
2021-10-07 01:21:23 +02:00
|
|
|
|
if (UsrFigures->NumMessagesSent >= 0)
|
2019-03-06 23:52:04 +01:00
|
|
|
|
{
|
2021-10-07 01:21:23 +02:00
|
|
|
|
HTM_Long (UsrFigures->NumMessagesSent);
|
|
|
|
|
HTM_TxtF (" %s ",UsrFigures->NumMessagesSent == 1 ? Txt_message :
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Txt_messages);
|
2021-10-07 23:29:41 +02:00
|
|
|
|
Prf_ShowRanking (Prf_DB_GetUsrRankingFigure (UsrDat->UsrCod,"NumMsgSnt"),
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Prf_DB_GetNumUsrsWithFigure ("NumMsgSnt"));
|
|
|
|
|
if (UsrFigures->NumDays > 0)
|
|
|
|
|
{
|
|
|
|
|
HTM_TxtF (" %s","(");
|
2021-10-07 01:21:23 +02:00
|
|
|
|
HTM_DoubleFewDigits ((double) UsrFigures->NumMessagesSent /
|
2021-07-08 15:00:17 +02:00
|
|
|
|
(double) UsrFigures->NumDays);
|
|
|
|
|
HTM_TxtF ("/%s)",Txt_day);
|
|
|
|
|
}
|
2019-03-06 23:52:04 +01:00
|
|
|
|
}
|
2021-07-08 15:00:17 +02:00
|
|
|
|
else // Number of messages sent is unknown
|
|
|
|
|
/***** Button to fetch and store user's figures *****/
|
|
|
|
|
Prf_PutLinkCalculateFigures (UsrDat->EnUsrCod);
|
2019-03-06 23:52:04 +01:00
|
|
|
|
|
|
|
|
|
Prf_EndListItem ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/****************** Begin/end list item in user's profile ********************/
|
2019-03-06 23:52:04 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
static void Prf_BeginListItem (const char *Title,const char *Icon)
|
2019-03-06 23:52:04 +01:00
|
|
|
|
{
|
2021-12-28 11:46:57 +01:00
|
|
|
|
HTM_LI_Begin ("title=\"%s\" class=\"PRF_FIG_LI\"",Title);
|
|
|
|
|
HTM_DIV_Begin ("class=\"PRF_FIG_ICO\"");
|
2021-12-31 14:51:44 +01:00
|
|
|
|
Ico_PutIcon (Icon,Ico_BLACK,Title,"CONTEXT_ICOx16");
|
2021-12-28 11:46:57 +01:00
|
|
|
|
HTM_DIV_End ();
|
2019-03-06 23:52:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Prf_EndListItem (void)
|
|
|
|
|
{
|
2019-10-26 22:49:13 +02:00
|
|
|
|
HTM_LI_End ();
|
2019-03-06 22:07:24 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-30 18:43:58 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******** Put contextual link with animated icon to update an action *********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-03-06 10:13:39 +01:00
|
|
|
|
static void Prf_PutLinkCalculateFigures (const char *EncryptedUsrCod)
|
2015-12-30 18:43:58 +01:00
|
|
|
|
{
|
2019-11-19 00:17:23 +01:00
|
|
|
|
extern const char *The_ClassFormLinkOutBoxBold[The_NUM_THEMES];
|
2015-12-30 18:43:58 +01:00
|
|
|
|
extern const char *Txt_Calculate;
|
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActCalFig);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Usr_PutParamUsrCodEncrypted (EncryptedUsrCod);
|
2021-12-29 17:26:48 +01:00
|
|
|
|
|
|
|
|
|
/***** Put button to refresh *****/
|
|
|
|
|
HTM_BUTTON_OnSubmit_Begin (Txt_Calculate,
|
2021-07-08 15:00:17 +02:00
|
|
|
|
The_ClassFormLinkOutBoxBold[Gbl.Prefs.Theme],
|
|
|
|
|
NULL);
|
2021-12-29 17:26:48 +01:00
|
|
|
|
Ico_PutIconTextLink ("recycle.svg",Ico_BLACK,Txt_Calculate);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_BUTTON_End ();
|
2021-12-29 17:26:48 +01:00
|
|
|
|
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2015-12-30 18:43:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Select values on user's figures **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-10-13 10:42:08 +02:00
|
|
|
|
void Prf_GetUsrFigures (long UsrCod,struct Prf_UsrFigures *UsrFigures)
|
2015-03-14 17:39:04 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
|
|
|
|
|
/***** Get user's figures from database *****/
|
2021-10-07 01:21:23 +02:00
|
|
|
|
if (Prf_DB_GetUsrFigures (&mysql_res,UsrCod))
|
2015-03-14 17:39:04 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get user's figures *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
2015-10-26 14:35:50 +01:00
|
|
|
|
/* Get first click (row[0] holds first click time UTC) */
|
|
|
|
|
UsrFigures->FirstClickTimeUTC = Dat_GetUNIXTimeFromStr (row[0]);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
|
|
|
|
/* Get number of days since first click (row[1]) */
|
2015-10-26 14:35:50 +01:00
|
|
|
|
if (UsrFigures->FirstClickTimeUTC)
|
2015-03-14 17:39:04 +01:00
|
|
|
|
{
|
|
|
|
|
if (sscanf (row[1],"%d",&UsrFigures->NumDays) != 1)
|
|
|
|
|
UsrFigures->NumDays = -1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
UsrFigures->NumDays = -1;
|
|
|
|
|
|
|
|
|
|
/* Get number of clicks (row[2]) */
|
2021-04-17 01:08:48 +02:00
|
|
|
|
if (sscanf (row[2],"%d",&UsrFigures->NumClicks) != 1)
|
|
|
|
|
UsrFigures->NumClicks = -1;
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
2021-10-07 01:21:23 +02:00
|
|
|
|
/* Get number of timeline publications (row[3]) */
|
|
|
|
|
if (sscanf (row[3],"%d",&UsrFigures->NumTimelinePubs) != 1)
|
|
|
|
|
UsrFigures->NumTimelinePubs = -1;
|
2019-03-06 10:13:39 +01:00
|
|
|
|
|
|
|
|
|
/* Get number of file views (row[4]) */
|
2021-04-17 01:08:48 +02:00
|
|
|
|
if (sscanf (row[4],"%d",&UsrFigures->NumFileViews) != 1)
|
|
|
|
|
UsrFigures->NumFileViews = -1;
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
2019-03-06 10:13:39 +01:00
|
|
|
|
/* Get number of forum posts (row[5]) */
|
2021-10-07 01:21:23 +02:00
|
|
|
|
if (sscanf (row[5],"%d",&UsrFigures->NumForumPosts) != 1)
|
|
|
|
|
UsrFigures->NumForumPosts = -1;
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
2019-03-06 10:13:39 +01:00
|
|
|
|
/* Get number of messages sent (row[6]) */
|
2021-10-07 01:21:23 +02:00
|
|
|
|
if (sscanf (row[6],"%d",&UsrFigures->NumMessagesSent) != 1)
|
|
|
|
|
UsrFigures->NumMessagesSent = -1;
|
2015-03-14 17:39:04 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
/***** Return special user's figures indicating "not present" *****/
|
|
|
|
|
Prf_ResetUsrFigures (UsrFigures);
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-17 00:54:03 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Show position in ranking **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-04-17 01:08:48 +02:00
|
|
|
|
static void Prf_ShowRanking (unsigned Rank,unsigned NumUsrs)
|
2015-03-17 00:54:03 +01:00
|
|
|
|
{
|
2019-11-18 20:12:10 +01:00
|
|
|
|
extern const char *The_ClassFormLinkOutBox[The_NUM_THEMES];
|
2015-03-17 00:54:03 +01:00
|
|
|
|
extern const char *Txt_of_PART_OF_A_TOTAL;
|
2019-12-30 22:32:06 +01:00
|
|
|
|
char *Title;
|
2015-03-17 00:54:03 +01:00
|
|
|
|
|
|
|
|
|
/***** Rank in form to go to ranking *****/
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActSeeUseGbl);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Sco_PutParamScope ("ScopeSta",HieLvl_SYS);
|
|
|
|
|
Par_PutHiddenParamUnsigned (NULL,"FigureType",(unsigned) Fig_USERS_RANKING);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
if (asprintf (&Title,"#%u %s %u",
|
|
|
|
|
Rank,Txt_of_PART_OF_A_TOTAL,NumUsrs) < 0)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2021-12-26 22:39:16 +01:00
|
|
|
|
HTM_BUTTON_OnSubmit_Begin (Title,The_ClassFormLinkOutBox[Gbl.Prefs.Theme],
|
|
|
|
|
NULL);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
free (Title);
|
|
|
|
|
HTM_TxtF ("#%u",Rank);
|
|
|
|
|
HTM_BUTTON_End ();
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2015-03-17 00:54:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
/*****************************************************************************/
|
2016-10-03 18:16:05 +02:00
|
|
|
|
/********** Calculate user's figures and show user's profile again ***********/
|
2015-03-14 17:39:04 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-10-03 18:16:05 +02:00
|
|
|
|
void Prf_CalculateFigures (void)
|
2015-03-14 17:39:04 +01:00
|
|
|
|
{
|
2021-10-13 10:42:08 +02:00
|
|
|
|
struct Prf_UsrFigures UsrFigures;
|
2016-10-03 18:16:05 +02:00
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
/***** Get user's code *****/
|
2016-01-25 14:40:57 +01:00
|
|
|
|
Usr_GetParamOtherUsrCodEncryptedAndGetListIDs ();
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
|
|
|
|
/***** Get first click time from log and store as user's figure *****/
|
2016-10-03 18:16:05 +02:00
|
|
|
|
Prf_GetUsrFigures (Gbl.Usrs.Other.UsrDat.UsrCod,&UsrFigures);
|
|
|
|
|
Prf_GetAndStoreAllUsrFigures (Gbl.Usrs.Other.UsrDat.UsrCod,&UsrFigures);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
|
|
|
|
/***** Show user's profile again *****/
|
2015-03-18 02:11:23 +01:00
|
|
|
|
Prf_GetUsrDatAndShowUserProfile ();
|
2015-03-14 17:39:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-03 18:16:05 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*** Calculate and store all figures in user's profile not yet calculated ****/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Return true if any figure has been calculated and stored
|
|
|
|
|
|
2021-10-13 10:42:08 +02:00
|
|
|
|
bool Prf_GetAndStoreAllUsrFigures (long UsrCod,struct Prf_UsrFigures *UsrFigures)
|
2016-10-03 18:16:05 +02:00
|
|
|
|
{
|
|
|
|
|
bool UsrFiguresModified = false;
|
|
|
|
|
|
|
|
|
|
if (!UsrFigures->FirstClickTimeUTC)
|
|
|
|
|
{
|
|
|
|
|
/***** Get first click time from log and store as user's figure *****/
|
|
|
|
|
Prf_GetFirstClickFromLogAndStoreAsUsrFigure (UsrCod);
|
|
|
|
|
UsrFiguresModified = true;
|
|
|
|
|
}
|
|
|
|
|
if (UsrFigures->NumClicks < 0)
|
|
|
|
|
{
|
|
|
|
|
/***** Get number of clicks and store as user's figure *****/
|
|
|
|
|
Prf_GetNumClicksAndStoreAsUsrFigure (UsrCod);
|
|
|
|
|
UsrFiguresModified = true;
|
|
|
|
|
}
|
2021-10-07 01:21:23 +02:00
|
|
|
|
if (UsrFigures->NumTimelinePubs < 0)
|
2019-03-06 10:13:39 +01:00
|
|
|
|
{
|
2021-10-07 01:21:23 +02:00
|
|
|
|
/***** Get number of timeline publications and store as user's figure *****/
|
|
|
|
|
Prf_GetNumTimelinePubsAndStoreAsUsrFigure (UsrCod);
|
2019-03-06 10:13:39 +01:00
|
|
|
|
UsrFiguresModified = true;
|
|
|
|
|
}
|
2016-10-03 18:16:05 +02:00
|
|
|
|
if (UsrFigures->NumFileViews < 0)
|
|
|
|
|
{
|
|
|
|
|
/***** Get number of file views and store as user's figure *****/
|
|
|
|
|
Prf_GetNumFileViewsAndStoreAsUsrFigure (UsrCod);
|
|
|
|
|
UsrFiguresModified = true;
|
|
|
|
|
}
|
2021-10-07 01:21:23 +02:00
|
|
|
|
if (UsrFigures->NumForumPosts < 0)
|
2016-10-03 18:16:05 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Get number of forum posts and store as user's figure *****/
|
2019-03-06 10:13:39 +01:00
|
|
|
|
Prf_GetNumForumPostsAndStoreAsUsrFigure (UsrCod);
|
2016-10-03 18:16:05 +02:00
|
|
|
|
UsrFiguresModified = true;
|
|
|
|
|
}
|
2021-10-07 01:21:23 +02:00
|
|
|
|
if (UsrFigures->NumMessagesSent < 0)
|
2016-10-03 18:16:05 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Get number of messages sent and store as user's figure *****/
|
2019-03-06 10:13:39 +01:00
|
|
|
|
Prf_GetNumMessagesSentAndStoreAsUsrFigure (UsrCod);
|
2016-10-03 18:16:05 +02:00
|
|
|
|
UsrFiguresModified = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return UsrFiguresModified;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*** Get first click of a user from log table and store in user's figures ****/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prf_GetFirstClickFromLogAndStoreAsUsrFigure (long UsrCod)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2021-10-13 10:42:08 +02:00
|
|
|
|
struct Prf_UsrFigures UsrFigures;
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
2021-10-29 00:32:19 +02:00
|
|
|
|
if (Usr_DB_ChkIfUsrCodExists (UsrCod))
|
2015-03-14 17:39:04 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Reset user's figures *****/
|
|
|
|
|
Prf_ResetUsrFigures (&UsrFigures);
|
|
|
|
|
|
|
|
|
|
/***** Get first click from log table *****/
|
2021-10-07 01:21:23 +02:00
|
|
|
|
if (Log_DB_GetUsrFirstClick (&mysql_res,UsrCod))
|
2015-03-14 17:39:04 +01:00
|
|
|
|
{
|
|
|
|
|
/* Get first click */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
2015-10-26 14:35:50 +01:00
|
|
|
|
/* Get first click (row[0] holds the start date-time UTC) */
|
2015-03-14 17:39:04 +01:00
|
|
|
|
if (row[0]) // It is NULL when user never logged
|
2015-10-26 14:35:50 +01:00
|
|
|
|
UsrFigures.FirstClickTimeUTC = Dat_GetUNIXTimeFromStr (row[0]);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
}
|
|
|
|
|
/* Free structure that stores the query result */
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
/***** Update first click time in user's figures *****/
|
2021-07-08 15:00:17 +02:00
|
|
|
|
if (Prf_DB_CheckIfUsrFiguresExists (UsrCod))
|
2021-10-07 01:21:23 +02:00
|
|
|
|
Prf_DB_UpdateFirstClickTimeUsr (UsrCod,UsrFigures.FirstClickTimeUTC);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
else // User entry does not exist
|
2021-10-07 23:29:41 +02:00
|
|
|
|
Prf_DB_CreateUsrFigures (UsrCod,&UsrFigures,false);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/* Get number of clicks of a user from log table and store in user's figures */
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prf_GetNumClicksAndStoreAsUsrFigure (long UsrCod)
|
|
|
|
|
{
|
2021-10-13 10:42:08 +02:00
|
|
|
|
struct Prf_UsrFigures UsrFigures;
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
2021-10-29 00:32:19 +02:00
|
|
|
|
if (Usr_DB_ChkIfUsrCodExists (UsrCod))
|
2015-03-14 17:39:04 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Reset user's figures *****/
|
|
|
|
|
Prf_ResetUsrFigures (&UsrFigures);
|
|
|
|
|
|
|
|
|
|
/***** Get number of clicks from database *****/
|
2021-10-07 01:21:23 +02:00
|
|
|
|
UsrFigures.NumClicks = (int) Log_DB_GetUsrNumClicks (UsrCod);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
|
|
|
|
/***** Update number of clicks in user's figures *****/
|
2021-07-08 15:00:17 +02:00
|
|
|
|
if (Prf_DB_CheckIfUsrFiguresExists (UsrCod))
|
2021-10-07 01:21:23 +02:00
|
|
|
|
Prf_DB_UpdateNumClicksUsr (UsrCod,UsrFigures.NumClicks);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
else // User entry does not exist
|
2021-10-07 23:29:41 +02:00
|
|
|
|
Prf_DB_CreateUsrFigures (UsrCod,&UsrFigures,false);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
}
|
2019-03-06 10:13:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-10-07 01:21:23 +02:00
|
|
|
|
/**** Get number of timeline pubs. from a user and store in user's figures ***/
|
2019-03-06 10:13:39 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-10-07 01:21:23 +02:00
|
|
|
|
static void Prf_GetNumTimelinePubsAndStoreAsUsrFigure (long UsrCod)
|
2019-03-06 10:13:39 +01:00
|
|
|
|
{
|
2021-10-13 10:42:08 +02:00
|
|
|
|
struct Prf_UsrFigures UsrFigures;
|
2019-03-06 10:13:39 +01:00
|
|
|
|
|
2021-10-29 00:32:19 +02:00
|
|
|
|
if (Usr_DB_ChkIfUsrCodExists (UsrCod))
|
2019-03-06 10:13:39 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Reset user's figures *****/
|
|
|
|
|
Prf_ResetUsrFigures (&UsrFigures);
|
|
|
|
|
|
|
|
|
|
/***** Get number of forum posts from database *****/
|
2021-10-07 01:21:23 +02:00
|
|
|
|
UsrFigures.NumTimelinePubs = (int) Tml_DB_GetNumPubsUsr (UsrCod);
|
2019-03-06 10:13:39 +01:00
|
|
|
|
|
2021-10-07 01:21:23 +02:00
|
|
|
|
/***** Update number of timeline publications in user's figures *****/
|
2021-07-08 15:00:17 +02:00
|
|
|
|
if (Prf_DB_CheckIfUsrFiguresExists (UsrCod))
|
2021-10-07 01:21:23 +02:00
|
|
|
|
Prf_DB_UpdateNumTimelinePubsUsr (UsrCod,UsrFigures.NumTimelinePubs);
|
2019-03-06 10:13:39 +01:00
|
|
|
|
else // User entry does not exist
|
2021-10-07 23:29:41 +02:00
|
|
|
|
Prf_DB_CreateUsrFigures (UsrCod,&UsrFigures,false);
|
2019-03-06 10:13:39 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**** Get number of file views sent by a user and store in user's figures ****/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Prf_GetNumFileViewsAndStoreAsUsrFigure (long UsrCod)
|
|
|
|
|
{
|
2021-10-13 10:42:08 +02:00
|
|
|
|
struct Prf_UsrFigures UsrFigures;
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
2021-10-29 00:32:19 +02:00
|
|
|
|
if (Usr_DB_ChkIfUsrCodExists (UsrCod))
|
2015-03-14 17:39:04 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Reset user's figures *****/
|
|
|
|
|
Prf_ResetUsrFigures (&UsrFigures);
|
|
|
|
|
|
|
|
|
|
/***** Get number of file views from database *****/
|
2021-06-17 13:26:25 +02:00
|
|
|
|
UsrFigures.NumFileViews = (long) Brw_DB_GetNumFileViewsUsr (UsrCod);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
|
|
|
|
/***** Update number of file views in user's figures *****/
|
2021-07-08 15:00:17 +02:00
|
|
|
|
if (Prf_DB_CheckIfUsrFiguresExists (UsrCod))
|
2021-10-07 01:21:23 +02:00
|
|
|
|
Prf_DB_UpdateNumFileViewsUsr (UsrCod,UsrFigures.NumFileViews);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
else // User entry does not exist
|
2021-10-07 23:29:41 +02:00
|
|
|
|
Prf_DB_CreateUsrFigures (UsrCod,&UsrFigures,false);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
}
|
2019-03-06 10:13:39 +01:00
|
|
|
|
}
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**** Get number of forum posts sent by a user and store in user's figures ***/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-03-06 10:13:39 +01:00
|
|
|
|
static void Prf_GetNumForumPostsAndStoreAsUsrFigure (long UsrCod)
|
2015-03-14 17:39:04 +01:00
|
|
|
|
{
|
2021-10-13 10:42:08 +02:00
|
|
|
|
struct Prf_UsrFigures UsrFigures;
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
2021-10-29 00:32:19 +02:00
|
|
|
|
if (Usr_DB_ChkIfUsrCodExists (UsrCod))
|
2015-03-14 17:39:04 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Reset user's figures *****/
|
|
|
|
|
Prf_ResetUsrFigures (&UsrFigures);
|
|
|
|
|
|
|
|
|
|
/***** Get number of forum posts from database *****/
|
2021-10-07 01:21:23 +02:00
|
|
|
|
UsrFigures.NumForumPosts = For_DB_GetNumPostsUsr (UsrCod);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
|
|
|
|
/***** Update number of forum posts in user's figures *****/
|
2021-07-08 15:00:17 +02:00
|
|
|
|
if (Prf_DB_CheckIfUsrFiguresExists (UsrCod))
|
2021-10-07 01:21:23 +02:00
|
|
|
|
Prf_DB_UpdateNumForumPostsUsr (UsrCod,UsrFigures.NumForumPosts);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
else // User entry does not exist
|
2021-10-07 23:29:41 +02:00
|
|
|
|
Prf_DB_CreateUsrFigures (UsrCod,&UsrFigures,false);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
}
|
2019-03-06 10:13:39 +01:00
|
|
|
|
}
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***** Get number of messages sent by a user and store in user's figures *****/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-03-06 10:13:39 +01:00
|
|
|
|
static void Prf_GetNumMessagesSentAndStoreAsUsrFigure (long UsrCod)
|
2015-03-14 17:39:04 +01:00
|
|
|
|
{
|
2021-10-13 10:42:08 +02:00
|
|
|
|
struct Prf_UsrFigures UsrFigures;
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
2021-10-29 00:32:19 +02:00
|
|
|
|
if (Usr_DB_ChkIfUsrCodExists (UsrCod))
|
2015-03-14 17:39:04 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Reset user's figures *****/
|
|
|
|
|
Prf_ResetUsrFigures (&UsrFigures);
|
|
|
|
|
|
|
|
|
|
/***** Get number of messages sent from database *****/
|
2021-10-07 01:21:23 +02:00
|
|
|
|
UsrFigures.NumMessagesSent = (int) Msg_DB_GetNumMsgsSentByUsr (UsrCod);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
|
|
|
|
|
/***** Update number of messages sent in user's figures *****/
|
2021-07-08 15:00:17 +02:00
|
|
|
|
if (Prf_DB_CheckIfUsrFiguresExists (UsrCod))
|
2021-10-07 01:21:23 +02:00
|
|
|
|
Prf_DB_UpdateNumMessagesSentUsr (UsrCod,UsrFigures.NumMessagesSent);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
else // User entry does not exist
|
2021-10-07 23:29:41 +02:00
|
|
|
|
Prf_DB_CreateUsrFigures (UsrCod,&UsrFigures,false);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-28 18:34:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Create user's figures for a new user ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-11-08 00:58:32 +01:00
|
|
|
|
void Prf_CreateNewUsrFigures (long UsrCod,bool CreatingMyOwnAccount)
|
2015-03-28 18:34:08 +01:00
|
|
|
|
{
|
2021-10-13 10:42:08 +02:00
|
|
|
|
struct Prf_UsrFigures UsrFigures;
|
2015-03-28 18:34:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Reset user's figures *****/
|
|
|
|
|
Prf_ResetUsrFigures (&UsrFigures);
|
2021-10-07 01:21:23 +02:00
|
|
|
|
UsrFigures.NumClicks = 0; // set number of clicks to 0
|
|
|
|
|
UsrFigures.NumTimelinePubs = 0; // set number of timeline publications to 0
|
|
|
|
|
UsrFigures.NumFileViews = 0; // set number of file views to 0
|
|
|
|
|
UsrFigures.NumForumPosts = 0; // set number of forum posts to 0
|
|
|
|
|
UsrFigures.NumMessagesSent = 0; // set number of messages sent to 0
|
2015-03-28 18:34:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Create user's figures *****/
|
2021-10-07 23:29:41 +02:00
|
|
|
|
Prf_DB_CreateUsrFigures (UsrCod,&UsrFigures,CreatingMyOwnAccount);
|
2015-03-28 18:34:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Reset values of user's figures ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-10-13 10:42:08 +02:00
|
|
|
|
static void Prf_ResetUsrFigures (struct Prf_UsrFigures *UsrFigures)
|
2015-03-14 17:39:04 +01:00
|
|
|
|
{
|
2015-10-26 14:35:50 +01:00
|
|
|
|
UsrFigures->FirstClickTimeUTC = (time_t) 0; // unknown first click time or user never logged
|
2021-10-07 01:21:23 +02:00
|
|
|
|
UsrFigures->NumDays = -1; // not applicable
|
|
|
|
|
UsrFigures->NumClicks = -1; // unknown number of clicks
|
|
|
|
|
UsrFigures->NumTimelinePubs = -1; // unknown number of timeline publications
|
|
|
|
|
UsrFigures->NumFileViews = -1; // unknown number of file views
|
|
|
|
|
UsrFigures->NumForumPosts = -1; // unknown number of forum posts
|
|
|
|
|
UsrFigures->NumMessagesSent = -1; // unknown number of messages sent
|
2015-03-14 17:39:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-16 14:05:16 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******** Get and show ranking of users attending to number of clicks ********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prf_GetAndShowRankingClicks (void)
|
|
|
|
|
{
|
2015-03-16 17:46:32 +01:00
|
|
|
|
Prf_GetAndShowRankingFigure ("NumClicks");
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-07 01:21:23 +02:00
|
|
|
|
void Prf_GetAndShowRankingTimelinePubs (void)
|
2019-03-06 13:14:40 +01:00
|
|
|
|
{
|
|
|
|
|
Prf_GetAndShowRankingFigure ("NumSocPub");
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-16 17:46:32 +01:00
|
|
|
|
void Prf_GetAndShowRankingFileViews (void)
|
|
|
|
|
{
|
|
|
|
|
Prf_GetAndShowRankingFigure ("NumFileViews");
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-07 01:21:23 +02:00
|
|
|
|
void Prf_GetAndShowRankingForPsts (void)
|
2015-03-16 17:46:32 +01:00
|
|
|
|
{
|
|
|
|
|
Prf_GetAndShowRankingFigure ("NumForPst");
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-07 01:21:23 +02:00
|
|
|
|
void Prf_GetAndShowRankingMsgsSnt (void)
|
2015-03-16 17:46:32 +01:00
|
|
|
|
{
|
|
|
|
|
Prf_GetAndShowRankingFigure ("NumMsgSnt");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Prf_GetAndShowRankingFigure (const char *FieldName)
|
|
|
|
|
{
|
2018-11-01 19:23:52 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
2021-10-07 23:29:41 +02:00
|
|
|
|
unsigned NumUsrs;
|
2018-11-01 19:23:52 +01:00
|
|
|
|
|
2015-03-16 14:05:16 +01:00
|
|
|
|
/***** Get ranking from database *****/
|
2021-10-07 23:29:41 +02:00
|
|
|
|
NumUsrs = Prf_DB_GetRankingFigure (&mysql_res,FieldName);
|
2018-11-01 19:23:52 +01:00
|
|
|
|
|
|
|
|
|
Prf_ShowRankingFigure (&mysql_res,NumUsrs);
|
2015-03-23 10:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-01 19:23:52 +01:00
|
|
|
|
void Prf_ShowRankingFigure (MYSQL_RES **mysql_res,unsigned NumUsrs)
|
2015-03-23 10:35:15 +01:00
|
|
|
|
{
|
2022-03-25 00:48:40 +01:00
|
|
|
|
extern const char *The_Colors[The_NUM_THEMES];
|
2015-03-23 10:35:15 +01:00
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumUsr;
|
|
|
|
|
unsigned Rank;
|
|
|
|
|
struct UsrData UsrDat;
|
2019-11-20 15:23:52 +01:00
|
|
|
|
bool ItsMe;
|
2015-03-23 10:35:15 +01:00
|
|
|
|
long FigureHigh = LONG_MAX;
|
|
|
|
|
long Figure;
|
|
|
|
|
|
2015-03-16 14:05:16 +01:00
|
|
|
|
if (NumUsrs)
|
|
|
|
|
{
|
|
|
|
|
/***** Initialize structure with user's data *****/
|
|
|
|
|
Usr_UsrDataConstructor (&UsrDat);
|
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_Begin (NULL);
|
2015-03-16 14:05:16 +01:00
|
|
|
|
|
2022-03-19 02:05:53 +01:00
|
|
|
|
for (NumUsr = 1, Rank = 1;
|
2021-07-08 15:00:17 +02:00
|
|
|
|
NumUsr <= NumUsrs;
|
2022-03-24 01:18:19 +01:00
|
|
|
|
NumUsr++, The_ChangeRowColor ())
|
2015-03-16 17:46:32 +01:00
|
|
|
|
{
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Get user and number of clicks *****/
|
|
|
|
|
row = mysql_fetch_row (*mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get user's code (row[0]) */
|
|
|
|
|
UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
|
|
|
Usr_GetAllUsrDataFromUsrCod (&UsrDat,
|
|
|
|
|
Usr_DONT_GET_PREFS,
|
|
|
|
|
Usr_DONT_GET_ROLE_IN_CURRENT_CRS);
|
2021-11-18 22:06:06 +01:00
|
|
|
|
ItsMe = Usr_ItsMe (UsrDat.UsrCod);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
|
|
|
|
|
/* Get figure (row[1]) */
|
|
|
|
|
if (sscanf (row[1],"%ld",&Figure) != 1)
|
|
|
|
|
Err_ShowErrorAndExit ("Error reading user's figure.");
|
|
|
|
|
|
|
|
|
|
if (Figure < FigureHigh)
|
|
|
|
|
{
|
|
|
|
|
Rank = NumUsr;
|
|
|
|
|
FigureHigh = Figure;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Show row *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
Prf_ShowUsrInRanking (&UsrDat,Rank,ItsMe);
|
2022-03-25 00:48:40 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"RM %s_%s %s\"",
|
|
|
|
|
ItsMe ? "DAT_SMALL_STRONG" :
|
|
|
|
|
"DAT_SMALL",
|
|
|
|
|
The_Colors[Gbl.Prefs.Theme],
|
2022-03-19 02:05:53 +01:00
|
|
|
|
The_GetColorRows ());
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_Long (Figure);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
HTM_TR_End ();
|
2015-03-16 17:46:32 +01:00
|
|
|
|
}
|
2015-03-16 14:05:16 +01:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_End ();
|
2015-03-16 14:05:16 +01:00
|
|
|
|
|
|
|
|
|
/***** Free memory used for user's data *****/
|
|
|
|
|
Usr_UsrDataDestructor (&UsrDat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
2018-11-01 19:23:52 +01:00
|
|
|
|
DB_FreeMySQLResult (mysql_res);
|
2015-03-16 14:05:16 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**** Get and show ranking of users attending to number of clicks per day ****/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Prf_GetAndShowRankingClicksPerDay (void)
|
|
|
|
|
{
|
2022-03-25 00:48:40 +01:00
|
|
|
|
extern const char *The_Colors[The_NUM_THEMES];
|
2015-03-16 14:05:16 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2018-11-01 19:23:52 +01:00
|
|
|
|
unsigned NumUsrs = 0; // Initialized to avoid warning
|
2015-03-16 14:05:16 +01:00
|
|
|
|
unsigned NumUsr;
|
2015-03-16 17:46:32 +01:00
|
|
|
|
unsigned Rank;
|
2015-03-16 14:05:16 +01:00
|
|
|
|
struct UsrData UsrDat;
|
2019-11-20 15:23:52 +01:00
|
|
|
|
bool ItsMe;
|
2019-11-11 00:15:44 +01:00
|
|
|
|
double NumClicksPerDayHigh = (double) LONG_MAX;
|
|
|
|
|
double NumClicksPerDay;
|
2015-03-16 14:05:16 +01:00
|
|
|
|
|
|
|
|
|
/***** Get ranking from database *****/
|
2021-10-07 23:29:41 +02:00
|
|
|
|
if ((NumUsrs = Prf_DB_GetRankingClicksPerDay (&mysql_res)))
|
2015-03-16 14:05:16 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Initialize structure with user's data *****/
|
|
|
|
|
Usr_UsrDataConstructor (&UsrDat);
|
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_Begin (NULL);
|
2015-03-16 14:05:16 +01:00
|
|
|
|
|
2022-03-19 02:05:53 +01:00
|
|
|
|
for (NumUsr = 1, Rank = 1;
|
2021-07-08 15:00:17 +02:00
|
|
|
|
NumUsr <= NumUsrs;
|
2022-03-24 01:18:19 +01:00
|
|
|
|
NumUsr++, The_ChangeRowColor ())
|
2015-03-16 17:46:32 +01:00
|
|
|
|
{
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Get user and number of clicks *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get user's code (row[0]) */
|
|
|
|
|
UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
|
|
|
Usr_GetAllUsrDataFromUsrCod (&UsrDat,
|
|
|
|
|
Usr_DONT_GET_PREFS,
|
|
|
|
|
Usr_DONT_GET_ROLE_IN_CURRENT_CRS);
|
2021-11-18 22:06:06 +01:00
|
|
|
|
ItsMe = Usr_ItsMe (UsrDat.UsrCod);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
|
|
|
|
|
/* Get average number of clicks per day (row[1]) */
|
|
|
|
|
NumClicksPerDay = Str_GetDoubleFromStr (row[1]);
|
|
|
|
|
if (NumClicksPerDay < NumClicksPerDayHigh)
|
|
|
|
|
{
|
|
|
|
|
Rank = NumUsr;
|
|
|
|
|
NumClicksPerDayHigh = NumClicksPerDay;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Show row *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
Prf_ShowUsrInRanking (&UsrDat,Rank,ItsMe);
|
2022-03-25 00:48:40 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"RM %s_%s %s\"",
|
|
|
|
|
ItsMe ? "DAT_SMALL_STRONG" :
|
|
|
|
|
"DAT_SMALL",
|
|
|
|
|
The_Colors[Gbl.Prefs.Theme],
|
2022-03-19 02:05:53 +01:00
|
|
|
|
The_GetColorRows ());
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_DoubleFewDigits (NumClicksPerDay);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
HTM_TR_End ();
|
2015-03-16 17:46:32 +01:00
|
|
|
|
}
|
2015-03-16 14:05:16 +01:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_End ();
|
2015-03-16 14:05:16 +01:00
|
|
|
|
|
|
|
|
|
/***** Free memory used for user's data *****/
|
|
|
|
|
Usr_UsrDataDestructor (&UsrDat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
2015-03-16 17:46:32 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Show user's photo and nickname in ranking list ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-11-20 15:23:52 +01:00
|
|
|
|
static void Prf_ShowUsrInRanking (struct UsrData *UsrDat,unsigned Rank,bool ItsMe)
|
2015-03-16 17:46:32 +01:00
|
|
|
|
{
|
2022-03-25 00:48:40 +01:00
|
|
|
|
extern const char *The_Colors[The_NUM_THEMES];
|
2017-02-17 01:59:58 +01:00
|
|
|
|
extern const char *Txt_Another_user_s_profile;
|
2021-12-31 14:51:44 +01:00
|
|
|
|
static const char *ClassPhoto[PhoSha_NUM_SHAPES] =
|
2021-12-01 01:43:13 +01:00
|
|
|
|
{
|
2021-12-31 14:51:44 +01:00
|
|
|
|
[PhoSha_SHAPE_CIRCLE ] = "PHOTOC30x40",
|
|
|
|
|
[PhoSha_SHAPE_ELLIPSE ] = "PHOTOE30x40",
|
|
|
|
|
[PhoSha_SHAPE_OVAL ] = "PHOTOO30x40",
|
|
|
|
|
[PhoSha_SHAPE_RECTANGLE] = "PHOTOR30x40",
|
2021-12-01 01:43:13 +01:00
|
|
|
|
};
|
2019-03-22 15:21:46 +01:00
|
|
|
|
bool Visible = Pri_ShowingIsAllowed (UsrDat->BaPrfVisibility,UsrDat);
|
2015-03-17 14:51:58 +01:00
|
|
|
|
|
2022-03-25 00:48:40 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"RM %s_%s %s\"",
|
|
|
|
|
ItsMe ? "DAT_SMALL_STRONG" :
|
|
|
|
|
"DAT_SMALL",
|
|
|
|
|
The_Colors[Gbl.Prefs.Theme],
|
2022-03-19 02:05:53 +01:00
|
|
|
|
The_GetColorRows ());
|
2021-03-02 10:16:41 +01:00
|
|
|
|
HTM_TxtF ("#%u",Rank);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2015-03-16 17:46:32 +01:00
|
|
|
|
|
2015-03-16 20:26:39 +01:00
|
|
|
|
/***** Check if I can see the public profile *****/
|
2022-03-19 02:05:53 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"RANK_PHOTO %s\"",The_GetColorRows ());
|
2021-03-02 10:16:41 +01:00
|
|
|
|
if (Visible)
|
|
|
|
|
/***** User's photo *****/
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Pho_ShowUsrPhotoIfAllowed (UsrDat,
|
2021-12-02 08:39:18 +01:00
|
|
|
|
ClassPhoto[Gbl.Prefs.PhotoShape],Pho_ZOOM,
|
2021-12-01 01:43:13 +01:00
|
|
|
|
false);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2015-03-17 14:51:58 +01:00
|
|
|
|
|
|
|
|
|
/***** Put form to go to public profile *****/
|
2022-03-25 00:48:40 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"RANK_USR %s_%s %s\"", // Limited width
|
|
|
|
|
ItsMe ? "DAT_SMALL_STRONG" :
|
|
|
|
|
"DAT_SMALL",
|
|
|
|
|
The_Colors[Gbl.Prefs.Theme],
|
2022-03-19 02:05:53 +01:00
|
|
|
|
The_GetColorRows ());
|
2021-03-02 10:16:41 +01:00
|
|
|
|
if (Visible)
|
|
|
|
|
{
|
|
|
|
|
Frm_BeginForm (ActSeeOthPubPrf);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
2021-12-26 16:22:58 +01:00
|
|
|
|
HTM_BUTTON_OnSubmit_Begin (Txt_Another_user_s_profile,
|
2021-12-26 22:39:16 +01:00
|
|
|
|
"BT_LINK",NULL);
|
2021-03-02 10:16:41 +01:00
|
|
|
|
Usr_WriteFirstNameBRSurnames (UsrDat);
|
|
|
|
|
HTM_BUTTON_End ();
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
}
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2015-03-16 17:46:32 +01:00
|
|
|
|
}
|