Version 23.25.3: Oct 03, 2023 Code refactoring in user's hierarchy.

This commit is contained in:
acanas 2023-10-03 22:14:35 +02:00
parent 859c488098
commit 5015773a40
24 changed files with 73 additions and 74 deletions

View File

@ -2617,7 +2617,7 @@ table.CELLS_PAD_10 > tbody > tr > td {padding:10px;}
.LIST_TREE li .LIST_TREE li
{ {
box-sizing:border-box; box-sizing:border-box;
max-width:500px; /* max-width:500px; */
height:25px; height:25px;
text-align:left; text-align:left;
vertical-align:middle; vertical-align:middle;

View File

@ -124,8 +124,8 @@ bool Act_CheckIfIHavePermissionToExecuteAction (Act_Action_t Action)
Permission = ActLst_Actions[Action].PermissionDeg; Permission = ActLst_Actions[Action].PermissionDeg;
break; break;
case Hie_CRS: // Course selected case Hie_CRS: // Course selected
Permission = Gbl.Usrs.Me.IBelongToCurrentCrs ? ActLst_Actions[Action].PermissionCrsIfIBelong : Permission = Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS] ? ActLst_Actions[Action].PermissionCrsIfIBelong :
ActLst_Actions[Action].PermissionCrsIfIDontBelong; ActLst_Actions[Action].PermissionCrsIfIDontBelong;
break; break;
default: default:
return false; return false;
@ -358,7 +358,7 @@ void Act_AdjustCurrentAction (void)
} }
/***** If I belong to current course *****/ /***** If I belong to current course *****/
if (Gbl.Usrs.Me.IBelongToCurrentCrs) if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS])
{ {
/***** Adjustment 6: /***** Adjustment 6:
------------- -------------

View File

@ -1988,22 +1988,22 @@ void Brw_GetParAndInitFileBrowser (void)
case Brw_SHOW_DOC_INS: case Brw_SHOW_DOC_INS:
case Brw_ADMI_DOC_INS: case Brw_ADMI_DOC_INS:
case Brw_ADMI_SHR_INS: case Brw_ADMI_SHR_INS:
Gbl.FileBrowser.ShowOnlyPublicFiles = !Gbl.Usrs.Me.IBelongToCurrentIns; Gbl.FileBrowser.ShowOnlyPublicFiles = !Gbl.Usrs.Me.IBelongToCurrent[Hie_INS];
break; break;
case Brw_SHOW_DOC_CTR: case Brw_SHOW_DOC_CTR:
case Brw_ADMI_DOC_CTR: case Brw_ADMI_DOC_CTR:
case Brw_ADMI_SHR_CTR: case Brw_ADMI_SHR_CTR:
Gbl.FileBrowser.ShowOnlyPublicFiles = !Gbl.Usrs.Me.IBelongToCurrentCtr; Gbl.FileBrowser.ShowOnlyPublicFiles = !Gbl.Usrs.Me.IBelongToCurrent[Hie_CTR];
break; break;
case Brw_SHOW_DOC_DEG: case Brw_SHOW_DOC_DEG:
case Brw_ADMI_DOC_DEG: case Brw_ADMI_DOC_DEG:
case Brw_ADMI_SHR_DEG: case Brw_ADMI_SHR_DEG:
Gbl.FileBrowser.ShowOnlyPublicFiles = !Gbl.Usrs.Me.IBelongToCurrentDeg; Gbl.FileBrowser.ShowOnlyPublicFiles = !Gbl.Usrs.Me.IBelongToCurrent[Hie_DEG];
break; break;
case Brw_SHOW_DOC_CRS: case Brw_SHOW_DOC_CRS:
case Brw_ADMI_DOC_CRS: case Brw_ADMI_DOC_CRS:
case Brw_ADMI_SHR_CRS: case Brw_ADMI_SHR_CRS:
Gbl.FileBrowser.ShowOnlyPublicFiles = !Gbl.Usrs.Me.IBelongToCurrentCrs; Gbl.FileBrowser.ShowOnlyPublicFiles = !Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS];
break; break;
default: default:
break; break;

View File

@ -632,10 +632,12 @@ TODO: Francisco Javier Fern
Me sale este error, no si por no recordar yo la sintaxis apropiada para mandar a varios destinatarios. ¿No era así? Me sale este error, no 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') "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 Log_PLATFORM_VERSION "SWAD 23.25.3 (2023-10-03)"
#define CSS_FILE "swad23.16.1.css" #define CSS_FILE "swad23.25.2.css"
#define JS_FILE "swad22.49.js" #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.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.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) Version 23.24: Oct 03, 2023 Code refactoring in user's hierarchy. (336276 lines)

View File

@ -137,7 +137,7 @@ void Cht_ShowListOfAvailableChatRooms (void)
HTM_UL_Begin ("class=\"LIST_TREE\""); HTM_UL_Begin ("class=\"LIST_TREE\"");
/***** Link to chat available for all users *****/ /***** 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); !Gbl.Usrs.Me.Hierarchy[Hie_DEG].Num);
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s (%s)", snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s (%s)",
Txt_General,Txt_SEX_PLURAL_abc[Usr_SEX_ALL]); Txt_General,Txt_SEX_PLURAL_abc[Usr_SEX_ALL]);

View File

@ -233,7 +233,7 @@ void Con_ComputeConnectedUsrsBelongingToCurrentCrs (void)
{ {
if ((Gbl.Prefs.SideCols & Lay_SHOW_RIGHT_COLUMN) && // Right column visible if ((Gbl.Prefs.SideCols & Lay_SHOW_RIGHT_COLUMN) && // Right column visible
Gbl.Hierarchy.Level == Hie_CRS && // Course selected 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.Me.Role.Logged == Rol_SYS_ADM))
{ {
Gbl.Usrs.Connected.NumUsrs = Gbl.Usrs.Connected.NumUsrs =

View File

@ -151,6 +151,7 @@ void Crs_ShowIntroduction (void)
static void Crs_WriteListMyCoursesToSelectOne (void) static void Crs_WriteListMyCoursesToSelectOne (void)
{ {
extern const char *Hlp_PROFILE_Courses; extern const char *Hlp_PROFILE_Courses;
extern const char *Par_CodeStr[];
extern const char *Txt_My_courses; extern const char *Txt_My_courses;
extern const char *Txt_System; extern const char *Txt_System;
struct Hie_Node Hie[Hie_NUM_LEVELS]; struct Hie_Node Hie[Hie_NUM_LEVELS];
@ -188,7 +189,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
IsLastItemInLevel[1] = true; IsLastItemInLevel[1] = true;
Lay_IndentDependingOnLevel (1,IsLastItemInLevel); Lay_IndentDependingOnLevel (1,IsLastItemInLevel);
Frm_BeginForm (ActMyCrs); Frm_BeginForm (ActMyCrs);
// Cty_PutParCtyCod (-1L); Par_PutParLong (NULL,Par_CodeStr[ParCod_Cty],-1L);
HTM_BUTTON_Submit_Begin (Txt_System, HTM_BUTTON_Submit_Begin (Txt_System,
"class=\"BT_LINK FORM_IN_%s\"", "class=\"BT_LINK FORM_IN_%s\"",
The_GetSuffix ()); The_GetSuffix ());
@ -621,8 +622,8 @@ void Crs_WriteSelectorMyCoursesInBreadcrumb (void)
/***** Write an option with the current course /***** Write an option with the current course
when I don't belong to it *****/ when I don't belong to it *****/
if (Gbl.Hierarchy.Level == Hie_CRS && // Course selected if (Gbl.Hierarchy.Level == Hie_CRS && // Course selected
!Gbl.Usrs.Me.IBelongToCurrentCrs) // I do not belong to it !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 (HTM_Type_LONG,&Gbl.Hierarchy.Node[Hie_CRS].HieCod,
HTM_OPTION_SELECTED, HTM_OPTION_SELECTED,
HTM_OPTION_DISABLED, HTM_OPTION_DISABLED,

View File

@ -176,7 +176,8 @@ void Enr_PutButtonInlineToRegisterStds (long CrsCod)
{ {
extern const char *Txt_Register_students; 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, if (!Enr_GetNumUsrsInCrss (Hie_CRS,CrsCod,
1 << Rol_STD)) // No students in course 1 << Rol_STD)) // No students in course
{ {
@ -3184,8 +3185,8 @@ static void Enr_EffectivelyRemUsrFromCrs (struct Usr_Data *UsrDat,
{ {
case Usr_ME: case Usr_ME:
/* Now I don't belong to current course */ /* Now I don't belong to current course */
Gbl.Usrs.Me.IBelongToCurrentCrs = Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS] =
Gbl.Usrs.Me.UsrDat.Accepted = false; Gbl.Usrs.Me.UsrDat.Accepted = false;
/* Fill the list with the courses I belong to */ /* Fill the list with the courses I belong to */
Gbl.Usrs.Me.Hierarchy[Hie_CRS].Filled = false; Gbl.Usrs.Me.Hierarchy[Hie_CRS].Filled = false;
@ -3324,7 +3325,7 @@ bool Enr_CheckIfUsrSharesAnyOfMyCrs (struct Usr_Data *UsrDat)
return Gbl.Cache.UsrSharesAnyOfMyCrs.SharesAnyOfMyCrs; return Gbl.Cache.UsrSharesAnyOfMyCrs.SharesAnyOfMyCrs;
/***** 5. Fast check: Is course selected and we both belong to it? *****/ /***** 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 if (Enr_CheckIfUsrBelongsToCurrentCrs (UsrDat)) // Course selected and we both belong to it
{ {
Gbl.Cache.UsrSharesAnyOfMyCrs.UsrCod = UsrDat->UsrCod; Gbl.Cache.UsrSharesAnyOfMyCrs.UsrCod = UsrDat->UsrCod;

View File

@ -1298,7 +1298,7 @@ void For_ShowForumList (struct For_Forums *Forums)
Gbl.Hierarchy.Node[Hie_DEG].HieCod, Gbl.Hierarchy.Node[Hie_DEG].HieCod,
true, true,
IsLastItemInLevel) > 0) IsLastItemInLevel) > 0)
if (Gbl.Usrs.Me.IBelongToCurrentCrs || if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS] ||
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)
/***** Links to forums of current degree *****/ /***** Links to forums of current degree *****/
For_WriteLinksToCrsForums (Forums, For_WriteLinksToCrsForums (Forums,

View File

@ -124,10 +124,6 @@ void Gbl_InitializeGlobals (void)
Gbl.Usrs.Me.Role.LoggedBeforeCloseSession = Gbl.Usrs.Me.Role.LoggedBeforeCloseSession =
Gbl.Usrs.Me.Role.Max = Rol_UNK; Gbl.Usrs.Me.Role.Max = Rol_UNK;
Gbl.Usrs.Me.Role.HasChanged = false; 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.MyPhotoExists = false;
Gbl.Usrs.Me.NumAccWithoutPhoto = 0; 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 Gbl.Usrs.Me.TimeLastAccToThisFileBrowser = LONG_MAX; // Initialized to a big value, so by default files are not shown as recent or new

View File

@ -124,10 +124,7 @@ struct Globals
char PendingPassword[Pwd_BYTES_ENCRYPTED_PASSWORD + 1]; char PendingPassword[Pwd_BYTES_ENCRYPTED_PASSWORD + 1];
char PathDir[PATH_MAX + 1]; char PathDir[PATH_MAX + 1];
bool Logged; bool Logged;
bool IBelongToCurrentIns; bool IBelongToCurrent[Hie_NUM_LEVELS];
bool IBelongToCurrentCtr;
bool IBelongToCurrentDeg;
bool IBelongToCurrentCrs;
bool MyPhotoExists; bool MyPhotoExists;
unsigned NumAccWithoutPhoto; unsigned NumAccWithoutPhoto;
char PhotoURL[Cns_MAX_BYTES_WWW + 1]; char PhotoURL[Cns_MAX_BYTES_WWW + 1];

View File

@ -3045,7 +3045,7 @@ bool Grp_CheckIfUsrSharesAnyOfMyGrpsInCurrentCrs (const struct Usr_Data *UsrDat)
return false; return false;
/***** 4. Fast check: Do I belong to the current course? *****/ /***** 4. Fast check: Do I belong to the current course? *****/
if (!Gbl.Usrs.Me.IBelongToCurrentCrs) if (!Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS])
return false; return false;
/***** 5. Fast check: It's me? *****/ /***** 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 belong to this course ==> see only my groups
If I don't belong to this course ==> see all groups If I don't belong to this course ==> see all groups
*/ */
WhichGroupsDefault = Gbl.Usrs.Me.IBelongToCurrentCrs ? Grp_MY_GROUPS : WhichGroupsDefault = Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS] ? Grp_MY_GROUPS :
Grp_ALL_GROUPS; Grp_ALL_GROUPS;
break; break;
case ActSeeMyTT: // Show my timetable case ActSeeMyTT: // Show my timetable
case ActPrnMyTT: // Print my timetable case ActPrnMyTT: // Print my timetable

View File

@ -127,7 +127,7 @@ void Hlp_ShowHelpWhatWouldYouLikeToDo (void)
{ {
if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected 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 && if (Gbl.Action.Act != ActLogIn &&
Gbl.Action.Act != ActLogInNew && Gbl.Action.Act != ActLogInNew &&

View File

@ -635,6 +635,8 @@ void Hie_ResetHierarchy (void)
Gbl.Hierarchy.Node[Level].ShrtName[0] = Gbl.Hierarchy.Node[Level].ShrtName[0] =
Gbl.Hierarchy.Node[Level].FullName[0] = '\0'; Gbl.Hierarchy.Node[Level].FullName[0] = '\0';
Gbl.Hierarchy.Node[Level].WWW[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_CTR].Specific.PlcCod = -1L;
Gbl.Hierarchy.Node[Hie_DEG].Specific.TypCod = -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].Nodes = NULL;
Gbl.Usrs.Me.Hierarchy[Level].Num = 0; Gbl.Usrs.Me.Hierarchy[Level].Num = 0;
Gbl.Usrs.Me.Hierarchy[Level].Filled = false; Gbl.Usrs.Me.Hierarchy[Level].Filled = false;
Gbl.Usrs.Me.IBelongToCurrent[Level] = false;
} }
} }

View File

@ -1612,8 +1612,11 @@ void Lay_IndentDependingOnLevel (unsigned Level,bool IsLastItemInLevel[])
{ {
unsigned i; unsigned i;
if (Level <= 1)
return;
/***** Indent (from 1 to Level-1) *****/ /***** Indent (from 1 to Level-1) *****/
for (i = 1; for (i = 2;
i < Level; i < Level;
i++) i++)
Ico_PutIcon (IsLastItemInLevel[i] ? "tr20x20.gif" : Ico_PutIcon (IsLastItemInLevel[i] ? "tr20x20.gif" :
@ -1622,11 +1625,10 @@ void Lay_IndentDependingOnLevel (unsigned Level,bool IsLastItemInLevel[])
"","ICO25x25"); "","ICO25x25");
/***** Level *****/ /***** Level *****/
if (Level) Ico_PutIcon (IsLastItemInLevel[Level] ? "subend20x20.gif" :
Ico_PutIcon (IsLastItemInLevel[Level] ? "subend20x20.gif" : "submid20x20.gif",
"submid20x20.gif", Ico_BLACK,
Ico_BLACK, "","ICO25x25");
"","ICO25x25");
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -246,7 +246,7 @@ static void Msg_PutFormMsgUsrs (struct Msg_Messages *Messages,
Messages->ShowOnlyOneRecipient = false; Messages->ShowOnlyOneRecipient = false;
GetUsrsInCrs = !Messages->ShowOnlyOneRecipient && // Show list of potential recipients 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); Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM);
if (GetUsrsInCrs) if (GetUsrsInCrs)
{ {
@ -528,7 +528,7 @@ static void Msg_WriteFormUsrsIDsOrNicksOtherRecipients (void)
char Nickname[Nck_MAX_BYTES_NICK_WITHOUT_ARROBA + 1]; char Nickname[Nck_MAX_BYTES_NICK_WITHOUT_ARROBA + 1];
unsigned ColSpan; unsigned ColSpan;
bool StdsAndTchsWritten = Gbl.Hierarchy.Level == Hie_CRS && // Course selected 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); Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM);
/***** How many columns? *****/ /***** How many columns? *****/

View File

@ -2257,7 +2257,7 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView,
{ {
case Usr_ME: case Usr_ME:
// Don't show groups if I don't belong to course // 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 (); Grp_ShowLstGrpsToChgMyGrps ();
break; break;
case Usr_OTHER: case Usr_OTHER:

View File

@ -125,55 +125,55 @@ void Rol_SetMyRoles (void)
/***** Check if I belong to current course *****/ /***** Check if I belong to current course *****/
if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected
{ {
Gbl.Usrs.Me.IBelongToCurrentCrs = Enr_CheckIfUsrBelongsToCurrentCrs (&Gbl.Usrs.Me.UsrDat); Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS] = Enr_CheckIfUsrBelongsToCurrentCrs (&Gbl.Usrs.Me.UsrDat);
if (Gbl.Usrs.Me.IBelongToCurrentCrs) if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS])
Gbl.Usrs.Me.UsrDat.Accepted = Enr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Me.UsrDat); Gbl.Usrs.Me.UsrDat.Accepted = Enr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Me.UsrDat);
else else
Gbl.Usrs.Me.UsrDat.Accepted = false; Gbl.Usrs.Me.UsrDat.Accepted = false;
} }
else // No course selected else // No course selected
{ {
Gbl.Usrs.Me.IBelongToCurrentCrs = false; Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS] = false;
Gbl.Usrs.Me.UsrDat.Accepted = false; Gbl.Usrs.Me.UsrDat.Accepted = false;
} }
/***** Check if I belong to current degree *****/ /***** Check if I belong to current degree *****/
if (Gbl.Hierarchy.Node[Hie_DEG].HieCod > 0) if (Gbl.Hierarchy.Node[Hie_DEG].HieCod > 0)
{ {
if (Gbl.Usrs.Me.IBelongToCurrentCrs) if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS])
Gbl.Usrs.Me.IBelongToCurrentDeg = true; Gbl.Usrs.Me.IBelongToCurrent[Hie_DEG] = true;
else 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 else
Gbl.Usrs.Me.IBelongToCurrentDeg = false; Gbl.Usrs.Me.IBelongToCurrent[Hie_DEG] = false;
/***** Check if I belong to current center *****/ /***** Check if I belong to current center *****/
if (Gbl.Hierarchy.Node[Hie_CTR].HieCod > 0) if (Gbl.Hierarchy.Node[Hie_CTR].HieCod > 0)
{ {
if (Gbl.Usrs.Me.IBelongToCurrentDeg) if (Gbl.Usrs.Me.IBelongToCurrent[Hie_DEG])
Gbl.Usrs.Me.IBelongToCurrentCtr = true; Gbl.Usrs.Me.IBelongToCurrent[Hie_CTR] = true;
else 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 else
Gbl.Usrs.Me.IBelongToCurrentCtr = false; Gbl.Usrs.Me.IBelongToCurrent[Hie_CTR] = false;
/***** Check if I belong to current institution *****/ /***** Check if I belong to current institution *****/
if (Gbl.Hierarchy.Node[Hie_INS].HieCod > 0) if (Gbl.Hierarchy.Node[Hie_INS].HieCod > 0)
{ {
if (Gbl.Usrs.Me.IBelongToCurrentCtr) if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CTR])
Gbl.Usrs.Me.IBelongToCurrentIns = true; Gbl.Usrs.Me.IBelongToCurrent[Hie_INS] = true;
else 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 else
Gbl.Usrs.Me.IBelongToCurrentIns = false; Gbl.Usrs.Me.IBelongToCurrent[Hie_INS] = false;
/***** Build my list of available roles for current course *****/ /***** Build my list of available roles for current course *****/
if (Gbl.Hierarchy.Level == Hie_CRS) 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); Gbl.Usrs.Me.Role.Available = (1 << Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs);
else if (Gbl.Usrs.Me.Role.Max >= Rol_STD) else if (Gbl.Usrs.Me.Role.Max >= Rol_STD)
Gbl.Usrs.Me.Role.Available = (1 << Rol_USR); Gbl.Usrs.Me.Role.Available = (1 << Rol_USR);

View File

@ -123,13 +123,10 @@ void Ses_CloseSession (void)
/***** Now, user is not logged in *****/ /***** Now, user is not logged in *****/
Gbl.Usrs.Me.Role.LoggedBeforeCloseSession = Gbl.Usrs.Me.Role.Logged; Gbl.Usrs.Me.Role.LoggedBeforeCloseSession = Gbl.Usrs.Me.Role.Logged;
Gbl.Usrs.Me.Logged = false; Gbl.Usrs.Me.Logged = false;
Gbl.Usrs.Me.IBelongToCurrentIns = false; Gbl.Usrs.Me.Role.Logged = Rol_UNK; // TODO: Keep user's role in order to log the access?
Gbl.Usrs.Me.IBelongToCurrentCtr = false; Hie_FreeMyHierarchy ();
Gbl.Usrs.Me.IBelongToCurrentDeg = false; // Gbl.Usrs.Me.Hierarchy[Hie_CRS].Filled = false;
Gbl.Usrs.Me.IBelongToCurrentCrs = false; // Gbl.Usrs.Me.Hierarchy[Hie_CRS].Num = 0;
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;
/***** Update number of open sessions in order to show them properly *****/ /***** Update number of open sessions in order to show them properly *****/
Ses_GetNumSessions (); Ses_GetNumSessions ();

View File

@ -995,7 +995,7 @@ static void Svy_SetAllowedAndHiddenScopes (unsigned *ScopesAllowed,
if (Hie_CheckIfIBelongTo (Hie_DEG,Gbl.Hierarchy.Node[Hie_DEG].HieCod)) if (Hie_CheckIfIBelongTo (Hie_DEG,Gbl.Hierarchy.Node[Hie_DEG].HieCod))
{ {
*ScopesAllowed |= 1 << Hie_DEG; *ScopesAllowed |= 1 << Hie_DEG;
if (Gbl.Usrs.Me.IBelongToCurrentCrs) if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS])
*ScopesAllowed |= 1 << 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)) if (Hie_CheckIfIBelongTo (Hie_DEG,Gbl.Hierarchy.Node[Hie_DEG].HieCod))
{ {
*ScopesAllowed |= 1 << Hie_DEG; *ScopesAllowed |= 1 << Hie_DEG;
if (Gbl.Usrs.Me.IBelongToCurrentCrs) if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS])
{ {
*ScopesAllowed |= 1 << Hie_CRS; *ScopesAllowed |= 1 << Hie_CRS;
*HiddenAllowed |= 1 << Hie_CRS; // A non-editing teacher or teacher can view hidden course surveys *HiddenAllowed |= 1 << Hie_CRS; // A non-editing teacher or teacher can view hidden course surveys

View File

@ -350,7 +350,7 @@ void Tst_AssessTest (void)
Lay_WriteHeaderClassPhoto (false,false); Lay_WriteHeaderClassPhoto (false,false);
/***** Header *****/ /***** Header *****/
if (Gbl.Usrs.Me.IBelongToCurrentCrs) if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS])
{ {
HTM_DIV_Begin ("class=\"Tst_SUBTITLE DAT_%s\"", HTM_DIV_Begin ("class=\"Tst_SUBTITLE DAT_%s\"",
The_GetSuffix ()); The_GetSuffix ());

View File

@ -57,8 +57,8 @@ extern struct Globals Gbl;
void Tst_DB_IncreaseNumMyPrints (void) void Tst_DB_IncreaseNumMyPrints (void)
{ {
/***** Trivial check *****/ /***** Trivial check: do I belong to current course? *****/
if (!Gbl.Usrs.Me.IBelongToCurrentCrs) if (!Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS])
return; return;
/***** Update my number of accesses to test in this course *****/ /***** Update my number of accesses to test in this course *****/

View File

@ -2645,7 +2645,7 @@ unsigned TstPrn_GetNumPrintsGeneratedByMe (void)
unsigned NumRows; unsigned NumRows;
unsigned NumPrintsGeneratedByMe = 0; 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 *****/ /***** Get number of test prints generated by me from database *****/
NumRows = Tst_DB_GetNumPrintsGeneratedByMe (&mysql_res); NumRows = Tst_DB_GetNumPrintsGeneratedByMe (&mysql_res);

View File

@ -874,7 +874,7 @@ bool Usr_CheckIfICanViewRecordStd (const struct Usr_Data *UsrDat)
return true; return true;
/***** 6. Fast check: Do I belong to the current course? *****/ /***** 6. Fast check: Do I belong to the current course? *****/
if (!Gbl.Usrs.Me.IBelongToCurrentCrs) if (!Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS])
return false; return false;
/***** 7. Fast check: It's me? *****/ /***** 7. Fast check: It's me? *****/
@ -947,7 +947,7 @@ bool Usr_CheckIfICanViewTstExaMchResult (const struct Usr_Data *UsrDat)
return true; return true;
/***** 5. Fast check: Do I belong to the current course? *****/ /***** 5. Fast check: Do I belong to the current course? *****/
if (!Gbl.Usrs.Me.IBelongToCurrentCrs) if (!Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS])
return false; return false;
/***** 6. Fast check: It's me? *****/ /***** 6. Fast check: It's me? *****/
@ -998,7 +998,7 @@ bool Usr_CheckIfICanViewAsgWrk (const struct Usr_Data *UsrDat)
return true; return true;
/***** 6. Fast check: Do I belong to the current course? *****/ /***** 6. Fast check: Do I belong to the current course? *****/
if (!Gbl.Usrs.Me.IBelongToCurrentCrs) if (!Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS])
return false; return false;
/***** 7. Fast check: It's me? *****/ /***** 7. Fast check: It's me? *****/
@ -1040,7 +1040,7 @@ bool Usr_CheckIfICanViewAtt (const struct Usr_Data *UsrDat)
return true; return true;
/***** 5. Fast check: Do I belong to the current course? *****/ /***** 5. Fast check: Do I belong to the current course? *****/
if (!Gbl.Usrs.Me.IBelongToCurrentCrs) if (!Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS])
return false; return false;
/***** 6. Fast check: It's me? *****/ /***** 6. Fast check: It's me? *****/