Version 22.71: Mar 08, 2023 Code refactoring in parameters. Not finished.

This commit is contained in:
acanas 2023-03-08 14:45:02 +01:00
parent 4c998fc1b0
commit ce3877188e
10 changed files with 68 additions and 90 deletions

View File

@ -1050,7 +1050,7 @@ void Ctr_ChangeCtrPlc (void)
Ctr_EditingCtr->CtrCod = Par_GetAndCheckParCode (Par_OthHieCod);
/***** Get parameter with place code *****/
NewPlcCod = Plc_GetParamPlcCod ();
NewPlcCod = Par_GetAndCheckParCodeMin (Par_PlcCod,0); // 0 (another place) is allowed here
/***** Get data of center from database *****/
Ctr_GetDataOfCenterByCod (Ctr_EditingCtr);
@ -1535,8 +1535,7 @@ static void Ctr_ReceiveFormRequestOrCreateCtr (Hie_Status_t Status)
Ctr_EditingCtr->InsCod = Gbl.Hierarchy.Ins.InsCod;
/* Get place */
if ((Ctr_EditingCtr->PlcCod = Plc_GetParamPlcCod ()) < 0) // 0 is reserved for "other place"
Err_WrongPlaceExit ();
Ctr_EditingCtr->PlcCod = Par_GetAndCheckParCodeMin (Par_PlcCod,0); // 0 (another place) is allowed here
/* Get center short name and full name */
Par_GetParText ("ShortName",Ctr_EditingCtr->ShrtName,Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);

View File

@ -631,6 +631,7 @@ static void CtrCfg_ShrtName (bool PutForm)
static void CtrCfg_Place (bool PutForm)
{
extern const char *Par_CodeStr[];
extern const char *Txt_Place;
extern const char *Txt_Another_place;
struct Plc_Places Places;
@ -648,7 +649,7 @@ static void CtrCfg_Place (bool PutForm)
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",PutForm ? "PlcCod" :
Frm_LabelColumn ("RT",PutForm ? Par_CodeStr[Par_PlcCod] :
NULL,
Txt_Place);
@ -1060,7 +1061,7 @@ void CtrCfg_ChangeCtrPlc (void)
long NewPlcCod;
/***** Get parameter with place code *****/
NewPlcCod = Plc_GetParamPlcCod ();
NewPlcCod = Par_GetAndCheckParCodeMin (Par_PlcCod,0); // 0 (another place) is allowed here
/***** Update place in table of centers *****/
Ctr_DB_UpdateCtrPlc (Gbl.Hierarchy.Ctr.CtrCod,NewPlcCod);

View File

@ -629,10 +629,11 @@ TODO: Emilce Barrera Mesa: Podr
TODO: Emilce Barrera Mesa: Mis estudiantes presentan muchas dificultades a la hora de poner la foto porque la plataforma es muy exigente respecto al fondo de la imagen.
*/
#define Log_PLATFORM_VERSION "SWAD 22.70 (2023-03-07)"
#define Log_PLATFORM_VERSION "SWAD 22.71 (2023-03-08)"
#define CSS_FILE "swad22.57.1.css"
#define JS_FILE "swad22.49.js"
/*
Version 22.71: Mar 08, 2023 Code refactoring in parameters. Not finished. (336806 lines)
Version 22.70: Mar 07, 2023 Code refactoring in parameters. Not finished. (336824 lines)
Version 22.69: Mar 07, 2023 Code refactoring in parameters. Not finished. (336866 lines)
Version 22.68: Mar 06, 2023 Code refactoring in parameters. Not finished. (336887 lines)

View File

@ -677,7 +677,8 @@ void Hld_ChangeHolidayPlace (void)
Hld_EditingHld->HldCod = Par_GetAndCheckParCode (Par_HldCod);
/* Get the new place for the holiday */
NewPlace.PlcCod = Plc_GetParamPlcCod ();
// <0 (place unspecified/all places) and 0 (another place) are allowed here
NewPlace.PlcCod = Par_GetParCode (Par_PlcCod);
/***** Get from the database the data of the place *****/
Plc_GetDataOfPlaceByCod (&NewPlace);
@ -1022,7 +1023,8 @@ void Hld_ReceiveFormNewHoliday (void)
Hld_EditingHolidayConstructor ();
/***** Get place code *****/
Hld_EditingHld->PlcCod = Plc_GetParamPlcCod ();
// <0 (place unspecified/all places) and 0 (another place) are allowed here
Hld_EditingHld->PlcCod = Par_GetParCode (Par_PlcCod);
/***** Get the type of holiday *****/
Hld_EditingHld->HldTyp = Hld_GetParamHldType ();

View File

@ -57,38 +57,41 @@ const char *Par_SEPARATOR_PARAM_MULTIPLE = "\x0a"; // Must be 1 <= character <=
// Parameter name for codes, some of them also used as database fields (so change carefully)
const char *Par_CodeStr[] =
{
[Par_AgdCod ] = "AgdCod",
[Par_AnnCod ] = "AnnCod",
[Par_AsgCod ] = "AsgCod",
[Par_AttCod ] = "AttCod",
[Par_BanCod ] = "BanCod",
[Par_BldCod ] = "BldCod",
[Par_DptCod ] = "DptCod",
[Par_ExaCod ] = "ExaCod",
[Par_FilCod ] = "FilCod",
[Par_FilterCrsCod] = "FilterCrsCod",
[Par_GamCod ] = "GamCod",
[Par_GrpCod ] = "GrpCod",
[Par_GrpTypCod ] = "GrpTypCod",
[Par_HldCod ] = "HldCod",
[Par_LnkCod ] = "LnkCod",
[Par_MaiCod ] = "MaiCod",
[Par_MchCod ] = "MchCod",
[Par_MsgCod ] = "MsgCod",
[Par_NotCod ] = "NotCod",
[Par_OrgActCod ] = "OrgActCod",
[Par_OthCtrCod ] = "OthCtrCod",
[Par_OthCtyCod ] = "OthCtyCod",
[Par_OthDegCod ] = "OthDegCod",
[Par_OthDegTypCod] = "OthDegTypCod",
[Par_OthHieCod ] = "OthHieCod",
[Par_OthInsCod ] = "OthInsCod",
[Par_PstCod ] = "PstCod",
[Par_PubCod ] = "PubCod",
[Par_QstCod ] = "QstCod",
[Par_SesCod ] = "SesCod",
[Par_SvyCod ] = "SvyCod",
[Par_ThrCod ] = "ThrCod",
[Par_AgdCod ] = "AgdCod", // Agenda event code
[Par_AnnCod ] = "AnnCod", // Announcement code
[Par_AsgCod ] = "AsgCod", // Assignment code
[Par_AttCod ] = "AttCod", // Attendance event code
[Par_BanCod ] = "BanCod", // Banner code
[Par_BldCod ] = "BldCod", // Building code
[Par_DptCod ] = "DptCod", // Department code
[Par_ExaCod ] = "ExaCod", // Exam code in calls for exams and exams
[Par_FilCod ] = "FilCod", // File code
[Par_FilterCrsCod] = "FilterCrsCod", // Course code filtering messages
[Par_GamCod ] = "GamCod", // Game code
[Par_GrpCod ] = "GrpCod", // Group code
[Par_GrpTypCod ] = "GrpTypCod", // Group type code
[Par_HldCod ] = "HldCod", // Holiday code
[Par_LnkCod ] = "LnkCod", // Link code
[Par_MaiCod ] = "MaiCod", // Domain mail code
[Par_MchCod ] = "MchCod", // Match code in game
[Par_MsgCod ] = "MsgCod", // Message code
[Par_NotCod ] = "NotCod", // Note code in timeline
[Par_OrgActCod ] = "OrgActCod", // Original action code
[Par_OthCtrCod ] = "OthCtrCod", // Other center code
[Par_OthCtyCod ] = "OthCtyCod", // Other country code
[Par_OthDegCod ] = "OthDegCod", // Other degree code
[Par_OthDegTypCod] = "OthDegTypCod", // Other degree type code
[Par_OthHieCod ] = "OthHieCod", // Other hierarchy code
[Par_OthInsCod ] = "OthInsCod", // Other institution code
[Par_PlcCod ] = "PlcCod", // Place code
[Par_PlgCod ] = "PlgCod", // Plugin code
[Par_PstCod ] = "PstCod", // Post code in forum
[Par_PubCod ] = "PubCod", // Publication code in timeline
[Par_QstCod ] = "QstCod", // Question code in assessment/survey
[Par_RscCod ] = "RscCod", // Resource code in course program
[Par_SesCod ] = "SesCod", // Session code in exam
[Par_SvyCod ] = "SvyCod", // Syrvey code
[Par_ThrCod ] = "ThrCod", // Thread code in forum
};
/*****************************************************************************/

View File

@ -91,9 +91,12 @@ typedef enum
Par_OthDegTypCod,
Par_OthHieCod,
Par_OthInsCod,
Par_PlcCod,
Par_PlgCod,
Par_PstCod,
Par_PubCod,
Par_QstCod,
Par_RscCod,
Par_SesCod,
Par_SvyCod,
Par_ThrCod,

View File

@ -495,7 +495,7 @@ static void Plc_ListPlacesForEdition (const struct Plc_Places *Places)
/* Place short name */
HTM_TD_Begin ("class=\"CM\"");
Frm_BeginForm (ActRenPlcSho);
Plc_PutParamPlcCod (&Plc->PlcCod);
Par_PutParCode (Par_PlcCod,Plc->PlcCod);
HTM_INPUT_TEXT ("ShortName",Plc_MAX_CHARS_PLACE_SHRT_NAME,Plc->ShrtName,
HTM_SUBMIT_ON_CHANGE,
"class=\"INPUT_SHORT_NAME INPUT_%s\"",
@ -506,7 +506,7 @@ static void Plc_ListPlacesForEdition (const struct Plc_Places *Places)
/* Place full name */
HTM_TD_Begin ("class=\"CM\"");
Frm_BeginForm (ActRenPlcFul);
Plc_PutParamPlcCod (&Plc->PlcCod);
Par_PutParCode (Par_PlcCod,Plc->PlcCod);
HTM_INPUT_TEXT ("FullName",Plc_MAX_CHARS_PLACE_FULL_NAME,Plc->FullName,
HTM_SUBMIT_ON_CHANGE,
"class=\"INPUT_FULL_NAME INPUT_%s\"",
@ -533,17 +533,7 @@ static void Plc_ListPlacesForEdition (const struct Plc_Places *Places)
static void Plc_PutParamPlcCod (void *PlcCod)
{
if (PlcCod)
Par_PutParLong (NULL,"PlcCod",*((long *) PlcCod));
}
/*****************************************************************************/
/********************* Get parameter with code of place **********************/
/*****************************************************************************/
long Plc_GetParamPlcCod (void)
{
/***** Get code of place *****/
return Par_GetParLong ("PlcCod");
Par_PutParCode (Par_PlcCod,*((long *) PlcCod));
}
/*****************************************************************************/
@ -559,8 +549,7 @@ void Plc_RemovePlace (void)
Plc_EditingPlaceConstructor ();
/***** Get place code *****/
if ((Plc_EditingPlc->PlcCod = Plc_GetParamPlcCod ()) <= 0)
Err_WrongPlaceExit ();
Plc_EditingPlc->PlcCod = Par_GetAndCheckParCode (Par_PlcCod);
/***** Get data of the place from database *****/
Plc_GetDataOfPlaceByCod (Plc_EditingPlc);
@ -640,8 +629,7 @@ static void Plc_RenamePlace (Cns_ShrtOrFullName_t ShrtOrFullName)
/***** Get parameters from form *****/
/* Get the code of the place */
if ((Plc_EditingPlc->PlcCod = Plc_GetParamPlcCod ()) <= 0)
Err_WrongPlaceExit ();
Plc_EditingPlc->PlcCod = Par_GetAndCheckParCode (Par_PlcCod);
/* Get the new name for the place */
Par_GetParText (ParamName,NewPlcName,MaxBytes);

View File

@ -75,7 +75,6 @@ void Plc_PutIconToViewPlaces (void);
void Plc_GetListPlaces (struct Plc_Places *Places);
void Plc_FreeListPlaces (struct Plc_Places *Places);
void Plc_GetDataOfPlaceByCod (struct Plc_Place *Plc);
long Plc_GetParamPlcCod (void);
void Plc_RemovePlace (void);
void Plc_RenamePlaceShort (void);
void Plc_RenamePlaceFull (void);

View File

@ -387,7 +387,7 @@ static void Plg_ListPluginsForEdition (struct Plg_Plugins *Plugins)
/* Plugin name */
HTM_TD_Begin ("class=\"CM\"");
Frm_BeginForm (ActRenPlg);
Plg_PutParamPlgCod (&Plg->PlgCod);
Par_PutParCode (Par_PlgCod,Plg->PlgCod);
HTM_INPUT_TEXT ("Name",Plg_MAX_CHARS_PLUGIN_NAME,Plg->Name,
HTM_SUBMIT_ON_CHANGE,
"size=\"10\" class=\"INPUT_%s\"",
@ -398,7 +398,7 @@ static void Plg_ListPluginsForEdition (struct Plg_Plugins *Plugins)
/* Plugin description */
HTM_TD_Begin ("class=\"CM\"");
Frm_BeginForm (ActChgPlgDes);
Plg_PutParamPlgCod (&Plg->PlgCod);
Par_PutParCode (Par_PlgCod,Plg->PlgCod);
HTM_INPUT_TEXT ("Description",Plg_MAX_CHARS_PLUGIN_DESCRIPTION,Plg->Description,
HTM_SUBMIT_ON_CHANGE,
"size=\"30\" class=\"INPUT_%s\"",
@ -409,7 +409,7 @@ static void Plg_ListPluginsForEdition (struct Plg_Plugins *Plugins)
/* Plugin logo */
HTM_TD_Begin ("class=\"CM\"");
Frm_BeginForm (ActChgPlgLog);
Plg_PutParamPlgCod (&Plg->PlgCod);
Par_PutParCode (Par_PlgCod,Plg->PlgCod);
HTM_INPUT_TEXT ("Logo",Plg_MAX_CHARS_PLUGIN_LOGO,Plg->Logo,
HTM_SUBMIT_ON_CHANGE,
"size=\"4\" class=\"INPUT_%s\"",
@ -420,7 +420,7 @@ static void Plg_ListPluginsForEdition (struct Plg_Plugins *Plugins)
/* Plugin application key */
HTM_TD_Begin ("class=\"CM\"");
Frm_BeginForm (ActChgPlgAppKey);
Plg_PutParamPlgCod (&Plg->PlgCod);
Par_PutParCode (Par_PlgCod,Plg->PlgCod);
HTM_INPUT_TEXT ("AppKey",Plg_MAX_CHARS_PLUGIN_APP_KEY,Plg->AppKey,
HTM_SUBMIT_ON_CHANGE,
"size=\"16\" class=\"INPUT_%s\"",
@ -431,7 +431,7 @@ static void Plg_ListPluginsForEdition (struct Plg_Plugins *Plugins)
/* Plugin URL */
HTM_TD_Begin ("class=\"CM\"");
Frm_BeginForm (ActChgPlgURL);
Plg_PutParamPlgCod (&Plg->PlgCod);
Par_PutParCode (Par_PlgCod,Plg->PlgCod);
HTM_INPUT_URL ("URL",Plg->URL,HTM_SUBMIT_ON_CHANGE,
"size=\"15\" class=\"INPUT_%s\"",
The_GetSuffix ());
@ -441,7 +441,7 @@ static void Plg_ListPluginsForEdition (struct Plg_Plugins *Plugins)
/* Plugin IP */
HTM_TD_Begin ("class=\"CM\"");
Frm_BeginForm (ActChgPlgIP);
Plg_PutParamPlgCod (&Plg->PlgCod);
Par_PutParCode (Par_PlgCod,Plg->PlgCod);
HTM_INPUT_TEXT ("IP",Cns_MAX_CHARS_IP,Plg->IP,HTM_SUBMIT_ON_CHANGE,
"size=\"10\" class=\"INPUT_%s\"",
The_GetSuffix ());
@ -463,17 +463,7 @@ static void Plg_ListPluginsForEdition (struct Plg_Plugins *Plugins)
static void Plg_PutParamPlgCod (void *PlgCod)
{
if (PlgCod)
Par_PutParLong (NULL,"PlgCod",*((long *) PlgCod));
}
/*****************************************************************************/
/********************* Get parameter with code of plugin *********************/
/*****************************************************************************/
long Plg_GetParamPlgCod (void)
{
/***** Get code of plugin *****/
return Par_GetParLong ("PlgCod");
Par_PutParCode (Par_PlgCod,*((long *) PlgCod));
}
/*****************************************************************************/
@ -488,8 +478,7 @@ void Plg_RemovePlugin (void)
Plg_EditingPluginConstructor ();
/***** Get plugin code *****/
if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0)
Err_WrongPluginExit ();
Plg_EditingPlg->PlgCod = Par_GetAndCheckParCode (Par_PlgCod);
/***** Get data of the plugin from database *****/
Plg_GetDataOfPluginByCod (Plg_EditingPlg);
@ -519,8 +508,7 @@ void Plg_RenamePlugin (void)
/***** Get parameters from form *****/
/* Get the code of the plugin */
if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0)
Err_WrongPluginExit ();
Plg_EditingPlg->PlgCod = Par_GetAndCheckParCode (Par_PlgCod);
/* Get the new name for the plugin */
Par_GetParText ("Name",NewPlgName,Plg_MAX_BYTES_PLUGIN_NAME);
@ -576,8 +564,7 @@ void Plg_ChangePlgDescription (void)
/***** Get parameters from form *****/
/* Get the code of the plugin */
if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0)
Err_WrongPluginExit ();
Plg_EditingPlg->PlgCod = Par_GetAndCheckParCode (Par_PlgCod);
/* Get the new description for the plugin */
Par_GetParText ("Description",NewDescription,Plg_MAX_BYTES_PLUGIN_DESCRIPTION);
@ -618,8 +605,7 @@ void Plg_ChangePlgLogo (void)
/***** Get parameters from form *****/
/* Get the code of the plugin */
if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0)
Err_WrongPluginExit ();
Plg_EditingPlg->PlgCod = Par_GetAndCheckParCode (Par_PlgCod);
/* Get the new logo for the plugin */
Par_GetParText ("Logo",NewLogo,Plg_MAX_BYTES_PLUGIN_LOGO);
@ -660,8 +646,7 @@ void Plg_ChangePlgAppKey (void)
/***** Get parameters from form *****/
/* Get the code of the plugin */
if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0)
Err_WrongPluginExit ();
Plg_EditingPlg->PlgCod = Par_GetAndCheckParCode (Par_PlgCod);
/* Get the new logo for the plugin */
Par_GetParText ("AppKey",NewAppKey,Plg_MAX_BYTES_PLUGIN_APP_KEY);
@ -702,8 +687,7 @@ void Plg_ChangePlgURL (void)
/***** Get parameters from form *****/
/* Get the code of the plugin */
if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0)
Err_WrongPluginExit ();
Plg_EditingPlg->PlgCod = Par_GetAndCheckParCode (Par_PlgCod);
/* Get the new URL for the plugin */
Par_GetParText ("URL",NewURL,Cns_MAX_BYTES_WWW);
@ -744,8 +728,7 @@ void Plg_ChangePlgIP (void)
/***** Get parameters from form *****/
/* Get the code of the plugin */
if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0)
Err_WrongPluginExit ();
Plg_EditingPlg->PlgCod = Par_GetAndCheckParCode (Par_PlgCod);
/* Get the new IP for the plugin */
Par_GetParText ("IP",NewIP,Cns_MAX_BYTES_IP);

View File

@ -67,7 +67,6 @@ struct Plg_Plugin
void Plg_ListPlugins (void);
void Plg_EditPlugins (void);
bool Plg_GetDataOfPluginByCod (struct Plg_Plugin *Plg);
long Plg_GetParamPlgCod (void);
void Plg_RemovePlugin (void);
void Plg_RenamePlugin (void);
void Plg_ChangePlgDescription (void);