Version 22.33.4: Sep 29, 2022 Code refactoring in program resources.

This commit is contained in:
acanas 2022-09-29 19:42:38 +02:00
parent 670f366c88
commit 52774daf77
12 changed files with 45 additions and 37 deletions

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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)

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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];
}

View File

@ -23,6 +23,12 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*****************************************************************************/
/********************************* 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

View File

@ -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);
}

View File

@ -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);
}