swad-core/swad_network.c

605 lines
20 KiB
C
Raw Normal View History

2014-12-01 23:55:08 +01:00
// swad_network.c: users' webs and social networks
/*
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.
2019-01-07 21:52:19 +01:00
Copyright (C) 1999-2019 Antonio Ca<EFBFBD>as Vargas
2014-12-01 23:55:08 +01:00
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public 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 ***********************************/
/*****************************************************************************/
#include <string.h>
2017-06-10 21:38:10 +02:00
#include "swad_box.h"
2014-12-01 23:55:08 +01:00
#include "swad_database.h"
2018-11-09 20:47:39 +01:00
#include "swad_form.h"
2014-12-01 23:55:08 +01:00
#include "swad_global.h"
2019-10-23 19:05:05 +02:00
#include "swad_HTML.h"
2014-12-01 23:55:08 +01:00
#include "swad_parameter.h"
2015-03-14 17:39:04 +01:00
#include "swad_profile.h"
2014-12-01 23:55:08 +01:00
#include "swad_theme.h"
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl;
/*****************************************************************************/
/***************************** Private constants *****************************/
/*****************************************************************************/
2019-02-13 00:37:08 +01:00
#define Net_NUM_WEBS_AND_SOCIAL_NETWORKS 29
2014-12-01 23:55:08 +01:00
typedef enum
{
Net_WWW, // Personal web page
2015-03-03 21:15:52 +01:00
Net_500PX,
2014-12-01 23:55:08 +01:00
Net_DELICIOUS,
2015-03-03 21:15:52 +01:00
Net_DEVIANTART,
2015-03-10 14:37:45 +01:00
Net_DIASPORA,
2014-12-01 23:55:08 +01:00
Net_EDMODO,
Net_FACEBOOK,
Net_FLICKR,
Net_FOURSQUARE,
2014-12-06 18:26:16 +01:00
Net_GITHUB,
2015-09-11 13:54:15 +02:00
Net_GNU_SOCIAL,
2014-12-01 23:55:08 +01:00
Net_GOOGLE_PLUS,
Net_GOOGLE_SCHOLAR,
2015-09-11 13:54:15 +02:00
Net_IDENTICA,
2014-12-01 23:55:08 +01:00
Net_INSTAGRAM,
Net_LINKEDIN,
2015-09-09 23:44:58 +02:00
Net_ORCID,
2014-12-01 23:55:08 +01:00
Net_PAPERLI,
Net_PINTEREST,
Net_RESEARCH_GATE,
2015-09-09 23:44:58 +02:00
Net_RESEARCHERID,
2014-12-01 23:55:08 +01:00
Net_SCOOPIT,
Net_SLIDESHARE,
2016-06-19 15:18:46 +02:00
Net_STACK_OVERFLOW,
2014-12-01 23:55:08 +01:00
Net_STORIFY,
Net_TUMBLR,
Net_TWITTER,
Net_WIKIPEDIA,
Net_YOUTUBE,
} Net_WebsAndSocialNetworks_t;
2017-01-29 21:41:08 +01:00
#define Net_WEB_SOCIAL_NET_DEFAULT Net_WWW
2014-12-01 23:55:08 +01:00
2017-03-07 19:55:29 +01:00
#define Net_MAX_BYTES_NETWORK_NAME 32
2017-01-17 03:10:43 +01:00
2014-12-01 23:55:08 +01:00
const char *Net_WebsAndSocialNetworksDB[Net_NUM_WEBS_AND_SOCIAL_NETWORKS] =
{
"www", // Net_WWW
2015-03-03 21:15:52 +01:00
"500px", // Net_500PX
2014-12-01 23:55:08 +01:00
"delicious", // Net_DELICIOUS
2015-03-03 21:15:52 +01:00
"deviantart", // Net_DEVIANTART
2015-03-10 14:37:45 +01:00
"diaspora", // Net_DIASPORA
2014-12-01 23:55:08 +01:00
"edmodo", // Net_EDMODO
"facebook", // Net_FACEBOOK
"flickr", // Net_FLICKR
2014-12-06 18:26:16 +01:00
"foursquare", // Net_FOURSQUAREhub
"github", // Net_GITHUB
2015-09-11 13:54:15 +02:00
"gnusocial", // Net_GNU_SOCIAL
2014-12-01 23:55:08 +01:00
"googleplus", // Net_GOOGLE_PLUS
"googlescholar", // Net_GOOGLE_SCHOLAR
2015-09-11 13:54:15 +02:00
"identica", // Net_IDENTICA
2014-12-01 23:55:08 +01:00
"instagram", // Net_INSTAGRAM
"linkedin", // Net_LINKEDIN
2015-09-09 23:44:58 +02:00
"orcid", // Net_ORCID
2014-12-01 23:55:08 +01:00
"paperli", // Net_PAPERLI
"pinterest", // Net_PINTEREST
"researchgate", // Net_RESEARCH_GATE
2015-09-09 23:44:58 +02:00
"researcherid", // Net_RESEARCHERID
2014-12-01 23:55:08 +01:00
"scoopit", // Net_SCOOPIT
"slideshare", // Net_SLIDESHARE
2016-06-19 15:18:46 +02:00
"stackoverflow", // Net_STACK_OVERFLOW
2014-12-01 23:55:08 +01:00
"storify", // Net_STORIFY
"tumblr", // Net_TUMBLR
"twitter", // Net_TWITTER
"wikipedia", // Net_WIKIPEDIA
"youtube", // Net_YOUTUBE
};
2015-12-12 19:47:10 +01:00
const char *Net_WebsAndSocialNetworksIcons[Net_NUM_WEBS_AND_SOCIAL_NETWORKS] =
{
2019-02-13 00:37:08 +01:00
"globe.svg", // Net_WWW
"500px-brands.svg", // Net_500PX
"delicious-brands.svg", // Net_DELICIOUS
"deviantart-brands.svg", // Net_DEVIANTART
"diaspora-brands.svg", // Net_DIASPORA
"edmodo64x64.png", // Net_EDMODO
"facebook-brands.svg", // Net_FACEBOOK
"flickr-brands.svg", // Net_FLICKR
"foursquare-brands.svg", // Net_FOURSQUAREhub
"github-brands.svg", // Net_GITHUB
"gnusocial64x64.png", // Net_GNU_SOCIAL
"google-plus-brands.svg", // Net_GOOGLE_PLUS
"googlescholar.svg", // Net_GOOGLE_SCHOLAR
"identica64x64.png", // Net_IDENTICA
"instagram-brands.svg", // Net_INSTAGRAM
"linkedin-brands.svg", // Net_LINKEDIN
"orcid64x64.png", // Net_ORCID
"paperli64x64.png", // Net_PAPERLI
"pinterest-brands.svg", // Net_PINTEREST
"researchgate-brands.svg", // Net_RESEARCH_GATE
"researcherid64x64.png", // Net_RESEARCHERID
"scoopit64x64.png", // Net_SCOOPIT
"slideshare-brands.svg", // Net_SLIDESHARE
"stack-overflow-brands.svg", // Net_STACK_OVERFLOW
"storify64x64.png", // Net_STORIFY
"tumblr-brands.svg", // Net_TUMBLR
"twitter-brands.svg", // Net_TWITTER
"wikipedia-w-brands.svg", // Net_WIKIPEDIA
"youtube-brands.svg", // Net_YOUTUBE
2015-12-12 19:47:10 +01:00
};
const char *Net_WebsAndSocialNetworksTitle[Net_NUM_WEBS_AND_SOCIAL_NETWORKS] =
2014-12-01 23:55:08 +01:00
{
"WWW", // Net_WWW
2015-03-03 21:15:52 +01:00
"500px", // Net_500PX
2014-12-01 23:55:08 +01:00
"Delicious", // Net_DELICIOUS
2015-03-03 21:15:52 +01:00
"DeviantArt", // Net_DEVIANTART
2015-03-10 14:37:45 +01:00
"Diaspora", // Net_DIASPORA
2014-12-01 23:55:08 +01:00
"Edmodo", // Net_EDMODO
"Facebook", // Net_FACEBOOK
"Flickr", // Net_FLICKR
"Foursquare", // Net_FOURSQUARE
2014-12-06 18:26:16 +01:00
"GitHub", // Net_GITHUB
2015-09-11 13:54:15 +02:00
"GNU Social", // Net_GNU_SOCIAL
2014-12-01 23:55:08 +01:00
"Google+", // Net_GOOGLE_PLUS
"Google Scholar", // Net_GOOGLE_SCHOLAR
2015-09-11 13:54:15 +02:00
"identi.ca", // Net_IDENTICA
2014-12-01 23:55:08 +01:00
"Instagram", // Net_INSTAGRAM
"LinkedIn", // Net_LINKEDIN
2015-09-09 23:44:58 +02:00
"ORCID", // Net_ORCID
2014-12-01 23:55:08 +01:00
"Paper.li", // Net_PAPERLI
"Pinterest", // Net_PINTEREST
"Research Gate", // Net_RESEARCH_GATE
2015-09-09 23:44:58 +02:00
"ResearcherID", // Net_RESEARCHERID
2014-12-01 23:55:08 +01:00
"Scoop.it", // Net_SCOOPIT
"Slideshare", // Net_SLIDESHARE
2016-06-19 15:18:46 +02:00
"Stack Overflow", // Net_STACK_OVERFLOW
2014-12-01 23:55:08 +01:00
"Storify", // Net_STORIFY
"Tumblr", // Net_TUMBLR
"Twitter", // Net_TWITTER
"Wikipedia", // Net_WIKIPEDIA
"YouTube", // Net_YOUTUBE
};
2018-10-08 18:41:56 +02:00
#define Net_MY_WEBS_ID "my_webs_section"
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/***************************** Private prototypes ****************************/
/*****************************************************************************/
2015-03-14 17:39:04 +01:00
static void Net_ShowAWebOrSocialNet (const char *URL,
const char *Icon,const char *Title);
2016-11-07 16:35:58 +01:00
static void Net_PutIconsWebsSocialNetworks (void);
2014-12-01 23:55:08 +01:00
static void Net_GetMyWebsAndSocialNetsFromForm (void);
/*****************************************************************************/
/************************** Show webs / social networks **********************/
/*****************************************************************************/
2015-03-14 17:39:04 +01:00
void Net_ShowWebsAndSocialNets (const struct UsrData *UsrDat)
2014-12-01 23:55:08 +01:00
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
Net_WebsAndSocialNetworks_t NumURL;
2017-03-07 01:56:41 +01:00
char URL[Cns_MAX_BYTES_WWW + 1];
2014-12-01 23:55:08 +01:00
2015-03-14 17:39:04 +01:00
/***** Start container *****/
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ("class=\"REC_WEBS\"");
2014-12-01 23:55:08 +01:00
2015-03-14 17:39:04 +01:00
/***** Show link to public profile *****/
Net_ShowAWebOrSocialNet (Prf_GetURLPublicProfile (URL,UsrDat->Nickname),
2019-01-11 02:55:01 +01:00
"swad64x64.png",Cfg_PLATFORM_SHORT_NAME);
2015-03-14 17:39:04 +01:00
/***** Show the rest of webs / social networks *****/
2014-12-01 23:55:08 +01:00
for (NumURL = (Net_WebsAndSocialNetworks_t) 0;
NumURL < Net_NUM_WEBS_AND_SOCIAL_NETWORKS;
NumURL++)
{
2015-03-14 17:39:04 +01:00
/***** Check if exists the web / social network for this user *****/
2018-11-01 12:02:58 +01:00
if (DB_QuerySELECT (&mysql_res,"can not get user's web / social network",
"SELECT URL FROM usr_webs"
" WHERE UsrCod=%ld AND Web='%s'",
UsrDat->UsrCod,Net_WebsAndSocialNetworksDB[NumURL]))
2014-12-01 23:55:08 +01:00
{
2015-03-14 17:39:04 +01:00
/* Get URL */
2014-12-01 23:55:08 +01:00
row = mysql_fetch_row (mysql_res);
2017-01-17 03:10:43 +01:00
Str_Copy (URL,row[0],
2017-03-07 01:56:41 +01:00
Cns_MAX_BYTES_WWW);
2014-12-01 23:55:08 +01:00
2015-03-14 17:39:04 +01:00
/* Show the web / social network */
Net_ShowAWebOrSocialNet (URL,
2015-12-12 19:47:10 +01:00
Net_WebsAndSocialNetworksIcons[NumURL],
Net_WebsAndSocialNetworksTitle[NumURL]);
2014-12-01 23:55:08 +01:00
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
2015-03-14 17:39:04 +01:00
/***** End container *****/
2019-10-23 20:07:56 +02:00
HTM_DIV_End ();
2014-12-01 23:55:08 +01:00
}
2015-03-14 17:39:04 +01:00
/*****************************************************************************/
/************************** Show a web / social network **********************/
/*****************************************************************************/
static void Net_ShowAWebOrSocialNet (const char *URL,
const char *Icon,const char *Title)
{
/***** Write link and icon *****/
2019-10-24 00:04:40 +02:00
HTM_DIV_Begin ("class=\"ICO_HIGHLIGHT\" style=\"display:inline;\"");
2019-10-28 20:38:29 +01:00
HTM_A_Begin ("href=\"%s\" target=\"_blank\" title=\"%s\"",URL,Title);
2019-10-29 21:41:54 +01:00
Ico_PutIcon (Icon,Title,"ICO16x16");
2019-10-28 13:56:04 +01:00
HTM_A_End ();
2019-10-23 20:07:56 +02:00
HTM_DIV_End ();
2015-03-14 17:39:04 +01:00
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/********************* Show form to edit my social networks ******************/
/*****************************************************************************/
void Net_ShowFormMyWebsAndSocialNets (void)
{
2016-11-13 13:44:20 +01:00
extern const char *Hlp_PROFILE_Webs;
2019-02-22 21:47:50 +01:00
extern const char *The_ClassFormInBox[The_NUM_THEMES];
2014-12-01 23:55:08 +01:00
extern const char *Txt_Webs_social_networks;
2019-02-18 19:35:52 +01:00
extern const char *Txt_Save_changes;
2014-12-01 23:55:08 +01:00
MYSQL_RES *mysql_res;
MYSQL_ROW row;
Net_WebsAndSocialNetworks_t NumURL;
2017-03-07 01:56:41 +01:00
char URL[Cns_MAX_BYTES_WWW + 1];
2019-11-08 01:10:32 +01:00
char StrRecordWidth[Cns_MAX_DECIMAL_DIGITS_UINT + 2 + 1];
2019-11-04 09:45:57 +01:00
char StrName[32];
2018-10-08 18:41:56 +02:00
/***** Start section *****/
2019-10-26 01:56:36 +02:00
HTM_SECTION_Begin (Net_MY_WEBS_ID);
2014-12-01 23:55:08 +01:00
2019-10-26 02:19:42 +02:00
/***** Begin box *****/
2018-10-18 02:02:32 +02:00
snprintf (StrRecordWidth,sizeof (StrRecordWidth),
"%upx",
Rec_RECORD_WIDTH);
2019-10-25 22:48:34 +02:00
Box_BoxBegin (StrRecordWidth,Txt_Webs_social_networks,
2019-02-18 19:35:52 +01:00
Net_PutIconsWebsSocialNetworks,
Hlp_PROFILE_Webs,Box_NOT_CLOSABLE);
2014-12-01 23:55:08 +01:00
2019-10-20 22:00:28 +02:00
/***** Begin table *****/
2019-10-23 19:05:05 +02:00
HTM_TABLE_BeginPadding (2);
2019-02-18 19:35:52 +01:00
2019-10-20 22:00:28 +02:00
/***** Begin form *****/
2019-02-18 19:35:52 +01:00
Frm_StartFormAnchor (ActChgMyNet,Net_MY_WEBS_ID);
/***** List webs and social networks *****/
2014-12-01 23:55:08 +01:00
for (NumURL = (Net_WebsAndSocialNetworks_t) 0;
NumURL < Net_NUM_WEBS_AND_SOCIAL_NETWORKS;
NumURL++)
{
/***** Get user's web / social network from database *****/
2018-11-01 12:02:58 +01:00
if (DB_QuerySELECT (&mysql_res,"can not get user's web / social network",
"SELECT URL FROM usr_webs"
" WHERE UsrCod=%ld AND Web='%s'",
Gbl.Usrs.Me.UsrDat.UsrCod,
Net_WebsAndSocialNetworksDB[NumURL]))
2014-12-01 23:55:08 +01:00
{
/***** Read the data comunes a all the users *****/
row = mysql_fetch_row (mysql_res);
/* Get URL */
2017-01-17 03:10:43 +01:00
Str_Copy (URL,row[0],
2017-03-07 01:56:41 +01:00
Cns_MAX_BYTES_WWW);
2014-12-01 23:55:08 +01:00
}
else
URL[0] = '\0';
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
/***** Row for this web / social network *****/
2019-11-12 15:41:58 +01:00
snprintf (StrName,sizeof (StrName),
"URL%u",
(unsigned) NumURL);
2019-10-23 19:05:05 +02:00
HTM_TR_Begin (NULL);
2019-10-07 17:36:41 +02:00
2019-10-23 19:05:05 +02:00
HTM_TD_Begin ("class=\"REC_C1_BOT LM\"");
2019-11-12 15:41:58 +01:00
HTM_LABEL_Begin ("for=\"%s\" class=\"%s\"",
StrName,The_ClassFormInBox[Gbl.Prefs.Theme]);
2019-10-30 00:42:01 +01:00
HTM_IMG (Cfg_URL_ICON_PUBLIC,Net_WebsAndSocialNetworksIcons[NumURL],Net_WebsAndSocialNetworksTitle[NumURL],
2019-10-30 22:31:03 +01:00
"class=\"CONTEXT_ICO_16x16\" style=\"margin-right:6px;\"");
2019-11-11 10:59:24 +01:00
HTM_TxtF ("%s:",Net_WebsAndSocialNetworksTitle[NumURL]);
2019-11-02 12:59:31 +01:00
HTM_LABEL_End ();
2019-10-23 19:05:05 +02:00
HTM_TD_End ();
2019-10-07 17:36:41 +02:00
2019-10-23 19:05:05 +02:00
HTM_TD_Begin ("class=\"REC_C2_BOT LM\"");
2019-11-07 15:19:53 +01:00
HTM_INPUT_URL (StrName,URL,false,
2019-11-12 15:41:58 +01:00
"id=\"%s\" class=\"REC_C2_BOT_INPUT\"",StrName);
2019-10-23 19:05:05 +02:00
HTM_TD_End ();
2019-10-07 17:36:41 +02:00
2019-10-23 19:05:05 +02:00
HTM_TR_End ();
2014-12-01 23:55:08 +01:00
}
2019-02-18 19:35:52 +01:00
/***** End table *****/
2019-10-23 19:05:05 +02:00
HTM_TABLE_End ();
2019-02-18 19:35:52 +01:00
/***** Confirm button *****/
Btn_PutConfirmButton (Txt_Save_changes);
/***** End form *****/
Frm_EndForm ();
/***** End box *****/
2019-10-25 22:48:34 +02:00
Box_BoxEnd ();
2018-10-08 18:41:56 +02:00
/***** End section *****/
2019-10-26 01:56:36 +02:00
HTM_SECTION_End ();
2014-12-01 23:55:08 +01:00
}
2016-11-07 16:35:58 +01:00
/*****************************************************************************/
/************** Put contextual icons in my web / social networks *************/
/*****************************************************************************/
static void Net_PutIconsWebsSocialNetworks (void)
{
/***** Put icon to show a figure *****/
2019-02-12 14:46:14 +01:00
Gbl.Figures.FigureType = Fig_SOCIAL_NETWORKS;
Fig_PutIconToShowFigure ();
2016-11-07 16:35:58 +01:00
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/**************** Update and show data from identified user ******************/
/*****************************************************************************/
void Net_UpdateMyWebsAndSocialNets (void)
{
/***** Get my web and social networks from form *****/
Net_GetMyWebsAndSocialNetsFromForm ();
/***** Show form again *****/
2018-10-09 13:41:55 +02:00
Rec_ShowMySharedRecordAndMore ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/********* Get data fields about web and social networks from form ***********/
/*****************************************************************************/
static void Net_GetMyWebsAndSocialNetsFromForm (void)
{
2019-02-18 19:35:52 +01:00
Net_WebsAndSocialNetworks_t NumURL;
char ParamName[3 + 10 + 1];
2017-03-07 01:56:41 +01:00
char URL[Cns_MAX_BYTES_WWW + 1];
2014-12-01 23:55:08 +01:00
2019-02-18 19:35:52 +01:00
/***** Get URLs *****/
for (NumURL = (Net_WebsAndSocialNetworks_t) 0;
NumURL < Net_NUM_WEBS_AND_SOCIAL_NETWORKS;
NumURL++)
{
/***** Get URL from the form *****/
snprintf (ParamName,sizeof (ParamName),
"URL%u",
(unsigned) NumURL);
Par_GetParToText (ParamName,URL,Cns_MAX_BYTES_WWW);
if (URL[0])
/***** Insert or replace web / social network *****/
DB_QueryREPLACE ("can not update user's web / social network",
"REPLACE INTO usr_webs"
" (UsrCod,Web,URL)"
" VALUES"
" (%ld,'%s','%s')",
Gbl.Usrs.Me.UsrDat.UsrCod,
Net_WebsAndSocialNetworksDB[NumURL],
URL);
else
/***** Remove web / social network *****/
DB_QueryDELETE ("can not remove user's web / social network",
"DELETE FROM usr_webs WHERE UsrCod=%ld AND Web='%s'",
Gbl.Usrs.Me.UsrDat.UsrCod,
Net_WebsAndSocialNetworksDB[NumURL]);
}
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************** Show stats about users' webs / social networks ***************/
/*****************************************************************************/
void Net_ShowWebAndSocialNetworksStats (void)
{
2017-12-19 18:41:19 +01:00
extern const char *Hlp_ANALYTICS_Figures_webs_social_networks;
2019-02-12 14:46:14 +01:00
extern const char *Txt_FIGURE_TYPES[Fig_NUM_FIGURES];
2014-12-01 23:55:08 +01:00
extern const char *Txt_Web_social_network;
extern const char *Txt_No_of_users;
extern const char *Txt_PERCENT_of_users;
MYSQL_RES *mysql_res;
MYSQL_ROW row;
2018-11-01 12:02:58 +01:00
unsigned NumRows = 0; // Initialized to avoid warning
2017-01-17 03:10:43 +01:00
unsigned NumRow;
2014-12-01 23:55:08 +01:00
Net_WebsAndSocialNetworks_t Web;
2017-03-07 19:55:29 +01:00
char NetName[Net_MAX_BYTES_NETWORK_NAME + 1];
2017-05-25 19:57:34 +02:00
unsigned NumUsrsTotal;
2014-12-01 23:55:08 +01:00
unsigned NumUsrs;
2017-05-25 19:57:34 +02:00
/***** Get total number of users in current scope *****/
2019-04-03 20:57:04 +02:00
NumUsrsTotal = (Gbl.Scope.Current == Hie_SYS) ? Usr_GetTotalNumberOfUsersInPlatform () :
2017-05-25 19:57:34 +02:00
Usr_GetTotalNumberOfUsersInCourses (Gbl.Scope.Current,
1 << Rol_STD |
1 << Rol_NET |
1 << Rol_TCH);
2014-12-01 23:55:08 +01:00
/***** Get number of users with a web / social network *****/
switch (Gbl.Scope.Current)
{
2019-04-03 20:57:04 +02:00
case Hie_SYS:
2018-11-01 12:02:58 +01:00
NumRows =
(unsigned) DB_QuerySELECT (&mysql_res,"can not get number of users"
" with webs / social networks",
"SELECT Web,COUNT(*) AS N"
" FROM usr_webs"
" GROUP BY Web"
" ORDER BY N DESC,Web");
2014-12-01 23:55:08 +01:00
break;
2019-04-03 20:57:04 +02:00
case Hie_CTY:
2018-11-01 12:02:58 +01:00
NumRows =
(unsigned) DB_QuerySELECT (&mysql_res,"can not get number of users"
" with webs / social networks",
"SELECT usr_webs.Web,"
"COUNT(DISTINCT usr_webs.UsrCod) AS N"
" FROM institutions,centres,degrees,courses,crs_usr,usr_webs"
" WHERE institutions.CtyCod=%ld"
" AND institutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.UsrCod=usr_webs.UsrCod"
" GROUP BY usr_webs.Web"
" ORDER BY N DESC,usr_webs.Web",
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Cty.CtyCod);
2015-03-09 12:09:31 +01:00
break;
2019-04-03 20:57:04 +02:00
case Hie_INS:
2018-11-01 12:02:58 +01:00
NumRows =
(unsigned) DB_QuerySELECT (&mysql_res,"can not get number of users"
" with webs / social networks",
"SELECT usr_webs.Web,"
"COUNT(DISTINCT usr_webs.UsrCod) AS N"
" FROM centres,degrees,courses,crs_usr,usr_webs"
" WHERE centres.InsCod=%ld"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.UsrCod=usr_webs.UsrCod"
" GROUP BY usr_webs.Web"
" ORDER BY N DESC,usr_webs.Web",
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ins.InsCod);
2014-12-01 23:55:08 +01:00
break;
2019-04-03 20:57:04 +02:00
case Hie_CTR:
2018-11-01 12:02:58 +01:00
NumRows =
(unsigned) DB_QuerySELECT (&mysql_res,"can not get number of users"
" with webs / social networks",
"SELECT usr_webs.Web,"
"COUNT(DISTINCT usr_webs.UsrCod) AS N"
" FROM degrees,courses,crs_usr,usr_webs"
" WHERE degrees.CtrCod=%ld"
" AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.UsrCod=usr_webs.UsrCod"
" GROUP BY usr_webs.Web"
" ORDER BY N DESC,usr_webs.Web",
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ctr.CtrCod);
2014-12-01 23:55:08 +01:00
break;
2019-04-03 20:57:04 +02:00
case Hie_DEG:
2018-11-01 12:02:58 +01:00
NumRows =
(unsigned) DB_QuerySELECT (&mysql_res,"can not get number of users"
" with webs / social networks",
"SELECT usr_webs.Web,"
"COUNT(DISTINCT usr_webs.UsrCod) AS N"
" FROM courses,crs_usr,usr_webs"
" WHERE courses.DegCod=%ld"
" AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.UsrCod=usr_webs.UsrCod"
" GROUP BY usr_webs.Web"
" ORDER BY N DESC,usr_webs.Web",
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Deg.DegCod);
2014-12-01 23:55:08 +01:00
break;
2019-04-03 20:57:04 +02:00
case Hie_CRS:
2018-11-01 12:02:58 +01:00
NumRows =
(unsigned) DB_QuerySELECT (&mysql_res,"can not get number of users"
" with webs / social networks",
"SELECT usr_webs.Web,"
"COUNT(DISTINCT usr_webs.UsrCod) AS N"
" FROM crs_usr,usr_webs"
" WHERE crs_usr.CrsCod=%ld"
" AND crs_usr.UsrCod=usr_webs.UsrCod"
" GROUP BY usr_webs.Web"
" ORDER BY N DESC,usr_webs.Web",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.CrsCod);
2014-12-01 23:55:08 +01:00
break;
default:
2018-10-24 23:03:11 +02:00
Lay_WrongScopeExit ();
2014-12-01 23:55:08 +01:00
break;
}
2019-10-26 02:19:42 +02:00
/***** Begin box and table *****/
2019-02-12 14:46:14 +01:00
Box_StartBoxTable (NULL,Txt_FIGURE_TYPES[Fig_SOCIAL_NETWORKS],NULL,
2017-12-19 18:41:19 +01:00
Hlp_ANALYTICS_Figures_webs_social_networks,Box_NOT_CLOSABLE,2);
2014-12-01 23:55:08 +01:00
2017-06-12 14:16:33 +02:00
/***** Write heading *****/
2019-10-23 19:05:05 +02:00
HTM_TR_Begin (NULL);
2019-10-12 00:07:52 +02:00
2019-10-23 19:05:05 +02:00
HTM_TH (1,1,"LM",Txt_Web_social_network);
HTM_TH (1,1,"RM",Txt_No_of_users);
HTM_TH (1,1,"RM",Txt_PERCENT_of_users);
2019-10-12 00:07:52 +02:00
2019-10-23 19:05:05 +02:00
HTM_TR_End ();
2014-12-01 23:55:08 +01:00
/***** For each web / social network... *****/
for (NumRow = 0;
NumRow < NumRows;
NumRow++)
{
/* Get row */
row = mysql_fetch_row (mysql_res);
/* Get web / social network (row[0]) */
2017-01-17 03:10:43 +01:00
Str_Copy (NetName,row[0],
2017-03-07 19:55:29 +01:00
Net_MAX_BYTES_NETWORK_NAME);
2014-12-01 23:55:08 +01:00
for (Web = (Net_WebsAndSocialNetworks_t) 0;
Web < Net_NUM_WEBS_AND_SOCIAL_NETWORKS;
Web++)
2017-01-17 03:10:43 +01:00
if (!strcmp (Net_WebsAndSocialNetworksDB[Web],NetName))
2014-12-01 23:55:08 +01:00
break;
if (Web < Net_NUM_WEBS_AND_SOCIAL_NETWORKS)
{
/* Get number of users (row[1]) */
if (sscanf (row[1],"%u",&NumUsrs) != 1)
Lay_ShowErrorAndExit ("Error when getting number of files.");
2019-10-23 19:05:05 +02:00
HTM_TR_Begin (NULL);
2019-10-07 17:36:41 +02:00
2019-10-23 19:05:05 +02:00
HTM_TD_Begin ("class=\"DAT LM\"");
2019-10-30 22:31:03 +01:00
HTM_IMG (Cfg_URL_ICON_PUBLIC,Net_WebsAndSocialNetworksIcons[Web],Net_WebsAndSocialNetworksTitle[Web],
"class=\"CONTEXT_ICO_16x16\" style=\"margin-right:6px;\"");
2019-11-10 12:36:37 +01:00
HTM_Txt (Net_WebsAndSocialNetworksTitle[Web]);
2019-10-23 19:05:05 +02:00
HTM_TD_End ();
2019-10-07 17:36:41 +02:00
2019-10-23 19:05:05 +02:00
HTM_TD_Begin ("class=\"DAT RM\"");
2019-11-10 13:31:47 +01:00
HTM_Unsigned (NumUsrs);
2019-10-23 19:05:05 +02:00
HTM_TD_End ();
2019-10-07 17:36:41 +02:00
2019-10-23 19:05:05 +02:00
HTM_TD_Begin ("class=\"DAT RM\"");
2019-11-11 00:15:44 +01:00
HTM_Percentage (NumUsrsTotal ? 100.0 * (double) NumUsrs /
(double) NumUsrsTotal :
0.0);
2019-10-23 19:05:05 +02:00
HTM_TD_End ();
2019-10-07 17:36:41 +02:00
2019-10-23 19:05:05 +02:00
HTM_TR_End ();
2014-12-01 23:55:08 +01:00
}
}
2017-06-12 14:16:33 +02:00
/***** End table and box *****/
2017-06-10 21:38:10 +02:00
Box_EndBoxTable ();
2014-12-01 23:55:08 +01:00
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}