diff --git a/swad_assignment.c b/swad_assignment.c index e48ff786..12f3affe 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -49,6 +49,7 @@ #include "swad_pagination.h" #include "swad_parameter.h" #include "swad_photo.h" +#include "swad_program_resource.h" #include "swad_role.h" #include "swad_setting.h" #include "swad_string.h" @@ -289,8 +290,7 @@ static void Asg_PutIconsListAssignments (void *Assignments) Asg_PutIconToCreateNewAsg (Assignments); /***** Link to get resource link *****/ - if (Gbl.Usrs.Me.Role.Logged == Rol_TCH || // Only if I am a teacher - Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) // or a superuser + if (PrgRsc_CheckIfICanGetLink ()) { ((struct Asg_Assignments *) Assignments)->AsgCod = -1L; Ico_PutContextualIconToGetLink (ActReqLnkAsg,NULL, @@ -450,8 +450,7 @@ void Asg_ShowOneAssignmentInBox (struct Asg_Assignments *Assignments) static void Asg_PutIconsOneAsg (void *Assignments) { /***** Put icon to get resource link *****/ - if (Gbl.Usrs.Me.Role.Logged == Rol_TCH || // Only if I am a teacher - Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) // or a superuser + if (PrgRsc_CheckIfICanGetLink ()) Ico_PutContextualIconToGetLink (ActReqLnkAsg,NULL, Asg_PutParams,Assignments); } diff --git a/swad_attendance.c b/swad_attendance.c index 1f620397..1f623a37 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -369,8 +369,7 @@ static void Att_PutIconsInListOfAttEvents (void *Events) Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EnUsrCod); /***** Put icon to get resource link *****/ - if (Gbl.Usrs.Me.Role.Logged == Rol_TCH || // Only if I am a teacher - Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) // or a superuser + if (PrgRsc_CheckIfICanGetLink ()) Ico_PutContextualIconToGetLink (ActReqLnkAtt,NULL, Att_PutParams,Events); } @@ -1520,8 +1519,7 @@ static void Att_ShowEvent (struct Att_Events *Events) static void Att_PutIconsOneAtt (void *Events) { /***** Put icon to get resource link *****/ - if (Gbl.Usrs.Me.Role.Logged == Rol_TCH || // Only if I am a teacher - Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) // or a superuser + if (PrgRsc_CheckIfICanGetLink ()) Ico_PutContextualIconToGetLink (ActReqLnkAtt,NULL, Att_PutParams,Events); } diff --git a/swad_browser.c b/swad_browser.c index 8ed2fa8a..e9b90e04 100644 --- a/swad_browser.c +++ b/swad_browser.c @@ -3577,8 +3577,7 @@ static void Brw_PutIconsFileBrowser (__attribute__((unused)) void *Args) /***** Put icon to get resource link *****/ if (Brw_ActReqLnk[Gbl.FileBrowser.Type] != ActUnk && - (Gbl.Usrs.Me.Role.Logged == Rol_TCH || // Only if I am a teacher - Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) // or a superuser + PrgRsc_CheckIfICanGetLink ()) Ico_PutContextualIconToGetLink (Brw_ActReqLnk[Gbl.FileBrowser.Type],NULL, NULL,NULL); @@ -7953,8 +7952,7 @@ void Brw_ShowFileMetadata (void) if (Brw_ActReqLnk[Gbl.FileBrowser.Type] != ActUnk && (FileMetadata.FilFolLnk.Type == Brw_IS_FILE || // Only files or links FileMetadata.FilFolLnk.Type == Brw_IS_LINK) && - (Gbl.Usrs.Me.Role.Logged == Rol_TCH || // Only if I am a teacher - Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) // or a superuser + PrgRsc_CheckIfICanGetLink ()) Box_BoxShadowBegin (NULL,NULL, Brw_PutIconToGetLinkToFile,&FileMetadata, NULL); diff --git a/swad_call_for_exam.c b/swad_call_for_exam.c index 3f17dca4..d9d98b6b 100644 --- a/swad_call_for_exam.c +++ b/swad_call_for_exam.c @@ -692,8 +692,7 @@ static void Cfe_PutIconsCallsForExams (__attribute__((unused)) void *Args) Ico_PutContextualIconToAdd (ActEdiCfe,NULL,NULL,NULL); /***** Link to get resource link *****/ - if (Gbl.Usrs.Me.Role.Logged == Rol_TCH || // Only if I am a teacher - Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) // or a superuser + if (PrgRsc_CheckIfICanGetLink ()) Ico_PutContextualIconToGetLink (ActReqLnkCfe,NULL, NULL,NULL); } @@ -1528,8 +1527,7 @@ static void Cfe_PutIconsCallForExam (void *CallsForExams) &((struct Cfe_CallsForExams *) CallsForExams)->ExaCod); /***** Link to get resource link *****/ - if (Gbl.Usrs.Me.Role.Logged == Rol_TCH || // Only if I am a teacher - Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) // or a superuser + if (PrgRsc_CheckIfICanGetLink ()) Ico_PutContextualIconToGetLink (ActReqLnkCfe,NULL, Cfe_PutParamExaCodToEdit, &((struct Cfe_CallsForExams *) CallsForExams)->ExaCod); diff --git a/swad_changelog.h b/swad_changelog.h index 5395e51a..ad041275 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -606,10 +606,11 @@ TODO: Fix bug: error al enviar un mensaje a dos recipientes, error on duplicate TODO: Attach pdf files in multimedia. */ -#define Log_PLATFORM_VERSION "SWAD 22.33.3 (2022-09-29)" +#define Log_PLATFORM_VERSION "SWAD 22.33.4 (2022-09-29)" #define CSS_FILE "swad22.22.1.css" #define JS_FILE "swad21.100.js" /* + Version 22.33.4: Sep 29, 2022 Code refactoring in program resources. (332711 lines) Version 22.33.3: Sep 29, 2022 Fixed layout of marks file metadata. (332709 lines) Version 22.33.2: Sep 29, 2022 Changes in program resources and course forums. (332708 lines) Version 22.33.1: Sep 29, 2022 Changes in program resources and attendance events. (332687 lines) diff --git a/swad_exam.c b/swad_exam.c index a3771ffc..f4d72127 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -355,8 +355,7 @@ static void Exa_PutIconsListExams (void *Exams) NULL,NULL); /***** Link to get resource link *****/ - if (Gbl.Usrs.Me.Role.Logged == Rol_TCH || // Only if I am a teacher - Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) // or a superuser + if (PrgRsc_CheckIfICanGetLink ()) Ico_PutContextualIconToGetLink (ActReqLnkExa,NULL, Exa_PutParams,Exams); @@ -664,8 +663,7 @@ static void Exa_PutIconToShowResultsOfExam (void *Exams) Exa_PutParams,Exams); /***** Link to get resource link *****/ - if (Gbl.Usrs.Me.Role.Logged == Rol_TCH || // Only if I am a teacher - Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) // or a superuser + if (PrgRsc_CheckIfICanGetLink ()) Ico_PutContextualIconToGetLink (ActReqLnkExa,NULL, Exa_PutParams,Exams); } diff --git a/swad_forum.c b/swad_forum.c index ddf0cfde..c9ba2c47 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -831,8 +831,7 @@ static void For_PutIconsOneThread (void *Forums) /***** Put icon to get resource link *****/ if (((struct For_Forums *) Forums)->Forum.Type == For_FORUM_COURSE_USRS && - (Gbl.Usrs.Me.Role.Logged == Rol_TCH || // Only if I am a teacher - Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) // or a superuser + PrgRsc_CheckIfICanGetLink ()) Ico_PutContextualIconToGetLink (ActReqLnkForCrsUsr,NULL, For_PutAllHiddenParamsNewPost,Forums); } @@ -2133,8 +2132,7 @@ static void For_PutIconsThreads (void *Forums) /***** Put icon to get resource link *****/ if (((struct For_Forums *) Forums)->Forum.Type == For_FORUM_COURSE_USRS && - (Gbl.Usrs.Me.Role.Logged == Rol_TCH || // Only if I am a teacher - Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) // or a superuser + PrgRsc_CheckIfICanGetLink ()) Ico_PutContextualIconToGetLink (ActReqLnkForCrsUsr,NULL, For_PutAllHiddenParamsNewPost,Forums); } diff --git a/swad_game.c b/swad_game.c index 8d330a56..5e7f8774 100644 --- a/swad_game.c +++ b/swad_game.c @@ -394,8 +394,7 @@ static void Gam_PutIconsListGames (void *Games) NULL,NULL); /***** Link to get resource link *****/ - if (Gbl.Usrs.Me.Role.Logged == Rol_TCH || // Only if I am a teacher - Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) // or a superuser + if (PrgRsc_CheckIfICanGetLink ()) Ico_PutContextualIconToGetLink (ActReqLnkGam,NULL, Gam_PutParams,Games); @@ -715,8 +714,7 @@ static void Gam_PutIconsOneGame (void *Games) Gam_PutParams,Games); /***** Link to get resource link *****/ - if (Gbl.Usrs.Me.Role.Logged == Rol_TCH || // Only if I am a teacher - Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) // or a superuser + if (PrgRsc_CheckIfICanGetLink ()) Ico_PutContextualIconToGetLink (ActReqLnkGam,NULL, Gam_PutParams,Games); } diff --git a/swad_program_resource.c b/swad_program_resource.c index 1b401bf4..92d7a073 100644 --- a/swad_program_resource.c +++ b/swad_program_resource.c @@ -1147,3 +1147,18 @@ PrgRsc_Type_t PrgRsc_GetTypeFromString (const char *Str) return PrgRsc_NONE; } + +/*****************************************************************************/ +/************************** Check if I can get link **************************/ +/*****************************************************************************/ + +bool PrgRsc_CheckIfICanGetLink (void) + { + static const bool ICanGetLink[Rol_NUM_ROLES] = + { + [Rol_TCH ] = true, + [Rol_SYS_ADM] = true, + }; + + return ICanGetLink[Gbl.Usrs.Me.Role.Logged]; + } diff --git a/swad_program_resource.h b/swad_program_resource.h index a935cf89..482106dc 100644 --- a/swad_program_resource.h +++ b/swad_program_resource.h @@ -23,6 +23,12 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ +/*****************************************************************************/ +/********************************* Headers ***********************************/ +/*****************************************************************************/ + +#include "swad_program.h" + /*****************************************************************************/ /***************************** Public prototypes *****************************/ /*****************************************************************************/ @@ -57,4 +63,6 @@ void PrgRsc_ChangeLink (void); PrgRsc_Type_t PrgRsc_GetTypeFromString (const char *Str); +bool PrgRsc_CheckIfICanGetLink (void); + #endif diff --git a/swad_project.c b/swad_project.c index a778a510..c9e7fa68 100644 --- a/swad_project.c +++ b/swad_project.c @@ -48,6 +48,7 @@ #include "swad_pagination.h" #include "swad_parameter.h" #include "swad_photo.h" +#include "swad_program_resource.h" #include "swad_project.h" #include "swad_project_database.h" #include "swad_role.h" @@ -1094,8 +1095,7 @@ static void Prj_PutIconsListProjects (void *Projects) NULL,NULL); /***** Link to get resource link *****/ - if (Gbl.Usrs.Me.Role.Logged == Rol_TCH || // Only if I am a teacher - Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) // or a superuser + if (PrgRsc_CheckIfICanGetLink ()) Ico_PutContextualIconToGetLink (ActReqLnkPrj,NULL, Prj_PutCurrentParams,Projects); @@ -2805,8 +2805,7 @@ static void Prj_PutFormsToRemEditOnePrj (struct Prj_Projects *Projects, Prj_PutIconOffLockedUnlocked (Prj); /***** Link to get resource link *****/ - if (Gbl.Usrs.Me.Role.Logged == Rol_TCH || // Only if I am a teacher - Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) // or a superuser + if (PrgRsc_CheckIfICanGetLink ()) Ico_PutContextualIconToGetLink (ActReqLnkPrj,NULL, Prj_PutCurrentParams,Projects); } diff --git a/swad_survey.c b/swad_survey.c index f45c2b41..7ef212bf 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -328,8 +328,7 @@ static void Svy_PutIconsListSurveys (void *Surveys) Svy_PutIconToCreateNewSvy ((struct Svy_Surveys *) Surveys); /***** Put icon to get resource link *****/ - if (Gbl.Usrs.Me.Role.Logged == Rol_TCH || // Only if I am a teacher - Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) // or a superuser + if (PrgRsc_CheckIfICanGetLink ()) Ico_PutContextualIconToGetLink (ActReqLnkSvy,NULL, Svy_PutParams,Surveys); @@ -731,8 +730,7 @@ static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys, static void Svy_PutIconsOneSvy (void *Surveys) { /***** Put icon to get resource link *****/ - if (Gbl.Usrs.Me.Role.Logged == Rol_TCH || // Only if I am a teacher - Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) // or a superuser + if (PrgRsc_CheckIfICanGetLink ()) Ico_PutContextualIconToGetLink (ActReqLnkSvy,NULL, Svy_PutParams,Surveys); }