swad-core/swad_network.c

579 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.
2016-01-01 20:19:43 +01:00
Copyright (C) 1999-2016 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 *****************************/
/*****************************************************************************/
2016-06-19 15:18:46 +02:00
#define Net_NUM_WEBS_AND_SOCIAL_NETWORKS 30
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,
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;
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
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] =
{
"www16x16.gif", // Net_WWW
"500px16x16.gif", // Net_500PX
"delicious16x16.gif", // Net_DELICIOUS
"deviantart16x16.gif", // Net_DEVIANTART
"diaspora16x16.gif", // Net_DIASPORA
"edmodo16x16.gif", // Net_EDMODO
"facebook16x16.gif", // Net_FACEBOOK
"flickr16x16.gif", // Net_FLICKR
"foursquare16x16.gif", // Net_FOURSQUAREhub
"github16x16.gif", // Net_GITHUB
"gnusocial16x16.gif", // Net_GNU_SOCIAL
"googleplus16x16.gif", // Net_GOOGLE_PLUS
"googlescholar16x16.gif", // Net_GOOGLE_SCHOLAR
"identica16x16.gif", // Net_IDENTICA
"instagram16x16.gif", // Net_INSTAGRAM
"linkedin16x16.gif", // Net_LINKEDIN
"orcid16x16.gif", // Net_ORCID
"paperli16x16.gif", // Net_PAPERLI
"pinterest16x16.gif", // Net_PINTEREST
"quitter16x16.gif", // Net_QUITTER
"researchgate16x16.gif", // Net_RESEARCH_GATE
"researcherid16x16.gif", // Net_RESEARCHERID
"scoopit16x16.gif", // Net_SCOOPIT
"slideshare16x16.gif", // Net_SLIDESHARE
2016-06-19 15:18:46 +02:00
"stackoverflow64x64.png", // Net_STACK_OVERFLOW
2015-12-12 19:47:10 +01:00
"storify16x16.gif", // Net_STORIFY
"tumblr16x16.gif", // Net_TUMBLR
"twitter16x16.gif", // Net_TWITTER
"wikipedia16x16.gif", // Net_WIKIPEDIA
"youtube16x16.gif", // Net_YOUTUBE
};
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
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
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
};
/*****************************************************************************/
/***************************** 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-12-13 17:12:48 +01:00
fprintf (Gbl.F.Out,"<div 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),
2016-03-20 22:31:57 +01:00
"swad64x64.gif",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++)
{
/***** 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,
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 *****/
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\">"
2015-12-12 19:47:10 +01:00
"<img src=\"%s/%s\""
2015-07-22 13:32:56 +02:00
" alt=\"%s\" title=\"%s\""
2015-12-13 12:51:41 +01:00
" class=\"ICON20x20\" />"
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
}
2016-01-04 16:45:43 +01:00
/*****************************************************************************/
/*********** Put a link to the action to edit my social networks *************/
/*****************************************************************************/
void Net_PutLinkToChangeMySocialNetworks (void)
{
extern const char *Txt_Edit_my_webs_networks;
/***** Link to edit my social networks *****/
2016-07-01 16:32:42 +02:00
Lay_PutContextualLink (ActReqEdiMyNet,NULL,
"earth64x64.gif",
Txt_Edit_my_webs_networks,Txt_Edit_my_webs_networks,
NULL);
2016-01-04 16:45:43 +01:00
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/********************* Show form to edit my social networks ******************/
/*****************************************************************************/
2015-09-28 18:28:29 +02:00
#define Net_COL2_WIDTH 500
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\">"
2015-12-12 19:47:10 +01:00
"<img src=\"%s/%s\""
2015-07-22 13:32:56 +02:00
" alt=\"%s\" title=\"%s\""
2015-12-13 12:51:41 +01:00
" class=\"ICON20x20\""
2015-09-28 18:28:29 +02:00
" style=\"margin-right:12px;\" />"
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],
2015-12-12 19:47:10 +01:00
Gbl.Prefs.IconsURL,Net_WebsAndSocialNetworksIcons[NumURL],
Net_WebsAndSocialNetworksTitle[NumURL],
Net_WebsAndSocialNetworksTitle[NumURL],
Net_WebsAndSocialNetworksTitle[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-28 18:28:29 +02:00
" style=\"width:500px;\" maxlength=\"%u\" value=\"%s\""
2015-10-22 14:49:48 +02:00
" onchange=\"document.getElementById('%s').submit();\" />",
2014-12-01 23:55:08 +01:00
Cns_MAX_LENGTH_URL,URL,
2016-01-14 10:31:09 +01:00
Gbl.Form.Id);
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-11-17 01:22:57 +01:00
NumUsrsTotalInPlatform = Sta_GetTotalNumberOfUsersInCourses (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:
2016-11-06 13:06:21 +01:00
sprintf (Query,"SELECT usr_webs.Web,"
"COUNT(DISTINCT usr_webs.UsrCod) AS N"
2015-03-09 12:09:31 +01:00
" 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:
2016-11-06 13:06:21 +01:00
sprintf (Query,"SELECT usr_webs.Web,"
"COUNT(DISTINCT usr_webs.UsrCod) AS N"
2014-12-01 23:55:08 +01:00
" 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:
2016-11-06 13:06:21 +01:00
sprintf (Query,"SELECT usr_webs.Web,"
"COUNT(DISTINCT usr_webs.UsrCod) AS N"
2014-12-01 23:55:08 +01:00
" 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:
2016-11-06 13:06:21 +01:00
sprintf (Query,"SELECT usr_webs.Web,"
"COUNT(DISTINCT usr_webs.UsrCod) AS N"
2014-12-01 23:55:08 +01:00
" 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:
2016-11-06 13:06:21 +01:00
sprintf (Query,"SELECT usr_webs.Web,"
"COUNT(DISTINCT usr_webs.UsrCod) AS N"
2014-12-01 23:55:08 +01:00
" 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\">"
2015-12-12 19:47:10 +01:00
"<img src=\"%s/%s\""
2015-07-22 13:32:56 +02:00
" alt=\"%s\" title=\"%s\""
2015-12-13 12:51:41 +01:00
" class=\"ICON20x20\""
2015-09-28 18:28:29 +02:00
" style=\"margin-right:12px;\" />"
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>",
2015-12-12 19:47:10 +01:00
Gbl.Prefs.IconsURL,Net_WebsAndSocialNetworksIcons[Web],
Net_WebsAndSocialNetworksTitle[Web],
Net_WebsAndSocialNetworksTitle[Web],
Net_WebsAndSocialNetworksTitle[Web],
2014-12-01 23:55:08 +01:00
NumUsrs,
2016-11-06 13:06:21 +01:00
NumUsrsTotalInPlatform ? 100.0 *
(float) NumUsrs /
(float) NumUsrsTotalInPlatform :
2014-12-01 23:55:08 +01:00
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);
}