From 5015773a405ef6acb7e90099aa9831e4cb9caadb Mon Sep 17 00:00:00 2001 From: acanas Date: Tue, 3 Oct 2023 22:14:35 +0200 Subject: [PATCH] Version 23.25.3: Oct 03, 2023 Code refactoring in user's hierarchy. --- css/{swad23.16.1.css => swad23.25.2.css} | 2 +- swad_action.c | 6 ++--- swad_browser.c | 8 +++--- swad_changelog.h | 6 +++-- swad_chat.c | 2 +- swad_connected.c | 2 +- swad_course.c | 7 +++--- swad_enrolment.c | 9 ++++--- swad_forum.c | 2 +- swad_global.c | 4 --- swad_global.h | 5 +--- swad_group.c | 6 ++--- swad_help.c | 2 +- swad_hierarchy.c | 3 +++ swad_layout.c | 14 ++++++----- swad_message.c | 4 +-- swad_record.c | 2 +- swad_role.c | 32 ++++++++++++------------ swad_session.c | 11 +++----- swad_survey.c | 4 +-- swad_test.c | 2 +- swad_test_database.c | 4 +-- swad_test_print.c | 2 +- swad_user.c | 8 +++--- 24 files changed, 73 insertions(+), 74 deletions(-) rename css/{swad23.16.1.css => swad23.25.2.css} (99%) diff --git a/css/swad23.16.1.css b/css/swad23.25.2.css similarity index 99% rename from css/swad23.16.1.css rename to css/swad23.25.2.css index c5c28c36..1eb020c7 100644 --- a/css/swad23.16.1.css +++ b/css/swad23.25.2.css @@ -2617,7 +2617,7 @@ table.CELLS_PAD_10 > tbody > tr > td {padding:10px;} .LIST_TREE li { box-sizing:border-box; - max-width:500px; + /* max-width:500px; */ height:25px; text-align:left; vertical-align:middle; diff --git a/swad_action.c b/swad_action.c index 5d6048f9..841cdbab 100644 --- a/swad_action.c +++ b/swad_action.c @@ -124,8 +124,8 @@ bool Act_CheckIfIHavePermissionToExecuteAction (Act_Action_t Action) Permission = ActLst_Actions[Action].PermissionDeg; break; case Hie_CRS: // Course selected - Permission = Gbl.Usrs.Me.IBelongToCurrentCrs ? ActLst_Actions[Action].PermissionCrsIfIBelong : - ActLst_Actions[Action].PermissionCrsIfIDontBelong; + Permission = Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS] ? ActLst_Actions[Action].PermissionCrsIfIBelong : + ActLst_Actions[Action].PermissionCrsIfIDontBelong; break; default: return false; @@ -358,7 +358,7 @@ void Act_AdjustCurrentAction (void) } /***** If I belong to current course *****/ - if (Gbl.Usrs.Me.IBelongToCurrentCrs) + if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS]) { /***** Adjustment 6: ------------- diff --git a/swad_browser.c b/swad_browser.c index c2c0e66e..f9b26ea4 100644 --- a/swad_browser.c +++ b/swad_browser.c @@ -1988,22 +1988,22 @@ void Brw_GetParAndInitFileBrowser (void) case Brw_SHOW_DOC_INS: case Brw_ADMI_DOC_INS: case Brw_ADMI_SHR_INS: - Gbl.FileBrowser.ShowOnlyPublicFiles = !Gbl.Usrs.Me.IBelongToCurrentIns; + Gbl.FileBrowser.ShowOnlyPublicFiles = !Gbl.Usrs.Me.IBelongToCurrent[Hie_INS]; break; case Brw_SHOW_DOC_CTR: case Brw_ADMI_DOC_CTR: case Brw_ADMI_SHR_CTR: - Gbl.FileBrowser.ShowOnlyPublicFiles = !Gbl.Usrs.Me.IBelongToCurrentCtr; + Gbl.FileBrowser.ShowOnlyPublicFiles = !Gbl.Usrs.Me.IBelongToCurrent[Hie_CTR]; break; case Brw_SHOW_DOC_DEG: case Brw_ADMI_DOC_DEG: case Brw_ADMI_SHR_DEG: - Gbl.FileBrowser.ShowOnlyPublicFiles = !Gbl.Usrs.Me.IBelongToCurrentDeg; + Gbl.FileBrowser.ShowOnlyPublicFiles = !Gbl.Usrs.Me.IBelongToCurrent[Hie_DEG]; break; case Brw_SHOW_DOC_CRS: case Brw_ADMI_DOC_CRS: case Brw_ADMI_SHR_CRS: - Gbl.FileBrowser.ShowOnlyPublicFiles = !Gbl.Usrs.Me.IBelongToCurrentCrs; + Gbl.FileBrowser.ShowOnlyPublicFiles = !Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS]; break; default: break; diff --git a/swad_changelog.h b/swad_changelog.h index d80131af..ac333b70 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -632,10 +632,12 @@ TODO: Francisco Javier Fern Me sale este error, no sé si por no recordar yo la sintaxis apropiada para mandar a varios destinatarios. ¿No era así? "can npt create received message (duplicated entry '243218-2160773' for key 'UsrCod_MsgCod') */ -#define Log_PLATFORM_VERSION "SWAD 23.25.1 (2023-10-03)" -#define CSS_FILE "swad23.16.1.css" +#define Log_PLATFORM_VERSION "SWAD 23.25.3 (2023-10-03)" +#define CSS_FILE "swad23.25.2.css" #define JS_FILE "swad22.49.js" /* + Version 23.25.3: Oct 03, 2023 Code refactoring in user's hierarchy. (336222 lines) + Version 23.25.2: Oct 03, 2023 Changes in my courses. (336230 lines) Version 23.25.1: Oct 03, 2023 Fixed recent bug in user's roles. (336225 lines) Version 23.25: Oct 03, 2023 Code refactoring in user's roles. (336224 lines) Version 23.24: Oct 03, 2023 Code refactoring in user's hierarchy. (336276 lines) diff --git a/swad_chat.c b/swad_chat.c index a386e319..8f83c8a7 100644 --- a/swad_chat.c +++ b/swad_chat.c @@ -137,7 +137,7 @@ void Cht_ShowListOfAvailableChatRooms (void) HTM_UL_Begin ("class=\"LIST_TREE\""); /***** Link to chat available for all users *****/ - IsLastItemInLevel[1] = (!Gbl.Usrs.Me.IBelongToCurrentCrs && + IsLastItemInLevel[1] = (!Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS] && !Gbl.Usrs.Me.Hierarchy[Hie_DEG].Num); snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s (%s)", Txt_General,Txt_SEX_PLURAL_abc[Usr_SEX_ALL]); diff --git a/swad_connected.c b/swad_connected.c index e6f1a42b..fe4245ee 100644 --- a/swad_connected.c +++ b/swad_connected.c @@ -233,7 +233,7 @@ void Con_ComputeConnectedUsrsBelongingToCurrentCrs (void) { if ((Gbl.Prefs.SideCols & Lay_SHOW_RIGHT_COLUMN) && // Right column visible Gbl.Hierarchy.Level == Hie_CRS && // Course selected - (Gbl.Usrs.Me.IBelongToCurrentCrs || // I can view users + (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS] || // I can view users Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) { Gbl.Usrs.Connected.NumUsrs = diff --git a/swad_course.c b/swad_course.c index 9864b1cb..7856d156 100644 --- a/swad_course.c +++ b/swad_course.c @@ -151,6 +151,7 @@ void Crs_ShowIntroduction (void) static void Crs_WriteListMyCoursesToSelectOne (void) { extern const char *Hlp_PROFILE_Courses; + extern const char *Par_CodeStr[]; extern const char *Txt_My_courses; extern const char *Txt_System; struct Hie_Node Hie[Hie_NUM_LEVELS]; @@ -188,7 +189,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void) IsLastItemInLevel[1] = true; Lay_IndentDependingOnLevel (1,IsLastItemInLevel); Frm_BeginForm (ActMyCrs); - // Cty_PutParCtyCod (-1L); + Par_PutParLong (NULL,Par_CodeStr[ParCod_Cty],-1L); HTM_BUTTON_Submit_Begin (Txt_System, "class=\"BT_LINK FORM_IN_%s\"", The_GetSuffix ()); @@ -621,8 +622,8 @@ void Crs_WriteSelectorMyCoursesInBreadcrumb (void) /***** Write an option with the current course when I don't belong to it *****/ - if (Gbl.Hierarchy.Level == Hie_CRS && // Course selected - !Gbl.Usrs.Me.IBelongToCurrentCrs) // I do not belong to it + if (Gbl.Hierarchy.Level == Hie_CRS && // Course selected + !Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS]) // I do not belong to it HTM_OPTION (HTM_Type_LONG,&Gbl.Hierarchy.Node[Hie_CRS].HieCod, HTM_OPTION_SELECTED, HTM_OPTION_DISABLED, diff --git a/swad_enrolment.c b/swad_enrolment.c index de68ea16..00b7aff0 100644 --- a/swad_enrolment.c +++ b/swad_enrolment.c @@ -176,7 +176,8 @@ void Enr_PutButtonInlineToRegisterStds (long CrsCod) { extern const char *Txt_Register_students; - if (Gbl.Usrs.Me.Role.Logged == Rol_TCH) // Course selected and I am logged as teacher + // if (Gbl.Usrs.Me.Role.Logged == Rol_TCH) // Course selected and I am logged as teacher + if (Rol_GetMyRoleInCrs (CrsCod) == Rol_TCH) // I am a teacher in the given course if (!Enr_GetNumUsrsInCrss (Hie_CRS,CrsCod, 1 << Rol_STD)) // No students in course { @@ -3184,8 +3185,8 @@ static void Enr_EffectivelyRemUsrFromCrs (struct Usr_Data *UsrDat, { case Usr_ME: /* Now I don't belong to current course */ - Gbl.Usrs.Me.IBelongToCurrentCrs = - Gbl.Usrs.Me.UsrDat.Accepted = false; + Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS] = + Gbl.Usrs.Me.UsrDat.Accepted = false; /* Fill the list with the courses I belong to */ Gbl.Usrs.Me.Hierarchy[Hie_CRS].Filled = false; @@ -3324,7 +3325,7 @@ bool Enr_CheckIfUsrSharesAnyOfMyCrs (struct Usr_Data *UsrDat) return Gbl.Cache.UsrSharesAnyOfMyCrs.SharesAnyOfMyCrs; /***** 5. Fast check: Is course selected and we both belong to it? *****/ - if (Gbl.Usrs.Me.IBelongToCurrentCrs) + if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS]) if (Enr_CheckIfUsrBelongsToCurrentCrs (UsrDat)) // Course selected and we both belong to it { Gbl.Cache.UsrSharesAnyOfMyCrs.UsrCod = UsrDat->UsrCod; diff --git a/swad_forum.c b/swad_forum.c index 08b3b03e..ca5e3d59 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -1298,7 +1298,7 @@ void For_ShowForumList (struct For_Forums *Forums) Gbl.Hierarchy.Node[Hie_DEG].HieCod, true, IsLastItemInLevel) > 0) - if (Gbl.Usrs.Me.IBelongToCurrentCrs || + if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS] || Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) /***** Links to forums of current degree *****/ For_WriteLinksToCrsForums (Forums, diff --git a/swad_global.c b/swad_global.c index 60c24a0f..51689b18 100644 --- a/swad_global.c +++ b/swad_global.c @@ -124,10 +124,6 @@ void Gbl_InitializeGlobals (void) Gbl.Usrs.Me.Role.LoggedBeforeCloseSession = Gbl.Usrs.Me.Role.Max = Rol_UNK; Gbl.Usrs.Me.Role.HasChanged = false; - Gbl.Usrs.Me.IBelongToCurrentIns = false; - Gbl.Usrs.Me.IBelongToCurrentCtr = false; - Gbl.Usrs.Me.IBelongToCurrentDeg = false; - Gbl.Usrs.Me.IBelongToCurrentCrs = false; Gbl.Usrs.Me.MyPhotoExists = false; Gbl.Usrs.Me.NumAccWithoutPhoto = 0; Gbl.Usrs.Me.TimeLastAccToThisFileBrowser = LONG_MAX; // Initialized to a big value, so by default files are not shown as recent or new diff --git a/swad_global.h b/swad_global.h index 4723f09f..7dd29b10 100644 --- a/swad_global.h +++ b/swad_global.h @@ -124,10 +124,7 @@ struct Globals char PendingPassword[Pwd_BYTES_ENCRYPTED_PASSWORD + 1]; char PathDir[PATH_MAX + 1]; bool Logged; - bool IBelongToCurrentIns; - bool IBelongToCurrentCtr; - bool IBelongToCurrentDeg; - bool IBelongToCurrentCrs; + bool IBelongToCurrent[Hie_NUM_LEVELS]; bool MyPhotoExists; unsigned NumAccWithoutPhoto; char PhotoURL[Cns_MAX_BYTES_WWW + 1]; diff --git a/swad_group.c b/swad_group.c index be60af6d..6103ba72 100644 --- a/swad_group.c +++ b/swad_group.c @@ -3045,7 +3045,7 @@ bool Grp_CheckIfUsrSharesAnyOfMyGrpsInCurrentCrs (const struct Usr_Data *UsrDat) return false; /***** 4. Fast check: Do I belong to the current course? *****/ - if (!Gbl.Usrs.Me.IBelongToCurrentCrs) + if (!Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS]) return false; /***** 5. Fast check: It's me? *****/ @@ -4331,8 +4331,8 @@ Grp_WhichGroups_t Grp_GetParWhichGroups (void) If I belong to this course ==> see only my groups If I don't belong to this course ==> see all groups */ - WhichGroupsDefault = Gbl.Usrs.Me.IBelongToCurrentCrs ? Grp_MY_GROUPS : - Grp_ALL_GROUPS; + WhichGroupsDefault = Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS] ? Grp_MY_GROUPS : + Grp_ALL_GROUPS; break; case ActSeeMyTT: // Show my timetable case ActPrnMyTT: // Print my timetable diff --git a/swad_help.c b/swad_help.c index 416071a5..cacb7aee 100644 --- a/swad_help.c +++ b/swad_help.c @@ -127,7 +127,7 @@ void Hlp_ShowHelpWhatWouldYouLikeToDo (void) { if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected { - if (Gbl.Usrs.Me.IBelongToCurrentCrs) // I belong to this course + if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS]) // I belong to this course { if (Gbl.Action.Act != ActLogIn && Gbl.Action.Act != ActLogInNew && diff --git a/swad_hierarchy.c b/swad_hierarchy.c index 89b40ab1..03be4616 100644 --- a/swad_hierarchy.c +++ b/swad_hierarchy.c @@ -635,6 +635,8 @@ void Hie_ResetHierarchy (void) Gbl.Hierarchy.Node[Level].ShrtName[0] = Gbl.Hierarchy.Node[Level].FullName[0] = '\0'; Gbl.Hierarchy.Node[Level].WWW[0] = '\0'; + + Gbl.Usrs.Me.IBelongToCurrent[Level] = false; } Gbl.Hierarchy.Node[Hie_CTR].Specific.PlcCod = -1L; Gbl.Hierarchy.Node[Hie_DEG].Specific.TypCod = -1L; @@ -934,6 +936,7 @@ void Hie_ResetMyHierarchy (void) Gbl.Usrs.Me.Hierarchy[Level].Nodes = NULL; Gbl.Usrs.Me.Hierarchy[Level].Num = 0; Gbl.Usrs.Me.Hierarchy[Level].Filled = false; + Gbl.Usrs.Me.IBelongToCurrent[Level] = false; } } diff --git a/swad_layout.c b/swad_layout.c index 4705d033..54272983 100644 --- a/swad_layout.c +++ b/swad_layout.c @@ -1612,8 +1612,11 @@ void Lay_IndentDependingOnLevel (unsigned Level,bool IsLastItemInLevel[]) { unsigned i; + if (Level <= 1) + return; + /***** Indent (from 1 to Level-1) *****/ - for (i = 1; + for (i = 2; i < Level; i++) Ico_PutIcon (IsLastItemInLevel[i] ? "tr20x20.gif" : @@ -1622,11 +1625,10 @@ void Lay_IndentDependingOnLevel (unsigned Level,bool IsLastItemInLevel[]) "","ICO25x25"); /***** Level *****/ - if (Level) - Ico_PutIcon (IsLastItemInLevel[Level] ? "subend20x20.gif" : - "submid20x20.gif", - Ico_BLACK, - "","ICO25x25"); + Ico_PutIcon (IsLastItemInLevel[Level] ? "subend20x20.gif" : + "submid20x20.gif", + Ico_BLACK, + "","ICO25x25"); } /*****************************************************************************/ diff --git a/swad_message.c b/swad_message.c index 4e8e16f4..40634fc4 100644 --- a/swad_message.c +++ b/swad_message.c @@ -246,7 +246,7 @@ static void Msg_PutFormMsgUsrs (struct Msg_Messages *Messages, Messages->ShowOnlyOneRecipient = false; GetUsrsInCrs = !Messages->ShowOnlyOneRecipient && // Show list of potential recipients - (Gbl.Usrs.Me.IBelongToCurrentCrs || // If there is a course selected and I belong to it + (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS] || // If there is a course selected and I belong to it Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM); if (GetUsrsInCrs) { @@ -528,7 +528,7 @@ static void Msg_WriteFormUsrsIDsOrNicksOtherRecipients (void) char Nickname[Nck_MAX_BYTES_NICK_WITHOUT_ARROBA + 1]; unsigned ColSpan; bool StdsAndTchsWritten = Gbl.Hierarchy.Level == Hie_CRS && // Course selected - (Gbl.Usrs.Me.IBelongToCurrentCrs || // I belong to it + (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS] || // I belong to it Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM); /***** How many columns? *****/ diff --git a/swad_record.c b/swad_record.c index 083a320b..81813587 100644 --- a/swad_record.c +++ b/swad_record.c @@ -2257,7 +2257,7 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView, { case Usr_ME: // Don't show groups if I don't belong to course - if (Gbl.Usrs.Me.IBelongToCurrentCrs) + if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS]) Grp_ShowLstGrpsToChgMyGrps (); break; case Usr_OTHER: diff --git a/swad_role.c b/swad_role.c index 31aae895..7330b06d 100644 --- a/swad_role.c +++ b/swad_role.c @@ -125,55 +125,55 @@ void Rol_SetMyRoles (void) /***** Check if I belong to current course *****/ if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected { - Gbl.Usrs.Me.IBelongToCurrentCrs = Enr_CheckIfUsrBelongsToCurrentCrs (&Gbl.Usrs.Me.UsrDat); - if (Gbl.Usrs.Me.IBelongToCurrentCrs) + Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS] = Enr_CheckIfUsrBelongsToCurrentCrs (&Gbl.Usrs.Me.UsrDat); + if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS]) Gbl.Usrs.Me.UsrDat.Accepted = Enr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Me.UsrDat); else Gbl.Usrs.Me.UsrDat.Accepted = false; } else // No course selected { - Gbl.Usrs.Me.IBelongToCurrentCrs = false; + Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS] = false; Gbl.Usrs.Me.UsrDat.Accepted = false; } /***** Check if I belong to current degree *****/ if (Gbl.Hierarchy.Node[Hie_DEG].HieCod > 0) { - if (Gbl.Usrs.Me.IBelongToCurrentCrs) - Gbl.Usrs.Me.IBelongToCurrentDeg = true; + if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS]) + Gbl.Usrs.Me.IBelongToCurrent[Hie_DEG] = true; else - Gbl.Usrs.Me.IBelongToCurrentDeg = Hie_CheckIfIBelongTo (Hie_DEG,Gbl.Hierarchy.Node[Hie_DEG].HieCod); + Gbl.Usrs.Me.IBelongToCurrent[Hie_DEG] = Hie_CheckIfIBelongTo (Hie_DEG,Gbl.Hierarchy.Node[Hie_DEG].HieCod); } else - Gbl.Usrs.Me.IBelongToCurrentDeg = false; + Gbl.Usrs.Me.IBelongToCurrent[Hie_DEG] = false; /***** Check if I belong to current center *****/ if (Gbl.Hierarchy.Node[Hie_CTR].HieCod > 0) { - if (Gbl.Usrs.Me.IBelongToCurrentDeg) - Gbl.Usrs.Me.IBelongToCurrentCtr = true; + if (Gbl.Usrs.Me.IBelongToCurrent[Hie_DEG]) + Gbl.Usrs.Me.IBelongToCurrent[Hie_CTR] = true; else - Gbl.Usrs.Me.IBelongToCurrentCtr = Hie_CheckIfIBelongTo (Hie_CTR,Gbl.Hierarchy.Node[Hie_CTR].HieCod); + Gbl.Usrs.Me.IBelongToCurrent[Hie_CTR] = Hie_CheckIfIBelongTo (Hie_CTR,Gbl.Hierarchy.Node[Hie_CTR].HieCod); } else - Gbl.Usrs.Me.IBelongToCurrentCtr = false; + Gbl.Usrs.Me.IBelongToCurrent[Hie_CTR] = false; /***** Check if I belong to current institution *****/ if (Gbl.Hierarchy.Node[Hie_INS].HieCod > 0) { - if (Gbl.Usrs.Me.IBelongToCurrentCtr) - Gbl.Usrs.Me.IBelongToCurrentIns = true; + if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CTR]) + Gbl.Usrs.Me.IBelongToCurrent[Hie_INS] = true; else - Gbl.Usrs.Me.IBelongToCurrentIns = Hie_CheckIfIBelongTo (Hie_INS,Gbl.Hierarchy.Node[Hie_INS].HieCod); + Gbl.Usrs.Me.IBelongToCurrent[Hie_INS] = Hie_CheckIfIBelongTo (Hie_INS,Gbl.Hierarchy.Node[Hie_INS].HieCod); } else - Gbl.Usrs.Me.IBelongToCurrentIns = false; + Gbl.Usrs.Me.IBelongToCurrent[Hie_INS] = false; /***** Build my list of available roles for current course *****/ if (Gbl.Hierarchy.Level == Hie_CRS) { - if (Gbl.Usrs.Me.IBelongToCurrentCrs) + if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS]) Gbl.Usrs.Me.Role.Available = (1 << Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs); else if (Gbl.Usrs.Me.Role.Max >= Rol_STD) Gbl.Usrs.Me.Role.Available = (1 << Rol_USR); diff --git a/swad_session.c b/swad_session.c index 8dc08fe5..2b3a25a4 100644 --- a/swad_session.c +++ b/swad_session.c @@ -123,13 +123,10 @@ void Ses_CloseSession (void) /***** Now, user is not logged in *****/ Gbl.Usrs.Me.Role.LoggedBeforeCloseSession = Gbl.Usrs.Me.Role.Logged; Gbl.Usrs.Me.Logged = false; - Gbl.Usrs.Me.IBelongToCurrentIns = false; - Gbl.Usrs.Me.IBelongToCurrentCtr = false; - Gbl.Usrs.Me.IBelongToCurrentDeg = false; - Gbl.Usrs.Me.IBelongToCurrentCrs = false; - Gbl.Usrs.Me.Role.Logged = Rol_UNK; // Don't uncomment this line. Don't change the role to unknown. Keep user's role in order to log the access - Gbl.Usrs.Me.Hierarchy[Hie_CRS].Filled = false; - Gbl.Usrs.Me.Hierarchy[Hie_CRS].Num = 0; + Gbl.Usrs.Me.Role.Logged = Rol_UNK; // TODO: Keep user's role in order to log the access? + Hie_FreeMyHierarchy (); + // Gbl.Usrs.Me.Hierarchy[Hie_CRS].Filled = false; + // Gbl.Usrs.Me.Hierarchy[Hie_CRS].Num = 0; /***** Update number of open sessions in order to show them properly *****/ Ses_GetNumSessions (); diff --git a/swad_survey.c b/swad_survey.c index 7cc0bd0e..7ff56eb2 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -995,7 +995,7 @@ static void Svy_SetAllowedAndHiddenScopes (unsigned *ScopesAllowed, if (Hie_CheckIfIBelongTo (Hie_DEG,Gbl.Hierarchy.Node[Hie_DEG].HieCod)) { *ScopesAllowed |= 1 << Hie_DEG; - if (Gbl.Usrs.Me.IBelongToCurrentCrs) + if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS]) *ScopesAllowed |= 1 << Hie_CRS; } } @@ -1018,7 +1018,7 @@ static void Svy_SetAllowedAndHiddenScopes (unsigned *ScopesAllowed, if (Hie_CheckIfIBelongTo (Hie_DEG,Gbl.Hierarchy.Node[Hie_DEG].HieCod)) { *ScopesAllowed |= 1 << Hie_DEG; - if (Gbl.Usrs.Me.IBelongToCurrentCrs) + if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS]) { *ScopesAllowed |= 1 << Hie_CRS; *HiddenAllowed |= 1 << Hie_CRS; // A non-editing teacher or teacher can view hidden course surveys diff --git a/swad_test.c b/swad_test.c index c26de350..11d41cea 100644 --- a/swad_test.c +++ b/swad_test.c @@ -350,7 +350,7 @@ void Tst_AssessTest (void) Lay_WriteHeaderClassPhoto (false,false); /***** Header *****/ - if (Gbl.Usrs.Me.IBelongToCurrentCrs) + if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS]) { HTM_DIV_Begin ("class=\"Tst_SUBTITLE DAT_%s\"", The_GetSuffix ()); diff --git a/swad_test_database.c b/swad_test_database.c index ee78fbb3..4b636f05 100644 --- a/swad_test_database.c +++ b/swad_test_database.c @@ -57,8 +57,8 @@ extern struct Globals Gbl; void Tst_DB_IncreaseNumMyPrints (void) { - /***** Trivial check *****/ - if (!Gbl.Usrs.Me.IBelongToCurrentCrs) + /***** Trivial check: do I belong to current course? *****/ + if (!Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS]) return; /***** Update my number of accesses to test in this course *****/ diff --git a/swad_test_print.c b/swad_test_print.c index f12ca241..56350d5f 100644 --- a/swad_test_print.c +++ b/swad_test_print.c @@ -2645,7 +2645,7 @@ unsigned TstPrn_GetNumPrintsGeneratedByMe (void) unsigned NumRows; unsigned NumPrintsGeneratedByMe = 0; - if (Gbl.Usrs.Me.IBelongToCurrentCrs) + if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS]) { /***** Get number of test prints generated by me from database *****/ NumRows = Tst_DB_GetNumPrintsGeneratedByMe (&mysql_res); diff --git a/swad_user.c b/swad_user.c index d0def591..41781dfe 100644 --- a/swad_user.c +++ b/swad_user.c @@ -874,7 +874,7 @@ bool Usr_CheckIfICanViewRecordStd (const struct Usr_Data *UsrDat) return true; /***** 6. Fast check: Do I belong to the current course? *****/ - if (!Gbl.Usrs.Me.IBelongToCurrentCrs) + if (!Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS]) return false; /***** 7. Fast check: It's me? *****/ @@ -947,7 +947,7 @@ bool Usr_CheckIfICanViewTstExaMchResult (const struct Usr_Data *UsrDat) return true; /***** 5. Fast check: Do I belong to the current course? *****/ - if (!Gbl.Usrs.Me.IBelongToCurrentCrs) + if (!Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS]) return false; /***** 6. Fast check: It's me? *****/ @@ -998,7 +998,7 @@ bool Usr_CheckIfICanViewAsgWrk (const struct Usr_Data *UsrDat) return true; /***** 6. Fast check: Do I belong to the current course? *****/ - if (!Gbl.Usrs.Me.IBelongToCurrentCrs) + if (!Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS]) return false; /***** 7. Fast check: It's me? *****/ @@ -1040,7 +1040,7 @@ bool Usr_CheckIfICanViewAtt (const struct Usr_Data *UsrDat) return true; /***** 5. Fast check: Do I belong to the current course? *****/ - if (!Gbl.Usrs.Me.IBelongToCurrentCrs) + if (!Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS]) return false; /***** 6. Fast check: It's me? *****/