mirror of
https://github.com/acanas/swad-core.git
synced 2024-06-18 06:25:42 +02:00
Version 14.82
This commit is contained in:
parent
cd31719a48
commit
101b00d93f
|
@ -10509,7 +10509,9 @@ ALTER TABLE usr_data ADD COLUMN PhotoVisibility ENUM('user','course','system','w
|
|||
UPDATE usr_data SET PhotoVisibility='user' WHERE PublicPhoto='N';
|
||||
UPDATE usr_data SET PhotoVisibility='system' WHERE PublicPhoto='Y';
|
||||
|
||||
|
||||
----- 2015-03-09, swad14.82
|
||||
|
||||
CREATE TABLE IF NOT EXISTS usr_figures (UsrCod INT NOT NULL,FirstClickTime DATETIME NOT NULL,NumClicks INT NOT NULL DEFAULT 0,PRIMARY KEY(UsrCod));
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1170,6 +1170,14 @@ CREATE TABLE IF NOT EXISTS usr_emails (
|
|||
UNIQUE INDEX(UsrCod,E_mail),
|
||||
UNIQUE INDEX(E_mail));
|
||||
--
|
||||
-- Table usr_figures: stores some figures (numbers) related to users to show in public profile
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS usr_figures (
|
||||
UsrCod INT NOT NULL,
|
||||
FirstClickTime DATETIME NOT NULL,
|
||||
NumClicks INT NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY(UsrCod));
|
||||
--
|
||||
-- Table usr_last: stores some variable data related to users
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS usr_last (
|
||||
|
|
|
@ -103,11 +103,15 @@
|
|||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 14.81.4 (2015/03/09)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 14.82 (2015/03/10)"
|
||||
|
||||
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
||||
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h | tail -1
|
||||
/*
|
||||
Version 14.82: Mar 10, 2015 New database table usr_figures. (179898 lines)
|
||||
1 change necessary in database:
|
||||
CREATE TABLE IF NOT EXISTS usr_figures (UsrCod INT NOT NULL,FirstClickTime DATETIME NOT NULL,NumClicks INT NOT NULL DEFAULT 0,PRIMARY KEY(UsrCod));
|
||||
|
||||
Version 14.81.4: Mar 09, 2015 Information about number of public files in user's public profile. (179733 lines)
|
||||
Version 14.81.3: Mar 09, 2015 Information about number of files in user's public profile. (179670 lines)
|
||||
Version 14.81.2: Mar 09, 2015 Information about number of courses in user's public profile. (179641 lines)
|
||||
|
|
|
@ -2337,6 +2337,24 @@ mysql> DESCRIBE usr_emails;
|
|||
"Confirmed ENUM('N','Y') NOT NULL DEFAULT 'N',"
|
||||
"UNIQUE INDEX(UsrCod,E_mail),UNIQUE INDEX(E_mail))");
|
||||
|
||||
/***** Table usr_figures *****/
|
||||
/*
|
||||
mysql> DESCRIBE usr_figures;
|
||||
+----------------+----------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+----------------+----------+------+-----+---------+-------+
|
||||
| UsrCod | int(11) | NO | PRI | NULL | |
|
||||
| FirstClickTime | datetime | NO | | NULL | |
|
||||
| NumClicks | int(11) | NO | | 0 | |
|
||||
+----------------+----------+------+-----+---------+-------+
|
||||
3 rows in set (0.01 sec)
|
||||
*/
|
||||
DB_CreateTable ("CREATE TABLE IF NOT EXISTS usr_figures ("
|
||||
"UsrCod INT NOT NULL,"
|
||||
"FirstClickTime DATETIME NOT NULL,"
|
||||
"NumClicks INT NOT NULL DEFAULT 0,"
|
||||
"PRIMARY KEY(UsrCod))");
|
||||
|
||||
/***** Table usr_IDs *****/
|
||||
/*
|
||||
mysql> DESCRIBE usr_IDs;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <string.h> // For string functions
|
||||
|
||||
#include "swad_config.h"
|
||||
#include "swad_date.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_parameter.h"
|
||||
|
|
|
@ -343,6 +343,10 @@ void Sta_LogAccess (const char *Comments)
|
|||
LogCod,Gbl.Banners.BanCodClicked);
|
||||
DB_QueryINSERT (Query,"can not log banner clicked");
|
||||
}
|
||||
|
||||
/***** Increment my number of clicks *****/
|
||||
if (Gbl.Usrs.Me.UsrDat.UsrCod > 0)
|
||||
Usr_IncrementNumClicksUsr ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
21
swad_text.c
21
swad_text.c
|
@ -11484,6 +11484,27 @@ const char *Txt_Files_works =
|
|||
"Arquivos trabalhos";
|
||||
#endif
|
||||
|
||||
const char *Txt_First_access =
|
||||
#if L==0
|
||||
"Primer accés";
|
||||
#elif L==1
|
||||
"Erster Zugang";
|
||||
#elif L==2
|
||||
"First access";
|
||||
#elif L==3
|
||||
"Primer acceso";
|
||||
#elif L==4
|
||||
"Premier accès";
|
||||
#elif L==5
|
||||
"Primer acceso"; // Okoteve traducción
|
||||
#elif L==6
|
||||
"Primo accesso";
|
||||
#elif L==7
|
||||
"Pierwszy dostęp";
|
||||
#elif L==8
|
||||
"Primeiro acesso";
|
||||
#endif
|
||||
|
||||
const char *Txt_first_message_not_allowed =
|
||||
#if L==0
|
||||
"primer mensaje no permitido"; // Necessita traduccio
|
||||
|
|
140
swad_user.c
140
swad_user.c
|
@ -91,6 +91,12 @@ const char *Usr_UsrDatMainFieldNames[Usr_NUM_MAIN_FIELDS_DATA_USR];
|
|||
/****************************** Internal types *******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
struct UsrFigures
|
||||
{
|
||||
struct DateTime FirstClickTime;
|
||||
unsigned long NumClicks;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** External global variables from others modules ****************/
|
||||
/*****************************************************************************/
|
||||
|
@ -174,6 +180,8 @@ static unsigned Usr_GetNumUsrsBelongingToAnyCrs (Rol_Role_t Role);
|
|||
static float Usr_GetNumCrssPerUsr (Rol_Role_t Role);
|
||||
static float Usr_GetNumUsrsPerCrs (Rol_Role_t Role);
|
||||
|
||||
static void Usr_GetUsrFigures (long UsrCod,struct UsrFigures *UsrFigures);
|
||||
|
||||
/*****************************************************************************/
|
||||
/**** Show alert about number of clicks remaining before sending my photo ****/
|
||||
/*****************************************************************************/
|
||||
|
@ -7556,6 +7564,8 @@ void Usr_ShowDetailsUserProfile (const struct UsrData *UsrDat)
|
|||
extern const char *Txt_Figures;
|
||||
// extern const char *Txt_Shortcut;
|
||||
// extern const char *Txt_STR_LANG_ID[Txt_NUM_LANGUAGES];
|
||||
extern const char *Txt_First_access;
|
||||
extern const char *Txt_Clicks;
|
||||
extern const char *Txt_Courses_as_a_ROLE;
|
||||
extern const char *Txt_ROLES_SINGULAR_abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
||||
extern const char *Txt_ROLES_PLURAL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
||||
|
@ -7563,6 +7573,7 @@ void Usr_ShowDetailsUserProfile (const struct UsrData *UsrDat)
|
|||
extern const char *Txt_public_files;
|
||||
extern const char *Txt_Forum_posts;
|
||||
extern const char *Txt_Messages_sent;
|
||||
struct UsrFigures UsrFigures;
|
||||
unsigned NumCrssUsrIsTeacher;
|
||||
unsigned NumCrssUsrIsStudent;
|
||||
unsigned NumFiles;
|
||||
|
@ -7590,6 +7601,48 @@ void Usr_ShowDetailsUserProfile (const struct UsrData *UsrDat)
|
|||
Cfg_HTTPS_URL_SWAD_CGI,Txt_STR_LANG_ID[Gbl.Prefs.Language],UsrDat->Nickname,
|
||||
Cfg_HTTPS_URL_SWAD_CGI,Txt_STR_LANG_ID[Gbl.Prefs.Language],UsrDat->Nickname);
|
||||
*/
|
||||
|
||||
/***** First click time and number of clicks *****/
|
||||
Usr_GetUsrFigures (UsrDat->UsrCod,&UsrFigures);
|
||||
|
||||
/* First click time */
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
"<td class=\"%s\""
|
||||
" style=\"text-align:right; vertical-align:middle;\">"
|
||||
"%s:"
|
||||
"</td>"
|
||||
"<td class=\"DAT\""
|
||||
" style=\"text-align:left; vertical-align:middle;\">",
|
||||
The_ClassFormul[Gbl.Prefs.Theme],
|
||||
Txt_First_access);
|
||||
if (UsrFigures.FirstClickTime.Date.Year)
|
||||
{
|
||||
Dat_WriteDate (UsrFigures.FirstClickTime.Date.YYYYMMDD);
|
||||
fprintf (Gbl.F.Out," ");
|
||||
Dat_WriteHourMinute (&(UsrFigures.FirstClickTime.YYYYMMDDHHMMSS[8]));
|
||||
}
|
||||
else
|
||||
fprintf (Gbl.F.Out,"-");
|
||||
fprintf (Gbl.F.Out,"</a>"
|
||||
"</td>"
|
||||
"</tr>");
|
||||
|
||||
/* Number of clicks */
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
"<td class=\"%s\""
|
||||
" style=\"text-align:right; vertical-align:middle;\">"
|
||||
"%s:"
|
||||
"</td>"
|
||||
"<td class=\"DAT\""
|
||||
" style=\"text-align:left; vertical-align:middle;\">"
|
||||
"%lu"
|
||||
"</a>"
|
||||
"</td>"
|
||||
"</tr>",
|
||||
The_ClassFormul[Gbl.Prefs.Theme],
|
||||
Txt_Clicks,
|
||||
UsrFigures.NumClicks);
|
||||
|
||||
/***** Number of courses in which the user is teacher or student *****/
|
||||
if ((NumCrssUsrIsTeacher = Usr_GetNumCrssOfUsrWithARole (UsrDat->UsrCod,Rol_ROLE_TEACHER)))
|
||||
{
|
||||
|
@ -7687,3 +7740,90 @@ void Usr_ShowDetailsUserProfile (const struct UsrData *UsrDat)
|
|||
/***** End of table *****/
|
||||
Lay_EndRoundFrameTable10 ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************** Select values on user's figures **********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Usr_GetUsrFigures (long UsrCod,struct UsrFigures *UsrFigures)
|
||||
{
|
||||
char Query[512];
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumRows;
|
||||
|
||||
/***** Get user's code from database *****/
|
||||
sprintf (Query,"SELECT DATE_FORMAT(FirstClickTime,'%%Y%%m%%d%%H%%i%%S'),NumClicks"
|
||||
" FROM usr_figures WHERE UsrCod='%ld'",
|
||||
UsrCod);
|
||||
if ((NumRows = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get user's figures")))
|
||||
{
|
||||
/***** Get user's figures *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/* Get first click (row[0] holds the start date in YYYYMMDDHHMMSS format) */
|
||||
if (!(Dat_GetDateTimeFromYYYYMMDDHHMMSS (&(UsrFigures->FirstClickTime),row[0])))
|
||||
Lay_ShowErrorAndExit ("Error when reading first click time.");
|
||||
|
||||
/* Get number of clicks */
|
||||
if (sscanf (row[1],"%ld",&UsrFigures->NumClicks) != 1)
|
||||
UsrFigures->NumClicks = 0;
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
||||
if (!NumRows)
|
||||
{
|
||||
/***** Get first click from database *****/
|
||||
sprintf (Query,"SELECT DATE_FORMAT(ClickTime,'%%Y%%m%%d%%H%%i%%S') FROM log"
|
||||
" WHERE UsrCod='%ld' ORDER BY ClickTime LIMIT 1",
|
||||
UsrCod);
|
||||
if (DB_QuerySELECT (Query,&mysql_res,"can not get user's first click"))
|
||||
{
|
||||
/* Get first click */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/* Get first click (row[0] holds the start date in YYYYMMDDHHMMSS format) */
|
||||
if (!(Dat_GetDateTimeFromYYYYMMDDHHMMSS (&(UsrFigures->FirstClickTime),row[0])))
|
||||
Lay_ShowErrorAndExit ("Error when reading first click time.");
|
||||
}
|
||||
else
|
||||
if (!(Dat_GetDateTimeFromYYYYMMDDHHMMSS (&(UsrFigures->FirstClickTime),"00000000000000")))
|
||||
Lay_ShowErrorAndExit ("Error when reading first click time.");
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
||||
/***** Get first click from database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM log WHERE UsrCod='%ld'",
|
||||
UsrCod);
|
||||
UsrFigures->NumClicks = DB_QueryCOUNT (Query,"can not get user's first click");
|
||||
|
||||
/***** Insert new user's figures *****/
|
||||
if (UsrFigures->FirstClickTime.Date.Year) // If first click time found
|
||||
{
|
||||
sprintf (Query,"INSERT INTO usr_figures (UsrCod,FirstClickTime,NumClicks)"
|
||||
" VALUES ('%ld','%s','%ld')",
|
||||
UsrCod,
|
||||
UsrFigures->FirstClickTime.YYYYMMDDHHMMSS,
|
||||
UsrFigures->NumClicks);
|
||||
DB_QueryINSERT (Query,"can not insert user's figures");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************** Select values on user's figures **********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Usr_IncrementNumClicksUsr (void)
|
||||
{
|
||||
char Query[512];
|
||||
|
||||
/***** Increment my number of clicks *****/
|
||||
sprintf (Query,"UPDATE IGNORE usr_figures SET NumClicks=NumClicks+1"
|
||||
" WHERE UsrCod='%ld'",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
DB_QueryINSERT (Query,"can not increment user's clicks");
|
||||
}
|
||||
|
|
|
@ -328,5 +328,6 @@ void Usr_RequestUserProfile (void);
|
|||
void Usr_ShowUserProfile (void);
|
||||
void Usr_ChangeProfileVisibility (void);
|
||||
void Usr_ShowDetailsUserProfile (const struct UsrData *UsrDat);
|
||||
void Usr_IncrementNumClicksUsr (void);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user