From f40674ed95a7eaf3e72d665e10b3533085e57d8e Mon Sep 17 00:00:00 2001 From: acanas Date: Mon, 6 Mar 2023 23:53:45 +0100 Subject: [PATCH] Version 22.68: Mar 06, 2023 Code refactoring in parameters. Not finished. --- swad_API.c | 4 +- swad_agenda.c | 3 +- swad_announcement.c | 2 +- swad_assignment.c | 19 ++---- swad_assignment.h | 1 - swad_assignment_resource.c | 2 +- swad_attendance.c | 24 +++---- swad_attendance.h | 2 - swad_attendance_resource.c | 2 +- swad_banner.c | 10 +-- swad_browser.c | 17 ++--- swad_browser.h | 1 - swad_building.c | 2 +- swad_call_for_exam.c | 11 +--- swad_call_for_exam.h | 2 - swad_call_for_exam_resource.c | 2 +- swad_center_config.c | 3 +- swad_changelog.h | 3 +- swad_country.c | 5 +- swad_course_config.c | 3 +- swad_degree.c | 4 +- swad_degree_config.c | 3 +- swad_degree_type.c | 21 +----- swad_degree_type.h | 2 - swad_department.c | 27 ++------ swad_department.h | 3 - swad_exam.c | 58 ++++++---------- swad_exam.h | 4 +- swad_exam_print.c | 2 +- swad_exam_resource.c | 5 +- swad_exam_result.c | 25 +++---- swad_exam_session.c | 52 ++++----------- swad_exam_session.h | 2 - swad_exam_set.c | 67 ++++--------------- swad_exam_set.h | 1 - swad_forum.c | 30 ++------- swad_game.c | 27 +++----- swad_game.h | 3 +- swad_game_resource.c | 2 +- swad_group.c | 18 ++--- swad_group_database.c | 14 ++-- swad_group_database.h | 5 +- swad_indicator.c | 21 +++--- swad_institution_config.c | 3 +- swad_match.c | 58 +++++----------- swad_match.h | 1 - swad_match_result.c | 9 ++- swad_notice.c | 35 ++-------- swad_notice.h | 2 - swad_notification.c | 11 ++-- swad_parameter.c | 62 +++++++++++++----- swad_parameter.h | 12 ++++ swad_project.c | 8 ++- swad_question.c | 36 ++++------ swad_question.h | 1 - swad_record.c | 17 +++-- swad_survey.c | 120 ++++++++++------------------------ swad_survey.h | 2 - swad_survey_resource.c | 5 +- swad_timeline.c | 3 +- swad_timeline_comment.c | 14 ++-- swad_timeline_database.c | 47 ++++++++----- swad_timeline_favourite.c | 13 ++-- swad_timeline_note.c | 39 +++-------- swad_timeline_note.h | 3 - swad_timeline_publication.c | 18 ----- swad_timeline_publication.h | 3 - swad_timeline_share.c | 7 +- 68 files changed, 377 insertions(+), 666 deletions(-) diff --git a/swad_API.c b/swad_API.c index c444be6d..a785c9c3 100644 --- a/swad_API.c +++ b/swad_API.c @@ -2699,7 +2699,9 @@ int swad__getAttendanceUsers (struct soap *soap, "Requester must be a teacher"); /***** Query list of attendance users *****/ - AttEventIsAsociatedToGrps = Grp_DB_CheckIfAssociatedToGrps ("att_groups","AttCod",Event.AttCod); + AttEventIsAsociatedToGrps = Grp_DB_CheckIfAssociatedToGrps ("att_groups", + Par_AttCod, + Event.AttCod); NumUsrs = Att_DB_GetListUsrsInAttEvent (&mysql_res,Event.AttCod,AttEventIsAsociatedToGrps); diff --git a/swad_agenda.c b/swad_agenda.c index 063f6889..7c93a206 100644 --- a/swad_agenda.c +++ b/swad_agenda.c @@ -963,8 +963,7 @@ void Agd_PutParamsMyAgenda (unsigned Past__FutureEvents, if (NumPage > 1) Pag_PutHiddenParamPagNum (Pag_MY_AGENDA,NumPage); - if (AgdCodToEdit > 0) - Par_PutHiddenParamLong (NULL,"AgdCod",AgdCodToEdit); + Par_PutParCod (Par_AgdCod,AgdCodToEdit); } /*****************************************************************************/ diff --git a/swad_announcement.c b/swad_announcement.c index 15eead15..1fb6a1e9 100644 --- a/swad_announcement.c +++ b/swad_announcement.c @@ -304,7 +304,7 @@ static void Ann_DrawAnAnnouncement (long AnnCod,Ann_Status_t Status, static void Ann_PutParams (void *AnnCod) { - Par_PutHiddenParamLong (NULL,"AnnCod",*((long *) AnnCod)); + Par_PutParCod (Par_AnnCod,*((long *) AnnCod)); } /*****************************************************************************/ diff --git a/swad_assignment.c b/swad_assignment.c index 3cb0f9db..4adbf53c 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -774,8 +774,7 @@ static void Asg_PutParams (void *Assignments) if (Assignments) { - if (((struct Asg_Assignments *) Assignments)->Asg.AsgCod > 0) - Asg_PutParamAsgCod (((struct Asg_Assignments *) Assignments)->Asg.AsgCod); + Par_PutParCod (Par_AsgCod,((struct Asg_Assignments *) Assignments)->Asg.AsgCod); Par_PutHiddenParamOrder ((unsigned) ((struct Asg_Assignments *) Assignments)->SelectedOrder); WhichGroups = Grp_GetParamWhichGroups (); Grp_PutParamWhichGroups (&WhichGroups); @@ -1004,16 +1003,6 @@ void Asg_GetNotifAssignment (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], DB_FreeMySQLResult (&mysql_res); } -/*****************************************************************************/ -/***************** Write parameter with code of assignment *******************/ -/*****************************************************************************/ - -void Asg_PutParamAsgCod (long AsgCod) - { - if (AsgCod > 0) - Par_PutHiddenParamLong (NULL,"AsgCod",AsgCod); - } - /*****************************************************************************/ /************* Ask for confirmation of removing an assignment ****************/ /*****************************************************************************/ @@ -1354,8 +1343,10 @@ static void Asg_ShowLstGrpsToEditAssignment (long AsgCod) HTM_INPUT_CHECKBOX ("WholeCrs",HTM_DONT_SUBMIT_ON_CHANGE, "id=\"WholeCrs\" value=\"Y\"%s" " onclick=\"uncheckChildren(this,'GrpCods')\"", - Grp_DB_CheckIfAssociatedToGrps ("asg_groups","AsgCod",AsgCod) ? "" : - " checked=\"checked\""); + Grp_DB_CheckIfAssociatedToGrps ("asg_groups", + Par_AsgCod, + AsgCod) ? "" : + " checked=\"checked\""); HTM_TxtF ("%s %s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName); HTM_LABEL_End (); HTM_TD_End (); diff --git a/swad_assignment.h b/swad_assignment.h index 914a8bf3..4f2b12a4 100644 --- a/swad_assignment.h +++ b/swad_assignment.h @@ -98,7 +98,6 @@ void Asg_GetNotifAssignment (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long AsgCod,bool GetContent); -void Asg_PutParamAsgCod (long AsgCod); void Asg_ReqRemAssignment (void); void Asg_RemoveAssignment (void); void Asg_HideAssignment (void); diff --git a/swad_assignment_resource.c b/swad_assignment_resource.c index 9f55a9fc..bd620cd9 100644 --- a/swad_assignment_resource.c +++ b/swad_assignment_resource.c @@ -95,7 +95,7 @@ void AsgRsc_WriteAssignmentInCrsProgram (long AsgCod,bool PutFormToGo, NextAction = (AsgCod > 0) ? ActSeeOneAsg : // Assignment specified ActSeeAsg; // All assignments Frm_BeginForm (NextAction); - Asg_PutParamAsgCod (AsgCod); + Par_PutParCod (Par_AsgCod,AsgCod); // TODO: In the listing of assignments, the page is always the first. // The page should be that corresponding to the selected assignment. HTM_BUTTON_Submit_Begin (Txt_Actions[NextAction], diff --git a/swad_attendance.c b/swad_attendance.c index 488b1e04..e0af7d6f 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -651,7 +651,7 @@ static void Att_PutParams (void *Events) if (Events) { - Att_PutParamAttCod (((struct Att_Events *) Events)->Event.AttCod); + Par_PutParCod (Par_AttCod,((struct Att_Events *) Events)->Event.AttCod); Par_PutHiddenParamOrder ((unsigned) ((struct Att_Events *) Events)->SelectedOrder); WhichGroups = Grp_GetParamWhichGroups (); Grp_PutParamWhichGroups (&WhichGroups); @@ -820,13 +820,7 @@ static void Att_FreeListAttEvents (struct Att_Events *Events) static void Att_PutParamSelectedAttCod (void *Events) { if (Events) - Att_PutParamAttCod (((struct Att_Events *) Events)->Event.AttCod); - } - -void Att_PutParamAttCod (long AttCod) - { - if (AttCod > 0) - Par_PutHiddenParamLong (NULL,"AttCod",AttCod); + Par_PutParCod (Par_AttCod,((struct Att_Events *) Events)->Event.AttCod); } /*****************************************************************************/ @@ -1016,7 +1010,7 @@ void Att_RequestCreatOrEditAttEvent (void) else { Frm_BeginForm (ActChgAtt); - Att_PutParamAttCod (Events.Event.AttCod); + Par_PutParCod (Par_AttCod,Events.Event.AttCod); } Par_PutHiddenParamOrder ((unsigned) Events.SelectedOrder); WhichGroups = Grp_GetParamWhichGroups (); @@ -1149,8 +1143,10 @@ static void Att_ShowLstGrpsToEditAttEvent (long AttCod) HTM_INPUT_CHECKBOX ("WholeCrs",HTM_DONT_SUBMIT_ON_CHANGE, "id=\"WholeCrs\" value=\"Y\"%s" " onclick=\"uncheckChildren(this,'GrpCods')\"", - Grp_DB_CheckIfAssociatedToGrps ("att_groups","AttCod",AttCod) ? "" : - " checked=\"checked\""); + Grp_DB_CheckIfAssociatedToGrps ("att_groups", + Par_AttCod, + AttCod) ? "" : + " checked=\"checked\""); HTM_TxtF ("%s %s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName); HTM_LABEL_End (); HTM_TD_End (); @@ -1541,7 +1537,7 @@ static void Att_ListAttOnlyMeAsStudent (struct Att_Event *Event) if (Event->Open) { Frm_BeginForm (ActRecAttMe); - Att_PutParamAttCod (Event->AttCod); + Par_PutParCod (Par_AttCod,Event->AttCod); } /***** List students (only me) *****/ @@ -1621,7 +1617,7 @@ static void Att_ListAttStudents (struct Att_Events *Events) /* Begin form */ Frm_BeginForm (ActRecAttStd); - Att_PutParamAttCod (Events->Event.AttCod); + Par_PutParCod (Par_AttCod,Events->Event.AttCod); Grp_PutParamsCodGrps (); /* Begin table */ @@ -1855,7 +1851,7 @@ static void Att_PutLinkAttEvent (struct Att_Event *Event, { /***** Begin form *****/ Frm_BeginForm (ActSeeOneAtt); - Att_PutParamAttCod (Event->AttCod); + Par_PutParCod (Par_AttCod,Event->AttCod); Att_PutParamsCodGrps (Event->AttCod); /***** Link to view attendance event *****/ diff --git a/swad_attendance.h b/swad_attendance.h index d821fa6c..554a4582 100644 --- a/swad_attendance.h +++ b/swad_attendance.h @@ -90,8 +90,6 @@ bool Att_CheckIfICanEditAttEvents (void); void Att_RequestCreatOrEditAttEvent (void); bool Att_GetDataOfAttEventByCod (struct Att_Event *Event); -void Att_PutParamAttCod (long AttCod); - void Att_AskRemAttEvent (void); void Att_GetAndRemAttEvent (void); void Att_RemoveAttEventFromDB (long AttCod); diff --git a/swad_attendance_resource.c b/swad_attendance_resource.c index f4162f30..4f821d9a 100644 --- a/swad_attendance_resource.c +++ b/swad_attendance_resource.c @@ -81,7 +81,7 @@ void AttRsc_WriteAttEventInCrsProgram (long AttCod,bool PutFormToGo, NextAction = (AttCod > 0) ? ActSeeOneAtt : // Attendance events specified ActSeeAtt; // All attendance events Frm_BeginForm (NextAction); - Att_PutParamAttCod (AttCod); + Par_PutParCod (Par_AttCod,AttCod); Att_PutParamsCodGrps (AttCod); HTM_BUTTON_Submit_Begin (Txt_Actions[NextAction], "class=\"LM BT_LINK PRG_LNK_%s\"", diff --git a/swad_banner.c b/swad_banner.c index 81b23211..7b8b4963 100644 --- a/swad_banner.c +++ b/swad_banner.c @@ -89,7 +89,6 @@ static void Ban_PutIconsEditingBanners (__attribute__((unused)) void *Args); static void Ban_ListBannersForEdition (struct Ban_Banners *Banners); static void Ban_PutParamBanCodToEdit (void *BanCod); -static void Ban_PutParamBanCod (long BanCod); static void Ban_ShowOrHideBanner (struct Ban_Banner *Ban,bool Hide); static void Ban_RenameBanner (struct Ban_Banner *Ban, @@ -509,12 +508,7 @@ static void Ban_ListBannersForEdition (struct Ban_Banners *Banners) static void Ban_PutParamBanCodToEdit (void *BanCod) { if (BanCod) - Ban_PutParamBanCod (*((long *) BanCod)); - } - -static void Ban_PutParamBanCod (long BanCod) - { - Par_PutHiddenParamLong (NULL,"BanCod",BanCod); + Par_PutParCod (Par_BanCod,*((long *) BanCod)); } /*****************************************************************************/ @@ -987,7 +981,7 @@ void Ban_WriteMenuWithBanners (void) /* Begin form */ Frm_BeginForm (ActClkBan); - Ban_PutParamBanCod (Banners.Lst[NumBan].BanCod); + Par_PutParCod (Par_BanCod,Banners.Lst[NumBan].BanCod); Par_PutHiddenParamString (NULL,"URL",Banners.Lst[NumBan].WWW); /* Banner image */ diff --git a/swad_browser.c b/swad_browser.c index 27069ac9..5869420c 100644 --- a/swad_browser.c +++ b/swad_browser.c @@ -2075,16 +2075,6 @@ static void Brw_GetDataCurrentGrp (void) } } -/*****************************************************************************/ -/**************** Write hidden parameter with code of file *******************/ -/*****************************************************************************/ - -void Brw_PutHiddenParamFilCod (long FilCod) - { - if (FilCod > 0) - Par_PutHiddenParamLong (NULL,"FilCod",FilCod); - } - /*****************************************************************************/ /**************** Write parameters related with file browser *****************/ /*****************************************************************************/ @@ -2122,7 +2112,7 @@ void Brw_PutParamsFileBrowser (const char *PathInTree,const char *FilFolLnkName, Par_PutHiddenParamString (NULL,"Path",PathInTree); if (FilFolLnkName) Par_PutHiddenParamString (NULL,Brw_FileTypeParamName[FileType],FilFolLnkName); - Brw_PutHiddenParamFilCod (FilCod); + Par_PutParCod (Par_FilCod,FilCod); } /*****************************************************************************/ @@ -2826,6 +2816,7 @@ static void Brw_ShowFileBrowsersAsgWrkUsr (void) static void Brw_FormToChangeCrsGrpZone (void) { + extern const char *Par_CodeStr[]; struct ListCodGrps LstMyGrps; unsigned NumGrp; struct GroupData GrpDat; @@ -2858,7 +2849,7 @@ static void Brw_FormToChangeCrsGrpZone (void) HTM_LI_Begin ("class=\"%s\"",IsCourseZone ? "BROWSER_TITLE" : "BROWSER_TITLE_LIGHT"); HTM_LABEL_Begin (NULL); - HTM_INPUT_RADIO ("GrpCod",true, + HTM_INPUT_RADIO (Par_CodeStr[Par_GrpCod],true, "value=\"-1\"%s", IsCourseZone ? " checked=\"checked\"" : ""); HTM_Txt (Gbl.Hierarchy.Crs.FullName); @@ -2887,7 +2878,7 @@ static void Brw_FormToChangeCrsGrpZone (void) NULL, "class=\"ICO25x25\" style=\"margin-left:6px;\""); HTM_LABEL_Begin (NULL); - HTM_INPUT_RADIO ("GrpCod",true, + HTM_INPUT_RADIO (Par_CodeStr[Par_GrpCod],true, "value=\"%ld\"%s", GrpDat.GrpCod, (IsGroupZone && diff --git a/swad_browser.h b/swad_browser.h index 6ccb4262..922f4626 100644 --- a/swad_browser.h +++ b/swad_browser.h @@ -181,7 +181,6 @@ struct Brw_FileMetadata /*****************************************************************************/ void Brw_GetParAndInitFileBrowser (void); -void Brw_PutHiddenParamFilCod (long FilCod); void Brw_InitializeFileBrowser (void); bool Brw_CheckIfExistsFolderAssigmentForAnyUsr (const char *FolderName); bool Brw_UpdateFoldersAssigmentsIfExistForAllUsrs (const char *OldFolderName, diff --git a/swad_building.c b/swad_building.c index 10a2555d..3da86bb0 100644 --- a/swad_building.c +++ b/swad_building.c @@ -489,7 +489,7 @@ static void Bld_ListBuildingsForEdition (const struct Bld_Buildings *Buildings) static void Bld_PutParamBldCod (void *BldCod) { if (BldCod) - Par_PutHiddenParamLong (NULL,"BldCod",*((long *) BldCod)); + Par_PutParCod (Par_BldCod,*((long *) BldCod)); } /*****************************************************************************/ diff --git a/swad_call_for_exam.c b/swad_call_for_exam.c index 757dc747..9344c95b 100644 --- a/swad_call_for_exam.c +++ b/swad_call_for_exam.c @@ -958,8 +958,7 @@ static void Cfe_ShowCallForExam (struct Cfe_CallsForExams *CallsForExams, { /***** Begin form *****/ Frm_BeginFormAnchor (ActRcvCfe,Anchor); - if (ExaCod > 0) // Existing call for exam - Cfe_PutHiddenParamExaCod (ExaCod); + Par_PutParCod (Par_ExaCod,ExaCod); } /***** Begin table *****/ @@ -1548,13 +1547,7 @@ bool Cfe_CheckIfICanEditCallsForExams (void) static void Cfe_PutParamExaCodToEdit (void *ExaCod) { if (ExaCod) - Cfe_PutHiddenParamExaCod (*((long *) ExaCod)); - } - -void Cfe_PutHiddenParamExaCod (long ExaCod) - { - if (ExaCod > 0) - Par_PutHiddenParamLong (NULL,"ExaCod",ExaCod); + Par_PutParCod (Par_ExaCod,*((long *) ExaCod)); } /*****************************************************************************/ diff --git a/swad_call_for_exam.h b/swad_call_for_exam.h index 3df3aa5b..3936e419 100644 --- a/swad_call_for_exam.h +++ b/swad_call_for_exam.h @@ -131,8 +131,6 @@ void Cfe_CreateListCallsForExams (struct Cfe_CallsForExams *CallsForExams); bool Cfe_CheckIfICanEditCallsForExams (void); -void Cfe_PutHiddenParamExaCod (long ExaCod); - void Cfe_GetSummaryAndContentCallForExam (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long ExaCod,bool GetContent); diff --git a/swad_call_for_exam_resource.c b/swad_call_for_exam_resource.c index b26aa99c..a83dd0c3 100644 --- a/swad_call_for_exam_resource.c +++ b/swad_call_for_exam_resource.c @@ -91,7 +91,7 @@ void CfeRsc_WriteCallForExamInCrsProgram (long ExaCod,bool PutFormToGo, NextAction = (ExaCod > 0) ? ActSeeOneCfe : // Call for exam specified ActSeeAllCfe; // All calls for exams Frm_BeginFormAnchor (NextAction,Anchor); - Cfe_PutHiddenParamExaCod (ExaCod); + Par_PutParCod (Par_ExaCod,ExaCod); HTM_BUTTON_Submit_Begin (Txt_Actions[NextAction], "class=\"LM BT_LINK PRG_LNK_%s\"", The_GetSuffix ()); diff --git a/swad_center_config.c b/swad_center_config.c index cbd1cffc..8abb104e 100644 --- a/swad_center_config.c +++ b/swad_center_config.c @@ -540,6 +540,7 @@ static void CtrCfg_FreePhotoAttr (char **PhotoAttribution) static void CtrCfg_Institution (bool PrintView,bool PutForm) { + extern const char *Par_CodeStr[]; extern const char *Txt_Institution; unsigned NumIns; @@ -547,7 +548,7 @@ static void CtrCfg_Institution (bool PrintView,bool PutForm) HTM_TR_Begin (NULL); /* Label */ - Frm_LabelColumn ("RT",PutForm ? "OthInsCod" : + Frm_LabelColumn ("RT",PutForm ? Par_CodeStr[Par_OthInsCod] : NULL, Txt_Institution); diff --git a/swad_changelog.h b/swad_changelog.h index 10c6b7b2..8f451fd9 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -629,10 +629,11 @@ TODO: Emilce Barrera Mesa: Podr TODO: Emilce Barrera Mesa: Mis estudiantes presentan muchas dificultades a la hora de poner la foto porque la plataforma es muy exigente respecto al fondo de la imagen. */ -#define Log_PLATFORM_VERSION "SWAD 22.67.1 (2023-03-06)" +#define Log_PLATFORM_VERSION "SWAD 22.68 (2023-03-06)" #define CSS_FILE "swad22.57.1.css" #define JS_FILE "swad22.49.js" /* + Version 22.68: Mar 06, 2023 Code refactoring in parameters. Not finished. (336887 lines) Version 22.67.1: Mar 06, 2023 Code refactoring in dates. (337124 lines) Version 22.67: Mar 04, 2023 Code refactoring in parameters. Not finished. (337118 lines) Version 22.66.4: Mar 04, 2023 Fixed issues in exams. (337245 lines) diff --git a/swad_country.c b/swad_country.c index 1855b2b2..d059b01e 100644 --- a/swad_country.c +++ b/swad_country.c @@ -1180,7 +1180,7 @@ void Cty_PutParamCtyCod (long CtyCod) static void Cty_PutParamOtherCtyCod (void *CtyCod) { if (CtyCod) - Par_PutHiddenParamLong (NULL,"OthCtyCod",*((long *) CtyCod)); + Par_PutParCod (Par_OthCtyCod,*((long *) CtyCod)); } /*****************************************************************************/ @@ -1413,6 +1413,7 @@ static void Cty_PutParamGoToCty (void *CtyCod) static void Cty_PutFormToCreateCountry (void) { extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES]; + extern const char *Par_CodeStr[]; extern const char *Txt_New_country; extern const char *Txt_STR_LANG_NAME[1 + Lan_NUM_LANGUAGES]; extern const char *Txt_Create_country; @@ -1443,7 +1444,7 @@ static void Cty_PutFormToCreateCountry (void) snprintf (StrCtyCod,sizeof (StrCtyCod),"%03ld",Cty_EditingCty->CtyCod); else StrCtyCod[0] = '\0'; - HTM_INPUT_TEXT ("OthCtyCod",3,StrCtyCod,HTM_DONT_SUBMIT_ON_CHANGE, + HTM_INPUT_TEXT (Par_CodeStr[Par_OthCtyCod],3,StrCtyCod,HTM_DONT_SUBMIT_ON_CHANGE, "size=\"3\" class=\"INPUT_%s\"" " required=\"required\"", The_GetSuffix ()); diff --git a/swad_course_config.c b/swad_course_config.c index 8592b5e6..389312d0 100644 --- a/swad_course_config.c +++ b/swad_course_config.c @@ -211,6 +211,7 @@ static void CrsCfg_Title (bool PutLink) static void CrsCfg_Degree (bool PrintView,bool PutForm) { + extern const char *Par_CodeStr[]; extern const char *Txt_Degree; unsigned NumDeg; @@ -218,7 +219,7 @@ static void CrsCfg_Degree (bool PrintView,bool PutForm) HTM_TR_Begin (NULL); /* Label */ - Frm_LabelColumn ("RT",PutForm ? "OthDegCod" : + Frm_LabelColumn ("RT",PutForm ? Par_CodeStr[Par_OthDegCod] : NULL, Txt_Degree); diff --git a/swad_degree.c b/swad_degree.c index c6b13c47..344bf00f 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -1095,7 +1095,7 @@ static void Deg_ReceiveFormRequestOrCreateDeg (Hie_Status_t Status) Par_GetParToText ("FullName" ,Deg_EditingDeg->FullName,Cns_HIERARCHY_MAX_BYTES_FULL_NAME); /* Get degree type */ - Deg_EditingDeg->DegTypCod = DegTyp_GetAndCheckParamOtherDegTypCod (1); + Deg_EditingDeg->DegTypCod = Par_GetAndCheckParCode (Par_OthDegTypCod); /* Get degree WWW */ Par_GetParToText ("WWW",Deg_EditingDeg->WWW,Cns_MAX_BYTES_WWW); @@ -1415,7 +1415,7 @@ void Deg_ChangeDegreeType (void) Deg_EditingDeg->DegCod = Hie_GetAndCheckParamOtherHieCod (1L); /* Get the new degree type */ - NewDegTypCod = DegTyp_GetAndCheckParamOtherDegTypCod (1); + NewDegTypCod = Par_GetAndCheckParCode (Par_OthDegTypCod); /***** Get data of degree *****/ Deg_GetDataOfDegreeByCod (Deg_EditingDeg); diff --git a/swad_degree_config.c b/swad_degree_config.c index a2501a25..e40ba824 100644 --- a/swad_degree_config.c +++ b/swad_degree_config.c @@ -206,6 +206,7 @@ static void DegCfg_Title (bool PutLink) static void DegCfg_Center (bool PrintView,bool PutForm) { + extern const char *Par_CodeStr[]; extern const char *Txt_Center; unsigned NumCtr; @@ -213,7 +214,7 @@ static void DegCfg_Center (bool PrintView,bool PutForm) HTM_TR_Begin (NULL); /* Label */ - Frm_LabelColumn ("RT",PutForm ? "OthCtrCod" : + Frm_LabelColumn ("RT",PutForm ? Par_CodeStr[Par_OthCtrCod] : NULL, Txt_Center); diff --git a/swad_degree_type.c b/swad_degree_type.c index a3a77ee3..53526c72 100644 --- a/swad_degree_type.c +++ b/swad_degree_type.c @@ -700,7 +700,7 @@ void DegTyp_RemoveDegreeType (void) DegTyp_EditingDegreeTypeConstructor (); /***** Get the code of the degree type *****/ - DegTyp_EditingDegTyp->DegTypCod = DegTyp_GetAndCheckParamOtherDegTypCod (1); + DegTyp_EditingDegTyp->DegTypCod = Par_GetAndCheckParCode (Par_OthDegTypCod); /***** Get data of the degree type from database *****/ if (!DegTyp_GetDataOfDegreeTypeByCod (DegTyp_EditingDegTyp)) @@ -729,22 +729,7 @@ void DegTyp_RemoveDegreeType (void) static void DegTyp_PutParamOtherDegTypCod (void *DegTypCod) { if (DegTypCod) - Par_PutHiddenParamLong (NULL,"OthDegTypCod",*((long *) DegTypCod)); - } - -/*****************************************************************************/ -/******************* Get parameter with code of degree type ******************/ -/*****************************************************************************/ - -long DegTyp_GetAndCheckParamOtherDegTypCod (long MinCodAllowed) - { - long DegTypCod; - - /***** Get and check parameter with code of degree type *****/ - if ((DegTypCod = Par_GetParToLong ("OthDegTypCod")) < MinCodAllowed) - Err_WrongDegTypExit (); - - return DegTypCod; + Par_PutParCod (Par_OthDegTypCod,*((long *) DegTypCod)); } /*****************************************************************************/ @@ -825,7 +810,7 @@ void DegTyp_RenameDegreeType (void) /***** Get parameters from form *****/ /* Get the code of the degree type */ - DegTyp_EditingDegTyp->DegTypCod = DegTyp_GetAndCheckParamOtherDegTypCod (1); + DegTyp_EditingDegTyp->DegTypCod = Par_GetAndCheckParCode (Par_OthDegTypCod); /* Get the new name for the degree type */ Par_GetParToText ("DegTypName",NewNameDegTyp,DegTyp_MAX_BYTES_DEGREE_TYPE_NAME); diff --git a/swad_degree_type.h b/swad_degree_type.h index 4ef225ec..1b758fa9 100644 --- a/swad_degree_type.h +++ b/swad_degree_type.h @@ -83,8 +83,6 @@ void DegTyp_ReceiveFormNewDegreeType (void); void DegTyp_RemoveDegreeType (void); -long DegTyp_GetAndCheckParamOtherDegTypCod (long MinCodAllowed); - bool DegTyp_GetDataOfDegreeTypeByCod (struct DegTyp_DegreeType *DegTyp); void DegTyp_RenameDegreeType (void); diff --git a/swad_department.c b/swad_department.c index ab365a8c..c0e8f49a 100644 --- a/swad_department.c +++ b/swad_department.c @@ -556,23 +556,10 @@ static void Dpt_ListDepartmentsForEdition (const struct Dpt_Departments *Departm static void Dpt_PutParamDptCod (void *DptCod) { + extern const char *Par_CodeStr[]; + if (DptCod) - Par_PutHiddenParamLong (NULL,Dpt_PARAM_DPT_COD_NAME,*((long *) DptCod)); - } - -/*****************************************************************************/ -/******************* Get parameter with code of department *******************/ -/*****************************************************************************/ - -long Dpt_GetAndCheckParamDptCod (long MinCodAllowed) - { - long DptCod; - - /***** Get and check parameter with code of department *****/ - if ((DptCod = Par_GetParToLong (Dpt_PARAM_DPT_COD_NAME)) < MinCodAllowed) - Err_WrongDepartmentExit (); - - return DptCod; + Par_PutHiddenParamLong (NULL,Par_CodeStr[Par_DptCod],*((long *) DptCod)); } /*****************************************************************************/ @@ -588,7 +575,7 @@ void Dpt_RemoveDepartment (void) Dpt_EditingDepartmentConstructor (); /***** Get department code *****/ - Dpt_EditingDpt->DptCod = Dpt_GetAndCheckParamDptCod (1); + Dpt_EditingDpt->DptCod = Par_GetAndCheckParCode (Par_DptCod); /***** Get data of the department from database *****/ Dpt_GetDataOfDepartmentByCod (Dpt_EditingDpt); @@ -623,7 +610,7 @@ void Dpt_ChangeDepartIns (void) /***** Get parameters from form *****/ /* Get the code of the department */ - Dpt_EditingDpt->DptCod = Dpt_GetAndCheckParamDptCod (1); + Dpt_EditingDpt->DptCod = Par_GetAndCheckParCode (Par_DptCod); /* Get parameter with institution code */ NewInsCod = Par_GetAndCheckParCode (Par_OthInsCod); @@ -698,7 +685,7 @@ static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName) /***** Get parameters from form *****/ /* Get the code of the department */ - Dpt_EditingDpt->DptCod = Dpt_GetAndCheckParamDptCod (1); + Dpt_EditingDpt->DptCod = Par_GetAndCheckParCode (Par_DptCod); /* Get the new name for the department */ Par_GetParToText (ParamName,NewDptName,MaxBytes); @@ -754,7 +741,7 @@ void Dpt_ChangeDptWWW (void) /***** Get parameters from form *****/ /* Get the code of the department */ - Dpt_EditingDpt->DptCod = Dpt_GetAndCheckParamDptCod (1); + Dpt_EditingDpt->DptCod = Par_GetAndCheckParCode (Par_DptCod); /* Get the new WWW for the department */ Par_GetParToText ("WWW",NewWWW,Cns_MAX_BYTES_WWW); diff --git a/swad_department.h b/swad_department.h index 81db3df4..2836323a 100644 --- a/swad_department.h +++ b/swad_department.h @@ -51,8 +51,6 @@ typedef enum } Dpt_Order_t; #define Dpt_ORDER_DEFAULT Dpt_ORDER_BY_DEPARTMENT -#define Dpt_PARAM_DPT_COD_NAME "DptCod" - struct Dpt_Departments { unsigned Num; // Number of departments @@ -68,7 +66,6 @@ void Dpt_SeeDepts (void); void Dpt_EditDepartments (void); void Dpt_FreeListDepartments (struct Dpt_Departments *Departments); void Dpt_GetDataOfDepartmentByCod (struct Dpt_Department *Dpt); -long Dpt_GetAndCheckParamDptCod (long MinCodAllowed); void Dpt_RemoveDepartment (void); void Dpt_ChangeDepartIns (void); void Dpt_RenameDepartShort (void); diff --git a/swad_exam.c b/swad_exam.c index 5d4076ed..c7c18fa6 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -198,7 +198,7 @@ void Exa_SeeAllExams (void) Exa_ResetExams (&Exams); /***** Get parameters *****/ - Exa_GetParams (&Exams); + Exa_GetParams (&Exams,false); // Don't check exam code /***** Show all exams *****/ Exa_ListAllExams (&Exams); @@ -413,9 +413,7 @@ void Exa_SeeOneExam (void) ExaSes_ResetSession (&Session); /***** Get parameters *****/ - Exa_GetParams (&Exams); - if (Exams.Exam.ExaCod <= 0) - Err_WrongExamExit (); + Exa_GetParams (&Exams,true); /***** Get exam data *****/ Exa_GetDataOfExamByCod (&Exams.Exam); @@ -718,8 +716,7 @@ void Exa_PutParams (void *Exams) if (Exams) { - if (((struct Exa_Exams *) Exams)->Exam.ExaCod > 0) - Exa_PutParamExamCod (((struct Exa_Exams *) Exams)->Exam.ExaCod); + Par_PutParCod (Par_ExaCod,((struct Exa_Exams *) Exams)->Exam.ExaCod); Exa_PutHiddenParamOrder (((struct Exa_Exams *) Exams)->SelectedOrder); WhichGroups = Grp_GetParamWhichGroups (); Grp_PutParamWhichGroups (&WhichGroups); @@ -727,38 +724,24 @@ void Exa_PutParams (void *Exams) } } -/*****************************************************************************/ -/******************** Write parameter with code of exam **********************/ -/*****************************************************************************/ - -void Exa_PutParamExamCod (long ExaCod) - { - if (ExaCod > 0) - Par_PutHiddenParamLong (NULL,"ExaCod",ExaCod); - } - -/*****************************************************************************/ -/********************* Get parameter with code of exam ***********************/ -/*****************************************************************************/ - -long Exa_GetParamExamCod (void) - { - /***** Get code of exam *****/ - return Par_GetParToLong ("ExaCod"); - } - /*****************************************************************************/ /******************* Get parameters used to edit an exam **********************/ /*****************************************************************************/ -void Exa_GetParams (struct Exa_Exams *Exams) +void Exa_GetParams (struct Exa_Exams *Exams,bool CheckExaCod) { + long (*GetExaCo[2]) (Par_Code_t ParamCode) = + { + [false] = Par_GetParCode, + [true ] = Par_GetAndCheckParCode, + }; + /***** Get other parameters *****/ Exams->SelectedOrder = Exa_GetParamOrder (); Exams->CurrentPage = Pag_GetParamPagNum (Pag_EXAMS); /***** Get exam code *****/ - Exams->Exam.ExaCod = Exa_GetParamExamCod (); + Exams->Exam.ExaCod = GetExaCo[CheckExaCod] (Par_ExaCod); } /*****************************************************************************/ @@ -829,6 +812,7 @@ void Exa_GetListExams (struct Exa_Exams *Exams,Exa_Order_t SelectedOrder) void Exa_GetListSelectedExaCods (struct Exa_Exams *Exams) { + extern const char *Par_CodeStr[]; unsigned MaxSizeListExaCodsSelected; unsigned NumExam; const char *Ptr; @@ -841,7 +825,8 @@ void Exa_GetListSelectedExaCods (struct Exa_Exams *Exams) Err_NotEnoughMemoryExit (); /***** Get parameter multiple with list of exams selected *****/ - Par_GetParMultiToText ("ExaCod",Exams->ExaCodsSelected,MaxSizeListExaCodsSelected); + Par_GetParMultiToText (Par_CodeStr[Par_ExaCod],Exams->ExaCodsSelected, + MaxSizeListExaCodsSelected); /***** Set which exams will be shown as selected (checkboxes on) *****/ if (Exams->ExaCodsSelected[0]) // Some exams selected @@ -1005,9 +990,7 @@ void Exa_AskRemExam (void) Exa_ResetExam (&Exams.Exam); /***** Get parameters *****/ - Exa_GetParams (&Exams); - if (Exams.Exam.ExaCod <= 0) - Err_WrongExamExit (); + Exa_GetParams (&Exams,true); /***** Get data of the exam from database *****/ Exa_GetDataOfExamByCod (&Exams.Exam); @@ -1041,8 +1024,7 @@ void Exa_RemoveExam (void) Exa_ResetExam (&Exams.Exam); /***** Get exam code *****/ - if ((Exams.Exam.ExaCod = Exa_GetParamExamCod ()) <= 0) - Err_WrongExamExit (); + Exams.Exam.ExaCod = Par_GetAndCheckParCode (Par_ExaCod); /***** Get data of the exam from database *****/ Exa_GetDataOfExamByCod (&Exams.Exam); @@ -1230,9 +1212,7 @@ static void Exa_HideUnhideExam (bool Hide) Exa_ResetExam (&Exams.Exam); /***** Get parameters *****/ - Exa_GetParams (&Exams); - if (Exams.Exam.ExaCod <= 0) - Err_WrongExamExit (); + Exa_GetParams (&Exams,true); /***** Get data of the exam from database *****/ Exa_GetDataOfExamByCod (&Exams.Exam); @@ -1264,7 +1244,7 @@ void Exa_RequestCreatOrEditExam (void) ExaSet_ResetSet (&Set); /***** Get parameters *****/ - Exa_GetParams (&Exams); + Exa_GetParams (&Exams,false); // Don't check exam code ItsANewExam = (Exams.Exam.ExaCod <= 0); /***** Get exam data *****/ @@ -1437,7 +1417,7 @@ void Exa_ReceiveFormExam (void) ExaSet_ResetSet (&Set); /***** Get parameters *****/ - Exa_GetParams (&Exams); + Exa_GetParams (&Exams,false); // Don't check exam code ItsANewExam = (Exams.Exam.ExaCod <= 0); /***** Get all current exam data from database *****/ diff --git a/swad_exam.h b/swad_exam.h index 096575d0..22c06f7a 100644 --- a/swad_exam.h +++ b/swad_exam.h @@ -52,9 +52,7 @@ void Exa_ShowOnlyOneExamEnd (void); void Exa_SetCurrentExaCod (long ExaCod); void Exa_PutParams (void *Exams); -void Exa_PutParamExamCod (long ExaCod); -long Exa_GetParamExamCod (void); -void Exa_GetParams (struct Exa_Exams *Exams); +void Exa_GetParams (struct Exa_Exams *Exams,bool CheckExaCod); void Exa_GetListExams (struct Exa_Exams *Exams,Exa_Order_t SelectedOrder); void Exa_GetListSelectedExaCods (struct Exa_Exams *Exams); diff --git a/swad_exam_print.c b/swad_exam_print.c index 789db3f6..1efb526b 100644 --- a/swad_exam_print.c +++ b/swad_exam_print.c @@ -971,7 +971,7 @@ void ExaPrn_ReceivePrintAnswer (void) ExaSes_ResetSession (&Session); /***** Get session code *****/ - Print.SesCod = ExaSes_GetParamSesCod (); + Print.SesCod = Par_GetAndCheckParCode (Par_SesCod); /***** Get print data *****/ Print.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; diff --git a/swad_exam_resource.c b/swad_exam_resource.c index 008ac7d3..73c03054 100644 --- a/swad_exam_resource.c +++ b/swad_exam_resource.c @@ -32,6 +32,7 @@ #include "swad_exam_database.h" #include "swad_exam_resource.h" #include "swad_form.h" +#include "swad_parameter.h" #include "swad_program_database.h" /*****************************************************************************/ @@ -48,7 +49,7 @@ void ExaRsc_GetLinkToExam (void) Exa_ResetExams (&Exams); /***** Get parameters *****/ - Exa_GetParams (&Exams); + Exa_GetParams (&Exams,true); /***** Get exam title *****/ ExaRsc_GetTitleFromExaCod (Exams.Exam.ExaCod,Title,sizeof (Title) - 1); @@ -84,7 +85,7 @@ void ExaRsc_WriteExamInCrsProgram (long ExaCod,bool PutFormToGo, NextAction = (ExaCod > 0) ? ActSeeExa : // Exam specified ActSeeAllExa; // All exams Frm_BeginForm (NextAction); - Exa_PutParamExamCod (ExaCod); + Par_PutParCod (Par_ExaCod,ExaCod); HTM_BUTTON_Submit_Begin (Txt_Actions[NextAction], "class=\"LM BT_LINK PRG_LNK_%s\"", The_GetSuffix ()); diff --git a/swad_exam_result.c b/swad_exam_result.c index bd7f1847..1795aba8 100644 --- a/swad_exam_result.c +++ b/swad_exam_result.c @@ -194,9 +194,7 @@ void ExaRes_ShowMyResultsInExa (void) ExaSes_ResetSession (&Session); /***** Get parameters *****/ - Exa_GetParams (&Exams); - if (Exams.Exam.ExaCod <= 0) - Err_WrongExamExit (); + Exa_GetParams (&Exams,true); /***** Get exam data from database *****/ Exa_GetDataOfExamByCod (&Exams.Exam); @@ -244,11 +242,8 @@ void ExaRes_ShowMyResultsInSes (void) ExaSes_ResetSession (&Session); /***** Get parameters *****/ - Exa_GetParams (&Exams); - if (Exams.Exam.ExaCod <= 0) - Err_WrongExamExit (); - if ((Session.SesCod = ExaSes_GetParamSesCod ()) <= 0) - Err_WrongExamSessionExit (); + Exa_GetParams (&Exams,true); + Session.SesCod = Par_GetAndCheckParCode (Par_SesCod); Exa_GetDataOfExamByCod (&Exams.Exam); ExaSes_GetDataOfSessionByCod (&Session); @@ -393,9 +388,7 @@ void ExaRes_ShowAllResultsInExa (void) ExaSes_ResetSession (&Session); /***** Get parameters *****/ - Exa_GetParams (&Exams); - if (Exams.Exam.ExaCod <= 0) - Err_WrongExamExit (); + Exa_GetParams (&Exams,true); Exa_GetDataOfExamByCod (&Exams.Exam); /***** Exam begin *****/ @@ -463,11 +456,8 @@ void ExaRes_ShowAllResultsInSes (void) ExaSes_ResetSession (&Session); /***** Get parameters *****/ - Exa_GetParams (&Exams); - if (Exams.Exam.ExaCod <= 0) - Err_WrongExamExit (); - if ((Session.SesCod = ExaSes_GetParamSesCod ()) <= 0) - Err_WrongExamSessionExit (); + Exa_GetParams (&Exams,true); + Session.SesCod = Par_GetAndCheckParCode (Par_SesCod); /***** Get exam data and session *****/ Exa_GetDataOfExamByCod (&Exams.Exam); @@ -570,6 +560,7 @@ static void ExaRes_ShowResultsEnd (void) static void ExaRes_ListExamsToSelect (struct Exa_Exams *Exams) { + extern const char *Par_CodeStr[]; extern const char *Txt_Exams; extern const char *Txt_Exam; extern const char *Txt_Update_results; @@ -614,7 +605,7 @@ static void ExaRes_ListExamsToSelect (struct Exa_Exams *Exams) HTM_TD_Begin ("class=\"CT DAT_%s %s\"", The_GetSuffix (), The_GetColorRows ()); - HTM_INPUT_CHECKBOX ("ExaCod",HTM_DONT_SUBMIT_ON_CHANGE, + HTM_INPUT_CHECKBOX (Par_CodeStr[Par_ExaCod],HTM_DONT_SUBMIT_ON_CHANGE, "id=\"Gam%u\" value=\"%ld\"%s", NumExam,Exams->Lst[NumExam].ExaCod, Exams->Lst[NumExam].Selected ? " checked=\"checked\"" : diff --git a/swad_exam_session.c b/swad_exam_session.c index ad3e6e8c..197bf723 100644 --- a/swad_exam_session.c +++ b/swad_exam_session.c @@ -521,7 +521,7 @@ static void ExaSes_ListOneOrMoreSessionsTitleGrps (struct Exa_Exams *Exams, { Frm_BeginForm (ActSeeExaPrn); Exa_PutParams (Exams); - ExaSes_PutParamSesCod (Session->SesCod); + Par_PutParCod (Par_SesCod,Session->SesCod); HTM_BUTTON_Submit_Begin (Gbl.Usrs.Me.Role.Logged == Rol_STD ? Txt_Play : Txt_Resume, "class=\"LT BT_LINK %s_%s\"", @@ -926,19 +926,10 @@ void ExaSes_PutParamsEdit (void *Exams) if (Exams) { Exa_PutParams (Exams); - ExaSes_PutParamSesCod (((struct Exa_Exams *) Exams)->SesCod); + Par_PutParCod (Par_SesCod,((struct Exa_Exams *) Exams)->SesCod); } } -/*****************************************************************************/ -/**************** Write parameter with code of exam session ******************/ -/*****************************************************************************/ - -void ExaSes_PutParamSesCod (long SesCod) - { - Par_PutHiddenParamLong (NULL,"SesCod",SesCod); - } - /*****************************************************************************/ /************************** Get and check parameters *************************/ /*****************************************************************************/ @@ -947,12 +938,9 @@ void ExaSes_GetAndCheckParameters (struct Exa_Exams *Exams, struct ExaSes_Session *Session) { /***** Get parameters *****/ - Exa_GetParams (Exams); - if (Exams->Exam.ExaCod <= 0) - Err_WrongExamExit (); + Exa_GetParams (Exams,true); Grp_GetParamWhichGroups (); - if ((Session->SesCod = ExaSes_GetParamSesCod ()) <= 0) - Err_WrongExamSessionExit (); + Session->SesCod = Par_GetAndCheckParCode (Par_SesCod); /***** Get exam data from database *****/ Exa_GetDataOfExamByCod (&Exams->Exam); @@ -966,16 +954,6 @@ void ExaSes_GetAndCheckParameters (struct Exa_Exams *Exams, Exams->SesCod = Session->SesCod; } -/*****************************************************************************/ -/**************** Get parameter with code of exam session ********************/ -/*****************************************************************************/ - -long ExaSes_GetParamSesCod (void) - { - /***** Get code of exam session *****/ - return Par_GetParToLong ("SesCod"); - } - /*****************************************************************************/ /* Put a big button to play exam session (start a new session) as a teacher **/ /*****************************************************************************/ @@ -1000,9 +978,9 @@ static void ExaSes_PutFormSession (const struct ExaSes_Session *Session) /***** Begin form *****/ Frm_BeginForm (ItsANewSession ? ActNewExaSes : // New session ActChgExaSes); // Existing session - Exa_PutParamExamCod (Session->ExaCod); + Par_PutParCod (Par_ExaCod,Session->ExaCod); if (!ItsANewSession) // Existing session - ExaSes_PutParamSesCod (Session->SesCod); + Par_PutParCod (Par_SesCod,Session->SesCod); /***** Begin box and table *****/ Box_BoxTableBegin (NULL,ItsANewSession ? Txt_New_session : @@ -1084,8 +1062,10 @@ static void ExaSes_ShowLstGrpsToCreateSession (long SesCod) HTM_INPUT_CHECKBOX ("WholeCrs",HTM_DONT_SUBMIT_ON_CHANGE, "id=\"WholeCrs\" value=\"Y\"%s" " onclick=\"uncheckChildren(this,'GrpCods')\"", - Grp_DB_CheckIfAssociatedToGrps ("exa_groups","SesCod",SesCod) ? "" : - " checked=\"checked\""); + Grp_DB_CheckIfAssociatedToGrps ("exa_groups", + Par_SesCod, + SesCod) ? "" : + " checked=\"checked\""); HTM_TxtF ("%s %s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName); HTM_LABEL_End (); HTM_TD_End (); @@ -1140,11 +1120,9 @@ void ExaSes_RequestCreatOrEditSes (void) ExaSes_ResetSession (&Session); /***** Get parameters *****/ - Exa_GetParams (&Exams); - if (Exams.Exam.ExaCod <= 0) - Err_WrongExamExit (); + Exa_GetParams (&Exams,true); Grp_GetParamWhichGroups (); - Session.SesCod = ExaSes_GetParamSesCod (); + Session.SesCod = Par_GetParCode (Par_SesCod); ItsANewSession = (Session.SesCod <= 0); /***** Get exam data from database *****/ @@ -1188,11 +1166,9 @@ void ExaSes_ReceiveFormSession (void) ExaSes_ResetSession (&Session); /***** Get main parameters *****/ - Exa_GetParams (&Exams); - if (Exams.Exam.ExaCod <= 0) - Err_WrongExamExit (); + Exa_GetParams (&Exams,true); Grp_GetParamWhichGroups (); - Session.SesCod = ExaSes_GetParamSesCod (); + Session.SesCod = Par_GetParCode (Par_SesCod); ItsANewSession = (Session.SesCod <= 0); /***** Get exam data from database *****/ diff --git a/swad_exam_session.h b/swad_exam_session.h index 0fbd043e..1604fabf 100644 --- a/swad_exam_session.h +++ b/swad_exam_session.h @@ -64,10 +64,8 @@ void ExaSes_HideSession (void); void ExaSes_UnhideSession (void); void ExaSes_PutParamsEdit (void *Exams); -void ExaSes_PutParamSesCod (long SesCod); void ExaSes_GetAndCheckParameters (struct Exa_Exams *Exams, struct ExaSes_Session *Session); -long ExaSes_GetParamSesCod (void); void ExaSes_PutButtonNewSession (struct Exa_Exams *Exams); void ExaSes_RequestCreatOrEditSes (void); diff --git a/swad_exam_set.c b/swad_exam_set.c index e9051ed6..a2507b9c 100644 --- a/swad_exam_set.c +++ b/swad_exam_set.c @@ -116,9 +116,6 @@ static void ExaSet_ChangeValidityQst (Qst_Validity_t Valid); static void ExaSet_GetAndCheckParameters (struct Exa_Exams *Exams, struct ExaSet_Set *Set); -static long ExaSet_GetParamQstCod (void); -static void ExaSet_PutParamQstCod (void *QstCod); // Should be a pointer to long - static void ExaSet_ExchangeSets (long ExaCod, unsigned SetIndTop,unsigned SetIndBottom); @@ -145,17 +142,7 @@ void ExaSet_PutParamsOneSet (void *Exams) static void ExaSet_PutParamsOneQst (void *Exams) { ExaSet_PutParamsOneSet (Exams); - ExaSet_PutParamQstCod (&(((struct Exa_Exams *) Exams)->QstCod)); - } - -/*****************************************************************************/ -/********************** Get parameter with code of set ***********************/ -/*****************************************************************************/ - -long ExaSet_GetParamSetCod (void) - { - /***** Get code of set *****/ - return Par_GetParToLong ("SetCod"); + Qst_PutParamQstCod (&(((struct Exa_Exams *) Exams)->QstCod)); } /*****************************************************************************/ @@ -295,11 +282,9 @@ void ExaSet_ReceiveFormSet (void) ExaSet_ResetSet (&Set); /***** Get parameters *****/ - Exa_GetParams (&Exams); - if (Exams.Exam.ExaCod <= 0) - Err_WrongExamExit (); + Exa_GetParams (&Exams,true); Set.ExaCod = Exams.Exam.ExaCod; - Exams.SetCod = Set.SetCod = ExaSet_GetParamSetCod (); + Exams.SetCod = Set.SetCod = Par_GetParCode (Par_SesCod); ItsANewSet = (Set.SetCod <= 0); /***** Get exam data from database *****/ @@ -516,10 +501,8 @@ void ExaSet_RequestCreatOrEditSet (void) ExaSet_ResetSet (&Set); /***** Get parameters *****/ - Exa_GetParams (&Exams); - if (Exams.Exam.ExaCod <= 0) - Err_WrongExamExit (); - Exams.SetCod = Set.SetCod = ExaSet_GetParamSetCod (); + Exa_GetParams (&Exams,true); + Exams.SetCod = Set.SetCod = Par_GetParCode (Par_SesCod); ItsANewSet = (Set.SetCod <= 0); /***** Get exam data from database *****/ @@ -1548,8 +1531,8 @@ void ExaSet_RequestRemoveQstFromSet (void) /***** Get and check parameters *****/ ExaSet_GetAndCheckParameters (&Exams,&Set); - /***** Get question index *****/ - Exams.QstCod = ExaSet_GetParamQstCod (); + /***** Get question code *****/ + Exams.QstCod = Par_GetAndCheckParCode (Par_QstCod); /***** Build anchor string *****/ Frm_SetAnchorStr (Set.SetCod,&Anchor); @@ -1588,8 +1571,8 @@ void ExaSet_RemoveQstFromSet (void) /***** Get and check parameters *****/ ExaSet_GetAndCheckParameters (&Exams,&Set); - /***** Get question index *****/ - QstCod = ExaSet_GetParamQstCod (); + /***** Get question code *****/ + QstCod = Par_GetAndCheckParCode (Par_QstCod); /***** Remove media associated to question *****/ ExaSet_RemoveMediaFromStemOfQst (QstCod,Set.SetCod); @@ -1669,8 +1652,8 @@ static void ExaSet_ChangeValidityQst (Qst_Validity_t Validity) /***** Get and check parameters *****/ ExaSet_GetAndCheckParameters (&Exams,&Set); - /***** Get question index *****/ - QstCod = ExaSet_GetParamQstCod (); + /***** Get question code *****/ + QstCod = Par_GetAndCheckParCode (Par_QstCod); /***** Validate/unvalidate question *****/ Exa_DB_ChangeValidityQst (QstCod,Set.SetCod,Exams.Exam.ExaCod,Gbl.Hierarchy.Crs.CrsCod, @@ -1689,12 +1672,9 @@ static void ExaSet_GetAndCheckParameters (struct Exa_Exams *Exams, struct ExaSet_Set *Set) { /***** Get parameters *****/ - Exa_GetParams (Exams); - if (Exams->Exam.ExaCod <= 0) - Err_WrongExamExit (); + Exa_GetParams (Exams,true); Grp_GetParamWhichGroups (); - if ((Set->SetCod = ExaSet_GetParamSetCod ()) <= 0) - Err_WrongSetExit (); + Set->SetCod = Par_GetAndCheckParCode (Par_SesCod); /***** Get exam data from database *****/ Exa_GetDataOfExamByCod (&Exams->Exam); @@ -1708,27 +1688,6 @@ static void ExaSet_GetAndCheckParameters (struct Exa_Exams *Exams, Exams->SetCod = Set->SetCod; } -/*****************************************************************************/ -/************ Get the parameter with the code of a test question *************/ -/*****************************************************************************/ - -static long ExaSet_GetParamQstCod (void) - { - /***** Get code of test question *****/ - return Par_GetParToLong ("QstCod"); - } - -/*****************************************************************************/ -/************ Put parameter with question code to edit, remove... ************/ -/*****************************************************************************/ - -static void ExaSet_PutParamQstCod (void *QstCod) // Should be a pointer to long - { - if (QstCod) - if (*((long *) QstCod) > 0) // If question exists - Par_PutHiddenParamLong (NULL,"QstCod",*((long *) QstCod)); - } - /*****************************************************************************/ /*********** Exchange the order of two consecutive sets in an exam ***********/ /*****************************************************************************/ diff --git a/swad_exam_set.h b/swad_exam_set.h index 6a24ffa4..d31c65ce 100644 --- a/swad_exam_set.h +++ b/swad_exam_set.h @@ -36,7 +36,6 @@ /*****************************************************************************/ void ExaSet_PutParamsOneSet (void *Exams); -long ExaSet_GetParamSetCod (void); void ExaSet_GetDataOfSetByCod (struct ExaSet_Set *Set); diff --git a/swad_forum.c b/swad_forum.c index 0f429779..5d65c8e9 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -330,8 +330,6 @@ static void For_PutParamsForum (void *Forums); static void For_PutParamForumSet (For_ForumSet_t ForumSet); static void For_PutParamForumLocation (long Location); -static void For_PutHiddenParamThrCod (long ThrCod); -static void For_PutHiddenParamPstCod (long PstCod); static void For_PutIconsForums (__attribute__((unused)) void *Args); static void For_PutFormWhichForums (const struct For_Forums *Forums); @@ -1143,8 +1141,8 @@ void For_PutAllHiddenParamsForum (unsigned NumPageThreads, For_PutParamForumSet (ForumSet); Par_PutHiddenParamOrder ((unsigned) Order); For_PutParamForumLocation (Location); - For_PutHiddenParamThrCod (ThrCod); - For_PutHiddenParamPstCod (PstCod); + Par_PutParCod (Par_ThrCod,ThrCod); + Par_PutParCod (Par_PstCod,PstCod); } /*****************************************************************************/ @@ -1169,26 +1167,6 @@ static void For_PutParamForumLocation (long Location) Par_PutHiddenParamLong (NULL,"Location",Location); } -/*****************************************************************************/ -/************ Write a form parameter to specify a thread code ****************/ -/*****************************************************************************/ - -static void For_PutHiddenParamThrCod (long ThrCod) - { - if (ThrCod > 0) - Par_PutHiddenParamLong (NULL,"ThrCod",ThrCod); - } - -/*****************************************************************************/ -/************* Write a form parameter to specify a post code *****************/ -/*****************************************************************************/ - -static void For_PutHiddenParamPstCod (long PstCod) - { - if (PstCod > 0) - Par_PutHiddenParamLong (NULL,"PstCod",PstCod); - } - /*****************************************************************************/ /************************** Show list of available forums ********************/ /*****************************************************************************/ @@ -2462,10 +2440,10 @@ void For_GetParamsForums (struct For_Forums *Forums) /***** Get optional parameter with code of a selected thread *****/ Forums->Thread.Current = - Forums->Thread.Selected = Par_GetParToLong ("ThrCod"); + Forums->Thread.Selected = Par_GetParCode (Par_ThrCod); /***** Get optional parameter with code of a selected post *****/ - Forums->PstCod = Par_GetParToLong ("PstCod"); + Forums->PstCod = Par_GetParCode (Par_PstCod); /***** Get which forums I want to see *****/ Forums->ForumSet = (For_ForumSet_t) diff --git a/swad_game.c b/swad_game.c index 4f763ac3..cd95b7b7 100644 --- a/swad_game.c +++ b/swad_game.c @@ -786,7 +786,7 @@ void Gam_PutParams (void *Games) if (Games) { if (((struct Gam_Games *) Games)->Game.GamCod > 0) - Gam_PutParamGameCod (((struct Gam_Games *) Games)->Game.GamCod); + Gam_PutParamGamCod (((struct Gam_Games *) Games)->Game.GamCod); Gam_PutHiddenParamOrder (((struct Gam_Games *) Games)->SelectedOrder); WhichGroups = Grp_GetParamWhichGroups (); Grp_PutParamWhichGroups (&WhichGroups); @@ -798,20 +798,12 @@ void Gam_PutParams (void *Games) /******************** Write parameter with code of game **********************/ /*****************************************************************************/ -void Gam_PutParamGameCod (long GamCod) +void Gam_PutParamGamCod (long GamCod) { + extern const char *Par_CodeStr[]; + if (GamCod > 0) - Par_PutHiddenParamLong (NULL,"GamCod",GamCod); - } - -/*****************************************************************************/ -/********************* Get parameter with code of game ***********************/ -/*****************************************************************************/ - -long Gam_GetParamGameCod (void) - { - /***** Get code of game *****/ - return Par_GetParToLong ("GamCod"); + Par_PutHiddenParamLong (NULL,Par_CodeStr[Par_GamCod],GamCod); } /*****************************************************************************/ @@ -825,7 +817,7 @@ long Gam_GetParams (struct Gam_Games *Games) Games->CurrentPage = Pag_GetParamPagNum (Pag_GAMES); /***** Get game code *****/ - return Gam_GetParamGameCod (); + return Par_GetParCode (Par_GamCod); } /*****************************************************************************/ @@ -896,6 +888,7 @@ void Gam_GetListGames (struct Gam_Games *Games,Gam_Order_t SelectedOrder) void Gam_GetListSelectedGamCods (struct Gam_Games *Games) { + extern const char *Par_CodeStr[]; unsigned MaxSizeListGamCodsSelected; unsigned NumGame; const char *Ptr; @@ -915,7 +908,8 @@ void Gam_GetListSelectedGamCods (struct Gam_Games *Games) Err_NotEnoughMemoryExit (); /***** Get parameter multiple with list of games selected *****/ - Par_GetParMultiToText ("GamCod",Games->GamCodsSelected,MaxSizeListGamCodsSelected); + Par_GetParMultiToText (Par_CodeStr[Par_GamCod],Games->GamCodsSelected, + MaxSizeListGamCodsSelected); /***** Set which games will be shown as selected (checkboxes on) *****/ if (Games->GamCodsSelected[0]) // Some games selected @@ -1104,8 +1098,7 @@ void Gam_RemoveGame (void) Gam_ResetGame (&Games.Game); /***** Get game code *****/ - if ((Games.Game.GamCod = Gam_GetParamGameCod ()) <= 0) - Err_WrongGameExit (); + Games.Game.GamCod = Par_GetAndCheckParCode (Par_GamCod); /***** Get data of the game from database *****/ Gam_GetDataOfGameByCod (&Games.Game); diff --git a/swad_game.h b/swad_game.h index fbc22548..effa4e0d 100644 --- a/swad_game.h +++ b/swad_game.h @@ -119,8 +119,7 @@ void Gam_ShowOnlyOneGameEnd (void); void Gam_SetCurrentGamCod (long GamCod); void Gam_PutParams (void *Games); -void Gam_PutParamGameCod (long GamCod); -long Gam_GetParamGameCod (void); +void Gam_PutParamGamCod (long GamCod); long Gam_GetParams (struct Gam_Games *Games); void Gam_GetListGames (struct Gam_Games *Games,Gam_Order_t SelectedOrder); diff --git a/swad_game_resource.c b/swad_game_resource.c index fc552339..c79129f8 100644 --- a/swad_game_resource.c +++ b/swad_game_resource.c @@ -85,7 +85,7 @@ void GamRsc_WriteGameInCrsProgram (long GamCod,bool PutFormToGo, NextAction = (GamCod > 0) ? ActSeeGam : // Game specified ActSeeAllGam; // All games Frm_BeginForm (NextAction); - Gam_PutParamGameCod (GamCod); + Gam_PutParamGamCod (GamCod); HTM_BUTTON_Submit_Begin (Txt_Actions[NextAction], "class=\"LM BT_LINK PRG_LNK_%s\"", The_GetSuffix ()); diff --git a/swad_group.c b/swad_group.c index e38898c9..55957880 100644 --- a/swad_group.c +++ b/swad_group.c @@ -1620,14 +1620,14 @@ void Grp_ListGrpsToEditAsgAttSvyEvtMch (struct GroupType *GrpTyp, static const struct { const char *Table; - const char *Field; + Par_Code_t ParamCode; } AssociationsToGrps[Grp_NUM_ASSOCIATIONS_TO_GROUPS] = { - [Grp_ASSIGNMENT] = {"asg_groups","AsgCod"}, - [Grp_ATT_EVENT ] = {"att_groups","AttCod"}, - [Grp_SURVEY ] = {"svy_groups","SvyCod"}, - [Grp_EXA_EVENT ] = {"exa_groups","SesCod"}, - [Grp_MATCH ] = {"mch_groups","MchCod"}, + [Grp_ASSIGNMENT] = {"asg_groups",Par_AsgCod}, + [Grp_ATT_EVENT ] = {"att_groups",Par_AttCod}, + [Grp_SURVEY ] = {"svy_groups",Par_SvyCod}, + [Grp_EXA_EVENT ] = {"exa_groups",Par_SesCod}, + [Grp_MATCH ] = {"mch_groups",Par_MchCod}, }; struct ListCodGrps LstGrpsIBelong; unsigned NumGrpThisType; @@ -1652,7 +1652,7 @@ void Grp_ListGrpsToEditAsgAttSvyEvtMch (struct GroupType *GrpTyp, if (Cod > 0) // Cod == -1L means new item, assignment, event, survey, exam event or match AssociatedToGrp = Grp_DB_CheckIfAssociatedToGrp (AssociationsToGrps[WhichIsAssociatedToGrp].Table, - AssociationsToGrps[WhichIsAssociatedToGrp].Field, + AssociationsToGrps[WhichIsAssociatedToGrp].ParamCode, Cod,Grp->GrpCod); else AssociatedToGrp = false; @@ -4177,7 +4177,7 @@ void Grp_RenameGroup (void) static void Grp_PutParamGrpTypCod (void *GrpTypCod) { if (GrpTypCod) - Par_PutHiddenParamLong (NULL,"GrpTypCod",*((long *) GrpTypCod)); + Par_PutParCod (Par_GrpTypCod,*((long *) GrpTypCod)); } /*****************************************************************************/ @@ -4187,7 +4187,7 @@ static void Grp_PutParamGrpTypCod (void *GrpTypCod) void Grp_PutParamGrpCod (void *GrpCod) { if (GrpCod) - Par_PutHiddenParamLong (NULL,"GrpCod",*((long *) GrpCod)); + Par_PutParCod (Par_GrpCod,*((long *) GrpCod)); } /*****************************************************************************/ diff --git a/swad_group_database.c b/swad_group_database.c index 96ca4f27..c21022d8 100644 --- a/swad_group_database.c +++ b/swad_group_database.c @@ -32,7 +32,7 @@ #include "swad_database.h" #include "swad_error.h" #include "swad_global.h" -#include "swad_group.h" +#include "swad_group_database.h" /*****************************************************************************/ /************* External global variables from others modules *****************/ @@ -679,9 +679,11 @@ long Grp_DB_GetGrpTypeFromGrp (long GrpCod) /*********** exam session or match is associated to a given group ************/ /*****************************************************************************/ -bool Grp_DB_CheckIfAssociatedToGrp (const char *Table,const char *Field, +bool Grp_DB_CheckIfAssociatedToGrp (const char *Table,Par_Code_t ParamCode, long Cod,long GrpCod) { + extern const char *Par_CodeStr[]; // Database field name must be equal to code parameter name + return DB_QueryEXISTS ("can not check if associated to a group", "SELECT EXISTS" @@ -690,7 +692,7 @@ bool Grp_DB_CheckIfAssociatedToGrp (const char *Table,const char *Field, " WHERE %s=%ld" " AND GrpCod=%ld)", Table, - Field,Cod, + Par_CodeStr[ParamCode],Cod, GrpCod); } @@ -699,8 +701,10 @@ bool Grp_DB_CheckIfAssociatedToGrp (const char *Table,const char *Field, /************ exam session or match is associated to any group **************/ /*****************************************************************************/ -bool Grp_DB_CheckIfAssociatedToGrps (const char *Table,const char *Field,long Cod) +bool Grp_DB_CheckIfAssociatedToGrps (const char *Table,Par_Code_t ParamCode,long Cod) { + extern const char *Par_CodeStr[]; // Database field name must be equal to code parameter name + /***** Trivial check *****/ if (Cod <= 0) // Assignment, attendance event, survey, exam event or match code return false; @@ -714,7 +718,7 @@ bool Grp_DB_CheckIfAssociatedToGrps (const char *Table,const char *Field,long Co " FROM %s" " WHERE %s=%ld)", Table, - Field,Cod); + Par_CodeStr[ParamCode],Cod); } /*****************************************************************************/ diff --git a/swad_group_database.h b/swad_group_database.h index 4fac3b00..4d2b98dc 100644 --- a/swad_group_database.h +++ b/swad_group_database.h @@ -28,6 +28,7 @@ /*****************************************************************************/ #include "swad_group.h" +#include "swad_parameter.h" /*****************************************************************************/ /**************************** Public prototypes ******************************/ @@ -77,9 +78,9 @@ unsigned Grp_DB_GetNamesGrpsUsrBelongsTo (MYSQL_RES **mysql_res, long Grp_DB_GetGrpTypeFromGrp (long GrpCod); -bool Grp_DB_CheckIfAssociatedToGrp (const char *Table,const char *Field, +bool Grp_DB_CheckIfAssociatedToGrp (const char *Table,Par_Code_t ParamCode, long Cod,long GrpCod); -bool Grp_DB_CheckIfAssociatedToGrps (const char *Table,const char *Field,long Cod); +bool Grp_DB_CheckIfAssociatedToGrps (const char *Table,Par_Code_t ParamCode,long Cod); void Grp_DB_ChangeMandatoryEnrolmentOfAGrpTyp (long GrpTypCod, bool NewMandatoryEnrolment); diff --git a/swad_indicator.c b/swad_indicator.c index bdf06768..48e40084 100644 --- a/swad_indicator.c +++ b/swad_indicator.c @@ -97,6 +97,7 @@ static unsigned Ind_GetAndUpdateNumIndicatorsCrs (long CrsCod); void Ind_ReqIndicatorsCourses (void) { extern const char *Hlp_ANALYTICS_Indicators; + extern const char *Par_CodeStr[]; extern const char *Txt_Scope; extern const char *Txt_Types_of_degree; extern const char *Txt_only_if_the_scope_is_X; @@ -143,7 +144,7 @@ void Ind_ReqIndicatorsCourses (void) HTM_TR_Begin (NULL); /* Label */ - Frm_LabelColumn ("RT","OthDegTypCod",Txt_Types_of_degree); + Frm_LabelColumn ("RT",Par_CodeStr[Par_OthDegTypCod],Txt_Types_of_degree); /* Data */ HTM_TD_Begin ("class=\"LT DAT_%s\"",The_GetSuffix ()); @@ -159,7 +160,7 @@ void Ind_ReqIndicatorsCourses (void) HTM_TR_Begin (NULL); /* Label */ - Frm_LabelColumn ("RT",Dpt_PARAM_DPT_COD_NAME,Txt_Department); + Frm_LabelColumn ("RT",Par_CodeStr[Par_DptCod],Txt_Department); /* Data */ HTM_TD_Begin ("class=\"LT\""); @@ -168,7 +169,7 @@ void Ind_ReqIndicatorsCourses (void) Err_NotEnoughMemoryExit (); Dpt_WriteSelectorDepartment (Gbl.Hierarchy.Ins.InsCod, // Departments in current insitution Indicators.DptCod, // Selected department - Dpt_PARAM_DPT_COD_NAME, // Parameter name + Par_CodeStr[Par_DptCod], // Parameter name SelectClass, // Selector class -1L, // First option Txt_Any_department, // Text when no department selected @@ -220,8 +221,8 @@ void Ind_ReqIndicatorsCourses (void) /* Button to show more details */ Frm_BeginForm (ActSeeAllStaCrs); Sco_PutParamScope ("ScopeInd",Gbl.Scope.Current); - Par_PutHiddenParamLong (NULL,"OthDegTypCod",Indicators.DegTypCod); - Par_PutHiddenParamLong (NULL,Dpt_PARAM_DPT_COD_NAME,Indicators.DptCod); + Par_PutParCod (Par_OthDegTypCod,Indicators.DegTypCod); + Par_PutParCod (Par_DptCod ,Indicators.DptCod ); if (Indicators.StrIndicatorsSelected[0]) Par_PutHiddenParamString (NULL,"Indicators",Indicators.StrIndicatorsSelected); Btn_PutConfirmButton (Txt_Show_more_details); @@ -253,11 +254,11 @@ static void Ind_GetParamsIndicators (struct Ind_Indicators *Indicators) /***** Get degree type code *****/ Indicators->DegTypCod = (Gbl.Scope.Current == HieLvl_SYS) ? - DegTyp_GetAndCheckParamOtherDegTypCod (-1L) : // -1L (any degree type) is allowed here + Par_GetParCode (Par_OthDegTypCod) : // -1L (any degree type) is allowed here -1L; /***** Get department code *****/ - Indicators->DptCod = Dpt_GetAndCheckParamDptCod (-1L); // -1L (any department) is allowed here + Indicators->DptCod = Par_GetParCode (Par_DptCod); // -1L (any department) is allowed here /***** Get number of indicators *****/ Ind_GetParamNumIndicators (Indicators); @@ -381,11 +382,13 @@ static void Ind_PutButtonToConfirmIWantToSeeBigList (struct Ind_Indicators *Indi static void Ind_PutParamsConfirmIWantToSeeBigList (void *Indicators) { + extern const char *Par_CodeStr[]; + if (Indicators) { Sco_PutParamScope ("ScopeInd",Gbl.Scope.Current); - Par_PutHiddenParamLong (NULL,"OthDegTypCod",((struct Ind_Indicators *) Indicators)->DegTypCod); - Par_PutHiddenParamLong (NULL,Dpt_PARAM_DPT_COD_NAME,((struct Ind_Indicators *) Indicators)->DptCod); + Par_PutParCod (Par_OthDegTypCod,((struct Ind_Indicators *) Indicators)->DegTypCod); + Par_PutParCod (Par_DptCod ,((struct Ind_Indicators *) Indicators)->DptCod ); if (((struct Ind_Indicators *) Indicators)->StrIndicatorsSelected[0]) Par_PutHiddenParamString (NULL,"Indicators",((struct Ind_Indicators *) Indicators)->StrIndicatorsSelected); Par_PutHiddenParamChar ("ShowBigList",'Y'); diff --git a/swad_institution_config.c b/swad_institution_config.c index 3532de02..7218a372 100644 --- a/swad_institution_config.c +++ b/swad_institution_config.c @@ -306,6 +306,7 @@ static void InsCfg_Map (void) static void InsCfg_Country (bool PrintView,bool PutForm) { + extern const char *Par_CodeStr[]; extern const char *Txt_Country; unsigned NumCty; @@ -316,7 +317,7 @@ static void InsCfg_Country (bool PrintView,bool PutForm) HTM_TR_Begin (NULL); /* Label */ - Frm_LabelColumn ("RT",PutForm ? "OthCtyCod" : + Frm_LabelColumn ("RT",PutForm ? Par_CodeStr[Par_OthCtyCod] : NULL, Txt_Country); diff --git a/swad_match.c b/swad_match.c index 2e46a5b2..edeeb9db 100644 --- a/swad_match.c +++ b/swad_match.c @@ -124,7 +124,6 @@ static void Mch_GetMatchDataFromRow (MYSQL_RES *mysql_res, struct Mch_Match *Match); static void Mch_PutParamsPlay (void *MchCod); -static void Mch_PutParamMchCod (long MchCod); static void Mch_PutFormExistingMatch (struct Gam_Games *Games, const struct Mch_Match *Match, @@ -632,7 +631,7 @@ static void Mch_ListOneOrMoreMatchesTitleGrps (const struct Mch_Match *Match, /***** Match title *****/ Frm_BeginForm (Gbl.Usrs.Me.Role.Logged == Rol_STD ? ActJoiMch : ActResMch); - Mch_PutParamMchCod (Match->MchCod); + Par_PutParCod (Par_MchCod,Match->MchCod); HTM_BUTTON_Submit_Begin (Gbl.Usrs.Me.Role.Logged == Rol_STD ? Txt_Play : Txt_Resume, @@ -1122,7 +1121,7 @@ void Mch_PutParamsEdit (void *Games) if (Games) { Gam_PutParams (Games); - Mch_PutParamMchCod (((struct Gam_Games *) Games)->MchCod.Current); + Par_PutParCod (Par_MchCod,((struct Gam_Games *) Games)->MchCod.Current); } } @@ -1133,19 +1132,7 @@ void Mch_PutParamsEdit (void *Games) static void Mch_PutParamsPlay (void *MchCod) { if (MchCod) - { - if (*((long *) MchCod) > 0) - Mch_PutParamMchCod (*((long *) MchCod)); - } - } - -/*****************************************************************************/ -/******************** Write parameter with code of match **********************/ -/*****************************************************************************/ - -static void Mch_PutParamMchCod (long MchCod) - { - Par_PutHiddenParamLong (NULL,"MchCod",MchCod); + Par_PutParCod (Par_MchCod,*((long *) MchCod)); } /*****************************************************************************/ @@ -1163,8 +1150,7 @@ void Mch_GetAndCheckParameters (struct Gam_Games *Games, Gam_GetDataOfGameByCod (&Games->Game); /* Get match code */ - if ((Match->MchCod = Mch_GetParamMchCod ()) <= 0) - Err_WrongMatchExit (); + Match->MchCod = Par_GetAndCheckParCode (Par_MchCod); Mch_GetDataOfMatchByCod (Match); /***** Ensure parameters are correct *****/ @@ -1178,16 +1164,6 @@ void Mch_GetAndCheckParameters (struct Gam_Games *Games, Games->MchCod.Selected = Match->MchCod; } -/*****************************************************************************/ -/********************* Get parameter with code of match **********************/ -/*****************************************************************************/ - -long Mch_GetParamMchCod (void) - { - /***** Get code of match *****/ - return Par_GetParToLong ("MchCod"); - } - /*****************************************************************************/ /******************* Put a form to change and existing match *****************/ /*****************************************************************************/ @@ -1258,7 +1234,7 @@ static void Mch_PutFormNewMatch (const struct Gam_Game *Game) /***** Begin form *****/ Frm_BeginForm (ActNewMch); - Gam_PutParamGameCod (Game->GamCod); + Gam_PutParamGamCod (Game->GamCod); Gam_PutParamQstInd (0); // Start by first question in game /***** Begin box and table *****/ @@ -1341,8 +1317,10 @@ static void Mch_ShowLstGrpsToEditMatch (long MchCod) HTM_INPUT_CHECKBOX ("WholeCrs",HTM_DONT_SUBMIT_ON_CHANGE, "id=\"WholeCrs\" value=\"Y\"%s" " onclick=\"uncheckChildren(this,'GrpCods')\"", - Grp_DB_CheckIfAssociatedToGrps ("mch_groups","MchCod",MchCod) ? "" : - " checked=\"checked\""); + Grp_DB_CheckIfAssociatedToGrps ("mch_groups", + Par_MchCod, + MchCod) ? "" : + " checked=\"checked\""); HTM_TxtF ("%s %s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName); HTM_LABEL_End (); HTM_TD_End (); @@ -1380,8 +1358,7 @@ void Mch_CreateNewMatch (void) /***** Get form parameters *****/ /* Get match code */ - if ((GamCod = Gam_GetParamGameCod ()) < 0) - Err_WrongGameExit (); + GamCod = Par_GetAndCheckParCode (Par_GamCod); /* Get match title */ Par_GetParToText ("Title",Title,Mch_MAX_BYTES_TITLE); @@ -2621,7 +2598,7 @@ static void Mch_ShowFormColumns (const struct Mch_Match *Match) /* Begin form */ Frm_BeginForm (ActChgNumColMch); - Mch_PutParamMchCod (Match->MchCod); // Current match being played + Par_PutParCod (Par_MchCod,Match->MchCod); // Current match being played Mch_PutParamNumCols (NumCols); // Number of columns /* Number of columns */ @@ -2666,7 +2643,7 @@ static void Mch_PutCheckboxResult (const struct Mch_Match *Match) /***** Begin form *****/ Frm_BeginForm (ActChgVisResMchQst); - Mch_PutParamMchCod (Match->MchCod); // Current match being played + Par_PutParCod (Par_MchCod,Match->MchCod); // Current match being played /***** Put icon with link *****/ HTM_BUTTON_Submit_Begin (Txt_View_results, @@ -2704,7 +2681,7 @@ static void Mch_PutIfAnswered (const struct Mch_Match *Match,bool Answered) { /* Begin form */ Frm_BeginForm (ActSeeMchAnsQstStd); - Mch_PutParamMchCod (Match->MchCod); // Current match being played + Par_PutParCod (Par_MchCod,Match->MchCod); // Current match being played HTM_BUTTON_Submit_Begin (Txt_View_my_answer, "class=\"BT_LINK DAT_SMALL_GREEN_%s\"" @@ -2749,7 +2726,7 @@ static void Mch_PutIconToRemoveMyAnswer (const struct Mch_Match *Match) /***** Begin form *****/ Frm_BeginForm (ActRemMchAnsQstStd); - Mch_PutParamMchCod (Match->MchCod); // Current match being played + Par_PutParCod (Par_MchCod,Match->MchCod); // Current match being played Gam_PutParamQstInd (Match->Status.QstInd); // Current question index shown /***** Put icon with link *****/ @@ -3005,7 +2982,7 @@ static void Mch_ShowQuestionAndAnswersStd (const struct Mch_Match *Match, is necessary in order to be fast and not lose clicks due to refresh */ Frm_BeginForm (ActAnsMchQstStd); - Mch_PutParamMchCod (Match->MchCod); // Current match being played + Par_PutParCod (Par_MchCod,Match->MchCod); // Current match being played Gam_PutParamQstInd (Match->Status.QstInd); // Current question index shown Mch_PutParamNumOpt (NumOpt); // Number of button @@ -3270,7 +3247,7 @@ static void Mch_PutBigButton (Act_Action_t NextAction,const char *Id, { /***** Begin form *****/ Frm_BeginFormId (NextAction,Id); - Mch_PutParamMchCod (MchCod); + Par_PutParCod (Par_MchCod,MchCod); /***** Put icon with link *****/ HTM_DIV_Begin ("class=\"MCH_BIGBUTTON_CONT\""); @@ -3365,8 +3342,7 @@ void Mch_GetMatchBeingPlayed (void) long MchCodBeingPlayed; /***** Get match code ****/ - if ((MchCodBeingPlayed = Mch_GetParamMchCod ()) <= 0) - Err_WrongMatchExit (); + MchCodBeingPlayed = Par_GetAndCheckParCode (Par_MchCod); Mch_SetMchCodBeingPlayed (MchCodBeingPlayed); } diff --git a/swad_match.h b/swad_match.h index a50d3a4f..99a2d27f 100644 --- a/swad_match.h +++ b/swad_match.h @@ -116,7 +116,6 @@ void Mch_EditMatch (void); void Mch_PutParamsEdit (void *Games); void Mch_GetAndCheckParameters (struct Gam_Games *Games, struct Mch_Match *Match); -long Mch_GetParamMchCod (void); void Mch_CreateNewMatch (void); void Mch_ChangeMatch (void); diff --git a/swad_match_result.c b/swad_match_result.c index 629911c2..6965cf48 100644 --- a/swad_match_result.c +++ b/swad_match_result.c @@ -213,8 +213,7 @@ void MchRes_ShowMyMchResultsInMch (void) /***** Get parameters *****/ if ((Games.Game.GamCod = Gam_GetParams (&Games)) <= 0) Err_WrongGameExit (); - if ((Match.MchCod = Mch_GetParamMchCod ()) <= 0) - Err_WrongMatchExit (); + Match.MchCod = Par_GetAndCheckParCode (Par_MchCod); Gam_GetDataOfGameByCod (&Games.Game); Mch_GetDataOfMatchByCod (&Match); @@ -440,8 +439,7 @@ void MchRes_ShowAllMchResultsInMch (void) /***** Get parameters *****/ if ((Games.Game.GamCod = Gam_GetParams (&Games)) <= 0) Err_WrongGameExit (); - if ((Match.MchCod = Mch_GetParamMchCod ()) <= 0) - Err_WrongMatchExit (); + Match.MchCod = Par_GetAndCheckParCode (Par_MchCod); Gam_GetDataOfGameByCod (&Games.Game); Mch_GetDataOfMatchByCod (&Match); @@ -535,6 +533,7 @@ static void MchRes_ShowResultsEnd (void) static void MchRes_ListGamesToSelect (struct Gam_Games *Games) { + extern const char *Par_CodeStr[]; extern const char *Txt_Games; extern const char *Txt_Game; extern const char *Txt_Update_results; @@ -579,7 +578,7 @@ static void MchRes_ListGamesToSelect (struct Gam_Games *Games) HTM_TD_Begin ("class=\"CT DAT_%s %s\"", The_GetSuffix (), The_GetColorRows ()); - HTM_INPUT_CHECKBOX ("GamCod",HTM_DONT_SUBMIT_ON_CHANGE, + HTM_INPUT_CHECKBOX (Par_CodeStr[Par_GamCod],HTM_DONT_SUBMIT_ON_CHANGE, "id=\"Gam%u\" value=\"%ld\"%s", NumGame,Games->Lst[NumGame].GamCod, Games->Lst[NumGame].Selected ? " checked=\"checked\"" : diff --git a/swad_notice.c b/swad_notice.c index a1ed0c90..5f0459bd 100644 --- a/swad_notice.c +++ b/swad_notice.c @@ -93,7 +93,6 @@ static void Not_DrawANotice (Not_Listing_t TypeNoticesListing, Not_Status_t Status); static void Not_PutParams (void *NotCod); -static long Not_GetParamNotCod (void); /*****************************************************************************/ /***************************** Write a new notice ****************************/ @@ -203,8 +202,7 @@ void Not_ListFullNotices (void) void Not_GetHighLightedNotCod (void) { - /***** Get notice to be highlighted *****/ - Gbl.Crs.Notices.HighlightNotCod = Not_GetParamNotCod (); + Gbl.Crs.Notices.HighlightNotCod = Par_GetParCode (Par_NotCod); } /*****************************************************************************/ @@ -216,7 +214,7 @@ void Not_HideActiveNotice (void) long NotCod; /***** Get the code of the notice to hide *****/ - NotCod = Not_GetParamNotCod (); + NotCod = Par_GetAndCheckParCode (Par_NotCod); /***** Set notice as hidden *****/ Not_DB_ChangeNoticeStatus (NotCod,Not_OBSOLETE_NOTICE); @@ -237,7 +235,7 @@ void Not_RevealHiddenNotice (void) long NotCod; /***** Get the code of the notice to reveal *****/ - NotCod = Not_GetParamNotCod (); + NotCod = Par_GetAndCheckParCode (Par_NotCod); /***** Set notice as active *****/ Not_DB_ChangeNoticeStatus (NotCod,Not_ACTIVE_NOTICE); @@ -259,7 +257,7 @@ void Not_RequestRemNotice (void) long NotCod; /***** Get the code of the notice to remove *****/ - NotCod = Not_GetParamNotCod (); + NotCod = Par_GetAndCheckParCode (Par_NotCod); /***** Show question and button to remove this notice *****/ /* Begin alert */ @@ -287,7 +285,7 @@ void Not_RemoveNotice (void) long NotCod; /***** Get the code of the notice to remove *****/ - NotCod = Not_GetParamNotCod (); + NotCod = Par_GetAndCheckParCode (Par_NotCod); /***** Remove notice *****/ /* Copy notice to table of deleted notices */ @@ -602,7 +600,7 @@ static void Not_DrawANotice (Not_Listing_t TypeNoticesListing, { /* Form to view full notice */ Frm_BeginFormAnchor (ActSeeOneNot,Anchor); - Not_PutHiddenParamNotCod (NotCod); + Par_PutParCod (Par_NotCod,NotCod); HTM_BUTTON_Submit_Begin (Txt_See_full_notice, "class=\"RT BT_LINK\""); } @@ -806,26 +804,7 @@ unsigned Not_GetNumNoticesDeleted (HieLvl_Level_t Scope,unsigned *NumNotif) static void Not_PutParams (void *NotCod) { if (NotCod) - Not_PutHiddenParamNotCod (*((long *) NotCod)); - } - -/*****************************************************************************/ -/*************** Put parameter with the code of a notice *********************/ -/*****************************************************************************/ - -void Not_PutHiddenParamNotCod (long NotCod) - { - Par_PutHiddenParamLong (NULL,"NotCod",NotCod); - } - -/*****************************************************************************/ -/*************** Get parameter with the code of a notice *********************/ -/*****************************************************************************/ - -static long Not_GetParamNotCod (void) - { - /***** Get notice code *****/ - return Par_GetParToLong ("NotCod"); + Par_PutParCod (Par_NotCod,*((long *) NotCod)); } /*****************************************************************************/ diff --git a/swad_notice.h b/swad_notice.h index 8138d80b..e24ce167 100644 --- a/swad_notice.h +++ b/swad_notice.h @@ -71,8 +71,6 @@ void Not_GetSummaryAndContentNotice (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], unsigned Not_GetNumNotices (HieLvl_Level_t Scope,Not_Status_t Status,unsigned *NumNotif); unsigned Not_GetNumNoticesDeleted (HieLvl_Level_t Scope,unsigned *NumNotif); -void Not_PutHiddenParamNotCod (long NotCod); - //-------------------------------- Figures ------------------------------------ void Not_GetAndShowNoticesStats (void); diff --git a/swad_notification.c b/swad_notification.c index b13213f8..2fe09218 100644 --- a/swad_notification.c +++ b/swad_notification.c @@ -714,7 +714,7 @@ static Act_Action_t Ntf_StartFormGoToAction (Ntf_NotifyEvent_t NotifyEvent, /* Begin form */ Action = ActSeeOneCfe; Frm_BeginFormAnchor (ActSeeOneCfe,Anchor); - Cfe_PutHiddenParamExaCod (Cod); + Par_PutParCod (Par_ExaCod,Cod); /* Free anchor string */ Frm_FreeAnchorStr (Anchor); @@ -758,9 +758,8 @@ static Act_Action_t Ntf_StartFormGoToAction (Ntf_NotifyEvent_t NotifyEvent, break; } Frm_BeginForm (Action); - if (GrpCod > 0) - Grp_PutParamGrpCod (&GrpCod); - Brw_PutHiddenParamFilCod (FileMetadata.FilCod); + Par_PutParCod (Par_GrpCod,GrpCod); + Par_PutParCod (Par_FilCod,FileMetadata.FilCod); } break; case Ntf_EVENT_TML_COMMENT: @@ -770,7 +769,7 @@ static Act_Action_t Ntf_StartFormGoToAction (Ntf_NotifyEvent_t NotifyEvent, // Cod is the code of the social publishing Action = ActSeeGblTL; Frm_BeginForm (Action); - TmlPub_PutHiddenParamPubCod (Cod); + Par_PutParCod (Par_PubCod,Cod); Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod); Ntf_PutHiddenParamNotifyEvent (NotifyEvent); break; @@ -804,7 +803,7 @@ static Act_Action_t Ntf_StartFormGoToAction (Ntf_NotifyEvent_t NotifyEvent, case Ntf_EVENT_NOTICE: Action = ActSeeOneNot; Frm_BeginForm (Action); - Not_PutHiddenParamNotCod (Cod); + Par_PutParCod (Par_NotCod,Cod); break; case Ntf_EVENT_MESSAGE: Action = ActExpRcvMsg; diff --git a/swad_parameter.c b/swad_parameter.c index b3a0fad7..2cb435fc 100644 --- a/swad_parameter.c +++ b/swad_parameter.c @@ -54,6 +54,36 @@ extern struct Globals Gbl; const char *Par_SEPARATOR_PARAM_MULTIPLE = "\x0a"; // Must be 1 <= character <= 31 +// 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_GamCod ] = "GamCod", + [Par_GrpCod ] = "GrpCod", + [Par_GrpTypCod ] = "GrpTypCod", + [Par_MchCod ] = "MchCod", + [Par_NotCod ] = "NotCod", + [Par_OthCtrCod ] = "OthCtrCod", + [Par_OthCtyCod ] = "OthCtyCod", + [Par_OthDegCod ] = "OthDegCod", + [Par_OthDegTypCod] = "OthDegTypCod", + [Par_OthInsCod ] = "OthInsCod", + [Par_PstCod ] = "PstCod", + [Par_PubCod ] = "PubCod", + [Par_QstCod ] = "QstCod", + [Par_SesCod ] = "SesCod", + [Par_SvyCod ] = "SvyCod", + [Par_ThrCod ] = "ThrCod", + }; + /*****************************************************************************/ /**************************** Private constants ******************************/ /*****************************************************************************/ @@ -968,24 +998,6 @@ long Par_GetAndCheckParCodeMin (Par_Code_t ParamCode,long MinCodAllowed) long Par_GetParCode (Par_Code_t ParamCode) { - static const char *Par_CodeStr[] = - { - [Par_AgdCod] = "AgdCod", - [Par_AnnCod] = "AnnCod", - [Par_AsgCod] = "AsgCod", - [Par_AttCod] = "AttCod", - [Par_BanCod] = "BanCod", - [Par_BldCod] = "BldCod", - [Par_ExaCod] = "ExaCod", - [Par_FilCod] = "FilCod", - [Par_GrpCod] = "GrpCod", - [Par_GrpTypCod] = "GrpTypCod", - [Par_OthCtrCod] = "OthCtrCod", - [Par_OthCtyCod] = "OthCtyCod", - [Par_OthDegCod] = "OthDegCod", - [Par_OthInsCod] = "OthInsCod", - }; - return Par_GetParToLong (Par_CodeStr[ParamCode]); } @@ -1150,6 +1162,20 @@ void Par_PutHiddenParamUnsignedDisabled (const char *Id,const char *ParamName,un ParamName,Value); } +/*****************************************************************************/ +/******************** Put the value of a code parameter **********************/ +/*****************************************************************************/ + +void Par_PutParCod (Par_Code_t ParamCode,long Cod) + { + extern const char *Par_CodeStr[]; + + // <0 => not specified => don't write parameter + if (Cod >= 0) // 0 => another country, institution, centre... + // >0 => a given country, institution, centre... + Par_PutHiddenParamLong (NULL,Par_CodeStr[ParamCode],Cod); + } + /*****************************************************************************/ /************************* Put a long hidden parameter ***********************/ /*****************************************************************************/ diff --git a/swad_parameter.h b/swad_parameter.h index 62bdbbbb..18263b20 100644 --- a/swad_parameter.h +++ b/swad_parameter.h @@ -71,14 +71,25 @@ typedef enum Par_AttCod, Par_BanCod, Par_BldCod, + Par_DptCod, Par_ExaCod, Par_FilCod, + Par_GamCod, Par_GrpCod, Par_GrpTypCod, + Par_MchCod, + Par_NotCod, Par_OthCtrCod, Par_OthCtyCod, Par_OthDegCod, + Par_OthDegTypCod, Par_OthInsCod, + Par_PstCod, + Par_PubCod, + Par_QstCod, + Par_SesCod, + Par_SvyCod, + Par_ThrCod, } Par_Code_t; /*****************************************************************************/ @@ -118,6 +129,7 @@ void Par_ReplaceSeparatorMultipleByComma (char *Str); void Par_PutHiddenParamUnsigned (const char *Id,const char *ParamName,unsigned Value); void Par_PutHiddenParamUnsignedDisabled (const char *Id,const char *ParamName,unsigned Value); +void Par_PutParCod (Par_Code_t ParamCode,long Cod); void Par_PutHiddenParamLong (const char *Id,const char *ParamName,long Value); void Par_PutHiddenParamChar (const char *ParamName,char Value); void Par_PutHiddenParamString (const char *Id,const char *ParamName, diff --git a/swad_project.c b/swad_project.c index 0ff2a537..888f6d9c 100644 --- a/swad_project.c +++ b/swad_project.c @@ -3740,6 +3740,7 @@ static void Prj_PutFormProject (struct Prj_Projects *Projects, { extern const char *Hlp_ASSESSMENT_Projects_new_project; extern const char *Hlp_ASSESSMENT_Projects_edit_project; + extern const char *Par_CodeStr[]; extern const char *Txt_New_project; extern const char *Txt_Edit_project; extern const char *Txt_Data; @@ -3825,7 +3826,7 @@ static void Prj_PutFormProject (struct Prj_Projects *Projects, HTM_TR_Begin (NULL); /* Label */ - Frm_LabelColumn ("RT",Dpt_PARAM_DPT_COD_NAME,Txt_Department); + Frm_LabelColumn ("RT",Par_CodeStr[Par_DptCod],Txt_Department); /* Data */ HTM_TD_Begin ("class=\"LT\""); @@ -3834,7 +3835,7 @@ static void Prj_PutFormProject (struct Prj_Projects *Projects, Err_NotEnoughMemoryExit (); Dpt_WriteSelectorDepartment (Gbl.Hierarchy.Ins.InsCod, // Departments in current institution Projects->Prj.DptCod, // Selected department - Dpt_PARAM_DPT_COD_NAME, // Parameter name + Par_CodeStr[Par_DptCod], // Parameter name SelectClass, // Selector class 0, // First option Txt_Another_department, // Text when no department selected @@ -4031,6 +4032,7 @@ void Prj_FreeMemProject (struct Prj_Project *Prj) void Prj_ReceiveFormProject (void) { + extern const char *Par_CodeStr[]; extern const char *Txt_Created_new_project_X; extern const char *Txt_The_project_has_been_modified; struct Prj_Projects Projects; @@ -4069,7 +4071,7 @@ void Prj_ReceiveFormProject (void) Par_GetParToText ("Title",Projects.Prj.Title,Prj_MAX_BYTES_TITLE); /* Get department */ - Projects.Prj.DptCod = Par_GetParToLong (Dpt_PARAM_DPT_COD_NAME); + Projects.Prj.DptCod = Par_GetParToLong (Par_CodeStr[Par_DptCod]); /* Get whether the project is assigned */ Projects.Prj.Assigned = (Par_GetParToBool ("Assigned")) ? Prj_ASSIGNED : diff --git a/swad_question.c b/swad_question.c index 93da3726..b01689c8 100644 --- a/swad_question.c +++ b/swad_question.c @@ -1817,11 +1817,11 @@ void Qst_ShowFormEditOneQst (void) Qst_QstConstructor (&Question); /***** Get question data *****/ - Question.QstCod = Qst_GetParamQstCod (); - if (Question.QstCod > 0) // Question already exists in the database - PutFormToEditQuestion = Qst_GetQstDataFromDB (&Question); - else // New question + Question.QstCod = Par_GetParCode (Par_QstCod); + if (Question.QstCod <= 0) // New question PutFormToEditQuestion = true; + else + PutFormToEditQuestion = Qst_GetQstDataFromDB (&Question); /***** Put form to edit question *****/ if (PutFormToEditQuestion) @@ -2724,7 +2724,7 @@ void Qst_GetQstFromForm (struct Qst_Question *Question) unsigned NumCorrectAns; /***** Get question code *****/ - Question->QstCod = Qst_GetParamQstCod (); + Question->QstCod = Par_GetParCode (Par_QstCod); /***** Get answer type *****/ Question->Answer.Type = (Qst_AnswerType_t) @@ -3330,9 +3330,7 @@ void Qst_RequestRemoveOneQst (void) /***** Get main parameters from form *****/ /* Get the question code */ - Questions.Question.QstCod = Qst_GetParamQstCod (); - if (Questions.Question.QstCod <= 0) - Err_WrongQuestionExit (); + Questions.Question.QstCod = Par_GetAndCheckParCode (Par_QstCod); /* Get a parameter that indicates whether it's necessary to continue listing the rest of questions */ @@ -3391,9 +3389,7 @@ void Qst_RemoveOneQst (void) bool EditingOnlyThisQst; /***** Get the question code *****/ - QstCod = Qst_GetParamQstCod (); - if (QstCod <= 0) - Err_WrongQuestionExit (); + QstCod = Par_GetAndCheckParCode (Par_QstCod); /***** Get a parameter that indicates whether it's necessary to continue listing the rest of questions ******/ @@ -3446,9 +3442,7 @@ void Qst_ChangeShuffleQst (void) Qst_Constructor (&Questions); /***** Get the question code *****/ - Questions.Question.QstCod = Qst_GetParamQstCod (); - if (Questions.Question.QstCod <= 0) - Err_WrongQuestionExit (); + Questions.Question.QstCod = Par_GetAndCheckParCode (Par_QstCod); /***** Get a parameter that indicates whether it's necessary to continue listing the rest of questions ******/ EditingOnlyThisQst = Par_GetParToBool ("OnlyThisQst"); @@ -3474,25 +3468,17 @@ void Qst_ChangeShuffleQst (void) Qst_Destructor (&Questions); } -/*****************************************************************************/ -/************ Get the parameter with the code of a test question *************/ -/*****************************************************************************/ - -long Qst_GetParamQstCod (void) - { - /***** Get code of test question *****/ - return Par_GetParToLong ("QstCod"); - } - /*****************************************************************************/ /************ Put parameter with question code to edit, remove... ************/ /*****************************************************************************/ void Qst_PutParamQstCod (void *QstCod) // Should be a pointer to long { + extern const char *Par_CodeStr[]; + if (QstCod) if (*((long *) QstCod) > 0) // If question exists - Par_PutHiddenParamLong (NULL,"QstCod",*((long *) QstCod)); + Par_PutHiddenParamLong (NULL,Par_CodeStr[Par_QstCod],*((long *) QstCod)); } /*****************************************************************************/ diff --git a/swad_question.h b/swad_question.h index eed0f805..d0f46813 100644 --- a/swad_question.h +++ b/swad_question.h @@ -261,7 +261,6 @@ void Qst_RemoveOneQstFromDB (long CrsCod,long QstCod); void Qst_ChangeShuffleQst (void); -long Qst_GetParamQstCod (void); void Qst_PutParamQstCod (void *QstCod); void Qst_InsertOrUpdateQstTagsAnsIntoDB (struct Qst_Question *Question); diff --git a/swad_record.c b/swad_record.c index b1c78388..a5e0ff79 100644 --- a/swad_record.c +++ b/swad_record.c @@ -3153,6 +3153,7 @@ static void Rec_ShowFirstName (struct Usr_Data *UsrDat,bool PutForm) static void Rec_ShowCountry (struct Usr_Data *UsrDat,bool PutForm) { + extern const char *Par_CodeStr[]; extern const char *Txt_Country; extern const char *Txt_Another_country; char *Label; @@ -3169,7 +3170,7 @@ static void Rec_ShowCountry (struct Usr_Data *UsrDat,bool PutForm) { if (asprintf (&Label,"%s*",Txt_Country) < 0) Err_NotEnoughMemoryExit (); - Frm_LabelColumn ("REC_C1_BOT RM","OthCtyCod",Label); + Frm_LabelColumn ("REC_C1_BOT RM",Par_CodeStr[Par_OthCtyCod],Label); free (Label); } else @@ -3206,6 +3207,7 @@ static void Rec_ShowCountry (struct Usr_Data *UsrDat,bool PutForm) static void Rec_ShowDateOfBirth (struct Usr_Data *UsrDat,bool ShowData,bool PutForm) { + extern const char *Par_CodeStr[]; extern const char *Txt_Date_of_birth; unsigned CurrentYear = Dat_GetCurrentYear (); @@ -3644,7 +3646,7 @@ static void Rec_GetUsrExtraDataFromRecordForm (struct Usr_Data *UsrDat) (unsigned long) Usr_SEX_UNKNOWN); /***** Get country code *****/ - UsrDat->CtyCod = Par_GetParToLong ("OthCtyCod"); + UsrDat->CtyCod = Par_GetAndCheckParCodeMin (Par_OthCtyCod,0); // 0 (another country) is allowed here Dat_GetDateFromForm ("BirthDay","BirthMonth","BirthYear", &(UsrDat->Birthday.Day ), @@ -3754,6 +3756,7 @@ void Rec_ShowMySharedRecordAndMore (void) static void Rec_ShowFormMyInsCtrDpt (bool IAmATeacher) { extern const char *Hlp_PROFILE_Institution; + extern const char *Par_CodeStr[]; extern const char *Txt_Institution_center_and_department; extern const char *Txt_Institution; extern const char *Txt_Country; @@ -3824,7 +3827,7 @@ static void Rec_ShowFormMyInsCtrDpt (bool IAmATeacher) /* Label */ if (asprintf (&Label,"%s*",Txt_Institution) < 0) Err_NotEnoughMemoryExit (); - Frm_LabelColumn ("REC_C1_BOT RM","OthInsCod",Label); + Frm_LabelColumn ("REC_C1_BOT RM",Par_CodeStr[Par_OthInsCod],Label); free (Label); /* Data */ @@ -3867,7 +3870,7 @@ static void Rec_ShowFormMyInsCtrDpt (bool IAmATeacher) /* Label */ if (asprintf (&Label,"%s*",Txt_Center) < 0) Err_NotEnoughMemoryExit (); - Frm_LabelColumn ("REC_C1_BOT RM","OthCtrCod",Label); + Frm_LabelColumn ("REC_C1_BOT RM",Par_CodeStr[Par_OthCtrCod],Label); free (Label); /* Data */ @@ -3908,7 +3911,7 @@ static void Rec_ShowFormMyInsCtrDpt (bool IAmATeacher) /* Label */ if (asprintf (&Label,"%s*",Txt_Department) < 0) Err_NotEnoughMemoryExit (); - Frm_LabelColumn ("REC_C1_BOT RM",Dpt_PARAM_DPT_COD_NAME,Label); + Frm_LabelColumn ("REC_C1_BOT RM",Par_CodeStr[Par_DptCod],Label); free (Label); /* Data */ @@ -3919,7 +3922,7 @@ static void Rec_ShowFormMyInsCtrDpt (bool IAmATeacher) Err_NotEnoughMemoryExit (); Dpt_WriteSelectorDepartment (Gbl.Usrs.Me.UsrDat.InsCod, // Departments in my institution Gbl.Usrs.Me.UsrDat.Tch.DptCod, // Selected department - Dpt_PARAM_DPT_COD_NAME, // Parameter name + Par_CodeStr[Par_DptCod], // Parameter name SelectClass, // Selector class -1L, // First option "", // Text when no department selected @@ -4092,7 +4095,7 @@ void Rec_UpdateMyDepartment (void) /***** Get my department *****/ /* Get department code */ - Dpt.DptCod = Dpt_GetAndCheckParamDptCod (0); // 0 (another department) is allowed here + Dpt.DptCod = Par_GetAndCheckParCodeMin (Par_DptCod,0); // 0 (another department) is allowed here /* Get institution of department */ if (Dpt.DptCod > 0) diff --git a/swad_survey.c b/swad_survey.c index 448f54f2..e0a23b6e 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -122,8 +122,6 @@ static void Svy_ShowFormEditOneQst (struct Svy_Surveys *Surveys, struct Svy_Question *SvyQst, char Stem[Cns_MAX_BYTES_TEXT + 1]); static void Svy_InitQst (struct Svy_Question *SvyQst); -static void Svy_PutParamQstCod (long QstCod); -static long Svy_GetParamQstCod (void); static bool Svy_AllocateTextChoiceAnswer (struct Svy_Question *SvyQst,unsigned NumAns); static void Svy_FreeTextChoiceAnswers (struct Svy_Question *SvyQst,unsigned NumAnswers); static void Svy_FreeTextChoiceAnswer (struct Svy_Question *SvyQst,unsigned NumAns); @@ -409,8 +407,7 @@ void Svy_SeeOneSurvey (void) Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS); /***** Get survey code *****/ - if ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0) - Err_WrongSurveyExit (); + Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod); /***** Show survey *****/ Svy_ShowOneSurvey (&Surveys,true); @@ -534,7 +531,7 @@ static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys, HTM_ARTICLE_Begin (Anchor); Frm_BeginForm (ActSeeSvy); - Svy_PutParamSvyCod (Surveys->Svy.SvyCod); + Par_PutParCod (Par_SvyCod,Surveys->Svy.SvyCod); Svy_PutHiddenParamSvyOrder (Surveys->SelectedOrder); WhichGroups = Grp_GetParamWhichGroups (); Grp_PutParamWhichGroups (&WhichGroups); @@ -578,7 +575,7 @@ static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys, HTM_DIV_Begin ("class=\"BUTTONS_AFTER_ALERT\""); Frm_BeginForm (ActSeeSvy); - Svy_PutParamSvyCod (Surveys->Svy.SvyCod); + Par_PutParCod (Par_SvyCod,Surveys->Svy.SvyCod); Svy_PutHiddenParamSvyOrder (Surveys->SelectedOrder); WhichGroups = Grp_GetParamWhichGroups (); Grp_PutParamWhichGroups (&WhichGroups); @@ -594,7 +591,7 @@ static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys, HTM_DIV_Begin ("class=\"BUTTONS_AFTER_ALERT\""); Frm_BeginForm (ActSeeSvy); - Svy_PutParamSvyCod (Surveys->Svy.SvyCod); + Par_PutParCod (Par_SvyCod,Surveys->Svy.SvyCod); Svy_PutHiddenParamSvyOrder (Surveys->SelectedOrder); WhichGroups = Grp_GetParamWhichGroups (); Grp_PutParamWhichGroups (&WhichGroups); @@ -937,8 +934,7 @@ static void Svy_PutParams (void *Surveys) if (Surveys) { - if (((struct Svy_Surveys *) Surveys)->Svy.SvyCod > 0) - Svy_PutParamSvyCod (((struct Svy_Surveys *) Surveys)->Svy.SvyCod); + Par_PutParCod (Par_SvyCod,((struct Svy_Surveys *) Surveys)->Svy.SvyCod); Par_PutHiddenParamOrder ((unsigned) ((struct Svy_Surveys *) Surveys)->SelectedOrder); WhichGroups = Grp_GetParamWhichGroups (); Grp_PutParamWhichGroups (&WhichGroups); @@ -1408,26 +1404,6 @@ void Svy_GetNotifSurvey (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], DB_FreeMySQLResult (&mysql_res); } -/*****************************************************************************/ -/******************* Write parameter with code of survey *********************/ -/*****************************************************************************/ - -void Svy_PutParamSvyCod (long SvyCod) - { - if (SvyCod > 0) - Par_PutHiddenParamLong (NULL,"SvyCod",SvyCod); - } - -/*****************************************************************************/ -/******************** Get parameter with code of survey **********************/ -/*****************************************************************************/ - -long Svy_GetParamSvyCod (void) - { - /***** Get code of survey *****/ - return Par_GetParToLong ("SvyCod"); - } - /*****************************************************************************/ /*************** Ask for confirmation of removing of a survey ****************/ /*****************************************************************************/ @@ -1447,8 +1423,7 @@ void Svy_AskRemSurvey (void) Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS); /***** Get survey code *****/ - if ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0) - Err_WrongSurveyExit (); + Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod); /***** Get data of the survey from database *****/ Svy_GetDataOfSurveyByCod (&Surveys.Svy); @@ -1484,8 +1459,7 @@ void Svy_RemoveSurvey (void) Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS); /***** Get survey code *****/ - if ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0) - Err_WrongSurveyExit (); + Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod); /***** Get data of the survey from database *****/ Svy_GetDataOfSurveyByCod (&Surveys.Svy); @@ -1537,8 +1511,7 @@ void Svy_AskResetSurvey (void) Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS); /***** Get survey code *****/ - if ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0) - Err_WrongSurveyExit (); + Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod); /***** Get data of the survey from database *****/ Svy_GetDataOfSurveyByCod (&Surveys.Svy); @@ -1574,8 +1547,7 @@ void Svy_ResetSurvey (void) Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS); /***** Get survey code *****/ - if ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0) - Err_WrongSurveyExit (); + Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod); /***** Get data of the survey from database *****/ Svy_GetDataOfSurveyByCod (&Surveys.Svy); @@ -1613,8 +1585,7 @@ void Svy_HideSurvey (void) Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS); /***** Get survey code *****/ - if ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0) - Err_WrongSurveyExit (); + Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod); /***** Get data of the survey from database *****/ Svy_GetDataOfSurveyByCod (&Surveys.Svy); @@ -1645,8 +1616,7 @@ void Svy_UnhideSurvey (void) Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS); /***** Get survey code *****/ - if ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0) - Err_WrongSurveyExit (); + Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod); /***** Get data of the survey from database *****/ Svy_GetDataOfSurveyByCod (&Surveys.Svy); @@ -1694,7 +1664,7 @@ void Svy_RequestCreatOrEditSvy (void) Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS); /***** Get the code of the survey *****/ - ItsANewSurvey = ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0); + ItsANewSurvey = ((Surveys.Svy.SvyCod = Par_GetParCode (Par_SvyCod)) <= 0); /***** Get from the database the data of the survey *****/ if (ItsANewSurvey) @@ -1956,8 +1926,10 @@ static void Svy_ShowLstGrpsToEditSurvey (long SvyCod) HTM_LABEL_Begin (NULL); HTM_INPUT_CHECKBOX ("WholeCrs",HTM_DONT_SUBMIT_ON_CHANGE, "id=\"WholeCrs\" value=\"Y\"%s onclick=\"uncheckChildren(this,'GrpCods')\"", - Grp_DB_CheckIfAssociatedToGrps ("svy_groups","SvyCod",SvyCod) ? "" : - " checked=\"checked\""); + Grp_DB_CheckIfAssociatedToGrps ("svy_groups", + Par_SvyCod, + SvyCod) ? "" : + " checked=\"checked\""); HTM_TxtF ("%s %s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName); HTM_LABEL_End (); HTM_TD_End (); @@ -2006,7 +1978,7 @@ void Svy_ReceiveFormSurvey (void) Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS); /***** Get the code of the survey *****/ - ItsANewSurvey = ((NewSvy.SvyCod = Svy_GetParamSvyCod ()) <= 0); + ItsANewSurvey = ((NewSvy.SvyCod = Par_GetParCode (Par_SvyCod)) <= 0); if (ItsANewSurvey) NewSvy.Scope = HieLvl_UNK; @@ -2292,11 +2264,10 @@ void Svy_RequestEditQuestion (void) Stem[0] = '\0'; /***** Get survey code *****/ - if ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0) - Err_WrongSurveyExit (); + Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod); /* Get the question code */ - SvyQst.QstCod = Svy_GetParamQstCod (); + SvyQst.QstCod = Par_GetParCode (Par_QstCod); /***** Get other parameters *****/ Surveys.SelectedOrder = Svy_GetParamSvyOrder (); @@ -2390,9 +2361,8 @@ static void Svy_ShowFormEditOneQst (struct Svy_Surveys *Surveys, /***** Begin form *****/ Frm_BeginForm (ActRcvSvyQst); - Svy_PutParamSvyCod (Surveys->Svy.SvyCod); - if (SvyQst->QstCod > 0) // If the question already has assigned a code - Svy_PutParamQstCod (SvyQst->QstCod); + Par_PutParCod (Par_SvyCod,Surveys->Svy.SvyCod); + Par_PutParCod (Par_QstCod,SvyQst->QstCod); /***** Begin table *****/ HTM_TABLE_BeginWidePadding (2); @@ -2514,24 +2484,6 @@ static void Svy_InitQst (struct Svy_Question *SvyQst) SvyQst->AnsChoice[NumAns].Text = NULL; } -/*****************************************************************************/ -/****************** Write parameter with code of question ********************/ -/*****************************************************************************/ - -static void Svy_PutParamQstCod (long QstCod) - { - Par_PutHiddenParamLong (NULL,"QstCod",QstCod); - } - -/*****************************************************************************/ -/******************* Get parameter with code of question *********************/ -/*****************************************************************************/ - -static long Svy_GetParamQstCod (void) - { - return Par_GetParToLong ("QstCod"); - } - /*****************************************************************************/ /******************* Allocate memory for a choice answer *********************/ /*****************************************************************************/ @@ -2604,11 +2556,10 @@ void Svy_ReceiveQst (void) /***** Get parameters from form *****/ /* Get survey code */ - if ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0) - Err_WrongSurveyExit (); + Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod); /* Get question code */ - SvyQst.QstCod = Svy_GetParamQstCod (); + SvyQst.QstCod = Par_GetParCode (Par_QstCod); /* Get answer type */ SvyQst.AnswerType = (Svy_AnswerType_t) @@ -2791,7 +2742,7 @@ static void Svy_ListSvyQuestions (struct Svy_Surveys *Surveys) { /***** Begin form to send answers to survey *****/ Frm_BeginForm (ActAnsSvy); - Svy_PutParamSvyCod (Surveys->Svy.SvyCod); + Par_PutParCod (Par_SvyCod,Surveys->Svy.SvyCod); } /***** Write the heading *****/ @@ -2919,8 +2870,8 @@ static void Svy_PutParamsToEditQuestion (void *Surveys) { if (Surveys) { - Svy_PutParamSvyCod (((struct Svy_Surveys *) Surveys)->Svy.SvyCod); - Svy_PutParamQstCod (((struct Svy_Surveys *) Surveys)->QstCod); + Par_PutParCod (Par_SvyCod,((struct Svy_Surveys *) Surveys)->Svy.SvyCod); + Par_PutParCod (Par_QstCod,((struct Svy_Surveys *) Surveys)->QstCod); } } @@ -3144,8 +3095,8 @@ static void Svy_PutParamsRemoveOneQst (void *Surveys) { if (Surveys) { - Svy_PutParamSvyCod (((struct Svy_Surveys *) Surveys)->Svy.SvyCod); - Svy_PutParamQstCod (((struct Svy_Surveys *) Surveys)->QstCod); + Par_PutParCod (Par_SvyCod,((struct Svy_Surveys *) Surveys)->Svy.SvyCod); + Par_PutParCod (Par_QstCod,((struct Svy_Surveys *) Surveys)->QstCod); } } @@ -3168,12 +3119,10 @@ void Svy_RequestRemoveQst (void) /***** Get parameters from form *****/ /* Get survey code */ - if ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0) - Err_WrongSurveyExit (); + Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod); /* Get question code */ - if ((SvyQst.QstCod = Svy_GetParamQstCod ()) < 0) - Err_WrongQuestionExit (); + SvyQst.QstCod = Par_GetAndCheckParCode (Par_QstCod); /* Get question index */ SvyQst.QstInd = Svy_DB_GetQstIndFromQstCod (SvyQst.QstCod); @@ -3208,12 +3157,10 @@ void Svy_RemoveQst (void) /***** Get parameters from form *****/ /* Get survey code */ - if ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0) - Err_WrongSurveyExit (); + Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod); /* Get question code */ - if ((SvyQst.QstCod = Svy_GetParamQstCod ()) <= 0) - Err_WrongQuestionExit (); + SvyQst.QstCod = Par_GetAndCheckParCode (Par_QstCod); /* Get question index */ SvyQst.QstInd = Svy_DB_GetQstIndFromQstCod (SvyQst.QstCod); @@ -3249,8 +3196,7 @@ void Svy_ReceiveSurveyAnswers (void) Svy_ResetSurveys (&Surveys); /***** Get survey code *****/ - if ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0) - Err_WrongSurveyExit (); + Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod); /***** Get data of the survey from database *****/ Svy_GetDataOfSurveyByCod (&Surveys.Svy); diff --git a/swad_survey.h b/swad_survey.h index 3e7bd57f..8c3efbff 100644 --- a/swad_survey.h +++ b/swad_survey.h @@ -100,8 +100,6 @@ void Svy_FreeListSurveys (struct Svy_Surveys *Surveys); void Svy_GetNotifSurvey (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long SvyCod,bool GetContent); -void Svy_PutParamSvyCod (long SvyCod); -long Svy_GetParamSvyCod (void); void Svy_AskRemSurvey (void); void Svy_RemoveSurvey (void); void Svy_AskResetSurvey (void); diff --git a/swad_survey_resource.c b/swad_survey_resource.c index 87dfb287..b4feda9c 100644 --- a/swad_survey_resource.c +++ b/swad_survey_resource.c @@ -29,6 +29,7 @@ #include "swad_alert.h" #include "swad_error.h" #include "swad_form.h" +#include "swad_parameter.h" #include "swad_program_database.h" #include "swad_survey.h" #include "swad_survey_database.h" @@ -48,7 +49,7 @@ void SvyRsc_GetLinkToSurvey (void) Svy_ResetSurveys (&Surveys); /***** Get survey code *****/ - Surveys.Svy.SvyCod = Svy_GetParamSvyCod (); + Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod); /***** Get survey title *****/ SvyRsc_GetTitleFromSvyCod (Surveys.Svy.SvyCod,Title,sizeof (Title) - 1); @@ -84,7 +85,7 @@ void SvyRsc_WriteSurveyInCrsProgram (long SvyCod,bool PutFormToGo, NextAction = (SvyCod > 0) ? ActSeeSvy : // Survey specified ActSeeAllSvy; // All surveys Frm_BeginForm (NextAction); - Svy_PutParamSvyCod (SvyCod); + Par_PutParCod (Par_SvyCod,SvyCod); HTM_BUTTON_Submit_Begin (Txt_Actions[NextAction], "class=\"LM BT_LINK PRG_LNK_%s\"", The_GetSuffix ()); diff --git a/swad_timeline.c b/swad_timeline.c index ce6c26ff..b35dd619 100644 --- a/swad_timeline.c +++ b/swad_timeline.c @@ -134,6 +134,7 @@ mysql> SHOW TABLES LIKE 'tml_%'; #include "swad_global.h" #include "swad_message.h" #include "swad_notification.h" +#include "swad_parameter.h" #include "swad_photo.h" #include "swad_profile.h" #include "swad_timeline.h" @@ -225,7 +226,7 @@ void Tml_ShowNoteAndTimelineGbl (struct Tml_Timeline *Timeline) // This parameter is optional. It can be provided by a notification. // If > 0 ==> the associated note will be shown highlighted // get its code from database and show it above the timeline - if ((PubCod = TmlPub_GetParamPubCod ()) > 0) + if ((PubCod = Par_GetParCode (Par_PubCod)) > 0) { if ((Not.NotCod = Tml_DB_GetNotCodFromPubCod (PubCod)) > 0) TmlNot_ShowHighlightedNote (Timeline,&Not); diff --git a/swad_timeline_comment.c b/swad_timeline_comment.c index e56d98a5..69bd25b3 100644 --- a/swad_timeline_comment.c +++ b/swad_timeline_comment.c @@ -223,7 +223,7 @@ static void TmlCom_PutFormToWriteNewComm (const struct Tml_Timeline *Timeline, /***** Begin form to write the post *****/ TmlFrm_BeginForm (Timeline,TmlFrm_RECEIVE_COMM); - TmlNot_PutHiddenParamNotCod (NotCod); + Par_PutParCod (Par_NotCod,NotCod); /***** Textarea and button *****/ if (asprintf (&ClassTextArea,"Tml_COM_TEXTAREA Tml_COM_WIDTH INPUT_%s", @@ -372,7 +372,7 @@ void TmlCom_ShowHiddenCommsGbl (void) /***** Get parameters *****/ /* Get note code, identifier and number of comments to get */ - NotCod = TmlNot_GetParamNotCod (); + NotCod = Par_GetParCode (Par_NotCod); Par_GetParToText ("IdComments",IdComms,Frm_MAX_BYTES_ID); NumInitialCommsToGet = (unsigned) Par_GetParToLong ("NumHidCom"); @@ -700,7 +700,7 @@ static void TmlCom_PutFormToRemoveComm (const struct Tml_Timeline *Timeline, /***** Form to remove publication *****/ /* Begin form */ TmlFrm_BeginForm (Timeline,TmlFrm_REQ_REM_COMM); - TmlPub_PutHiddenParamPubCod (PubCod); + Par_PutParCod (Par_PubCod,PubCod); /* Icon to remove */ Ico_PutIconLink ("trash.svg",Ico_RED, @@ -764,7 +764,7 @@ static long TmlCom_ReceiveComm (void) struct TmlPub_Publication Pub; /***** Get data of note *****/ - Not.NotCod = TmlNot_GetParamNotCod (); + Not.NotCod = Par_GetAndCheckParCode (Par_NotCod); TmlNot_GetDataOfNoteByCod (&Not); /***** Trivial check: note code *****/ @@ -870,7 +870,7 @@ static void TmlCom_RequestRemovalComm (struct Tml_Timeline *Timeline) Med_MediaConstructor (&Com.Content.Media); /***** Get data of comment *****/ - Com.PubCod = TmlPub_GetParamPubCod (); + Com.PubCod = Par_GetAndCheckParCode (Par_PubCod); TmlCom_GetDataOfCommByCod (&Com); /***** Do some checks *****/ @@ -922,7 +922,7 @@ static void TmlCom_PutParamsRemoveComm (void *Timeline) Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod); else // Global timeline Usr_PutHiddenParamWho (((struct Tml_Timeline *) Timeline)->Who); - TmlPub_PutHiddenParamPubCod (((struct Tml_Timeline *) Timeline)->PubCod); + Par_PutParCod (Par_PubCod,((struct Tml_Timeline *) Timeline)->PubCod); } } @@ -980,7 +980,7 @@ static void TmlCom_RemoveComm (void) Med_MediaConstructor (&Com.Content.Media); /***** Get data of comment *****/ - Com.PubCod = TmlPub_GetParamPubCod (); + Com.PubCod = Par_GetAndCheckParCode (Par_PubCod); TmlCom_GetDataOfCommByCod (&Com); /***** Trivial check 1: publication code *****/ diff --git a/swad_timeline_database.c b/swad_timeline_database.c index 8dde3837..96483b0b 100644 --- a/swad_timeline_database.c +++ b/swad_timeline_database.c @@ -30,6 +30,7 @@ #include "swad_follow.h" #include "swad_follow_database.h" #include "swad_global.h" +#include "swad_parameter.h" #include "swad_timeline.h" #include "swad_timeline_database.h" #include "swad_timeline_publication.h" @@ -44,11 +45,11 @@ static const char *Tml_DB_TableFav[TmlUsr_NUM_FAV_SHA] = [TmlUsr_FAV_UNF_COMM] = "tml_comments_fav", [TmlUsr_SHA_UNS_NOTE] = NULL, // Not used }; -static const char *Tml_DB_FieldFav[TmlUsr_NUM_FAV_SHA] = +static Par_Code_t Tml_DB_FieldFav[TmlUsr_NUM_FAV_SHA] = { - [TmlUsr_FAV_UNF_NOTE] = "NotCod", - [TmlUsr_FAV_UNF_COMM] = "PubCod", - [TmlUsr_SHA_UNS_NOTE] = NULL, // Not used + [TmlUsr_FAV_UNF_NOTE] = Par_NotCod, + [TmlUsr_FAV_UNF_COMM] = Par_PubCod, + [TmlUsr_SHA_UNS_NOTE] = Par_NotCod, // Not used }; static TmlPub_Type_t Tml_DB_PubTypeFav[TmlUsr_NUM_FAV_SHA] = { @@ -67,7 +68,7 @@ extern struct Globals Gbl; /***************************** Private prototypes ****************************/ /*****************************************************************************/ -static long Tml_DB_GetMedCod (const char *Table,const char *Field,long Cod); +static long Tml_DB_GetMedCod (const char *Table,Par_Code_t ParCod,long Cod); /*****************************************************************************/ /********************* Get which users to show in timeline *******************/ @@ -572,7 +573,7 @@ unsigned Tml_DB_GetPostByCod (long PstCod,MYSQL_RES **mysql_res) long Tml_DB_GetMedCodFromPost (long PstCod) { - return Tml_DB_GetMedCod ("tml_posts","PstCod",PstCod); + return Tml_DB_GetMedCod ("tml_posts",Par_PstCod,PstCod); } /*****************************************************************************/ @@ -756,7 +757,7 @@ void Tml_DB_InsertCommContent (long PubCod, long Tml_DB_GetMedCodFromComm (long PubCod) { - return Tml_DB_GetMedCod ("tml_comments","PubCod",PubCod); + return Tml_DB_GetMedCod ("tml_comments",Par_PubCod,PubCod); } /*****************************************************************************/ @@ -838,14 +839,16 @@ void Tml_DB_RemoveAllCommsMadeBy (long UsrCod) /*************** Get code of media associated to post/comment ****************/ /*****************************************************************************/ -static long Tml_DB_GetMedCod (const char *Table,const char *Field,long Cod) +static long Tml_DB_GetMedCod (const char *Table,Par_Code_t ParCod,long Cod) { + extern const char *Par_CodeStr[]; // Database field name must be equal to code parameter name + return DB_QuerySELECTCode ("can not get media code", "SELECT MedCod" // row[0] " FROM %s" " WHERE %s=%ld", Table, - Field,Cod); + Par_CodeStr[ParCod],Cod); } /*****************************************************************************/ @@ -1131,6 +1134,8 @@ void Tml_DB_RemoveAllPubsPublishedBy (long UsrCod) bool Tml_DB_CheckIfFavedByUsr (TmlUsr_FavSha_t FavSha,long Cod,long UsrCod) { + extern const char *Par_CodeStr[]; // Database field name must be equal to code parameter name + return DB_QueryEXISTS ("can not check if a user has favourited", "SELECT EXISTS" @@ -1139,7 +1144,7 @@ bool Tml_DB_CheckIfFavedByUsr (TmlUsr_FavSha_t FavSha,long Cod,long UsrCod) " WHERE %s=%ld" " AND UsrCod=%ld)", Tml_DB_TableFav[FavSha], - Tml_DB_FieldFav[FavSha],Cod,UsrCod); + Par_CodeStr[Tml_DB_FieldFav[FavSha]],Cod,UsrCod); } /*****************************************************************************/ @@ -1148,6 +1153,8 @@ bool Tml_DB_CheckIfFavedByUsr (TmlUsr_FavSha_t FavSha,long Cod,long UsrCod) unsigned Tml_DB_GetNumFavers (TmlUsr_FavSha_t FavSha,long Cod,long UsrCod) { + extern const char *Par_CodeStr[]; // Database field name must be equal to code parameter name + return (unsigned) DB_QueryCOUNT ("can not get number of times has been favourited", "SELECT COUNT(*)" @@ -1155,7 +1162,7 @@ unsigned Tml_DB_GetNumFavers (TmlUsr_FavSha_t FavSha,long Cod,long UsrCod) " WHERE %s=%ld" " AND UsrCod<>%ld", // Extra check Tml_DB_TableFav[FavSha], - Tml_DB_FieldFav[FavSha],Cod, + Par_CodeStr[Tml_DB_FieldFav[FavSha]],Cod, UsrCod); // The author } @@ -1167,6 +1174,8 @@ unsigned Tml_DB_GetFavers (TmlUsr_FavSha_t FavSha, long Cod,long UsrCod,unsigned MaxUsrs, MYSQL_RES **mysql_res) { + extern const char *Par_CodeStr[]; // Database field name must be equal to code parameter name + return (unsigned) DB_QuerySELECT (mysql_res,"can not get favers", "SELECT UsrCod" // row[0] @@ -1176,7 +1185,7 @@ unsigned Tml_DB_GetFavers (TmlUsr_FavSha_t FavSha, " ORDER BY FavCod" " LIMIT %u", Tml_DB_TableFav[FavSha], - Tml_DB_FieldFav[FavSha],Cod, + Par_CodeStr[Tml_DB_FieldFav[FavSha]],Cod, UsrCod, MaxUsrs); } @@ -1187,13 +1196,15 @@ unsigned Tml_DB_GetFavers (TmlUsr_FavSha_t FavSha, void Tml_DB_MarkAsFav (TmlUsr_FavSha_t FavSha,long Cod) { + extern const char *Par_CodeStr[]; // Database field name must be equal to code parameter name + DB_QueryINSERT ("can not favourite comment", "INSERT IGNORE INTO %s" " (%s,UsrCod,TimeFav)" " VALUES" " (%ld,%ld,NOW())", Tml_DB_TableFav[FavSha], - Tml_DB_FieldFav[FavSha], + Par_CodeStr[Tml_DB_FieldFav[FavSha]], Cod,Gbl.Usrs.Me.UsrDat.UsrCod); } @@ -1203,12 +1214,14 @@ void Tml_DB_MarkAsFav (TmlUsr_FavSha_t FavSha,long Cod) void Tml_DB_UnmarkAsFav (TmlUsr_FavSha_t FavSha,long Cod) { + extern const char *Par_CodeStr[]; // Database field name must be equal to code parameter name + DB_QueryDELETE ("can not unfavourite", "DELETE FROM %s" " WHERE %s=%ld" " AND UsrCod=%ld", Tml_DB_TableFav[FavSha], - Tml_DB_FieldFav[FavSha],Cod, + Par_CodeStr[Tml_DB_FieldFav[FavSha]],Cod, Gbl.Usrs.Me.UsrDat.UsrCod); } @@ -1231,6 +1244,8 @@ void Tml_DB_RemoveAllFavsMadeByUsr (TmlUsr_FavSha_t FavSha,long UsrCod) void Tml_DB_RemoveAllFavsToPubsBy (TmlUsr_FavSha_t FavSha,long UsrCod) { + extern const char *Par_CodeStr[]; // Database field name must be equal to code parameter name + DB_QueryDELETE ("can not remove favs", "DELETE FROM %s" " USING tml_pubs," @@ -1242,9 +1257,9 @@ void Tml_DB_RemoveAllFavsToPubsBy (TmlUsr_FavSha_t FavSha,long UsrCod) Tml_DB_TableFav[FavSha], UsrCod, (unsigned) Tml_DB_PubTypeFav[FavSha], - Tml_DB_FieldFav[FavSha], + Par_CodeStr[Tml_DB_FieldFav[FavSha]], Tml_DB_TableFav[FavSha], - Tml_DB_FieldFav[FavSha]); + Par_CodeStr[Tml_DB_FieldFav[FavSha]]); } /*****************************************************************************/ diff --git a/swad_timeline_favourite.c b/swad_timeline_favourite.c index de83463e..bd1670d2 100644 --- a/swad_timeline_favourite.c +++ b/swad_timeline_favourite.c @@ -28,6 +28,7 @@ #include "swad_database.h" #include "swad_global.h" #include "swad_notification_database.h" +#include "swad_parameter.h" #include "swad_timeline.h" #include "swad_timeline_database.h" #include "swad_timeline_favourite.h" @@ -68,7 +69,7 @@ void TmlFav_ShowAllFaversNoteGbl (void) struct TmlNot_Note Not; /***** Get data of note *****/ - Not.NotCod = TmlNot_GetParamNotCod (); + Not.NotCod = Par_GetAndCheckParCode (Par_NotCod); TmlNot_GetDataOfNoteByCod (&Not); /***** Write HTML inside DIV with form to fav/unfav *****/ @@ -130,7 +131,7 @@ static void TmlFav_FavNote (struct TmlNot_Note *Not) long OriginalPubCod; /***** Get data of note *****/ - Not->NotCod = TmlNot_GetParamNotCod (); + Not->NotCod = Par_GetAndCheckParCode (Par_NotCod); TmlNot_GetDataOfNoteByCod (Not); /***** Do some checks *****/ @@ -160,7 +161,7 @@ static void TmlFav_UnfNote (struct TmlNot_Note *Not) long OriginalPubCod; /***** Get data of note *****/ - Not->NotCod = TmlNot_GetParamNotCod (); + Not->NotCod = Par_GetAndCheckParCode (Par_NotCod); TmlNot_GetDataOfNoteByCod (Not); /***** Do some checks *****/ @@ -203,7 +204,7 @@ void TmlFav_ShowAllFaversComGbl (void) /***** Get data of comment *****/ Med_MediaConstructor (&Com.Content.Media); - Com.PubCod = TmlPub_GetParamPubCod (); + Com.PubCod = Par_GetAndCheckParCode (Par_PubCod); TmlCom_GetDataOfCommByCod (&Com); Med_MediaDestructor (&Com.Content.Media); @@ -267,7 +268,7 @@ static void TmlFav_FavComm (struct TmlCom_Comment *Com) Med_MediaConstructor (&Com->Content.Media); /***** Get data of comment *****/ - Com->PubCod = TmlPub_GetParamPubCod (); + Com->PubCod = Par_GetAndCheckParCode (Par_PubCod); TmlCom_GetDataOfCommByCod (Com); /***** Do some checks *****/ @@ -306,7 +307,7 @@ static void TmlFav_UnfComm (struct TmlCom_Comment *Com) Med_MediaConstructor (&Com->Content.Media); /***** Get data of comment *****/ - Com->PubCod = TmlPub_GetParamPubCod (); + Com->PubCod = Par_GetAndCheckParCode (Par_PubCod); TmlCom_GetDataOfCommByCod (Com); /***** Do some checks *****/ diff --git a/swad_timeline_note.c b/swad_timeline_note.c index f27c0f84..f0fc69ac 100644 --- a/swad_timeline_note.c +++ b/swad_timeline_note.c @@ -625,28 +625,28 @@ static void TmlNot_PutFormGoToAction (const struct TmlNot_Note *Not, case TmlNot_INS_DOC_PUB_FILE: case TmlNot_INS_SHA_PUB_FILE: Frm_BeginForm (Tml_DefaultActions[Not->Type]); - Brw_PutHiddenParamFilCod (Not->Cod); + Par_PutParCod (Par_FilCod,Not->Cod); if (Not->HieCod != Gbl.Hierarchy.Ins.InsCod) // Not the current institution Ins_PutParamInsCod (Not->HieCod); // Go to another institution break; case TmlNot_CTR_DOC_PUB_FILE: case TmlNot_CTR_SHA_PUB_FILE: Frm_BeginForm (Tml_DefaultActions[Not->Type]); - Brw_PutHiddenParamFilCod (Not->Cod); + Par_PutParCod (Par_FilCod,Not->Cod); if (Not->HieCod != Gbl.Hierarchy.Ctr.CtrCod) // Not the current center Ctr_PutParamCtrCod (Not->HieCod); // Go to another center break; case TmlNot_DEG_DOC_PUB_FILE: case TmlNot_DEG_SHA_PUB_FILE: Frm_BeginForm (Tml_DefaultActions[Not->Type]); - Brw_PutHiddenParamFilCod (Not->Cod); + Par_PutParCod (Par_FilCod,Not->Cod); if (Not->HieCod != Gbl.Hierarchy.Deg.DegCod) // Not the current degree Deg_PutParamDegCod (Not->HieCod); // Go to another degree break; case TmlNot_CRS_DOC_PUB_FILE: case TmlNot_CRS_SHA_PUB_FILE: Frm_BeginForm (Tml_DefaultActions[Not->Type]); - Brw_PutHiddenParamFilCod (Not->Cod); + Par_PutParCod (Par_FilCod,Not->Cod); if (Not->HieCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course Crs_PutParamCrsCod (Not->HieCod); // Go to another course break; @@ -655,7 +655,7 @@ static void TmlNot_PutFormGoToAction (const struct TmlNot_Note *Not, Frm_BeginFormAnchor (Tml_DefaultActions[Not->Type], Anchor); // Locate on this specific exam Frm_FreeAnchorStr (Anchor); - Cfe_PutHiddenParamExaCod (Not->Cod); + Par_PutParCod (Par_ExaCod,Not->Cod); if (Not->HieCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course Crs_PutParamCrsCod (Not->HieCod); // Go to another course break; @@ -677,7 +677,7 @@ static void TmlNot_PutFormGoToAction (const struct TmlNot_Note *Not, Frm_SetAnchorStr (Not->Cod,&Anchor); Frm_BeginFormAnchor (Tml_DefaultActions[Not->Type],Anchor); Frm_FreeAnchorStr (Anchor); - Not_PutHiddenParamNotCod (Not->Cod); + Par_PutParCod (Par_NotCod,Not->Cod); if (Not->HieCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course Crs_PutParamCrsCod (Not->HieCod); // Go to another course break; @@ -867,7 +867,7 @@ static void TmlNot_PutFormToRemoveNote (const struct Tml_Timeline *Timeline, /***** Form to remove publication *****/ /* Begin form */ TmlFrm_BeginForm (Timeline,TmlFrm_REQ_REM_NOTE); - TmlNot_PutHiddenParamNotCod (NotCod); + Par_PutParCod (Par_NotCod,NotCod); /* Icon to remove */ Ico_PutIconLink ("trash.svg",Ico_RED, @@ -959,25 +959,6 @@ void TmlNot_MarkNotesChildrenOfFolderAsUnavailable (const char *Path) Path); } -/*****************************************************************************/ -/****************** Put parameter with the code of a note ********************/ -/*****************************************************************************/ - -void TmlNot_PutHiddenParamNotCod (long NotCod) - { - Par_PutHiddenParamLong (NULL,"NotCod",NotCod); - } - -/*****************************************************************************/ -/****************** Get parameter with the code of a note ********************/ -/*****************************************************************************/ - -long TmlNot_GetParamNotCod (void) - { - /***** Get note code *****/ - return Par_GetParToLong ("NotCod"); - } - /*****************************************************************************/ /*********************** Request the removal of a note ***********************/ /*****************************************************************************/ @@ -1028,7 +1009,7 @@ static void TmlNot_RequestRemovalNote (struct Tml_Timeline *Timeline) struct TmlNot_Note Not; /***** Get data of note *****/ - Not.NotCod = TmlNot_GetParamNotCod (); + Not.NotCod = Par_GetAndCheckParCode (Par_NotCod); TmlNot_GetDataOfNoteByCod (&Not); /***** Do some checks *****/ @@ -1068,7 +1049,7 @@ static void TmlNot_PutParamsRemoveNote (void *Timeline) Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod); else // Global timeline Usr_PutHiddenParamWho (((struct Tml_Timeline *) Timeline)->Who); - TmlNot_PutHiddenParamNotCod (((struct Tml_Timeline *) Timeline)->NotCod); + Par_PutParCod (Par_NotCod,((struct Tml_Timeline *) Timeline)->NotCod); } } @@ -1123,7 +1104,7 @@ static void TmlNot_RemoveNote (void) struct TmlNot_Note Not; /***** Get data of note *****/ - Not.NotCod = TmlNot_GetParamNotCod (); + Not.NotCod = Par_GetAndCheckParCode (Par_NotCod); TmlNot_GetDataOfNoteByCod (&Not); /***** Trivial check 1: note code should be > 0 *****/ diff --git a/swad_timeline_note.h b/swad_timeline_note.h index 529b6faf..94ca4dd9 100644 --- a/swad_timeline_note.h +++ b/swad_timeline_note.h @@ -106,9 +106,6 @@ void TmlNot_StoreAndPublishNoteInternal (TmlNot_Type_t NoteType,long Cod, void TmlNot_MarkNoteOneFileAsUnavailable (const char *Path); void TmlNot_MarkNotesChildrenOfFolderAsUnavailable (const char *Path); -void TmlNot_PutHiddenParamNotCod (long NotCod); -long TmlNot_GetParamNotCod (void); - void TmlNot_RequestRemNoteUsr (void); void TmlNot_RequestRemNoteGbl (void); void TmlNot_RemoveNoteUsr (void); diff --git a/swad_timeline_publication.c b/swad_timeline_publication.c index 17e1b03e..ff4810f8 100644 --- a/swad_timeline_publication.c +++ b/swad_timeline_publication.c @@ -506,24 +506,6 @@ void TmlPub_PutLinkToViewOldPubs (void) HTM_DIV_End (); } -/*****************************************************************************/ -/*************** Put parameter with the code of a publication ****************/ -/*****************************************************************************/ - -void TmlPub_PutHiddenParamPubCod (long PubCod) - { - Par_PutHiddenParamLong (NULL,"PubCod",PubCod); - } - -/*****************************************************************************/ -/**************** Get parameter with the code of a publication ***************/ -/*****************************************************************************/ - -long TmlPub_GetParamPubCod (void) - { - return Par_GetParToLong ("PubCod"); - } - /*****************************************************************************/ /***************** Get data of publication using its code ********************/ /*****************************************************************************/ diff --git a/swad_timeline_publication.h b/swad_timeline_publication.h index 020256f0..93f8da2e 100644 --- a/swad_timeline_publication.h +++ b/swad_timeline_publication.h @@ -115,9 +115,6 @@ Tml_TopMessage_t TmlPub_GetTopMessage (TmlPub_Type_t PubType); void TmlPub_PutLinkToViewNewPubs (void); void TmlPub_PutLinkToViewOldPubs (void); -void TmlPub_PutHiddenParamPubCod (long PubCod); -long TmlPub_GetParamPubCod (void); - void TmlPub_GetDataOfPubFromNextRow (MYSQL_RES *mysql_res, struct TmlPub_Publication *Pub); diff --git a/swad_timeline_share.c b/swad_timeline_share.c index 4c88261b..e05a2f63 100644 --- a/swad_timeline_share.c +++ b/swad_timeline_share.c @@ -28,6 +28,7 @@ #include "swad_database.h" #include "swad_global.h" #include "swad_notification_database.h" +#include "swad_parameter.h" #include "swad_timeline.h" #include "swad_timeline_database.h" #include "swad_timeline_notification.h" @@ -65,7 +66,7 @@ void TmlSha_ShowAllSharersNoteGbl (void) struct TmlNot_Note Not; /***** Get data of note *****/ - Not.NotCod = TmlNot_GetParamNotCod (); + Not.NotCod = Par_GetAndCheckParCode (Par_NotCod); TmlNot_GetDataOfNoteByCod (&Not); /***** Write HTML inside DIV with form to share/unshare *****/ @@ -106,7 +107,7 @@ static void TmlSha_ShaNote (struct TmlNot_Note *Not) long OriginalPubCod; /***** Get data of note *****/ - Not->NotCod = TmlNot_GetParamNotCod (); + Not->NotCod = Par_GetAndCheckParCode (Par_NotCod); TmlNot_GetDataOfNoteByCod (Not); /***** Do some checks *****/ @@ -164,7 +165,7 @@ static void TmlSha_UnsNote (struct TmlNot_Note *Not) long OriginalPubCod; /***** Get data of note *****/ - Not->NotCod = TmlNot_GetParamNotCod (); + Not->NotCod = Par_GetAndCheckParCode (Par_NotCod); TmlNot_GetDataOfNoteByCod (Not); /***** Do some checks *****/