From 86f39764956ae7d58d3006f51d6ee293934637cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Sun, 4 Jun 2017 14:22:04 +0200 Subject: [PATCH] Version 16.233 --- sql/cambios.sql | 2 +- swad_ID.c | 12 +-- swad_account.c | 4 +- swad_action.c | 8 +- swad_announcement.c | 6 +- swad_assignment.c | 12 +-- swad_attendance.c | 16 +-- swad_banner.c | 4 +- swad_calendar.c | 2 +- swad_centre.c | 24 ++--- swad_changelog.h | 10 +- swad_chat.c | 10 +- swad_connected.c | 6 +- swad_country.c | 4 +- swad_course.c | 26 ++--- swad_degree.c | 22 ++--- swad_degree_type.c | 2 +- swad_department.c | 2 +- swad_duplicate.c | 2 +- swad_enrolment.c | 130 ++++++++++++------------ swad_exam.c | 8 +- swad_file_browser.c | 86 ++++++++-------- swad_forum.c | 58 +++++------ swad_global.c | 12 +-- swad_global.h | 15 +-- swad_group.c | 28 +++--- swad_help.c | 6 +- swad_holiday.c | 4 +- swad_info.c | 20 ++-- swad_institution.c | 22 ++--- swad_layout.c | 2 +- swad_link.c | 4 +- swad_mail.c | 22 ++--- swad_mark.c | 2 +- swad_message.c | 8 +- swad_notice.c | 4 +- swad_password.c | 4 +- swad_photo.c | 16 +-- swad_place.c | 2 +- swad_plugin.c | 4 +- swad_privacy.c | 2 +- swad_profile.c | 2 +- swad_record.c | 108 ++++++++++---------- swad_role.c | 147 ++++++++++++++++++++++++++-- swad_role.h | 2 + swad_scope.c | 4 +- swad_search.c | 10 +- swad_session.c | 12 +-- swad_statistic.c | 24 ++--- swad_string.c | 2 +- swad_survey.c | 30 +++--- swad_syllabus.c | 4 +- swad_tab.c | 2 +- swad_test.c | 26 ++--- swad_timetable.c | 4 +- swad_user.c | 233 +++++++++++--------------------------------- swad_user.h | 11 ++- swad_web_service.c | 148 ++++++++++++++-------------- 58 files changed, 719 insertions(+), 683 deletions(-) diff --git a/sql/cambios.sql b/sql/cambios.sql index 399928c1..37c0b272 100644 --- a/sql/cambios.sql +++ b/sql/cambios.sql @@ -11926,7 +11926,7 @@ BEGIN DECLARE LogCodStart INT; DECLARE LogCodEnd INT; SET LogCodStart = 0; - WHILE LogCodStart <= 440000000 DO + WHILE LogCodStart <= 450000000 DO SET LogCodEnd = LogCodStart + 99999; UPDATE log_full SET Role = Role + (Role >= 4) WHERE LogCod BETWEEN LogCodStart AND LogCodEnd; SET LogCodStart = LogCodEnd + 1; diff --git a/swad_ID.c b/swad_ID.c index 0fb1cce7..f49acfa1 100644 --- a/swad_ID.c +++ b/swad_ID.c @@ -404,7 +404,7 @@ bool ID_ICanSeeOtherUsrIDs (const struct UsrData *UsrDat) return true; /***** Check if I have permission to see another user's IDs *****/ - switch (Gbl.Usrs.Me.LoggedRole) + switch (Gbl.Usrs.Me.Roles.LoggedRole) { case Rol_NET: case Rol_TCH: @@ -413,7 +413,7 @@ bool ID_ICanSeeOtherUsrIDs (const struct UsrData *UsrDat) return true; /* Check 2: I can see the IDs of confirmed students */ - if (UsrDat->RoleInCurrentCrsDB == Rol_STD && // A student + if (UsrDat->Roles.InCurrentCrsDB == Rol_STD && // A student UsrDat->Accepted) // who accepted registration return true; @@ -452,7 +452,7 @@ static void ID_PutLinkToConfirmID (struct UsrData *UsrDat,unsigned NumID, Act_Action_t NextAction; /***** Start form *****/ - switch (UsrDat->RoleInCurrentCrsDB) + switch (UsrDat->Roles.InCurrentCrsDB) { case Rol_STD: NextAction = ActCnfID_Std; @@ -512,7 +512,7 @@ void ID_PutLinkToChangeUsrIDs (void) NULL); else // Not me { - switch (Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB) + switch (Gbl.Usrs.Other.UsrDat.Roles.InCurrentCrsDB) { case Rol_STD: NextAction = ActFrmIDsStd; @@ -614,7 +614,7 @@ void ID_ShowFormChangeUsrID (const struct UsrData *UsrDat,bool ItsMe) Act_FormStart (ActRemID_Me); else { - switch (UsrDat->RoleInCurrentCrsDB) + switch (UsrDat->Roles.InCurrentCrsDB) { case Rol_STD: NextAction = ActRemID_Std; @@ -679,7 +679,7 @@ void ID_ShowFormChangeUsrID (const struct UsrData *UsrDat,bool ItsMe) Act_FormStart (ActNewIDMe); else { - switch (UsrDat->RoleInCurrentCrsDB) + switch (UsrDat->Roles.InCurrentCrsDB) { case Rol_STD: NextAction = ActNewID_Std; diff --git a/swad_account.c b/swad_account.c index 1e4b4946..d3878d5e 100644 --- a/swad_account.c +++ b/swad_account.c @@ -883,10 +883,10 @@ bool Acc_CheckIfICanEliminateAccount (long UsrCod) // A user logged as superuser can eliminate any user except her/him // Other users only can eliminate themselves return (( ItsMe && // It's me - (Gbl.Usrs.Me.AvailableRoles & (1 << Rol_SYS_ADM)) == 0) // I can not be system admin + (Gbl.Usrs.Me.Roles.Available & (1 << Rol_SYS_ADM)) == 0) // I can not be system admin || (!ItsMe && // It's not me - Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)); // I am logged as system admin + Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM)); // I am logged as system admin } /*****************************************************************************/ diff --git a/swad_action.c b/swad_action.c index 837ea7c1..88e6b293 100644 --- a/swad_action.c +++ b/swad_action.c @@ -4696,7 +4696,7 @@ bool Act_CheckIfIHavePermissionToExecuteAction (Act_Action_t Action) else Permission = Act_Actions[Action].PermissionSys; - return Permission & (1 << Gbl.Usrs.Me.LoggedRole); + return Permission & (1 << Gbl.Usrs.Me.Roles.LoggedRole); } /*****************************************************************************/ @@ -5101,7 +5101,7 @@ void Act_AdjustCurrentAction (void) /***** Check if I am a teacher *****/ Rol_GetRolesInAllCrssIfNotYetGot (&Gbl.Usrs.Me.UsrDat); - IAmATeacher = (Gbl.Usrs.Me.UsrDat.Roles & ((1 << Rol_NET) | // I am a non-editing teacher... + IAmATeacher = (Gbl.Usrs.Me.UsrDat.Roles.InCrss & ((1 << Rol_NET) | // I am a non-editing teacher... (1 << Rol_TCH))); // ...or a teacher in any course /***** If I haven't filled my institution, @@ -5144,7 +5144,7 @@ void Act_AdjustCurrentAction (void) the only action possible is show a form to ask for enrolment *****/ if (!Gbl.Usrs.Me.UsrDat.Accepted && Gbl.Action.Act != ActLogOut) { - switch (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB) + switch (Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrsDB) { case Rol_STD: Gbl.Action.Act = ActReqAccEnrStd; @@ -5163,7 +5163,7 @@ void Act_AdjustCurrentAction (void) } /***** Depending on the role I am logged... *****/ - switch (Gbl.Usrs.Me.LoggedRole) + switch (Gbl.Usrs.Me.Roles.LoggedRole) { case Rol_STD: switch (Gbl.Action.Act) diff --git a/swad_announcement.c b/swad_announcement.c index b571e37e..06f65475 100644 --- a/swad_announcement.c +++ b/swad_announcement.c @@ -90,7 +90,7 @@ void Ann_ShowAllAnnouncements (void) char Content[Cns_MAX_BYTES_TEXT + 1]; unsigned UnsignedNum; Ann_Status_t Status; - bool ICanEdit = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); + bool ICanEdit = (Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM); /***** Get announcements from database *****/ if (ICanEdit) @@ -106,7 +106,7 @@ void Ann_ShowAllAnnouncements (void) " FROM announcements" " WHERE (Roles&%u)<>0 " " ORDER BY AnnCod DESC", - (unsigned) Gbl.Usrs.Me.UsrDat.Roles); // All my roles in different courses + (unsigned) Gbl.Usrs.Me.UsrDat.Roles.InCrss); // All my roles in different courses } else // No user logged /* Select only active announcements for unknown users */ @@ -223,7 +223,7 @@ void Ann_ShowMyAnnouncementsNotMarkedAsSeen (void) " (SELECT AnnCod FROM ann_seen WHERE UsrCod=%ld)" " ORDER BY AnnCod DESC", // Newest first (unsigned) Ann_ACTIVE_ANNOUNCEMENT, - (unsigned) Gbl.Usrs.Me.UsrDat.Roles, // All my roles in different courses + (unsigned) Gbl.Usrs.Me.UsrDat.Roles.InCrss, // All my roles in different courses Gbl.Usrs.Me.UsrDat.UsrCod); NumAnnouncements = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get announcements"); diff --git a/swad_assignment.c b/swad_assignment.c index f2d7f61e..f02d0a8b 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -244,8 +244,8 @@ static void Asg_PutHeadForSeeing (bool PrintView) static bool Asg_CheckIfICanCreateAssignments (void) { - return (bool) (Gbl.Usrs.Me.LoggedRole == Rol_TCH || - Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); + return (bool) (Gbl.Usrs.Me.Roles.LoggedRole == Rol_TCH || + Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM); } /*****************************************************************************/ @@ -511,7 +511,7 @@ static void Asg_WriteAssignmentFolder (struct Assignment *Asg,bool PrintView) bool ICanSendFiles = !Asg->Hidden && // It's visible (not hidden) Asg->Open && // It's open (inside dates) Asg->IBelongToCrsOrGrps && // I belong to course or groups - Gbl.Usrs.Me.LoggedRole == Rol_STD; // I am a student + Gbl.Usrs.Me.Roles.LoggedRole == Rol_STD; // I am a student /***** Folder icon *****/ if (!PrintView && // Not print view @@ -575,7 +575,7 @@ static void Asg_PutFormsToRemEditOneAsg (long AsgCod,bool Hidden) { Gbl.Asgs.AsgCodToEdit = AsgCod; // Used as parameter in contextual links - switch (Gbl.Usrs.Me.LoggedRole) + switch (Gbl.Usrs.Me.Roles.LoggedRole) { case Rol_TCH: case Rol_SYS_ADM: @@ -632,7 +632,7 @@ void Asg_GetListAssignments (void) Asg_FreeListAssignments (); /***** Get list of assignments from database *****/ - switch (Gbl.Usrs.Me.LoggedRole) + switch (Gbl.Usrs.Me.Roles.LoggedRole) { case Rol_TCH: case Rol_SYS_ADM: @@ -1717,7 +1717,7 @@ static bool Asg_CheckIfIBelongToCrsOrGrpsThisAssignment (long AsgCod) { char Query[512]; - switch (Gbl.Usrs.Me.LoggedRole) + switch (Gbl.Usrs.Me.Roles.LoggedRole) { case Rol_STD: case Rol_NET: diff --git a/swad_attendance.c b/swad_attendance.c index 34e6f392..3102d40b 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -163,7 +163,7 @@ void Att_SeeAttEvents (void) /* Put link to show list of attendance */ if (Gbl.AttEvents.Num) - switch (Gbl.Usrs.Me.LoggedRole) + switch (Gbl.Usrs.Me.Roles.LoggedRole) { case Rol_STD: Att_PutFormToListMyAttendance (); @@ -206,8 +206,8 @@ static void Att_ShowAllAttEvents (void) Dat_StartEndTime_t Order; struct Pagination Pagination; unsigned NumAttEvent; - bool ICanEdit = (Gbl.Usrs.Me.LoggedRole == Rol_TCH || - Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); + bool ICanEdit = (Gbl.Usrs.Me.Roles.LoggedRole == Rol_TCH || + Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM); /***** Compute variables related to pagination *****/ Pagination.NumItems = Gbl.AttEvents.Num; @@ -375,7 +375,7 @@ static void Att_ShowOneAttEvent (struct AttendanceEvent *Att,bool ShowOnlyThisAt if (!ShowOnlyThisAttEventComplete) fprintf (Gbl.F.Out," COLOR%u",Gbl.RowEvenOdd); fprintf (Gbl.F.Out,"\">"); - switch (Gbl.Usrs.Me.LoggedRole) + switch (Gbl.Usrs.Me.Roles.LoggedRole) { case Rol_TCH: case Rol_SYS_ADM: @@ -604,7 +604,7 @@ static void Att_GetListAttEvents (Att_OrderTime_t Order) Att_FreeListAttEvents (); /***** Get list of attendance events from database *****/ - switch (Gbl.Usrs.Me.LoggedRole) + switch (Gbl.Usrs.Me.Roles.LoggedRole) { case Rol_TCH: case Rol_SYS_ADM: @@ -1826,7 +1826,7 @@ void Att_SeeOneAttEvent (void) Att_ShowOneAttEvent (&Att,true); Lay_EndRoundFrameTable (); - switch (Gbl.Usrs.Me.LoggedRole) + switch (Gbl.Usrs.Me.Roles.LoggedRole) { case Rol_STD: Att_ListAttOnlyMeAsStudent (&Att); @@ -2031,7 +2031,7 @@ static void Att_WriteRowStdToCallTheRoll (unsigned NumStd, bool ICanEditTchComment; /***** Set who can edit *****/ - switch (Gbl.Usrs.Me.LoggedRole) + switch (Gbl.Usrs.Me.Roles.LoggedRole) { case Rol_STD: // A student can see only her/his attendance @@ -3532,7 +3532,7 @@ static void Att_ListAttEventsForAStd (unsigned NumStd,struct UsrData *UsrDat) Present = Att_CheckIfUsrIsPresentInAttEventAndGetComments (Gbl.AttEvents.Lst[NumAttEvent].AttCod,UsrDat->UsrCod,CommentStd,CommentTch); ShowCommentStd = CommentStd[0]; ShowCommentTch = CommentTch[0] && - (Gbl.Usrs.Me.LoggedRole == Rol_TCH || + (Gbl.Usrs.Me.Roles.LoggedRole == Rol_TCH || Gbl.AttEvents.Lst[NumAttEvent].CommentTchVisible); /***** Write a row for this event *****/ diff --git a/swad_banner.c b/swad_banner.c index 02cae75c..e3d66986 100644 --- a/swad_banner.c +++ b/swad_banner.c @@ -125,7 +125,7 @@ void Ban_SeeBanners (void) Ale_ShowAlert (Ale_INFO,Txt_No_banners); /***** Button to create banner *****/ - if (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM) + if (Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM) { Act_FormStart (ActEdiBan); Lay_PutConfirmButton (Txt_New_banner); @@ -179,7 +179,7 @@ static void Ban_WriteListOfBanners (void) static void Ban_PutFormToEditBanners (void) { - if (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM) + if (Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM) Lay_PutContextualIconToEdit (ActEdiBan,NULL); } diff --git a/swad_calendar.c b/swad_calendar.c index 1b7a3685..898d45ec 100644 --- a/swad_calendar.c +++ b/swad_calendar.c @@ -378,7 +378,7 @@ static void Cal_PutIconToPrintCalendarIns (void) /***** View holidays *****/ if (Gbl.Hlds.Num || // There are holidays - Gbl.Usrs.Me.LoggedRole >= Rol_INS_ADM) // Institution admin or system admin + Gbl.Usrs.Me.Roles.LoggedRole >= Rol_INS_ADM) // Institution admin or system admin Lay_PutContextualLink (ActSeeHld,NULL,NULL, "holiday64x64.png", Txt_Holidays,NULL, diff --git a/swad_centre.c b/swad_centre.c index a26ab77d..7280dae5 100644 --- a/swad_centre.c +++ b/swad_centre.c @@ -137,7 +137,7 @@ void Ctr_SeeCtrWithPendingDegs (void) const char *BgColor; /***** Get centres with pending degrees *****/ - switch (Gbl.Usrs.Me.LoggedRole) + switch (Gbl.Usrs.Me.Roles.LoggedRole) { case Rol_CTR_ADM: sprintf (Query,"SELECT degrees.CtrCod,COUNT(*)" @@ -355,7 +355,7 @@ static void Ctr_Configuration (bool PrintView) /* Photo attribution */ if (!PrintView && - Gbl.Usrs.Me.LoggedRole >= Rol_CTR_ADM) + Gbl.Usrs.Me.Roles.LoggedRole >= Rol_CTR_ADM) // Only centre admins, institution admins and centre admins // have permission to edit photo attribution { @@ -394,7 +394,7 @@ static void Ctr_Configuration (bool PrintView) Txt_Institution); if (!PrintView && - Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM) + Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM) // Only system admins can move a centre to another institution { /* Get list of institutions of the current country */ @@ -435,7 +435,7 @@ static void Ctr_Configuration (bool PrintView) The_ClassForm[Gbl.Prefs.Theme], Txt_Centre); if (!PrintView && - Gbl.Usrs.Me.LoggedRole >= Rol_INS_ADM) + Gbl.Usrs.Me.Roles.LoggedRole >= Rol_INS_ADM) // Only institution admins and system admins can edit centre full name { /* Form to change centre full name */ @@ -464,7 +464,7 @@ static void Ctr_Configuration (bool PrintView) The_ClassForm[Gbl.Prefs.Theme], Txt_Short_name); if (!PrintView && - Gbl.Usrs.Me.LoggedRole >= Rol_INS_ADM) + Gbl.Usrs.Me.Roles.LoggedRole >= Rol_INS_ADM) // Only institution admins and system admins can edit centre short name { /* Form to change centre short name */ @@ -493,7 +493,7 @@ static void Ctr_Configuration (bool PrintView) The_ClassForm[Gbl.Prefs.Theme], Txt_Web); if (!PrintView && - Gbl.Usrs.Me.LoggedRole >= Rol_CTR_ADM) + Gbl.Usrs.Me.Roles.LoggedRole >= Rol_CTR_ADM) // Only centre admins, institution admins and system admins // can change centre WWW { @@ -642,7 +642,7 @@ static void Ctr_PutIconsToPrintAndUpload (void) /***** Link to print info about centre *****/ Lay_PutContextualIconToPrint (ActPrnCtrInf,NULL); - if (Gbl.Usrs.Me.LoggedRole >= Rol_CTR_ADM) + if (Gbl.Usrs.Me.Roles.LoggedRole >= Rol_CTR_ADM) // Only centre admins, institution admins and system admins // have permission to upload logo and photo of the centre { @@ -783,7 +783,7 @@ static void Ctr_ListCentres (void) static bool Ctr_CheckIfICanCreateCentres (void) { - return (bool) (Gbl.Usrs.Me.LoggedRole >= Rol_GST); + return (bool) (Gbl.Usrs.Me.Roles.LoggedRole >= Rol_GST); } /*****************************************************************************/ @@ -1569,7 +1569,7 @@ static void Ctr_ListCentresForEdition (void) /* Centre status */ StatusTxt = Ctr_GetStatusTxtFromStatusBits (Ctr->Status); fprintf (Gbl.F.Out,""); - if (Gbl.Usrs.Me.LoggedRole >= Rol_INS_ADM && + if (Gbl.Usrs.Me.Roles.LoggedRole >= Rol_INS_ADM && StatusTxt == Ctr_STATUS_PENDING) { Act_FormStart (ActChgCtrSta); @@ -1605,7 +1605,7 @@ static void Ctr_ListCentresForEdition (void) static bool Ctr_CheckIfICanEditACentre (struct Centre *Ctr) { - return (bool) (Gbl.Usrs.Me.LoggedRole >= Rol_INS_ADM || // I am an institution administrator or higher + return (bool) (Gbl.Usrs.Me.Roles.LoggedRole >= Rol_INS_ADM || // I am an institution administrator or higher ((Ctr->Status & Ctr_STATUS_BIT_PENDING) != 0 && // Centre is not yet activated Gbl.Usrs.Me.UsrDat.UsrCod == Ctr->RequesterUsrCod)); // I am the requester } @@ -2402,9 +2402,9 @@ static void Ctr_PutFormToCreateCentre (void) unsigned NumPlc; /***** Start form *****/ - if (Gbl.Usrs.Me.LoggedRole >= Rol_INS_ADM) + if (Gbl.Usrs.Me.Roles.LoggedRole >= Rol_INS_ADM) Act_FormStart (ActNewCtr); - else if (Gbl.Usrs.Me.MaxRole >= Rol_GST) + else if (Gbl.Usrs.Me.Roles.Max >= Rol_GST) Act_FormStart (ActReqCtr); else Lay_ShowErrorAndExit ("You can not edit centres."); diff --git a/swad_changelog.h b/swad_changelog.h index b9d8ca27..5b94f83c 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -230,17 +230,25 @@ // TODO: Link names are too short ==> add more length, for example: "A guide to building and understanding the physics of Water Rockets" // TODO: Fix bug: Error when a link end in a dot. Example: "A guide to building..." --> "A guide to building._..url" (two dots) +// TODO: Fix bug: soy profesor no editor y superusuario. Si me modifico en la asignatura, me borro sin querer de los grupos, ya que no me deja elegir grupos. +// TODO: Fix bug: no llegan notificaciones de inscripción como profesor no editor. +// TODO: Fix bug: un profesor no editor no debería poder cambiarse a profesor. + +// TODO: When a user (student) is removed from a course, remove him in a priori function (check that he can not view Students option) +// TODO: When the role of a user is modified in a course, modify him in a priori function (check that he can not view Students option) + /*****************************************************************************/ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.232.8 (2017-06-03)" +#define Log_PLATFORM_VERSION "SWAD 16.233 (2017-06-03)" #define CSS_FILE "swad16.226.css" #define JS_FILE "swad16.206.3.js" // Number of lines (includes comments but not blank lines) has been got with the following command: // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1 /* + Version 16.233: Jun 04, 2017 Code refactoring related with roles. (221175 lines) Version 16.232.8: Jun 03, 2017 Fix bug (an URL like https://openswad.org/es?a gived Internal Server Error). (221147 lines) Version 16.232.7: Jun 03, 2017 Changed contextual links in institutional links and banners. (221148 lines) Copy the following icon to icon public directory: diff --git a/swad_chat.c b/swad_chat.c index 17c1c4d9..26760b14 100644 --- a/swad_chat.c +++ b/swad_chat.c @@ -89,7 +89,7 @@ void Cht_ShowChatRooms (void) Ale_ShowAlert (Ale_WARNING,Txt_Unfortunately_Firefox_and_Chrome_no_longer_allow_Java_to_run_); - if (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM) + if (Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM) Cht_ShowListOfChatRoomsWithUsrs (); } @@ -152,7 +152,7 @@ void Cht_ShowListOfAvailableChatRooms (void) Cht_WriteLinkToChat2 ("GBL_USR",ThisRoomFullName); IsLastItemInLevel[1] = !Gbl.Usrs.Me.MyDegs.Num; - switch (Gbl.Usrs.Me.LoggedRole) + switch (Gbl.Usrs.Me.Roles.LoggedRole) { case Rol_STD: sprintf (ThisRoomFullName,"%s (%s)", @@ -463,7 +463,7 @@ void Cht_OpenChatWindow (void) Cht_MAX_BYTES_ROOM_FULL_NAMES); } - if (Gbl.Usrs.Me.LoggedRole == Rol_STD) + if (Gbl.Usrs.Me.Roles.LoggedRole == Rol_STD) if (strcmp (RoomCode,"GBL_STD")) { Str_Concat (ListRoomCodes,"|#GBL_STD", @@ -479,8 +479,8 @@ void Cht_OpenChatWindow (void) Cht_MAX_BYTES_ROOM_FULL_NAMES); } - if (Gbl.Usrs.Me.LoggedRole == Rol_NET || - Gbl.Usrs.Me.LoggedRole == Rol_TCH) + if (Gbl.Usrs.Me.Roles.LoggedRole == Rol_NET || + Gbl.Usrs.Me.Roles.LoggedRole == Rol_TCH) if (strcmp (RoomCode,"GBL_TCH")) { Str_Concat (ListRoomCodes,"|#GBL_TCH", diff --git a/swad_connected.c b/swad_connected.c index 13662a31..f3a8b8bb 100644 --- a/swad_connected.c +++ b/swad_connected.c @@ -426,7 +426,7 @@ void Con_ComputeConnectedUsrsBelongingToCurrentCrs (void) if ((Gbl.Prefs.SideCols & Lay_SHOW_RIGHT_COLUMN) && // Right column visible Gbl.CurrentCrs.Crs.CrsCod > 0 && // There is a course selected (Gbl.Usrs.Me.IBelongToCurrentCrs || // I can view users - Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)) + Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM)) { Gbl.Usrs.Connected.NumUsrs = 0; Gbl.Usrs.Connected.NumUsrsToList = 0; @@ -487,7 +487,7 @@ static void Con_ShowConnectedUsrsBelongingToLocation (void) Con_ShowConnectedUsrsWithARoleBelongingToCurrentLocationOnMainZone (Rol_TCH); Con_ShowConnectedUsrsWithARoleBelongingToCurrentLocationOnMainZone (Rol_NET); Con_ShowConnectedUsrsWithARoleBelongingToCurrentLocationOnMainZone (Rol_STD); - if (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM) + if (Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM) Con_ShowConnectedUsrsWithARoleBelongingToCurrentLocationOnMainZone (Rol_GST); fprintf (Gbl.F.Out,""); @@ -640,7 +640,7 @@ void Con_UpdateMeInConnectedList (void) " VALUES" " (%ld,%u,%ld,NOW())", Gbl.Usrs.Me.UsrDat.UsrCod, - (unsigned) Gbl.Usrs.Me.LoggedRole, + (unsigned) Gbl.Usrs.Me.Roles.LoggedRole, Gbl.CurrentCrs.Crs.CrsCod); DB_QueryREPLACE (Query,"can not update list of connected users"); } diff --git a/swad_country.c b/swad_country.c index 89b8404c..b476bde2 100644 --- a/swad_country.c +++ b/swad_country.c @@ -116,7 +116,7 @@ void Cty_SeeCtyWithPendingInss (void) const char *BgColor; /***** Get countries with pending institutions *****/ - switch (Gbl.Usrs.Me.LoggedRole) + switch (Gbl.Usrs.Me.Roles.LoggedRole) { case Rol_SYS_ADM: sprintf (Query,"SELECT institutions.CtyCod,COUNT(*)" @@ -736,7 +736,7 @@ static void Cty_ListOneCountryForSeeing (struct Country *Cty,unsigned NumCty) static bool Cty_CheckIfICanEditCountries (void) { - return (bool) (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); + return (bool) (Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM); } /*****************************************************************************/ diff --git a/swad_course.c b/swad_course.c index fd2d36c3..bcfeac98 100644 --- a/swad_course.c +++ b/swad_course.c @@ -178,15 +178,15 @@ static void Crs_Configuration (bool PrintView) unsigned Year; int NumIndicatorsFromDB; struct Ind_IndicatorsCrs Indicators; - bool IsForm = (!PrintView && Gbl.Usrs.Me.LoggedRole >= Rol_TCH); + bool IsForm = (!PrintView && Gbl.Usrs.Me.Roles.LoggedRole >= Rol_TCH); bool PutLink = !PrintView && Gbl.CurrentDeg.Deg.WWW[0]; /***** Messages and links above the frame *****/ if (!PrintView) { /* Link to request enrolment in the current course */ - if (Gbl.Usrs.Me.LoggedRole == Rol_GST || - Gbl.Usrs.Me.LoggedRole == Rol_USR) + if (Gbl.Usrs.Me.Roles.LoggedRole == Rol_GST || + Gbl.Usrs.Me.Roles.LoggedRole == Rol_USR) { fprintf (Gbl.F.Out,"
"); Enr_PutLinkToRequestSignUp (); @@ -229,7 +229,7 @@ static void Crs_Configuration (bool PrintView) Txt_Degree); if (!PrintView && - Gbl.Usrs.Me.LoggedRole >= Rol_CTR_ADM) + Gbl.Usrs.Me.Roles.LoggedRole >= Rol_CTR_ADM) // Only centre admins, institution admins and system admin can move a course to another degree { /* Get list of degrees of the current centre */ @@ -270,7 +270,7 @@ static void Crs_Configuration (bool PrintView) The_ClassForm[Gbl.Prefs.Theme], Txt_Course); if (!PrintView && - Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM) + Gbl.Usrs.Me.Roles.LoggedRole >= Rol_DEG_ADM) // Only degree admins, centre admins, institution admins and system admins can edit course full name { /* Form to change course full name */ @@ -299,7 +299,7 @@ static void Crs_Configuration (bool PrintView) The_ClassForm[Gbl.Prefs.Theme], Txt_Short_name); if (!PrintView && - Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM) + Gbl.Usrs.Me.Roles.LoggedRole >= Rol_DEG_ADM) // Only degree admins, centre admins, institution admins and system admins can edit course short name { /* Form to change course short name */ @@ -1175,7 +1175,7 @@ static void Crs_ListCourses (void) static bool Crs_CheckIfICanCreateCourses (void) { - return (bool) (Gbl.Usrs.Me.LoggedRole >= Rol_GST); + return (bool) (Gbl.Usrs.Me.Roles.LoggedRole >= Rol_GST); } /*****************************************************************************/ @@ -1536,7 +1536,7 @@ static void Crs_ListCoursesOfAYearForEdition (unsigned Year) /* Course status */ StatusTxt = Crs_GetStatusTxtFromStatusBits (Crs->Status); fprintf (Gbl.F.Out,""); - if (Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM && + if (Gbl.Usrs.Me.Roles.LoggedRole >= Rol_DEG_ADM && StatusTxt == Crs_STATUS_PENDING) { Act_FormStart (ActChgCrsSta); @@ -1570,7 +1570,7 @@ static void Crs_ListCoursesOfAYearForEdition (unsigned Year) static bool Crs_CheckIfICanEdit (struct Course *Crs) { - return (bool) (Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM || // I am a degree administrator or higher + return (bool) (Gbl.Usrs.Me.Roles.LoggedRole >= Rol_DEG_ADM || // I am a degree administrator or higher ((Crs->Status & Crs_STATUS_BIT_PENDING) != 0 && // Course is not yet activated Gbl.Usrs.Me.UsrDat.UsrCod == Crs->RequesterUsrCod)); // I am the requester } @@ -1629,9 +1629,9 @@ static void Crs_PutFormToCreateCourse (void) unsigned Year; /***** Start form *****/ - if (Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM) + if (Gbl.Usrs.Me.Roles.LoggedRole >= Rol_DEG_ADM) Act_FormStart (ActNewCrs); - else if (Gbl.Usrs.Me.MaxRole >= Rol_GST) + else if (Gbl.Usrs.Me.Roles.Max >= Rol_GST) Act_FormStart (ActReqCrs); else Lay_ShowErrorAndExit ("You can not edit courses."); @@ -2784,7 +2784,7 @@ void Crs_ContEditAfterChgCrs (void) /***** Put button to request my registration in course *****/ PutButtonToRequestRegistration = false; - switch (Gbl.Usrs.Me.LoggedRole) + switch (Gbl.Usrs.Me.Roles.LoggedRole) { case Rol_GST: // I do not belong to any course PutButtonToRequestRegistration = true; @@ -3270,7 +3270,7 @@ void Crs_UpdateCrsLast (void) char Query[128]; if (Gbl.CurrentCrs.Crs.CrsCod > 0 && - Gbl.Usrs.Me.LoggedRole >= Rol_STD) + Gbl.Usrs.Me.Roles.LoggedRole >= Rol_STD) { /***** Update my last access to current course *****/ sprintf (Query,"REPLACE INTO crs_last (CrsCod,LastTime)" diff --git a/swad_degree.c b/swad_degree.c index 8398000c..16b26776 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -139,7 +139,7 @@ void Deg_SeeDegWithPendingCrss (void) const char *BgColor; /***** Get degrees with pending courses *****/ - switch (Gbl.Usrs.Me.LoggedRole) + switch (Gbl.Usrs.Me.Roles.LoggedRole) { case Rol_DEG_ADM: sprintf (Query,"SELECT courses.DegCod,COUNT(*)" @@ -329,7 +329,7 @@ static void Deg_Configuration (bool PrintView) Txt_Centre); if (!PrintView && - Gbl.Usrs.Me.LoggedRole >= Rol_INS_ADM) + Gbl.Usrs.Me.Roles.LoggedRole >= Rol_INS_ADM) // Only institution admins and system admin can move a degree to another centre { /* Get list of centres of the current institution */ @@ -370,7 +370,7 @@ static void Deg_Configuration (bool PrintView) The_ClassForm[Gbl.Prefs.Theme], Txt_Degree); if (!PrintView && - Gbl.Usrs.Me.LoggedRole >= Rol_CTR_ADM) + Gbl.Usrs.Me.Roles.LoggedRole >= Rol_CTR_ADM) // Only centre admins, institution admins and system admins // can edit degree full name { @@ -400,7 +400,7 @@ static void Deg_Configuration (bool PrintView) The_ClassForm[Gbl.Prefs.Theme], Txt_Short_name); if (!PrintView && - Gbl.Usrs.Me.LoggedRole >= Rol_CTR_ADM) + Gbl.Usrs.Me.Roles.LoggedRole >= Rol_CTR_ADM) // Only centre admins, institution admins and system admins // can edit degree short name { @@ -430,7 +430,7 @@ static void Deg_Configuration (bool PrintView) The_ClassForm[Gbl.Prefs.Theme], Txt_Web); if (!PrintView && - Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM) + Gbl.Usrs.Me.Roles.LoggedRole >= Rol_DEG_ADM) // Only degree admins, centre admins, institution admins // and system admins can change degree WWW { @@ -538,7 +538,7 @@ static void Deg_PutIconsToPrintAndUpload (void) /***** Link to print info about degree *****/ Lay_PutContextualIconToPrint (ActPrnDegInf,NULL); - if (Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM) + if (Gbl.Usrs.Me.Roles.LoggedRole >= Rol_DEG_ADM) // Only degree admins, centre admins, institution admins and system admins // have permission to upload logo of the degree /***** Link to upload logo of degree *****/ @@ -830,7 +830,7 @@ static void Deg_ListDegreesForEdition (void) /* Degree status */ StatusTxt = Deg_GetStatusTxtFromStatusBits (Deg->Status); fprintf (Gbl.F.Out,""); - if (Gbl.Usrs.Me.LoggedRole >= Rol_CTR_ADM && + if (Gbl.Usrs.Me.Roles.LoggedRole >= Rol_CTR_ADM && StatusTxt == Deg_STATUS_PENDING) { Act_FormStart (ActChgDegSta); @@ -866,7 +866,7 @@ static void Deg_ListDegreesForEdition (void) static bool Deg_CheckIfICanEditADegree (struct Degree *Deg) { - return (bool) (Gbl.Usrs.Me.LoggedRole >= Rol_CTR_ADM || // I am a centre administrator or higher + return (bool) (Gbl.Usrs.Me.Roles.LoggedRole >= Rol_CTR_ADM || // I am a centre administrator or higher ((Deg->Status & Deg_STATUS_BIT_PENDING) != 0 && // Degree is not yet activated Gbl.Usrs.Me.UsrDat.UsrCod == Deg->RequesterUsrCod)); // I am the requester } @@ -929,9 +929,9 @@ static void Deg_PutFormToCreateDegree (void) Deg = &Gbl.Degs.EditingDeg; /***** Start form *****/ - if (Gbl.Usrs.Me.LoggedRole >= Rol_CTR_ADM) + if (Gbl.Usrs.Me.Roles.LoggedRole >= Rol_CTR_ADM) Act_FormStart (ActNewDeg); - else if (Gbl.Usrs.Me.MaxRole >= Rol_GST) + else if (Gbl.Usrs.Me.Roles.Max >= Rol_GST) Act_FormStart (ActReqDeg); else Lay_ShowErrorAndExit ("You can not edit degrees."); @@ -1209,7 +1209,7 @@ static void Deg_ListDegrees (void) static bool Deg_CheckIfICanCreateDegrees (void) { - return (bool) (Gbl.Usrs.Me.LoggedRole >= Rol_GST); + return (bool) (Gbl.Usrs.Me.Roles.LoggedRole >= Rol_GST); } /*****************************************************************************/ diff --git a/swad_degree_type.c b/swad_degree_type.c index 34244cec..b2adf91b 100644 --- a/swad_degree_type.c +++ b/swad_degree_type.c @@ -416,7 +416,7 @@ static void DT_ListDegreeTypesForEdition (void) bool DT_CheckIfICanCreateDegreeTypes (void) { - return (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); + return (Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM); } /*****************************************************************************/ diff --git a/swad_department.c b/swad_department.c index 8168049e..5ccdcc9d 100644 --- a/swad_department.c +++ b/swad_department.c @@ -101,7 +101,7 @@ void Dpt_SeeDepts (void) /***** Table head *****/ Lay_StartRoundFrameTable (NULL,Txt_Departments, - Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ? Dpt_PutIconToEditDpts : + Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM ? Dpt_PutIconToEditDpts : NULL, Hlp_INSTITUTION_Departments,2); fprintf (Gbl.F.Out,""); diff --git a/swad_duplicate.c b/swad_duplicate.c index f4c33ac2..9c6d5660 100644 --- a/swad_duplicate.c +++ b/swad_duplicate.c @@ -85,7 +85,7 @@ void Dup_ReportUsrAsPossibleDuplicate (void) { /* Check if it's allowed to me to report users as possible duplicatedr */ ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod); - if (!ItsMe && Gbl.Usrs.Me.LoggedRole >= Rol_TCH) + if (!ItsMe && Gbl.Usrs.Me.Roles.LoggedRole >= Rol_TCH) { /***** Insert possible duplicate into database *****/ sprintf (Query,"REPLACE INTO usr_duplicated" diff --git a/swad_enrolment.c b/swad_enrolment.c index 72bd4b27..5b3b2bbe 100644 --- a/swad_enrolment.c +++ b/swad_enrolment.c @@ -158,7 +158,7 @@ static void Enr_EffectivelyRemAdm (struct UsrData *UsrDat,Sco_Scope_t Scope, void Enr_CheckStdsAndPutButtonToRegisterStdsInCurrentCrs (void) { /***** Put link to register students *****/ - if (Gbl.Usrs.Me.LoggedRole == Rol_TCH) // Course selected and I am logged as teacher + if (Gbl.Usrs.Me.Roles.LoggedRole == Rol_TCH) // Course selected and I am logged as teacher if (!Gbl.CurrentCrs.Crs.NumUsrs[Rol_STD]) // No students in course Usr_ShowWarningNoUsersFound (Rol_STD); } @@ -226,8 +226,8 @@ void Enr_ModifyRoleInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole) activate the sending of a notification *****/ Enr_NotifyAfterEnrolment (UsrDat,NewRole); - UsrDat->RoleInCurrentCrsDB = NewRole; - UsrDat->Roles = -1; // Force roles to be got from database + UsrDat->Roles.InCurrentCrsDB = NewRole; + UsrDat->Roles.InCrss = -1; // Force roles to be got from database Rol_GetRolesInAllCrssIfNotYetGot (UsrDat); // Get roles } @@ -274,8 +274,8 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole, Usr_LIST_WITH_PHOTOS_DEF ? 'Y' : 'N'); DB_QueryINSERT (Query,"can not register user in course"); - UsrDat->RoleInCurrentCrsDB = NewRole; - UsrDat->Roles = -1; // Force roles to be got from database + UsrDat->Roles.InCurrentCrsDB = NewRole; + UsrDat->Roles.InCrss = -1; // Force roles to be got from database Rol_GetRolesInAllCrssIfNotYetGot (UsrDat); // Get roles /***** Create notification for this user. @@ -376,12 +376,12 @@ void Enr_ReqAcceptRegisterInCrs (void) /***** Show message *****/ sprintf (Gbl.Alert.Txt,Txt_A_teacher_or_administrator_has_enroled_you_as_X_into_the_course_Y, - Txt_ROLES_SINGUL_abc[Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB][Gbl.Usrs.Me.UsrDat.Sex], + Txt_ROLES_SINGUL_abc[Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrsDB][Gbl.Usrs.Me.UsrDat.Sex], Gbl.CurrentCrs.Crs.FullName); Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); /***** Send button to accept register in the current course *****/ - switch (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB) + switch (Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrsDB) { case Rol_STD: Act_FormStart (ActAccEnrStd); @@ -399,7 +399,7 @@ void Enr_ReqAcceptRegisterInCrs (void) Act_FormEnd (); /***** Send button to refuse register in the current course *****/ - switch (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB) + switch (Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrsDB) { case Rol_STD: Act_FormStart (ActRemMe_Std); @@ -420,7 +420,7 @@ void Enr_ReqAcceptRegisterInCrs (void) Lay_EndRoundFrame (); /***** Mark possible notification as seen *****/ - switch (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB) + switch (Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrsDB) { case Rol_STD: NotifyEvent = Ntf_EVENT_ENROLMENT_STD; @@ -591,7 +591,7 @@ static void Enr_ReqAdminUsrs (Rol_Role_t Role) { extern const char *Txt_You_dont_have_permission_to_perform_this_action; - switch (Gbl.Usrs.Me.LoggedRole) + switch (Gbl.Usrs.Me.Roles.LoggedRole) { case Rol_GST: case Rol_STD: @@ -990,7 +990,7 @@ bool Enr_PutActionsRegRemOneUsr (bool ItsMe) /***** Register user in course / Modify user's data *****/ if (Gbl.CurrentCrs.Crs.CrsCod > 0 && - Gbl.Usrs.Me.LoggedRole >= Rol_TCH) + Gbl.Usrs.Me.Roles.LoggedRole >= Rol_TCH) { sprintf (Gbl.Alert.Txt,UsrBelongsToCrs ? (ItsMe ? Txt_Modify_me_in_the_course_X : Txt_Modify_user_in_the_course_X) : @@ -1023,7 +1023,7 @@ bool Enr_PutActionsRegRemOneUsr (bool ItsMe) if (Gbl.CurrentDeg.Deg.DegCod > 0) /***** Register user as administrator of degree *****/ if (!UsrIsDegAdmin && - Gbl.Usrs.Me.LoggedRole >= Rol_CTR_ADM) + Gbl.Usrs.Me.Roles.LoggedRole >= Rol_CTR_ADM) { sprintf (Gbl.Alert.Txt,Txt_Register_USER_as_an_administrator_of_the_degree_X, Gbl.CurrentDeg.Deg.ShrtName); @@ -1048,7 +1048,7 @@ bool Enr_PutActionsRegRemOneUsr (bool ItsMe) /***** Register user as administrator of centre *****/ if (!UsrIsCtrAdmin && - Gbl.Usrs.Me.LoggedRole >= Rol_INS_ADM) + Gbl.Usrs.Me.Roles.LoggedRole >= Rol_INS_ADM) { sprintf (Gbl.Alert.Txt,Txt_Register_USER_as_an_administrator_of_the_centre_X, Gbl.CurrentCtr.Ctr.ShrtName); @@ -1074,7 +1074,7 @@ bool Enr_PutActionsRegRemOneUsr (bool ItsMe) /***** Register user as administrator of institution *****/ if (!UsrIsInsAdmin && - Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM) + Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM) { sprintf (Gbl.Alert.Txt,Txt_Register_USER_as_an_administrator_of_the_institution_X, Gbl.CurrentIns.Ins.ShrtName); @@ -1099,7 +1099,7 @@ bool Enr_PutActionsRegRemOneUsr (bool ItsMe) } /***** Report user as possible duplicate *****/ - if (!ItsMe && Gbl.Usrs.Me.LoggedRole >= Rol_TCH) + if (!ItsMe && Gbl.Usrs.Me.Roles.LoggedRole >= Rol_TCH) { fprintf (Gbl.F.Out,"
  • " "
  • " "