diff --git a/swad_attendance.c b/swad_attendance.c index b8079170..967b9983 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -1868,9 +1868,9 @@ static void Att_ListAttStudents (struct AttendanceEvent *Att) Grp_ShowFormToSelectSeveralGroups (ActSeeOneAtt); /***** Get and order list of students in this course *****/ - Usr_GetListUsrs (&Gbl.Usrs.LstStds,Rol_STUDENT,Sco_SCOPE_CRS); + Usr_GetListUsrs (Rol_STUDENT,Sco_SCOPE_CRS); - if (Gbl.Usrs.LstStds.NumUsrs) + if (Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs) { /***** Get my preference about photos in users' list for current course *****/ Usr_GetMyPrefAboutListWithPhotosFromDB (); @@ -1908,13 +1908,13 @@ static void Att_ListAttStudents (struct AttendanceEvent *Att) /* List of students */ for (NumStd = 0, Gbl.RowEvenOdd = 0; - NumStd < Gbl.Usrs.LstStds.NumUsrs; + NumStd < Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs; NumStd++) { - UsrDat.UsrCod = Gbl.Usrs.LstStds.Lst[NumStd].UsrCod; + UsrDat.UsrCod = Gbl.Usrs.LstUsrs[Rol_STUDENT].Lst[NumStd].UsrCod; if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // If user's data exist... { - UsrDat.Accepted = Gbl.Usrs.LstStds.Lst[NumStd].Accepted; + UsrDat.Accepted = Gbl.Usrs.LstUsrs[Rol_STUDENT].Lst[NumStd].Accepted; Att_WriteRowStdToCallTheRoll (NumStd + 1,&UsrDat,Att); } } @@ -1932,7 +1932,7 @@ static void Att_ListAttStudents (struct AttendanceEvent *Att) Usr_ShowWarningNoUsersFound (Rol_STUDENT); /***** Free memory for students list *****/ - Usr_FreeUsrsList (&Gbl.Usrs.LstStds); + Usr_FreeUsrsList (Rol_STUDENT); /***** Free memory for list of selected groups *****/ Grp_FreeListCodSelectedGrps (); @@ -2154,12 +2154,12 @@ void Att_RegisterMeAsStdInAttEvent (void) /***************** Save students who attended to an event ********************/ /*****************************************************************************/ /* Algorithm: - 1. Get list of students in the groups selected: Gbl.Usrs.LstStds + 1. Get list of students in the groups selected: Gbl.Usrs.LstUsrs[Rol_STUDENT] 2. Mark all students in the groups selected setting Remove=true 3. Get list of students marked as present by me: Gbl.Usrs.Select.Std 4. Loop over the list Gbl.Usrs.Select.Std, that holds the list of the students marked as present, - marking the students in Gbl.Usrs.LstStds.Lst as Remove=false + marking the students in Gbl.Usrs.LstUsrs[Rol_STUDENT].Lst as Remove=false 5. Delete from att_usr all the students marked as Remove=true 6. Replace (insert without duplicated) into att_usr all the students marked as Remove=false */ @@ -2188,17 +2188,17 @@ void Att_RegisterStudentsInAttEvent (void) /***** Get groups selected *****/ Grp_GetParCodsSeveralGrpsToShowUsrs (); - /***** 1. Get list of students in the groups selected: Gbl.Usrs.LstStds *****/ + /***** 1. Get list of students in the groups selected: Gbl.Usrs.LstUsrs[Rol_STUDENT] *****/ /* Get list of students in the groups selected */ - Usr_GetListUsrs (&Gbl.Usrs.LstStds,Rol_STUDENT,Sco_SCOPE_CRS); + Usr_GetListUsrs (Rol_STUDENT,Sco_SCOPE_CRS); - if (Gbl.Usrs.LstStds.NumUsrs) // If there are students in the groups selected... + if (Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs) // If there are students in the groups selected... { /***** 2. Mark all students in the groups selected setting Remove=true *****/ for (NumStd = 0; - NumStd < Gbl.Usrs.LstStds.NumUsrs; + NumStd < Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs; NumStd++) - Gbl.Usrs.LstStds.Lst[NumStd].Remove = true; + Gbl.Usrs.LstUsrs[Rol_STUDENT].Lst[NumStd].Remove = true; /***** 3. Get list of students marked as present by me: Gbl.Usrs.Select.Std *****/ Usr_GetListsSelectedUsrs (); @@ -2208,7 +2208,7 @@ void Att_RegisterStudentsInAttEvent (void) /***** 4. Loop over the list Gbl.Usrs.Select.Std, that holds the list of the students marked as present, - marking the students in Gbl.Usrs.LstStds.Lst as Remove=false *****/ + marking the students in Gbl.Usrs.LstUsrs[Rol_STUDENT].Lst as Remove=false *****/ Ptr = Gbl.Usrs.Select.Std; while (*Ptr) { @@ -2217,11 +2217,11 @@ void Att_RegisterStudentsInAttEvent (void) if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrData)) // Get student's data from the database /***** Mark student to not be removed *****/ for (NumStd = 0; - NumStd < Gbl.Usrs.LstStds.NumUsrs; + NumStd < Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs; NumStd++) - if (Gbl.Usrs.LstStds.Lst[NumStd].UsrCod == UsrData.UsrCod) + if (Gbl.Usrs.LstUsrs[Rol_STUDENT].Lst[NumStd].UsrCod == UsrData.UsrCod) { - Gbl.Usrs.LstStds.Lst[NumStd].Remove = false; + Gbl.Usrs.LstUsrs[Rol_STUDENT].Lst[NumStd].Remove = false; break; // Found! Exit loop } } @@ -2236,25 +2236,25 @@ void Att_RegisterStudentsInAttEvent (void) // 5. Delete from att_usr all the students marked as Remove=true // 6. Replace (insert without duplicated) into att_usr all the students marked as Remove=false for (NumStd = 0, NumStdsAbsent = NumStdsPresent = 0; - NumStd < Gbl.Usrs.LstStds.NumUsrs; + NumStd < Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs; NumStd++) { /***** Get comments for this student *****/ - Att_CheckIfUsrIsPresentInAttEventAndGetComments (Att.AttCod,Gbl.Usrs.LstStds.Lst[NumStd].UsrCod,CommentStd,CommentTch); - sprintf (CommentParamName,"CommentTch%ld",Gbl.Usrs.LstStds.Lst[NumStd].UsrCod); + Att_CheckIfUsrIsPresentInAttEventAndGetComments (Att.AttCod,Gbl.Usrs.LstUsrs[Rol_STUDENT].Lst[NumStd].UsrCod,CommentStd,CommentTch); + sprintf (CommentParamName,"CommentTch%ld",Gbl.Usrs.LstUsrs[Rol_STUDENT].Lst[NumStd].UsrCod); Par_GetParToHTML (CommentParamName,CommentTch,Cns_MAX_BYTES_TEXT); - Present = !Gbl.Usrs.LstStds.Lst[NumStd].Remove; + Present = !Gbl.Usrs.LstUsrs[Rol_STUDENT].Lst[NumStd].Remove; if (Present || CommentStd[0] || CommentTch[0]) /***** Register student *****/ - Att_RegUsrInAttEventChangingComments (Att.AttCod,Gbl.Usrs.LstStds.Lst[NumStd].UsrCod, + Att_RegUsrInAttEventChangingComments (Att.AttCod,Gbl.Usrs.LstUsrs[Rol_STUDENT].Lst[NumStd].UsrCod, Present,CommentStd,CommentTch); else /***** Remove student *****/ - Att_RemoveUsrFromAttEvent (Att.AttCod,Gbl.Usrs.LstStds.Lst[NumStd].UsrCod); + Att_RemoveUsrFromAttEvent (Att.AttCod,Gbl.Usrs.LstUsrs[Rol_STUDENT].Lst[NumStd].UsrCod); if (Present) NumStdsPresent++; @@ -2263,7 +2263,7 @@ void Att_RegisterStudentsInAttEvent (void) } /***** Free memory for students list *****/ - Usr_FreeUsrsList (&Gbl.Usrs.LstStds); + Usr_FreeUsrsList (Rol_STUDENT); /***** Write final message *****/ sprintf (Format,"%s: %%u
%s: %%u",Txt_Presents,Txt_Absents); @@ -2271,7 +2271,7 @@ void Att_RegisterStudentsInAttEvent (void) NumStdsPresent,NumStdsAbsent); Lay_ShowAlert (Lay_INFO,Gbl.Message); } - else // Gbl.Usrs.LstStds.NumUsrs == 0 + else // Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs == 0 Lay_ShowAlert (Lay_INFO,Txt_No_users_found[Rol_STUDENT]); /***** Show the attendance event again *****/ @@ -2533,11 +2533,11 @@ void Usr_ReqListStdsAttendanceCrs (void) Grp_ShowFormToSelectSeveralGroups (ActReqLstStdAtt); /***** Get and order lists of users from current course *****/ - Usr_GetListUsrs (&Gbl.Usrs.LstStds,Rol_STUDENT,Sco_SCOPE_CRS); + Usr_GetListUsrs (Rol_STUDENT,Sco_SCOPE_CRS); - if (Gbl.Usrs.LstStds.NumUsrs) + if (Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs) { - if (Usr_GetIfShowBigList (Gbl.Usrs.LstStds.NumUsrs)) + if (Usr_GetIfShowBigList (Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs)) { /***** Get list of selected users *****/ Usr_GetListsSelectedUsrs (); @@ -2575,7 +2575,7 @@ void Usr_ReqListStdsAttendanceCrs (void) Usr_ShowWarningNoUsersFound (Rol_STUDENT); /***** Free memory for students list *****/ - Usr_FreeUsrsList (&Gbl.Usrs.LstStds); + Usr_FreeUsrsList (Rol_STUDENT); /***** Free memory for list of selected groups *****/ Grp_FreeListCodSelectedGrps (); diff --git a/swad_changelog.h b/swad_changelog.h index 16b1937d..86d371c4 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -129,13 +129,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.227.1 (2016-06-23)" +#define Log_PLATFORM_VERSION "SWAD 15.228 (2016-06-23)" #define CSS_FILE "swad15.226.css" #define JS_FILE "swad15.226.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 15.228 Jun 23, 2015 Code refactoring in lists of users. (202814 lines) Version 15.227.1 Jun 23, 2015 Code refactoring in getting/searching users. (202854 lines) Version 15.227: Jun 21, 2015 Query optimization in search of users. (202820 lines) Version 15.226.7: Jun 19, 2015 One new social network. (202969 lines) diff --git a/swad_enrollment.c b/swad_enrollment.c index 6ed33fff..f86cac1c 100644 --- a/swad_enrollment.c +++ b/swad_enrollment.c @@ -1240,7 +1240,6 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role) unsigned NumUsrsRegistered = 0; unsigned NumUsrsRemoved = 0; unsigned NumUsrsEliminated = 0; - struct ListUsers *LstCurrentUsrs; struct ListCodGrps LstGrps; struct UsrData UsrDat; bool ItLooksLikeAUsrID; @@ -1371,28 +1370,15 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role) if (WhatToDo.RemoveUsrs) { /***** Get list of users in current course *****/ - switch (Role) - { - case Rol_STUDENT: - LstCurrentUsrs = &Gbl.Usrs.LstStds; - break; - case Rol_TEACHER: - LstCurrentUsrs = &Gbl.Usrs.LstTchs; - break; - default: - LstCurrentUsrs = NULL; // To avoid warning - Lay_ShowErrorAndExit ("Wrong role."); // If user manipulated the form - break; - } - Usr_GetListUsrs (LstCurrentUsrs,Rol_STUDENT,Sco_SCOPE_CRS); + Usr_GetListUsrs (Rol_STUDENT,Sco_SCOPE_CRS); - if (LstCurrentUsrs->NumUsrs) + if (Gbl.Usrs.LstUsrs[Role].NumUsrs) { /***** Initialize list of users to remove *****/ for (NumCurrentUsr = 0; - NumCurrentUsr < LstCurrentUsrs->NumUsrs; + NumCurrentUsr < Gbl.Usrs.LstUsrs[Role].NumUsrs; NumCurrentUsr++) - LstCurrentUsrs->Lst[NumCurrentUsr].Remove = !WhatToDo.RemoveSpecifiedUsrs; + Gbl.Usrs.LstUsrs[Role].Lst[NumCurrentUsr].Remove = !WhatToDo.RemoveSpecifiedUsrs; /***** Loop 1: go through form list setting if a student must be removed *****/ /* Step a: Get students from a list of official groups */ @@ -1464,21 +1450,21 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role) { if (ListUsrCods.NumUsrs == 1) // If more than one user found ==> do not remove for (NumCurrentUsr = 0; - NumCurrentUsr < LstCurrentUsrs->NumUsrs; + NumCurrentUsr < Gbl.Usrs.LstUsrs[Role].NumUsrs; NumCurrentUsr++) - if (LstCurrentUsrs->Lst[NumCurrentUsr].UsrCod == ListUsrCods.Lst[0]) // User found - LstCurrentUsrs->Lst[NumCurrentUsr].Remove = true; // Mark as removable + if (Gbl.Usrs.LstUsrs[Role].Lst[NumCurrentUsr].UsrCod == ListUsrCods.Lst[0]) // User found + Gbl.Usrs.LstUsrs[Role].Lst[NumCurrentUsr].Remove = true; // Mark as removable } else // Remove all the users (of the role) except these specified { for (NumCurrentUsr = 0; - NumCurrentUsr < LstCurrentUsrs->NumUsrs; + NumCurrentUsr < Gbl.Usrs.LstUsrs[Role].NumUsrs; NumCurrentUsr++) for (NumUsrFound = 0; NumUsrFound < ListUsrCods.NumUsrs; NumUsrFound++) - if (LstCurrentUsrs->Lst[NumCurrentUsr].UsrCod == ListUsrCods.Lst[NumUsrFound]) // User found - LstCurrentUsrs->Lst[NumCurrentUsr].Remove = false; // Mark as not removable + if (Gbl.Usrs.LstUsrs[Role].Lst[NumCurrentUsr].UsrCod == ListUsrCods.Lst[NumUsrFound]) // User found + Gbl.Usrs.LstUsrs[Role].Lst[NumCurrentUsr].Remove = false; // Mark as not removable } /* Free memory used for list of users' codes found for this ID */ @@ -1487,11 +1473,11 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role) /***** Loop 2: go through users list removing users *****/ for (NumCurrentUsr = 0; - NumCurrentUsr < LstCurrentUsrs->NumUsrs; + NumCurrentUsr < Gbl.Usrs.LstUsrs[Role].NumUsrs; NumCurrentUsr++) - if (LstCurrentUsrs->Lst[NumCurrentUsr].Remove) // If this student must be removed + if (Gbl.Usrs.LstUsrs[Role].Lst[NumCurrentUsr].Remove) // If this student must be removed { - UsrDat.UsrCod = LstCurrentUsrs->Lst[NumCurrentUsr].UsrCod; + UsrDat.UsrCod = Gbl.Usrs.LstUsrs[Role].Lst[NumCurrentUsr].UsrCod; if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // If user's data exist... { if (WhatToDo.EliminateUsrs) // Eliminate user completely from the platform @@ -1527,7 +1513,7 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role) } /***** Free memory for users list *****/ - Usr_FreeUsrsList (LstCurrentUsrs); + Usr_FreeUsrsList (Role); } /***** Register users *****/ @@ -1776,13 +1762,13 @@ static void Enr_MarkOfficialStdsAsRemovable (long ImpGrpCod,bool RemoveSpecified if (ID_GetListUsrCodsFromUsrID (&Gbl.Usrs.Other.UsrDat,NULL,&ListUsrCods,false)) // User(s) found { for (NumUsr = 0; - NumUsr < Gbl.Usrs.LstStds.NumUsrs; + NumUsr < Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs; NumUsr++) for (NumUsrFound = 0; NumUsrFound < ListUsrCods.NumUsrs; NumUsrFound++) - if (Gbl.Usrs.LstStds.Lst[NumUsr].UsrCod == ListUsrCods.Lst[NumUsrFound]) // User found - Gbl.Usrs.LstStds.Lst[NumUsr].Remove = RemoveSpecifiedUsrs; + if (Gbl.Usrs.LstUsrs[Rol_STUDENT].Lst[NumUsr].UsrCod == ListUsrCods.Lst[NumUsrFound]) // User found + Gbl.Usrs.LstUsrs[Rol_STUDENT].Lst[NumUsr].Remove = RemoveSpecifiedUsrs; /* Free memory used for list of users' codes found for this ID */ Usr_FreeListUsrCods (&ListUsrCods); @@ -1879,21 +1865,21 @@ unsigned Enr_RemAllStdsInCrs (struct Course *Crs) /***** Get list of students in current course *****/ Gbl.Usrs.ClassPhoto.AllGroups = true; // Get all the students of the current course - Usr_GetListUsrs (&Gbl.Usrs.LstStds,Rol_STUDENT,Sco_SCOPE_CRS); - NumStdsInCrs = Gbl.Usrs.LstStds.NumUsrs; + Usr_GetListUsrs (Rol_STUDENT,Sco_SCOPE_CRS); + NumStdsInCrs = Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs; /***** Remove all the students *****/ for (NumUsr = 0; NumUsr < NumStdsInCrs; NumUsr++) { - Gbl.Usrs.Other.UsrDat.UsrCod = Gbl.Usrs.LstStds.Lst[NumUsr].UsrCod; + Gbl.Usrs.Other.UsrDat.UsrCod = Gbl.Usrs.LstUsrs[Rol_STUDENT].Lst[NumUsr].UsrCod; Enr_EffectivelyRemUsrFromCrs (&Gbl.Usrs.Other.UsrDat,Crs, Enr_REMOVE_WORKS,Cns_QUIET); } /***** Free memory for students list *****/ - Usr_FreeUsrsList (&Gbl.Usrs.LstStds); + Usr_FreeUsrsList (Rol_STUDENT); return NumStdsInCrs; } diff --git a/swad_file_browser.c b/swad_file_browser.c index c8ef2d1a..727c3c2b 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -3096,14 +3096,14 @@ void Brw_AskEditWorksCrs (void) Grp_ShowFormToSelectSeveralGroups (ActReqAsgWrkCrs); /***** Get and order lists of users from this course *****/ - Usr_GetListUsrs (&Gbl.Usrs.LstTchs,Rol_TEACHER,Sco_SCOPE_CRS); - Usr_GetListUsrs (&Gbl.Usrs.LstStds,Rol_STUDENT,Sco_SCOPE_CRS); + Usr_GetListUsrs (Rol_TEACHER,Sco_SCOPE_CRS); + Usr_GetListUsrs (Rol_STUDENT,Sco_SCOPE_CRS); - if (Gbl.Usrs.LstTchs.NumUsrs || - Gbl.Usrs.LstStds.NumUsrs) + if (Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs || + Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs) { - if (Usr_GetIfShowBigList (Gbl.Usrs.LstTchs.NumUsrs + - Gbl.Usrs.LstStds.NumUsrs)) + if (Usr_GetIfShowBigList (Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs + + Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs)) { /***** Draw class photos to select users *****/ Lay_StartRoundFrame (NULL,Txt_Users,NULL); @@ -3136,8 +3136,8 @@ void Brw_AskEditWorksCrs (void) Usr_ShowWarningNoUsersFound (Rol_UNKNOWN); /***** Free memory for users' list *****/ - Usr_FreeUsrsList (&Gbl.Usrs.LstTchs); - Usr_FreeUsrsList (&Gbl.Usrs.LstStds); + Usr_FreeUsrsList (Rol_TEACHER); + Usr_FreeUsrsList (Rol_STUDENT); /***** Free the memory used by the list of users *****/ Usr_FreeListsSelectedUsrCods (); diff --git a/swad_global.c b/swad_global.c index 44c0ee45..1f1046f5 100644 --- a/swad_global.c +++ b/swad_global.c @@ -183,17 +183,17 @@ void Gbl_InitializeGlobals (void) Gbl.Action.UsesAJAX = false; Gbl.Action.Tab = TabUnk; - Gbl.Usrs.LstGsts.NumUsrs = 0; - Gbl.Usrs.LstGsts.Lst = NULL; + Gbl.Usrs.LstUsrs[Rol__GUEST_].Lst = NULL; + Gbl.Usrs.LstUsrs[Rol__GUEST_].NumUsrs = 0; - Gbl.Usrs.LstStds.NumUsrs = 0; - Gbl.Usrs.LstStds.Lst = NULL; + Gbl.Usrs.LstUsrs[Rol_STUDENT].Lst = NULL; + Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs = 0; - Gbl.Usrs.LstTchs.NumUsrs = 0; - Gbl.Usrs.LstTchs.Lst = NULL; + Gbl.Usrs.LstUsrs[Rol_TEACHER].Lst = NULL; + Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs = 0; - Gbl.Usrs.LstAdms.NumUsrs = 0; - Gbl.Usrs.LstAdms.Lst = NULL; + Gbl.Usrs.LstUsrs[Rol_DEG_ADM].Lst = NULL; // Used to list of administrators of any scope, not only degree administrators + Gbl.Usrs.LstUsrs[Rol_DEG_ADM].NumUsrs = 0; Gbl.ExamAnnouncements.NumExaAnns = 0; Gbl.ExamAnnouncements.Lst = NULL; @@ -462,9 +462,10 @@ void Gbl_Cleanup (void) Hld_FreeListHolidays (); Lnk_FreeListLinks (); Plg_FreeListPlugins (); - Usr_FreeUsrsList (&Gbl.Usrs.LstAdms); - Usr_FreeUsrsList (&Gbl.Usrs.LstTchs); - Usr_FreeUsrsList (&Gbl.Usrs.LstStds); + Usr_FreeUsrsList (Rol__GUEST_); + Usr_FreeUsrsList (Rol_STUDENT); + Usr_FreeUsrsList (Rol_TEACHER); + Usr_FreeUsrsList (Rol_DEG_ADM); Usr_FreeListOtherRecipients (); Usr_FreeListsSelectedUsrCods (); Syl_FreeListItemsSyllabus (); diff --git a/swad_global.h b/swad_global.h index 6ee812f0..dd4c68e0 100644 --- a/swad_global.h +++ b/swad_global.h @@ -362,10 +362,7 @@ struct Globals { struct UsrData UsrDat; } Other; // Another user, used for example to register in / remove from a course - struct ListUsers LstGsts; - struct ListUsers LstStds; - struct ListUsers LstTchs; - struct ListUsers LstAdms; + struct ListUsrs LstUsrs[Rol_NUM_ROLES]; struct { char *All; diff --git a/swad_message.c b/swad_message.c index 5a5c1e1c..acf5fca3 100644 --- a/swad_message.c +++ b/swad_message.c @@ -162,11 +162,11 @@ void Msg_ListEMails (void) Grp_ShowFormToSelectSeveralGroups (ActMaiStd); /***** Get and order list of students in this course *****/ - Usr_GetListUsrs (&Gbl.Usrs.LstStds,Rol_STUDENT,Sco_SCOPE_CRS); + Usr_GetListUsrs (Rol_STUDENT,Sco_SCOPE_CRS); - if (Gbl.Usrs.LstStds.NumUsrs) + if (Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs) { - if (Usr_GetIfShowBigList (Gbl.Usrs.LstStds.NumUsrs)) + if (Usr_GetIfShowBigList (Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs)) { /***** Start of the frame used to list the e-mails *****/ Lay_StartRoundFrameTable (NULL,0,Txt_Students_who_have_accepted_and_who_have_e_mail); @@ -178,13 +178,13 @@ void Msg_ListEMails (void) /***** List the students' e-mail addresses *****/ for (NumUsr = 0; - NumUsr < Gbl.Usrs.LstStds.NumUsrs; + NumUsr < Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs; NumUsr++) { - UsrDat.UsrCod = Gbl.Usrs.LstStds.Lst[NumUsr].UsrCod; + UsrDat.UsrCod = Gbl.Usrs.LstUsrs[Rol_STUDENT].Lst[NumUsr].UsrCod; if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // If user's data exist... { - UsrDat.Accepted = Gbl.Usrs.LstStds.Lst[NumUsr].Accepted; + UsrDat.Accepted = Gbl.Usrs.LstUsrs[Rol_STUDENT].Lst[NumUsr].Accepted; if (UsrDat.Email[0]) { NumStdsWithEmail++; @@ -224,7 +224,7 @@ void Msg_ListEMails (void) ""); fprintf (Gbl.F.Out,Txt_X_students_who_have_e_mail, NumStdsWithEmail, - ((float) NumStdsWithEmail / (float) Gbl.Usrs.LstStds.NumUsrs) * 100.0,Gbl.Usrs.LstStds.NumUsrs); + ((float) NumStdsWithEmail / (float) Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs) * 100.0,Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs); fprintf (Gbl.F.Out,"" ""); @@ -232,7 +232,7 @@ void Msg_ListEMails (void) fprintf (Gbl.F.Out,"" ""); fprintf (Gbl.F.Out,Txt_X_students_who_have_accepted_and_who_have_e_mail, - NumAcceptedStdsWithEmail,((float) NumAcceptedStdsWithEmail / (float) Gbl.Usrs.LstStds.NumUsrs) * 100.0,Gbl.Usrs.LstStds.NumUsrs); + NumAcceptedStdsWithEmail,((float) NumAcceptedStdsWithEmail / (float) Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs) * 100.0,Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs); fprintf (Gbl.F.Out,"" ""); @@ -255,7 +255,7 @@ void Msg_ListEMails (void) Usr_ShowWarningNoUsersFound (Rol_STUDENT); /***** Free memory for students list *****/ - Usr_FreeUsrsList (&Gbl.Usrs.LstStds); + Usr_FreeUsrsList (Rol_STUDENT); /***** Free memory for list of selected groups *****/ Grp_FreeListCodSelectedGrps (); @@ -286,8 +286,8 @@ static void Msg_PutFormMsgUsrs (const char *Content) extern const char *Txt_Send_message; char YN[1+1]; - Gbl.Usrs.LstTchs.NumUsrs = - Gbl.Usrs.LstStds.NumUsrs = 0; + Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs = + Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs = 0; /***** Get parameter that indicates if the message is a reply to another message *****/ Par_GetParToText ("IsReply",YN,1); @@ -328,17 +328,17 @@ static void Msg_PutFormMsgUsrs (const char *Content) Grp_ShowFormToSelectSeveralGroups (ActReqMsgUsr); /***** Get and order lists of users from this course *****/ - Usr_GetListUsrs (&Gbl.Usrs.LstTchs,Rol_TEACHER,Sco_SCOPE_CRS); - Usr_GetListUsrs (&Gbl.Usrs.LstStds,Rol_STUDENT,Sco_SCOPE_CRS); + Usr_GetListUsrs (Rol_TEACHER,Sco_SCOPE_CRS); + Usr_GetListUsrs (Rol_STUDENT,Sco_SCOPE_CRS); - if (Gbl.Usrs.LstTchs.NumUsrs || - Gbl.Usrs.LstStds.NumUsrs) + if (Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs || + Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs) /***** Get lists of selected users *****/ Usr_GetListsSelectedUsrs (); } - if (Usr_GetIfShowBigList (Gbl.Usrs.LstTchs.NumUsrs + - Gbl.Usrs.LstStds.NumUsrs)) + if (Usr_GetIfShowBigList (Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs + + Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs)) { /***** Start frame *****/ Lay_StartRoundFrame (NULL, @@ -347,8 +347,8 @@ static void Msg_PutFormMsgUsrs (const char *Content) NULL); /***** Form to select type of list used for select several users *****/ - if (Gbl.Usrs.LstTchs.NumUsrs || - Gbl.Usrs.LstStds.NumUsrs) + if (Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs || + Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs) Usr_ShowFormsToSelectUsrListType (ActReqMsgUsr); /***** Form to show several potential recipients *****/ @@ -433,8 +433,8 @@ static void Msg_PutFormMsgUsrs (const char *Content) Usr_FreeListOtherRecipients (); /***** Free memory used for by the lists of users *****/ - Usr_FreeUsrsList (&Gbl.Usrs.LstTchs); - Usr_FreeUsrsList (&Gbl.Usrs.LstStds); + Usr_FreeUsrsList (Rol_TEACHER); + Usr_FreeUsrsList (Rol_STUDENT); /***** Free memory used by list of users *****/ Usr_FreeListsSelectedUsrCods (); diff --git a/swad_photo.c b/swad_photo.c index e48b0295..cd5bade9 100644 --- a/swad_photo.c +++ b/swad_photo.c @@ -100,7 +100,7 @@ static void Pho_ClearPhotoName (long UsrCod); static long Pho_GetDegWithAvgPhotoLeastRecentlyUpdated (void); static long Pho_GetTimeAvgPhotoWasComputed (long DegCod); static long Pho_GetTimeToComputeAvgPhoto (long DegCod); -static void Pho_ComputeAveragePhoto (long DegCod,Usr_Sex_t Sex,struct ListUsers *LstUsrs, +static void Pho_ComputeAveragePhoto (long DegCod,Usr_Sex_t Sex,Rol_Role_t Role, Pho_AvgPhotoTypeOfAverage_t TypeOfAverage,const char *DirAvgPhotosRelPath, unsigned *NumStds,unsigned *NumStdsWithPhoto,long *TimeToComputeAvgPhotoInMicroseconds); static void Pho_PutSelectorForTypeOfAvg (void); @@ -1293,7 +1293,7 @@ void Pho_CalcPhotoDegree (void) TypeOfAverage++) { /***** Compute average photos of students belonging this degree *****/ - Pho_ComputeAveragePhoto (DegCod,Sex,&Gbl.Usrs.LstStds, + Pho_ComputeAveragePhoto (DegCod,Sex,Rol_STUDENT, TypeOfAverage,DirAvgPhotosRelPath[TypeOfAverage], &NumStds,&NumStdsWithPhoto,&PartialTimeToComputeAvgPhotoInMicroseconds); TotalTimeToComputeAvgPhotoInMicroseconds += PartialTimeToComputeAvgPhotoInMicroseconds; @@ -1304,7 +1304,7 @@ void Pho_CalcPhotoDegree (void) } /***** Free memory for students list *****/ - Usr_FreeUsrsList (&Gbl.Usrs.LstStds); + Usr_FreeUsrsList (Rol_STUDENT); /***** Show photos *****/ Pho_ShowOrPrintPhotoDegree (Pho_DEGREES_SEE); @@ -1489,7 +1489,7 @@ static long Pho_GetTimeToComputeAvgPhoto (long DegCod) /*****************************************************************************/ // Returns number of users in list with photo -static void Pho_ComputeAveragePhoto (long DegCod,Usr_Sex_t Sex,struct ListUsers *LstUsrs, +static void Pho_ComputeAveragePhoto (long DegCod,Usr_Sex_t Sex,Rol_Role_t Role, Pho_AvgPhotoTypeOfAverage_t TypeOfAverage,const char *DirAvgPhotosRelPath, unsigned *NumStds,unsigned *NumStdsWithPhoto,long *TimeToComputeAvgPhotoInMicroseconds) { @@ -1528,16 +1528,16 @@ static void Pho_ComputeAveragePhoto (long DegCod,Usr_Sex_t Sex,struct ListUsers /***** Loop writing file names in text file *****/ for (NumUsr = 0; - NumUsr < LstUsrs->NumUsrs; + NumUsr < Gbl.Usrs.LstUsrs[Role].NumUsrs; NumUsr++) { - Gbl.Usrs.Other.UsrDat.Sex = LstUsrs->Lst[NumUsr].Sex; + Gbl.Usrs.Other.UsrDat.Sex = Gbl.Usrs.LstUsrs[Role].Lst[NumUsr].Sex; if (Sex == Usr_SEX_ALL || Sex == Gbl.Usrs.Other.UsrDat.Sex) { (*NumStds)++; /***** Add photo to file for average face calculation *****/ - Gbl.Usrs.Other.UsrDat.UsrCod = LstUsrs->Lst[NumUsr].UsrCod; + Gbl.Usrs.Other.UsrDat.UsrCod = Gbl.Usrs.LstUsrs[Role].Lst[NumUsr].UsrCod; if (Pho_CheckIfPrivPhotoExists (Gbl.Usrs.Other.UsrDat.UsrCod,PathPrivRelPhoto)) { (*NumStdsWithPhoto)++; @@ -1573,7 +1573,10 @@ static void Pho_ComputeAveragePhoto (long DegCod,Usr_Sex_t Sex,struct ListUsers tvEndComputingStat.tv_sec--; tvEndComputingStat.tv_usec += 1000000L; } - *TimeToComputeAvgPhotoInMicroseconds = (tvEndComputingStat.tv_sec - tvStartComputingStat.tv_sec) * 1000000L + tvEndComputingStat.tv_usec - tvStartComputingStat.tv_usec; + *TimeToComputeAvgPhotoInMicroseconds = (tvEndComputingStat.tv_sec - + tvStartComputingStat.tv_sec) * 1000000L + + tvEndComputingStat.tv_usec - + tvStartComputingStat.tv_usec; } } diff --git a/swad_statistic.c b/swad_statistic.c index 18d2d6e6..ff9b2518 100644 --- a/swad_statistic.c +++ b/swad_statistic.c @@ -417,14 +417,14 @@ void Sta_AskShowCrsHits (void) Grp_ShowFormToSelectSeveralGroups (ActReqAccCrs); /***** Get and order the lists of users of this course *****/ - Usr_GetListUsrs (&Gbl.Usrs.LstTchs,Rol_TEACHER,Sco_SCOPE_CRS); - Usr_GetListUsrs (&Gbl.Usrs.LstStds,Rol_STUDENT,Sco_SCOPE_CRS); + Usr_GetListUsrs (Rol_TEACHER,Sco_SCOPE_CRS); + Usr_GetListUsrs (Rol_STUDENT,Sco_SCOPE_CRS); - if (Gbl.Usrs.LstTchs.NumUsrs || - Gbl.Usrs.LstStds.NumUsrs) + if (Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs || + Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs) { - if (Usr_GetIfShowBigList (Gbl.Usrs.LstTchs.NumUsrs + - Gbl.Usrs.LstStds.NumUsrs)) + if (Usr_GetIfShowBigList (Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs + + Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs)) { /***** Get lists of selected users *****/ Usr_GetListsSelectedUsrs (); @@ -554,8 +554,8 @@ void Sta_AskShowCrsHits (void) Lay_ShowAlert (Lay_WARNING,Txt_No_teachers_or_students_found); /* Free memory used by the lists */ - Usr_FreeUsrsList (&Gbl.Usrs.LstTchs); - Usr_FreeUsrsList (&Gbl.Usrs.LstStds); + Usr_FreeUsrsList (Rol_TEACHER); + Usr_FreeUsrsList (Rol_STUDENT); /* Free memory for list of selected groups */ Grp_FreeListCodSelectedGrps (); diff --git a/swad_test.c b/swad_test.c index 15f9c09b..3c028713 100644 --- a/swad_test.c +++ b/swad_test.c @@ -6821,14 +6821,14 @@ void Tst_SelUsrsToSeeUsrsExams (void) Grp_ShowFormToSelectSeveralGroups (ActReqSeeUsrTstExa); /***** Get and order lists of users from this course *****/ - Usr_GetListUsrs (&Gbl.Usrs.LstTchs,Rol_TEACHER,Sco_SCOPE_CRS); - Usr_GetListUsrs (&Gbl.Usrs.LstStds,Rol_STUDENT,Sco_SCOPE_CRS); + Usr_GetListUsrs (Rol_TEACHER,Sco_SCOPE_CRS); + Usr_GetListUsrs (Rol_STUDENT,Sco_SCOPE_CRS); - if (Gbl.Usrs.LstTchs.NumUsrs || - Gbl.Usrs.LstStds.NumUsrs) + if (Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs || + Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs) { - if (Usr_GetIfShowBigList (Gbl.Usrs.LstTchs.NumUsrs + - Gbl.Usrs.LstStds.NumUsrs)) + if (Usr_GetIfShowBigList (Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs + + Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs)) { /***** Start frame *****/ Lay_StartRoundFrame (NULL,Txt_Exams,NULL); @@ -6876,8 +6876,8 @@ void Tst_SelUsrsToSeeUsrsExams (void) Usr_ShowWarningNoUsersFound (Rol_UNKNOWN); /***** Free memory for users' list *****/ - Usr_FreeUsrsList (&Gbl.Usrs.LstTchs); - Usr_FreeUsrsList (&Gbl.Usrs.LstStds); + Usr_FreeUsrsList (Rol_TEACHER); + Usr_FreeUsrsList (Rol_STUDENT); /***** Free the memory used by the list of users *****/ Usr_FreeListsSelectedUsrCods (); diff --git a/swad_user.c b/swad_user.c index d254543f..b4dd6537 100644 --- a/swad_user.c +++ b/swad_user.c @@ -144,9 +144,8 @@ static void Usr_WriteUsrData (const char *BgColor, static void Usr_BuildQueryToGetUsrsLstCrs (Rol_Role_t Role,bool Search,const char *UsrQuery,char *Query); static void Usr_GetAdmsLst (Sco_Scope_t Scope); static void Usr_GetGstsLst (Sco_Scope_t Scope); -static void Usr_GetListUsrsFromQuery (const char *Query,struct ListUsers *LstUsrs, - Rol_Role_t Role,Sco_Scope_t Scope); -static void Usr_AllocateUsrsList (struct ListUsers *LstUsrs); +static void Usr_GetListUsrsFromQuery (const char *Query,Rol_Role_t Role,Sco_Scope_t Scope); +static void Usr_AllocateUsrsList (Rol_Role_t Role); static void Usr_ShowWarningListIsTooBig (unsigned NumStds); static void Usr_PutButtonToConfirmIWantToSeeBigList (unsigned NumUsrs); @@ -154,7 +153,7 @@ static void Usr_AllocateListOtherRecipients (void); static void Usr_FormToSelectUsrListType (Act_Action_t NextAction,Usr_ShowUsrsType_t ListType); -static Usr_Sex_t Usr_GetSexOfUsrsLst (struct ListUsers *LstUsrs); +static Usr_Sex_t Usr_GetSexOfUsrsLst (Rol_Role_t Role); static void Usr_PutCheckboxToSelectUser (struct UsrData *UsrDat,bool UsrIsTheMsgSender); static void Usr_PutCheckboxListWithPhotos (void); @@ -3686,7 +3685,7 @@ static void Usr_BuildQueryToGetUsrsLstCrs (Rol_Role_t Role,bool Search,const cha // - Rol_STUDENT // - Rol_TEACHER -void Usr_GetListUsrs (struct ListUsers *LstUsrs,Rol_Role_t Role,Sco_Scope_t Scope) +void Usr_GetListUsrs (Rol_Role_t Role,Sco_Scope_t Scope) { char Query[512]; @@ -3795,7 +3794,7 @@ void Usr_GetListUsrs (struct ListUsers *LstUsrs,Rol_Role_t Role,Sco_Scope_t Scop Lay_ShowAlert (Lay_INFO,Query); */ /***** Get list of users from database given a query *****/ - Usr_GetListUsrsFromQuery (Query,LstUsrs,Role,Scope); + Usr_GetListUsrsFromQuery (Query,Role,Scope); } @@ -3803,7 +3802,7 @@ void Usr_GetListUsrs (struct ListUsers *LstUsrs,Rol_Role_t Role,Sco_Scope_t Scop /********* Search list of users with a given role in current scope ***********/ /*****************************************************************************/ -void Usr_SearchListUsrs (struct ListUsers *LstUsrs,Rol_Role_t Role,const char *UsrQuery) +void Usr_SearchListUsrs (Rol_Role_t Role,const char *UsrQuery) { char Query[16*1024]; @@ -3940,7 +3939,7 @@ void Usr_SearchListUsrs (struct ListUsers *LstUsrs,Rol_Role_t Role,const char *U Lay_ShowAlert (Lay_INFO,Query); */ /***** Get list of users from database given a query *****/ - Usr_GetListUsrsFromQuery (Query,LstUsrs,Role,Gbl.Scope.Current); + Usr_GetListUsrsFromQuery (Query,Role,Gbl.Scope.Current); } /*****************************************************************************/ @@ -4069,7 +4068,7 @@ static void Usr_GetAdmsLst (Sco_Scope_t Scope) } /***** Get list of administrators from database *****/ - Usr_GetListUsrsFromQuery (Query,&Gbl.Usrs.LstAdms,Rol_UNKNOWN,Scope); + Usr_GetListUsrsFromQuery (Query,Rol_DEG_ADM,Scope); } /*****************************************************************************/ @@ -4120,7 +4119,7 @@ static void Usr_GetGstsLst (Sco_Scope_t Scope) } /***** Get list of students from database *****/ - Usr_GetListUsrsFromQuery (Query,&Gbl.Usrs.LstGsts,Rol__GUEST_,Scope); + Usr_GetListUsrsFromQuery (Query,Rol__GUEST_,Scope); } /*****************************************************************************/ @@ -4131,7 +4130,7 @@ void Usr_GetUnorderedStdsCodesInDeg (long DegCod) { char Query[512]; - Gbl.Usrs.LstStds.NumUsrs = 0; + Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs = 0; if (Usr_GetNumUsrsInCrssOfDeg (Rol_STUDENT,DegCod)) { @@ -4146,7 +4145,7 @@ void Usr_GetUnorderedStdsCodesInDeg (long DegCod) DegCod,(unsigned) Rol_STUDENT); /***** Get list of students from database *****/ - Usr_GetListUsrsFromQuery (Query,&Gbl.Usrs.LstStds,Rol_STUDENT,Sco_SCOPE_DEG); + Usr_GetListUsrsFromQuery (Query,Rol_STUDENT,Sco_SCOPE_DEG); } } @@ -4154,8 +4153,7 @@ void Usr_GetUnorderedStdsCodesInDeg (long DegCod) /********************** Get list of users from database **********************/ /*****************************************************************************/ -static void Usr_GetListUsrsFromQuery (const char *Query,struct ListUsers *LstUsrs, - Rol_Role_t Role,Sco_Scope_t Scope) +static void Usr_GetListUsrsFromQuery (const char *Query,Rol_Role_t Role,Sco_Scope_t Scope) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -4164,36 +4162,36 @@ static void Usr_GetListUsrsFromQuery (const char *Query,struct ListUsers *LstUsr if (!Query[0]) { - LstUsrs->NumUsrs = 0; + Gbl.Usrs.LstUsrs[Role].NumUsrs = 0; return; } /***** Query database *****/ - if ((LstUsrs->NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get list of users"))) + if ((Gbl.Usrs.LstUsrs[Role].NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get list of users"))) { - if (LstUsrs->NumUsrs > Cfg_MAX_USRS_IN_LIST) + if (Gbl.Usrs.LstUsrs[Role].NumUsrs > Cfg_MAX_USRS_IN_LIST) { - Usr_ShowWarningListIsTooBig (LstUsrs->NumUsrs); + Usr_ShowWarningListIsTooBig (Gbl.Usrs.LstUsrs[Role].NumUsrs); Abort = true; } else { /***** Allocate memory for the list of users *****/ - Usr_AllocateUsrsList (LstUsrs); + Usr_AllocateUsrsList (Role); /***** Get list of users *****/ for (NumUsr = 0; - NumUsr < LstUsrs->NumUsrs; + NumUsr < Gbl.Usrs.LstUsrs[Role].NumUsrs; NumUsr++) { /* Get next user */ row = mysql_fetch_row (mysql_res); /* Get user code */ - LstUsrs->Lst[NumUsr].UsrCod = Str_ConvertStrCodToLongCod (row[0]); + Gbl.Usrs.LstUsrs[Role].Lst[NumUsr].UsrCod = Str_ConvertStrCodToLongCod (row[0]); /* Get user's sex */ - LstUsrs->Lst[NumUsr].Sex = Usr_GetSexFromStr (row[1]); + Gbl.Usrs.LstUsrs[Role].Lst[NumUsr].Sex = Usr_GetSexFromStr (row[1]); /* Get user's acceptance of enrollment in course(s) */ if (Role == Rol_STUDENT || @@ -4201,16 +4199,16 @@ static void Usr_GetListUsrsFromQuery (const char *Query,struct ListUsers *LstUsr { if (Scope == Sco_SCOPE_CRS) // Query result has a third column with the acceptation - LstUsrs->Lst[NumUsr].Accepted = (Str_ConvertToUpperLetter (row[2][0]) == 'Y'); + Gbl.Usrs.LstUsrs[Role].Lst[NumUsr].Accepted = (Str_ConvertToUpperLetter (row[2][0]) == 'Y'); else // Query result has not a third column with the acceptation - LstUsrs->Lst[NumUsr].Accepted = (Usr_GetNumCrssOfUsrWithARoleNotAccepted (LstUsrs->Lst[NumUsr].UsrCod,Role) == 0); + Gbl.Usrs.LstUsrs[Role].Lst[NumUsr].Accepted = (Usr_GetNumCrssOfUsrWithARoleNotAccepted (Gbl.Usrs.LstUsrs[Role].Lst[NumUsr].UsrCod,Role) == 0); } else - LstUsrs->Lst[NumUsr].Accepted = false; + Gbl.Usrs.LstUsrs[Role].Lst[NumUsr].Accepted = false; /* By default, users are not removed */ - LstUsrs->Lst[NumUsr].Remove = false; + Gbl.Usrs.LstUsrs[Role].Lst[NumUsr].Remove = false; } } } @@ -4226,7 +4224,7 @@ static void Usr_GetListUsrsFromQuery (const char *Query,struct ListUsers *LstUsr /********************** Allocate space for list of users *********************/ /*****************************************************************************/ -static void Usr_AllocateUsrsList (struct ListUsers *LstUsrs) +static void Usr_AllocateUsrsList (Rol_Role_t Role) { /* if (Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SYS_ADM) @@ -4235,8 +4233,8 @@ if (Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SYS_ADM) Lay_ShowAlert (Lay_INFO,Gbl.Message); } */ - if (LstUsrs->NumUsrs) - if ((LstUsrs->Lst = (struct UsrInList *) calloc (LstUsrs->NumUsrs,sizeof (struct UsrInList))) == NULL) + if (Gbl.Usrs.LstUsrs[Role].NumUsrs) + if ((Gbl.Usrs.LstUsrs[Role].Lst = (struct UsrInList *) calloc (Gbl.Usrs.LstUsrs[Role].NumUsrs,sizeof (struct UsrInList))) == NULL) Lay_ShowErrorAndExit ("Not enough memory to store users list."); } @@ -4244,19 +4242,19 @@ if (Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SYS_ADM) /********************* Free space used for list of users *********************/ /*****************************************************************************/ -void Usr_FreeUsrsList (struct ListUsers *LstUsrs) +void Usr_FreeUsrsList (Rol_Role_t Role) { - if (LstUsrs->NumUsrs) + if (Gbl.Usrs.LstUsrs[Role].NumUsrs) { /***** Free the list itself *****/ - if (LstUsrs->Lst) + if (Gbl.Usrs.LstUsrs[Role].Lst) { - free ((void *) LstUsrs->Lst); - LstUsrs->Lst = NULL; + free ((void *) Gbl.Usrs.LstUsrs[Role].Lst); + Gbl.Usrs.LstUsrs[Role].Lst = NULL; } /***** Reset number of users *****/ - LstUsrs->NumUsrs = 0; + Gbl.Usrs.LstUsrs[Role].NumUsrs = 0; } } @@ -4829,11 +4827,11 @@ void Usr_ListUsersToSelect (Rol_Role_t Role) switch (Role) { case Rol_STUDENT: - if (!Gbl.Usrs.LstStds.NumUsrs) + if (!Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs) return; break; case Rol_TEACHER: - if (!Gbl.Usrs.LstTchs.NumUsrs) + if (!Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs) return; break; default: @@ -4863,53 +4861,46 @@ void Usr_PutCheckboxToSelectAllTheUsers (Rol_Role_t Role) { extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; - struct ListUsers *LstUsrs; Usr_Sex_t Sex; fprintf (Gbl.F.Out,"" "", Usr_GetColumnsForSelectUsrs ()); if (Role == Rol_STUDENT) - { fprintf (Gbl.F.Out,""); - LstUsrs = &Gbl.Usrs.LstStds; - } else // Role == Rol_TEACHER or Role == Rol__GUEST_ - { fprintf (Gbl.F.Out,""); - LstUsrs = &Gbl.Usrs.LstTchs; - } - Sex = Usr_GetSexOfUsrsLst (LstUsrs); + Sex = Usr_GetSexOfUsrsLst (Role); fprintf (Gbl.F.Out,"%s:" "" "", - LstUsrs->NumUsrs == 1 ? Txt_ROLES_SINGUL_Abc[Role][Sex] : - Txt_ROLES_PLURAL_Abc[Role][Sex]); + Gbl.Usrs.LstUsrs[Role].NumUsrs == 1 ? Txt_ROLES_SINGUL_Abc[Role][Sex] : + Txt_ROLES_PLURAL_Abc[Role][Sex]); } /*****************************************************************************/ /************************** Get sex of a list of users ***********************/ /*****************************************************************************/ -static Usr_Sex_t Usr_GetSexOfUsrsLst (struct ListUsers *LstUsrs) +static Usr_Sex_t Usr_GetSexOfUsrsLst (Rol_Role_t Role) { Usr_Sex_t Sex; unsigned NumUsr; /***** If no users, sex is undefined *****/ - if (LstUsrs->NumUsrs == 0) + if (Gbl.Usrs.LstUsrs[Role].NumUsrs == 0) return Usr_SEX_UNKNOWN; /***** Initialize sex to that of first user in list *****/ - Sex = LstUsrs->Lst[0].Sex; + Sex = Gbl.Usrs.LstUsrs[Role].Lst[0].Sex; /***** Search if there is one user at least with different sex than the first one *****/ for (NumUsr = 1; - NumUsr < LstUsrs->NumUsrs; + NumUsr < Gbl.Usrs.LstUsrs[Role].NumUsrs; NumUsr++) - if (LstUsrs->Lst[NumUsr].Sex != Sex) + if (Gbl.Usrs.LstUsrs[Role].Lst[NumUsr].Sex != Sex) return Usr_SEX_UNKNOWN; return Sex; @@ -5046,7 +5037,7 @@ static void Usr_ListMainDataGsts (bool PutCheckBoxToSelectUsr) /***** Initialize field names *****/ Usr_SetUsrDatMainFieldNames (); - if (Gbl.Usrs.LstGsts.NumUsrs) + if (Gbl.Usrs.LstUsrs[Rol__GUEST_].NumUsrs) { /***** Heading row with column names *****/ Usr_WriteHeaderFieldsUsrDat (PutCheckBoxToSelectUsr); // Columns for the data @@ -5056,9 +5047,9 @@ static void Usr_ListMainDataGsts (bool PutCheckBoxToSelectUsr) /***** List students' data *****/ for (NumUsr = 0, Gbl.RowEvenOdd = 0; - NumUsr < Gbl.Usrs.LstGsts.NumUsrs; ) + NumUsr < Gbl.Usrs.LstUsrs[Rol__GUEST_].NumUsrs; ) { - UsrDat.UsrCod = Gbl.Usrs.LstGsts.Lst[NumUsr].UsrCod; + UsrDat.UsrCod = Gbl.Usrs.LstUsrs[Rol__GUEST_].Lst[NumUsr].UsrCod; if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // If user's data exist... { UsrDat.Accepted = false; // Guests have no courses,... @@ -5073,11 +5064,11 @@ static void Usr_ListMainDataGsts (bool PutCheckBoxToSelectUsr) /***** Free memory used for user's data *****/ Usr_UsrDataDestructor (&UsrDat); } - else // Gbl.Usrs.LstGsts.NumUsrs == 0 + else // Gbl.Usrs.LstUsrs[Rol__GUEST_].NumUsrs == 0 Usr_ShowWarningNoUsersFound (Rol__GUEST_); - /***** Free memory for students list *****/ - Usr_FreeUsrsList (&Gbl.Usrs.LstGsts); + /***** Free memory for guests list *****/ + Usr_FreeUsrsList (Rol__GUEST_); } /*****************************************************************************/ @@ -5095,7 +5086,7 @@ static void Usr_ListMainDataStds (bool PutCheckBoxToSelectUsr) GroupNames = NULL; // To avoid warning - if (Gbl.Usrs.LstStds.NumUsrs) + if (Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs) { /***** Allocate memory for the string with the list of group names where student belongs to *****/ if ((GroupNames = (char *) malloc ((MAX_LENGTH_GROUP_NAME+3)*Gbl.CurrentCrs.Grps.GrpTypes.NumGrpsTotal)) == NULL) @@ -5120,12 +5111,12 @@ static void Usr_ListMainDataStds (bool PutCheckBoxToSelectUsr) /***** List students' data *****/ for (NumUsr = 0, Gbl.RowEvenOdd = 0; - NumUsr < Gbl.Usrs.LstStds.NumUsrs; ) + NumUsr < Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs; ) { - UsrDat.UsrCod = Gbl.Usrs.LstStds.Lst[NumUsr].UsrCod; + UsrDat.UsrCod = Gbl.Usrs.LstUsrs[Rol_STUDENT].Lst[NumUsr].UsrCod; if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // If user's data exist... { - UsrDat.Accepted = Gbl.Usrs.LstStds.Lst[NumUsr].Accepted; + UsrDat.Accepted = Gbl.Usrs.LstUsrs[Rol_STUDENT].Lst[NumUsr].Accepted; Usr_WriteRowUsrMainData (++NumUsr,&UsrDat,PutCheckBoxToSelectUsr); Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; @@ -5138,11 +5129,11 @@ static void Usr_ListMainDataStds (bool PutCheckBoxToSelectUsr) /***** Free memory used by the string with the list of group names where student belongs to *****/ free ((void *) GroupNames); } - else // Gbl.Usrs.LstStds.NumUsrs == 0 + else // Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs == 0 Usr_ShowWarningNoUsersFound (Rol_STUDENT); /***** Free memory for students list *****/ - Usr_FreeUsrsList (&Gbl.Usrs.LstStds); + Usr_FreeUsrsList (Rol_STUDENT); } /*****************************************************************************/ @@ -5160,7 +5151,7 @@ static void Usr_ListMainDataTchs (bool PutCheckBoxToSelectUsr) /***** Initialize field names *****/ Usr_SetUsrDatMainFieldNames (); - if (Gbl.Usrs.LstTchs.NumUsrs) + if (Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs) { /***** Initialize number of columns *****/ NumColumns = Usr_NUM_MAIN_FIELDS_DATA_USR; @@ -5193,12 +5184,12 @@ static void Usr_ListMainDataTchs (bool PutCheckBoxToSelectUsr) /***** List data of teachers *****/ for (NumUsr = 0, Gbl.RowEvenOdd = 0; - NumUsr < Gbl.Usrs.LstTchs.NumUsrs; ) + NumUsr < Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs; ) { - UsrDat.UsrCod = Gbl.Usrs.LstTchs.Lst[NumUsr].UsrCod; + UsrDat.UsrCod = Gbl.Usrs.LstUsrs[Rol_TEACHER].Lst[NumUsr].UsrCod; if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // If user's data exist... { - UsrDat.Accepted = Gbl.Usrs.LstTchs.Lst[NumUsr].Accepted; + UsrDat.Accepted = Gbl.Usrs.LstUsrs[Rol_TEACHER].Lst[NumUsr].Accepted; Usr_WriteRowUsrMainData (++NumUsr,&UsrDat,PutCheckBoxToSelectUsr); Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; @@ -5208,11 +5199,11 @@ static void Usr_ListMainDataTchs (bool PutCheckBoxToSelectUsr) /***** Free memory used for user's data *****/ Usr_UsrDataDestructor (&UsrDat); } - else // Gbl.Usrs.LstTchs.NumUsrs == 0 + else // Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs == 0 Lay_ShowAlert (Lay_INFO,Txt_No_users_found[Rol_TEACHER]); /***** Free memory for teachers list *****/ - Usr_FreeUsrsList (&Gbl.Usrs.LstTchs); + Usr_FreeUsrsList (Rol_TEACHER); } /*****************************************************************************/ @@ -5273,7 +5264,7 @@ void Usr_ListAllDataGsts (void) /****** Get and order list of guests ******/ Usr_GetGstsLst (Gbl.Scope.Current); - if (Gbl.Usrs.LstGsts.NumUsrs) + if (Gbl.Usrs.LstUsrs[Rol__GUEST_].NumUsrs) { /***** Set number of columns *****/ NumColumnsCommonCard = Usr_NUM_ALL_FIELDS_DATA_INV; @@ -5301,9 +5292,9 @@ void Usr_ListAllDataGsts (void) /***** List guests' data *****/ for (NumUsr = 0, Gbl.RowEvenOdd = 0; - NumUsr < Gbl.Usrs.LstGsts.NumUsrs; ) + NumUsr < Gbl.Usrs.LstUsrs[Rol__GUEST_].NumUsrs; ) { - UsrDat.UsrCod = Gbl.Usrs.LstGsts.Lst[NumUsr].UsrCod; + UsrDat.UsrCod = Gbl.Usrs.LstUsrs[Rol__GUEST_].Lst[NumUsr].UsrCod; if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // If user's data exist... { UsrDat.Accepted = false; // Guests have no courses,... @@ -5322,11 +5313,11 @@ void Usr_ListAllDataGsts (void) /***** End of table *****/ fprintf (Gbl.F.Out,""); } - else // Gbl.Usrs.LstGsts.NumUsrs == 0 + else // Gbl.Usrs.LstUsrs[Rol__GUEST_].NumUsrs == 0 Usr_ShowWarningNoUsersFound (Rol__GUEST_); - /***** Free memory for guests' list *****/ - Usr_FreeUsrsList (&Gbl.Usrs.LstGsts); + /***** Free memory for guests list *****/ + Usr_FreeUsrsList (Rol__GUEST_); } /*****************************************************************************/ @@ -5392,9 +5383,9 @@ void Usr_ListAllDataStds (void) Sco_GetScope (); /****** Get and order list of students in current course ******/ - Usr_GetListUsrs (&Gbl.Usrs.LstStds,Rol_STUDENT,Gbl.Scope.Current); + Usr_GetListUsrs (Rol_STUDENT,Gbl.Scope.Current); - if (Gbl.Usrs.LstStds.NumUsrs) + if (Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs) { if (Gbl.Scope.Current == Sco_SCOPE_CRS) /***** Get list of record fields in current course *****/ @@ -5493,12 +5484,12 @@ void Usr_ListAllDataStds (void) /***** List students' data *****/ for (NumUsr = 0, Gbl.RowEvenOdd = 0; - NumUsr < Gbl.Usrs.LstStds.NumUsrs; ) + NumUsr < Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs; ) { - UsrDat.UsrCod = Gbl.Usrs.LstStds.Lst[NumUsr].UsrCod; + UsrDat.UsrCod = Gbl.Usrs.LstUsrs[Rol_STUDENT].Lst[NumUsr].UsrCod; if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // If user's data exist... { - UsrDat.Accepted = Gbl.Usrs.LstStds.Lst[NumUsr].Accepted; + UsrDat.Accepted = Gbl.Usrs.LstUsrs[Rol_STUDENT].Lst[NumUsr].Accepted; NumUsr++; Usr_WriteRowStdAllData (&UsrDat,GroupNames); @@ -5516,14 +5507,14 @@ void Usr_ListAllDataStds (void) if (Gbl.Scope.Current == Sco_SCOPE_CRS) free ((void *) GroupNames); } - else // Gbl.Usrs.LstStds.NumUsrs == 0 + else // Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs == 0 Usr_ShowWarningNoUsersFound (Rol_STUDENT); /***** Free memory for list of selected groups *****/ Grp_FreeListCodSelectedGrps (); /***** Free memory for students list *****/ - Usr_FreeUsrsList (&Gbl.Usrs.LstStds); + Usr_FreeUsrsList (Rol_STUDENT); /***** Free list of groups types and groups in current course *****/ Grp_FreeListGrpTypesAndGrps (); @@ -5552,12 +5543,12 @@ void Usr_ListUsrsForSelection (Rol_Role_t Role) { case Rol_STUDENT: for (NumUsr = 0, Gbl.RowEvenOdd = 0; - NumUsr < Gbl.Usrs.LstStds.NumUsrs; ) + NumUsr < Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs; ) { - UsrDat.UsrCod = Gbl.Usrs.LstStds.Lst[NumUsr].UsrCod; + UsrDat.UsrCod = Gbl.Usrs.LstUsrs[Rol_STUDENT].Lst[NumUsr].UsrCod; if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // If user's data exist... { - UsrDat.Accepted = Gbl.Usrs.LstStds.Lst[NumUsr].Accepted; + UsrDat.Accepted = Gbl.Usrs.LstUsrs[Rol_STUDENT].Lst[NumUsr].Accepted; Usr_WriteRowUsrMainData (++NumUsr,&UsrDat,true); Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; @@ -5566,12 +5557,12 @@ void Usr_ListUsrsForSelection (Rol_Role_t Role) break; case Rol_TEACHER: for (NumUsr = 0, Gbl.RowEvenOdd = 0; - NumUsr < Gbl.Usrs.LstTchs.NumUsrs; ) + NumUsr < Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs; ) { - UsrDat.UsrCod = Gbl.Usrs.LstTchs.Lst[NumUsr].UsrCod; + UsrDat.UsrCod = Gbl.Usrs.LstUsrs[Rol_TEACHER].Lst[NumUsr].UsrCod; if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // If user's data exist... { - UsrDat.Accepted = Gbl.Usrs.LstTchs.Lst[NumUsr].Accepted; + UsrDat.Accepted = Gbl.Usrs.LstUsrs[Rol_TEACHER].Lst[NumUsr].Accepted; Usr_WriteRowUsrMainData (++NumUsr,&UsrDat,true); Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; @@ -5639,9 +5630,9 @@ void Usr_ListAllDataTchs (void) Sco_GetScope (); /***** Get and order list of teachers *****/ - Usr_GetListUsrs (&Gbl.Usrs.LstTchs,Rol_TEACHER,Gbl.Scope.Current); + Usr_GetListUsrs (Rol_TEACHER,Gbl.Scope.Current); - if (Gbl.Usrs.LstTchs.NumUsrs) + if (Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs) { /***** Initialize number of columns *****/ NumColumns = Usr_NUM_ALL_FIELDS_DATA_TCH; @@ -5667,12 +5658,12 @@ void Usr_ListAllDataTchs (void) /***** List data of teachers *****/ for (NumUsr = 0, Gbl.RowEvenOdd = 0; - NumUsr < Gbl.Usrs.LstTchs.NumUsrs; ) + NumUsr < Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs; ) { - UsrDat.UsrCod = Gbl.Usrs.LstTchs.Lst[NumUsr].UsrCod; + UsrDat.UsrCod = Gbl.Usrs.LstUsrs[Rol_TEACHER].Lst[NumUsr].UsrCod; if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // If user's data exist... { - UsrDat.Accepted = Gbl.Usrs.LstTchs.Lst[NumUsr].Accepted; + UsrDat.Accepted = Gbl.Usrs.LstUsrs[Rol_TEACHER].Lst[NumUsr].Accepted; NumUsr++; Usr_WriteRowTchAllData (&UsrDat); @@ -5686,11 +5677,11 @@ void Usr_ListAllDataTchs (void) /***** End of table *****/ fprintf (Gbl.F.Out,""); } - else // Gbl.Usrs.LstTchs.NumUsrs == 0 + else // Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs == 0 Lay_ShowAlert (Lay_INFO,Txt_No_users_found[Rol_TEACHER]); /***** Free memory for teachers list *****/ - Usr_FreeUsrsList (&Gbl.Usrs.LstTchs); + Usr_FreeUsrsList (Rol_TEACHER); } /*****************************************************************************/ @@ -5703,27 +5694,21 @@ unsigned Usr_ListUsrsFound (Rol_Role_t Role,const char *UsrQuery) extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; extern const char *Txt_ROLES_SINGUL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; extern const char *Txt_ROLES_PLURAL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; - struct ListUsers *LstUsrs; Usr_Sex_t Sex; unsigned NumUsr; struct UsrData UsrDat; unsigned NumUsrs; - /***** Set list *****/ - LstUsrs = ( Role == Rol_TEACHER ? &Gbl.Usrs.LstTchs : - (Role == Rol_STUDENT ? &Gbl.Usrs.LstStds : - &Gbl.Usrs.LstGsts)); - /***** Initialize field names *****/ Usr_SetUsrDatMainFieldNames (); /***** Search for users *****/ - Usr_SearchListUsrs (LstUsrs,Role,UsrQuery); - if ((NumUsrs = LstUsrs->NumUsrs)) + Usr_SearchListUsrs (Role,UsrQuery); + if ((NumUsrs = Gbl.Usrs.LstUsrs[Role].NumUsrs)) { /***** Write heading *****/ /* Number of users found */ - Sex = Usr_GetSexOfUsrsLst (LstUsrs); + Sex = Usr_GetSexOfUsrsLst (Role); sprintf (Gbl.Title,"%u %s", NumUsrs,(NumUsrs == 1) ? Txt_ROLES_SINGUL_abc[Role][Sex] : Txt_ROLES_PLURAL_abc[Role][Sex]); @@ -5741,10 +5726,10 @@ unsigned Usr_ListUsrsFound (Rol_Role_t Role,const char *UsrQuery) NumUsr < NumUsrs; NumUsr++) { - UsrDat.UsrCod = LstUsrs->Lst[NumUsr].UsrCod; + UsrDat.UsrCod = Gbl.Usrs.LstUsrs[Role].Lst[NumUsr].UsrCod; if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // If user's data exist... { - UsrDat.Accepted = LstUsrs->Lst[NumUsr].Accepted; + UsrDat.Accepted = Gbl.Usrs.LstUsrs[Role].Lst[NumUsr].Accepted; if (Role == Rol__GUEST_) UsrDat.Accepted = false; @@ -5780,7 +5765,7 @@ unsigned Usr_ListUsrsFound (Rol_Role_t Role,const char *UsrQuery) } /***** Free memory for teachers list *****/ - Usr_FreeUsrsList (LstUsrs); + Usr_FreeUsrsList (Role); return NumUsrs; } @@ -5868,7 +5853,7 @@ void Usr_ListDataAdms (void) Act_FormEnd (); fprintf (Gbl.F.Out,""); - if (Gbl.Usrs.LstAdms.NumUsrs) + if (Gbl.Usrs.LstUsrs[Rol_DEG_ADM].NumUsrs) { /****** Show photos? *****/ fprintf (Gbl.F.Out,"
"); } - else // Gbl.Usrs.LstAdms.NumUsrs == 0 + else // Gbl.Usrs.LstUsrs[Rol_DEG_ADM].NumUsrs == 0 Lay_ShowAlert (Lay_INFO,Txt_No_users_found[Rol_DEG_ADM]); /***** End frame *****/ Lay_EndRoundFrame (); - /***** Free memory for teachers list *****/ - Usr_FreeUsrsList (&Gbl.Usrs.LstAdms); + /***** Free memory for administrators list *****/ + Usr_FreeUsrsList (Rol_DEG_ADM); } /*****************************************************************************/ @@ -6322,15 +6307,15 @@ void Usr_SeeGuests (void) /***** Get and order list of students in current scope *****/ Usr_GetGstsLst (Gbl.Scope.Current); - if (Usr_GetIfShowBigList (Gbl.Usrs.LstGsts.NumUsrs)) + if (Usr_GetIfShowBigList (Gbl.Usrs.LstUsrs[Rol__GUEST_].NumUsrs)) { /***** Get list of selected users *****/ Usr_GetListsSelectedUsrs (); /***** Start frame *****/ Lay_StartRoundFrame (NULL,Txt_ROLES_PLURAL_Abc[Rol__GUEST_][Usr_SEX_UNKNOWN], - (Gbl.Usrs.Me.ListType == Usr_CLASS_PHOTO) ? (Gbl.Usrs.LstGsts.NumUsrs ? Usr_PutIconToPrintGsts : - NULL) : + (Gbl.Usrs.Me.ListType == Usr_CLASS_PHOTO) ? (Gbl.Usrs.LstUsrs[Rol__GUEST_].NumUsrs ? Usr_PutIconToPrintGsts : + NULL) : Usr_PutIconToShowGstsAllData); /***** Form to select range of guests *****/ @@ -6354,7 +6339,7 @@ void Usr_SeeGuests (void) break; } - if (Gbl.Usrs.LstGsts.NumUsrs) + if (Gbl.Usrs.LstUsrs[Rol__GUEST_].NumUsrs) { /***** Form to select type of list of users *****/ Usr_ShowFormsToSelectUsrListType (ActLstGst); @@ -6406,8 +6391,8 @@ void Usr_SeeGuests (void) Lay_EndRoundFrame (); } - /***** Free memory for students list *****/ - Usr_FreeUsrsList (&Gbl.Usrs.LstGsts); + /***** Free memory for guests list *****/ + Usr_FreeUsrsList (Rol__GUEST_); } /*****************************************************************************/ @@ -6471,16 +6456,16 @@ void Usr_SeeStudents (void) Grp_ShowFormToSelectSeveralGroups (ActLstStd); /***** Get and order list of students *****/ - Usr_GetListUsrs (&Gbl.Usrs.LstStds,Rol_STUDENT,Gbl.Scope.Current); + Usr_GetListUsrs (Rol_STUDENT,Gbl.Scope.Current); - if (Usr_GetIfShowBigList (Gbl.Usrs.LstStds.NumUsrs)) + if (Usr_GetIfShowBigList (Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs)) { /***** Get list of selected users *****/ Usr_GetListsSelectedUsrs (); /***** Start frame *****/ Lay_StartRoundFrame (NULL,Txt_ROLES_PLURAL_Abc[Rol_STUDENT][Usr_SEX_UNKNOWN], - (Gbl.Usrs.Me.ListType == Usr_CLASS_PHOTO) ? (Gbl.Usrs.LstStds.NumUsrs ? Usr_PutIconToPrintStds : + (Gbl.Usrs.Me.ListType == Usr_CLASS_PHOTO) ? (Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs ? Usr_PutIconToPrintStds : NULL) : ((Gbl.Usrs.Me.LoggedRole >= Rol_TEACHER) ? Usr_PutIconToShowStdsAllData : NULL)); @@ -6505,7 +6490,7 @@ void Usr_SeeStudents (void) break; } - if (Gbl.Usrs.LstStds.NumUsrs) + if (Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs) { /***** Form to select type of list of users *****/ Usr_ShowFormsToSelectUsrListType (ActLstStd); @@ -6579,7 +6564,7 @@ void Usr_SeeStudents (void) } /***** Free memory for students list *****/ - Usr_FreeUsrsList (&Gbl.Usrs.LstStds); + Usr_FreeUsrsList (Rol_STUDENT); /***** Free memory for list of selected groups *****/ Grp_FreeListCodSelectedGrps (); @@ -6631,13 +6616,13 @@ void Usr_SeeTeachers (void) ICanViewRecords = (Gbl.Scope.Current == Sco_SCOPE_CRS); /***** Get and order list of teachers *****/ - Usr_GetListUsrs (&Gbl.Usrs.LstTchs,Rol_TEACHER,Gbl.Scope.Current); + Usr_GetListUsrs (Rol_TEACHER,Gbl.Scope.Current); - if (Usr_GetIfShowBigList (Gbl.Usrs.LstTchs.NumUsrs)) + if (Usr_GetIfShowBigList (Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs)) { /***** Start frame *****/ Lay_StartRoundFrame (NULL,Txt_ROLES_PLURAL_Abc[Rol_TEACHER][Usr_SEX_UNKNOWN], - (Gbl.Usrs.Me.ListType == Usr_CLASS_PHOTO) ? (Gbl.Usrs.LstTchs.NumUsrs ? Usr_PutIconToPrintTchs : + (Gbl.Usrs.Me.ListType == Usr_CLASS_PHOTO) ? (Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs ? Usr_PutIconToPrintTchs : NULL) : ((Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM) ? Usr_PutIconToShowTchsAllData : NULL)); @@ -6654,7 +6639,7 @@ void Usr_SeeTeachers (void) Act_FormEnd (); fprintf (Gbl.F.Out,"
"); - if (Gbl.Usrs.LstTchs.NumUsrs) + if (Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs) { /***** Form to select type of list of users *****/ Usr_ShowFormsToSelectUsrListType (ActLstTch); @@ -6717,7 +6702,7 @@ void Usr_SeeTeachers (void) } /***** Free memory for teachers list *****/ - Usr_FreeUsrsList (&Gbl.Usrs.LstTchs); + Usr_FreeUsrsList (Rol_TEACHER); } /*****************************************************************************/ @@ -6828,7 +6813,7 @@ void Usr_SeeGstClassPhotoPrn (void) /***** Get and order list of students *****/ Usr_GetGstsLst (Gbl.Scope.Current); - if (Gbl.Usrs.LstGsts.NumUsrs) + if (Gbl.Usrs.LstUsrs[Rol__GUEST_].NumUsrs) { /***** Draw the guests' class photo *****/ Lay_StartRoundFrame (NULL,NULL,NULL); @@ -6845,8 +6830,8 @@ void Usr_SeeGstClassPhotoPrn (void) else Usr_ShowWarningNoUsersFound (Rol__GUEST_); - /***** Free memory for students list *****/ - Usr_FreeUsrsList (&Gbl.Usrs.LstGsts); + /***** Free memory for guests list *****/ + Usr_FreeUsrsList (Rol__GUEST_); } /*****************************************************************************/ @@ -6868,9 +6853,9 @@ void Usr_SeeStdClassPhotoPrn (void) Grp_GetParCodsSeveralGrpsToShowUsrs (); /***** Get and order list of students *****/ - Usr_GetListUsrs (&Gbl.Usrs.LstStds,Rol_STUDENT,Gbl.Scope.Current); + Usr_GetListUsrs (Rol_STUDENT,Gbl.Scope.Current); - if (Gbl.Usrs.LstStds.NumUsrs) + if (Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs) { /***** Draw the students' class photo *****/ Lay_StartRoundFrame (NULL,NULL,NULL); @@ -6894,7 +6879,7 @@ void Usr_SeeStdClassPhotoPrn (void) Usr_ShowWarningNoUsersFound (Rol_STUDENT); /***** Free memory for students list *****/ - Usr_FreeUsrsList (&Gbl.Usrs.LstStds); + Usr_FreeUsrsList (Rol_STUDENT); /***** Free memory for list of selected groups *****/ Grp_FreeListCodSelectedGrps (); @@ -6924,9 +6909,9 @@ void Usr_SeeTchClassPhotoPrn (void) Sco_GetScope (); /***** Get and order list of teachers *****/ - Usr_GetListUsrs (&Gbl.Usrs.LstTchs,Rol_TEACHER,Gbl.Scope.Current); + Usr_GetListUsrs (Rol_TEACHER,Gbl.Scope.Current); - if (Gbl.Usrs.LstTchs.NumUsrs) + if (Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs) { /***** Draw the teachers' class photo *****/ Lay_StartRoundFrame (NULL,NULL,NULL); @@ -6950,7 +6935,7 @@ void Usr_SeeTchClassPhotoPrn (void) Lay_ShowAlert (Lay_INFO,Txt_No_users_found[Rol_TEACHER]); /***** Free memory for teachers list *****/ - Usr_FreeUsrsList (&Gbl.Usrs.LstTchs); + Usr_FreeUsrsList (Rol_TEACHER); } /*****************************************************************************/ @@ -6960,7 +6945,6 @@ void Usr_SeeTchClassPhotoPrn (void) static void Usr_DrawClassPhoto (Usr_ClassPhotoType_t ClassPhotoType, Rol_Role_t RoleInClassPhoto) { - struct ListUsers *LstUsrs; unsigned NumUsr; bool TRIsOpen = false; bool PutCheckBoxToSelectUsr = (ClassPhotoType == Usr_CLASS_PHOTO_SEL || @@ -6978,20 +6962,6 @@ static void Usr_DrawClassPhoto (Usr_ClassPhotoType_t ClassPhotoType, char PhotoURL[PATH_MAX+1]; struct UsrData UsrDat; - /***** Show guests, students or teachers? *****/ - switch (RoleInClassPhoto) - { - case Rol_STUDENT: - LstUsrs = &Gbl.Usrs.LstStds; - break; - case Rol_TEACHER: - LstUsrs = &Gbl.Usrs.LstTchs; - break; - default: - LstUsrs = &Gbl.Usrs.LstGsts; - break; - } - /***** Set width and height of photos *****/ switch (ClassPhotoType) { @@ -7015,7 +6985,7 @@ static void Usr_DrawClassPhoto (Usr_ClassPhotoType_t ClassPhotoType, /***** Loop for showing users photos, names and place of birth *****/ for (NumUsr = 0; - NumUsr < LstUsrs->NumUsrs; ) + NumUsr < Gbl.Usrs.LstUsrs[RoleInClassPhoto].NumUsrs; ) { if ((NumUsr % Gbl.Usrs.ClassPhoto.Cols) == 0) { @@ -7023,10 +6993,10 @@ static void Usr_DrawClassPhoto (Usr_ClassPhotoType_t ClassPhotoType, TRIsOpen = true; } - UsrDat.UsrCod = LstUsrs->Lst[NumUsr].UsrCod; + UsrDat.UsrCod = Gbl.Usrs.LstUsrs[RoleInClassPhoto].Lst[NumUsr].UsrCod; if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // If user's data exist... { - UsrDat.Accepted = LstUsrs->Lst[NumUsr].Accepted; + UsrDat.Accepted = Gbl.Usrs.LstUsrs[RoleInClassPhoto].Lst[NumUsr].Accepted; ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat.UsrCod); ShowData = (ItsMe || UsrDat.Accepted || diff --git a/swad_user.h b/swad_user.h index 9fb589b3..e317461e 100644 --- a/swad_user.h +++ b/swad_user.h @@ -181,7 +181,7 @@ struct UsrInList bool Remove; // A boolean associated with each user that indicates if it must be removed }; -struct ListUsers +struct ListUsrs { struct UsrInList *Lst; // List of users unsigned NumUsrs; // Number of users in the list @@ -303,11 +303,11 @@ unsigned Usr_GetNumUsrsWhoClaimToBelongToIns (long InsCod); unsigned Usr_GetNumUsrsWhoClaimToBelongToCtr (long CtrCod); unsigned Usr_GetNumberOfTeachersInCentre (long CtrCod); -void Usr_GetListUsrs (struct ListUsers *LstUsrs,Rol_Role_t Role,Sco_Scope_t Scope); -void Usr_SearchListUsrs (struct ListUsers *LstUsrs,Rol_Role_t Role,const char *UsrQuery); +void Usr_GetListUsrs (Rol_Role_t Role,Sco_Scope_t Scope); +void Usr_SearchListUsrs (Rol_Role_t Role,const char *UsrQuery); void Usr_GetUnorderedStdsCodesInDeg (long DegCod); -void Usr_FreeUsrsList (struct ListUsers *LstUsrs); +void Usr_FreeUsrsList (Rol_Role_t Role); bool Usr_GetIfShowBigList (unsigned NumUsrs); void Usr_PutHiddenParUsrCodAll (Act_Action_t NextAction,const char *ListUsrCods); void Usr_GetListsSelectedUsrs (void);