From 48b0c060871c96502de95b5f3226fb81bffd697b Mon Sep 17 00:00:00 2001 From: acanas Date: Wed, 11 Oct 2023 00:02:14 +0200 Subject: [PATCH] Version 23.35: Oct 10, 2023 Fixed bugs in short/full names. --- swad_banner.c | 48 ++++++++-------- swad_building.c | 46 +++++++-------- swad_call_for_exam.c | 4 +- swad_center.c | 46 +++++++-------- swad_center.h | 2 +- swad_center_config.c | 14 ++--- swad_changelog.h | 3 +- swad_course.c | 72 +++++++++++------------ swad_course.h | 2 +- swad_course_config.c | 28 ++++----- swad_degree.c | 46 +++++++-------- swad_degree.h | 2 +- swad_degree_config.c | 14 ++--- swad_department.c | 45 +++++++-------- swad_hierarchy_config.c | 26 ++++----- swad_hierarchy_config.h | 2 +- swad_institution.c | 48 ++++++++-------- swad_institution.h | 2 +- swad_institution_config.c | 14 ++--- swad_link.c | 45 +++++++-------- swad_mail.c | 18 +++--- swad_name.c | 117 ++++++++++++-------------------------- swad_name.h | 4 +- swad_place.c | 48 ++++++++-------- swad_room.c | 48 ++++++++-------- 25 files changed, 339 insertions(+), 405 deletions(-) diff --git a/swad_banner.c b/swad_banner.c index fc4cf4e3..58b060a8 100644 --- a/swad_banner.c +++ b/swad_banner.c @@ -98,7 +98,7 @@ static void Ban_ShowOrHideBanner (struct Ban_Banner *Ban, HidVis_HiddenOrVisible_t HiddenOrVisible); static void Ban_RenameBanner (struct Ban_Banner *Ban, - Nam_ShrtOrFullName_t ShrtOrFullName); + Nam_ShrtOrFullName_t ShrtOrFull); static void Ban_PutFormToCreateBanner (const struct Ban_Banner *Ban); static void Ban_PutHeadBanners (void); @@ -603,11 +603,11 @@ void Ban_RenameBannerFull (void) /*****************************************************************************/ static void Ban_RenameBanner (struct Ban_Banner *Ban, - Nam_ShrtOrFullName_t ShrtOrFullName) + Nam_ShrtOrFullName_t ShrtOrFull) { - extern const char *Nam_ParShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern const char *Nam_FldShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern unsigned Nam_MaxBytesShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; + extern const char *Nam_Params[Nam_NUM_SHRT_FULL_NAMES]; + extern const char *Nam_Fields[Nam_NUM_SHRT_FULL_NAMES]; + extern unsigned Nam_MaxBytes[Nam_NUM_SHRT_FULL_NAMES]; extern const char *Txt_X_already_exists; extern const char *Txt_The_banner_X_has_been_renamed_as_Y; extern const char *Txt_The_name_X_has_not_changed; @@ -623,7 +623,7 @@ static void Ban_RenameBanner (struct Ban_Banner *Ban, Ban->BanCod = ParCod_GetAndCheckPar (ParCod_Ban); /* Get the new name for the banner */ - Nam_GetParShrtOrFullName (ShrtOrFullName,NewName); + Nam_GetParShrtOrFullName (ShrtOrFull,NewName); /***** Get banner data from the database *****/ Ban_GetBannerDataByCod (Ban); @@ -635,33 +635,33 @@ static void Ban_RenameBanner (struct Ban_Banner *Ban, { /***** Check if old and new names are the same (this happens when return is pressed without changes) *****/ - if (strcmp (CurrentName[ShrtOrFullName],NewName)) // Different names + if (strcmp (CurrentName[ShrtOrFull],NewName)) // Different names { /***** If banner was in database... *****/ - if (Ban_DB_CheckIfBannerNameExists (Nam_ParShrtOrFullName[ShrtOrFullName], + if (Ban_DB_CheckIfBannerNameExists (Nam_Params[ShrtOrFull], NewName,Ban->BanCod, -1L,0)) // Unused Ale_CreateAlert (Ale_WARNING,NULL,Txt_X_already_exists,NewName); else { /* Update the table changing old name by new name */ - Ban_DB_UpdateBanName (Ban->BanCod,Nam_FldShrtOrFullName[ShrtOrFullName],NewName); + Ban_DB_UpdateBanName (Ban->BanCod,Nam_Fields[ShrtOrFull],NewName); /* Write message to show the change made */ Ale_CreateAlert (Ale_SUCCESS,NULL, Txt_The_banner_X_has_been_renamed_as_Y, - CurrentName[ShrtOrFullName],NewName); + CurrentName[ShrtOrFull],NewName); } } else // The same name /* Write warning message */ Ale_CreateAlert (Ale_INFO,NULL,Txt_The_name_X_has_not_changed, - CurrentName[ShrtOrFullName]); + CurrentName[ShrtOrFull]); } /***** Update name *****/ - Str_Copy (CurrentName[ShrtOrFullName],NewName, - Nam_MaxBytesShrtOrFullName[ShrtOrFullName]); + Str_Copy (CurrentName[ShrtOrFull],NewName, + Nam_MaxBytes[ShrtOrFull]); } /*****************************************************************************/ @@ -773,11 +773,7 @@ void Ban_ContEditAfterChgBan (void) static void Ban_PutFormToCreateBanner (const struct Ban_Banner *Ban) { - const char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Ban->ShrtName, - [Nam_FULL_NAME] = Ban->FullName, - }; + const char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Begin form to create *****/ Frm_BeginFormTable (ActNewBan,NULL,NULL,NULL); @@ -799,6 +795,8 @@ static void Ban_PutFormToCreateBanner (const struct Ban_Banner *Ban) HTM_TD_Empty (1); /* Banner short name and full name */ + Names[Nam_SHRT_NAME] = Ban->ShrtName; + Names[Nam_FULL_NAME] = Ban->FullName; Nam_NewShortAndFullNames (Names); /* Banner image */ @@ -859,21 +857,19 @@ static void Ban_PutHeadBanners (void) void Ban_ReceiveFormNewBanner (void) { - extern const char *Nam_FldShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; + extern const char *Nam_Fields[Nam_NUM_SHRT_FULL_NAMES]; extern const char *Txt_You_must_specify_the_image_of_the_new_banner; extern const char *Txt_You_must_specify_the_web_address; extern const char *Txt_Created_new_banner_X; struct Ban_Banner *Ban = Ban_GetEditingBanner (); - char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Ban->ShrtName, - [Nam_FULL_NAME] = Ban->FullName, - }; + char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Reset banner *****/ Ban_ResetBanner (Ban); /***** Get parameters from form *****/ + Names[Nam_SHRT_NAME] = Ban->ShrtName; + Names[Nam_FULL_NAME] = Ban->FullName; Nam_GetParsShrtAndFullName (Names); Par_GetParText ("Img",Ban->Img,Ban_MAX_BYTES_IMAGE); Par_GetParText ("WWW",Ban->WWW,Cns_MAX_BYTES_WWW); @@ -882,7 +878,9 @@ void Ban_ReceiveFormNewBanner (void) Ban->FullName[0]) // If there's a banner name { /***** If name of banner was not in database... *****/ - if (!Nam_CheckIfNameExists (Ban_DB_CheckIfBannerNameExists,Names,-1L, + if (!Nam_CheckIfNameExists (Ban_DB_CheckIfBannerNameExists, + (const char **) Names, + -1L, -1L, // Unused 0)) // Unused { diff --git a/swad_building.c b/swad_building.c index b742f237..0c96ed6a 100644 --- a/swad_building.c +++ b/swad_building.c @@ -74,7 +74,7 @@ static void Bld_GetBuildingDataFromRow (MYSQL_RES *mysql_res, static void Bld_ListBuildingsForEdition (const struct Bld_Buildings *Buildings); static void Bld_PutParBldCod (void *BldCod); -static void Bld_RenameBuilding (Nam_ShrtOrFullName_t ShrtOrFullName); +static void Bld_RenameBuilding (Nam_ShrtOrFullName_t ShrtOrFull); static void Bld_PutFormToCreateBuilding (void); static void Bld_PutHeadBuildings (void); @@ -526,11 +526,11 @@ void Bld_RenameBuildingFull (void) /*********************** Change the name of a building ***********************/ /*****************************************************************************/ -static void Bld_RenameBuilding (Nam_ShrtOrFullName_t ShrtOrFullName) +static void Bld_RenameBuilding (Nam_ShrtOrFullName_t ShrtOrFull) { - extern const char *Nam_ParShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern const char *Nam_FldShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern unsigned Nam_MaxBytesShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; + extern const char *Nam_Params[Nam_NUM_SHRT_FULL_NAMES]; + extern const char *Nam_Fields[Nam_NUM_SHRT_FULL_NAMES]; + extern unsigned Nam_MaxBytes[Nam_NUM_SHRT_FULL_NAMES]; extern const char *Txt_X_already_exists; extern const char *Txt_The_building_X_has_been_renamed_as_Y; extern const char *Txt_The_name_X_has_not_changed; @@ -546,7 +546,7 @@ static void Bld_RenameBuilding (Nam_ShrtOrFullName_t ShrtOrFullName) Bld_EditingBuilding->BldCod = ParCod_GetAndCheckPar (ParCod_Bld); /* Get the new name for the building */ - Nam_GetParShrtOrFullName (ShrtOrFullName,NewName); + Nam_GetParShrtOrFullName (ShrtOrFull,NewName); /***** Get from the database the old names of the building *****/ Bld_GetBuildingDataByCod (Bld_EditingBuilding); @@ -556,10 +556,10 @@ static void Bld_RenameBuilding (Nam_ShrtOrFullName_t ShrtOrFullName) { /***** Check if old and new names are the same (this happens when return is pressed without changes) *****/ - if (strcmp (CurrentName[ShrtOrFullName],NewName)) // Different names + if (strcmp (CurrentName[ShrtOrFull],NewName)) // Different names { /***** If building was in database... *****/ - if (Bld_DB_CheckIfBuildingNameExists (Nam_ParShrtOrFullName[ShrtOrFullName], + if (Bld_DB_CheckIfBuildingNameExists (Nam_Params[ShrtOrFull], NewName,Bld_EditingBuilding->BldCod, -1L,0)) // Unused Ale_CreateAlert (Ale_WARNING,NULL,Txt_X_already_exists,NewName); @@ -567,26 +567,26 @@ static void Bld_RenameBuilding (Nam_ShrtOrFullName_t ShrtOrFullName) { /* Update the table changing old name by new name */ Bld_DB_UpdateBuildingName (Bld_EditingBuilding->BldCod, - Nam_FldShrtOrFullName[ShrtOrFullName], + Nam_Fields[ShrtOrFull], NewName); /* Write message to show the change made */ Ale_CreateAlert (Ale_SUCCESS,NULL, Txt_The_building_X_has_been_renamed_as_Y, - CurrentName[ShrtOrFullName],NewName); + CurrentName[ShrtOrFull],NewName); } } else // The same name Ale_CreateAlert (Ale_INFO,NULL, Txt_The_name_X_has_not_changed, - CurrentName[ShrtOrFullName]); + CurrentName[ShrtOrFull]); } else Ale_CreateAlertYouCanNotLeaveFieldEmpty (); /***** Update building name *****/ - Str_Copy (CurrentName[ShrtOrFullName],NewName, - Nam_MaxBytesShrtOrFullName[ShrtOrFullName]); + Str_Copy (CurrentName[ShrtOrFull],NewName, + Nam_MaxBytes[ShrtOrFull]); } /*****************************************************************************/ @@ -654,11 +654,7 @@ void Bld_ContEditAfterChgBuilding (void) static void Bld_PutFormToCreateBuilding (void) { - const char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Bld_EditingBuilding->ShrtName, - [Nam_FULL_NAME] = Bld_EditingBuilding->FullName, - }; + const char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Begin form to create *****/ Frm_BeginFormTable (ActNewBld,NULL,NULL,NULL); @@ -677,6 +673,8 @@ static void Bld_PutFormToCreateBuilding (void) HTM_TD_End (); /***** Building short name and full name *****/ + Names[Nam_SHRT_NAME] = Bld_EditingBuilding->ShrtName; + Names[Nam_FULL_NAME] = Bld_EditingBuilding->FullName; Nam_NewShortAndFullNames (Names); /***** Building location *****/ @@ -722,17 +720,15 @@ static void Bld_PutHeadBuildings (void) void Bld_ReceiveFormNewBuilding (void) { extern const char *Txt_Created_new_building_X; - char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Bld_EditingBuilding->ShrtName, - [Nam_FULL_NAME] = Bld_EditingBuilding->FullName, - }; + char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Building constructor *****/ Bld_EditingBuildingConstructor (); /***** Get parameters from form *****/ /* Get building short name and full name */ + Names[Nam_SHRT_NAME] = Bld_EditingBuilding->ShrtName; + Names[Nam_FULL_NAME] = Bld_EditingBuilding->FullName; Nam_GetParsShrtAndFullName (Names); /* Get building location */ @@ -742,7 +738,9 @@ void Bld_ReceiveFormNewBuilding (void) Bld_EditingBuilding->FullName[0]) // If there's a building name { /***** If name of building was not in database... *****/ - if (!Nam_CheckIfNameExists (Bld_DB_CheckIfBuildingNameExists,Names,-1L, + if (!Nam_CheckIfNameExists (Bld_DB_CheckIfBuildingNameExists, + (const char **) Names, + -1L, -1L, // Unused 0)) // Unused { diff --git a/swad_call_for_exam.c b/swad_call_for_exam.c index e93d9292..388056c9 100644 --- a/swad_call_for_exam.c +++ b/swad_call_for_exam.c @@ -854,7 +854,7 @@ static void Cfe_ShowCallForExam (struct Cfe_CallsForExams *CallsForExams, Cfe_TypeViewCallForExam_t TypeViewCallForExam, bool HighLight) { - extern unsigned Nam_MaxCharsShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; + extern unsigned Nam_MaxChars[Nam_NUM_SHRT_FULL_NAMES]; extern const char *Hlp_ASSESSMENT_Calls_for_exams_new_call; extern const char *Hlp_ASSESSMENT_Calls_for_exams_edit_call; extern const char *Txt_YEAR_OF_DEGREE[1 + Deg_MAX_YEARS_PER_DEGREE]; @@ -1002,7 +1002,7 @@ static void Cfe_ShowCallForExam (struct Cfe_CallsForExams *CallsForExams, HTM_TD_Begin ("class=\"LB DAT_STRONG_%s\"", The_GetSuffix ()); if (TypeViewCallForExam == Cfe_FORM_VIEW) - HTM_INPUT_TEXT ("CrsName",Nam_MaxCharsShrtOrFullName[Nam_FULL_NAME], + HTM_INPUT_TEXT ("CrsName",Nam_MaxChars[Nam_FULL_NAME], CallsForExams->CallForExam.CrsFullName, HTM_DONT_SUBMIT_ON_CHANGE, "id=\"CrsName\" size=\"30\" class=\"INPUT_%s\"", diff --git a/swad_center.c b/swad_center.c index eddbf8d4..8d827b90 100644 --- a/swad_center.c +++ b/swad_center.c @@ -1059,11 +1059,11 @@ void Ctr_RenameCenterFull (void) /************************ Change the name of a center ************************/ /*****************************************************************************/ -void Ctr_RenameCenter (struct Hie_Node *Ctr,Nam_ShrtOrFullName_t ShrtOrFullName) +void Ctr_RenameCenter (struct Hie_Node *Ctr,Nam_ShrtOrFullName_t ShrtOrFull) { - extern const char *Nam_ParShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern const char *Nam_FldShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern unsigned Nam_MaxBytesShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; + extern const char *Nam_Params[Nam_NUM_SHRT_FULL_NAMES]; + extern const char *Nam_Fields[Nam_NUM_SHRT_FULL_NAMES]; + extern unsigned Nam_MaxBytes[Nam_NUM_SHRT_FULL_NAMES]; extern const char *Txt_X_already_exists; extern const char *Txt_The_center_X_has_been_renamed_as_Y; extern const char *Txt_The_name_X_has_not_changed; @@ -1076,7 +1076,7 @@ void Ctr_RenameCenter (struct Hie_Node *Ctr,Nam_ShrtOrFullName_t ShrtOrFullName) /***** Get parameters from form *****/ /* Get the new name for the center */ - Nam_GetParShrtOrFullName (ShrtOrFullName,NewName); + Nam_GetParShrtOrFullName (ShrtOrFull,NewName); /***** Get from the database the old names of the center *****/ Ctr_GetCenterDataByCod (Ctr); @@ -1088,10 +1088,10 @@ void Ctr_RenameCenter (struct Hie_Node *Ctr,Nam_ShrtOrFullName_t ShrtOrFullName) { /***** Check if old and new names are the same (this happens when return is pressed without changes) *****/ - if (strcmp (CurrentName[ShrtOrFullName],NewName)) // Different names + if (strcmp (CurrentName[ShrtOrFull],NewName)) // Different names { /***** If degree was in database... *****/ - if (Ctr_DB_CheckIfCtrNameExistsInIns (Nam_ParShrtOrFullName[ShrtOrFullName], + if (Ctr_DB_CheckIfCtrNameExistsInIns (Nam_Params[ShrtOrFull], NewName,Ctr->HieCod, Gbl.Hierarchy.Node[Hie_INS].HieCod, 0)) // Unused @@ -1100,22 +1100,22 @@ void Ctr_RenameCenter (struct Hie_Node *Ctr,Nam_ShrtOrFullName_t ShrtOrFullName) { /* Update the table changing old name by new name */ Ctr_DB_UpdateCtrName (Ctr->HieCod, - Nam_FldShrtOrFullName[ShrtOrFullName],NewName); + Nam_Fields[ShrtOrFull],NewName); /* Write message to show the change made */ Ale_CreateAlert (Ale_SUCCESS,NULL, Txt_The_center_X_has_been_renamed_as_Y, - CurrentName[ShrtOrFullName],NewName); + CurrentName[ShrtOrFull],NewName); /* Change current center name in order to display it properly */ - Str_Copy (CurrentName[ShrtOrFullName],NewName, - Nam_MaxBytesShrtOrFullName[ShrtOrFullName]); + Str_Copy (CurrentName[ShrtOrFull],NewName, + Nam_MaxBytes[ShrtOrFull]); } } else // The same name Ale_CreateAlert (Ale_INFO,NULL, Txt_The_name_X_has_not_changed, - CurrentName[ShrtOrFullName]); + CurrentName[ShrtOrFull]); } } @@ -1239,11 +1239,7 @@ static void Ctr_PutFormToCreateCenter (const struct Plc_Places *Places) Act_Action_t NextAction = ActUnk; unsigned NumPlc; const struct Plc_Place *Plc; - const char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Ctr_EditingCtr->ShrtName, - [Nam_FULL_NAME] = Ctr_EditingCtr->FullName, - }; + const char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Set action depending on role *****/ if (Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) @@ -1302,6 +1298,8 @@ static void Ctr_PutFormToCreateCenter (const struct Plc_Places *Places) HTM_TD_End (); /***** Center short name and full name *****/ + Names[Nam_SHRT_NAME] = Ctr_EditingCtr->ShrtName; + Names[Nam_FULL_NAME] = Ctr_EditingCtr->FullName; Nam_NewShortAndFullNames (Names); /***** Center WWW *****/ @@ -1475,11 +1473,7 @@ void Ctr_ReceiveFormNewCtr (void) static void Ctr_ReceiveFormRequestOrCreateCtr (Hie_Status_t Status) { extern const char *Txt_Created_new_center_X; - char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Ctr_EditingCtr->ShrtName, - [Nam_FULL_NAME] = Ctr_EditingCtr->FullName, - }; + char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Get parameters from form *****/ /* Set center institution */ @@ -1489,6 +1483,8 @@ static void Ctr_ReceiveFormRequestOrCreateCtr (Hie_Status_t Status) Ctr_EditingCtr->Specific.PlcCod = ParCod_GetAndCheckParMin (ParCod_Plc,0); // 0 (another place) is allowed here /* Get center short name and full name */ + Names[Nam_SHRT_NAME] = Ctr_EditingCtr->ShrtName; + Names[Nam_FULL_NAME] = Ctr_EditingCtr->FullName; Nam_GetParsShrtAndFullName (Names); /* Get center WWW */ @@ -1500,8 +1496,10 @@ static void Ctr_ReceiveFormRequestOrCreateCtr (Hie_Status_t Status) if (Ctr_EditingCtr->WWW[0]) { /***** If name of center was in database... *****/ - if (!Nam_CheckIfNameExists (Ctr_DB_CheckIfCtrNameExistsInIns,Names, - -1L,Gbl.Hierarchy.Node[Hie_INS].HieCod, + if (!Nam_CheckIfNameExists (Ctr_DB_CheckIfCtrNameExistsInIns, + (const char **) Names, + -1L, + Gbl.Hierarchy.Node[Hie_INS].HieCod, 0)) // Unused { Ctr_EditingCtr->HieCod = Ctr_DB_CreateCenter (Ctr_EditingCtr,Status); diff --git a/swad_center.h b/swad_center.h index 84ffa591..2ef3dad5 100644 --- a/swad_center.h +++ b/swad_center.h @@ -58,7 +58,7 @@ void Ctr_RemoveCenter (void); void Ctr_ChangeCtrPlc (void); void Ctr_RenameCenterShort (void); void Ctr_RenameCenterFull (void); -void Ctr_RenameCenter (struct Hie_Node *Ctr,Nam_ShrtOrFullName_t ShrtOrFullName); +void Ctr_RenameCenter (struct Hie_Node *Ctr,Nam_ShrtOrFullName_t ShrtOrFull); void Ctr_ChangeCtrWWW (void); void Ctr_ChangeCtrStatus (void); void Ctr_ContEditAfterChgCtr (void); diff --git a/swad_center_config.c b/swad_center_config.c index ece2d8ef..7a41abf4 100644 --- a/swad_center_config.c +++ b/swad_center_config.c @@ -1017,11 +1017,7 @@ void CtrCfg_ChangeCtrIns (void) { extern const char *Txt_The_center_X_has_been_moved_to_the_institution_Y; struct Hie_Node NewIns; - char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Gbl.Hierarchy.Node[Hie_CTR].ShrtName, - [Nam_FULL_NAME] = Gbl.Hierarchy.Node[Hie_CTR].FullName, - }; + const char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Get parameter with institution code *****/ NewIns.HieCod = ParCod_GetAndCheckPar (ParCod_OthIns); @@ -1033,8 +1029,12 @@ void CtrCfg_ChangeCtrIns (void) Ins_GetInstitDataByCod (&NewIns); /***** Check if it already exists a center with the same name in the new institution *****/ - if (!Nam_CheckIfNameExists (Ctr_DB_CheckIfCtrNameExistsInIns,Names, - Gbl.Hierarchy.Node[Hie_CTR].HieCod,NewIns.HieCod, + Names[Nam_SHRT_NAME] = Gbl.Hierarchy.Node[Hie_CTR].ShrtName; + Names[Nam_FULL_NAME] = Gbl.Hierarchy.Node[Hie_CTR].FullName; + if (!Nam_CheckIfNameExists (Ctr_DB_CheckIfCtrNameExistsInIns, + Names, + Gbl.Hierarchy.Node[Hie_CTR].HieCod, + NewIns.HieCod, 0)) // Unused { /***** Update institution in table of centers *****/ diff --git a/swad_changelog.h b/swad_changelog.h index d2b4fa1d..7196b154 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.34 (2023-10-10)" +#define Log_PLATFORM_VERSION "SWAD 23.35 (2023-10-10)" #define CSS_FILE "swad23.25.2.css" #define JS_FILE "swad22.49.js" /* + Version 23.35: Oct 10, 2023 Fixed bugs in short/full names. (335549 lines) Version 23.34: Oct 10, 2023 New module swad_name for short and full names. (335608 lines) Version 23.33.3: Oct 10, 2023 Code refactoring in short and full names. (335515 lines) Version 23.33.2: Oct 10, 2023 Code refactoring in short and full names. Not finished. (335661 lines) diff --git a/swad_course.c b/swad_course.c index 2ba4c104..4f5d5ff2 100644 --- a/swad_course.c +++ b/swad_course.c @@ -1075,11 +1075,7 @@ static void Crs_PutFormToCreateCourse (void) extern const char *Txt_YEAR_OF_DEGREE[1 + Deg_MAX_YEARS_PER_DEGREE]; Act_Action_t NextAction = ActUnk; unsigned Year; - const char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Crs_EditingCrs->ShrtName, - [Nam_FULL_NAME] = Crs_EditingCrs->FullName, - }; + const char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Begin form *****/ if (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM) @@ -1132,6 +1128,8 @@ static void Crs_PutFormToCreateCourse (void) HTM_TD_End (); /***** Course short name and full name *****/ + Names[Nam_SHRT_NAME] = Crs_EditingCrs->ShrtName; + Names[Nam_FULL_NAME] = Crs_EditingCrs->FullName; Nam_NewShortAndFullNames (Names); /***** Current number of teachers in this course *****/ @@ -1251,15 +1249,10 @@ static void Crs_ReceiveFormRequestOrCreateCrs (Hie_Status_t Status) extern const char *Txt_Created_new_course_X; extern const char *Txt_The_year_X_is_not_allowed; extern const char *Txt_YEAR_OF_DEGREE[1 + Deg_MAX_YEARS_PER_DEGREE]; - char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Crs_EditingCrs->ShrtName, - [Nam_FULL_NAME] = Crs_EditingCrs->FullName, - }; + const char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Get parameters from form *****/ /* Set course degree */ - // Deg.DegCod = Crs_EditingCrs->PrtCod = Gbl.Hierarchy.Node[Hie_DEG].HieCod; /* Get parameters of the new course */ @@ -1272,8 +1265,12 @@ static void Crs_ReceiveFormRequestOrCreateCrs (Hie_Status_t Status) Crs_EditingCrs->FullName[0]) // If there's a course name { /***** If name of course was not in database... *****/ - if (!Nam_CheckIfNameExists (Crs_DB_CheckIfCrsNameExistsInYearOfDeg,Names, - -1L,Crs_EditingCrs->PrtCod, + Names[Nam_SHRT_NAME] = Crs_EditingCrs->ShrtName; + Names[Nam_FULL_NAME] = Crs_EditingCrs->FullName; + if (!Nam_CheckIfNameExists (Crs_DB_CheckIfCrsNameExistsInYearOfDeg, + Names, + -1L, + Crs_EditingCrs->PrtCod, Crs_EditingCrs->Specific.Year)) { Crs_DB_CreateCourse (Crs_EditingCrs,Status); @@ -1297,11 +1294,7 @@ static void Crs_ReceiveFormRequestOrCreateCrs (Hie_Status_t Status) static void Crs_GetParsNewCourse (struct Hie_Node *Crs) { char YearStr[2 + 1]; - char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Crs->ShrtName, - [Nam_FULL_NAME] = Crs->FullName, - }; + char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Get parameters of the course from form *****/ /* Get year */ @@ -1312,6 +1305,8 @@ static void Crs_GetParsNewCourse (struct Hie_Node *Crs) Par_GetParText ("InsCrsCod",Crs->InstitutionalCod,Hie_MAX_BYTES_INSTITUTIONAL_COD); /* Get course short name and full name */ + Names[Nam_SHRT_NAME] = Crs->ShrtName; + Names[Nam_FULL_NAME] = Crs->FullName; Nam_GetParsShrtAndFullName (Names); } @@ -1602,11 +1597,7 @@ void Crs_ChangeCrsYear (void) extern const char *Txt_The_year_X_is_not_allowed; char YearStr[2 + 1]; unsigned NewYear; - char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Crs_EditingCrs->ShrtName, - [Nam_FULL_NAME] = Crs_EditingCrs->FullName, - }; + const char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Course constructor *****/ Crs_EditingCourseConstructor (); @@ -1627,8 +1618,13 @@ void Crs_ChangeCrsYear (void) if (NewYear <= Deg_MAX_YEARS_PER_DEGREE) // If year is valid { /***** If name of course was not in database in the new year... *****/ - if (!Nam_CheckIfNameExists (Crs_DB_CheckIfCrsNameExistsInYearOfDeg,Names, - -1L,Crs_EditingCrs->PrtCod,NewYear)) + Names[Nam_SHRT_NAME] = Crs_EditingCrs->ShrtName; + Names[Nam_FULL_NAME] = Crs_EditingCrs->FullName; + if (!Nam_CheckIfNameExists (Crs_DB_CheckIfCrsNameExistsInYearOfDeg, + Names, + -1L, + Crs_EditingCrs->PrtCod, + NewYear)) { /***** Update year in table of courses *****/ Crs_UpdateCrsYear (Crs_EditingCrs,NewYear); @@ -1700,11 +1696,11 @@ void Crs_RenameCourseFull (void) /************************ Change the name of a course ************************/ /*****************************************************************************/ -void Crs_RenameCourse (struct Hie_Node *Crs,Nam_ShrtOrFullName_t ShrtOrFullName) +void Crs_RenameCourse (struct Hie_Node *Crs,Nam_ShrtOrFullName_t ShrtOrFull) { - extern const char *Nam_ParShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern const char *Nam_FldShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern unsigned Nam_MaxBytesShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; + extern const char *Nam_Params[Nam_NUM_SHRT_FULL_NAMES]; + extern const char *Nam_Fields[Nam_NUM_SHRT_FULL_NAMES]; + extern unsigned Nam_MaxBytes[Nam_NUM_SHRT_FULL_NAMES]; extern const char *Txt_X_already_exists; extern const char *Txt_The_course_X_has_been_renamed_as_Y; extern const char *Txt_The_name_X_has_not_changed; @@ -1717,7 +1713,7 @@ void Crs_RenameCourse (struct Hie_Node *Crs,Nam_ShrtOrFullName_t ShrtOrFullName) /***** Get parameters from form *****/ /* Get the new name for the course */ - Nam_GetParShrtOrFullName (ShrtOrFullName,NewName); + Nam_GetParShrtOrFullName (ShrtOrFull,NewName); /***** Get from the database the data of the degree *****/ Crs_GetCourseDataByCod (Crs); @@ -1729,10 +1725,10 @@ void Crs_RenameCourse (struct Hie_Node *Crs,Nam_ShrtOrFullName_t ShrtOrFullName) { /***** Check if old and new names are the same (this happens when return is pressed without changes) *****/ - if (strcmp (CurrentName[ShrtOrFullName],NewName)) // Different names + if (strcmp (CurrentName[ShrtOrFull],NewName)) // Different names { /***** If course was in database... *****/ - if (Crs_DB_CheckIfCrsNameExistsInYearOfDeg (Nam_ParShrtOrFullName[ShrtOrFullName], + if (Crs_DB_CheckIfCrsNameExistsInYearOfDeg (Nam_Params[ShrtOrFull], NewName,Crs->HieCod, Crs->PrtCod,Crs->Specific.Year)) Ale_CreateAlert (Ale_WARNING,NULL,Txt_X_already_exists,NewName); @@ -1740,21 +1736,21 @@ void Crs_RenameCourse (struct Hie_Node *Crs,Nam_ShrtOrFullName_t ShrtOrFullName) { /* Update the table changing old name by new name */ Crs_DB_UpdateCrsName (Crs->HieCod, - Nam_FldShrtOrFullName[ShrtOrFullName],NewName); + Nam_Fields[ShrtOrFull],NewName); /* Create alert to show the change made */ Ale_CreateAlert (Ale_SUCCESS,NULL, Txt_The_course_X_has_been_renamed_as_Y, - CurrentName[ShrtOrFullName],NewName); + CurrentName[ShrtOrFull],NewName); /* Change current course name in order to display it properly */ - Str_Copy (CurrentName[ShrtOrFullName],NewName, - Nam_MaxBytesShrtOrFullName[ShrtOrFullName]); + Str_Copy (CurrentName[ShrtOrFull],NewName, + Nam_MaxBytes[ShrtOrFull]); } } else // The same name Ale_CreateAlert (Ale_INFO,NULL, - Txt_The_name_X_has_not_changed,CurrentName[ShrtOrFullName]); + Txt_The_name_X_has_not_changed,CurrentName[ShrtOrFull]); } else Ale_CreateAlertYouCanNotLeaveFieldEmpty (); @@ -2370,7 +2366,7 @@ static void Crs_EditingCourseConstructor (void) Err_NotEnoughMemoryExit (); /***** Reset course *****/ - Crs_EditingCrs->HieCod = -1L; + Crs_EditingCrs->HieCod = -1L; Crs_EditingCrs->PrtCod = -1L; Crs_EditingCrs->Specific.Year = 0; Crs_EditingCrs->Status = 0; diff --git a/swad_course.h b/swad_course.h index be52bcb5..8c395486 100644 --- a/swad_course.h +++ b/swad_course.h @@ -74,7 +74,7 @@ void Crs_UpdateCrsYear (struct Hie_Node *Crs,unsigned NewYear); void Crs_RenameCourseShort (void); void Crs_RenameCourseFull (void); -void Crs_RenameCourse (struct Hie_Node *Crs,Nam_ShrtOrFullName_t ShrtOrFullName); +void Crs_RenameCourse (struct Hie_Node *Crs,Nam_ShrtOrFullName_t ShrtOrFull); void Crs_ChangeCrsStatus (void); void Crs_ContEditAfterChgCrs (void); diff --git a/swad_course_config.c b/swad_course_config.c index 191a2c76..d090fd3f 100644 --- a/swad_course_config.c +++ b/swad_course_config.c @@ -461,11 +461,7 @@ void CrsCfg_ChangeCrsDeg (void) extern const char *Txt_YEAR_OF_DEGREE[1 + Deg_MAX_YEARS_PER_DEGREE]; extern const char *Txt_The_course_X_has_been_moved_to_the_degree_Y; struct Hie_Node NewDeg; - char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Gbl.Hierarchy.Node[Hie_CRS].ShrtName, - [Nam_FULL_NAME] = Gbl.Hierarchy.Node[Hie_CRS].FullName, - }; + const char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Get parameter with degree code *****/ NewDeg.HieCod = ParCod_GetAndCheckPar (ParCod_OthDeg); @@ -477,8 +473,12 @@ void CrsCfg_ChangeCrsDeg (void) Deg_GetDegreeDataByCod (&NewDeg); /***** If name of course was not in database in the new degree... *****/ - if (!Nam_CheckIfNameExists (Crs_DB_CheckIfCrsNameExistsInYearOfDeg,Names, - -1L,NewDeg.HieCod, + Names[Nam_SHRT_NAME] = Gbl.Hierarchy.Node[Hie_CRS].ShrtName; + Names[Nam_FULL_NAME] = Gbl.Hierarchy.Node[Hie_CRS].FullName; + if (!Nam_CheckIfNameExists (Crs_DB_CheckIfCrsNameExistsInYearOfDeg, + Names, + -1L, + NewDeg.HieCod, Gbl.Hierarchy.Node[Hie_CRS].Specific.Year)) { /***** Update degree in table of courses *****/ @@ -523,11 +523,7 @@ void CrsCfg_ChangeCrsYear (void) extern const char *Txt_The_year_X_is_not_allowed; char YearStr[2 + 1]; unsigned NewYear; - char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Gbl.Hierarchy.Node[Hie_CRS].ShrtName, - [Nam_FULL_NAME] = Gbl.Hierarchy.Node[Hie_CRS].FullName, - }; + const char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Get parameter with year/semester *****/ Par_GetParText ("OthCrsYear",YearStr,2); @@ -536,8 +532,12 @@ void CrsCfg_ChangeCrsYear (void) if (NewYear <= Deg_MAX_YEARS_PER_DEGREE) // If year is valid { /***** If name of course was not in database in the new year... *****/ - if (!Nam_CheckIfNameExists (Crs_DB_CheckIfCrsNameExistsInYearOfDeg,Names, - -1L,Gbl.Hierarchy.Node[Hie_CRS].PrtCod, + Names[Nam_SHRT_NAME] = Gbl.Hierarchy.Node[Hie_CRS].ShrtName; + Names[Nam_FULL_NAME] = Gbl.Hierarchy.Node[Hie_CRS].FullName; + if (!Nam_CheckIfNameExists (Crs_DB_CheckIfCrsNameExistsInYearOfDeg, + Names, + -1L, + Gbl.Hierarchy.Node[Hie_CRS].PrtCod, NewYear)) { /***** Update year in table of courses *****/ diff --git a/swad_degree.c b/swad_degree.c index ef46c9f1..19782436 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -509,11 +509,7 @@ static void Deg_PutFormToCreateDegree (const struct DegTyp_DegTypes *DegTypes) Act_Action_t NextAction = ActUnk; unsigned NumDegTyp; struct DegTyp_DegreeType *DegTyp; - const char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Deg_EditingDeg->ShrtName, - [Nam_FULL_NAME] = Deg_EditingDeg->FullName, - }; + const char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Set action depending on role *****/ if (Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM) @@ -548,6 +544,8 @@ static void Deg_PutFormToCreateDegree (const struct DegTyp_DegTypes *DegTypes) HTM_TD_End (); /***** Degree short name and full name *****/ + Names[Nam_SHRT_NAME] = Deg_EditingDeg->ShrtName; + Names[Nam_FULL_NAME] = Deg_EditingDeg->FullName; Nam_NewShortAndFullNames (Names); /***** Degree type *****/ @@ -1046,17 +1044,15 @@ void Deg_ReceiveFormNewDeg (void) static void Deg_ReceiveFormRequestOrCreateDeg (Hie_Status_t Status) { extern const char *Txt_Created_new_degree_X; - char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Deg_EditingDeg->ShrtName, - [Nam_FULL_NAME] = Deg_EditingDeg->FullName, - }; + char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Get parameters from form *****/ /* Set degree center */ Deg_EditingDeg->PrtCod = Gbl.Hierarchy.Node[Hie_CTR].HieCod; /* Get degree short name and full name */ + Names[Nam_SHRT_NAME] = Deg_EditingDeg->ShrtName; + Names[Nam_FULL_NAME] = Deg_EditingDeg->FullName; Nam_GetParsShrtAndFullName (Names); /* Get degree type */ @@ -1071,8 +1067,10 @@ static void Deg_ReceiveFormRequestOrCreateDeg (Hie_Status_t Status) if (Deg_EditingDeg->WWW[0]) { /***** If name of degree was not in database... *****/ - if (!Nam_CheckIfNameExists (Deg_DB_CheckIfDegNameExistsInCtr,Names, - -1L,Deg_EditingDeg->PrtCod, + if (!Nam_CheckIfNameExists (Deg_DB_CheckIfDegNameExistsInCtr, + (const char **) Names, + -1L, + Deg_EditingDeg->PrtCod, 0)) // Unused { Deg_DB_CreateDegree (Deg_EditingDeg,Status); @@ -1283,11 +1281,11 @@ void Deg_RenameDegreeFull (void) /************************ Change the name of a degree ************************/ /*****************************************************************************/ -void Deg_RenameDegree (struct Hie_Node *Deg,Nam_ShrtOrFullName_t ShrtOrFullName) +void Deg_RenameDegree (struct Hie_Node *Deg,Nam_ShrtOrFullName_t ShrtOrFull) { - extern const char *Nam_ParShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern const char *Nam_FldShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern unsigned Nam_MaxBytesShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; + extern const char *Nam_Params[Nam_NUM_SHRT_FULL_NAMES]; + extern const char *Nam_Fields[Nam_NUM_SHRT_FULL_NAMES]; + extern unsigned Nam_MaxBytes[Nam_NUM_SHRT_FULL_NAMES]; extern const char *Txt_X_already_exists; extern const char *Txt_The_degree_X_has_been_renamed_as_Y; extern const char *Txt_The_name_X_has_not_changed; @@ -1300,7 +1298,7 @@ void Deg_RenameDegree (struct Hie_Node *Deg,Nam_ShrtOrFullName_t ShrtOrFullName) /***** Get parameters from form *****/ /* Get the new name for the degree */ - Nam_GetParShrtOrFullName (ShrtOrFullName,NewName); + Nam_GetParShrtOrFullName (ShrtOrFull,NewName); /***** Get data of degree *****/ Deg_GetDegreeDataByCod (Deg); @@ -1310,10 +1308,10 @@ void Deg_RenameDegree (struct Hie_Node *Deg,Nam_ShrtOrFullName_t ShrtOrFullName) { /***** Check if old and new names are the same (this happens when return is pressed without changes) *****/ - if (strcmp (CurrentName[ShrtOrFullName],NewName)) // Different names + if (strcmp (CurrentName[ShrtOrFull],NewName)) // Different names { /***** If degree was in database... *****/ - if (Deg_DB_CheckIfDegNameExistsInCtr (Nam_ParShrtOrFullName[ShrtOrFullName], + if (Deg_DB_CheckIfDegNameExistsInCtr (Nam_Params[ShrtOrFull], NewName,Deg->HieCod,Deg->PrtCod, 0)) // Unused Ale_CreateAlert (Ale_WARNING,NULL,Txt_X_already_exists,NewName); @@ -1321,22 +1319,22 @@ void Deg_RenameDegree (struct Hie_Node *Deg,Nam_ShrtOrFullName_t ShrtOrFullName) { /* Update the table changing old name by new name */ Deg_DB_UpdateDegNameDB (Deg->HieCod, - Nam_FldShrtOrFullName[ShrtOrFullName],NewName); + Nam_Fields[ShrtOrFull],NewName); /* Write message to show the change made */ Ale_CreateAlert (Ale_SUCCESS,NULL, Txt_The_degree_X_has_been_renamed_as_Y, - CurrentName[ShrtOrFullName],NewName); + CurrentName[ShrtOrFull],NewName); /* Change current degree name in order to display it properly */ - Str_Copy (CurrentName[ShrtOrFullName],NewName, - Nam_MaxBytesShrtOrFullName[ShrtOrFullName]); + Str_Copy (CurrentName[ShrtOrFull],NewName, + Nam_MaxBytes[ShrtOrFull]); } } else // The same name Ale_CreateAlert (Ale_INFO,NULL, Txt_The_name_X_has_not_changed, - CurrentName[ShrtOrFullName]); + CurrentName[ShrtOrFull]); } else Ale_CreateAlertYouCanNotLeaveFieldEmpty (); diff --git a/swad_degree.h b/swad_degree.h index 94e10686..79ef2a03 100644 --- a/swad_degree.h +++ b/swad_degree.h @@ -74,7 +74,7 @@ bool Deg_GetDegreeDataByCod (struct Hie_Node *Deg); void Deg_RemoveDegreeCompletely (long DegCod); void Deg_RenameDegreeShort (void); void Deg_RenameDegreeFull (void); -void Deg_RenameDegree (struct Hie_Node *Deg,Nam_ShrtOrFullName_t ShrtOrFullName); +void Deg_RenameDegree (struct Hie_Node *Deg,Nam_ShrtOrFullName_t ShrtOrFull); void Deg_ChangeDegreeType (void); void Deg_ChangeDegWWW (void); void Deg_ChangeDegStatus (void); diff --git a/swad_degree_config.c b/swad_degree_config.c index 4be23ab9..e1591427 100644 --- a/swad_degree_config.c +++ b/swad_degree_config.c @@ -350,11 +350,7 @@ void DegCfg_ChangeDegCtr (void) { extern const char *Txt_The_degree_X_has_been_moved_to_the_center_Y; struct Hie_Node NewCtr; - char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Gbl.Hierarchy.Node[Hie_DEG].ShrtName, - [Nam_FULL_NAME] = Gbl.Hierarchy.Node[Hie_DEG].FullName, - }; + const char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Get parameter with center code *****/ NewCtr.HieCod = ParCod_GetAndCheckPar (ParCod_OthCtr); @@ -366,8 +362,12 @@ void DegCfg_ChangeDegCtr (void) Ctr_GetCenterDataByCod (&NewCtr); /***** Check if it already existed a degree with the same name in the new center *****/ - if (!Nam_CheckIfNameExists (Deg_DB_CheckIfDegNameExistsInCtr,Names, - Gbl.Hierarchy.Node[Hie_DEG].HieCod,NewCtr.HieCod, + Names[Nam_SHRT_NAME] = Gbl.Hierarchy.Node[Hie_DEG].ShrtName; + Names[Nam_FULL_NAME] = Gbl.Hierarchy.Node[Hie_DEG].FullName; + if (!Nam_CheckIfNameExists (Deg_DB_CheckIfDegNameExistsInCtr, + Names, + Gbl.Hierarchy.Node[Hie_DEG].HieCod, + NewCtr.HieCod, 0)) // Unused { /***** Update center in table of degrees *****/ diff --git a/swad_department.c b/swad_department.c index a85ff07b..049f1a6c 100644 --- a/swad_department.c +++ b/swad_department.c @@ -91,7 +91,7 @@ static void Dpt_GetDepartmentDataFromRow (MYSQL_RES *mysql_res, static void Dpt_ListDepartmentsForEdition (const struct Dpt_Departments *Departments); static void Dpt_PutParDptCod (void *DptCod); -static void Dpt_RenameDepartment (Nam_ShrtOrFullName_t ShrtOrFullName); +static void Dpt_RenameDepartment (Nam_ShrtOrFullName_t ShrtOrFull); static void Dpt_PutFormToCreateDepartment (void); static void Dpt_PutHeadDepartments (void); @@ -668,11 +668,11 @@ void Dpt_RenameDepartFull (void) /************************ Change the name of a degree ************************/ /*****************************************************************************/ -static void Dpt_RenameDepartment (Nam_ShrtOrFullName_t ShrtOrFullName) +static void Dpt_RenameDepartment (Nam_ShrtOrFullName_t ShrtOrFull) { - extern const char *Nam_ParShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern const char *Nam_FldShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern unsigned Nam_MaxBytesShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; + extern const char *Nam_Params[Nam_NUM_SHRT_FULL_NAMES]; + extern const char *Nam_Fields[Nam_NUM_SHRT_FULL_NAMES]; + extern unsigned Nam_MaxBytes[Nam_NUM_SHRT_FULL_NAMES]; extern const char *Txt_X_already_exists; extern const char *Txt_The_department_X_has_been_renamed_as_Y; extern const char *Txt_The_name_X_has_not_changed; @@ -688,7 +688,7 @@ static void Dpt_RenameDepartment (Nam_ShrtOrFullName_t ShrtOrFullName) Dpt_EditingDpt->DptCod = ParCod_GetAndCheckPar (ParCod_Dpt); /* Get the new name for the department */ - Nam_GetParShrtOrFullName (ShrtOrFullName,NewName); + Nam_GetParShrtOrFullName (ShrtOrFull,NewName); /***** Get from the database the old names of the department *****/ Dpt_GetDepartmentDataByCod (Dpt_EditingDpt); @@ -698,10 +698,10 @@ static void Dpt_RenameDepartment (Nam_ShrtOrFullName_t ShrtOrFullName) { /***** Check if old and new names are the same (this happens when return is pressed without changes) *****/ - if (strcmp (CurrentName[ShrtOrFullName],NewName)) // Different names + if (strcmp (CurrentName[ShrtOrFull],NewName)) // Different names { /***** If name department was not in database... *****/ - if (Dpt_DB_CheckIfDepartmentNameExists (Nam_ParShrtOrFullName[ShrtOrFullName], + if (Dpt_DB_CheckIfDepartmentNameExists (Nam_Params[ShrtOrFull], NewName,Dpt_EditingDpt->DptCod, -1L, // Unused 0)) // Unused @@ -710,25 +710,25 @@ static void Dpt_RenameDepartment (Nam_ShrtOrFullName_t ShrtOrFullName) { /* Update the table changing old name by new name */ Dpt_DB_UpdateDptName (Dpt_EditingDpt->DptCod, - Nam_FldShrtOrFullName[ShrtOrFullName],NewName); + Nam_Fields[ShrtOrFull],NewName); /* Write message to show the change made */ Ale_CreateAlert (Ale_SUCCESS,NULL, Txt_The_department_X_has_been_renamed_as_Y, - CurrentName[ShrtOrFullName],NewName); + CurrentName[ShrtOrFull],NewName); } } else // The same name Ale_CreateAlert (Ale_INFO,NULL, Txt_The_name_X_has_not_changed, - CurrentName[ShrtOrFullName]); + CurrentName[ShrtOrFull]); } else Ale_CreateAlertYouCanNotLeaveFieldEmpty (); /***** Update name *****/ - Str_Copy (CurrentName[ShrtOrFullName],NewName, - Nam_MaxBytesShrtOrFullName[ShrtOrFullName]); + Str_Copy (CurrentName[ShrtOrFull],NewName, + Nam_MaxBytes[ShrtOrFull]); } /******************************************************************************/ @@ -796,11 +796,7 @@ static void Dpt_PutFormToCreateDepartment (void) extern const char *Txt_Another_institution; unsigned NumIns; const struct Hie_Node *Ins; - const char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Dpt_EditingDpt->ShrtName, - [Nam_FULL_NAME] = Dpt_EditingDpt->FullName, - }; + const char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Begin form to create *****/ Frm_BeginFormTable (ActNewDpt,NULL,NULL,NULL); @@ -844,6 +840,8 @@ static void Dpt_PutFormToCreateDepartment (void) HTM_TD_End (); /***** Department short name and full name *****/ + Names[Nam_SHRT_NAME] = Dpt_EditingDpt->ShrtName; + Names[Nam_FULL_NAME] = Dpt_EditingDpt->FullName; Nam_NewShortAndFullNames (Names); /***** Department WWW *****/ @@ -896,11 +894,7 @@ static void Dpt_PutHeadDepartments (void) void Dpt_ReceiveFormNewDpt (void) { extern const char *Txt_Created_new_department_X; - char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Dpt_EditingDpt->ShrtName, - [Nam_FULL_NAME] = Dpt_EditingDpt->FullName, - }; + char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Department constructor *****/ Dpt_EditingDepartmentConstructor (); @@ -910,6 +904,8 @@ void Dpt_ReceiveFormNewDpt (void) Dpt_EditingDpt->InsCod = ParCod_GetAndCheckPar (ParCod_OthIns); /* Get department short name and full name */ + Names[Nam_SHRT_NAME] = Dpt_EditingDpt->ShrtName; + Names[Nam_FULL_NAME] = Dpt_EditingDpt->FullName; Nam_GetParsShrtAndFullName (Names); /* Get department WWW */ @@ -921,7 +917,8 @@ void Dpt_ReceiveFormNewDpt (void) if (Dpt_EditingDpt->WWW[0]) { /***** If name of department was not in database... *****/ - if (!Nam_CheckIfNameExists (Dpt_DB_CheckIfDepartmentNameExists,Names, + if (!Nam_CheckIfNameExists (Dpt_DB_CheckIfDepartmentNameExists, + (const char **) Names, -1L, -1L, // Unused 0)) // Unused diff --git a/swad_hierarchy_config.c b/swad_hierarchy_config.c index f2c0fb7d..7ac6d29c 100644 --- a/swad_hierarchy_config.c +++ b/swad_hierarchy_config.c @@ -85,11 +85,11 @@ void HieCfg_Title (bool PutLink,Hie_Level_t Level) /******************* Show short/full name in configuration *******************/ /*****************************************************************************/ -void HieCfg_Name (bool PutForm,Hie_Level_t Level,Nam_ShrtOrFullName_t ShrtOrFullName) +void HieCfg_Name (bool PutForm,Hie_Level_t Level,Nam_ShrtOrFullName_t ShrtOrFull) { - extern const char *Nam_ParShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern unsigned Nam_MaxCharsShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern const char *Nam_ClassShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; + extern const char *Nam_Params[Nam_NUM_SHRT_FULL_NAMES]; + extern unsigned Nam_MaxChars[Nam_NUM_SHRT_FULL_NAMES]; + extern const char *Nam_Classes[Nam_NUM_SHRT_FULL_NAMES]; extern const char **Hie_TxtLevel[Hie_NUM_LEVELS]; extern const char *Txt_Short_name; static Act_Action_t Action[Hie_NUM_LEVELS][Nam_NUM_SHRT_FULL_NAMES] = @@ -113,9 +113,9 @@ void HieCfg_Name (bool PutForm,Hie_Level_t Level,Nam_ShrtOrFullName_t ShrtOrFull HTM_TR_Begin (NULL); /* Label */ - Frm_LabelColumn ("RT",PutForm ? Nam_ParShrtOrFullName[ShrtOrFullName] : + Frm_LabelColumn ("RT",PutForm ? Nam_Params[ShrtOrFull] : NULL, - ShrtOrFullName == Nam_SHRT_NAME ? Txt_Short_name : + ShrtOrFull == Nam_SHRT_NAME ? Txt_Short_name : *Hie_TxtLevel[Level]); /* Data */ @@ -123,21 +123,21 @@ void HieCfg_Name (bool PutForm,Hie_Level_t Level,Nam_ShrtOrFullName_t ShrtOrFull if (PutForm) { /* Form to change full name */ - Frm_BeginForm (Action[Level][ShrtOrFullName]); - HTM_INPUT_TEXT (Nam_ParShrtOrFullName[ShrtOrFullName], - Nam_MaxCharsShrtOrFullName[ShrtOrFullName], - Name[ShrtOrFullName], + Frm_BeginForm (Action[Level][ShrtOrFull]); + HTM_INPUT_TEXT (Nam_Params[ShrtOrFull], + Nam_MaxChars[ShrtOrFull], + Name[ShrtOrFull], HTM_SUBMIT_ON_CHANGE, "id=\"%s\"" " class=\"%s INPUT_%s\"" " required=\"required\"", - Nam_ParShrtOrFullName[ShrtOrFullName], - Nam_ClassShrtOrFullName[ShrtOrFullName], + Nam_Params[ShrtOrFull], + Nam_Classes[ShrtOrFull], The_GetSuffix ()); Frm_EndForm (); } else // I can not edit full name - HTM_Txt (Name[ShrtOrFullName]); + HTM_Txt (Name[ShrtOrFull]); HTM_TD_End (); HTM_TR_End (); diff --git a/swad_hierarchy_config.h b/swad_hierarchy_config.h index 569a2b1e..89838035 100644 --- a/swad_hierarchy_config.h +++ b/swad_hierarchy_config.h @@ -34,7 +34,7 @@ /*****************************************************************************/ void HieCfg_Title (bool PutLink,Hie_Level_t LogoScope); -void HieCfg_Name (bool PutForm,Hie_Level_t Level,Nam_ShrtOrFullName_t ShrtOrFullName); +void HieCfg_Name (bool PutForm,Hie_Level_t Level,Nam_ShrtOrFullName_t ShrtOrFull); void HieCfg_WWW (bool PrintView,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); diff --git a/swad_institution.c b/swad_institution.c index 7299054d..fc98a9be 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -1140,11 +1140,11 @@ void Ins_RenameInsFull (void) /******************** Change the name of an institution **********************/ /*****************************************************************************/ -void Ins_RenameInstitution (struct Hie_Node *Ins,Nam_ShrtOrFullName_t ShrtOrFullName) +void Ins_RenameInstitution (struct Hie_Node *Ins,Nam_ShrtOrFullName_t ShrtOrFull) { - extern const char *Nam_ParShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern const char *Nam_FldShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern unsigned Nam_MaxBytesShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; + extern const char *Nam_Params[Nam_NUM_SHRT_FULL_NAMES]; + extern const char *Nam_Fields[Nam_NUM_SHRT_FULL_NAMES]; + extern unsigned Nam_MaxBytes[Nam_NUM_SHRT_FULL_NAMES]; extern const char *Txt_X_already_exists; extern const char *Txt_The_institution_X_has_been_renamed_as_Y; extern const char *Txt_The_name_X_has_not_changed; @@ -1156,7 +1156,7 @@ void Ins_RenameInstitution (struct Hie_Node *Ins,Nam_ShrtOrFullName_t ShrtOrFull char NewName[Nam_MAX_BYTES_FULL_NAME + 1]; /***** Get the new name for the institution from form *****/ - Nam_GetParShrtOrFullName (ShrtOrFullName,NewName); + Nam_GetParShrtOrFullName (ShrtOrFull,NewName); /***** Get from the database the old names of the institution *****/ Ins_GetInstitDataByCod (Ins); @@ -1166,10 +1166,10 @@ void Ins_RenameInstitution (struct Hie_Node *Ins,Nam_ShrtOrFullName_t ShrtOrFull { /***** Check if old and new names are the same (this happens when return is pressed without changes) *****/ - if (strcmp (CurrentName[ShrtOrFullName],NewName)) // Different names + if (strcmp (CurrentName[ShrtOrFull],NewName)) // Different names { /***** If institution was not in database... *****/ - if (Ins_DB_CheckIfInsNameExistsInCty (Nam_ParShrtOrFullName[ShrtOrFullName], + if (Ins_DB_CheckIfInsNameExistsInCty (Nam_Params[ShrtOrFull], NewName,Ins->HieCod, Gbl.Hierarchy.Node[Hie_CTY].HieCod, 0)) // Unused @@ -1178,22 +1178,22 @@ void Ins_RenameInstitution (struct Hie_Node *Ins,Nam_ShrtOrFullName_t ShrtOrFull { /* Update the table changing old name by new name */ Ins_UpdateInsNameDB (Ins->HieCod, - Nam_FldShrtOrFullName[ShrtOrFullName],NewName); + Nam_Fields[ShrtOrFull],NewName); /* Create message to show the change made */ Ale_CreateAlert (Ale_SUCCESS,NULL, Txt_The_institution_X_has_been_renamed_as_Y, - CurrentName[ShrtOrFullName],NewName); + CurrentName[ShrtOrFull],NewName); /* Change current institution name in order to display it properly */ - Str_Copy (CurrentName[ShrtOrFullName],NewName, - Nam_MaxBytesShrtOrFullName[ShrtOrFullName]); + Str_Copy (CurrentName[ShrtOrFull],NewName, + Nam_MaxBytes[ShrtOrFull]); } } else // The same name Ale_CreateAlert (Ale_INFO,NULL, Txt_The_name_X_has_not_changed, - CurrentName[ShrtOrFullName]); + CurrentName[ShrtOrFull]); } else Ale_CreateAlertYouCanNotLeaveFieldEmpty (); @@ -1330,11 +1330,7 @@ static void Ins_ShowAlertAndButtonToGoToIns (void) static void Ins_PutFormToCreateInstitution (void) { Act_Action_t NextAction = ActUnk; - const char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Ins_EditingIns->ShrtName, - [Nam_FULL_NAME] = Ins_EditingIns->FullName, - }; + const char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Set action depending on role *****/ if (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) @@ -1369,6 +1365,8 @@ static void Ins_PutFormToCreateInstitution (void) HTM_TD_End (); /***** Institution short name and full name *****/ + Names[Nam_SHRT_NAME] = Ins_EditingIns->ShrtName; + Names[Nam_FULL_NAME] = Ins_EditingIns->FullName; Nam_NewShortAndFullNames (Names); /***** Institution WWW *****/ @@ -1479,17 +1477,15 @@ void Ins_ReceiveFormNewIns (void) static void Ins_ReceiveFormRequestOrCreateIns (Hie_Status_t Status) { extern const char *Txt_Created_new_institution_X; - char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Ins_EditingIns->ShrtName, - [Nam_FULL_NAME] = Ins_EditingIns->FullName, - }; + char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Get parameters from form *****/ /* Set institution country */ Ins_EditingIns->PrtCod = Gbl.Hierarchy.Node[Hie_CTY].HieCod; - /* Get institution short name, full name and WWW */ + /* Get institution short name and full name */ + Names[Nam_SHRT_NAME] = Ins_EditingIns->ShrtName; + Names[Nam_FULL_NAME] = Ins_EditingIns->FullName; Nam_GetParsShrtAndFullName (Names); /* Get institution URL */ @@ -1501,8 +1497,10 @@ static void Ins_ReceiveFormRequestOrCreateIns (Hie_Status_t Status) if (Ins_EditingIns->WWW[0]) { /***** If name of institution was not in database... *****/ - if (!Nam_CheckIfNameExists (Ins_DB_CheckIfInsNameExistsInCty,Names, - -1L,Gbl.Hierarchy.Node[Hie_CTY].HieCod, + if (!Nam_CheckIfNameExists (Ins_DB_CheckIfInsNameExistsInCty, + (const char **) Names, + -1L, + Gbl.Hierarchy.Node[Hie_CTY].HieCod, 0)) // Unused { Ins_EditingIns->HieCod = Ins_DB_CreateInstitution (Ins_EditingIns,Status); diff --git a/swad_institution.h b/swad_institution.h index 7f4e43e0..baac2c05 100644 --- a/swad_institution.h +++ b/swad_institution.h @@ -59,7 +59,7 @@ void Ins_WriteSelectorOfInstitution (void); void Ins_RemoveInstitution (void); void Ins_RenameInsShort (void); void Ins_RenameInsFull (void); -void Ins_RenameInstitution (struct Hie_Node *Ins,Nam_ShrtOrFullName_t ShrtOrFullName); +void Ins_RenameInstitution (struct Hie_Node *Ins,Nam_ShrtOrFullName_t ShrtOrFull); void Ins_ChangeInsWWW (void); void Ins_ChangeInsStatus (void); void Ins_ContEditAfterChgIns (void); diff --git a/swad_institution_config.c b/swad_institution_config.c index 3445c07d..b6286338 100644 --- a/swad_institution_config.c +++ b/swad_institution_config.c @@ -535,11 +535,7 @@ void InsCfg_ChangeInsCty (void) { extern const char *Txt_The_country_of_the_institution_X_has_changed_to_Y; struct Hie_Node NewCty; - char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Gbl.Hierarchy.Node[Hie_INS].ShrtName, - [Nam_FULL_NAME] = Gbl.Hierarchy.Node[Hie_INS].FullName, - }; + const char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Get the new country code for the institution *****/ NewCty.HieCod = ParCod_GetAndCheckPar (ParCod_OthCty); @@ -551,8 +547,12 @@ void InsCfg_ChangeInsCty (void) Cty_GetBasicCountryDataByCod (&NewCty); /***** Check if it already exists an institution with the same name in the new country *****/ - if (!Nam_CheckIfNameExists (Ins_DB_CheckIfInsNameExistsInCty,Names, - -1L,NewCty.HieCod, + Names[Nam_SHRT_NAME] = Gbl.Hierarchy.Node[Hie_INS].ShrtName; + Names[Nam_FULL_NAME] = Gbl.Hierarchy.Node[Hie_INS].FullName; + if (!Nam_CheckIfNameExists (Ins_DB_CheckIfInsNameExistsInCty, + Names, + -1L, + NewCty.HieCod, 0)) // Unused { /***** Update the table changing the country of the institution *****/ diff --git a/swad_link.c b/swad_link.c index 9820a326..83baca7e 100644 --- a/swad_link.c +++ b/swad_link.c @@ -96,7 +96,7 @@ static void Lnk_FreeListLinks (struct Lnk_Links *Links); static void Lnk_ListLinksForEdition (const struct Lnk_Links *Links); static void Lnk_PutParLnkCod (void *LnkCod); -static void Lnk_RenameLink (Nam_ShrtOrFullName_t ShrtOrFullName); +static void Lnk_RenameLink (Nam_ShrtOrFullName_t ShrtOrFull); static void Lnk_PutFormToCreateLink (void); static void Lnk_PutHeadLinks (void); @@ -524,11 +524,11 @@ void Lnk_RenameLinkFull (void) /************************ Change the name of a link **************************/ /*****************************************************************************/ -static void Lnk_RenameLink (Nam_ShrtOrFullName_t ShrtOrFullName) +static void Lnk_RenameLink (Nam_ShrtOrFullName_t ShrtOrFull) { - extern const char *Nam_ParShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern const char *Nam_FldShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern unsigned Nam_MaxBytesShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; + extern const char *Nam_Params[Nam_NUM_SHRT_FULL_NAMES]; + extern const char *Nam_Fields[Nam_NUM_SHRT_FULL_NAMES]; + extern unsigned Nam_MaxBytes[Nam_NUM_SHRT_FULL_NAMES]; extern const char *Txt_X_already_exists; extern const char *Txt_The_link_X_has_been_renamed_as_Y; extern const char *Txt_The_name_X_has_not_changed; @@ -544,7 +544,7 @@ static void Lnk_RenameLink (Nam_ShrtOrFullName_t ShrtOrFullName) Lnk_EditingLnk->LnkCod = ParCod_GetAndCheckPar (ParCod_Lnk); /* Get the new name for the link */ - Nam_GetParShrtOrFullName (ShrtOrFullName,NewName); + Nam_GetParShrtOrFullName (ShrtOrFull,NewName); /***** Get link data from the database *****/ Lnk_GetLinkDataByCod (Lnk_EditingLnk); @@ -554,10 +554,10 @@ static void Lnk_RenameLink (Nam_ShrtOrFullName_t ShrtOrFullName) { /***** Check if old and new names are the same (this happens when return is pressed without changes) *****/ - if (strcmp (CurrentName[ShrtOrFullName],NewName)) // Different names + if (strcmp (CurrentName[ShrtOrFull],NewName)) // Different names { /***** If link was in database... *****/ - if (Lnk_DB_CheckIfLinkNameExists (Nam_ParShrtOrFullName[ShrtOrFullName], + if (Lnk_DB_CheckIfLinkNameExists (Nam_Params[ShrtOrFull], NewName,Lnk_EditingLnk->LnkCod, -1L, // Unused 0)) // Unused @@ -566,25 +566,25 @@ static void Lnk_RenameLink (Nam_ShrtOrFullName_t ShrtOrFullName) { /* Update the table changing old name by new name */ Lnk_DB_UpdateLnkName (Lnk_EditingLnk->LnkCod, - Nam_FldShrtOrFullName[ShrtOrFullName],NewName); + Nam_Fields[ShrtOrFull],NewName); /* Write message to show the change made */ Ale_CreateAlert (Ale_SUCCESS,NULL, Txt_The_link_X_has_been_renamed_as_Y, - CurrentName[ShrtOrFullName],NewName); + CurrentName[ShrtOrFull],NewName); } } else // The same name Ale_CreateAlert (Ale_INFO,NULL, Txt_The_name_X_has_not_changed, - CurrentName[ShrtOrFullName]); + CurrentName[ShrtOrFull]); } else Ale_CreateAlertYouCanNotLeaveFieldEmpty (); /***** Update name *****/ - Str_Copy (CurrentName[ShrtOrFullName],NewName, - Nam_MaxBytesShrtOrFullName[ShrtOrFullName]); + Str_Copy (CurrentName[ShrtOrFull],NewName, + Nam_MaxBytes[ShrtOrFull]); } /*****************************************************************************/ @@ -649,11 +649,7 @@ void Lnk_ContEditAfterChgLnk (void) static void Lnk_PutFormToCreateLink (void) { - const char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Lnk_EditingLnk->ShrtName, - [Nam_FULL_NAME] = Lnk_EditingLnk->FullName, - }; + const char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Begin form to create *****/ Frm_BeginFormTable (ActNewLnk,NULL,NULL,NULL); @@ -672,6 +668,8 @@ static void Lnk_PutFormToCreateLink (void) HTM_TD_End (); /***** Link short name and full name *****/ + Names[Nam_SHRT_NAME] = Lnk_EditingLnk->ShrtName; + Names[Nam_FULL_NAME] = Lnk_EditingLnk->FullName; Nam_NewShortAndFullNames (Names); /***** Link WWW *****/ @@ -716,17 +714,15 @@ void Lnk_ReceiveFormNewLink (void) { extern const char *Txt_You_must_specify_the_web_address; extern const char *Txt_Created_new_link_X; - char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Lnk_EditingLnk->ShrtName, - [Nam_FULL_NAME] = Lnk_EditingLnk->FullName, - }; + char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Link constructor *****/ Lnk_EditingLinkConstructor (); /***** Get parameters from form *****/ /* Get link short name and full name */ + Names[Nam_SHRT_NAME] = Lnk_EditingLnk->ShrtName; + Names[Nam_FULL_NAME] = Lnk_EditingLnk->FullName; Nam_GetParsShrtAndFullName (Names); /* Get link URL */ @@ -736,7 +732,8 @@ void Lnk_ReceiveFormNewLink (void) Lnk_EditingLnk->FullName[0]) // If there's a link name { /***** If name of link was in database... *****/ - if (!Nam_CheckIfNameExists (Lnk_DB_CheckIfLinkNameExists,Names, + if (!Nam_CheckIfNameExists (Lnk_DB_CheckIfLinkNameExists, + (const char **) Names, -1L, -1L, // Unused 0)) // Unused diff --git a/swad_mail.c b/swad_mail.c index 45afa2e5..3a47c433 100644 --- a/swad_mail.c +++ b/swad_mail.c @@ -91,7 +91,7 @@ static void Mai_FreeListMailDomains (struct Mai_Mails *Mails); static void Mai_ListMailDomainsForEdition (const struct Mai_Mails *Mails); static void Mai_PutParMaiCod (void *MaiCod); -static void Mai_RenameMailDomain (Nam_ShrtOrFullName_t ShrtOrFullName); +static void Mai_RenameMailDomain (Nam_ShrtOrFullName_t ShrtOrFull); static void Mai_PutFormToCreateMailDomain (void); static void Mai_PutHeadMailDomains (void); @@ -585,7 +585,7 @@ void Mai_RenameMailDomainFull (void) /************************* Change the name of a mail *************************/ /*****************************************************************************/ -static void Mai_RenameMailDomain (Nam_ShrtOrFullName_t ShrtOrFullName) +static void Mai_RenameMailDomain (Nam_ShrtOrFullName_t ShrtOrFull) { extern const char *Txt_The_email_domain_X_already_exists; extern const char *Txt_The_email_domain_X_has_been_renamed_as_Y; @@ -617,7 +617,7 @@ static void Mai_RenameMailDomain (Nam_ShrtOrFullName_t ShrtOrFullName) Mai_EditingMai->MaiCod = ParCod_GetAndCheckPar (ParCod_Mai); /* Get the new name for the mail */ - Par_GetParText (ParName[ShrtOrFullName],NewName,MaxBytes[ShrtOrFullName]); + Par_GetParText (ParName[ShrtOrFull],NewName,MaxBytes[ShrtOrFull]); /***** Get from the database the old names of the mail *****/ Mai_GetMailDomainDataByCod (Mai_EditingMai); @@ -627,34 +627,34 @@ static void Mai_RenameMailDomain (Nam_ShrtOrFullName_t ShrtOrFullName) { /***** Check if old and new names are the same (this happens when return is pressed without changes) *****/ - if (strcmp (CurrentName[ShrtOrFullName],NewName)) // Different names + if (strcmp (CurrentName[ShrtOrFull],NewName)) // Different names { /***** If mail was in database... *****/ - if (Mai_DB_CheckIfMailDomainNameExists (ParName[ShrtOrFullName],NewName,Mai_EditingMai->MaiCod)) + if (Mai_DB_CheckIfMailDomainNameExists (ParName[ShrtOrFull],NewName,Mai_EditingMai->MaiCod)) Ale_CreateAlert (Ale_WARNING,Mai_EMAIL_SECTION_ID, Txt_The_email_domain_X_already_exists, NewName); else { /* Update the table changing old name by new name */ - Mai_DB_UpdateMailDomainName (Mai_EditingMai->MaiCod,FldName[ShrtOrFullName],NewName); + Mai_DB_UpdateMailDomainName (Mai_EditingMai->MaiCod,FldName[ShrtOrFull],NewName); /* Write message to show the change made */ Ale_CreateAlert (Ale_SUCCESS,Mai_EMAIL_SECTION_ID, Txt_The_email_domain_X_has_been_renamed_as_Y, - CurrentName[ShrtOrFullName],NewName); + CurrentName[ShrtOrFull],NewName); } } else // The same name Ale_CreateAlert (Ale_INFO,Mai_EMAIL_SECTION_ID, Txt_The_email_domain_X_has_not_changed, - CurrentName[ShrtOrFullName]); + CurrentName[ShrtOrFull]); } else Ale_CreateAlertYouCanNotLeaveFieldEmpty (); /***** Update name *****/ - Str_Copy (CurrentName[ShrtOrFullName],NewName,MaxBytes[ShrtOrFullName]); + Str_Copy (CurrentName[ShrtOrFull],NewName,MaxBytes[ShrtOrFull]); } /*****************************************************************************/ diff --git a/swad_name.c b/swad_name.c index a51b81dc..cd768490 100644 --- a/swad_name.c +++ b/swad_name.c @@ -36,77 +36,49 @@ /***************************** Public constants ******************************/ /*****************************************************************************/ -const char *Nam_ParShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES] = +const char *Nam_Params[Nam_NUM_SHRT_FULL_NAMES] = { [Nam_SHRT_NAME] = "ShortName", [Nam_FULL_NAME] = "FullName", }; -const char *Nam_FldShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES] = +const char *Nam_Fields[Nam_NUM_SHRT_FULL_NAMES] = { [Nam_SHRT_NAME] = "ShortName", [Nam_FULL_NAME] = "FullName", }; -unsigned Nam_MaxCharsShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES] = +unsigned Nam_MaxChars[Nam_NUM_SHRT_FULL_NAMES] = { [Nam_SHRT_NAME] = Nam_MAX_CHARS_SHRT_NAME, [Nam_FULL_NAME] = Nam_MAX_CHARS_FULL_NAME, }; -unsigned Nam_MaxBytesShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES] = +unsigned Nam_MaxBytes[Nam_NUM_SHRT_FULL_NAMES] = { [Nam_SHRT_NAME] = Nam_MAX_BYTES_SHRT_NAME, [Nam_FULL_NAME] = Nam_MAX_BYTES_FULL_NAME, }; -const char *Nam_ClassShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES] = +const char *Nam_Classes[Nam_NUM_SHRT_FULL_NAMES] = { [Nam_SHRT_NAME] = "INPUT_SHORT_NAME", [Nam_FULL_NAME] = "INPUT_FULL_NAME", }; -/*****************************************************************************/ -/**************************** Private constants ******************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/******************************* Private types *******************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/************** External global variables from others modules ****************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/************************** Public global variables **************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/************************* Private global variables **************************/ -/*****************************************************************************/ - -/*****************************************************************************/ -/***************************** Private prototypes ****************************/ -/*****************************************************************************/ - /*****************************************************************************/ /************************ Get short name and full name ***********************/ /*****************************************************************************/ void Nam_GetParsShrtAndFullName (char *Names[Nam_NUM_SHRT_FULL_NAMES]) { - Nam_ShrtOrFullName_t ShrtOrFullName; + Nam_ShrtOrFullName_t ShrtOrFull; - for (ShrtOrFullName = Nam_SHRT_NAME; - ShrtOrFullName <= Nam_FULL_NAME; - ShrtOrFullName++) - Nam_GetParShrtOrFullName (ShrtOrFullName,Names[ShrtOrFullName]); + for (ShrtOrFull = Nam_SHRT_NAME; + ShrtOrFull <= Nam_FULL_NAME; + ShrtOrFull++) + Nam_GetParShrtOrFullName (ShrtOrFull,Names[ShrtOrFull]); } -void Nam_GetParShrtOrFullName (Nam_ShrtOrFullName_t ShrtOrFullName,char *Name) +void Nam_GetParShrtOrFullName (Nam_ShrtOrFullName_t ShrtOrFull,char *Name) { - extern const char *Nam_ParShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern unsigned Nam_MaxBytesShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - - Par_GetParText (Nam_ParShrtOrFullName[ShrtOrFullName],Name, - Nam_MaxBytesShrtOrFullName[ShrtOrFullName]); + Par_GetParText (Nam_Params[ShrtOrFull],Name,Nam_MaxBytes[ShrtOrFull]); } /*****************************************************************************/ @@ -115,24 +87,18 @@ void Nam_GetParShrtOrFullName (Nam_ShrtOrFullName_t ShrtOrFullName,char *Name) void Nam_NewShortAndFullNames (const char *Names[Nam_NUM_SHRT_FULL_NAMES]) { - extern const char *Nam_ParShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern unsigned Nam_MaxCharsShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern const char *Nam_ClassShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - Nam_ShrtOrFullName_t ShrtOrFullName; + Nam_ShrtOrFullName_t ShrtOrFull; - for (ShrtOrFullName = Nam_SHRT_NAME; - ShrtOrFullName <= Nam_FULL_NAME; - ShrtOrFullName++) + for (ShrtOrFull = Nam_SHRT_NAME; + ShrtOrFull <= Nam_FULL_NAME; + ShrtOrFull++) { HTM_TD_Begin ("class=\"CM\""); - HTM_INPUT_TEXT (Nam_ParShrtOrFullName[ShrtOrFullName], - Nam_MaxCharsShrtOrFullName[ShrtOrFullName], - Names[ShrtOrFullName], + HTM_INPUT_TEXT (Nam_Params[ShrtOrFull],Nam_MaxChars[ShrtOrFull], + Names[ShrtOrFull], HTM_DONT_SUBMIT_ON_CHANGE, - "class=\"%s INPUT_%s\"" - " required=\"required\"", - Nam_ClassShrtOrFullName[ShrtOrFullName], - The_GetSuffix ()); + "class=\"%s INPUT_%s\" required=\"required\"", + Nam_Classes[ShrtOrFull],The_GetSuffix ()); HTM_TD_End (); } } @@ -142,32 +108,26 @@ void Nam_ExistingShortAndFullNames (Act_Action_t ActionRename[Nam_NUM_SHRT_FULL_ const char *Names[Nam_NUM_SHRT_FULL_NAMES], bool PutForm) { - extern const char *Nam_ParShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern unsigned Nam_MaxCharsShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern const char *Nam_ClassShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - Nam_ShrtOrFullName_t ShrtOrFullName; + Nam_ShrtOrFullName_t ShrtOrFull; - for (ShrtOrFullName = Nam_SHRT_NAME; - ShrtOrFullName <= Nam_FULL_NAME; - ShrtOrFullName++) + for (ShrtOrFull = Nam_SHRT_NAME; + ShrtOrFull <= Nam_FULL_NAME; + ShrtOrFull++) { HTM_TD_Begin ("class=\"LM DAT_%s\"",The_GetSuffix ()); if (PutForm) { - Frm_BeginForm (ActionRename[ShrtOrFullName]); + Frm_BeginForm (ActionRename[ShrtOrFull]); ParCod_PutPar (ParCod,Cod); - HTM_INPUT_TEXT (Nam_ParShrtOrFullName[ShrtOrFullName], - Nam_MaxCharsShrtOrFullName[ShrtOrFullName], - Names[ShrtOrFullName], + HTM_INPUT_TEXT (Nam_Params[ShrtOrFull],Nam_MaxChars[ShrtOrFull], + Names[ShrtOrFull], HTM_SUBMIT_ON_CHANGE, - "class=\"%s INPUT_%s\"" - " required=\"required\"", - Nam_ClassShrtOrFullName[ShrtOrFullName], - The_GetSuffix ()); + "class=\"%s INPUT_%s\" required=\"required\"", + Nam_Classes[ShrtOrFull],The_GetSuffix ()); Frm_EndForm (); } else - HTM_Txt (Names[ShrtOrFullName]); + HTM_Txt (Names[ShrtOrFull]); HTM_TD_End (); } } @@ -178,21 +138,18 @@ void Nam_ExistingShortAndFullNames (Act_Action_t ActionRename[Nam_NUM_SHRT_FULL_ bool Nam_CheckIfNameExists (bool (*FuncToCheck) (const char *FldName,const char *Name, long Cod,long PrtCod,unsigned Year), - char *Names[Nam_NUM_SHRT_FULL_NAMES], + const char *Names[Nam_NUM_SHRT_FULL_NAMES], long Cod,long PrtCod,unsigned Year) { - extern const char *Nam_FldShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; extern const char *Txt_X_already_exists; - Nam_ShrtOrFullName_t ShrtOrFullName; + Nam_ShrtOrFullName_t ShrtOrFull; - for (ShrtOrFullName = Nam_SHRT_NAME; - ShrtOrFullName <= Nam_FULL_NAME; - ShrtOrFullName++) - if (FuncToCheck (Nam_FldShrtOrFullName[ShrtOrFullName], - Names[ShrtOrFullName],Cod,PrtCod,Year)) + for (ShrtOrFull = Nam_SHRT_NAME; + ShrtOrFull <= Nam_FULL_NAME; + ShrtOrFull++) + if (FuncToCheck (Nam_Fields[ShrtOrFull],Names[ShrtOrFull],Cod,PrtCod,Year)) { - Ale_CreateAlert (Ale_WARNING,NULL,Txt_X_already_exists, - Names[ShrtOrFullName]); + Ale_CreateAlert (Ale_WARNING,NULL,Txt_X_already_exists,Names[ShrtOrFull]); return true; // Exists } diff --git a/swad_name.h b/swad_name.h index 44a70bd6..3f5adb5a 100644 --- a/swad_name.h +++ b/swad_name.h @@ -58,7 +58,7 @@ typedef enum /*****************************************************************************/ void Nam_GetParsShrtAndFullName (char *Names[Nam_NUM_SHRT_FULL_NAMES]); -void Nam_GetParShrtOrFullName (Nam_ShrtOrFullName_t ShrtOrFullName,char *Name); +void Nam_GetParShrtOrFullName (Nam_ShrtOrFullName_t ShrtOrFull,char *Name); void Nam_NewShortAndFullNames (const char *Names[Nam_NUM_SHRT_FULL_NAMES]); void Nam_ExistingShortAndFullNames (Act_Action_t ActionRename[Nam_NUM_SHRT_FULL_NAMES], @@ -68,7 +68,7 @@ void Nam_ExistingShortAndFullNames (Act_Action_t ActionRename[Nam_NUM_SHRT_FULL_ bool Nam_CheckIfNameExists (bool (*FuncToCheck) (const char *FldName,const char *Name, long Cod,long PrtCod,unsigned Year), - char *Names[Nam_NUM_SHRT_FULL_NAMES], + const char *Names[Nam_NUM_SHRT_FULL_NAMES], long Cod,long PrtCod,unsigned Year); #endif diff --git a/swad_place.c b/swad_place.c index 540f94f4..dfc084ce 100644 --- a/swad_place.c +++ b/swad_place.c @@ -83,7 +83,7 @@ static void Plc_GetPlaceDataFromRow (MYSQL_RES *mysql_res,struct Plc_Place *Plc) static void Plc_ListPlacesForEdition (const struct Plc_Places *Places); static void Plc_PutParPlcCod (void *PlcCod); -static void Plc_RenamePlace (Nam_ShrtOrFullName_t ShrtOrFullName); +static void Plc_RenamePlace (Nam_ShrtOrFullName_t ShrtOrFull); static void Plc_PutFormToCreatePlace (void); static void Plc_PutHeadPlaces (void); @@ -577,11 +577,11 @@ void Plc_RenamePlaceFull (void) /************************ Change the name of a place *************************/ /*****************************************************************************/ -static void Plc_RenamePlace (Nam_ShrtOrFullName_t ShrtOrFullName) +static void Plc_RenamePlace (Nam_ShrtOrFullName_t ShrtOrFull) { - extern const char *Nam_ParShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern const char *Nam_FldShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern unsigned Nam_MaxBytesShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; + extern const char *Nam_Params[Nam_NUM_SHRT_FULL_NAMES]; + extern const char *Nam_Fields[Nam_NUM_SHRT_FULL_NAMES]; + extern unsigned Nam_MaxBytes[Nam_NUM_SHRT_FULL_NAMES]; extern const char *Txt_X_already_exists; extern const char *Txt_The_place_X_has_been_renamed_as_Y; extern const char *Txt_The_name_X_has_not_changed; @@ -597,7 +597,7 @@ static void Plc_RenamePlace (Nam_ShrtOrFullName_t ShrtOrFullName) Plc_EditingPlc->PlcCod = ParCod_GetAndCheckPar (ParCod_Plc); /* Get the new name for the place */ - Nam_GetParShrtOrFullName (ShrtOrFullName,NewName); + Nam_GetParShrtOrFullName (ShrtOrFull,NewName); /***** Get place old names from database *****/ Plc_GetPlaceDataByCod (Plc_EditingPlc); @@ -607,10 +607,10 @@ static void Plc_RenamePlace (Nam_ShrtOrFullName_t ShrtOrFullName) { /***** Check if old and new names are the same (this happens when return is pressed without changes) *****/ - if (strcmp (CurrentName[ShrtOrFullName],NewName)) // Different names + if (strcmp (CurrentName[ShrtOrFull],NewName)) // Different names { /***** If place was in database... *****/ - if (Plc_DB_CheckIfPlaceNameExists (Nam_ParShrtOrFullName[ShrtOrFullName], + if (Plc_DB_CheckIfPlaceNameExists (Nam_Params[ShrtOrFull], NewName,Plc_EditingPlc->PlcCod, Gbl.Hierarchy.Node[Hie_INS].HieCod, 0)) // Unused @@ -619,25 +619,25 @@ static void Plc_RenamePlace (Nam_ShrtOrFullName_t ShrtOrFullName) { /* Update the table changing old name by new name */ Plc_DB_UpdatePlcName (Plc_EditingPlc->PlcCod, - Nam_FldShrtOrFullName[ShrtOrFullName],NewName); + Nam_Fields[ShrtOrFull],NewName); /* Write message to show the change made */ Ale_CreateAlert (Ale_SUCCESS,NULL, Txt_The_place_X_has_been_renamed_as_Y, - CurrentName[ShrtOrFullName],NewName); + CurrentName[ShrtOrFull],NewName); } } else // The same name Ale_CreateAlert (Ale_INFO,NULL, Txt_The_name_X_has_not_changed, - CurrentName[ShrtOrFullName]); + CurrentName[ShrtOrFull]); } else Ale_CreateAlertYouCanNotLeaveFieldEmpty (); /***** Update place name *****/ - Str_Copy (CurrentName[ShrtOrFullName],NewName, - Nam_MaxBytesShrtOrFullName[ShrtOrFullName]); + Str_Copy (CurrentName[ShrtOrFull],NewName, + Nam_MaxBytes[ShrtOrFull]); } /*****************************************************************************/ @@ -662,11 +662,7 @@ void Plc_ContEditAfterChgPlc (void) static void Plc_PutFormToCreatePlace (void) { - const char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Plc_EditingPlc->ShrtName, - [Nam_FULL_NAME] = Plc_EditingPlc->FullName, - }; + const char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Begin form to create *****/ Frm_BeginFormTable (ActNewPlc,NULL,NULL,NULL); @@ -685,6 +681,8 @@ static void Plc_PutFormToCreatePlace (void) HTM_TD_End (); /***** Place short name and full name *****/ + Names[Nam_SHRT_NAME] = Plc_EditingPlc->ShrtName; + Names[Nam_FULL_NAME] = Plc_EditingPlc->FullName; Nam_NewShortAndFullNames (Names); /***** Number of centers *****/ @@ -725,25 +723,25 @@ static void Plc_PutHeadPlaces (void) void Plc_ReceiveFormNewPlace (void) { extern const char *Txt_Created_new_place_X; - char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Plc_EditingPlc->ShrtName, - [Nam_FULL_NAME] = Plc_EditingPlc->FullName, - }; + char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Place constructor *****/ Plc_EditingPlaceConstructor (); /***** Get parameters from form *****/ /* Get place short name and full name */ + Names[Nam_SHRT_NAME] = Plc_EditingPlc->ShrtName; + Names[Nam_FULL_NAME] = Plc_EditingPlc->FullName; Nam_GetParsShrtAndFullName (Names); if (Plc_EditingPlc->ShrtName[0] && Plc_EditingPlc->FullName[0]) // If there's a place name { /***** If name of place was not in database... *****/ - if (!Nam_CheckIfNameExists (Plc_DB_CheckIfPlaceNameExists,Names, - -1L,Gbl.Hierarchy.Node[Hie_INS].HieCod, + if (!Nam_CheckIfNameExists (Plc_DB_CheckIfPlaceNameExists, + (const char **) Names, + -1L, + Gbl.Hierarchy.Node[Hie_INS].HieCod, 0)) // Unused { Plc_DB_CreatePlace (Plc_EditingPlc); diff --git a/swad_room.c b/swad_room.c index 0a336b25..58fd6c6c 100644 --- a/swad_room.c +++ b/swad_room.c @@ -122,7 +122,7 @@ static void Roo_PutSelectorType (Roo_RoomType_t RoomType, static int Roo_GetParFloor (void); static Roo_RoomType_t Roo_GetParType (void); -static void Roo_RenameRoom (Nam_ShrtOrFullName_t ShrtOrFullName); +static void Roo_RenameRoom (Nam_ShrtOrFullName_t ShrtOrFull); static void Roo_WriteCapacity (char Str[Cns_MAX_DECIMAL_DIGITS_UINT + 1],unsigned Capacity); @@ -1044,11 +1044,11 @@ void Roo_RenameRoomFull (void) /************************* Change the name of a room *************************/ /*****************************************************************************/ -static void Roo_RenameRoom (Nam_ShrtOrFullName_t ShrtOrFullName) +static void Roo_RenameRoom (Nam_ShrtOrFullName_t ShrtOrFull) { - extern const char *Nam_ParShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern const char *Nam_FldShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; - extern unsigned Nam_MaxBytesShrtOrFullName[Nam_NUM_SHRT_FULL_NAMES]; + extern const char *Nam_Params[Nam_NUM_SHRT_FULL_NAMES]; + extern const char *Nam_Fields[Nam_NUM_SHRT_FULL_NAMES]; + extern unsigned Nam_MaxBytes[Nam_NUM_SHRT_FULL_NAMES]; extern const char *Txt_X_already_exists; extern const char *Txt_The_room_X_has_been_renamed_as_Y; extern const char *Txt_The_name_X_has_not_changed; @@ -1064,7 +1064,7 @@ static void Roo_RenameRoom (Nam_ShrtOrFullName_t ShrtOrFullName) Roo_EditingRoom->RooCod = ParCod_GetAndCheckPar (ParCod_Roo); /* Get the new name for the room */ - Nam_GetParShrtOrFullName (ShrtOrFullName,NewName); + Nam_GetParShrtOrFullName (ShrtOrFull,NewName); /***** Get from the database the old names of the room *****/ Roo_GetRoomDataByCod (Roo_EditingRoom); @@ -1074,10 +1074,10 @@ static void Roo_RenameRoom (Nam_ShrtOrFullName_t ShrtOrFullName) { /***** Check if old and new names are the same (this happens when return is pressed without changes) *****/ - if (strcmp (CurrentName[ShrtOrFullName],NewName)) // Different names + if (strcmp (CurrentName[ShrtOrFull],NewName)) // Different names { /***** If room was in database... *****/ - if (Roo_DB_CheckIfRoomNameExists (Nam_ParShrtOrFullName[ShrtOrFullName], + if (Roo_DB_CheckIfRoomNameExists (Nam_Params[ShrtOrFull], NewName,Roo_EditingRoom->RooCod, Gbl.Hierarchy.Node[Hie_CTR].HieCod, 0)) // Unused @@ -1087,25 +1087,25 @@ static void Roo_RenameRoom (Nam_ShrtOrFullName_t ShrtOrFullName) { /* Update the table changing old name by new name */ Roo_DB_UpdateRoomName (Roo_EditingRoom->RooCod, - Nam_FldShrtOrFullName[ShrtOrFullName],NewName); + Nam_Fields[ShrtOrFull],NewName); /* Write message to show the change made */ Ale_CreateAlert (Ale_SUCCESS,NULL, Txt_The_room_X_has_been_renamed_as_Y, - CurrentName[ShrtOrFullName],NewName); + CurrentName[ShrtOrFull],NewName); } } else // The same name Ale_CreateAlert (Ale_INFO,NULL, Txt_The_name_X_has_not_changed, - CurrentName[ShrtOrFullName]); + CurrentName[ShrtOrFull]); } else Ale_CreateAlertYouCanNotLeaveFieldEmpty (); /***** Update room name *****/ - Str_Copy (CurrentName[ShrtOrFullName],NewName, - Nam_MaxBytesShrtOrFullName[ShrtOrFullName]); + Str_Copy (CurrentName[ShrtOrFull],NewName, + Nam_MaxBytes[ShrtOrFull]); } /*****************************************************************************/ @@ -1197,11 +1197,7 @@ static void Roo_PutFormToCreateRoom (const struct Bld_Buildings *Buildings) { char StrCapacity[Cns_MAX_DECIMAL_DIGITS_UINT + 1]; char MACstr[MAC_LENGTH_MAC_ADDRESS + 1]; // MAC address in xx:xx:xx:xx:xx:xx format - const char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Roo_EditingRoom->ShrtName, - [Nam_FULL_NAME] = Roo_EditingRoom->FullName, - }; + const char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Begin form to create *****/ Frm_BeginFormTable (ActNewRoo,NULL,NULL,NULL); @@ -1240,6 +1236,8 @@ static void Roo_PutFormToCreateRoom (const struct Bld_Buildings *Buildings) HTM_TD_End (); /***** Room short name and full name *****/ + Names[Nam_SHRT_NAME] = Roo_EditingRoom->ShrtName; + Names[Nam_FULL_NAME] = Roo_EditingRoom->FullName; Nam_NewShortAndFullNames (Names); /***** Seating capacity *****/ @@ -1301,11 +1299,7 @@ static void Roo_PutHeadRooms (void) void Roo_ReceiveFormNewRoom (void) { extern const char *Txt_Created_new_room_X; - char *Names[Nam_NUM_SHRT_FULL_NAMES] = - { - [Nam_SHRT_NAME] = Roo_EditingRoom->ShrtName, - [Nam_FULL_NAME] = Roo_EditingRoom->FullName, - }; + char *Names[Nam_NUM_SHRT_FULL_NAMES]; /***** Room constructor *****/ Roo_EditingRoomConstructor (); @@ -1317,6 +1311,8 @@ void Roo_ReceiveFormNewRoom (void) Roo_EditingRoom->Type = Roo_GetParType (); /* Get room short name and full name */ + Names[Nam_SHRT_NAME] = Roo_EditingRoom->ShrtName; + Names[Nam_FULL_NAME] = Roo_EditingRoom->FullName; Nam_GetParsShrtAndFullName (Names); /* Get seating capacity */ @@ -1333,8 +1329,10 @@ void Roo_ReceiveFormNewRoom (void) Roo_EditingRoom->FullName[0]) // If there's a room name { /***** If name of room was not in database... *****/ - if (!Nam_CheckIfNameExists (Roo_DB_CheckIfRoomNameExists,Names, - -1L,Gbl.Hierarchy.Node[Hie_CTR].HieCod, + if (!Nam_CheckIfNameExists (Roo_DB_CheckIfRoomNameExists, + (const char **) Names, + -1L, + Gbl.Hierarchy.Node[Hie_CTR].HieCod, 0)) // Unused { Roo_CreateRoom (Roo_EditingRoom);