From 362c522791d7191abaff732e64cd2d96860857de Mon Sep 17 00:00:00 2001 From: acanas Date: Sun, 29 Oct 2023 12:32:08 +0100 Subject: [PATCH] Version 23.41: Oct 29, 2023 Code refactoring in view/edit/print. --- swad_assignment.c | 151 ++++++++++++++++++---------- swad_calendar.c | 25 +++-- swad_center_config.c | 205 +++++++++++++++++++------------------- swad_changelog.h | 3 +- swad_country_config.c | 182 ++++++++++++++++----------------- swad_course.c | 2 +- swad_course_config.c | 139 +++++++++++++------------- swad_course_config.h | 2 +- swad_degree_config.c | 86 ++++++++-------- swad_exam_print.c | 2 +- swad_exam_result.c | 2 +- swad_hierarchy_config.c | 12 +-- swad_hierarchy_config.h | 4 +- swad_info.c | 8 +- swad_institution_config.c | 165 +++++++++++++++--------------- swad_layout.c | 18 ++-- swad_layout.h | 3 +- swad_match_result.c | 2 +- swad_program.c | 46 ++++----- swad_program_resource.c | 114 +++++++++++---------- swad_project.c | 2 +- swad_syllabus.c | 49 ++++----- swad_syllabus.h | 2 +- swad_system_config.c | 135 +++++++++++++------------ swad_test.c | 2 +- swad_test_print.c | 4 +- swad_timetable.c | 51 ++++++---- swad_user.c | 12 +-- swad_view_edit.h | 15 +-- 29 files changed, 765 insertions(+), 678 deletions(-) diff --git a/swad_assignment.c b/swad_assignment.c index 26007dc1..281a64b4 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -67,8 +67,7 @@ extern struct Globals Gbl; /*****************************************************************************/ static void Asg_PutHead (struct Asg_Assignments *Assignments, - bool OnlyOneAssignment, - bool PrintView); + bool OnlyOneAssignment,Vie_ViewType_t ViewType); static bool Asg_CheckIfICanCreateAssignments (void); static void Asg_PutIconsListAssignments (void *Assignments); static void Asg_PutIconToCreateNewAsg (void *Assignments); @@ -76,9 +75,10 @@ static void Asg_ParsWhichGroupsToShow (void *Assignments); static void Asg_PutIconsOneAsg (void *Assignments); static void Asg_ShowAssignmentRow (struct Asg_Assignments *Assignments, bool OnlyOneAssignment, - bool PrintView); + Vie_ViewType_t ViewType); static void Asg_WriteAsgAuthor (struct Asg_Assignment *Asg); -static void Asg_WriteAssignmentFolder (struct Asg_Assignment *Asg,bool PrintView); +static void Asg_WriteAssignmentFolder (struct Asg_Assignment *Asg, + Vie_ViewType_t ViewType); static void Asg_PutIconsToRemEditOneAsg (struct Asg_Assignments *Assignments, const char *Anchor); @@ -179,7 +179,7 @@ void Asg_ShowAllAssignments (struct Asg_Assignments *Assignments) /***** Table head *****/ Asg_PutHead (Assignments, false, // Not only this assignment in table - false); // Not print view + Vie_VIEW); // Not print view /***** Write all assignments *****/ for (NumAsg = Pagination.FirstItemVisible, The_ResetRowColor (); @@ -189,8 +189,8 @@ void Asg_ShowAllAssignments (struct Asg_Assignments *Assignments) Assignments->Asg.AsgCod = Assignments->LstAsgCods[NumAsg - 1]; Asg_GetAssignmentDataByCod (&Assignments->Asg); Asg_ShowAssignmentRow (Assignments, - false, // Not only this assignment in table - false); // Not print view + false, // Not only this assignment in table + Vie_VIEW); // Not print view } /***** End table *****/ @@ -215,8 +215,7 @@ void Asg_ShowAllAssignments (struct Asg_Assignments *Assignments) /*****************************************************************************/ static void Asg_PutHead (struct Asg_Assignments *Assignments, - bool OnlyOneAssignment, - bool PrintView) + bool OnlyOneAssignment,Vie_ViewType_t ViewType) { extern const char *Txt_START_END_TIME_HELP[Dat_NUM_START_END_TIME]; extern const char *Txt_START_END_TIME[Dat_NUM_START_END_TIME]; @@ -237,7 +236,7 @@ static void Asg_PutHead (struct Asg_Assignments *Assignments, /* Begin head cell */ HTM_TH_Begin (HTM_HEAD_LEFT); - if (!PrintView) + if (ViewType == Vie_VIEW) { /* Begin form */ Frm_BeginForm (ActSeeAllAsg); @@ -256,7 +255,7 @@ static void Asg_PutHead (struct Asg_Assignments *Assignments, /* Start / end text */ HTM_Txt (Txt_START_END_TIME[Order]); - if (!PrintView) + if (ViewType == Vie_VIEW) { /* End link to select order */ if (Order == Assignments->SelectedOrder) @@ -388,7 +387,7 @@ void Asg_PrintOneAssignment (void) Asg_GetAssignmentDataByCod (&Assignments.Asg); /***** Write header *****/ - Lay_WriteHeaderClassPhoto (true,false); + Lay_WriteHeaderClassPhoto (Vie_PRINT,false); /***** Begin table *****/ HTM_TABLE_BeginWideMarginPadding (2); @@ -396,12 +395,12 @@ void Asg_PrintOneAssignment (void) /***** Table head *****/ Asg_PutHead (&Assignments, true, // Only this assignment in table - true); // Print view + Vie_PRINT); // Print view /***** Write assignment *****/ Asg_ShowAssignmentRow (&Assignments, - true, // Only this assignment in table - true); // Print view + true, // Only this assignment in table + Vie_PRINT); // Print view /***** End table *****/ HTM_TABLE_End (); @@ -425,12 +424,12 @@ void Asg_ShowOneAssignmentInBox (struct Asg_Assignments *Assignments) /***** Table head *****/ Asg_PutHead (Assignments, true, // Only this assignment in table - false); // Not print view + Vie_VIEW); // Not print view /***** Write assignment *****/ Asg_ShowAssignmentRow (Assignments, true, // Only this assignment in table - false); // Not print view + Vie_VIEW); // Not print view /***** End table and end box *****/ Box_BoxTableEnd (); @@ -463,7 +462,7 @@ static void Asg_PutIconsOneAsg (void *Assignments) static void Asg_ShowAssignmentRow (struct Asg_Assignments *Assignments, bool OnlyOneAssignment, - bool PrintView) + Vie_ViewType_t ViewType) { extern const char *Txt_Actions[ActLst_NUM_ACTIONS]; extern const char *HidVis_DateGreenClass[HidVis_NUM_HIDDEN_VISIBLE]; @@ -500,19 +499,27 @@ static void Asg_ShowAssignmentRow (struct Asg_Assignments *Assignments, { if (asprintf (&Id,"asg_date_%u_%u",(unsigned) StartEndTime,UniqueId) < 0) Err_NotEnoughMemoryExit (); - if (PrintView) - HTM_TD_Begin ("id=\"%s\" class=\"LT %s_%s\"", - Id, - Assignments->Asg.Open ? HidVis_DateGreenClass[Assignments->Asg.HiddenOrVisible] : - HidVis_DateRedClass[Assignments->Asg.HiddenOrVisible], - The_GetSuffix ()); - else - HTM_TD_Begin ("id=\"%s\" class=\"LT %s_%s %s\"", - Id, - Assignments->Asg.Open ? HidVis_DateGreenClass[Assignments->Asg.HiddenOrVisible] : - HidVis_DateRedClass[Assignments->Asg.HiddenOrVisible], - The_GetSuffix (), - The_GetColorRows ()); + switch (ViewType) + { + case Vie_VIEW: + HTM_TD_Begin ("id=\"%s\" class=\"LT %s_%s %s\"", + Id, + Assignments->Asg.Open ? HidVis_DateGreenClass[Assignments->Asg.HiddenOrVisible] : + HidVis_DateRedClass[Assignments->Asg.HiddenOrVisible], + The_GetSuffix (), + The_GetColorRows ()); + break; + case Vie_PRINT: + HTM_TD_Begin ("id=\"%s\" class=\"LT %s_%s\"", + Id, + Assignments->Asg.Open ? HidVis_DateGreenClass[Assignments->Asg.HiddenOrVisible] : + HidVis_DateRedClass[Assignments->Asg.HiddenOrVisible], + The_GetSuffix ()); + break; + default: + Err_WrongTypeExit (); + break; + } Dat_WriteLocalDateHMSFromUTC (Id,Assignments->Asg.TimeUTC[StartEndTime], Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK, true,true,true,0x7); @@ -521,10 +528,18 @@ static void Asg_ShowAssignmentRow (struct Asg_Assignments *Assignments, } /* Assignment title */ - if (PrintView) - HTM_TD_Begin ("class=\"LT\""); - else - HTM_TD_Begin ("class=\"LT %s\"",The_GetColorRows ()); + switch (ViewType) + { + case Vie_VIEW: + HTM_TD_Begin ("class=\"LT %s\"",The_GetColorRows ()); + break; + case Vie_PRINT: + HTM_TD_Begin ("class=\"LT\""); + break; + default: + Err_WrongTypeExit (); + break; + } HTM_ARTICLE_Begin (Anchor); Frm_BeginForm (ActSeeOneAsg); @@ -541,14 +556,23 @@ static void Asg_ShowAssignmentRow (struct Asg_Assignments *Assignments, HTM_TD_End (); /* Assignment folder */ - if (PrintView) - HTM_TD_Begin ("class=\"LT DAT_%s\"", - The_GetSuffix ()); - else - HTM_TD_Begin ("class=\"LT DAT_%s %s\"", - The_GetSuffix (),The_GetColorRows ()); + switch (ViewType) + { + case Vie_VIEW: + HTM_TD_Begin ("class=\"LT DAT_%s %s\"", + The_GetSuffix (),The_GetColorRows ()); + break; + case Vie_PRINT: + HTM_TD_Begin ("class=\"LT DAT_%s\"", + The_GetSuffix ()); + break; + default: + Err_WrongTypeExit (); + break; + } + if (Assignments->Asg.SendWork == Asg_SEND_WORK) - Asg_WriteAssignmentFolder (&Assignments->Asg,PrintView); + Asg_WriteAssignmentFolder (&Assignments->Asg,ViewType); HTM_TD_End (); HTM_TR_End (); @@ -557,10 +581,18 @@ static void Asg_ShowAssignmentRow (struct Asg_Assignments *Assignments, HTM_TR_Begin (NULL); /* Author of the assignment */ - if (PrintView) - HTM_TD_Begin ("colspan=\"2\" class=\"LT\""); - else - HTM_TD_Begin ("colspan=\"2\" class=\"LT %s\"",The_GetColorRows ()); + switch (ViewType) + { + case Vie_VIEW: + HTM_TD_Begin ("colspan=\"2\" class=\"LT %s\"",The_GetColorRows ()); + break; + case Vie_PRINT: + HTM_TD_Begin ("colspan=\"2\" class=\"LT\""); + break; + default: + Err_WrongTypeExit (); + break; + } Asg_WriteAsgAuthor (&Assignments->Asg); HTM_TD_End (); @@ -569,10 +601,18 @@ static void Asg_ShowAssignmentRow (struct Asg_Assignments *Assignments, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Txt,Cns_MAX_BYTES_TEXT,Str_DONT_REMOVE_SPACES); ALn_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links - if (PrintView) - HTM_TD_Begin ("colspan=\"2\" class=\"LT\""); - else - HTM_TD_Begin ("colspan=\"2\" class=\"LT %s\"",The_GetColorRows ()); + switch (ViewType) + { + case Vie_VIEW: + HTM_TD_Begin ("colspan=\"2\" class=\"LT %s\"",The_GetColorRows ()); + break; + case Vie_PRINT: + HTM_TD_Begin ("colspan=\"2\" class=\"LT\""); + break; + default: + Err_WrongTypeExit (); + break; + } if (Gbl.Crs.Grps.NumGrps) Asg_GetAndWriteNamesOfGrpsAssociatedToAsg (&Assignments->Asg); @@ -606,17 +646,18 @@ static void Asg_WriteAsgAuthor (struct Asg_Assignment *Asg) /********************* Write the folder of an assignment *********************/ /*****************************************************************************/ -static void Asg_WriteAssignmentFolder (struct Asg_Assignment *Asg,bool PrintView) +static void Asg_WriteAssignmentFolder (struct Asg_Assignment *Asg, + Vie_ViewType_t ViewType) { extern const char *Txt_Folder; Act_Action_t NextAction; bool ICanSendFiles = Asg->HiddenOrVisible == HidVis_VISIBLE && // It's visible (not hidden) - Asg->Open && // It's open (inside dates) - Asg->IBelongToCrsOrGrps; // I belong to course or groups + Asg->Open && // It's open (inside dates) + Asg->IBelongToCrsOrGrps; // I belong to course or groups /***** Folder icon *****/ - if (!PrintView && // Not print view - ICanSendFiles) // I can send files to this assignment folder + if (ViewType == Vie_VIEW && // Not print view + ICanSendFiles) // I can send files to this assignment folder { /* Form to create a new file or folder */ Gbl.FileBrowser.FullTree = true; // By default, show all files diff --git a/swad_calendar.c b/swad_calendar.c index 9ff67d60..650b7a1d 100644 --- a/swad_calendar.c +++ b/swad_calendar.c @@ -78,7 +78,7 @@ static unsigned Cal_GetParFirstDayOfWeek (void); static void Cal_DrawCalendar (Act_Action_t ActionSeeCalendar, Act_Action_t ActionChangeCalendar1stDay, void (*FunctionToDrawContextualIcons) (void *Args),void *Args, - bool PrintView); + Vie_ViewType_t ViewType); static void Cal_PutIconsCalendar (__attribute__((unused)) void *Args); /*****************************************************************************/ @@ -235,36 +235,42 @@ void Cal_ShowCalendar (void) { Cal_DrawCalendar (ActSeeCal,ActChgCal1stDay, Cal_PutIconsCalendar,NULL, - false); + Vie_VIEW); } void Cal_PrintCalendar (void) { Cal_DrawCalendar (ActUnk,ActUnk, NULL,NULL, - true); + Vie_PRINT); } static void Cal_DrawCalendar (Act_Action_t ActionSeeCalendar, Act_Action_t ActionChangeCalendar1stDay, void (*FunctionToDrawContextualIcons) (void *Args),void *Args, - bool PrintView) + Vie_ViewType_t ViewType) { extern const char *Hlp_START_Calendar; extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES]; char ParsStr[Frm_MAX_BYTES_PARAMS_STR + 1]; + static const char *Print[Vie_NUM_VIEW_TYPES] = + { + [Vie_VIEW ] = "false", + [Vie_PRINT] = "true", + }; /***** Begin box *****/ Box_BoxBegin (NULL,NULL, FunctionToDrawContextualIcons,Args, - PrintView ? NULL : - Hlp_START_Calendar,Box_NOT_CLOSABLE); + ViewType == Vie_VIEW ? Hlp_START_Calendar : + NULL, + Box_NOT_CLOSABLE); /***** Write header *****/ - Lay_WriteHeaderClassPhoto (PrintView,false); + Lay_WriteHeaderClassPhoto (ViewType,false); /***** Preference selector to change first day of week *****/ - if (!PrintView) + if (ViewType == Vie_VIEW) { Set_BeginSettingsHead (); Cal_ShowFormToSelFirstDayOfWeek (ActionChangeCalendar1stDay, @@ -284,8 +290,7 @@ static void Cal_DrawCalendar (Act_Action_t ActionSeeCalendar, Gbl.Prefs.FirstDayOfWeek, (long) Dat_GetStartExecutionTimeUTC (), Gbl.Hierarchy.Node[Hie_CTR].Specific.PlcCod, - PrintView ? "true" : - "false", + Print[ViewType], The_GetSuffix (), Cfg_URL_SWAD_CGI,Lan_STR_LANG_ID[Gbl.Prefs.Language]); Frm_SetParsForm (ParsStr,ActionSeeCalendar,true); diff --git a/swad_center_config.c b/swad_center_config.c index 7a41abf4..9f4f875c 100644 --- a/swad_center_config.c +++ b/swad_center_config.c @@ -75,23 +75,23 @@ extern struct Globals Gbl; /***************************** Private prototypes ****************************/ /*****************************************************************************/ -static void CtrCfg_Configuration (bool PrintView); +static void CtrCfg_Configuration (Vie_ViewType_t ViewType); static void CtrCfg_PutIconsCtrConfig (__attribute__((unused)) void *Args); static void CtrCfg_PutIconToChangePhoto (void); static void CtrCfg_Map (const struct Map_Coordinates *Coord); static void CtrCfg_Latitude (double Latitude); static void CtrCfg_Longitude (double Longitude); static void CtrCfg_Altitude (double Altitude); -static void CtrCfg_Photo (bool PrintView,bool PutForm,bool PutLink, +static void CtrCfg_Photo (Vie_ViewType_t ViewType,bool PutForm,bool PutLink, const char PathPhoto[PATH_MAX + 1]); static void CtrCfg_GetPhotoAttr (long CtrCod,char **PhotoAttribution); static void CtrCfg_FreePhotoAttr (char **PhotoAttribution); -static void CtrCfg_Institution (bool PrintView,bool PutForm); +static void CtrCfg_Institution (Vie_ViewType_t ViewType,bool PutForm); static void CtrCfg_FullName (bool PutForm); static void CtrCfg_ShrtName (bool PutForm); static void CtrCfg_Place (bool PutForm); -static void CtrCfg_WWW (bool PrintView,bool PutForm); -static void CtrCfg_Shortcut (bool PrintView); +static void CtrCfg_WWW (Vie_ViewType_t ViewType,bool PutForm); +static void CtrCfg_Shortcut (Vie_ViewType_t ViewType); static void CtrCfg_QR (void); static void CtrCfg_NumUsrs (void); static void CtrCfg_NumDegs (void); @@ -103,7 +103,7 @@ static void CtrCfg_NumCrss (void); void CtrCfg_ShowConfiguration (void) { - CtrCfg_Configuration (false); + CtrCfg_Configuration (Vie_VIEW); /***** Show help to enrol me *****/ Hlp_ShowHelpWhatWouldYouLikeToDo (); @@ -115,14 +115,14 @@ void CtrCfg_ShowConfiguration (void) void CtrCfg_PrintConfiguration (void) { - CtrCfg_Configuration (true); + CtrCfg_Configuration (Vie_PRINT); } /*****************************************************************************/ /******************* Information of the current center ***********************/ /*****************************************************************************/ -static void CtrCfg_Configuration (bool PrintView) +static void CtrCfg_Configuration (Vie_ViewType_t ViewType) { extern const char *Hlp_CENTER_Information; struct Map_Coordinates Coord; @@ -145,108 +145,111 @@ static void CtrCfg_Configuration (bool PrintView) Ctr_GetCoordByCod (Gbl.Hierarchy.Node[Hie_CTR].HieCod,&Coord); /***** Initializations *****/ - PutLink = !PrintView && Gbl.Hierarchy.Node[Hie_CTR].WWW[0]; - PutFormIns = !PrintView && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM; - PutFormName = !PrintView && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM; + PutLink = ViewType == Vie_VIEW && Gbl.Hierarchy.Node[Hie_CTR].WWW[0]; + PutFormIns = ViewType == Vie_VIEW && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM; + PutFormName = ViewType == Vie_VIEW && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM; PutFormPlc = PutFormCoor = PutFormWWW = - PutFormPhoto = !PrintView && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM; + PutFormPhoto = ViewType == Vie_VIEW && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM; /***** Begin box *****/ - if (PrintView) - Box_BoxBegin (NULL,NULL, - NULL,NULL, - NULL,Box_NOT_CLOSABLE); - else - Box_BoxBegin (NULL,NULL, - CtrCfg_PutIconsCtrConfig,NULL, - Hlp_CENTER_Information,Box_NOT_CLOSABLE); + Box_BoxBegin (NULL,NULL, + ViewType == Vie_VIEW ? CtrCfg_PutIconsCtrConfig : + NULL,NULL, + ViewType == Vie_VIEW ? Hlp_CENTER_Information : + NULL,Box_NOT_CLOSABLE); - /***** Title *****/ - HieCfg_Title (PutLink,Hie_CTR); + /***** Title *****/ + HieCfg_Title (PutLink,Hie_CTR); - /**************************** Left part ***********************************/ - HTM_DIV_Begin ("class=\"HIE_CFG_LEFT HIE_CFG_WIDTH\""); + /**************************** Left part ***********************************/ + HTM_DIV_Begin ("class=\"HIE_CFG_LEFT HIE_CFG_WIDTH\""); - /***** Begin table *****/ - HTM_TABLE_BeginWidePadding (2); + /***** Begin table *****/ + HTM_TABLE_BeginWidePadding (2); - /***** Institution *****/ - CtrCfg_Institution (PrintView,PutFormIns); + /***** Institution *****/ + CtrCfg_Institution (ViewType,PutFormIns); - /***** Center name *****/ - CtrCfg_FullName (PutFormName); - CtrCfg_ShrtName (PutFormName); + /***** Center name *****/ + CtrCfg_FullName (PutFormName); + CtrCfg_ShrtName (PutFormName); - /***** Place *****/ - CtrCfg_Place (PutFormPlc); + /***** Place *****/ + CtrCfg_Place (PutFormPlc); - /***** Coordinates *****/ - if (PutFormCoor) - { - CtrCfg_Latitude (Coord.Latitude ); - CtrCfg_Longitude (Coord.Longitude); - CtrCfg_Altitude (Coord.Altitude ); - } + /***** Coordinates *****/ + if (PutFormCoor) + { + CtrCfg_Latitude (Coord.Latitude ); + CtrCfg_Longitude (Coord.Longitude); + CtrCfg_Altitude (Coord.Altitude ); + } - /***** Center WWW *****/ - CtrCfg_WWW (PrintView,PutFormWWW); + /***** Center WWW *****/ + CtrCfg_WWW (ViewType,PutFormWWW); - /***** Shortcut to the center *****/ - CtrCfg_Shortcut (PrintView); + /***** Shortcut to the center *****/ + CtrCfg_Shortcut (ViewType); - if (PrintView) - /***** QR code with link to the center *****/ - CtrCfg_QR (); - else - { - /***** Number of users who claim to belong to this center, - number of degrees, - number of courses *****/ - CtrCfg_NumUsrs (); - CtrCfg_NumDegs (); - CtrCfg_NumCrss (); + switch (ViewType) + { + case Vie_VIEW: + /***** Number of users who claim to belong to this center, + number of degrees, + number of courses *****/ + CtrCfg_NumUsrs (); + CtrCfg_NumDegs (); + CtrCfg_NumCrss (); - /***** Number of users in courses of this center *****/ - HieCfg_NumUsrsInCrss (Hie_CTR,Gbl.Hierarchy.Node[Hie_CTR].HieCod,Rol_TCH); - HieCfg_NumUsrsInCrss (Hie_CTR,Gbl.Hierarchy.Node[Hie_CTR].HieCod,Rol_NET); - HieCfg_NumUsrsInCrss (Hie_CTR,Gbl.Hierarchy.Node[Hie_CTR].HieCod,Rol_STD); - HieCfg_NumUsrsInCrss (Hie_CTR,Gbl.Hierarchy.Node[Hie_CTR].HieCod,Rol_UNK); - } + /***** Number of users in courses of this center *****/ + HieCfg_NumUsrsInCrss (Hie_CTR,Gbl.Hierarchy.Node[Hie_CTR].HieCod,Rol_TCH); + HieCfg_NumUsrsInCrss (Hie_CTR,Gbl.Hierarchy.Node[Hie_CTR].HieCod,Rol_NET); + HieCfg_NumUsrsInCrss (Hie_CTR,Gbl.Hierarchy.Node[Hie_CTR].HieCod,Rol_STD); + HieCfg_NumUsrsInCrss (Hie_CTR,Gbl.Hierarchy.Node[Hie_CTR].HieCod,Rol_UNK); + break; + case Vie_PRINT: + /***** QR code with link to the center *****/ + CtrCfg_QR (); + break; + default: + Err_WrongTypeExit (); + break; + } - /***** End table *****/ - HTM_TABLE_End (); - - /***** End of left part *****/ - HTM_DIV_End (); - - /**************************** Right part **********************************/ - /***** Check map *****/ - MapIsAvailable = Map_CheckIfCoordAreAvailable (&Coord); - - /***** Check photo *****/ - snprintf (PathPhoto,sizeof (PathPhoto),"%s/%02u/%u/%u.jpg", - Cfg_PATH_CTR_PUBLIC, - (unsigned) (Gbl.Hierarchy.Node[Hie_CTR].HieCod % 100), - (unsigned) Gbl.Hierarchy.Node[Hie_CTR].HieCod, - (unsigned) Gbl.Hierarchy.Node[Hie_CTR].HieCod); - PhotoExists = Fil_CheckIfPathExists (PathPhoto); - - if (MapIsAvailable || PhotoExists) - { - HTM_DIV_Begin ("class=\"HIE_CFG_RIGHT HIE_CFG_WIDTH\""); - - /***** Center map *****/ - if (MapIsAvailable) - CtrCfg_Map (&Coord); - - /***** Center photo *****/ - if (PhotoExists) - CtrCfg_Photo (PrintView,PutFormPhoto,PutLink,PathPhoto); + /***** End table *****/ + HTM_TABLE_End (); + /***** End of left part *****/ HTM_DIV_End (); - } + + /**************************** Right part **********************************/ + /***** Check map *****/ + MapIsAvailable = Map_CheckIfCoordAreAvailable (&Coord); + + /***** Check photo *****/ + snprintf (PathPhoto,sizeof (PathPhoto),"%s/%02u/%u/%u.jpg", + Cfg_PATH_CTR_PUBLIC, + (unsigned) (Gbl.Hierarchy.Node[Hie_CTR].HieCod % 100), + (unsigned) Gbl.Hierarchy.Node[Hie_CTR].HieCod, + (unsigned) Gbl.Hierarchy.Node[Hie_CTR].HieCod); + PhotoExists = Fil_CheckIfPathExists (PathPhoto); + + if (MapIsAvailable || PhotoExists) + { + HTM_DIV_Begin ("class=\"HIE_CFG_RIGHT HIE_CFG_WIDTH\""); + + /***** Center map *****/ + if (MapIsAvailable) + CtrCfg_Map (&Coord); + + /***** Center photo *****/ + if (PhotoExists) + CtrCfg_Photo (ViewType,PutFormPhoto,PutLink,PathPhoto); + + HTM_DIV_End (); + } /***** End box *****/ Box_BoxEnd (); @@ -418,7 +421,7 @@ static void CtrCfg_Altitude (double Altitude) /***************************** Draw center photo *****************************/ /*****************************************************************************/ -static void CtrCfg_Photo (bool PrintView,bool PutForm,bool PutLink, +static void CtrCfg_Photo (Vie_ViewType_t ViewType,bool PutForm,bool PutLink, const char PathPhoto[PATH_MAX + 1]) { char *PhotoAttribution = NULL; @@ -448,8 +451,8 @@ static void CtrCfg_Photo (bool PrintView,bool PutForm,bool PutLink, (unsigned) Gbl.Hierarchy.Node[Hie_CTR].HieCod) < 0) Err_NotEnoughMemoryExit (); HTM_IMG (URL,Icon,Gbl.Hierarchy.Node[Hie_CTR].FullName, - "class=\"%s\"",PrintView ? "CENTER_PHOTO_PRINT CENTER_PHOTO_WIDTH" : - "CENTER_PHOTO_SHOW CENTER_PHOTO_WIDTH"); + "class=\"%s\"",ViewType == Vie_VIEW ? "CENTER_PHOTO_SHOW CENTER_PHOTO_WIDTH" : + "CENTER_PHOTO_PRINT CENTER_PHOTO_WIDTH"); free (Icon); free (URL); if (PutLink) @@ -531,7 +534,7 @@ static void CtrCfg_FreePhotoAttr (char **PhotoAttribution) /***************** Show institution in center configuration ******************/ /*****************************************************************************/ -static void CtrCfg_Institution (bool PrintView,bool PutForm) +static void CtrCfg_Institution (Vie_ViewType_t ViewType,bool PutForm) { extern const char *Par_CodeStr[]; extern const char *Txt_Institution; @@ -578,7 +581,7 @@ static void CtrCfg_Institution (bool PrintView,bool PutForm) } else // I can not move center to another institution { - if (!PrintView) + if (ViewType == Vie_VIEW) { Frm_BeginFormGoTo (ActSeeInsInf); ParCod_PutPar (ParCod_Ins,Gbl.Hierarchy.Node[Hie_INS].HieCod); @@ -594,7 +597,7 @@ static void CtrCfg_Institution (bool PrintView,bool PutForm) HTM_NBSP (); HTM_Txt (Gbl.Hierarchy.Node[Hie_INS].FullName); - if (!PrintView) + if (ViewType == Vie_VIEW) { HTM_BUTTON_End (); Frm_EndForm (); @@ -698,18 +701,18 @@ static void CtrCfg_Place (bool PutForm) /***************** Show center WWW in center configuration *******************/ /*****************************************************************************/ -static void CtrCfg_WWW (bool PrintView,bool PutForm) +static void CtrCfg_WWW (Vie_ViewType_t ViewType,bool PutForm) { - HieCfg_WWW (PrintView,PutForm,ActChgCtrWWWCfg,Gbl.Hierarchy.Node[Hie_CTR].WWW); + HieCfg_WWW (ViewType,PutForm,ActChgCtrWWWCfg,Gbl.Hierarchy.Node[Hie_CTR].WWW); } /*****************************************************************************/ /*************** Show center shortcut in center configuration ****************/ /*****************************************************************************/ -static void CtrCfg_Shortcut (bool PrintView) +static void CtrCfg_Shortcut (Vie_ViewType_t ViewType) { - HieCfg_Shortcut (PrintView,ParCod_Ctr,Gbl.Hierarchy.Node[Hie_CTR].HieCod); + HieCfg_Shortcut (ViewType,ParCod_Ctr,Gbl.Hierarchy.Node[Hie_CTR].HieCod); } /*****************************************************************************/ diff --git a/swad_changelog.h b/swad_changelog.h index a917ac6a..a2532a16 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -633,10 +633,11 @@ Me sale este error, no s "can npt create received message (duplicated entry '243218-2160773' for key 'UsrCod_MsgCod') */ -#define Log_PLATFORM_VERSION "SWAD 23.40 (2023-10-28)" +#define Log_PLATFORM_VERSION "SWAD 23.41 (2023-10-29)" #define CSS_FILE "swad23.35.1.css" #define JS_FILE "swad22.49.js" /* + Version 23.41: Oct 29, 2023 Code refactoring in view/edit/print. (335359 lines) Version 23.40: Oct 28, 2023 Code refactoring in view/edit. (335273 lines) Version 23.39: Oct 27, 2023 Code refactoring in contracted/expanded and rubrics. (335209 lines) Version 23.38.3: Oct 27, 2023 When clicking on edition of a program item, expand it if contracted. (335155 lines) diff --git a/swad_country_config.c b/swad_country_config.c index 3c7f51df..e0033fbb 100644 --- a/swad_country_config.c +++ b/swad_country_config.c @@ -58,14 +58,14 @@ extern struct Globals Gbl; /***************************** Private prototypes ****************************/ /*****************************************************************************/ -static void CtyCfg_Configuration (bool PrintView); +static void CtyCfg_Configuration (Vie_ViewType_t ViewType); static void CtyCfg_PutIconToPrint (__attribute__((unused)) void *Args); static void CtyCfg_Title (bool PutLink); static void CtyCfg_Map (void); -static void CtyCfg_MapImage (bool PrintView,bool PutLink); -static void CtyCfg_Platform (bool PrintView); +static void CtyCfg_MapImage (Vie_ViewType_t ViewType,bool PutLink); +static void CtyCfg_Platform (Vie_ViewType_t ViewType); static void CtyCfg_Name (bool PutLink); -static void CtyCfg_Shortcut (bool PrintView); +static void CtyCfg_Shortcut (Vie_ViewType_t ViewType); static void CtyCfg_QR (void); static void CtyCfg_NumUsrs (void); static void CtyCfg_NumInss (void); @@ -81,7 +81,7 @@ static void CtyCfg_FreeMapAttr (char **MapAttribution); void CtyCfg_ShowConfiguration (void) { - CtyCfg_Configuration (false); + CtyCfg_Configuration (Vie_VIEW); /***** Show help to enrol me *****/ Hlp_ShowHelpWhatWouldYouLikeToDo (); @@ -93,14 +93,14 @@ void CtyCfg_ShowConfiguration (void) void CtyCfg_PrintConfiguration (void) { - CtyCfg_Configuration (true); + CtyCfg_Configuration (Vie_PRINT); } /*****************************************************************************/ /******************** Information of the current country *********************/ /*****************************************************************************/ -static void CtyCfg_Configuration (bool PrintView) +static void CtyCfg_Configuration (Vie_ViewType_t ViewType) { extern const char *Hlp_COUNTRY_Information; bool PutLink; @@ -113,92 +113,95 @@ static void CtyCfg_Configuration (bool PrintView) return; /***** Initializations *****/ - PutLink = !PrintView && Gbl.Hierarchy.Node[Hie_CTY].WWW[0]; + PutLink = ViewType == Vie_VIEW && Gbl.Hierarchy.Node[Hie_CTY].WWW[0]; /***** Begin box *****/ - if (PrintView) - Box_BoxBegin (NULL,NULL, - NULL,NULL, - NULL,Box_NOT_CLOSABLE); - else - Box_BoxBegin (NULL,NULL, - CtyCfg_PutIconToPrint,NULL, - Hlp_COUNTRY_Information,Box_NOT_CLOSABLE); + Box_BoxBegin (NULL,NULL, + ViewType == Vie_VIEW ? CtyCfg_PutIconToPrint : + NULL,NULL, + ViewType == Vie_VIEW ? Hlp_COUNTRY_Information : + NULL,Box_NOT_CLOSABLE); - /***** Title *****/ - CtyCfg_Title (PutLink); + /***** Title *****/ + CtyCfg_Title (PutLink); - /**************************** Left part ***********************************/ - HTM_DIV_Begin ("class=\"HIE_CFG_LEFT HIE_CFG_WIDTH\""); + /**************************** Left part ***********************************/ + HTM_DIV_Begin ("class=\"HIE_CFG_LEFT HIE_CFG_WIDTH\""); - /* Begin table */ - HTM_TABLE_BeginWidePadding (2); + /* Begin table */ + HTM_TABLE_BeginWidePadding (2); - /* Platform */ - CtyCfg_Platform (PrintView); + /* Platform */ + CtyCfg_Platform (ViewType); - /* Country name (an link to WWW if exists) */ - CtyCfg_Name (PutLink); + /* Country name (an link to WWW if exists) */ + CtyCfg_Name (PutLink); - /* Shortcut to the country */ - CtyCfg_Shortcut (PrintView); + /* Shortcut to the country */ + CtyCfg_Shortcut (ViewType); - NumCtrsWithMap = Ctr_GetCachedNumCtrsWithMapInCty (Gbl.Hierarchy.Node[Hie_CTY].HieCod); - if (PrintView) - /* QR code with link to the country */ - CtyCfg_QR (); - else - { - NumCtrs = Hie_GetCachedNumNodesInHieLvl (Hie_CTR, // Number of centers... - Hie_CTY, // ...in country - Gbl.Hierarchy.Node[Hie_CTY].HieCod); + NumCtrsWithMap = Ctr_GetCachedNumCtrsWithMapInCty (Gbl.Hierarchy.Node[Hie_CTY].HieCod); + switch (ViewType) + { + case Vie_VIEW: + NumCtrs = Hie_GetCachedNumNodesInHieLvl (Hie_CTR, // Number of centers... + Hie_CTY, // ...in country + Gbl.Hierarchy.Node[Hie_CTY].HieCod); - /* Number of users who claim to belong to this country, - number of institutions, - number of centers, - number of degrees, - number of courses */ - CtyCfg_NumUsrs (); - CtyCfg_NumInss (); - HieCfg_NumCtrs (NumCtrs, - false); // Don't put form - HieCfg_NumCtrsWithMap (NumCtrs,NumCtrsWithMap); - CtyCfg_NumDegs (); - CtyCfg_NumCrss (); + /* Number of users who claim to belong to this country, + number of institutions, + number of centers, + number of degrees, + number of courses */ + CtyCfg_NumUsrs (); + CtyCfg_NumInss (); + HieCfg_NumCtrs (NumCtrs, + false); // Don't put form + HieCfg_NumCtrsWithMap (NumCtrs,NumCtrsWithMap); + CtyCfg_NumDegs (); + CtyCfg_NumCrss (); - /* Number of users in courses of this country */ - HieCfg_NumUsrsInCrss (Hie_CTY,Gbl.Hierarchy.Node[Hie_CTY].HieCod,Rol_TCH); - HieCfg_NumUsrsInCrss (Hie_CTY,Gbl.Hierarchy.Node[Hie_CTY].HieCod,Rol_NET); - HieCfg_NumUsrsInCrss (Hie_CTY,Gbl.Hierarchy.Node[Hie_CTY].HieCod,Rol_STD); - HieCfg_NumUsrsInCrss (Hie_CTY,Gbl.Hierarchy.Node[Hie_CTY].HieCod,Rol_UNK); - } + /* Number of users in courses of this country */ + HieCfg_NumUsrsInCrss (Hie_CTY,Gbl.Hierarchy.Node[Hie_CTY].HieCod,Rol_TCH); + HieCfg_NumUsrsInCrss (Hie_CTY,Gbl.Hierarchy.Node[Hie_CTY].HieCod,Rol_NET); + HieCfg_NumUsrsInCrss (Hie_CTY,Gbl.Hierarchy.Node[Hie_CTY].HieCod,Rol_STD); + HieCfg_NumUsrsInCrss (Hie_CTY,Gbl.Hierarchy.Node[Hie_CTY].HieCod,Rol_UNK); + break; + case Vie_PRINT: + /* QR code with link to the country */ + CtyCfg_QR (); + break; + default: + Err_WrongTypeExit (); + break; + } - /* End table */ - HTM_TABLE_End (); + /* End table */ + HTM_TABLE_End (); - /* End of left part */ - HTM_DIV_End (); - - /**************************** Right part **********************************/ - /* Check country map */ - MapImageExists = Cty_CheckIfCountryPhotoExists (&Gbl.Hierarchy.Node[Hie_CTY]); - - if (NumCtrsWithMap || MapImageExists) - { - /* Begin container */ - HTM_DIV_Begin ("class=\"HIE_CFG_RIGHT HIE_CFG_WIDTH\""); - - /* Country map */ - if (NumCtrsWithMap) - CtyCfg_Map (); - - /* Country map image */ - if (MapImageExists) - CtyCfg_MapImage (PrintView,PutLink); - - /* End container */ + /* End of left part */ HTM_DIV_End (); - } + + /**************************** Right part **********************************/ + /* Check country map */ + MapImageExists = Cty_CheckIfCountryPhotoExists (&Gbl.Hierarchy.Node[Hie_CTY]); + + if (NumCtrsWithMap || MapImageExists) + { + /* Begin container */ + HTM_DIV_Begin ("class=\"HIE_CFG_RIGHT HIE_CFG_WIDTH\""); + + /* Country map */ + if (NumCtrsWithMap) + CtyCfg_Map (); + + /* Country map image */ + if (MapImageExists) + CtyCfg_MapImage (ViewType,PutLink); + + /* End container */ + HTM_DIV_End (); + } /***** End box *****/ Box_BoxEnd (); @@ -319,7 +322,7 @@ static void CtyCfg_Map (void) /************* Show country map image in country configuration ***************/ /*****************************************************************************/ -static void CtyCfg_MapImage (bool PrintView,bool PutLink) +static void CtyCfg_MapImage (Vie_ViewType_t ViewType,bool PutLink) { char *MapAttribution = NULL; @@ -332,18 +335,19 @@ static void CtyCfg_MapImage (bool PrintView,bool PutLink) HTM_A_Begin ("href=\"%s\" target=\"_blank\"", Gbl.Hierarchy.Node[Hie_CTY].WWW); Cty_DrawCountryMap (&Gbl.Hierarchy.Node[Hie_CTY], - PrintView ? "COUNTRY_MAP_PRINT" : - "COUNTRY_MAP_SHOW"); + ViewType == Vie_VIEW ? "COUNTRY_MAP_SHOW" : + "COUNTRY_MAP_PRINT"); if (PutLink) HTM_A_End (); HTM_DIV_End (); /***** Map attribution *****/ - if (!PrintView && Cty_CheckIfICanEditCountries ()) + if (ViewType == Vie_VIEW && Cty_CheckIfICanEditCountries ()) { HTM_DIV_Begin ("class=\"CM\""); Frm_BeginForm (ActChgCtyMapAtt); - HTM_TEXTAREA_Begin ("id=\"AttributionArea\" name=\"Attribution\" rows=\"3\"" + HTM_TEXTAREA_Begin ("id=\"AttributionArea\" name=\"Attribution\"" + " rows=\"3\"" " onchange=\"this.form.submit();return false;\""); if (MapAttribution) HTM_Txt (MapAttribution); @@ -366,7 +370,7 @@ static void CtyCfg_MapImage (bool PrintView,bool PutLink) /****************** Show platform in country configuration *******************/ /*****************************************************************************/ -static void CtyCfg_Platform (bool PrintView) +static void CtyCfg_Platform (Vie_ViewType_t ViewType) { extern const char *Txt_System; @@ -378,7 +382,7 @@ static void CtyCfg_Platform (bool PrintView) /* Data */ HTM_TD_Begin ("class=\"LT DAT_%s\"",The_GetSuffix ()); - if (!PrintView) + if (ViewType == Vie_VIEW) { Frm_BeginFormGoTo (ActSeeSysInf); HTM_BUTTON_Submit_Begin (Str_BuildGoToTitle (Cfg_PLATFORM_SHORT_NAME), @@ -388,7 +392,7 @@ static void CtyCfg_Platform (bool PrintView) Ico_PutIcon ("swad64x64.png",Ico_UNCHANGED,Cfg_PLATFORM_FULL_NAME,"ICO20x20"); HTM_NBSP (); HTM_Txt (Cfg_PLATFORM_SHORT_NAME); - if (!PrintView) + if (ViewType == Vie_VIEW) { HTM_BUTTON_End (); Frm_EndForm (); @@ -430,9 +434,9 @@ static void CtyCfg_Name (bool PutLink) /************** Show country shortcut in country configuration ***************/ /*****************************************************************************/ -static void CtyCfg_Shortcut (bool PrintView) +static void CtyCfg_Shortcut (Vie_ViewType_t ViewType) { - HieCfg_Shortcut (PrintView,ParCod_Cty,Gbl.Hierarchy.Node[Hie_CTY].HieCod); + HieCfg_Shortcut (ViewType,ParCod_Cty,Gbl.Hierarchy.Node[Hie_CTY].HieCod); } /*****************************************************************************/ diff --git a/swad_course.c b/swad_course.c index bd760f11..b9289d8c 100644 --- a/swad_course.c +++ b/swad_course.c @@ -132,7 +132,7 @@ void Crs_ShowIntroduction (void) { /***** Course configuration *****/ HTM_DIV_Begin ("class=\"CM\""); - CrsCfg_Configuration (false); + CrsCfg_Configuration (Vie_VIEW); HTM_DIV_End (); /***** Course introduction *****/ diff --git a/swad_course_config.c b/swad_course_config.c index d090fd3f..9e0e7a5f 100644 --- a/swad_course_config.c +++ b/swad_course_config.c @@ -60,13 +60,13 @@ extern struct Globals Gbl; /*****************************************************************************/ static void CrsCfg_PutIconToPrint (__attribute__((unused)) void *Args); -static void CrsCfg_Degree (bool PrintView,bool PutForm); +static void CrsCfg_Degree (Vie_ViewType_t ViewType,bool PutForm); static void CrsCfg_FullName (bool PutForm); static void CrsCfg_ShrtName (bool PutForm); static void CrsCfg_Year (bool PutForm); static void CrsCfg_InstitutionalCode (bool PutForm); static void CrsCfg_InternalCode (void); -static void CrsCfg_Shortcut (bool PrintView); +static void CrsCfg_Shortcut (Vie_ViewType_t ViewType); static void CrsCfg_QR (void); static void CrsCfg_Indicators (void); @@ -74,7 +74,7 @@ static void CrsCfg_Indicators (void); /***************** Configuration of the current course ***********************/ /*****************************************************************************/ -void CrsCfg_Configuration (bool PrintView) +void CrsCfg_Configuration (Vie_ViewType_t ViewType) { extern const char *Hlp_COURSE_Information; bool PutLink; @@ -88,83 +88,86 @@ void CrsCfg_Configuration (bool PrintView) return; /***** Initializations *****/ - PutLink = !PrintView && Gbl.Hierarchy.Node[Hie_DEG].WWW[0]; - PutFormDeg = !PrintView && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM; - PutFormName = !PrintView && Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM; + PutLink = ViewType == Vie_VIEW && Gbl.Hierarchy.Node[Hie_DEG].WWW[0]; + PutFormDeg = ViewType == Vie_VIEW && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM; + PutFormName = ViewType == Vie_VIEW && Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM; PutFormYear = - PutFormInsCod = !PrintView && Gbl.Usrs.Me.Role.Logged >= Rol_TCH; + PutFormInsCod = ViewType == Vie_VIEW && Gbl.Usrs.Me.Role.Logged >= Rol_TCH; /***** Contextual menu *****/ - if (!PrintView) - if (Gbl.Usrs.Me.Role.Logged == Rol_GST || - Gbl.Usrs.Me.Role.Logged == Rol_USR) - { - Mnu_ContextMenuBegin (); - Enr_PutLinkToRequestSignUp (); // Request enrolment in the current course - Mnu_ContextMenuEnd (); - } + if (ViewType == Vie_VIEW && + (Gbl.Usrs.Me.Role.Logged == Rol_GST || + Gbl.Usrs.Me.Role.Logged == Rol_USR)) + { + Mnu_ContextMenuBegin (); + Enr_PutLinkToRequestSignUp (); // Request enrolment in the current course + Mnu_ContextMenuEnd (); + } /***** Begin box *****/ - if (PrintView) - Box_BoxBegin (NULL,NULL, - NULL,NULL, - NULL,Box_NOT_CLOSABLE); - else - Box_BoxBegin (NULL,NULL, - CrsCfg_PutIconToPrint,NULL, - Hlp_COURSE_Information,Box_NOT_CLOSABLE); + Box_BoxBegin (NULL,NULL, + ViewType == Vie_VIEW ? CrsCfg_PutIconToPrint : + NULL,NULL, + ViewType == Vie_VIEW ? Hlp_COURSE_Information : + NULL,Box_NOT_CLOSABLE); - /***** Title *****/ - HieCfg_Title (PutLink,Hie_CRS); + /***** Title *****/ + HieCfg_Title (PutLink,Hie_CRS); - /**************************** Left part ***********************************/ - HTM_DIV_Begin ("class=\"HIE_CFG_LEFT HIE_CFG_WIDTH\""); + /**************************** Left part ***********************************/ + HTM_DIV_Begin ("class=\"HIE_CFG_LEFT HIE_CFG_WIDTH\""); - /***** Begin table *****/ - HTM_TABLE_BeginWidePadding (2); + /***** Begin table *****/ + HTM_TABLE_BeginWidePadding (2); - /***** Degree *****/ - CrsCfg_Degree (PrintView,PutFormDeg); + /***** Degree *****/ + CrsCfg_Degree (ViewType,PutFormDeg); - /***** Course name *****/ - CrsCfg_FullName (PutFormName); - CrsCfg_ShrtName (PutFormName); + /***** Course name *****/ + CrsCfg_FullName (PutFormName); + CrsCfg_ShrtName (PutFormName); - /***** Course year *****/ - CrsCfg_Year (PutFormYear); + /***** Course year *****/ + CrsCfg_Year (PutFormYear); - if (!PrintView) - { - /***** Institutional code of the course *****/ - CrsCfg_InstitutionalCode (PutFormInsCod); + if (ViewType == Vie_VIEW) + { + /***** Institutional code of the course *****/ + CrsCfg_InstitutionalCode (PutFormInsCod); - /***** Internal code of the course *****/ - CrsCfg_InternalCode (); - } + /***** Internal code of the course *****/ + CrsCfg_InternalCode (); + } - /***** Shortcut to the couse *****/ - CrsCfg_Shortcut (PrintView); + /***** Shortcut to the couse *****/ + CrsCfg_Shortcut (ViewType); - if (PrintView) - /***** QR code with link to the course *****/ - CrsCfg_QR (); - else - { - /***** Number of users *****/ - HieCfg_NumUsrsInCrss (Hie_CRS,Gbl.Hierarchy.Node[Hie_CRS].HieCod,Rol_TCH); - HieCfg_NumUsrsInCrss (Hie_CRS,Gbl.Hierarchy.Node[Hie_CRS].HieCod,Rol_NET); - HieCfg_NumUsrsInCrss (Hie_CRS,Gbl.Hierarchy.Node[Hie_CRS].HieCod,Rol_STD); - HieCfg_NumUsrsInCrss (Hie_CRS,Gbl.Hierarchy.Node[Hie_CRS].HieCod,Rol_UNK); + switch (ViewType) + { + case Vie_VIEW: + /***** Number of users *****/ + HieCfg_NumUsrsInCrss (Hie_CRS,Gbl.Hierarchy.Node[Hie_CRS].HieCod,Rol_TCH); + HieCfg_NumUsrsInCrss (Hie_CRS,Gbl.Hierarchy.Node[Hie_CRS].HieCod,Rol_NET); + HieCfg_NumUsrsInCrss (Hie_CRS,Gbl.Hierarchy.Node[Hie_CRS].HieCod,Rol_STD); + HieCfg_NumUsrsInCrss (Hie_CRS,Gbl.Hierarchy.Node[Hie_CRS].HieCod,Rol_UNK); - /***** Indicators *****/ - CrsCfg_Indicators (); - } + /***** Indicators *****/ + CrsCfg_Indicators (); + break; + case Vie_PRINT: + /***** QR code with link to the course *****/ + CrsCfg_QR (); + break; + default: + Err_WrongTypeExit (); + break; + } - /***** End table *****/ - HTM_TABLE_End (); + /***** End table *****/ + HTM_TABLE_End (); - /***** End of left part *****/ - HTM_DIV_End (); + /***** End of left part *****/ + HTM_DIV_End (); /***** End box *****/ Box_BoxEnd (); @@ -186,14 +189,14 @@ static void CrsCfg_PutIconToPrint (__attribute__((unused)) void *Args) void CrsCfg_PrintConfiguration (void) { - CrsCfg_Configuration (true); + CrsCfg_Configuration (Vie_PRINT); } /*****************************************************************************/ /******************** Show degree in course configuration ********************/ /*****************************************************************************/ -static void CrsCfg_Degree (bool PrintView,bool PutForm) +static void CrsCfg_Degree (Vie_ViewType_t ViewType,bool PutForm) { extern const char *Par_CodeStr[]; extern const char *Txt_Degree; @@ -240,7 +243,7 @@ static void CrsCfg_Degree (bool PrintView,bool PutForm) } else // I can not move course to another degree { - if (!PrintView) + if (ViewType == Vie_VIEW) { Frm_BeginFormGoTo (ActSeeDegInf); ParCod_PutPar (ParCod_Deg,Gbl.Hierarchy.Node[Hie_DEG].HieCod); @@ -254,7 +257,7 @@ static void CrsCfg_Degree (bool PrintView,bool PutForm) 20,"LM"); HTM_NBSP (); HTM_Txt (Gbl.Hierarchy.Node[Hie_DEG].FullName); - if (!PrintView) + if (ViewType == Vie_VIEW) { HTM_BUTTON_End (); Frm_EndForm (); @@ -393,9 +396,9 @@ static void CrsCfg_InternalCode (void) /*************** Show course shortcut in course configuration ****************/ /*****************************************************************************/ -static void CrsCfg_Shortcut (bool PrintView) +static void CrsCfg_Shortcut (Vie_ViewType_t ViewType) { - HieCfg_Shortcut (PrintView,ParCod_Crs,Gbl.Hierarchy.Node[Hie_CRS].HieCod); + HieCfg_Shortcut (ViewType,ParCod_Crs,Gbl.Hierarchy.Node[Hie_CRS].HieCod); } /*****************************************************************************/ diff --git a/swad_course_config.h b/swad_course_config.h index 082cf147..a2e48bdf 100644 --- a/swad_course_config.h +++ b/swad_course_config.h @@ -33,7 +33,7 @@ /***************************** Public prototypes *****************************/ /*****************************************************************************/ -void CrsCfg_Configuration (bool PrintView); +void CrsCfg_Configuration (Vie_ViewType_t ViewType); void CrsCfg_PrintConfiguration (void); void CrsCfg_ChangeCrsDeg (void); diff --git a/swad_degree_config.c b/swad_degree_config.c index e1591427..25c0c3df 100644 --- a/swad_degree_config.c +++ b/swad_degree_config.c @@ -57,13 +57,13 @@ extern struct Globals Gbl; /**************************** Private prototypes *****************************/ /*****************************************************************************/ -static void DegCfg_Configuration (bool PrintView); +static void DegCfg_Configuration (Vie_ViewType_t ViewType); static void DegCfg_PutIconsToPrintAndUpload (__attribute__((unused)) void *Args); -static void DegCfg_Center (bool PrintView,bool PutForm); +static void DegCfg_Center (Vie_ViewType_t ViewType,bool PutForm); static void DegCfg_FullName (bool PutForm); static void DegCfg_ShrtName (bool PutForm); -static void DegCfg_WWW (bool PrintView,bool PutForm); -static void DegCfg_Shortcut (bool PrintView); +static void DegCfg_WWW (Vie_ViewType_t ViewType,bool PutForm); +static void DegCfg_Shortcut (Vie_ViewType_t ViewType); static void DegCfg_QR (void); static void DegCfg_NumCrss (void); @@ -73,7 +73,7 @@ static void DegCfg_NumCrss (void); void DegCfg_ShowConfiguration (void) { - DegCfg_Configuration (false); + DegCfg_Configuration (Vie_VIEW); /***** Show help to enrol me *****/ Hlp_ShowHelpWhatWouldYouLikeToDo (); @@ -85,14 +85,14 @@ void DegCfg_ShowConfiguration (void) void DegCfg_PrintConfiguration (void) { - DegCfg_Configuration (true); + DegCfg_Configuration (Vie_PRINT); } /*****************************************************************************/ /******************* Information of the current degree ***********************/ /*****************************************************************************/ -static void DegCfg_Configuration (bool PrintView) +static void DegCfg_Configuration (Vie_ViewType_t ViewType) { extern const char *Hlp_DEGREE_Information; bool PutLink; @@ -105,23 +105,20 @@ static void DegCfg_Configuration (bool PrintView) return; /***** Initializations *****/ - PutLink = !PrintView && Gbl.Hierarchy.Node[Hie_DEG].WWW[0]; - PutFormCtr = !PrintView && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM; - PutFormName = !PrintView && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM; - PutFormWWW = !PrintView && Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM; + PutLink = ViewType == Vie_VIEW && Gbl.Hierarchy.Node[Hie_DEG].WWW[0]; + PutFormCtr = ViewType == Vie_VIEW && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM; + PutFormName = ViewType == Vie_VIEW && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM; + PutFormWWW = ViewType == Vie_VIEW && Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM; /***** Begin box *****/ - if (PrintView) - Box_BoxBegin (NULL,NULL, - NULL,NULL, - NULL,Box_NOT_CLOSABLE); - else - Box_BoxBegin (NULL,NULL, - DegCfg_PutIconsToPrintAndUpload,NULL, - Hlp_DEGREE_Information,Box_NOT_CLOSABLE); + Box_BoxBegin (NULL,NULL, + ViewType == Vie_VIEW ? DegCfg_PutIconsToPrintAndUpload : + NULL,NULL, + ViewType == Vie_VIEW ? Hlp_DEGREE_Information : + NULL,Box_NOT_CLOSABLE); - /***** Title *****/ - HieCfg_Title (PutLink,Hie_DEG); + /***** Title *****/ + HieCfg_Title (PutLink,Hie_DEG); /**************************** Left part ***********************************/ HTM_DIV_Begin ("class=\"HIE_CFG_LEFT HIE_CFG_WIDTH\""); @@ -130,31 +127,36 @@ static void DegCfg_Configuration (bool PrintView) HTM_TABLE_BeginWidePadding (2); /***** Center *****/ - DegCfg_Center (PrintView,PutFormCtr); + DegCfg_Center (ViewType,PutFormCtr); /***** Degree name *****/ DegCfg_FullName (PutFormName); DegCfg_ShrtName (PutFormName); /***** Degree WWW *****/ - DegCfg_WWW (PrintView,PutFormWWW); + DegCfg_WWW (ViewType,PutFormWWW); /***** Shortcut to the degree *****/ - DegCfg_Shortcut (PrintView); + DegCfg_Shortcut (ViewType); - if (PrintView) - /***** QR code with link to the degree *****/ - DegCfg_QR (); - else + switch (ViewType) { - /***** Number of courses *****/ - DegCfg_NumCrss (); + case Vie_VIEW: + /***** Number of courses *****/ + DegCfg_NumCrss (); - /***** Number of users *****/ - HieCfg_NumUsrsInCrss (Hie_DEG,Gbl.Hierarchy.Node[Hie_DEG].HieCod,Rol_TCH); - HieCfg_NumUsrsInCrss (Hie_DEG,Gbl.Hierarchy.Node[Hie_DEG].HieCod,Rol_NET); - HieCfg_NumUsrsInCrss (Hie_DEG,Gbl.Hierarchy.Node[Hie_DEG].HieCod,Rol_STD); - HieCfg_NumUsrsInCrss (Hie_DEG,Gbl.Hierarchy.Node[Hie_DEG].HieCod,Rol_UNK); + /***** Number of users *****/ + HieCfg_NumUsrsInCrss (Hie_DEG,Gbl.Hierarchy.Node[Hie_DEG].HieCod,Rol_TCH); + HieCfg_NumUsrsInCrss (Hie_DEG,Gbl.Hierarchy.Node[Hie_DEG].HieCod,Rol_NET); + HieCfg_NumUsrsInCrss (Hie_DEG,Gbl.Hierarchy.Node[Hie_DEG].HieCod,Rol_STD); + HieCfg_NumUsrsInCrss (Hie_DEG,Gbl.Hierarchy.Node[Hie_DEG].HieCod,Rol_UNK); + break; + case Vie_PRINT: + /***** QR code with link to the degree *****/ + DegCfg_QR (); + break; + default: + Err_WrongTypeExit (); } /***** End table *****/ @@ -188,7 +190,7 @@ static void DegCfg_PutIconsToPrintAndUpload (__attribute__((unused)) void *Args) /******************** Show center in degree configuration ********************/ /*****************************************************************************/ -static void DegCfg_Center (bool PrintView,bool PutForm) +static void DegCfg_Center (Vie_ViewType_t ViewType,bool PutForm) { extern const char *Par_CodeStr[]; extern const char *Txt_Center; @@ -235,7 +237,7 @@ static void DegCfg_Center (bool PrintView,bool PutForm) } else // I can not move degree to another center { - if (!PrintView) + if (ViewType == Vie_VIEW) { Frm_BeginFormGoTo (ActSeeCtrInf); ParCod_PutPar (ParCod_Ctr,Gbl.Hierarchy.Node[Hie_CTR].HieCod); @@ -249,7 +251,7 @@ static void DegCfg_Center (bool PrintView,bool PutForm) 20,"LM"); HTM_NBSP (); HTM_Txt (Gbl.Hierarchy.Node[Hie_CTR].FullName); - if (!PrintView) + if (ViewType == Vie_VIEW) { HTM_BUTTON_End (); Frm_EndForm (); @@ -282,18 +284,18 @@ static void DegCfg_ShrtName (bool PutForm) /***************** Show degree WWW in degree configuration *******************/ /*****************************************************************************/ -static void DegCfg_WWW (bool PrintView,bool PutForm) +static void DegCfg_WWW (Vie_ViewType_t ViewType,bool PutForm) { - HieCfg_WWW (PrintView,PutForm,ActChgDegWWWCfg,Gbl.Hierarchy.Node[Hie_DEG].WWW); + HieCfg_WWW (ViewType,PutForm,ActChgDegWWWCfg,Gbl.Hierarchy.Node[Hie_DEG].WWW); } /*****************************************************************************/ /*************** Show degree shortcut in degree configuration ****************/ /*****************************************************************************/ -static void DegCfg_Shortcut (bool PrintView) +static void DegCfg_Shortcut (Vie_ViewType_t ViewType) { - HieCfg_Shortcut (PrintView,ParCod_Deg,Gbl.Hierarchy.Node[Hie_DEG].HieCod); + HieCfg_Shortcut (ViewType,ParCod_Deg,Gbl.Hierarchy.Node[Hie_DEG].HieCod); } /*****************************************************************************/ diff --git a/swad_exam_print.c b/swad_exam_print.c index 131a2b47..0dd9bb96 100644 --- a/swad_exam_print.c +++ b/swad_exam_print.c @@ -581,7 +581,7 @@ static void ExaPrn_ShowExamPrintToFillIt (struct Exa_Exams *Exams, /***** Heading *****/ /* Institution, degree and course */ - Lay_WriteHeaderClassPhoto (false,false); + Lay_WriteHeaderClassPhoto (Vie_VIEW,false); /***** Show user and time *****/ HTM_TABLE_BeginWideMarginPadding (10); diff --git a/swad_exam_result.c b/swad_exam_result.c index 202a598c..1e041766 100644 --- a/swad_exam_result.c +++ b/swad_exam_result.c @@ -1348,7 +1348,7 @@ static void ExaRes_ShowExamResult (const struct Exa_Exam *Exam, Hlp_ASSESSMENT_Exams_results,Box_NOT_CLOSABLE); /***** Header *****/ - Lay_WriteHeaderClassPhoto (false,false); + Lay_WriteHeaderClassPhoto (Vie_VIEW,false); /***** Check user data *****/ /* Get data of the user who answered the exam print */ diff --git a/swad_hierarchy_config.c b/swad_hierarchy_config.c index 53e9d8d3..f2f2dd0f 100644 --- a/swad_hierarchy_config.c +++ b/swad_hierarchy_config.c @@ -147,7 +147,7 @@ void HieCfg_Name (bool PutForm,Hie_Level_t Level,Nam_ShrtOrFullName_t ShrtOrFull /************************* Show web in configuration *************************/ /*****************************************************************************/ -void HieCfg_WWW (bool PrintView,bool PutForm,Act_Action_t NextAction, +void HieCfg_WWW (Vie_ViewType_t ViewType,bool PutForm,Act_Action_t NextAction, const char WWW[Cns_MAX_BYTES_WWW + 1]) { extern const char *Txt_Web; @@ -175,12 +175,12 @@ void HieCfg_WWW (bool PrintView,bool PutForm,Act_Action_t NextAction, else // I can not change web { HTM_DIV_Begin ("class=\"EXTERNAL_WWW_FULL\""); - if (!PrintView) + if (ViewType == Vie_VIEW) HTM_A_Begin ("href=\"%s\" target=\"_blank\"" " class=\"DAT_%s\"", WWW,The_GetSuffix ()); HTM_Txt (WWW); - if (!PrintView) + if (ViewType == Vie_VIEW) HTM_A_End (); HTM_DIV_End (); } @@ -193,7 +193,7 @@ void HieCfg_WWW (bool PrintView,bool PutForm,Act_Action_t NextAction, /********************** Show shortcut in configuration ***********************/ /*****************************************************************************/ -void HieCfg_Shortcut (bool PrintView,ParCod_Param_t ParCode,long HieCod) +void HieCfg_Shortcut (Vie_ViewType_t ViewType,ParCod_Param_t ParCode,long HieCod) { extern const char *Par_CodeStr[]; extern const char *Txt_Shortcut; @@ -206,7 +206,7 @@ void HieCfg_Shortcut (bool PrintView,ParCod_Param_t ParCode,long HieCod) /* Data */ HTM_TD_Begin ("class=\"LB DAT_%s\"",The_GetSuffix ()); - if (!PrintView) + if (ViewType == Vie_VIEW) { if (ParCode == ParCod_None) HTM_A_Begin ("href=\"%s/\" target=\"_blank\" class=\"DAT_%s\"", @@ -226,7 +226,7 @@ void HieCfg_Shortcut (bool PrintView,ParCod_Param_t ParCode,long HieCod) HTM_TxtF ("%s/?%s=%ld", Cfg_URL_SWAD_CGI, Par_CodeStr[ParCode],HieCod); - if (!PrintView) + if (ViewType == Vie_VIEW) HTM_A_End (); HTM_TD_End (); diff --git a/swad_hierarchy_config.h b/swad_hierarchy_config.h index 89838035..08bd4bb2 100644 --- a/swad_hierarchy_config.h +++ b/swad_hierarchy_config.h @@ -35,9 +35,9 @@ void HieCfg_Title (bool PutLink,Hie_Level_t LogoScope); void HieCfg_Name (bool PutForm,Hie_Level_t Level,Nam_ShrtOrFullName_t ShrtOrFull); -void HieCfg_WWW (bool PrintView,bool PutForm,Act_Action_t NextAction, +void HieCfg_WWW (Vie_ViewType_t ViewType,bool PutForm,Act_Action_t NextAction, const char WWW[Cns_MAX_BYTES_WWW + 1]); -void HieCfg_Shortcut (bool PrintView,ParCod_Param_t ParCode,long HieCod); +void HieCfg_Shortcut (Vie_ViewType_t ViewType,ParCod_Param_t ParCode,long HieCod); void HieCfg_NumCtrs (unsigned NumCtrs,bool PutForm); void HieCfg_NumCtrsWithMap (unsigned NumCtrs,unsigned NumCtrsWithMap); void HieCfg_QR (ParCod_Param_t ParCode,long HieCod); diff --git a/swad_info.c b/swad_info.c index 8d691fc4..da9afc44 100644 --- a/swad_info.c +++ b/swad_info.c @@ -1441,7 +1441,7 @@ static bool Inf_CheckAndShowPlainTxt (void) if (Gbl.Crs.Info.Type == Inf_INTRODUCTION || Gbl.Crs.Info.Type == Inf_TEACHING_GUIDE) - Lay_WriteHeaderClassPhoto (false,false); + Lay_WriteHeaderClassPhoto (Vie_VIEW,false); HTM_DIV_Begin ("class=\"LM DAT_%s\"",The_GetSuffix ()); @@ -1531,7 +1531,7 @@ static bool Inf_CheckAndShowRichTxt (void) if (Gbl.Crs.Info.Type == Inf_INTRODUCTION || Gbl.Crs.Info.Type == Inf_TEACHING_GUIDE) - Lay_WriteHeaderClassPhoto (false,false); + Lay_WriteHeaderClassPhoto (Vie_VIEW,false); HTM_DIV_Begin ("id=\"crs_info\" class=\"LM CRS_INFO_%s\"", The_GetSuffix ()); @@ -1664,7 +1664,7 @@ void Inf_EditPlainTxtInfo (void) if (Gbl.Crs.Info.Type == Inf_INTRODUCTION || Gbl.Crs.Info.Type == Inf_TEACHING_GUIDE) - Lay_WriteHeaderClassPhoto (false,false); + Lay_WriteHeaderClassPhoto (Vie_VIEW,false); /***** Get info text from database *****/ Inf_GetInfoTxtFromDB (Gbl.Hierarchy.Node[Hie_CRS].HieCod,Gbl.Crs.Info.Type, @@ -1732,7 +1732,7 @@ void Inf_EditRichTxtInfo (void) if (Gbl.Crs.Info.Type == Inf_INTRODUCTION || Gbl.Crs.Info.Type == Inf_TEACHING_GUIDE) - Lay_WriteHeaderClassPhoto (false,false); + Lay_WriteHeaderClassPhoto (Vie_VIEW,false); /***** Get info text from database *****/ Inf_GetInfoTxtFromDB (Gbl.Hierarchy.Node[Hie_CRS].HieCod,Gbl.Crs.Info.Type, diff --git a/swad_institution_config.c b/swad_institution_config.c index b6286338..b1a9b377 100644 --- a/swad_institution_config.c +++ b/swad_institution_config.c @@ -62,14 +62,14 @@ extern struct Globals Gbl; /***************************** Private prototypes ****************************/ /*****************************************************************************/ -static void InsCfg_Configuration (bool PrintView); +static void InsCfg_Configuration (Vie_ViewType_t ViewType); static void InsCfg_PutIconsToPrintAndUpload (__attribute__((unused)) void *Args); static void InsCfg_Map (void); -static void InsCfg_Country (bool PrintView,bool PutForm); +static void InsCfg_Country (Vie_ViewType_t ViewType,bool PutForm); static void InsCfg_FullName (bool PutForm); static void InsCfg_ShrtName (bool PutForm); -static void InsCfg_WWW (bool PrintView,bool PutForm); -static void InsCfg_Shortcut (bool PrintView); +static void InsCfg_WWW (Vie_ViewType_t ViewType,bool PutForm); +static void InsCfg_Shortcut (Vie_ViewType_t ViewType); static void InsCfg_QR (void); static void InsCfg_NumUsrs (void); static void InsCfg_NumDegs (void); @@ -82,7 +82,7 @@ static void InsCfg_NumDpts (void); void InsCfg_ShowConfiguration (void) { - InsCfg_Configuration (false); + InsCfg_Configuration (Vie_VIEW); /***** Show help to enrol me *****/ Hlp_ShowHelpWhatWouldYouLikeToDo (); @@ -94,14 +94,14 @@ void InsCfg_ShowConfiguration (void) void InsCfg_PrintConfiguration (void) { - InsCfg_Configuration (true); + InsCfg_Configuration (Vie_PRINT); } /*****************************************************************************/ /***************** Information of the current institution ********************/ /*****************************************************************************/ -static void InsCfg_Configuration (bool PrintView) +static void InsCfg_Configuration (Vie_ViewType_t ViewType) { extern const char *Hlp_INSTITUTION_Information; bool PutLink; @@ -116,90 +116,93 @@ static void InsCfg_Configuration (bool PrintView) return; /***** Initializations *****/ - PutLink = !PrintView && Gbl.Hierarchy.Node[Hie_INS].WWW[0]; + PutLink = ViewType == Vie_VIEW && Gbl.Hierarchy.Node[Hie_INS].WWW[0]; PutFormCty = - PutFormName = !PrintView && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM; - PutFormWWW = !PrintView && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM; + PutFormName = ViewType == Vie_VIEW && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM; + PutFormWWW = ViewType == Vie_VIEW && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM; /***** Begin box *****/ - if (PrintView) - Box_BoxBegin (NULL,NULL, - NULL,NULL, - NULL,Box_NOT_CLOSABLE); - else - Box_BoxBegin (NULL,NULL, - InsCfg_PutIconsToPrintAndUpload,NULL, - Hlp_INSTITUTION_Information,Box_NOT_CLOSABLE); + Box_BoxBegin (NULL,NULL, + ViewType == Vie_VIEW ? InsCfg_PutIconsToPrintAndUpload : + NULL,NULL, + ViewType == Vie_VIEW ? Hlp_INSTITUTION_Information : + NULL,Box_NOT_CLOSABLE); + /***** Title *****/ + HieCfg_Title (PutLink,Hie_INS); - /***** Title *****/ - HieCfg_Title (PutLink,Hie_INS); + /**************************** Left part ***********************************/ + HTM_DIV_Begin ("class=\"HIE_CFG_LEFT HIE_CFG_WIDTH\""); - /**************************** Left part ***********************************/ - HTM_DIV_Begin ("class=\"HIE_CFG_LEFT HIE_CFG_WIDTH\""); + /***** Begin table *****/ + HTM_TABLE_BeginWidePadding (2); - /***** Begin table *****/ - HTM_TABLE_BeginWidePadding (2); + /***** Country *****/ + InsCfg_Country (ViewType,PutFormCty); - /***** Country *****/ - InsCfg_Country (PrintView,PutFormCty); + /***** Institution name *****/ + InsCfg_FullName (PutFormName); + InsCfg_ShrtName (PutFormName); - /***** Institution name *****/ - InsCfg_FullName (PutFormName); - InsCfg_ShrtName (PutFormName); + /***** Institution WWW *****/ + InsCfg_WWW (ViewType,PutFormWWW); - /***** Institution WWW *****/ - InsCfg_WWW (PrintView,PutFormWWW); + /***** Shortcut to the institution *****/ + InsCfg_Shortcut (ViewType); - /***** Shortcut to the institution *****/ - InsCfg_Shortcut (PrintView); + NumCtrsWithMap = Ctr_GetCachedNumCtrsWithMapInIns (Gbl.Hierarchy.Node[Hie_INS].HieCod); - NumCtrsWithMap = Ctr_GetCachedNumCtrsWithMapInIns (Gbl.Hierarchy.Node[Hie_INS].HieCod); - if (PrintView) - /***** QR code with link to the institution *****/ - InsCfg_QR (); - else - { - NumCtrs = Hie_GetCachedNumNodesInHieLvl (Hie_CTR, // Number of centers... - Hie_INS, // ...in institution - Gbl.Hierarchy.Node[Hie_INS].HieCod); + switch (ViewType) + { + case Vie_VIEW: + NumCtrs = Hie_GetCachedNumNodesInHieLvl (Hie_CTR, // Number of centers... + Hie_INS, // ...in institution + Gbl.Hierarchy.Node[Hie_INS].HieCod); - /***** Number of users who claim to belong to this institution, - number of centers, - number of degrees, - number of courses, - number of departments *****/ - InsCfg_NumUsrs (); - HieCfg_NumCtrs (NumCtrs, - true); // Put form - HieCfg_NumCtrsWithMap (NumCtrs,NumCtrsWithMap); - InsCfg_NumDegs (); - InsCfg_NumCrss (); - InsCfg_NumDpts (); + /***** Number of users who claim to belong to this institution, + number of centers, + number of degrees, + number of courses, + number of departments *****/ + InsCfg_NumUsrs (); + HieCfg_NumCtrs (NumCtrs, + true); // Put form + HieCfg_NumCtrsWithMap (NumCtrs,NumCtrsWithMap); + InsCfg_NumDegs (); + InsCfg_NumCrss (); + InsCfg_NumDpts (); - /***** Number of users in courses of this institution *****/ - HieCfg_NumUsrsInCrss (Hie_INS,Gbl.Hierarchy.Node[Hie_INS].HieCod,Rol_TCH); - HieCfg_NumUsrsInCrss (Hie_INS,Gbl.Hierarchy.Node[Hie_INS].HieCod,Rol_NET); - HieCfg_NumUsrsInCrss (Hie_INS,Gbl.Hierarchy.Node[Hie_INS].HieCod,Rol_STD); - HieCfg_NumUsrsInCrss (Hie_INS,Gbl.Hierarchy.Node[Hie_INS].HieCod,Rol_UNK); - } + /***** Number of users in courses of this institution *****/ + HieCfg_NumUsrsInCrss (Hie_INS,Gbl.Hierarchy.Node[Hie_INS].HieCod,Rol_TCH); + HieCfg_NumUsrsInCrss (Hie_INS,Gbl.Hierarchy.Node[Hie_INS].HieCod,Rol_NET); + HieCfg_NumUsrsInCrss (Hie_INS,Gbl.Hierarchy.Node[Hie_INS].HieCod,Rol_STD); + HieCfg_NumUsrsInCrss (Hie_INS,Gbl.Hierarchy.Node[Hie_INS].HieCod,Rol_UNK); + break; + case Vie_PRINT: + /***** QR code with link to the institution *****/ + InsCfg_QR (); + break; + default: + Err_WrongTypeExit (); + break; + } - /***** End table *****/ - HTM_TABLE_End (); - - /***** End of left part *****/ - HTM_DIV_End (); - - /**************************** Right part **********************************/ - if (NumCtrsWithMap) - { - HTM_DIV_Begin ("class=\"HIE_CFG_RIGHT HIE_CFG_WIDTH\""); - - /***** Institution map *****/ - InsCfg_Map (); + /***** End table *****/ + HTM_TABLE_End (); + /***** End of left part *****/ HTM_DIV_End (); - } + + /**************************** Right part **********************************/ + if (NumCtrsWithMap) + { + HTM_DIV_Begin ("class=\"HIE_CFG_RIGHT HIE_CFG_WIDTH\""); + + /***** Institution map *****/ + InsCfg_Map (); + + HTM_DIV_End (); + } /***** End box *****/ Box_BoxEnd (); @@ -294,7 +297,7 @@ static void InsCfg_Map (void) /***************** Show country in institution configuration *****************/ /*****************************************************************************/ -static void InsCfg_Country (bool PrintView,bool PutForm) +static void InsCfg_Country (Vie_ViewType_t ViewType,bool PutForm) { extern const char *Par_CodeStr[]; extern const char *Txt_Country; @@ -338,7 +341,7 @@ static void InsCfg_Country (bool PrintView,bool PutForm) } else // I can not move institution to another country { - if (!PrintView) + if (ViewType == Vie_VIEW) { Frm_BeginFormGoTo (ActSeeCtyInf); ParCod_PutPar (ParCod_Cty,Gbl.Hierarchy.Node[Hie_CTY].HieCod); @@ -349,7 +352,7 @@ static void InsCfg_Country (bool PrintView,bool PutForm) Cty_DrawCountryMap (&Gbl.Hierarchy.Node[Hie_CTY],"COUNTRY_MAP_TINY"); HTM_NBSP (); HTM_Txt (Gbl.Hierarchy.Node[Hie_CTY].FullName); - if (!PrintView) + if (ViewType == Vie_VIEW) { HTM_BUTTON_End (); Frm_EndForm (); @@ -384,18 +387,18 @@ static void InsCfg_ShrtName (bool PutForm) /************ Show institution WWW in institution configuration **************/ /*****************************************************************************/ -static void InsCfg_WWW (bool PrintView,bool PutForm) +static void InsCfg_WWW (Vie_ViewType_t ViewType,bool PutForm) { - HieCfg_WWW (PrintView,PutForm,ActChgInsWWWCfg,Gbl.Hierarchy.Node[Hie_INS].WWW); + HieCfg_WWW (ViewType,PutForm,ActChgInsWWWCfg,Gbl.Hierarchy.Node[Hie_INS].WWW); } /*****************************************************************************/ /********** Show institution shortcut in institution configuration ***********/ /*****************************************************************************/ -static void InsCfg_Shortcut (bool PrintView) +static void InsCfg_Shortcut (Vie_ViewType_t ViewType) { - HieCfg_Shortcut (PrintView,ParCod_Ins,Gbl.Hierarchy.Node[Hie_INS].HieCod); + HieCfg_Shortcut (ViewType,ParCod_Ins,Gbl.Hierarchy.Node[Hie_INS].HieCod); } /*****************************************************************************/ diff --git a/swad_layout.c b/swad_layout.c index edc16569..be776c27 100644 --- a/swad_layout.c +++ b/swad_layout.c @@ -1462,7 +1462,7 @@ static void Lay_WriteFootFromHTMLFile (void) /****** Write header and footer of the class photo or academic calendar ******/ /*****************************************************************************/ -void Lay_WriteHeaderClassPhoto (bool PrintView,bool DrawingClassPhoto) +void Lay_WriteHeaderClassPhoto (Vie_ViewType_t ViewType,bool DrawingClassPhoto) { struct Hie_Node Hie[Hie_NUM_LEVELS]; @@ -1492,13 +1492,13 @@ void Lay_WriteHeaderClassPhoto (bool PrintView,bool DrawingClassPhoto) HTM_TD_Begin ("class=\"LT\" style=\"width:60px;\""); if (Hie[Hie_INS].HieCod > 0) { - if (!PrintView) + if (ViewType == Vie_VIEW) HTM_A_Begin ("href=\"%s\" target=\"_blank\"",Hie[Hie_INS].WWW); Lgo_DrawLogo (Hie_INS, Hie[Hie_INS].HieCod, Hie[Hie_INS].ShrtName, 40,NULL); - if (!PrintView) + if (ViewType == Vie_VIEW) HTM_A_End (); } HTM_TD_End (); @@ -1508,24 +1508,24 @@ void Lay_WriteHeaderClassPhoto (bool PrintView,bool DrawingClassPhoto) The_GetSuffix ()); if (Hie[Hie_INS].HieCod > 0) { - if (!PrintView) + if (ViewType == Vie_VIEW) HTM_A_Begin ("href=\"%s\" target=\"_blank\"" " class=\"CLASSPHOTO_TITLE CLASSPHOTO_%s\"", Hie[Hie_INS].WWW,The_GetSuffix ()); HTM_Txt (Hie[Hie_INS].FullName); - if (!PrintView) + if (ViewType == Vie_VIEW) HTM_A_End (); } if (Hie[Hie_DEG].HieCod > 0) { if (Hie[Hie_INS].HieCod > 0) HTM_Txt (" - "); - if (!PrintView) + if (ViewType == Vie_VIEW) HTM_A_Begin ("href=\"%s\" target=\"_blank\"" " class=\"CLASSPHOTO_TITLE CLASSPHOTO_%s\"", Hie[Hie_DEG].WWW,The_GetSuffix ()); HTM_Txt (Hie[Hie_DEG].FullName); - if (!PrintView) + if (ViewType == Vie_VIEW) HTM_A_End (); } HTM_BR (); @@ -1544,7 +1544,7 @@ void Lay_WriteHeaderClassPhoto (bool PrintView,bool DrawingClassPhoto) HTM_TD_Begin ("class=\"RT\" style=\"width:60px;\""); if (Hie[Hie_DEG].HieCod > 0) { - if (!PrintView) + if (ViewType == Vie_VIEW) HTM_A_Begin ("href=\"%s\" target=\"_blank\"" " class=\"CLASSPHOTO_TITLE CLASSPHOTO_%s\"", Hie[Hie_DEG].WWW,The_GetSuffix ()); @@ -1552,7 +1552,7 @@ void Lay_WriteHeaderClassPhoto (bool PrintView,bool DrawingClassPhoto) Hie[Hie_DEG].HieCod, Hie[Hie_DEG].ShrtName, 40,NULL); - if (!PrintView) + if (ViewType == Vie_VIEW) HTM_A_End (); } HTM_TD_End (); diff --git a/swad_layout.h b/swad_layout.h index 0df631d8..69d26f1c 100644 --- a/swad_layout.h +++ b/swad_layout.h @@ -29,6 +29,7 @@ #include "swad_action.h" #include "swad_icon.h" +#include "swad_view_edit.h" /*****************************************************************************/ /****************************** Public constants *****************************/ @@ -67,7 +68,7 @@ void Lay_WriteAboutZone (void); void Lay_RefreshNotifsAndConnected (void); void Lay_RefreshLastClicks (void); -void Lay_WriteHeaderClassPhoto (bool PrintView,bool DrawingClassPhoto); +void Lay_WriteHeaderClassPhoto (Vie_ViewType_t ViewType,bool DrawingClassPhoto); void Lay_AdvertisementMobile (void); diff --git a/swad_match_result.c b/swad_match_result.c index 3c9b8aaf..44395b96 100644 --- a/swad_match_result.c +++ b/swad_match_result.c @@ -1097,7 +1097,7 @@ void MchRes_ShowOneMchResult (void) Box_BoxBegin (NULL,Match.Title, NULL,NULL, Hlp_ASSESSMENT_Games_results,Box_NOT_CLOSABLE); - Lay_WriteHeaderClassPhoto (false,false); + Lay_WriteHeaderClassPhoto (Vie_VIEW,false); /***** Begin table *****/ HTM_TABLE_BeginWideMarginPadding (10); diff --git a/swad_program.c b/swad_program.c index d33c3db0..e87e645b 100644 --- a/swad_program.c +++ b/swad_program.c @@ -130,7 +130,7 @@ static void Prg_WriteRowItem (Prg_ListingType_t ListingType, long SelectedRscCod); static void Prg_PutIconToContractOrExpandItem (struct Prg_Item *Item, ConExp_ContractedOrExpanded_t ContractedOrExpanded, - VieEdi_ViewOrEdit_t ViewingOrEditing); + Vie_ViewType_t ViewType); static void Prg_WriteItemText (long ItmCod,HidVis_HiddenOrVisible_t HiddenOrVisible); static void Prg_WriteRowToCreateItem (long ParentItmCod,unsigned FormLevel); static void Prg_SetTitleClass (char **TitleClass,unsigned Level); @@ -473,20 +473,20 @@ static void Prg_WriteRowItem (Prg_ListingType_t ListingType, { extern const char *HidVis_PrgClass[HidVis_NUM_HIDDEN_VISIBLE]; static unsigned UniqueId = 0; - static VieEdi_ViewOrEdit_t ViewingOrEditingProgram[Prg_NUM_LISTING_TYPES] = + static Vie_ViewType_t ViewingOrEditingProgram[Prg_NUM_LISTING_TYPES] = { - [Prg_PRINT ] = VieEdi_VIEW, - [Prg_VIEW ] = VieEdi_VIEW, - [Prg_EDIT_ITEMS ] = VieEdi_EDIT, - [Prg_FORM_NEW_END_ITEM ] = VieEdi_EDIT, - [Prg_FORM_NEW_CHILD_ITEM ] = VieEdi_EDIT, - [Prg_FORM_EDIT_ITEM ] = VieEdi_EDIT, - [Prg_END_EDIT_ITEM ] = VieEdi_EDIT, - [Prg_RECEIVE_ITEM ] = VieEdi_EDIT, - [Prg_EDIT_RESOURCES ] = VieEdi_EDIT, - [Prg_EDIT_RESOURCE_LINK ] = VieEdi_EDIT, - [Prg_CHANGE_RESOURCE_LINK] = VieEdi_EDIT, - [Prg_END_EDIT_RES ] = VieEdi_EDIT, + [Prg_PRINT ] = Vie_VIEW, + [Prg_VIEW ] = Vie_VIEW, + [Prg_EDIT_ITEMS ] = Vie_EDIT, + [Prg_FORM_NEW_END_ITEM ] = Vie_EDIT, + [Prg_FORM_NEW_CHILD_ITEM ] = Vie_EDIT, + [Prg_FORM_EDIT_ITEM ] = Vie_EDIT, + [Prg_END_EDIT_ITEM ] = Vie_EDIT, + [Prg_RECEIVE_ITEM ] = Vie_EDIT, + [Prg_EDIT_RESOURCES ] = Vie_EDIT, + [Prg_EDIT_RESOURCE_LINK ] = Vie_EDIT, + [Prg_CHANGE_RESOURCE_LINK] = Vie_EDIT, + [Prg_END_EDIT_RES ] = Vie_EDIT, }; static const char *RowSpan[ConExp_NUM_CONTRACTED_EXPANDED] = { @@ -513,7 +513,7 @@ static void Prg_WriteRowItem (Prg_ListingType_t ListingType, break; } - if (ViewingOrEditingProgram[ListingType] == VieEdi_EDIT || + if (ViewingOrEditingProgram[ListingType] == Vie_EDIT || HiddenOrVisible == HidVis_VISIBLE) { /***** Increase number in level *****/ @@ -548,7 +548,7 @@ static void Prg_WriteRowItem (Prg_ListingType_t ListingType, HTM_TD_End (); /* Forms to remove/edit this program item */ - if (ViewingOrEditingProgram[ListingType] == VieEdi_EDIT) + if (ViewingOrEditingProgram[ListingType] == Vie_EDIT) { HTM_TD_Begin ("class=\"PRG_COL1 LT %s\"%s", The_GetColorRows (),RowSpan[ContractedOrExpanded]); @@ -670,14 +670,14 @@ static void Prg_WriteRowItem (Prg_ListingType_t ListingType, static void Prg_PutIconToContractOrExpandItem (struct Prg_Item *Item, ConExp_ContractedOrExpanded_t ContractedOrExpanded, - VieEdi_ViewOrEdit_t ViewingOrEditing) + Vie_ViewType_t ViewType) { - static const Act_Action_t NextAction[ConExp_NUM_CONTRACTED_EXPANDED][2] = + static const Act_Action_t NextAction[ConExp_NUM_CONTRACTED_EXPANDED][Vie_NUM_VIEW_TYPES] = { - [ConExp_CONTRACTED][VieEdi_VIEW] = ActExpSeePrgItm, // Contracted, Not editing ==> action to expand - [ConExp_CONTRACTED][VieEdi_EDIT] = ActExpEdiPrgItm, // Contracted, Editing ==> action to expand - [ConExp_EXPANDED ][VieEdi_VIEW] = ActConSeePrgItm, // Expanded , Not editing ==> action to contract - [ConExp_EXPANDED ][VieEdi_EDIT] = ActConEdiPrgItm, // Expanded , Editing ==> action to contract + [ConExp_CONTRACTED][Vie_VIEW] = ActExpSeePrgItm, // Contracted, Not editing ==> action to expand + [ConExp_CONTRACTED][Vie_EDIT] = ActExpEdiPrgItm, // Contracted, Editing ==> action to expand + [ConExp_EXPANDED ][Vie_VIEW] = ActConSeePrgItm, // Expanded , Not editing ==> action to contract + [ConExp_EXPANDED ][Vie_EDIT] = ActConEdiPrgItm, // Expanded , Editing ==> action to contract }; static void (*PutContextualIcon[ConExp_NUM_CONTRACTED_EXPANDED]) (const Act_Action_t NextAction,const char *Anchor, void (*FuncPars) (void *Args),void *Args) = @@ -687,7 +687,7 @@ static void Prg_PutIconToContractOrExpandItem (struct Prg_Item *Item, }; /***** Icon to hide/unhide program item *****/ - PutContextualIcon[ContractedOrExpanded] (NextAction[ContractedOrExpanded][ViewingOrEditing], + PutContextualIcon[ContractedOrExpanded] (NextAction[ContractedOrExpanded][ViewType], Prg_HIGHLIGHTED_SECTION_ID, Prg_PutParItmCod,&Item->Hierarchy.ItmCod); } diff --git a/swad_program_resource.c b/swad_program_resource.c index ca06ea06..bfd97162 100644 --- a/swad_program_resource.c +++ b/swad_program_resource.c @@ -81,10 +81,10 @@ static void PrgRsc_WriteRowViewResource (unsigned NumRsc, const struct Prg_Item *Item); static void PrgRsc_WriteRowEditResource (unsigned NumRsc,unsigned NumResources, struct Prg_Item *Item, - VieEdi_ViewOrEdit_t ViewOrEditLink); + Vie_ViewType_t LinkViewType); static void PrgRsc_WriteRowNewResource (unsigned NumResources, struct Prg_Item *Item, - VieEdi_ViewOrEdit_t ViewOrEditLink); + Vie_ViewType_t LinkViewType); static void PrgRsc_PutFormsToRemEditOneResource (struct Prg_Item *Item, unsigned NumRsc, unsigned NumResources); @@ -155,42 +155,42 @@ void PrgRsc_ListItemResources (Prg_ListingType_t ListingType, MYSQL_RES *mysql_res; unsigned NumRsc; unsigned NumResources; - VieEdi_ViewOrEdit_t ViewingOrEditingResourcesOfThisItem; + Vie_ViewType_t ViewingOrEditingResourcesOfThisItem; char *Title; - static VieEdi_ViewOrEdit_t ViewingOrEditing[Prg_NUM_LISTING_TYPES] = + static Vie_ViewType_t ViewingOrEditing[Prg_NUM_LISTING_TYPES] = { - [Prg_PRINT ] = VieEdi_VIEW, - [Prg_VIEW ] = VieEdi_VIEW, - [Prg_EDIT_ITEMS ] = VieEdi_EDIT, - [Prg_FORM_NEW_END_ITEM ] = VieEdi_EDIT, - [Prg_FORM_NEW_CHILD_ITEM ] = VieEdi_EDIT, - [Prg_FORM_EDIT_ITEM ] = VieEdi_EDIT, - [Prg_END_EDIT_ITEM ] = VieEdi_EDIT, - [Prg_RECEIVE_ITEM ] = VieEdi_EDIT, - [Prg_EDIT_RESOURCES ] = VieEdi_EDIT, - [Prg_EDIT_RESOURCE_LINK ] = VieEdi_EDIT, - [Prg_CHANGE_RESOURCE_LINK] = VieEdi_EDIT, - [Prg_END_EDIT_RES ] = VieEdi_EDIT, + [Prg_PRINT ] = Vie_VIEW, + [Prg_VIEW ] = Vie_VIEW, + [Prg_EDIT_ITEMS ] = Vie_EDIT, + [Prg_FORM_NEW_END_ITEM ] = Vie_EDIT, + [Prg_FORM_NEW_CHILD_ITEM ] = Vie_EDIT, + [Prg_FORM_EDIT_ITEM ] = Vie_EDIT, + [Prg_END_EDIT_ITEM ] = Vie_EDIT, + [Prg_RECEIVE_ITEM ] = Vie_EDIT, + [Prg_EDIT_RESOURCES ] = Vie_EDIT, + [Prg_EDIT_RESOURCE_LINK ] = Vie_EDIT, + [Prg_CHANGE_RESOURCE_LINK] = Vie_EDIT, + [Prg_END_EDIT_RES ] = Vie_EDIT, }; - static VieEdi_ViewOrEdit_t ViewingOrEditingResources[Prg_NUM_LISTING_TYPES] = + static Vie_ViewType_t ViewingOrEditingResources[Prg_NUM_LISTING_TYPES] = { - [Prg_PRINT ] = VieEdi_VIEW, - [Prg_VIEW ] = VieEdi_VIEW, - [Prg_EDIT_ITEMS ] = VieEdi_VIEW, - [Prg_FORM_NEW_END_ITEM ] = VieEdi_VIEW, - [Prg_FORM_NEW_CHILD_ITEM ] = VieEdi_VIEW, - [Prg_FORM_EDIT_ITEM ] = VieEdi_VIEW, - [Prg_END_EDIT_ITEM ] = VieEdi_VIEW, - [Prg_RECEIVE_ITEM ] = VieEdi_VIEW, - [Prg_EDIT_RESOURCES ] = VieEdi_EDIT, - [Prg_EDIT_RESOURCE_LINK ] = VieEdi_EDIT, - [Prg_CHANGE_RESOURCE_LINK] = VieEdi_EDIT, - [Prg_END_EDIT_RES ] = VieEdi_VIEW, + [Prg_PRINT ] = Vie_VIEW, + [Prg_VIEW ] = Vie_VIEW, + [Prg_EDIT_ITEMS ] = Vie_VIEW, + [Prg_FORM_NEW_END_ITEM ] = Vie_VIEW, + [Prg_FORM_NEW_CHILD_ITEM ] = Vie_VIEW, + [Prg_FORM_EDIT_ITEM ] = Vie_VIEW, + [Prg_END_EDIT_ITEM ] = Vie_VIEW, + [Prg_RECEIVE_ITEM ] = Vie_VIEW, + [Prg_EDIT_RESOURCES ] = Vie_EDIT, + [Prg_EDIT_RESOURCE_LINK ] = Vie_EDIT, + [Prg_CHANGE_RESOURCE_LINK] = Vie_EDIT, + [Prg_END_EDIT_RES ] = Vie_VIEW, }; - static void (*PrgRsc_PutIconsResources[VieEdi_NUM_VIEW_EDIT]) (void *ItmCod) = + static void (*PrgRsc_PutIconsResources[Vie_NUM_VIEW_TYPES]) (void *ItmCod) = { - PrgRsc_PutIconsViewResources, - PrgRsc_PutIconsEditResources, + [Vie_VIEW] = PrgRsc_PutIconsViewResources, + [Vie_EDIT] = PrgRsc_PutIconsEditResources, }; /***** Trivial check *****/ @@ -199,9 +199,9 @@ void PrgRsc_ListItemResources (Prg_ListingType_t ListingType, /***** Get list of item resources from database *****/ NumResources = Prg_DB_GetListResources (&mysql_res,Item->Hierarchy.ItmCod, - ViewingOrEditingResources[ListingType] == VieEdi_EDIT); + ViewingOrEditingResources[ListingType] == Vie_EDIT); - if (NumResources || ViewingOrEditing[ListingType] == VieEdi_EDIT) + if (NumResources || ViewingOrEditing[ListingType] == Vie_EDIT) { if (Item->Hierarchy.ItmCod == SelectedItmCod) { @@ -219,18 +219,18 @@ void PrgRsc_ListItemResources (Prg_ListingType_t ListingType, } /***** Begin box *****/ - ViewingOrEditingResourcesOfThisItem = ViewingOrEditingResources[ListingType] == VieEdi_EDIT && - (Item->Hierarchy.ItmCod == SelectedItmCod) ? VieEdi_EDIT : - VieEdi_VIEW; + ViewingOrEditingResourcesOfThisItem = ViewingOrEditingResources[ListingType] == Vie_EDIT && + (Item->Hierarchy.ItmCod == SelectedItmCod) ? Vie_EDIT : + Vie_VIEW; switch (ViewingOrEditing[ListingType]) { - case VieEdi_VIEW: + case Vie_VIEW: Box_BoxBegin ("100%",NULL, NULL,NULL, NULL,Box_NOT_CLOSABLE); break; - case VieEdi_EDIT: + case Vie_EDIT: if (asprintf (&Title,Txt_Resources_of_X,Item->Title) < 0) Err_NotEnoughMemoryExit (); Box_BoxBegin ("100%",Title, @@ -239,6 +239,9 @@ void PrgRsc_ListItemResources (Prg_ListingType_t ListingType, Hlp_COURSE_Program,Box_NOT_CLOSABLE); free (Title); break; + default: + Err_WrongTypeExit (); + break; } /***** Table *****/ @@ -256,25 +259,29 @@ void PrgRsc_ListItemResources (Prg_ListingType_t ListingType, /* Show item */ switch (ViewingOrEditingResourcesOfThisItem) { - case VieEdi_VIEW: + case Vie_VIEW: PrgRsc_WriteRowViewResource (NumRsc,Item); break; - case VieEdi_EDIT: + case Vie_EDIT: PrgRsc_WriteRowEditResource (NumRsc,NumResources,Item, (ListingType == Prg_EDIT_RESOURCE_LINK && - Item->Resource.Hierarchy.RscCod == SelectedRscCod) ? VieEdi_EDIT : - VieEdi_VIEW); + Item->Resource.Hierarchy.RscCod == SelectedRscCod) ? Vie_EDIT : + Vie_VIEW); + break; + default: + Err_WrongTypeExit (); + break; } } /***** Form to create a new resource *****/ - if (ViewingOrEditingResourcesOfThisItem == VieEdi_EDIT) + if (ViewingOrEditingResourcesOfThisItem == Vie_EDIT) { Prg_ResetResource (Item); PrgRsc_WriteRowNewResource (NumResources,Item, (ListingType == Prg_EDIT_RESOURCE_LINK && - Item->Resource.Hierarchy.RscCod == SelectedRscCod) ? VieEdi_EDIT : - VieEdi_VIEW); + Item->Resource.Hierarchy.RscCod == SelectedRscCod) ? Vie_EDIT : + Vie_VIEW); } /***** End table *****/ @@ -413,7 +420,7 @@ static void PrgRsc_WriteRowViewResource (unsigned NumRsc, static void PrgRsc_WriteRowEditResource (unsigned NumRsc,unsigned NumResources, struct Prg_Item *Item, - VieEdi_ViewOrEdit_t ViewOrEditLink) + Vie_ViewType_t LinkViewType) { /***** Begin row *****/ HTM_TR_Begin (NULL); @@ -445,19 +452,22 @@ static void PrgRsc_WriteRowEditResource (unsigned NumRsc,unsigned NumResources, HTM_BR (); /* Edit link showing clipboard / Show current link */ - switch (ViewOrEditLink) + switch (LinkViewType) { - case VieEdi_VIEW: + case Vie_VIEW: /* Show current link */ Rsc_WriteLinkName (&Item->Resource.Link,Frm_PUT_FORM_TO_GO); break; - case VieEdi_EDIT: + case Vie_EDIT: /* Show clipboard to change resource link */ Frm_BeginFormAnchor (ActChgLnkPrgRsc,PrgRsc_RESOURCE_SECTION_ID); ParCod_PutPar (ParCod_Rsc,Item->Resource.Hierarchy.RscCod); Rsc_ShowClipboardToChangeLink (&Item->Resource.Link); Frm_EndForm (); break; + default: + Err_WrongTypeExit (); + break; } HTM_TD_End (); @@ -472,7 +482,7 @@ static void PrgRsc_WriteRowEditResource (unsigned NumRsc,unsigned NumResources, static void PrgRsc_WriteRowNewResource (unsigned NumResources, struct Prg_Item *Item, - VieEdi_ViewOrEdit_t ViewOrEditLink) + Vie_ViewType_t LinkViewType) { extern const char *Txt_New_resource; @@ -505,7 +515,7 @@ static void PrgRsc_WriteRowNewResource (unsigned NumResources, Frm_EndForm (); /* Edit link showing clipboard? */ - if (ViewOrEditLink == VieEdi_EDIT) + if (LinkViewType == Vie_EDIT) { HTM_BR (); diff --git a/swad_project.c b/swad_project.c index c768b1da..0d73e180 100644 --- a/swad_project.c +++ b/swad_project.c @@ -1413,7 +1413,7 @@ void Prj_PrintOneProject (void) Prj_GetProjectDataByCod (&Projects.Prj); /***** Write header *****/ - Lay_WriteHeaderClassPhoto (true,false); + Lay_WriteHeaderClassPhoto (Vie_PRINT,false); /***** Begin table *****/ HTM_TABLE_BeginWideMarginPadding (2); diff --git a/swad_syllabus.c b/swad_syllabus.c index cf815a04..6bfb71c0 100644 --- a/swad_syllabus.c +++ b/swad_syllabus.c @@ -136,7 +136,7 @@ void Syl_ResetSyllabus (struct Syl_Syllabus *Syllabus) { Syllabus->PathDir[0] = '\0'; Syllabus->NumItem = 0; - Syllabus->ViewingOrEditing = VieEdi_VIEW; + Syllabus->ViewType = Vie_VIEW; Syllabus->WhichSyllabus = Syl_DEFAULT_WHICH_SYLLABUS; } @@ -244,14 +244,14 @@ bool Syl_CheckAndEditSyllabus (struct Syl_Syllabus *Syllabus) case ActLftIteSylLec: case ActLftIteSylPra: case ActInsIteSylLec: case ActInsIteSylPra: case ActModIteSylLec: case ActModIteSylPra: - Syllabus->ViewingOrEditing = VieEdi_EDIT; + Syllabus->ViewType = Vie_EDIT; break; default: - Syllabus->ViewingOrEditing = VieEdi_VIEW; + Syllabus->ViewType = Vie_VIEW; break; } - if (Syllabus->ViewingOrEditing == VieEdi_EDIT || + if (Syllabus->ViewType == Vie_EDIT || Syl_LstItemsSyllabus.NumItems) { /***** Write the current syllabus *****/ @@ -523,15 +523,15 @@ static void Syl_ShowSyllabus (struct Syl_Syllabus *Syllabus) extern const char *Txt_Done; unsigned NumItem; int Col; - static const char **HelpLink[VieEdi_NUM_VIEW_EDIT] = + static const char **HelpLink[Vie_NUM_VIEW_TYPES] = { - [VieEdi_VIEW] = &Hlp_COURSE_Syllabus, - [VieEdi_EDIT] = &Hlp_COURSE_Syllabus_edit, + [Vie_VIEW] = &Hlp_COURSE_Syllabus, + [Vie_EDIT] = &Hlp_COURSE_Syllabus_edit, }; - static int NumButtons[VieEdi_NUM_VIEW_EDIT] = + static int NumButtons[Vie_NUM_VIEW_TYPES] = { - [VieEdi_VIEW] = 0, - [VieEdi_EDIT] = 5, + [Vie_VIEW] = 0, + [Vie_EDIT] = 5, }; bool ShowRowInsertNewItem = (Gbl.Action.Act == ActInsIteSylLec || Gbl.Action.Act == ActInsIteSylPra || Gbl.Action.Act == ActModIteSylLec || Gbl.Action.Act == ActModIteSylPra || @@ -539,7 +539,7 @@ static void Syl_ShowSyllabus (struct Syl_Syllabus *Syllabus) Gbl.Action.Act == ActLftIteSylLec || Gbl.Action.Act == ActLftIteSylPra); bool ICanEdit = Gbl.Usrs.Me.Role.Logged == Rol_TCH || Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM; - bool PutIconToEdit = Syllabus->ViewingOrEditing == VieEdi_VIEW && ICanEdit; + bool PutIconToEdit = Syllabus->ViewType == Vie_VIEW && ICanEdit; /***** Begin box *****/ Box_BoxBegin (NULL,Txt_INFO_TITLE[Gbl.Crs.Info.Type], @@ -547,7 +547,7 @@ static void Syl_ShowSyllabus (struct Syl_Syllabus *Syllabus) NULL, PutIconToEdit ? &Gbl.Crs.Info.Type : NULL, - *HelpLink[Syllabus->ViewingOrEditing],Box_NOT_CLOSABLE); + *HelpLink[Syllabus->ViewType],Box_NOT_CLOSABLE); /****** Form to select syllabus *****/ Syl_PutFormWhichSyllabus (Syllabus->WhichSyllabus); @@ -558,7 +558,7 @@ static void Syl_ShowSyllabus (struct Syl_Syllabus *Syllabus) /***** Set width of columns of the table *****/ HTM_Txt (""); for (Col = 0; - Col < NumButtons[Syllabus->ViewingOrEditing]; + Col < NumButtons[Syllabus->ViewType]; Col++) HTM_Txt (""); for (Col = 1; @@ -584,7 +584,7 @@ static void Syl_ShowSyllabus (struct Syl_Syllabus *Syllabus) Syl_LstItemsSyllabus.Lst[NumItem].Level,NULL, "",true); } - else if (Syllabus->ViewingOrEditing == VieEdi_EDIT) + else if (Syllabus->ViewType == Vie_EDIT) /***** If the syllabus is empty ==> show form to add a iten to the end *****/ Syl_ShowRowSyllabus (Syllabus,0, @@ -594,7 +594,7 @@ static void Syl_ShowSyllabus (struct Syl_Syllabus *Syllabus) HTM_TABLE_End (); /***** Button to view *****/ - if (Syllabus->ViewingOrEditing == VieEdi_EDIT) + if (Syllabus->ViewType == Vie_EDIT) { Frm_BeginForm (Inf_ActionsSeeInfo[Gbl.Crs.Info.Type]); Btn_PutConfirmButton (Txt_Done); @@ -629,9 +629,9 @@ static void Syl_ShowRowSyllabus (struct Syl_Syllabus *Syllabus,unsigned NumItem, /***** Begin the row *****/ HTM_TR_Begin (NULL); - switch (Syllabus->ViewingOrEditing) + switch (Syllabus->ViewType) { - case VieEdi_VIEW: + case Vie_VIEW: /***** Indent depending on the level *****/ if (Level > 1) { @@ -658,7 +658,7 @@ static void Syl_ShowRowSyllabus (struct Syl_Syllabus *Syllabus,unsigned NumItem, HTM_Txt (Text); HTM_TD_End (); break; - case VieEdi_EDIT: + case Vie_EDIT: if (NewItem) { HTM_TD_Begin ("colspan=\"5\" class=\"%s\"", @@ -737,6 +737,9 @@ static void Syl_ShowRowSyllabus (struct Syl_Syllabus *Syllabus,unsigned NumItem, Syl_PutFormItemSyllabus (Syllabus,NewItem,NumItem,Level,CodItem,Text); break; + default: + Err_WrongTypeExit (); + break; } /***** End of the row *****/ @@ -935,7 +938,7 @@ void Syl_RemoveItemSyllabus (void) /***** Load syllabus from XML file to memory *****/ Syl_LoadListItemsSyllabusIntoMemory (&Syllabus,Gbl.Hierarchy.Node[Hie_CRS].HieCod); - Syllabus.ViewingOrEditing = VieEdi_EDIT; + Syllabus.ViewType = Vie_EDIT; /***** Get item number *****/ Syllabus.NumItem = Syl_GetParItemNumber (); @@ -1012,7 +1015,7 @@ static void Syl_ChangePlaceItemSyllabus (Syl_ChangePosItem_t UpOrDownPos) /***** Load syllabus from XML file to memory *****/ Syl_LoadListItemsSyllabusIntoMemory (&Syllabus,Gbl.Hierarchy.Node[Hie_CRS].HieCod); - Syllabus.ViewingOrEditing = VieEdi_EDIT; + Syllabus.ViewType = Vie_EDIT; /***** Get item number *****/ Syllabus.NumItem = Syl_GetParItemNumber (); @@ -1198,7 +1201,7 @@ static void Syl_ChangeLevelItemSyllabus (Syl_ChangeLevelItem_t IncreaseOrDecreas /***** Load syllabus from XML file to memory *****/ Syl_LoadListItemsSyllabusIntoMemory (&Syllabus,Gbl.Hierarchy.Node[Hie_CRS].HieCod); - Syllabus.ViewingOrEditing = VieEdi_EDIT; + Syllabus.ViewType = Vie_EDIT; /***** Get item number *****/ Syllabus.NumItem = Syl_GetParItemNumber (); @@ -1261,7 +1264,7 @@ void Syl_InsertItemSyllabus (void) /***** Load syllabus from XML file to memory *****/ Syl_LoadListItemsSyllabusIntoMemory (&Syllabus,Gbl.Hierarchy.Node[Hie_CRS].HieCod); - Syllabus.ViewingOrEditing = VieEdi_EDIT; + Syllabus.ViewType = Vie_EDIT; /***** Get item number *****/ Syllabus.NumItem = Syl_GetParItemNumber (); @@ -1330,7 +1333,7 @@ void Syl_ModifyItemSyllabus (void) /***** Load syllabus from XML file to memory *****/ Syl_LoadListItemsSyllabusIntoMemory (&Syllabus,Gbl.Hierarchy.Node[Hie_CRS].HieCod); - Syllabus.ViewingOrEditing = VieEdi_EDIT; + Syllabus.ViewType = Vie_EDIT; /***** Get item number *****/ Syllabus.NumItem = Syl_GetParItemNumber (); diff --git a/swad_syllabus.h b/swad_syllabus.h index 4ef1e27a..952c7fcb 100644 --- a/swad_syllabus.h +++ b/swad_syllabus.h @@ -77,7 +77,7 @@ struct Syl_Syllabus char PathDir[PATH_MAX + 1]; unsigned NumItem; // Item being edited unsigned ParNumItem; // Used as parameter in forms - VieEdi_ViewOrEdit_t ViewingOrEditing; + Vie_ViewType_t ViewType; Syl_WhichSyllabus_t WhichSyllabus; }; diff --git a/swad_system_config.c b/swad_system_config.c index 5dbde13c..fecb2a19 100644 --- a/swad_system_config.c +++ b/swad_system_config.c @@ -59,11 +59,11 @@ extern struct Globals Gbl; /***************************** Private prototypes ****************************/ /*****************************************************************************/ -static void SysCfg_Configuration (bool PrintView); +static void SysCfg_Configuration (Vie_ViewType_t ViewType); static void SysCfg_PutIconToPrint (__attribute__((unused)) void *Args); static void SysCfg_Map (void); static void SysCfg_Platform (void); -static void SysCfg_Shortcut (bool PrintView); +static void SysCfg_Shortcut (Vie_ViewType_t ViewType); static void SysCfg_QR (void); static void SysCfg_NumCtys (void); static void SysCfg_NumInss (void); @@ -76,7 +76,7 @@ static void SysCfg_NumCrss (void); void SysCfg_ShowConfiguration (void) { - SysCfg_Configuration (false); + SysCfg_Configuration (Vie_VIEW); /***** Show help to enrol me *****/ Hlp_ShowHelpWhatWouldYouLikeToDo (); @@ -88,90 +88,93 @@ void SysCfg_ShowConfiguration (void) void SysCfg_PrintConfiguration (void) { - SysCfg_Configuration (true); + SysCfg_Configuration (Vie_PRINT); } /*****************************************************************************/ /******************** Information of the current country *********************/ /*****************************************************************************/ -static void SysCfg_Configuration (bool PrintView) +static void SysCfg_Configuration (Vie_ViewType_t ViewType) { extern const char *Hlp_SYSTEM_Information; unsigned NumCtrs; unsigned NumCtrsWithMap; /***** Begin box *****/ - if (PrintView) - Box_BoxBegin (NULL,Cfg_PLATFORM_SHORT_NAME, - NULL,NULL, - NULL,Box_NOT_CLOSABLE); - else - Box_BoxBegin (NULL,Cfg_PLATFORM_SHORT_NAME, - SysCfg_PutIconToPrint,NULL, - Hlp_SYSTEM_Information,Box_NOT_CLOSABLE); + Box_BoxBegin (NULL,Cfg_PLATFORM_SHORT_NAME, + ViewType == Vie_VIEW ? SysCfg_PutIconToPrint : + NULL,NULL, + ViewType == Vie_VIEW ? Hlp_SYSTEM_Information : + NULL,Box_NOT_CLOSABLE); - /**************************** Left part ***********************************/ - HTM_DIV_Begin ("class=\"HIE_CFG_LEFT HIE_CFG_WIDTH\""); + /**************************** Left part ***********************************/ + HTM_DIV_Begin ("class=\"HIE_CFG_LEFT HIE_CFG_WIDTH\""); - /***** Begin table *****/ - HTM_TABLE_BeginWidePadding (2); + /***** Begin table *****/ + HTM_TABLE_BeginWidePadding (2); - /***** Platform *****/ - SysCfg_Platform (); + /***** Platform *****/ + SysCfg_Platform (); - /***** Shortcut to the country *****/ - SysCfg_Shortcut (PrintView); + /***** Shortcut to the country *****/ + SysCfg_Shortcut (ViewType); - /***** Get number of centers with map *****/ - NumCtrsWithMap = Ctr_GetCachedNumCtrsWithMapInSys (); + /***** Get number of centers with map *****/ + NumCtrsWithMap = Ctr_GetCachedNumCtrsWithMapInSys (); - if (PrintView) - /***** QR code with link to the country *****/ - SysCfg_QR (); - else - { - /***** Get number of centers *****/ - NumCtrs = Hie_GetCachedNumNodesInHieLvl (Hie_CTR, // Number of centers... - Hie_SYS, // ...in system - Gbl.Hierarchy.Node[Hie_SYS].HieCod); + switch (ViewType) + { + case Vie_VIEW: + /***** Get number of centers *****/ + NumCtrs = Hie_GetCachedNumNodesInHieLvl (Hie_CTR, // Number of centers... + Hie_SYS, // ...in system + Gbl.Hierarchy.Node[Hie_SYS].HieCod); - /***** Number of countries, - number of institutions, - number of centers, - number of degrees, - number of courses *****/ - SysCfg_NumCtys (); - SysCfg_NumInss (); - HieCfg_NumCtrs (NumCtrs, - false); // Don't put form - HieCfg_NumCtrsWithMap (NumCtrs,NumCtrsWithMap); - SysCfg_NumDegs (); - SysCfg_NumCrss (); + /***** Number of countries, + number of institutions, + number of centers, + number of degrees, + number of courses *****/ + SysCfg_NumCtys (); + SysCfg_NumInss (); + HieCfg_NumCtrs (NumCtrs, + false); // Don't put form + HieCfg_NumCtrsWithMap (NumCtrs,NumCtrsWithMap); + SysCfg_NumDegs (); + SysCfg_NumCrss (); - /***** Number of users in courses of this country *****/ - HieCfg_NumUsrsInCrss (Hie_SYS,-1L,Rol_TCH); - HieCfg_NumUsrsInCrss (Hie_SYS,-1L,Rol_NET); - HieCfg_NumUsrsInCrss (Hie_SYS,-1L,Rol_STD); - HieCfg_NumUsrsInCrss (Hie_SYS,-1L,Rol_UNK); - } + /***** Number of users in courses of this country *****/ + HieCfg_NumUsrsInCrss (Hie_SYS,-1L,Rol_TCH); + HieCfg_NumUsrsInCrss (Hie_SYS,-1L,Rol_NET); + HieCfg_NumUsrsInCrss (Hie_SYS,-1L,Rol_STD); + HieCfg_NumUsrsInCrss (Hie_SYS,-1L,Rol_UNK); + break; + case Vie_PRINT: + /***** QR code with link to the country *****/ + SysCfg_QR (); + break; + default: + Err_WrongTypeExit (); + break; + } - /***** End table *****/ - HTM_TABLE_End (); - - /***** End of left part *****/ - HTM_DIV_End (); - - /**************************** Right part **********************************/ - if (NumCtrsWithMap) - { - HTM_DIV_Begin ("class=\"HIE_CFG_RIGHT HIE_CFG_WIDTH\""); - - /***** Country map *****/ - SysCfg_Map (); + /***** End table *****/ + HTM_TABLE_End (); + /***** End of left part *****/ HTM_DIV_End (); - } + + /**************************** Right part **********************************/ + if (NumCtrsWithMap) + { + HTM_DIV_Begin ("class=\"HIE_CFG_RIGHT HIE_CFG_WIDTH\""); + + /***** Country map *****/ + SysCfg_Map (); + + HTM_DIV_End (); + } /***** End box *****/ Box_BoxEnd (); @@ -285,9 +288,9 @@ static void SysCfg_Platform (void) /************** Show platform shortcut in system configuration ***************/ /*****************************************************************************/ -static void SysCfg_Shortcut (bool PrintView) +static void SysCfg_Shortcut (Vie_ViewType_t ViewType) { - HieCfg_Shortcut (PrintView,ParCod_None,-1L); + HieCfg_Shortcut (ViewType,ParCod_None,-1L); } /*****************************************************************************/ diff --git a/swad_test.c b/swad_test.c index c242cead..903f3bf0 100644 --- a/swad_test.c +++ b/swad_test.c @@ -347,7 +347,7 @@ void Tst_AssessTest (void) Box_BoxBegin (NULL,Txt_Result, NULL,NULL, Hlp_ASSESSMENT_Tests,Box_NOT_CLOSABLE); - Lay_WriteHeaderClassPhoto (false,false); + Lay_WriteHeaderClassPhoto (Vie_VIEW,false); /***** Header *****/ if (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS]) diff --git a/swad_test_print.c b/swad_test_print.c index d990c159..0054f699 100644 --- a/swad_test_print.c +++ b/swad_test_print.c @@ -218,7 +218,7 @@ void TstPrn_ShowTestPrintToFillIt (struct TstPrn_Print *Print, Box_BoxBegin (NULL,Txt_Test, NULL,NULL, Hlp_ASSESSMENT_Tests,Box_NOT_CLOSABLE); - Lay_WriteHeaderClassPhoto (false,false); + Lay_WriteHeaderClassPhoto (Vie_VIEW,false); if (Print->NumQsts.All) { @@ -2236,7 +2236,7 @@ void TstPrn_ShowOnePrint (void) Box_BoxBegin (NULL,Txt_Result, NULL,NULL, Hlp_ASSESSMENT_Tests_results,Box_NOT_CLOSABLE); - Lay_WriteHeaderClassPhoto (false,false); + Lay_WriteHeaderClassPhoto (Vie_VIEW,false); /***** Begin table *****/ HTM_TABLE_BeginWideMarginPadding (10); diff --git a/swad_timetable.c b/swad_timetable.c index be26b4c7..25684a70 100644 --- a/swad_timetable.c +++ b/swad_timetable.c @@ -323,8 +323,9 @@ void Tmt_ShowClassTimeTable (void) [Tmt_TUTORING_TIMETABLE] = ActUnk, }; struct Tmt_Timetable Timetable; - bool PrintView = (Gbl.Action.Act == ActPrnCrsTT || - Gbl.Action.Act == ActPrnMyTT); + Vie_ViewType_t ViewType = (Gbl.Action.Act == ActPrnCrsTT || + Gbl.Action.Act == ActPrnMyTT) ? Vie_PRINT : + Vie_VIEW; Grp_WhichGroups_t WhichGroups; /***** Initializations *****/ @@ -345,13 +346,13 @@ void Tmt_ShowClassTimeTable (void) } Timetable.ContextualIcons.PutIconEditCrsTT = (Timetable.Type == Tmt_COURSE_TIMETABLE && - !PrintView && + ViewType == Vie_VIEW && Gbl.Usrs.Me.Role.Logged >= Rol_TCH); Timetable.ContextualIcons.PutIconEditOfficeHours = (Timetable.Type == Tmt_MY_TIMETABLE && - !PrintView && + ViewType == Vie_VIEW && (Gbl.Usrs.Me.Role.Available & (1 << Rol_TCH | 1 << Rol_NET))); - Timetable.ContextualIcons.PutIconPrint = !PrintView; + Timetable.ContextualIcons.PutIconPrint = (ViewType == Vie_VIEW); /***** Get whether to show only my groups or all groups *****/ Grp_GetParWhichGroups (); @@ -370,28 +371,34 @@ void Tmt_ShowClassTimeTable (void) /***** Begin time table drawing *****/ if (Timetable.Type == Tmt_COURSE_TIMETABLE) - Lay_WriteHeaderClassPhoto (PrintView,false); + Lay_WriteHeaderClassPhoto (ViewType,false); - if (PrintView) - /***** Show whether only my groups or all groups are selected *****/ - Tmt_ShowTimeTableGrpsSelected (); - else + switch (ViewType) { - /***** Setting selector *****/ - Set_BeginSettingsHead (); + case Vie_VIEW: + /***** Setting selector *****/ + Set_BeginSettingsHead (); - /* Select whether show only my groups or all groups */ - if ( Timetable.Type == Tmt_MY_TIMETABLE || - (Timetable.Type == Tmt_COURSE_TIMETABLE && - Gbl.Crs.Grps.NumGrps)) - Tmt_PutFormToSelectWhichGroupsToShow (&Timetable); + /* Select whether show only my groups or all groups */ + if ( Timetable.Type == Tmt_MY_TIMETABLE || + (Timetable.Type == Tmt_COURSE_TIMETABLE && + Gbl.Crs.Grps.NumGrps)) + Tmt_PutFormToSelectWhichGroupsToShow (&Timetable); - /* Show form to change first day of week */ - WhichGroups = Grp_GetParWhichGroups (); - Cal_ShowFormToSelFirstDayOfWeek (ActChgTT1stDay[Timetable.Type], - Grp_PutParWhichGroups,&WhichGroups); + /* Show form to change first day of week */ + WhichGroups = Grp_GetParWhichGroups (); + Cal_ShowFormToSelFirstDayOfWeek (ActChgTT1stDay[Timetable.Type], + Grp_PutParWhichGroups,&WhichGroups); - Set_EndSettingsHead (); + Set_EndSettingsHead (); + break; + case Vie_PRINT: + /***** Show whether only my groups or all groups are selected *****/ + Tmt_ShowTimeTableGrpsSelected (); + break; + default: + Err_WrongTypeExit (); + break; } /***** Show the time table *****/ diff --git a/swad_user.c b/swad_user.c index 610d677d..7f697ecc 100644 --- a/swad_user.c +++ b/swad_user.c @@ -5082,7 +5082,7 @@ void Usr_SeeGuests (void) /***** Draw a class photo with guests *****/ if (Gbl.Usrs.Me.ListType == Set_USR_LIST_AS_CLASS_PHOTO) - Lay_WriteHeaderClassPhoto (false,true); + Lay_WriteHeaderClassPhoto (Vie_VIEW,true); /* Set options allowed */ PutForm = Usr_SetOptionsListUsrsAllowed (Rol_GST,ICanChooseOption); @@ -5232,7 +5232,7 @@ void Usr_SeeStudents (void) /***** Draw a class photo with students of the course *****/ if (Gbl.Usrs.Me.ListType == Set_USR_LIST_AS_CLASS_PHOTO) - Lay_WriteHeaderClassPhoto (false,true); + Lay_WriteHeaderClassPhoto (Vie_VIEW,true); /* Set options allowed */ PutForm = Usr_SetOptionsListUsrsAllowed (Rol_STD,ICanChooseOption); @@ -5398,7 +5398,7 @@ void Usr_SeeTeachers (void) /***** Draw a class photo with teachers of the course *****/ if (Gbl.Usrs.Me.ListType == Set_USR_LIST_AS_CLASS_PHOTO) - Lay_WriteHeaderClassPhoto (false,true); + Lay_WriteHeaderClassPhoto (Vie_VIEW,true); /* Set options allowed */ PutForm = Usr_SetOptionsListUsrsAllowed (Rol_TCH,ICanChooseOption); @@ -5928,7 +5928,7 @@ void Usr_SeeGstClassPhotoPrn (void) if (Gbl.Usrs.LstUsrs[Rol_GST].NumUsrs) { /***** Draw the guests' class photo *****/ - Lay_WriteHeaderClassPhoto (true,true); + Lay_WriteHeaderClassPhoto (Vie_PRINT,true); HTM_TABLE_BeginWide (); Usr_DrawClassPhoto (Usr_CLASS_PHOTO_PRN, Rol_GST,&Gbl.Usrs.Selected,false); @@ -5966,7 +5966,7 @@ void Usr_SeeStdClassPhotoPrn (void) if (Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs) { /***** Draw the students' class photo *****/ - Lay_WriteHeaderClassPhoto (true,true); + Lay_WriteHeaderClassPhoto (Vie_PRINT,true); HTM_TABLE_BeginWide (); Usr_DrawClassPhoto (Usr_CLASS_PHOTO_PRN, Rol_STD,&Gbl.Usrs.Selected,false); @@ -6028,7 +6028,7 @@ void Usr_SeeTchClassPhotoPrn (void) if (NumUsrs) { /***** Draw the teachers' class photo *****/ - Lay_WriteHeaderClassPhoto (true,true); + Lay_WriteHeaderClassPhoto (Vie_PRINT,true); HTM_TABLE_BeginWide (); /* List teachers and non-editing teachers */ diff --git a/swad_view_edit.h b/swad_view_edit.h index c920aab2..b8cad470 100644 --- a/swad_view_edit.h +++ b/swad_view_edit.h @@ -1,7 +1,7 @@ -// swad_view_edit.h: types and constants related to view/edit +// swad_view.h: types and constants related to view/edit/print -#ifndef _SWAD_VIE_EDI -#define _SWAD_VIE_EDI +#ifndef _SWAD_VIEW +#define _SWAD_VIEW /* SWAD (Shared Workspace At a Distance in Spanish), is a web platform developed at the University of Granada (Spain), @@ -28,7 +28,7 @@ /***************************** Public constants ******************************/ /*****************************************************************************/ -#define VieEdi_NUM_VIEW_EDIT 2 +#define Vie_NUM_VIEW_TYPES 3 /*****************************************************************************/ /******************************* Public types ********************************/ @@ -36,8 +36,9 @@ typedef enum { - VieEdi_VIEW = 0, - VieEdi_EDIT = 1, - } VieEdi_ViewOrEdit_t; + Vie_VIEW = 0, + Vie_EDIT = 1, + Vie_PRINT = 2, + } Vie_ViewType_t; #endif