Version 23.5.1: Sep 18, 2023 Code refactoring in edition of countries.

This commit is contained in:
acanas 2023-09-18 09:00:53 +02:00
parent 51b5f81cb8
commit d8be00fad4
5 changed files with 23 additions and 24 deletions

View File

@ -632,10 +632,11 @@ TODO: Francisco Javier Fern
Me sale este error, no si por no recordar yo la sintaxis apropiada para mandar a varios destinatarios. ¿No era así?
"can npt create received message (duplicated entry '243218-2160773' for key 'UsrCod_MsgCod')
*/
#define Log_PLATFORM_VERSION "SWAD 23.5 (2023-09-15)"
#define Log_PLATFORM_VERSION "SWAD 23.5.1 (2023-09-18)"
#define CSS_FILE "swad22.120.4.css"
#define JS_FILE "swad22.49.js"
/*
Version 23.5.1: Sep 18, 2023 Code refactoring in edition of countries. (337657 lines)
Version 23.5: Sep 15, 2023 Code refactoring in edition of countries. (337658 lines)
Version 23.4.1: Sep 15, 2023 Changes in listing and edition of courses. (337619 lines)
Version 23.4: Sep 15, 2023 Code refactoring in hierarchy. (337618 lines)

View File

@ -530,7 +530,7 @@ void Cty_DrawCountryMapAndNameWithLink (struct Cty_Countr *Cty,Act_Action_t Acti
/***** Write country name *****/
Str_Copy (CountryName,Cty->FullName,sizeof (CountryName) - 1);
HTM_TxtF (" %s ",CountryName);
HTM_TxtF ("(%s)",Cty->Alpha2);
HTM_TxtF ("(%s)",Cty->ShrtName);
/***** End link *****/
HTM_BUTTON_End ();
@ -557,9 +557,9 @@ void Cty_DrawCountryMap (struct Cty_Countr *Cty,const char *Class)
/***** Draw country map *****/
if (Cty_CheckIfCountryPhotoExists (Cty))
{
if (asprintf (&URL,"%s/%s",Cfg_URL_ICON_COUNTRIES_PUBLIC,Cty->Alpha2) < 0)
if (asprintf (&URL,"%s/%s",Cfg_URL_ICON_COUNTRIES_PUBLIC,Cty->ShrtName) < 0)
Err_NotEnoughMemoryExit ();
if (asprintf (&Icon,"%s.png",Cty->Alpha2) < 0)
if (asprintf (&Icon,"%s.png",Cty->ShrtName) < 0)
Err_NotEnoughMemoryExit ();
HTM_IMG (URL,Icon,Cty->FullName,"class=\"%s\"",Class);
free (Icon);
@ -580,8 +580,8 @@ bool Cty_CheckIfCountryPhotoExists (struct Cty_Countr *Cty)
snprintf (PathMap,sizeof (PathMap),"%s/%s/%s.png",
Cfg_PATH_ICON_COUNTRIES_PUBLIC,
Cty->Alpha2,
Cty->Alpha2);
Cty->ShrtName,
Cty->ShrtName);
return Fil_CheckIfPathExists (PathMap);
}
@ -629,7 +629,7 @@ void Cty_WriteScriptGoogleGeochart (void)
/* Write data of this country */
HTM_TxtF (" ['%s', %u, %u],\n",
Gbl.Hierarchy.Ctys.Lst[NumCty].Alpha2,NumUsrsCty,NumInss);
Gbl.Hierarchy.Ctys.Lst[NumCty].ShrtName,NumUsrsCty,NumInss);
if (NumUsrsCty > MaxUsrsInCountry)
MaxUsrsInCountry = NumUsrsCty;
NumCtysWithUsrs++;
@ -815,7 +815,7 @@ static void Cty_GetFullListOfCountries (void)
Err_WrongCountrExit ();
/* Get Alpha-2 country code (row[1]) */
Str_Copy (Cty->Alpha2,row[1],sizeof (Cty->Alpha2) - 1);
Str_Copy (Cty->ShrtName,row[1],sizeof (Cty->ShrtName) - 1);
/* Get the name and the web of the country in the current language */
Str_Copy (Cty->FullName,row[2],sizeof (Cty->FullName) - 1);
@ -951,7 +951,7 @@ bool Cty_GetBasicCountryDataByCod (struct Cty_Countr *Cty)
row = mysql_fetch_row (mysql_res);
/* Get Alpha-2 country code (row[0]) */
Str_Copy (Cty->Alpha2,row[0],sizeof (Cty->Alpha2) - 1);
Str_Copy (Cty->ShrtName,row[0],sizeof (Cty->ShrtName) - 1);
/* Get name and WWW of the country in current language */
Str_Copy (Cty->FullName,row[1],sizeof (Cty->FullName) - 1);
@ -1115,7 +1115,7 @@ static void Cty_ListCountriesForEdition (void)
/* Alphabetic country code with 2 letters (ISO 3166-1) */
HTM_TD_Begin ("rowspan=\"%u\" class=\"RT DAT_%s\"",
1 + Lan_NUM_LANGUAGES,The_GetSuffix ());
HTM_Txt (Cty->Alpha2);
HTM_Txt (Cty->ShrtName);
HTM_TD_End ();
HTM_TD_Empty (3);
@ -1447,7 +1447,7 @@ static void Cty_PutFormToCreateCountry (void)
/***** Alphabetic country code with 2 letters (ISO 3166-1) *****/
HTM_TD_Begin ("rowspan=\"%u\" class=\"RT\"",1 + Lan_NUM_LANGUAGES);
HTM_INPUT_TEXT ("Alpha2",2,Cty_EditingCty->Alpha2,HTM_DONT_SUBMIT_ON_CHANGE,
HTM_INPUT_TEXT ("Alpha2",2,Cty_EditingCty->ShrtName,HTM_DONT_SUBMIT_ON_CHANGE,
"size=\"2\" class=\"INPUT_%s\""
" required=\"required\"",
The_GetSuffix ());
@ -1583,26 +1583,26 @@ void Cty_ReceiveFormNewCountry (void)
else // Numeric code correct
{
/* Get alphabetic-2 country code */
Par_GetParText ("Alpha2",Cty_EditingCty->Alpha2,2);
Str_ConvertToUpperText (Cty_EditingCty->Alpha2);
Par_GetParText ("Alpha2",Cty_EditingCty->ShrtName,2);
Str_ConvertToUpperText (Cty_EditingCty->ShrtName);
for (i = 0;
i < 2 && CreateCountry;
i++)
if (Cty_EditingCty->Alpha2[i] < 'A' ||
Cty_EditingCty->Alpha2[i] > 'Z')
if (Cty_EditingCty->ShrtName[i] < 'A' ||
Cty_EditingCty->ShrtName[i] > 'Z')
{
Ale_CreateAlert (Ale_WARNING,NULL,
Txt_The_alphabetical_code_X_is_not_correct,
Cty_EditingCty->Alpha2);
Cty_EditingCty->ShrtName);
CreateCountry = false;
}
if (CreateCountry)
{
if (Cty_DB_CheckIfAlpha2CountryCodeExists (Cty_EditingCty->Alpha2))
if (Cty_DB_CheckIfAlpha2CountryCodeExists (Cty_EditingCty->ShrtName))
{
Ale_CreateAlert (Ale_WARNING,NULL,
Txt_The_alphabetical_code_X_already_exists,
Cty_EditingCty->Alpha2);
Cty_EditingCty->ShrtName);
CreateCountry = false;
}
else // Alphabetic code correct
@ -1854,7 +1854,6 @@ static void Cty_EditingCountryConstructor (void)
/***** Reset country *****/
Cty_EditingCty->Cod = -1L;
Cty_EditingCty->Alpha2[0] = '\0';
Cty_EditingCty->ShrtName[0] = '\0';
Cty_EditingCty->FullName[0] = '\0';
Cty_EditingCty->WWW[0] = '\0';

View File

@ -48,8 +48,7 @@
struct Cty_Countr
{
long Cod; // Country code
char Alpha2[2 + 1];
char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1];
char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]; // Alpha2
char FullName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1];
char WWW[Cns_MAX_BYTES_WWW + 1];
struct

View File

@ -98,7 +98,7 @@ void Cty_DB_CreateCountry (const struct Cty_Countr *Cty,
SubQueryNam1,
SubQueryWWW1,
Cty->Cod,
Cty->Alpha2,
Cty->ShrtName,
SubQueryNam2,
SubQueryWWW2);
}
@ -398,7 +398,7 @@ bool Cty_DB_CheckIfNumericCountryCodeExists (long CtyCod)
/*************** Check if an alphabetic country code exists ******************/
/*****************************************************************************/
bool Cty_DB_CheckIfAlpha2CountryCodeExists (const char Alpha2[2 + 1])
bool Cty_DB_CheckIfAlpha2CountryCodeExists (const char *Alpha2)
{
return
DB_QueryEXISTS ("can not check if the alphabetic code of a country already existed",

View File

@ -58,7 +58,7 @@ unsigned Cty_DB_GetNumCtysWithUsrs (Rol_Role_t Role,
HieLvl_Level_t Level,long Cod);
bool Cty_DB_CheckIfNumericCountryCodeExists (long CtyCod);
bool Cty_DB_CheckIfAlpha2CountryCodeExists (const char Alpha2[2 + 1]);
bool Cty_DB_CheckIfAlpha2CountryCodeExists (const char *Alpha2);
bool Cty_DB_CheckIfCountryNameExists (Lan_Language_t Language,const char *Name,long CtyCod);
unsigned Cty_DB_SearchCtys (MYSQL_RES **mysql_res,