From 4499b07d3bef579adaffc2900c7652a21ec3f70d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Fri, 23 Jun 2017 15:12:49 +0200 Subject: [PATCH] Version 16.247.2 --- swad_changelog.h | 4 +- swad_enrolment.c | 16 ++++---- swad_group.c | 22 ++++++++--- swad_profile.c | 2 +- swad_record.c | 6 +-- swad_role.c | 4 +- swad_role_type.h | 12 +++--- swad_user.c | 94 ++++++++++++++++++++++++++++++++++------------ swad_user.h | 4 +- swad_web_service.c | 32 ++++++++++------ 10 files changed, 134 insertions(+), 62 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 89aaa80d..71338b6a 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -236,13 +236,15 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.247.1 (2017-06-23)" +#define Log_PLATFORM_VERSION "SWAD 16.247.2 (2017-06-23)" #define CSS_FILE "swad16.235.1.css" #define JS_FILE "swad16.206.3.js" // 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 sql/swad*.sql | tail -1 /* + Version 16.247.2: Jun 23, 2017 Non-editing teachers can not view records of users who do not share groups with them. + Code refactoring related with roles. (222094 lines) Version 16.247.1: Jun 23, 2017 Non-editing teachers can select all groups when writing a message. (222068 lines) Version 16.247: Jun 20, 2017 Fixed bug when removing a user from a course. Code refactoring related with caches. (222063 lines) diff --git a/swad_enrolment.c b/swad_enrolment.c index 0e4972b5..d34298f1 100644 --- a/swad_enrolment.c +++ b/swad_enrolment.c @@ -230,8 +230,8 @@ void Enr_ModifyRoleInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole) activate the sending of a notification *****/ Enr_NotifyAfterEnrolment (UsrDat,NewRole); - UsrDat->Roles.InCurrentCrs.Role = NewRole; - UsrDat->Roles.InCurrentCrs.GotFromDBForUsrCod = UsrDat->UsrCod; + UsrDat->Roles.InCurrentCrs.Role = NewRole; + UsrDat->Roles.InCurrentCrs.Valid = true; UsrDat->Roles.InCrss = -1; // Force roles to be got from database Rol_GetRolesInAllCrssIfNotYetGot (UsrDat); // Get roles } @@ -279,8 +279,8 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole, Usr_LIST_WITH_PHOTOS_DEF ? 'Y' : 'N'); DB_QueryINSERT (Query,"can not register user in course"); - UsrDat->Roles.InCurrentCrs.Role = NewRole; - UsrDat->Roles.InCurrentCrs.GotFromDBForUsrCod = UsrDat->UsrCod; + UsrDat->Roles.InCurrentCrs.Role = NewRole; + UsrDat->Roles.InCurrentCrs.Valid = true; UsrDat->Roles.InCrss = -1; // Force roles to be got from database Rol_GetRolesInAllCrssIfNotYetGot (UsrDat); // Get roles @@ -3921,8 +3921,8 @@ void Enr_ModifyUsr1 (void) /***** If it's me, change my roles *****/ if (ItsMe) { - Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role = Gbl.Usrs.Other.UsrDat.Roles.InCurrentCrs.Role; - Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.GotFromDBForUsrCod = Gbl.Usrs.Other.UsrDat.UsrCod; + Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role = Gbl.Usrs.Other.UsrDat.Roles.InCurrentCrs.Role; + Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Valid = true; Gbl.Usrs.Me.UsrDat.Roles.InCrss = Gbl.Usrs.Other.UsrDat.Roles.InCrss; Rol_SetMyRoles (); } @@ -4202,8 +4202,8 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,struct Course * Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role = UsrDat->Roles.InCurrentCrs.Role = Rol_UNK; - Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.GotFromDBForUsrCod = - UsrDat->Roles.InCurrentCrs.GotFromDBForUsrCod = UsrDat->UsrCod; + Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Valid = + UsrDat->Roles.InCurrentCrs.Valid = true; Gbl.Usrs.Me.UsrDat.Roles.InCrss = UsrDat->Roles.InCrss = -1; // not yet filled/calculated diff --git a/swad_group.c b/swad_group.c index d2fa1ef7..a3790b66 100644 --- a/swad_group.c +++ b/swad_group.c @@ -3280,12 +3280,12 @@ bool Grp_GetIfIBelongToGrp (long GrpCod) sprintf (Query,"SELECT COUNT(*) FROM crs_grp_usr" " WHERE GrpCod=%ld AND UsrCod=%ld", GrpCod,Gbl.Usrs.Me.UsrDat.UsrCod); - Gbl.Cache.IBelongToGrp.IBelong = DB_QueryCOUNT (Query,"can not check if you belong to a group") != 0; Gbl.Cache.IBelongToGrp.GrpCod = GrpCod; + Gbl.Cache.IBelongToGrp.IBelong = (DB_QueryCOUNT (Query,"can not check" + " if you belong to a group") != 0); return Gbl.Cache.IBelongToGrp.IBelong; } - /*****************************************************************************/ /*************** Check if a user belongs to any of my courses ****************/ /*****************************************************************************/ @@ -3333,7 +3333,17 @@ bool Grp_CheckIfUsrSharesAnyOfMyGrpsInCurrentCrs (const struct UsrData *UsrDat) return false; } - /***** 8. Slow check: Get if user shares any group in this course with me from database *****/ + /***** 8. Fast check: Course has groups? *****/ + if (!Gbl.CurrentCrs.Grps.NumGrps) + { + Gbl.Cache.UsrSharesAnyOfMyGrpsInCurrentCrs.UsrCod = UsrDat->UsrCod; + Gbl.Cache.UsrSharesAnyOfMyGrpsInCurrentCrs.Shares = true; + return true; + } + + // Course has groups + + /***** 9. Slow check: Get if user shares any group in this course with me from database *****/ /* Check if user shares any group with me */ Gbl.Cache.UsrSharesAnyOfMyGrpsInCurrentCrs.UsrCod = UsrDat->UsrCod; sprintf (Query,"SELECT COUNT(*) FROM crs_grp_usr" @@ -3348,9 +3358,9 @@ bool Grp_CheckIfUsrSharesAnyOfMyGrpsInCurrentCrs (const struct UsrData *UsrDat) UsrDat->UsrCod, Gbl.Usrs.Me.UsrDat.UsrCod, Gbl.CurrentCrs.Crs.CrsCod); - Gbl.Cache.UsrSharesAnyOfMyGrpsInCurrentCrs.Shares = DB_QueryCOUNT (Query,"can not check" - " if a user shares any group" - " in the current course with you") != 0; + Gbl.Cache.UsrSharesAnyOfMyGrpsInCurrentCrs.Shares = (DB_QueryCOUNT (Query,"can not check" + " if a user shares any group" + " in the current course with you") != 0); return Gbl.Cache.UsrSharesAnyOfMyGrpsInCurrentCrs.Shares; } diff --git a/swad_profile.c b/swad_profile.c index 5f748aab..536e90a3 100644 --- a/swad_profile.c +++ b/swad_profile.c @@ -287,7 +287,7 @@ bool Prf_ShowUserProfile (struct UsrData *UsrDat) /* Get user's role in current course */ UsrDat->Roles.InCurrentCrs.Role = Rol_GetRoleUsrInCrs (UsrDat->UsrCod, Gbl.CurrentCrs.Crs.CrsCod); - UsrDat->Roles.InCurrentCrs.GotFromDBForUsrCod = UsrDat->UsrCod; + UsrDat->Roles.InCurrentCrs.Valid = true; /* Get if user has accepted enrolment in current course */ UsrDat->Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (UsrDat); diff --git a/swad_record.c b/swad_record.c index 8c3e0ae6..a2b71c72 100644 --- a/swad_record.c +++ b/swad_record.c @@ -2137,9 +2137,9 @@ void Rec_ShowFormOtherNewSharedRecord (struct UsrData *UsrDat,Rol_Role_t Default /* In this case UsrDat->Roles.InCurrentCrsDB is not the current role in current course. Instead it is initialized with the preferred role. */ - UsrDat->Roles.InCurrentCrs.Role = (Gbl.CurrentCrs.Crs.CrsCod > 0) ? DefaultRole : // Course selected - Rol_UNK; // No course selected - UsrDat->Roles.InCurrentCrs.GotFromDBForUsrCod = UsrDat->UsrCod; + UsrDat->Roles.InCurrentCrs.Role = (Gbl.CurrentCrs.Crs.CrsCod > 0) ? DefaultRole : // Course selected + Rol_UNK; // No course selected + UsrDat->Roles.InCurrentCrs.Valid = true; Rec_ShowSharedUsrRecord (Rec_SHA_OTHER_NEW_USR_FORM,UsrDat,NULL); } diff --git a/swad_role.c b/swad_role.c index dbe0415a..59381bb5 100644 --- a/swad_role.c +++ b/swad_role.c @@ -68,10 +68,10 @@ void Rol_SetMyRoles (void) bool ICanBeDegAdm = false; /***** Get my role in current course if not yet filled *****/ - if (Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.GotFromDBForUsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) + if (!Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Valid) { Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role = Rol_GetMyRoleInCrs (Gbl.CurrentCrs.Crs.CrsCod); - Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.GotFromDBForUsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; + Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Valid = true; } /***** Set the user's role I am logged *****/ diff --git a/swad_role_type.h b/swad_role_type.h index 81d776f9..f3c38c78 100644 --- a/swad_role_type.h +++ b/swad_role_type.h @@ -48,13 +48,15 @@ typedef enum Rol_USR = 2, // Student, non-editing teacher or teacher in some courses... // ...but no course selected // ...or not belonging to the current course + Rol_STD = 3, // Student in the current course Rol_NET = 4, // Non-editing teacher in the current course - Rol_TCH = 5, // Old 4 // Teacher in the current course - Rol_DEG_ADM = 6, // Old 5 // Degree administrator - Rol_CTR_ADM = 7, // Old 6 // Centre administrator - Rol_INS_ADM = 8, // Old 7 // Institution administrator - Rol_SYS_ADM = 9, // Old 8 // System administrator (superuser) + Rol_TCH = 5, // Teacher in the current course + + Rol_DEG_ADM = 6, // Degree administrator + Rol_CTR_ADM = 7, // Centre administrator + Rol_INS_ADM = 8, // Institution administrator + Rol_SYS_ADM = 9, // System administrator (superuser) } Rol_Role_t; #endif diff --git a/swad_user.c b/swad_user.c index 222f0882..cd023b16 100644 --- a/swad_user.c +++ b/swad_user.c @@ -295,8 +295,8 @@ void Usr_ResetUsrDataExceptUsrCodAndIDs (struct UsrData *UsrDat) UsrDat->EncryptedUsrCod[0] = '\0'; UsrDat->Nickname[0] = '\0'; UsrDat->Password[0] = '\0'; - UsrDat->Roles.InCurrentCrs.Role = Rol_UNK; - UsrDat->Roles.InCurrentCrs.GotFromDBForUsrCod = -1L; + UsrDat->Roles.InCurrentCrs.Role = Rol_UNK; + UsrDat->Roles.InCurrentCrs.Valid = false; UsrDat->Roles.InCrss = -1; // < 0 ==> not yet got from database UsrDat->Accepted = true; @@ -522,7 +522,7 @@ void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat) /* Get roles */ UsrDat->Roles.InCurrentCrs.Role = Rol_GetRoleUsrInCrs (UsrDat->UsrCod, Gbl.CurrentCrs.Crs.CrsCod); - UsrDat->Roles.InCurrentCrs.GotFromDBForUsrCod = UsrDat->UsrCod; + UsrDat->Roles.InCurrentCrs.Valid = true; UsrDat->Roles.InCrss = -1; // Force roles to be got from database Rol_GetRolesInAllCrssIfNotYetGot (UsrDat); @@ -1045,16 +1045,45 @@ unsigned Usr_GetNumUsrsInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole, bool Usr_CheckIfICanViewRecordStd (const struct UsrData *UsrDat) { - if (UsrDat->Roles.InCurrentCrs.Role != Rol_STD) // Not a student in the current course + /***** 1. Fast check: Am I logged? *****/ + if (!Gbl.Usrs.Me.Logged) return false; - // The user is a student in the current course + /***** 2. Fast check: Is it a valid user code? *****/ + if (UsrDat->UsrCod <= 0) + return false; + + /***** 3. Fast check: Is it a course selected? *****/ + if (Gbl.CurrentCrs.Crs.CrsCod <= 0) + return false; + + /***** 4. Fast check: Is he/she a student? *****/ + if (UsrDat->Roles.InCurrentCrs.Role != Rol_STD) + return false; + + /***** 5. Fast check: Am I a system admin? *****/ + if (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) + return true; + + /***** 6. Fast check: Do I belong to the current course? *****/ + if (!Gbl.Usrs.Me.IBelongToCurrentCrs) + return false; + + /***** 7. Fast check: It's me? *****/ + if (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod) + return true; + + /***** 8. Fast / slow check: Does he/she belong to the current course? *****/ + if (!Usr_CheckIfUsrBelongsToCurrentCrs (UsrDat)) + return false; + + /***** 9. Fast / slow check depending on roles *****/ switch (Gbl.Usrs.Me.Role.Logged) { case Rol_STD: case Rol_NET: + return Grp_CheckIfUsrSharesAnyOfMyGrpsInCurrentCrs (UsrDat); case Rol_TCH: - case Rol_SYS_ADM: return true; default: return false; @@ -1074,23 +1103,39 @@ bool Usr_CheckIfICanViewRecordTch (struct UsrData *UsrDat) if (!Gbl.Usrs.Me.Logged) return false; - /***** 2. Fast/slow check: Is he/she a non-editing teacher or a teacher in any course? *****/ - Rol_GetRolesInAllCrssIfNotYetGot (UsrDat); - if ((UsrDat->Roles.InCrss & ((1 << Rol_NET) | - (1 << Rol_TCH))) == 0) + /***** 2. Fast check: Is it a valid user code? *****/ + if (UsrDat->UsrCod <= 0) return false; - // He/she is a non-editing teacher or a teacher in any course + if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected + { + /***** 3. Fast check: Is he/she a non-editing teacher or a teacher? *****/ + if (UsrDat->Roles.InCurrentCrs.Role != Rol_NET && + UsrDat->Roles.InCurrentCrs.Role != Rol_TCH) + return false; - /***** 3. Fast check: It's me? *****/ + // He/she is a non-editing teacher or a teacher in this course + } + else // No course selected + { + /***** 3. Fast/slow check: Is he/she a non-editing teacher or a teacher in any course? *****/ + Rol_GetRolesInAllCrssIfNotYetGot (UsrDat); + if ((UsrDat->Roles.InCrss & ((1 << Rol_NET) | + (1 << Rol_TCH))) == 0) + return false; + + // He/she is a non-editing teacher or a teacher in any course + } + + /***** 4. Fast check: It's me? *****/ if (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod) return true; - /***** 4. Fast check: Am I logged as system admin? *****/ + /***** 5. Fast check: Am I a system admin? *****/ if (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) return true; - /***** 5. Slow check: Get if user shares any course with me from database *****/ + /***** 6. Slow check: Get if user shares any course with me from database *****/ return Usr_CheckIfUsrSharesAnyOfMyCrs (UsrDat); } @@ -1112,25 +1157,28 @@ bool Usr_CheckIfICanViewWrkTstAtt (const struct UsrData *UsrDat) if (Gbl.CurrentCrs.Crs.CrsCod <= 0) return false; - /***** 4. Fast check: Do I belong to the current course? *****/ + /***** 4. Fast check: Am I a system admin? *****/ + if (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) + return true; + + /***** 5. Fast check: Do I belong to the current course? *****/ if (!Gbl.Usrs.Me.IBelongToCurrentCrs) return false; - /***** 5. Fast check: It's me? *****/ + /***** 6. Fast check: It's me? *****/ if (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod) return true; - /***** 6. Fast check: Does he/she belong to the current course? *****/ + /***** 7. Fast check: Does he/she belong to the current course? *****/ if (!Usr_CheckIfUsrBelongsToCurrentCrs (UsrDat)) return false; - /***** 7. Fast / slow check depending on roles *****/ + /***** 8. Fast / slow check depending on roles *****/ switch (Gbl.Usrs.Me.Role.Logged) { case Rol_NET: return Grp_CheckIfUsrSharesAnyOfMyGrpsInCurrentCrs (UsrDat); case Rol_TCH: - case Rol_SYS_ADM: return true; default: return false; @@ -1197,8 +1245,8 @@ bool Usr_CheckIfUsrSharesAnyOfMyCrs (struct UsrData *UsrDat) /***** 6. Fast/slow check: Does he/she belong to any course? *****/ Rol_GetRolesInAllCrssIfNotYetGot (UsrDat); if (!(UsrDat->Roles.InCrss & ((1 << Rol_STD) | // Any of his/her roles is student - (1 << Rol_NET) | // or non-editing teacher - (1 << Rol_TCH)))) // or teacher? + (1 << Rol_NET) | // or non-editing teacher + (1 << Rol_TCH)))) // or teacher? return false; /***** 7. Slow check: Get if user shares any course with me from database *****/ @@ -1794,7 +1842,7 @@ bool Usr_CheckIfUsrBelongsToCurrentCrs (const struct UsrData *UsrDat) return Gbl.Cache.UsrBelongsToCurrentCrs.Belongs; /***** 3. Fast check: If we know role of user in the current course *****/ - if (UsrDat->Roles.InCurrentCrs.GotFromDBForUsrCod == UsrDat->UsrCod) + if (UsrDat->Roles.InCurrentCrs.Valid) { Gbl.Cache.UsrBelongsToCurrentCrs.UsrCod = UsrDat->UsrCod; Gbl.Cache.UsrBelongsToCurrentCrs.Belongs = UsrDat->Roles.InCurrentCrs.Role == Rol_STD || @@ -3049,7 +3097,7 @@ static void Usr_SetMyPrefsAndRoles (void) /* Get again my role in this course */ Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role = Rol_GetRoleUsrInCrs (Gbl.Usrs.Me.UsrDat.UsrCod, Gbl.CurrentCrs.Crs.CrsCod); - Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.GotFromDBForUsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; + Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Valid = true; } } diff --git a/swad_user.h b/swad_user.h index 8970e169..7696a287 100644 --- a/swad_user.h +++ b/swad_user.h @@ -133,7 +133,7 @@ struct UsrData { struct { - long GotFromDBForUsrCod; // Role was got from database for this user (used to not retrieve role if already retrieved) + bool Valid; // Role is not valid (for examples, it has not been trtriev Rol_Role_t Role; } InCurrentCrs; // Role in current course (Rol_UNK is no course selected) int InCrss; // Roles in all his/her courses @@ -262,10 +262,12 @@ void Usr_FlushCacheUsrBelongsToCurrentCrs (void); bool Usr_CheckIfUsrBelongsToCurrentCrs (const struct UsrData *UsrDat); void Usr_FlushCacheUsrHasAcceptedInCurrentCrs (void); bool Usr_CheckIfUsrHasAcceptedInCurrentCrs (const struct UsrData *UsrDat); + bool Usr_CheckIfICanViewRecordStd (const struct UsrData *UsrDat); bool Usr_CheckIfICanViewRecordTch (struct UsrData *UsrDat); bool Usr_CheckIfICanViewWrkTstAtt (const struct UsrData *UsrDat); bool Usr_CheckIfICanViewUsrAgenda (struct UsrData *UsrDat); + void Usr_FlushCacheUsrSharesAnyOfMyCrs (void); bool Usr_CheckIfUsrSharesAnyOfMyCrs (struct UsrData *UsrDat); bool Usr_CheckIfUsrSharesAnyOfMyCrsWithDifferentRole (long UsrCod); diff --git a/swad_web_service.c b/swad_web_service.c index 17c35fda..6a1de7bb 100644 --- a/swad_web_service.c +++ b/swad_web_service.c @@ -592,20 +592,24 @@ static bool Svc_GetSomeUsrDataFromUsrCod (struct UsrData *UsrDat,long CrsCod) row = mysql_fetch_row (mysql_res); if (row[0]) { - if (sscanf (row[0],"%u",&UsrDat->Roles.InCurrentCrs.Role) != 1) + if (sscanf (row[0],"%u",&UsrDat->Roles.InCurrentCrs.Role) == 1) + UsrDat->Roles.InCurrentCrs.Valid = true; + else + { UsrDat->Roles.InCurrentCrs.Role = Rol_UNK; - UsrDat->Roles.InCurrentCrs.GotFromDBForUsrCod = UsrDat->UsrCod; + UsrDat->Roles.InCurrentCrs.Valid = false; + } } else // Impossible { - UsrDat->Roles.InCurrentCrs.Role = Rol_UNK; - UsrDat->Roles.InCurrentCrs.GotFromDBForUsrCod = UsrDat->UsrCod; + UsrDat->Roles.InCurrentCrs.Role = Rol_UNK; + UsrDat->Roles.InCurrentCrs.Valid = false; } } else // User does not belong to course { - UsrDat->Roles.InCurrentCrs.Role = Rol_UNK; - UsrDat->Roles.InCurrentCrs.GotFromDBForUsrCod = UsrDat->UsrCod; + UsrDat->Roles.InCurrentCrs.Role = Rol_UNK; + UsrDat->Roles.InCurrentCrs.Valid = true; } } else @@ -619,21 +623,25 @@ static bool Svc_GetSomeUsrDataFromUsrCod (struct UsrData *UsrDat,long CrsCod) row = mysql_fetch_row (mysql_res); if (row[0]) { - if (sscanf (row[0],"%u",&UsrDat->Roles.InCurrentCrs.Role) != 1) + if (sscanf (row[0],"%u",&UsrDat->Roles.InCurrentCrs.Role) == 1) + UsrDat->Roles.InCurrentCrs.Valid = true; + else + { UsrDat->Roles.InCurrentCrs.Role = Rol_UNK; - UsrDat->Roles.InCurrentCrs.GotFromDBForUsrCod = UsrDat->UsrCod; + UsrDat->Roles.InCurrentCrs.Valid = false; + } } else // MAX(Role) == NULL if user does not belong to any course { - UsrDat->Roles.InCurrentCrs.Role = Rol_UNK; - UsrDat->Roles.InCurrentCrs.GotFromDBForUsrCod = UsrDat->UsrCod; + UsrDat->Roles.InCurrentCrs.Role = Rol_UNK; + UsrDat->Roles.InCurrentCrs.Valid = true; } } else // Impossible { - UsrDat->Roles.InCurrentCrs.Role = Rol_UNK; - UsrDat->Roles.InCurrentCrs.GotFromDBForUsrCod = UsrDat->UsrCod; + UsrDat->Roles.InCurrentCrs.Role = Rol_UNK; + UsrDat->Roles.InCurrentCrs.Valid = false; } }