From c2a118c5d9ff5c11efc7568f4b0add355b76f0d1 Mon Sep 17 00:00:00 2001 From: acanas Date: Wed, 19 Apr 2023 13:09:52 +0200 Subject: [PATCH] Version 22.100.4: Apr 19, 2023 Removed buttons to create a new institution, new center, new degree and new course. --- swad_center.c | 23 +----------- swad_changelog.h | 3 +- swad_course.c | 23 +----------- swad_degree.c | 23 +----------- swad_hierarchy.c | 26 +++++++++++++ swad_hierarchy.h | 2 + swad_institution.c | 23 +----------- swad_text.c | 92 ---------------------------------------------- 8 files changed, 34 insertions(+), 181 deletions(-) diff --git a/swad_center.c b/swad_center.c index d926f90c5..c725c67f3 100644 --- a/swad_center.c +++ b/swad_center.c @@ -75,7 +75,6 @@ static struct Ctr_Center *Ctr_EditingCtr = NULL; // Static variable to keep the /*****************************************************************************/ static void Ctr_ListCenters (void); -static bool Ctr_CheckIfICanCreateCenters (void); static void Ctr_PutIconsListingCenters (__attribute__((unused)) void *Args); static void Ctr_PutIconToEditCenters (void); static void Ctr_ListOneCenterForSeeing (struct Ctr_Center *Ctr,unsigned NumCtr); @@ -250,8 +249,6 @@ static void Ctr_ListCenters (void) extern const char *Hlp_INSTITUTION_Centers; extern const char *Txt_Centers_of_INSTITUTION_X; extern const char *Txt_No_centers; - extern const char *Txt_Create_another_center; - extern const char *Txt_Create_center; char *Title; unsigned NumCtr; @@ -282,28 +279,10 @@ static void Ctr_ListCenters (void) else // No centers created in the current institution Ale_ShowAlert (Ale_INFO,Txt_No_centers); - /***** Button to create center *****/ - if (Ctr_CheckIfICanCreateCenters ()) - { - Frm_BeginForm (ActEdiCtr); - Btn_PutConfirmButton (Gbl.Hierarchy.Ctrs.Num ? Txt_Create_another_center : - Txt_Create_center); - Frm_EndForm (); - } - /***** End box *****/ Box_BoxEnd (); } -/*****************************************************************************/ -/********************** Check if I can create centers ************************/ -/*****************************************************************************/ - -static bool Ctr_CheckIfICanCreateCenters (void) - { - return Gbl.Usrs.Me.Role.Logged >= Rol_GST; - } - /*****************************************************************************/ /***************** Put contextual icons in list of centers *******************/ /*****************************************************************************/ @@ -311,7 +290,7 @@ static bool Ctr_CheckIfICanCreateCenters (void) static void Ctr_PutIconsListingCenters (__attribute__((unused)) void *Args) { /***** Put icon to edit centers *****/ - if (Ctr_CheckIfICanCreateCenters ()) + if (Hie_CheckIfICanEdit ()) Ctr_PutIconToEditCenters (); /***** Put icon to view places *****/ diff --git a/swad_changelog.h b/swad_changelog.h index 329e66a80..0f7b64250 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -629,10 +629,11 @@ TODO: Emilce Barrera Mesa: Podr TODO: Emilce Barrera Mesa: Mis estudiantes presentan muchas dificultades a la hora de poner la foto porque la plataforma es muy exigente respecto al fondo de la imagen. */ -#define Log_PLATFORM_VERSION "SWAD 22.100.3 (2023-04-19)" +#define Log_PLATFORM_VERSION "SWAD 22.100.4 (2023-04-19)" #define CSS_FILE "swad22.95.css" #define JS_FILE "swad22.49.js" /* + Version 22.100.4: Apr 19, 2023 Removed buttons to create a new institution, new center, new degree and new course. (338756 lines) Version 22.100.3: Apr 19, 2023 Institution admins can edit places. (338891 lines) Version 22.100.2: Apr 19, 2023 Institution admins can edit departments. (338889 lines) Version 22.100.1: Apr 19, 2023 Changes in projects. (338897 lines) diff --git a/swad_course.c b/swad_course.c index 9f150b8a9..2e75259f9 100644 --- a/swad_course.c +++ b/swad_course.c @@ -94,7 +94,6 @@ static void Crs_WriteListMyCoursesToSelectOne (void); static void Crs_GetListCrssInCurrentDeg (void); static void Crs_ListCourses (void); -static bool Crs_CheckIfICanCreateCourses (void); static void Crs_PutIconsListCourses (__attribute__((unused)) void *Args); static void Crs_PutIconToEditCourses (void); static bool Crs_ListCoursesOfAYearForSeeing (unsigned Year); @@ -840,8 +839,6 @@ static void Crs_ListCourses (void) extern const char *Hlp_DEGREE_Courses; extern const char *Txt_Courses_of_DEGREE_X; extern const char *Txt_No_courses; - extern const char *Txt_Create_another_course; - extern const char *Txt_Create_course; char *Title; unsigned Year; @@ -874,28 +871,10 @@ static void Crs_ListCourses (void) else // No courses created in the current degree Ale_ShowAlert (Ale_INFO,Txt_No_courses); - /***** Button to create course *****/ - if (Crs_CheckIfICanCreateCourses ()) - { - Frm_BeginForm (ActEdiCrs); - Btn_PutConfirmButton (Gbl.Hierarchy.Crss.Num ? Txt_Create_another_course : - Txt_Create_course); - Frm_EndForm (); - } - /***** End box *****/ Box_BoxEnd (); } -/*****************************************************************************/ -/********************** Check if I can create courses ************************/ -/*****************************************************************************/ - -static bool Crs_CheckIfICanCreateCourses (void) - { - return Gbl.Usrs.Me.Role.Logged >= Rol_GST; - } - /*****************************************************************************/ /***************** Put contextual icons in list of courses *******************/ /*****************************************************************************/ @@ -903,7 +882,7 @@ static bool Crs_CheckIfICanCreateCourses (void) static void Crs_PutIconsListCourses (__attribute__((unused)) void *Args) { /***** Put icon to edit courses *****/ - if (Crs_CheckIfICanCreateCourses ()) + if (Hie_CheckIfICanEdit ()) Crs_PutIconToEditCourses (); /***** Put icon to show a figure *****/ diff --git a/swad_degree.c b/swad_degree.c index ab0e7194a..c9cc54cd6 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -90,7 +90,6 @@ static void Deg_PutHeadDegreesForSeeing (void); static void Deg_PutHeadDegreesForEdition (void); static void Deg_ListDegrees (void); -static bool Deg_CheckIfICanCreateDegrees (void); static void Deg_PutIconsListingDegrees (__attribute__((unused)) void *Args); static void Deg_PutIconToEditDegrees (void); static void Deg_ListOneDegreeForSeeing (struct Deg_Degree *Deg,unsigned NumDeg); @@ -714,8 +713,6 @@ static void Deg_ListDegrees (void) extern const char *Hlp_CENTER_Degrees; extern const char *Txt_Degrees_of_CENTER_X; extern const char *Txt_No_degrees; - extern const char *Txt_Create_another_degree; - extern const char *Txt_Create_degree; char *Title; unsigned NumDeg; @@ -746,28 +743,10 @@ static void Deg_ListDegrees (void) else // No degrees created in the current center Ale_ShowAlert (Ale_INFO,Txt_No_degrees); - /***** Button to create degree *****/ - if (Deg_CheckIfICanCreateDegrees ()) - { - Frm_BeginForm (ActEdiDeg); - Btn_PutConfirmButton (Gbl.Hierarchy.Degs.Num ? Txt_Create_another_degree : - Txt_Create_degree); - Frm_EndForm (); - } - /***** End box *****/ Box_BoxEnd (); } -/*****************************************************************************/ -/********************** Check if I can create degrees ************************/ -/*****************************************************************************/ - -static bool Deg_CheckIfICanCreateDegrees (void) - { - return Gbl.Usrs.Me.Role.Logged >= Rol_GST; - } - /*****************************************************************************/ /***************** Put contextual icons in list of degrees *******************/ /*****************************************************************************/ @@ -775,7 +754,7 @@ static bool Deg_CheckIfICanCreateDegrees (void) static void Deg_PutIconsListingDegrees (__attribute__((unused)) void *Args) { /***** Put icon to edit degrees *****/ - if (Deg_CheckIfICanCreateDegrees ()) + if (Hie_CheckIfICanEdit ()) Deg_PutIconToEditDegrees (); /***** Put icon to view degree types *****/ diff --git a/swad_hierarchy.c b/swad_hierarchy.c index 5a96fd5f3..93d973bab 100644 --- a/swad_hierarchy.c +++ b/swad_hierarchy.c @@ -773,6 +773,32 @@ void Hie_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan) DB_FreeMySQLResult (&mysql_res); } +/*****************************************************************************/ +/****************** Check if I can edit hierarchy elements *******************/ +/*****************************************************************************/ + +bool Hie_CheckIfICanEdit (void) + { + // Some admins can edit all hierarchy elements. + // Any user can edit the elements he/she has created... + // ...as long as they are in pending status. + static const bool ICanEdit[Rol_NUM_ROLES] = + { + /* Users who can edit */ + [Rol_GST ] = true, + [Rol_USR ] = true, + [Rol_STD ] = true, + [Rol_NET ] = true, + [Rol_TCH ] = true, + [Rol_DEG_ADM] = true, + [Rol_CTR_ADM] = true, + [Rol_INS_ADM] = true, + [Rol_SYS_ADM] = true, + }; + + return ICanEdit[Gbl.Usrs.Me.Role.Logged]; + } + /*****************************************************************************/ /*********************** Write status cell in table **************************/ /*****************************************************************************/ diff --git a/swad_hierarchy.h b/swad_hierarchy.h index 2344a5cc6..d81f275fb 100644 --- a/swad_hierarchy.h +++ b/swad_hierarchy.h @@ -62,6 +62,8 @@ void Hie_ResetHierarchy (void); void Hie_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan); +bool Hie_CheckIfICanEdit (void); + void Hie_WriteStatusCell (Hie_Status_t Status, const char *Class,const char *BgColor, const char *Txt[Hie_NUM_STATUS_TXT]); diff --git a/swad_institution.c b/swad_institution.c index b15b75dfe..0b3ecb998 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -75,7 +75,6 @@ static struct Ins_Instit *Ins_EditingIns = NULL; // Static variable to keep the /*****************************************************************************/ static void Ins_ListInstitutions (void); -static bool Ins_CheckIfICanCreateInstitutions (void); static void Ins_PutIconsListingInstitutions (__attribute__((unused)) void *Args); static void Ins_PutIconToEditInstitutions (void); static void Ins_ListOneInstitutionForSeeing (struct Ins_Instit *Ins,unsigned NumIns); @@ -291,8 +290,6 @@ static void Ins_ListInstitutions (void) extern const char *Hlp_COUNTRY_Institutions; extern const char *Txt_Institutions_of_COUNTRY_X; extern const char *Txt_No_institutions; - extern const char *Txt_Create_another_institution; - extern const char *Txt_Create_institution; char *Title; unsigned NumIns; @@ -323,27 +320,9 @@ static void Ins_ListInstitutions (void) else // No insrtitutions created in the current country Ale_ShowAlert (Ale_INFO,Txt_No_institutions); - /***** Button to create institution *****/ - if (Ins_CheckIfICanCreateInstitutions ()) - { - Frm_BeginForm (ActEdiIns); - Btn_PutConfirmButton (Gbl.Hierarchy.Inss.Num ? Txt_Create_another_institution : - Txt_Create_institution); - Frm_EndForm (); - } - Box_BoxEnd (); } -/*****************************************************************************/ -/******************* Check if I can create institutions **********************/ -/*****************************************************************************/ - -static bool Ins_CheckIfICanCreateInstitutions (void) - { - return Gbl.Usrs.Me.Role.Logged >= Rol_GST; - } - /*****************************************************************************/ /*************** Put contextual icons in list of institutions ****************/ /*****************************************************************************/ @@ -351,7 +330,7 @@ static bool Ins_CheckIfICanCreateInstitutions (void) static void Ins_PutIconsListingInstitutions (__attribute__((unused)) void *Args) { /***** Put icon to edit institutions *****/ - if (Ins_CheckIfICanCreateInstitutions ()) + if (Hie_CheckIfICanEdit ()) Ins_PutIconToEditInstitutions (); /***** Put icon to show a figure *****/ diff --git a/swad_text.c b/swad_text.c index c4653e5c5..cd03c63cf 100644 --- a/swad_text.c +++ b/swad_text.c @@ -6525,98 +6525,6 @@ const char *Txt_Create_announcement = "Create announcement"; // Çeviri lazim! #endif -const char *Txt_Create_another_center = -#if L==1 // ca - "Crear un altre center"; -#elif L==2 // de - "Erstellen Sie ein anderes Lehrinstitut"; -#elif L==3 // en - "Create another center"; -#elif L==4 // es - "Crear otro centro"; -#elif L==5 // fr - "Créer un autre center"; -#elif L==6 // gn - "Crear otro centro"; // Okoteve traducción -#elif L==7 // it - "Crea un altro centro"; -#elif L==8 // pl - "Utwórz inny centrum"; -#elif L==9 // pt - "Criar outro centro"; -#elif L==10 // tr - "Create another center"; // Çeviri lazim! -#endif - -const char *Txt_Create_another_course = -#if L==1 // ca - "Crear una altra assignatura"; -#elif L==2 // de - "Erstellen Sie ein anderes Kurs"; -#elif L==3 // en - "Create another course"; -#elif L==4 // es - "Crear otra asignatura"; -#elif L==5 // fr - "Créer une autre matière"; -#elif L==6 // gn - "Crear otra asignatura"; // Okoteve traducción -#elif L==7 // it - "Crea un altro corso"; -#elif L==8 // pl - "Utwórz inny kursu"; -#elif L==9 // pt - "Criar outra disciplina"; -#elif L==10 // tr - "Create another course"; // Çeviri lazim! -#endif - -const char *Txt_Create_another_degree = -#if L==1 // ca - "Crear una altra titulació"; -#elif L==2 // de - "Erstellen Sie ein anderes Studiengang"; -#elif L==3 // en - "Create another degree"; -#elif L==4 // es - "Crear otra titulación"; -#elif L==5 // fr - "Créer un autre étude"; -#elif L==6 // gn - "Crear otra titulación"; // Okoteve traducción -#elif L==7 // it - "Crea una altra laurea"; -#elif L==8 // pl - "Utwórz inny stopnia"; -#elif L==9 // pt - "Criar outro grau"; -#elif L==10 // tr - "Create another degree"; // Çeviri lazim! -#endif - -const char *Txt_Create_another_institution = -#if L==1 // ca - "Crear una altra institució"; -#elif L==2 // de - "Erstellen Sie ein anderes Hochschule"; -#elif L==3 // en - "Create another institution"; -#elif L==4 // es - "Crear otra institución"; -#elif L==5 // fr - "Créer un autre établissement"; -#elif L==6 // gn - "Crear otra institución"; // Okoteve traducción -#elif L==7 // it - "Crea una altra istituzione"; -#elif L==8 // pl - "Utwórz inny instytucji"; -#elif L==9 // pt - "Criar outra institução"; -#elif L==10 // tr - "Create another institution"; // Çeviri lazim! -#endif - const char *Txt_Create_another_type_of_degree = #if L==1 // ca "Crear un altre tipus de titulació";