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.
|
2015-01-01 14:34:06 +01:00
|
|
|
|
Copyright (C) 1999-2015 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>
|
|
|
|
|
|
|
|
|
|
#include "swad_database.h"
|
|
|
|
|
#include "swad_global.h"
|
|
|
|
|
#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 *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-09-11 13:54:15 +02: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,
|
2015-03-10 14:37:45 +01:00
|
|
|
|
Net_QUITTER,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
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,
|
|
|
|
|
Net_STORIFY,
|
|
|
|
|
Net_TUMBLR,
|
|
|
|
|
Net_TWITTER,
|
|
|
|
|
Net_WIKIPEDIA,
|
|
|
|
|
Net_YOUTUBE,
|
|
|
|
|
} Net_WebsAndSocialNetworks_t;
|
|
|
|
|
|
|
|
|
|
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
|
2015-03-10 14:37:45 +01:00
|
|
|
|
"quitter", // Net_QUITTER
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"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
|
|
|
|
|
"storify", // Net_STORIFY
|
|
|
|
|
"tumblr", // Net_TUMBLR
|
|
|
|
|
"twitter", // Net_TWITTER
|
|
|
|
|
"wikipedia", // Net_WIKIPEDIA
|
|
|
|
|
"youtube", // Net_YOUTUBE
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const char *Net_TitleWebsAndSocialNetworks[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
|
|
|
|
|
"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
|
2015-03-10 14:37:45 +01:00
|
|
|
|
"quitter", // Net_QUITTER
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"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
|
|
|
|
|
"Storify", // Net_STORIFY
|
|
|
|
|
"Tumblr", // Net_TUMBLR
|
|
|
|
|
"Twitter", // Net_TWITTER
|
|
|
|
|
"Wikipedia", // Net_WIKIPEDIA
|
|
|
|
|
"YouTube", // Net_YOUTUBE
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
static void Net_ShowAWebOrSocialNet (const char *URL,
|
|
|
|
|
const char *Icon,const char *Title);
|
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
|
|
|
|
{
|
|
|
|
|
char Query[256];
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
Net_WebsAndSocialNetworks_t NumURL;
|
|
|
|
|
char URL[Cns_MAX_BYTES_URL+1];
|
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
/***** Start container *****/
|
2015-09-24 18:02:21 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<div style=\"width:216px; margin:0 auto;\">");
|
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),
|
|
|
|
|
"swad",Cfg_PLATFORM_PAGE_TITLE);
|
|
|
|
|
|
|
|
|
|
/***** 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++)
|
|
|
|
|
{
|
|
|
|
|
/***** Get user's web / social network from database *****/
|
|
|
|
|
sprintf (Query,"SELECT URL FROM usr_webs"
|
|
|
|
|
" WHERE UsrCod='%ld' AND Web='%s'",
|
2015-03-14 17:39:04 +01:00
|
|
|
|
UsrDat->UsrCod,Net_WebsAndSocialNetworksDB[NumURL]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
/***** Check if exists the web / social network for this user *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (DB_QuerySELECT (Query,&mysql_res,"can not get user's web / social network"))
|
|
|
|
|
{
|
2015-03-14 17:39:04 +01:00
|
|
|
|
/* Get URL */
|
2014-12-01 23:55:08 +01:00
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
strncpy (URL,row[0],Cns_MAX_BYTES_URL);
|
|
|
|
|
URL[Cns_MAX_BYTES_URL] = '\0';
|
|
|
|
|
|
2015-03-14 17:39:04 +01:00
|
|
|
|
/* Show the web / social network */
|
|
|
|
|
Net_ShowAWebOrSocialNet (URL,
|
|
|
|
|
Net_WebsAndSocialNetworksDB[NumURL],
|
|
|
|
|
Net_TitleWebsAndSocialNetworks[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 *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</div>");
|
|
|
|
|
}
|
|
|
|
|
|
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 *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"ICON_HIGHLIGHT\""
|
|
|
|
|
" style=\"display:inline;\">"
|
|
|
|
|
"<a href=\"%s\" target=\"_blank\" title=\"%s\">"
|
|
|
|
|
"<img src=\"%s/%s16x16.gif\""
|
2015-07-22 13:32:56 +02:00
|
|
|
|
" alt=\"%s\" title=\"%s\""
|
2015-09-05 19:19:39 +02:00
|
|
|
|
" class=\"ICON16x16\" />"
|
2015-03-14 17:39:04 +01:00
|
|
|
|
"</a>"
|
|
|
|
|
"</div>",
|
|
|
|
|
URL,Title,
|
2015-07-22 13:32:56 +02:00
|
|
|
|
Gbl.Prefs.IconsURL,Icon,
|
|
|
|
|
Title,Title);
|
2015-03-14 17:39:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Show form to edit my social networks ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-09-24 18:02:21 +02:00
|
|
|
|
#define Net_COL2_WIDTH 600
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
void Net_ShowFormMyWebsAndSocialNets (void)
|
|
|
|
|
{
|
2015-07-28 00:16:09 +02:00
|
|
|
|
extern const char *The_ClassForm[The_NUM_THEMES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Webs_social_networks;
|
|
|
|
|
char Query[256];
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
Net_WebsAndSocialNetworks_t NumURL;
|
|
|
|
|
char URL[Cns_MAX_BYTES_URL+1];
|
|
|
|
|
|
|
|
|
|
/***** Start table *****/
|
2015-04-12 18:01:06 +02:00
|
|
|
|
Lay_StartRoundFrameTable (NULL,2,Txt_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++)
|
|
|
|
|
{
|
|
|
|
|
/***** Get user's web / social network from database *****/
|
|
|
|
|
sprintf (Query,"SELECT URL FROM usr_webs"
|
|
|
|
|
" WHERE UsrCod='%ld' AND Web='%s'",
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
|
|
|
|
Net_WebsAndSocialNetworksDB[NumURL]);
|
|
|
|
|
|
|
|
|
|
/***** Check number of rows in result *****/
|
|
|
|
|
if (DB_QuerySELECT (Query,&mysql_res,"can not get user's web / social network"))
|
|
|
|
|
{
|
|
|
|
|
/***** Read the data comunes a all the users *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get URL */
|
|
|
|
|
strncpy (URL,row[0],Cns_MAX_BYTES_URL);
|
|
|
|
|
URL[Cns_MAX_BYTES_URL] = '\0';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
URL[0] = '\0';
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
/***** Row for this web / social network *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2015-07-28 00:16:09 +02:00
|
|
|
|
"<td class=\"%s LEFT_MIDDLE\">"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"<img src=\"%s/%s16x16.gif\""
|
2015-07-22 13:32:56 +02:00
|
|
|
|
" alt=\"%s\" title=\"%s\""
|
2015-09-05 19:19:39 +02:00
|
|
|
|
" class=\"ICON16x16\""
|
2015-09-24 18:02:21 +02:00
|
|
|
|
" style=\"margin-right:15px;\" />"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"%s:</td>"
|
2015-09-24 18:02:21 +02:00
|
|
|
|
"<td class=\"LEFT_MIDDLE\" style=\"width:%upx;\">",
|
2015-07-28 00:16:09 +02:00
|
|
|
|
The_ClassForm[Gbl.Prefs.Theme],
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Gbl.Prefs.IconsURL,Net_WebsAndSocialNetworksDB[NumURL],
|
|
|
|
|
Net_TitleWebsAndSocialNetworks[NumURL],
|
|
|
|
|
Net_TitleWebsAndSocialNetworks[NumURL],
|
2015-07-22 13:32:56 +02:00
|
|
|
|
Net_TitleWebsAndSocialNetworks[NumURL],
|
2014-12-06 18:26:16 +01:00
|
|
|
|
Net_COL2_WIDTH);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Act_FormStart (ActChgMyNet);
|
|
|
|
|
Par_PutHiddenParamUnsigned ("Web",(unsigned) NumURL);
|
|
|
|
|
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"URL\""
|
2015-09-24 18:02:21 +02:00
|
|
|
|
" style=\"width:600px;\" maxlength=\"%u\" value=\"%s\""
|
2015-03-13 00:16:02 +01:00
|
|
|
|
" onchange=\"javascript:document.getElementById('%s').submit();\" />",
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Cns_MAX_LENGTH_URL,URL,
|
|
|
|
|
Gbl.FormId);
|
2015-03-13 00:16:02 +01:00
|
|
|
|
Act_FormEnd ();
|
|
|
|
|
fprintf (Gbl.F.Out,"</td>"
|
|
|
|
|
"</tr>");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** End table *****/
|
2015-04-12 18:01:06 +02:00
|
|
|
|
Lay_EndRoundFrameTable ();
|
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 *****/
|
|
|
|
|
Net_ShowFormMyWebsAndSocialNets ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********* Get data fields about web and social networks from form ***********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Net_GetMyWebsAndSocialNetsFromForm (void)
|
|
|
|
|
{
|
|
|
|
|
char Query[256+Cns_MAX_BYTES_URL];
|
|
|
|
|
char UnsignedStr[10+1];
|
|
|
|
|
unsigned UnsignedNum;
|
|
|
|
|
Net_WebsAndSocialNetworks_t Web;
|
|
|
|
|
char URL[Cns_MAX_BYTES_URL+1];
|
|
|
|
|
|
|
|
|
|
/***** Get parameter with the type of web / social network *****/
|
|
|
|
|
Par_GetParToText ("Web",UnsignedStr,10);
|
|
|
|
|
if (sscanf (UnsignedStr,"%u",&UnsignedNum) != 1)
|
|
|
|
|
Lay_ShowErrorAndExit ("Web / social network is missing.");
|
|
|
|
|
if (UnsignedNum >= Net_NUM_WEBS_AND_SOCIAL_NETWORKS)
|
|
|
|
|
Lay_ShowErrorAndExit ("Wrong web / social network.");
|
|
|
|
|
Web = (Net_WebsAndSocialNetworks_t) UnsignedNum;
|
|
|
|
|
|
|
|
|
|
/***** Get URL *****/
|
|
|
|
|
Par_GetParToText ("URL",URL,Cns_MAX_BYTES_URL);
|
|
|
|
|
if (URL[0])
|
|
|
|
|
{
|
|
|
|
|
/***** Insert or replace web / social network *****/
|
|
|
|
|
sprintf (Query,"REPLACE INTO usr_webs (UsrCod,Web,URL)"
|
|
|
|
|
" VALUES ('%ld','%s','%s')",
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
|
|
|
|
Net_WebsAndSocialNetworksDB[Web],
|
|
|
|
|
URL);
|
|
|
|
|
DB_QueryREPLACE (Query,"can not update user's web / social network");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/***** Remove web / social network *****/
|
|
|
|
|
sprintf (Query,"DELETE FROM usr_webs WHERE UsrCod='%ld' AND Web='%s'",
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
|
|
|
|
Net_WebsAndSocialNetworksDB[Web]);
|
|
|
|
|
DB_QueryREPLACE (Query,"can not remove user's web / social network");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Show stats about users' webs / social networks ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Net_ShowWebAndSocialNetworksStats (void)
|
|
|
|
|
{
|
2015-09-25 01:48:00 +02:00
|
|
|
|
extern const char *Txt_STAT_USE_STAT_TYPES[Sta_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;
|
|
|
|
|
char Query[512];
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumRows,NumRow;
|
|
|
|
|
Net_WebsAndSocialNetworks_t Web;
|
|
|
|
|
char WebStr[32];
|
|
|
|
|
unsigned NumUsrsTotalInPlatform;
|
|
|
|
|
unsigned NumUsrs;
|
|
|
|
|
|
|
|
|
|
/***** Get total number of users in platform *****/
|
2015-04-07 21:44:24 +02:00
|
|
|
|
NumUsrsTotalInPlatform = Sta_GetTotalNumberOfUsers (Gbl.Scope.Current,Rol_UNKNOWN);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get number of users with a web / social network *****/
|
|
|
|
|
switch (Gbl.Scope.Current)
|
|
|
|
|
{
|
2015-02-01 20:17:24 +01:00
|
|
|
|
case Sco_SCOPE_SYS:
|
2014-12-01 23:55:08 +01:00
|
|
|
|
sprintf (Query,"SELECT Web,COUNT(*) AS N"
|
|
|
|
|
" FROM usr_webs"
|
|
|
|
|
" GROUP BY Web"
|
|
|
|
|
" ORDER BY N DESC,Web");
|
|
|
|
|
break;
|
2015-03-09 12:09:31 +01:00
|
|
|
|
case Sco_SCOPE_CTY:
|
|
|
|
|
sprintf (Query,"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",
|
|
|
|
|
Gbl.CurrentCty.Cty.CtyCod);
|
|
|
|
|
break;
|
2015-02-01 20:17:24 +01:00
|
|
|
|
case Sco_SCOPE_INS:
|
2014-12-01 23:55:08 +01:00
|
|
|
|
sprintf (Query,"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",
|
|
|
|
|
Gbl.CurrentIns.Ins.InsCod);
|
|
|
|
|
break;
|
2015-02-01 20:17:24 +01:00
|
|
|
|
case Sco_SCOPE_CTR:
|
2014-12-01 23:55:08 +01:00
|
|
|
|
sprintf (Query,"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",
|
|
|
|
|
Gbl.CurrentCtr.Ctr.CtrCod);
|
|
|
|
|
break;
|
2015-02-01 20:17:24 +01:00
|
|
|
|
case Sco_SCOPE_DEG:
|
2014-12-01 23:55:08 +01:00
|
|
|
|
sprintf (Query,"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",
|
|
|
|
|
Gbl.CurrentDeg.Deg.DegCod);
|
|
|
|
|
break;
|
2015-02-01 20:17:24 +01:00
|
|
|
|
case Sco_SCOPE_CRS:
|
2014-12-01 23:55:08 +01:00
|
|
|
|
sprintf (Query,"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",
|
|
|
|
|
Gbl.CurrentCrs.Crs.CrsCod);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Lay_ShowErrorAndExit ("Wrong scope.");
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-12-06 18:26:16 +01:00
|
|
|
|
NumRows = (unsigned) DB_QuerySELECT (Query,&mysql_res,
|
|
|
|
|
"can not get number of users with webs / social networks");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Number of users *****/
|
2015-04-12 18:01:06 +02:00
|
|
|
|
Lay_StartRoundFrameTable (NULL,2,Txt_STAT_USE_STAT_TYPES[Sta_SOCIAL_NETWORKS]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2015-09-06 20:02:14 +02:00
|
|
|
|
"<th class=\"LEFT_MIDDLE\">"
|
2014-12-27 00:28:19 +01:00
|
|
|
|
"%s"
|
|
|
|
|
"</th>"
|
2015-09-06 20:02:14 +02:00
|
|
|
|
"<th class=\"RIGHT_MIDDLE\">"
|
2014-12-27 00:28:19 +01:00
|
|
|
|
"%s"
|
|
|
|
|
"</th>"
|
2015-09-06 20:02:14 +02:00
|
|
|
|
"<th class=\"RIGHT_MIDDLE\">"
|
2014-12-27 00:28:19 +01:00
|
|
|
|
"%s"
|
|
|
|
|
"</th>"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</tr>",
|
|
|
|
|
Txt_Web_social_network,
|
|
|
|
|
Txt_No_of_users,
|
|
|
|
|
Txt_PERCENT_of_users);
|
|
|
|
|
|
|
|
|
|
/***** 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]) */
|
|
|
|
|
strncpy (WebStr,row[0],sizeof (WebStr) - 1);
|
|
|
|
|
WebStr[sizeof (WebStr) - 1] = '\0';
|
|
|
|
|
for (Web = (Net_WebsAndSocialNetworks_t) 0;
|
|
|
|
|
Web < Net_NUM_WEBS_AND_SOCIAL_NETWORKS;
|
|
|
|
|
Web++)
|
|
|
|
|
if (!strcmp (Net_WebsAndSocialNetworksDB[Web],WebStr))
|
|
|
|
|
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.");
|
|
|
|
|
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2015-08-06 14:16:11 +02:00
|
|
|
|
"<td class=\"DAT LEFT_MIDDLE\">"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"<img src=\"%s/%s16x16.gif\""
|
2015-07-22 13:32:56 +02:00
|
|
|
|
" alt=\"%s\" title=\"%s\""
|
2015-09-05 19:19:39 +02:00
|
|
|
|
" class=\"ICON16x16\""
|
2015-09-24 18:02:21 +02:00
|
|
|
|
" style=\"margin-right:15px;\" />"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"%s</td>"
|
2015-08-06 14:16:11 +02:00
|
|
|
|
"<td class=\"DAT RIGHT_MIDDLE\">"
|
2014-12-23 22:47:09 +01:00
|
|
|
|
"%u"
|
|
|
|
|
"</td>"
|
2015-08-06 14:16:11 +02:00
|
|
|
|
"<td class=\"DAT RIGHT_MIDDLE\">"
|
2014-12-23 22:47:09 +01:00
|
|
|
|
"%.2f%%"
|
|
|
|
|
"</td>"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</tr>",
|
|
|
|
|
Gbl.Prefs.IconsURL,Net_WebsAndSocialNetworksDB[Web],
|
|
|
|
|
Net_TitleWebsAndSocialNetworks[Web],
|
|
|
|
|
Net_TitleWebsAndSocialNetworks[Web],
|
2015-07-22 13:32:56 +02:00
|
|
|
|
Net_TitleWebsAndSocialNetworks[Web],
|
2014-12-01 23:55:08 +01:00
|
|
|
|
NumUsrs,
|
|
|
|
|
NumUsrsTotalInPlatform ? 100.0 * (float) NumUsrs / (float) NumUsrsTotalInPlatform :
|
|
|
|
|
0.0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** End frame *****/
|
2015-04-12 18:01:06 +02:00
|
|
|
|
Lay_EndRoundFrameTable ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|