From a6d52e10501eb0b646f06097d176ce2a0492936b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Wed, 3 Apr 2019 22:08:44 +0200 Subject: [PATCH] Version18.94.2 --- swad_changelog.h | 3 ++- swad_config.h | 2 +- swad_user.c | 26 +++++++++++++++----------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index be435f87..b548a894 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -464,10 +464,11 @@ En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 18.94.1 (2019-04-03)" +#define Log_PLATFORM_VERSION "SWAD 18.94.2 (2019-04-03)" #define CSS_FILE "swad18.92.css" #define JS_FILE "swad18.92.js" /* + Version 18.94.2: Apr 03, 2019 Remember last role even if last access is old. (241531 lines) Version 18.94.1: Apr 03, 2019 Remember last action and role after login only if last access is recent. (241526 lines) Version 18.94: Apr 03, 2019 Code refactoring related to hierarchy. (241513 lines) Version 18.93: Apr 01, 2019 When a user logs in, hierarchy, action and role are got from database. (241533 lines) diff --git a/swad_config.h b/swad_config.h index 3ec451f3..1aeecba9 100644 --- a/swad_config.h +++ b/swad_config.h @@ -533,7 +533,7 @@ #define Cfg_MIN_TIME_TO_RECOMPUTE_AVG_PHOTO ((time_t)( 12UL * 60UL * 60UL)) // After these seconds, users can recompute the average photos of a degree -#define Cfg_MAX_TIME_TO_REMEMBER_LAST_ACTION_ON_LOGIN ((time_t)( 2UL * 60UL * 60UL)) // On login, if interval since last action is less than this time, remember last action and role +#define Cfg_MAX_TIME_TO_REMEMBER_LAST_ACTION_ON_LOGIN ((time_t)( 2UL * 60UL * 60UL)) // On login, if interval since last action is less than this time, remember last action /*****************************************************************************/ /***************************** Public prototypes *****************************/ diff --git a/swad_user.c b/swad_user.c index 77fc69bc..1e6b5ae3 100644 --- a/swad_user.c +++ b/swad_user.c @@ -3337,7 +3337,7 @@ static void Usr_SetMyPrefsAndRoles (void) extern const char *The_ThemeId[The_NUM_THEMES]; extern const char *Ico_IconSetId[Ico_NUM_ICON_SETS]; char URL[PATH_MAX + 1]; - bool GetActionAndRoleFromLastData; + bool GetRoleAndActionFromLastData; Act_Action_t LastSuperAction; bool JustAfterLogin = Gbl.Action.Act == ActLogIn || Gbl.Action.Act == ActLogInLan || @@ -3399,19 +3399,23 @@ static void Usr_SetMyPrefsAndRoles (void) Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Valid = true; } - // Action and role will be got from last data - GetActionAndRoleFromLastData = true; + // role and action will be got from last data + GetRoleAndActionFromLastData = true; } else // Country (and may be institution, centre, degree or course) selected - // Action and role will be got from last data + // Role and action will be got from last data // only if I am in the same hierarchy location that the stored one - GetActionAndRoleFromLastData = + GetRoleAndActionFromLastData = (Gbl.Hierarchy.Level == Gbl.Usrs.Me.UsrLast.LastHie.Scope && // The same scope... Gbl.Hierarchy.Cod == Gbl.Usrs.Me.UsrLast.LastHie.Cod); // ...and code in hierarchy - /***** Get action and role from last data *****/ - if (GetActionAndRoleFromLastData) - // Remember last action and role only if last access is recent + /***** Get role and action from last data *****/ + if (GetRoleAndActionFromLastData) + { + /* Get role from last data */ + Gbl.Usrs.Me.Role.Logged = Gbl.Usrs.Me.UsrLast.LastRole; + + /* Last action is really got only if last access is recent */ if (Gbl.Usrs.Me.UsrLast.LastTime >= Gbl.StartExecutionTimeUTC - Cfg_MAX_TIME_TO_REMEMBER_LAST_ACTION_ON_LOGIN) { @@ -3422,10 +3426,10 @@ static void Usr_SetMyPrefsAndRoles (void) Gbl.Action.Act = LastSuperAction; Tab_SetCurrentTab (); } - - /* Get role from last data */ - Gbl.Usrs.Me.Role.Logged = Gbl.Usrs.Me.UsrLast.LastRole; } + /* If action is not set to last action, + it will be set later to a default action */ + } } /***** Set my roles *****/