mirror of https://github.com/acanas/swad-core.git
Version18.92.3
This commit is contained in:
parent
8873e4d2eb
commit
cd04ddb7ea
|
@ -1414,6 +1414,8 @@ CREATE TABLE IF NOT EXISTS usr_last (
|
||||||
WhatToSearch TINYINT NOT NULL DEFAULT 0,
|
WhatToSearch TINYINT NOT NULL DEFAULT 0,
|
||||||
LastCrs INT NOT NULL DEFAULT -1,
|
LastCrs INT NOT NULL DEFAULT -1,
|
||||||
LastTab TINYINT NOT NULL,
|
LastTab TINYINT NOT NULL,
|
||||||
|
LastAct INT NOT NULL DEFAULT -1,
|
||||||
|
LastRole TINYINT NOT NULL DEFAULT 0,
|
||||||
LastTime DATETIME NOT NULL,
|
LastTime DATETIME NOT NULL,
|
||||||
LastAccNotif DATETIME NOT NULL,
|
LastAccNotif DATETIME NOT NULL,
|
||||||
TimelineUsrs TINYINT NOT NULL DEFAULT 0,
|
TimelineUsrs TINYINT NOT NULL DEFAULT 0,
|
||||||
|
|
|
@ -464,10 +464,15 @@ En OpenSWAD:
|
||||||
ps2pdf source.ps destination.pdf
|
ps2pdf source.ps destination.pdf
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 18.92.2 (2019-04-01)"
|
#define Log_PLATFORM_VERSION "SWAD 18.92.3 (2019-04-01)"
|
||||||
#define CSS_FILE "swad18.92.css"
|
#define CSS_FILE "swad18.92.css"
|
||||||
#define JS_FILE "swad18.92.js"
|
#define JS_FILE "swad18.92.js"
|
||||||
/*
|
/*
|
||||||
|
Version 18.92.3: Apr 01, 2019 Last action and role are saved in database. (241410 lines)
|
||||||
|
2 changes necessary in database:
|
||||||
|
ALTER TABLE usr_last ADD COLUMN LastAct INT NOT NULL DEFAULT -1 AFTER LastTab;
|
||||||
|
ALTER TABLE usr_last ADD COLUMN LastRole TINYINT NOT NULL DEFAULT 0 AFTER LastAct;
|
||||||
|
|
||||||
Version 18.92.2: Apr 01, 2019 Code refactoring related to user login and actions. (241379 lines)
|
Version 18.92.2: Apr 01, 2019 Code refactoring related to user login and actions. (241379 lines)
|
||||||
Version 18.92.1: Apr 01, 2019 Fixed bug in tests, reported by Javier Fernández Baldomero. (241371 lines)
|
Version 18.92.1: Apr 01, 2019 Fixed bug in tests, reported by Javier Fernández Baldomero. (241371 lines)
|
||||||
Version 18.92: Mar 29, 2019 Changes in timeline layout. (241367 lines)
|
Version 18.92: Mar 29, 2019 Changes in timeline layout. (241367 lines)
|
||||||
|
|
|
@ -2977,17 +2977,21 @@ mysql> DESCRIBE usr_last;
|
||||||
| WhatToSearch | tinyint(4) | NO | | 0 | |
|
| WhatToSearch | tinyint(4) | NO | | 0 | |
|
||||||
| LastCrs | int(11) | NO | | -1 | |
|
| LastCrs | int(11) | NO | | -1 | |
|
||||||
| LastTab | tinyint(4) | NO | | NULL | |
|
| LastTab | tinyint(4) | NO | | NULL | |
|
||||||
|
| LastAct | int(11) | NO | | -1 | |
|
||||||
|
| LastRole | tinyint(4) | NO | | 0 | |
|
||||||
| LastTime | datetime | NO | MUL | NULL | |
|
| LastTime | datetime | NO | MUL | NULL | |
|
||||||
| LastAccNotif | datetime | NO | | NULL | |
|
| LastAccNotif | datetime | NO | | NULL | |
|
||||||
| TimelineUsrs | tinyint(4) | NO | | 0 | |
|
| TimelineUsrs | tinyint(4) | NO | | 0 | |
|
||||||
+--------------+------------+------+-----+---------+-------+
|
+--------------+------------+------+-----+---------+-------+
|
||||||
7 rows in set (0.00 sec)
|
9 rows in set (0.00 sec)
|
||||||
*/
|
*/
|
||||||
DB_CreateTable ("CREATE TABLE IF NOT EXISTS usr_last ("
|
DB_CreateTable ("CREATE TABLE IF NOT EXISTS usr_last ("
|
||||||
"UsrCod INT NOT NULL,"
|
"UsrCod INT NOT NULL,"
|
||||||
"WhatToSearch TINYINT NOT NULL DEFAULT 0,"
|
"WhatToSearch TINYINT NOT NULL DEFAULT 0,"
|
||||||
"LastCrs INT NOT NULL DEFAULT -1,"
|
"LastCrs INT NOT NULL DEFAULT -1,"
|
||||||
"LastTab TINYINT NOT NULL,"
|
"LastTab TINYINT NOT NULL,"
|
||||||
|
"LastAct INT NOT NULL DEFAULT -1,"
|
||||||
|
"LastRole TINYINT NOT NULL DEFAULT 0,"
|
||||||
"LastTime DATETIME NOT NULL,"
|
"LastTime DATETIME NOT NULL,"
|
||||||
"LastAccNotif DATETIME NOT NULL,"
|
"LastAccNotif DATETIME NOT NULL,"
|
||||||
"TimelineUsrs TINYINT NOT NULL DEFAULT 0,"
|
"TimelineUsrs TINYINT NOT NULL DEFAULT 0,"
|
||||||
|
|
|
@ -1343,6 +1343,13 @@ void Lay_ShowErrorAndExit (const char *Txt)
|
||||||
/***** Log access *****/
|
/***** Log access *****/
|
||||||
Sta_LogAccess (Txt);
|
Sta_LogAccess (Txt);
|
||||||
|
|
||||||
|
/***** Update last data for next time *****/
|
||||||
|
if (Gbl.Usrs.Me.Logged)
|
||||||
|
{
|
||||||
|
Usr_UpdateMyLastData ();
|
||||||
|
Crs_UpdateCrsLast ();
|
||||||
|
}
|
||||||
|
|
||||||
/***** End the output *****/
|
/***** End the output *****/
|
||||||
if (!Gbl.Layout.HTMLEndWritten)
|
if (!Gbl.Layout.HTMLEndWritten)
|
||||||
{
|
{
|
||||||
|
|
45
swad_user.c
45
swad_user.c
|
@ -755,13 +755,16 @@ static void Usr_GetMyLastData (void)
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
unsigned UnsignedNum;
|
unsigned UnsignedNum;
|
||||||
|
long ActCod;
|
||||||
|
|
||||||
/***** Get user's last data from database *****/
|
/***** Get user's last data from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get user's last data",
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get user's last data",
|
||||||
"SELECT WhatToSearch," // row[0]
|
"SELECT WhatToSearch," // row[0]
|
||||||
"LastCrs," // row[1]
|
"LastCrs," // row[1]
|
||||||
"LastTab," // row[2]
|
"LastTab," // row[2]
|
||||||
"UNIX_TIMESTAMP(LastAccNotif)" // row[3]
|
"LastAct," // row[3]
|
||||||
|
"LastRole," // row[4]
|
||||||
|
"UNIX_TIMESTAMP(LastAccNotif)" // row[5]
|
||||||
" FROM usr_last WHERE UsrCod=%ld",
|
" FROM usr_last WHERE UsrCod=%ld",
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
if (NumRows == 0)
|
if (NumRows == 0)
|
||||||
|
@ -777,7 +780,7 @@ static void Usr_GetMyLastData (void)
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get last type of search */
|
/* Get last type of search (row[0]) */
|
||||||
Gbl.Usrs.Me.UsrLast.WhatToSearch = Sch_SEARCH_UNKNOWN;
|
Gbl.Usrs.Me.UsrLast.WhatToSearch = Sch_SEARCH_UNKNOWN;
|
||||||
if (sscanf (row[0],"%u",&UnsignedNum) == 1)
|
if (sscanf (row[0],"%u",&UnsignedNum) == 1)
|
||||||
if (UnsignedNum < Sch_NUM_WHAT_TO_SEARCH)
|
if (UnsignedNum < Sch_NUM_WHAT_TO_SEARCH)
|
||||||
|
@ -785,20 +788,27 @@ static void Usr_GetMyLastData (void)
|
||||||
if (Gbl.Usrs.Me.UsrLast.WhatToSearch == Sch_SEARCH_UNKNOWN)
|
if (Gbl.Usrs.Me.UsrLast.WhatToSearch == Sch_SEARCH_UNKNOWN)
|
||||||
Gbl.Usrs.Me.UsrLast.WhatToSearch = Sch_WHAT_TO_SEARCH_DEFAULT;
|
Gbl.Usrs.Me.UsrLast.WhatToSearch = Sch_WHAT_TO_SEARCH_DEFAULT;
|
||||||
|
|
||||||
/* Get last course */
|
/* Get last course (row[1]) */
|
||||||
Gbl.Usrs.Me.UsrLast.LastCrs = Str_ConvertStrCodToLongCod (row[1]);
|
Gbl.Usrs.Me.UsrLast.LastCrs = Str_ConvertStrCodToLongCod (row[1]);
|
||||||
|
|
||||||
/* Get last tab */
|
/* Get last tab (row[2]) */
|
||||||
Gbl.Usrs.Me.UsrLast.LastTab = TabStr; // By default, set last tab to the start tab
|
Gbl.Usrs.Me.UsrLast.LastTab = TabStr; // By default, set last tab to the start tab
|
||||||
if (sscanf (row[2],"%u",&UnsignedNum) == 1)
|
if (sscanf (row[2],"%u",&UnsignedNum) == 1)
|
||||||
if (UnsignedNum >= 1 ||
|
if (UnsignedNum >= 1 ||
|
||||||
UnsignedNum <= Tab_NUM_TABS)
|
UnsignedNum <= Tab_NUM_TABS)
|
||||||
Gbl.Usrs.Me.UsrLast.LastTab = (Tab_Tab_t) UnsignedNum;
|
Gbl.Usrs.Me.UsrLast.LastTab = (Tab_Tab_t) UnsignedNum;
|
||||||
|
|
||||||
/* Get last access to notifications */
|
/* Get last action (row[3]) */
|
||||||
|
ActCod = Str_ConvertStrCodToLongCod (row[3]);
|
||||||
|
Gbl.Usrs.Me.UsrLast.LastAct = Act_GetActionFromActCod (ActCod);
|
||||||
|
|
||||||
|
/* Get last rolw (row[4]) */
|
||||||
|
Gbl.Usrs.Me.UsrLast.LastRole = Rol_ConvertUnsignedStrToRole (row[4]);
|
||||||
|
|
||||||
|
/* Get last access to notifications (row[5]) */
|
||||||
Gbl.Usrs.Me.UsrLast.LastAccNotif = 0L;
|
Gbl.Usrs.Me.UsrLast.LastAccNotif = 0L;
|
||||||
if (row[3])
|
if (row[5])
|
||||||
sscanf (row[3],"%ld",&(Gbl.Usrs.Me.UsrLast.LastAccNotif));
|
sscanf (row[5],"%ld",&(Gbl.Usrs.Me.UsrLast.LastAccNotif));
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -3117,11 +3127,11 @@ void Usr_ChkUsrAndGetUsrData (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Update last data for next time *****/
|
/***** Update last data for next time *****/
|
||||||
if (Gbl.Usrs.Me.Logged)
|
// if (Gbl.Usrs.Me.Logged)
|
||||||
{
|
// {
|
||||||
Usr_UpdateMyLastData ();
|
// Usr_UpdateMyLastData ();
|
||||||
Crs_UpdateCrsLast ();
|
// Crs_UpdateCrsLast ();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3483,10 +3493,13 @@ void Usr_UpdateMyLastData (void)
|
||||||
/***** Update my last accessed course, tab and time of click in database *****/
|
/***** Update my last accessed course, tab and time of click in database *****/
|
||||||
// WhatToSearch, LastAccNotif remain unchanged
|
// WhatToSearch, LastAccNotif remain unchanged
|
||||||
DB_QueryUPDATE ("can not update last user's data",
|
DB_QueryUPDATE ("can not update last user's data",
|
||||||
"UPDATE usr_last SET LastCrs=%ld,LastTab=%u,LastTime=NOW()"
|
"UPDATE usr_last"
|
||||||
|
" SET LastCrs=%ld,LastTab=%u,LastAct=%ld,LastRole=%u,LastTime=NOW()"
|
||||||
" WHERE UsrCod=%ld",
|
" WHERE UsrCod=%ld",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
(unsigned) Gbl.Action.Tab,
|
(unsigned) Gbl.Action.Tab,
|
||||||
|
Act_GetActCod (Gbl.Action.Act),
|
||||||
|
(unsigned) Gbl.Usrs.Me.Role.Logged,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
else
|
else
|
||||||
Usr_InsertMyLastData ();
|
Usr_InsertMyLastData ();
|
||||||
|
@ -3501,13 +3514,15 @@ static void Usr_InsertMyLastData (void)
|
||||||
/***** Insert my last accessed course, tab and time of click in database *****/
|
/***** Insert my last accessed course, tab and time of click in database *****/
|
||||||
DB_QueryINSERT ("can not insert last user's data",
|
DB_QueryINSERT ("can not insert last user's data",
|
||||||
"INSERT INTO usr_last"
|
"INSERT INTO usr_last"
|
||||||
" (UsrCod,WhatToSearch,LastCrs,LastTab,LastTime,LastAccNotif)"
|
" (UsrCod,WhatToSearch,LastCrs,LastTab,LastAct,LastRole,LastTime,LastAccNotif)"
|
||||||
" VALUES"
|
" VALUES"
|
||||||
" (%ld,%u,%ld,%u,NOW(),FROM_UNIXTIME(%ld))",
|
" (%ld,%u,%ld,%u,%ld,%u,NOW(),FROM_UNIXTIME(%ld))",
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
(unsigned) Sch_SEARCH_ALL,
|
(unsigned) Sch_SEARCH_ALL,
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
(unsigned) Gbl.Action.Tab,
|
(unsigned) Gbl.Action.Tab,
|
||||||
|
Act_GetActCod (Gbl.Action.Act),
|
||||||
|
(unsigned) Gbl.Usrs.Me.Role.Logged,
|
||||||
(long) (time_t) 0); // The user never accessed to notifications
|
(long) (time_t) 0); // The user never accessed to notifications
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -214,6 +214,8 @@ struct UsrLast
|
||||||
Sch_WhatToSearch_t WhatToSearch; // Search courses, teachers, documents...?
|
Sch_WhatToSearch_t WhatToSearch; // Search courses, teachers, documents...?
|
||||||
long LastCrs;
|
long LastCrs;
|
||||||
Tab_Tab_t LastTab;
|
Tab_Tab_t LastTab;
|
||||||
|
Act_Action_t LastAct;
|
||||||
|
Rol_Role_t LastRole;
|
||||||
long LastAccNotif;
|
long LastAccNotif;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue