diff --git a/swad_browser.c b/swad_browser.c index 729c3951..57c7ccaf 100644 --- a/swad_browser.c +++ b/swad_browser.c @@ -4689,7 +4689,7 @@ static void Brw_PutIconFileWithLinkToViewMetadata (const struct Brw_FileMetadata if (FileMetadata->FilFolLnk.Type == Brw_IS_FILE) Brw_PutIconFile (FileMetadata->FilFolLnk.Name, "CONTEXT_OPT ICO_HIGHLIGHT CONTEXT_ICO16x16", - Frm_PUT_FORM_TO_GO); // Put link to view metadata + Frm_PUT_FORM); // Put link to view metadata else Ico_PutIconLink ("up-right-from-square.svg",Ico_BLACK, Brw_ActReqDatFile[Gbl.FileBrowser.Type]); @@ -4707,7 +4707,7 @@ static void Brw_PutIconFileWithLinkToViewMetadata (const struct Brw_FileMetadata /*****************************************************************************/ void Brw_PutIconFile (const char *FileName, - const char *Class,Frm_PutFormToGo_t PutFormToGo) + const char *Class,Frm_PutForm_t PutFormToGo) { extern const unsigned Ext_NUM_FILE_EXT_ALLOWED; extern const char *Ext_FileExtensionsAllowed[]; @@ -4744,10 +4744,10 @@ void Brw_PutIconFile (const char *FileName, switch (PutFormToGo) { - case Frm_DONT_PUT_FORM_TO_GO: + case Frm_DONT_PUT_FORM: HTM_IMG (URL,Icon,Title,"class=\"%s\"",Class); break; - case Frm_PUT_FORM_TO_GO: + case Frm_PUT_FORM: HTM_INPUT_IMAGE (URL,Icon,Title,"class=\"%s\"",Class); break; } @@ -8073,7 +8073,7 @@ static void Brw_WriteBigLinkToDownloadFile (const char *URL, if (FileMetadata->FilFolLnk.Type == Brw_IS_FILE) Brw_PutIconFile (FileMetadata->FilFolLnk.Name, "ICO40x40", - Frm_DONT_PUT_FORM_TO_GO); // Don't put link to view metadata + Frm_DONT_PUT_FORM); // Don't put link to view metadata else Ico_PutIcon ("up-right-from-square.svg",Ico_BLACK,Txt_Link,"ICO40x40"); @@ -8098,7 +8098,7 @@ static void Brw_WriteBigLinkToDownloadFile (const char *URL, if (FileMetadata->FilFolLnk.Type == Brw_IS_FILE) Brw_PutIconFile (FileMetadata->FilFolLnk.Name, "ICO40x40", - Frm_DONT_PUT_FORM_TO_GO); // Don't put link to view metadata + Frm_DONT_PUT_FORM); // Don't put link to view metadata else Ico_PutIcon ("up-right-from-square.svg",Ico_BLACK,Txt_Link,"ICO40x40"); HTM_TxtF (" %s ",FileNameToShow); @@ -9506,7 +9506,7 @@ static void Brw_WriteRowDocData (unsigned *NumDocsNotHidden,MYSQL_ROW row) case Brw_IS_FILE: Brw_PutIconFile (FileMetadata.FilFolLnk.Name, "CONTEXT_ICO16x16", - Frm_DONT_PUT_FORM_TO_GO); // Don't put link to view metadata + Frm_DONT_PUT_FORM); // Don't put link to view metadata break; case Brw_IS_FOLDER: Ico_PutIcon ("folder-yellow.png",Ico_UNCHANGED, diff --git a/swad_browser.h b/swad_browser.h index be578053..f4f61798 100644 --- a/swad_browser.h +++ b/swad_browser.h @@ -244,7 +244,7 @@ void Brw_DB_RemoveExpiredExpandedFolders (void); void Brw_SetFullPathInTree (void); void Brw_PutIconFile (const char *FileName, - const char *Class,Frm_PutFormToGo_t PutFormToGo); + const char *Class,Frm_PutForm_t PutFormToGo); //----------------------------------------------------------------------------- void Brw_CreateTmpPublicLinkToPrivateFile (const char *FullPathIncludingFile, diff --git a/swad_center_config.c b/swad_center_config.c index 9f4f875c..53b4e18f 100644 --- a/swad_center_config.c +++ b/swad_center_config.c @@ -82,15 +82,15 @@ static void CtrCfg_Map (const struct Map_Coordinates *Coord); static void CtrCfg_Latitude (double Latitude); static void CtrCfg_Longitude (double Longitude); static void CtrCfg_Altitude (double Altitude); -static void CtrCfg_Photo (Vie_ViewType_t ViewType,bool PutForm,bool PutLink, +static void CtrCfg_Photo (Vie_ViewType_t ViewType,Frm_PutForm_t PutForm,bool PutLink, const char PathPhoto[PATH_MAX + 1]); static void CtrCfg_GetPhotoAttr (long CtrCod,char **PhotoAttribution); static void CtrCfg_FreePhotoAttr (char **PhotoAttribution); -static void CtrCfg_Institution (Vie_ViewType_t ViewType,bool PutForm); -static void CtrCfg_FullName (bool PutForm); -static void CtrCfg_ShrtName (bool PutForm); -static void CtrCfg_Place (bool PutForm); -static void CtrCfg_WWW (Vie_ViewType_t ViewType,bool PutForm); +static void CtrCfg_Institution (Vie_ViewType_t ViewType,Frm_PutForm_t PutForm); +static void CtrCfg_FullName (Frm_PutForm_t PutForm); +static void CtrCfg_ShrtName (Frm_PutForm_t PutForm); +static void CtrCfg_Place (Frm_PutForm_t PutForm); +static void CtrCfg_WWW (Vie_ViewType_t ViewType,Frm_PutForm_t PutForm); static void CtrCfg_Shortcut (Vie_ViewType_t ViewType); static void CtrCfg_QR (void); static void CtrCfg_NumUsrs (void); @@ -127,12 +127,12 @@ static void CtrCfg_Configuration (Vie_ViewType_t ViewType) extern const char *Hlp_CENTER_Information; struct Map_Coordinates Coord; bool PutLink; - bool PutFormIns; - bool PutFormName; - bool PutFormPlc; - bool PutFormCoor; - bool PutFormWWW; - bool PutFormPhoto; + Frm_PutForm_t PutFormIns; + Frm_PutForm_t PutFormName; + Frm_PutForm_t PutFormPlc; + Frm_PutForm_t PutFormCoor; + Frm_PutForm_t PutFormWWW; + Frm_PutForm_t PutFormPhoto; bool MapIsAvailable; char PathPhoto[PATH_MAX + 1]; bool PhotoExists; @@ -146,12 +146,18 @@ static void CtrCfg_Configuration (Vie_ViewType_t ViewType) /***** Initializations *****/ PutLink = ViewType == Vie_VIEW && Gbl.Hierarchy.Node[Hie_CTR].WWW[0]; - PutFormIns = ViewType == Vie_VIEW && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM; - PutFormName = ViewType == Vie_VIEW && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM; + PutFormIns = (ViewType == Vie_VIEW && + Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) ? Frm_PUT_FORM : + Frm_DONT_PUT_FORM; + PutFormName = (ViewType == Vie_VIEW && + Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) ? Frm_PUT_FORM : + Frm_DONT_PUT_FORM; PutFormPlc = PutFormCoor = PutFormWWW = - PutFormPhoto = ViewType == Vie_VIEW && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM; + PutFormPhoto = (ViewType == Vie_VIEW && + Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM) ? Frm_PUT_FORM : + Frm_DONT_PUT_FORM; /***** Begin box *****/ Box_BoxBegin (NULL,NULL, @@ -180,7 +186,7 @@ static void CtrCfg_Configuration (Vie_ViewType_t ViewType) CtrCfg_Place (PutFormPlc); /***** Coordinates *****/ - if (PutFormCoor) + if (PutFormCoor == Frm_PUT_FORM) { CtrCfg_Latitude (Coord.Latitude ); CtrCfg_Longitude (Coord.Longitude); @@ -421,7 +427,7 @@ static void CtrCfg_Altitude (double Altitude) /***************************** Draw center photo *****************************/ /*****************************************************************************/ -static void CtrCfg_Photo (Vie_ViewType_t ViewType,bool PutForm,bool PutLink, +static void CtrCfg_Photo (Vie_ViewType_t ViewType,Frm_PutForm_t PutForm,bool PutLink, const char PathPhoto[PATH_MAX + 1]) { char *PhotoAttribution = NULL; @@ -460,23 +466,27 @@ static void CtrCfg_Photo (Vie_ViewType_t ViewType,bool PutForm,bool PutLink, HTM_DIV_End (); /****** Photo attribution ******/ - if (PutForm) + switch (PutForm) { - HTM_DIV_Begin ("class=\"CM\""); - Frm_BeginForm (ActChgCtrPhoAtt); - HTM_TEXTAREA_Begin ("id=\"AttributionArea\" name=\"Attribution\" rows=\"3\"" - " onchange=\"this.form.submit();return false;\""); - if (PhotoAttribution) - HTM_Txt (PhotoAttribution); - HTM_TEXTAREA_End (); - Frm_EndForm (); - HTM_DIV_End (); - } - else if (PhotoAttribution) - { - HTM_DIV_Begin ("class=\"ATTRIBUTION\""); - HTM_Txt (PhotoAttribution); - HTM_DIV_End (); + case Frm_DONT_PUT_FORM: + if (PhotoAttribution) + { + HTM_DIV_Begin ("class=\"ATTRIBUTION\""); + HTM_Txt (PhotoAttribution); + HTM_DIV_End (); + } + break; + case Frm_PUT_FORM: + HTM_DIV_Begin ("class=\"CM\""); + Frm_BeginForm (ActChgCtrPhoAtt); + HTM_TEXTAREA_Begin ("id=\"AttributionArea\" name=\"Attribution\" rows=\"3\"" + " onchange=\"this.form.submit();return false;\""); + if (PhotoAttribution) + HTM_Txt (PhotoAttribution); + HTM_TEXTAREA_End (); + Frm_EndForm (); + HTM_DIV_End (); + break; } /****** Free memory used for photo attribution ******/ @@ -534,75 +544,79 @@ static void CtrCfg_FreePhotoAttr (char **PhotoAttribution) /***************** Show institution in center configuration ******************/ /*****************************************************************************/ -static void CtrCfg_Institution (Vie_ViewType_t ViewType,bool PutForm) +static void CtrCfg_Institution (Vie_ViewType_t ViewType,Frm_PutForm_t PutForm) { extern const char *Par_CodeStr[]; extern const char *Txt_Institution; unsigned NumIns; const struct Hie_Node *Ins; + const char *Id[Frm_NUM_PUT_FORM] = + { + [Frm_DONT_PUT_FORM] = NULL, + [Frm_PUT_FORM ] = Par_CodeStr[ParCod_OthIns], + }; /***** Institution *****/ HTM_TR_Begin (NULL); /* Label */ - Frm_LabelColumn ("RT",PutForm ? Par_CodeStr[ParCod_OthIns] : - NULL, - Txt_Institution); + Frm_LabelColumn ("RT",Id[PutForm],Txt_Institution); /* Data */ HTM_TD_Begin ("class=\"LT DAT_%s\"",The_GetSuffix ()); - if (PutForm) - { - /* Get list of institutions of the current country */ - Ins_GetBasicListOfInstitutions (Gbl.Hierarchy.Node[Hie_CTY].HieCod); + switch (PutForm) + { + case Frm_DONT_PUT_FORM: + if (ViewType == Vie_VIEW) + { + Frm_BeginFormGoTo (ActSeeInsInf); + ParCod_PutPar (ParCod_Ins,Gbl.Hierarchy.Node[Hie_INS].HieCod); + HTM_BUTTON_Submit_Begin (Str_BuildGoToTitle (Gbl.Hierarchy.Node[Hie_INS].ShrtName), + "class=\"LT BT_LINK\""); + Str_FreeGoToTitle (); + } - /* Put form to select institution */ - Frm_BeginForm (ActChgCtrInsCfg); - HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,NULL, - "id=\"OthInsCod\" name=\"OthInsCod\"" - " class=\"INPUT_SHORT_NAME INPUT_%s\"", - The_GetSuffix ()); - for (NumIns = 0; - NumIns < Gbl.Hierarchy.List[Hie_CTY].Num; - NumIns++) - { - Ins = &Gbl.Hierarchy.List[Hie_CTY].Lst[NumIns]; - HTM_OPTION (HTM_Type_LONG,&Ins->HieCod, - Ins->HieCod == Gbl.Hierarchy.Node[Hie_INS].HieCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, - HTM_OPTION_ENABLED, - "%s",Ins->ShrtName); - } - HTM_SELECT_End (); - Frm_EndForm (); + Lgo_DrawLogo (Hie_INS, + Gbl.Hierarchy.Node[Hie_INS].HieCod, + Gbl.Hierarchy.Node[Hie_INS].ShrtName, + 20,"LM"); + HTM_NBSP (); + HTM_Txt (Gbl.Hierarchy.Node[Hie_INS].FullName); - /* Free list of institutions */ - Hie_FreeList (Hie_CTY); - } - else // I can not move center to another institution - { - if (ViewType == Vie_VIEW) - { - Frm_BeginFormGoTo (ActSeeInsInf); - ParCod_PutPar (ParCod_Ins,Gbl.Hierarchy.Node[Hie_INS].HieCod); - HTM_BUTTON_Submit_Begin (Str_BuildGoToTitle (Gbl.Hierarchy.Node[Hie_INS].ShrtName), - "class=\"LT BT_LINK\""); - Str_FreeGoToTitle (); - } + if (ViewType == Vie_VIEW) + { + HTM_BUTTON_End (); + Frm_EndForm (); + } + break; + case Frm_PUT_FORM: + /* Get list of institutions of the current country */ + Ins_GetBasicListOfInstitutions (Gbl.Hierarchy.Node[Hie_CTY].HieCod); - Lgo_DrawLogo (Hie_INS, - Gbl.Hierarchy.Node[Hie_INS].HieCod, - Gbl.Hierarchy.Node[Hie_INS].ShrtName, - 20,"LM"); - HTM_NBSP (); - HTM_Txt (Gbl.Hierarchy.Node[Hie_INS].FullName); - - if (ViewType == Vie_VIEW) - { - HTM_BUTTON_End (); + /* Put form to select institution */ + Frm_BeginForm (ActChgCtrInsCfg); + HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,NULL, + "id=\"OthInsCod\" name=\"OthInsCod\"" + " class=\"INPUT_SHORT_NAME INPUT_%s\"", + The_GetSuffix ()); + for (NumIns = 0; + NumIns < Gbl.Hierarchy.List[Hie_CTY].Num; + NumIns++) + { + Ins = &Gbl.Hierarchy.List[Hie_CTY].Lst[NumIns]; + HTM_OPTION (HTM_Type_LONG,&Ins->HieCod, + Ins->HieCod == Gbl.Hierarchy.Node[Hie_INS].HieCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, + HTM_OPTION_ENABLED, + "%s",Ins->ShrtName); + } + HTM_SELECT_End (); Frm_EndForm (); - } - } + + /* Free list of institutions */ + Hie_FreeList (Hie_CTY); + break; + } HTM_TD_End (); HTM_TR_End (); @@ -612,7 +626,7 @@ static void CtrCfg_Institution (Vie_ViewType_t ViewType,bool PutForm) /************** Show center full name in center configuration ****************/ /*****************************************************************************/ -static void CtrCfg_FullName (bool PutForm) +static void CtrCfg_FullName (Frm_PutForm_t PutForm) { HieCfg_Name (PutForm,Hie_CTR,Nam_FULL_NAME); } @@ -621,7 +635,7 @@ static void CtrCfg_FullName (bool PutForm) /************** Show center short name in center configuration ***************/ /*****************************************************************************/ -static void CtrCfg_ShrtName (bool PutForm) +static void CtrCfg_ShrtName (Frm_PutForm_t PutForm) { HieCfg_Name (PutForm,Hie_CTR,Nam_SHRT_NAME); } @@ -630,7 +644,7 @@ static void CtrCfg_ShrtName (bool PutForm) /**************** Show center place in center configuration ******************/ /*****************************************************************************/ -static void CtrCfg_Place (bool PutForm) +static void CtrCfg_Place (Frm_PutForm_t PutForm) { extern const char *Par_CodeStr[]; extern const char *Txt_Place; @@ -638,6 +652,11 @@ static void CtrCfg_Place (bool PutForm) struct Plc_Places Places; struct Plc_Place Plc; unsigned NumPlc; + const char *Id[Frm_NUM_PUT_FORM] = + { + [Frm_DONT_PUT_FORM] = NULL, + [Frm_PUT_FORM ] = Par_CodeStr[ParCod_Plc], + }; /***** Reset places context *****/ Plc_ResetPlaces (&Places); @@ -646,51 +665,50 @@ static void CtrCfg_Place (bool PutForm) HTM_TR_Begin (NULL); /* Label */ - Frm_LabelColumn ("RT",PutForm ? Par_CodeStr[ParCod_Plc] : - NULL, - Txt_Place); + Frm_LabelColumn ("RT",Id[PutForm],Txt_Place); /* Data */ HTM_TD_Begin ("class=\"LB DAT_%s\"",The_GetSuffix ()); - if (PutForm) - { - /* Get list of places of the current institution */ - Places.SelectedOrder = Plc_ORDER_BY_PLACE; - Plc_GetListPlaces (&Places); + switch (PutForm) + { + case Frm_DONT_PUT_FORM: // I can not change center place + /* Text with the place name */ + Plc.PlcCod = Gbl.Hierarchy.Node[Hie_CTR].Specific.PlcCod; + Plc_GetPlaceDataByCod (&Plc); + HTM_Txt (Plc.FullName); + break; + case Frm_PUT_FORM: + /* Get list of places of the current institution */ + Places.SelectedOrder = Plc_ORDER_BY_PLACE; + Plc_GetListPlaces (&Places); - /* Put form to select place */ - Frm_BeginForm (ActChgCtrPlcCfg); - HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,NULL, - "name=\"PlcCod\"" - " class=\"INPUT_SHORT_NAME INPUT_%s\"", - The_GetSuffix ()); - HTM_OPTION (HTM_Type_STRING,"0", - Gbl.Hierarchy.Node[Hie_CTR].Specific.PlcCod == 0 ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, - HTM_OPTION_ENABLED, - "%s",Txt_Another_place); - for (NumPlc = 0; - NumPlc < Places.Num; - NumPlc++) - HTM_OPTION (HTM_Type_LONG,&Places.Lst[NumPlc].PlcCod, - Places.Lst[NumPlc].PlcCod == Gbl.Hierarchy.Node[Hie_CTR].Specific.PlcCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, + /* Put form to select place */ + Frm_BeginForm (ActChgCtrPlcCfg); + HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,NULL, + "name=\"PlcCod\"" + " class=\"INPUT_SHORT_NAME INPUT_%s\"", + The_GetSuffix ()); + HTM_OPTION (HTM_Type_STRING,"0", + Gbl.Hierarchy.Node[Hie_CTR].Specific.PlcCod == 0 ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, HTM_OPTION_ENABLED, - "%s",Places.Lst[NumPlc].ShrtName); - HTM_SELECT_End (); - Frm_EndForm (); + "%s",Txt_Another_place); + for (NumPlc = 0; + NumPlc < Places.Num; + NumPlc++) + HTM_OPTION (HTM_Type_LONG,&Places.Lst[NumPlc].PlcCod, + Places.Lst[NumPlc].PlcCod == Gbl.Hierarchy.Node[Hie_CTR].Specific.PlcCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, + HTM_OPTION_ENABLED, + "%s",Places.Lst[NumPlc].ShrtName); + HTM_SELECT_End (); + Frm_EndForm (); - /* Free list of places */ - Plc_FreeListPlaces (&Places); - } - else // I can not change center place - { - /* Text with the place name */ - Plc.PlcCod = Gbl.Hierarchy.Node[Hie_CTR].Specific.PlcCod; - Plc_GetPlaceDataByCod (&Plc); - HTM_Txt (Plc.FullName); - } + /* Free list of places */ + Plc_FreeListPlaces (&Places); + break; + } HTM_TD_End (); @@ -701,7 +719,7 @@ static void CtrCfg_Place (bool PutForm) /***************** Show center WWW in center configuration *******************/ /*****************************************************************************/ -static void CtrCfg_WWW (Vie_ViewType_t ViewType,bool PutForm) +static void CtrCfg_WWW (Vie_ViewType_t ViewType,Frm_PutForm_t PutForm) { HieCfg_WWW (ViewType,PutForm,ActChgCtrWWWCfg,Gbl.Hierarchy.Node[Hie_CTR].WWW); } diff --git a/swad_country.c b/swad_country.c index 229c0eea..1c8cd266 100644 --- a/swad_country.c +++ b/swad_country.c @@ -867,26 +867,30 @@ void Cty_WriteSelectorOfCountry (void) void Cty_WriteCountryName (long CtyCod) { char CtyName[Cty_MAX_BYTES_NAME + 1]; - bool PutForm = !Frm_CheckIfInside () && // Only if not inside another form - Act_GetBrowserTab (Gbl.Action.Act) == Act_BRW_1ST_TAB; // Only in main browser tab + Frm_PutForm_t PutForm = (!Frm_CheckIfInside () && // Only if not inside another form + Act_GetBrowserTab (Gbl.Action.Act) == Act_BRW_1ST_TAB) ? Frm_PUT_FORM : // Only in main browser tab + Frm_DONT_PUT_FORM; /***** Get country name *****/ Cty_GetCountryNameInLanguage (CtyCod,Gbl.Prefs.Language,CtyName); - if (PutForm) + switch (PutForm) { - /***** Write country name with link to country information *****/ - Frm_BeginForm (ActSeeCtyInf); - ParCod_PutPar (ParCod_Cty,CtyCod); - HTM_BUTTON_Submit_Begin (Act_GetActionText (ActSeeCtyInf), - "class=\"BT_LINK\""); - HTM_Txt (CtyName); - HTM_BUTTON_End (); - Frm_EndForm (); + case Frm_DONT_PUT_FORM: + /***** Write country name without link *****/ + HTM_Txt (CtyName); + break; + case Frm_PUT_FORM: + /***** Write country name with link to country information *****/ + Frm_BeginForm (ActSeeCtyInf); + ParCod_PutPar (ParCod_Cty,CtyCod); + HTM_BUTTON_Submit_Begin (Act_GetActionText (ActSeeCtyInf), + "class=\"BT_LINK\""); + HTM_Txt (CtyName); + HTM_BUTTON_End (); + Frm_EndForm (); + break; } - else - /***** Write country name without link *****/ - HTM_Txt (CtyName); } /*****************************************************************************/ diff --git a/swad_course_config.c b/swad_course_config.c index 9e0e7a5f..370ea805 100644 --- a/swad_course_config.c +++ b/swad_course_config.c @@ -60,11 +60,11 @@ extern struct Globals Gbl; /*****************************************************************************/ static void CrsCfg_PutIconToPrint (__attribute__((unused)) void *Args); -static void CrsCfg_Degree (Vie_ViewType_t ViewType,bool PutForm); -static void CrsCfg_FullName (bool PutForm); -static void CrsCfg_ShrtName (bool PutForm); -static void CrsCfg_Year (bool PutForm); -static void CrsCfg_InstitutionalCode (bool PutForm); +static void CrsCfg_Degree (Vie_ViewType_t ViewType,Frm_PutForm_t PutForm); +static void CrsCfg_FullName (Frm_PutForm_t PutForm); +static void CrsCfg_ShrtName (Frm_PutForm_t PutForm); +static void CrsCfg_Year (Frm_PutForm_t PutForm); +static void CrsCfg_InstitutionalCode (Frm_PutForm_t PutForm); static void CrsCfg_InternalCode (void); static void CrsCfg_Shortcut (Vie_ViewType_t ViewType); static void CrsCfg_QR (void); @@ -78,10 +78,10 @@ void CrsCfg_Configuration (Vie_ViewType_t ViewType) { extern const char *Hlp_COURSE_Information; bool PutLink; - bool PutFormDeg; - bool PutFormName; - bool PutFormYear; - bool PutFormInsCod; + Frm_PutForm_t PutFormDeg; + Frm_PutForm_t PutFormName; + Frm_PutForm_t PutFormYear; + Frm_PutForm_t PutFormInsCod; /***** Trivial check *****/ if (Gbl.Hierarchy.Node[Hie_CRS].HieCod <= 0) // No course selected @@ -89,10 +89,16 @@ void CrsCfg_Configuration (Vie_ViewType_t ViewType) /***** Initializations *****/ PutLink = ViewType == Vie_VIEW && Gbl.Hierarchy.Node[Hie_DEG].WWW[0]; - PutFormDeg = ViewType == Vie_VIEW && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM; - PutFormName = ViewType == Vie_VIEW && Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM; + PutFormDeg = (ViewType == Vie_VIEW && + Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM) ? Frm_PUT_FORM : + Frm_DONT_PUT_FORM; + PutFormName = (ViewType == Vie_VIEW && + Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM) ? Frm_PUT_FORM : + Frm_DONT_PUT_FORM; PutFormYear = - PutFormInsCod = ViewType == Vie_VIEW && Gbl.Usrs.Me.Role.Logged >= Rol_TCH; + PutFormInsCod = (ViewType == Vie_VIEW && + Gbl.Usrs.Me.Role.Logged >= Rol_TCH) ? Frm_PUT_FORM : + Frm_DONT_PUT_FORM; /***** Contextual menu *****/ if (ViewType == Vie_VIEW && @@ -196,73 +202,77 @@ void CrsCfg_PrintConfiguration (void) /******************** Show degree in course configuration ********************/ /*****************************************************************************/ -static void CrsCfg_Degree (Vie_ViewType_t ViewType,bool PutForm) +static void CrsCfg_Degree (Vie_ViewType_t ViewType,Frm_PutForm_t PutForm) { extern const char *Par_CodeStr[]; extern const char *Txt_Degree; unsigned NumDeg; const struct Hie_Node *Deg; + const char *Id[Frm_NUM_PUT_FORM] = + { + [Frm_DONT_PUT_FORM] = NULL, + [Frm_PUT_FORM ] = Par_CodeStr[ParCod_OthDeg], + }; /***** Degree *****/ HTM_TR_Begin (NULL); /* Label */ - Frm_LabelColumn ("RT",PutForm ? Par_CodeStr[ParCod_OthDeg] : - NULL, - Txt_Degree); + Frm_LabelColumn ("RT",Id[PutForm],Txt_Degree); /* Data */ HTM_TD_Begin ("class=\"LT DAT_%s\"",The_GetSuffix ()); - if (PutForm) - { - /* Get list of degrees of the current center */ - Deg_GetListDegsInCurrentCtr (); + switch (PutForm) + { + case Frm_DONT_PUT_FORM: // I can not move course to another degree + if (ViewType == Vie_VIEW) + { + Frm_BeginFormGoTo (ActSeeDegInf); + ParCod_PutPar (ParCod_Deg,Gbl.Hierarchy.Node[Hie_DEG].HieCod); + HTM_BUTTON_Submit_Begin (Str_BuildGoToTitle (Gbl.Hierarchy.Node[Hie_DEG].ShrtName), + "class=\"LT BT_LINK\""); + Str_FreeGoToTitle (); + } + Lgo_DrawLogo (Hie_DEG, + Gbl.Hierarchy.Node[Hie_DEG].HieCod, + Gbl.Hierarchy.Node[Hie_DEG].ShrtName, + 20,"LM"); + HTM_NBSP (); + HTM_Txt (Gbl.Hierarchy.Node[Hie_DEG].FullName); + if (ViewType == Vie_VIEW) + { + HTM_BUTTON_End (); + Frm_EndForm (); + } + break; + case Frm_PUT_FORM: + /* Get list of degrees of the current center */ + Deg_GetListDegsInCurrentCtr (); - /* Put form to select degree */ - Frm_BeginForm (ActChgCrsDegCfg); - HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,NULL, - "id=\"OthDegCod\" name=\"OthDegCod\"" - " class=\"INPUT_SHORT_NAME INPUT_%s\"", - The_GetSuffix ()); - for (NumDeg = 0; - NumDeg < Gbl.Hierarchy.List[Hie_CTR].Num; - NumDeg++) - { - Deg = &Gbl.Hierarchy.List[Hie_CTR].Lst[NumDeg]; - HTM_OPTION (HTM_Type_LONG,&Deg->HieCod, - Deg->HieCod == Gbl.Hierarchy.Node[Hie_DEG].HieCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, - HTM_OPTION_ENABLED, - "%s",Deg->ShrtName); - } - HTM_SELECT_End (); - Frm_EndForm (); - - /* Free list of degrees of the current center */ - Hie_FreeList (Hie_CTR); - } - else // I can not move course to another degree - { - if (ViewType == Vie_VIEW) - { - Frm_BeginFormGoTo (ActSeeDegInf); - ParCod_PutPar (ParCod_Deg,Gbl.Hierarchy.Node[Hie_DEG].HieCod); - HTM_BUTTON_Submit_Begin (Str_BuildGoToTitle (Gbl.Hierarchy.Node[Hie_DEG].ShrtName), - "class=\"LT BT_LINK\""); - Str_FreeGoToTitle (); - } - Lgo_DrawLogo (Hie_DEG, - Gbl.Hierarchy.Node[Hie_DEG].HieCod, - Gbl.Hierarchy.Node[Hie_DEG].ShrtName, - 20,"LM"); - HTM_NBSP (); - HTM_Txt (Gbl.Hierarchy.Node[Hie_DEG].FullName); - if (ViewType == Vie_VIEW) - { - HTM_BUTTON_End (); + /* Put form to select degree */ + Frm_BeginForm (ActChgCrsDegCfg); + HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,NULL, + "id=\"OthDegCod\" name=\"OthDegCod\"" + " class=\"INPUT_SHORT_NAME INPUT_%s\"", + The_GetSuffix ()); + for (NumDeg = 0; + NumDeg < Gbl.Hierarchy.List[Hie_CTR].Num; + NumDeg++) + { + Deg = &Gbl.Hierarchy.List[Hie_CTR].Lst[NumDeg]; + HTM_OPTION (HTM_Type_LONG,&Deg->HieCod, + Deg->HieCod == Gbl.Hierarchy.Node[Hie_DEG].HieCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, + HTM_OPTION_ENABLED, + "%s",Deg->ShrtName); + } + HTM_SELECT_End (); Frm_EndForm (); - } - } + + /* Free list of degrees of the current center */ + Hie_FreeList (Hie_CTR); + break; + } HTM_TD_End (); HTM_TR_End (); @@ -272,7 +282,7 @@ static void CrsCfg_Degree (Vie_ViewType_t ViewType,bool PutForm) /************** Show course full name in course configuration ****************/ /*****************************************************************************/ -static void CrsCfg_FullName (bool PutForm) +static void CrsCfg_FullName (Frm_PutForm_t PutForm) { HieCfg_Name (PutForm,Hie_CRS,Nam_FULL_NAME); } @@ -281,7 +291,7 @@ static void CrsCfg_FullName (bool PutForm) /************** Show course short name in course configuration ***************/ /*****************************************************************************/ -static void CrsCfg_ShrtName (bool PutForm) +static void CrsCfg_ShrtName (Frm_PutForm_t PutForm) { HieCfg_Name (PutForm,Hie_CRS,Nam_SHRT_NAME); } @@ -290,44 +300,50 @@ static void CrsCfg_ShrtName (bool PutForm) /***************** Show course year in course configuration ******************/ /*****************************************************************************/ -static void CrsCfg_Year (bool PutForm) +static void CrsCfg_Year (Frm_PutForm_t PutForm) { extern const char *Txt_Year_OF_A_DEGREE; extern const char *Txt_YEAR_OF_DEGREE[1 + Deg_MAX_YEARS_PER_DEGREE]; extern const char *Txt_Not_applicable; unsigned Year; + static const char *Id[Frm_NUM_PUT_FORM] = + { + [Frm_DONT_PUT_FORM] = NULL, + [Frm_PUT_FORM ] = "OthCrsYear", + }; /***** Academic year *****/ HTM_TR_Begin (NULL); /* Label */ - Frm_LabelColumn ("RT",PutForm ? "OthCrsYear" : - NULL, - Txt_Year_OF_A_DEGREE); + Frm_LabelColumn ("RT",Id[PutForm],Txt_Year_OF_A_DEGREE); /* Data */ HTM_TD_Begin ("class=\"LB DAT_%s\"",The_GetSuffix ()); - if (PutForm) - { - Frm_BeginForm (ActChgCrsYeaCfg); - HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,NULL, - "id=\"OthCrsYear\" name=\"OthCrsYear\"" - " class=\"INPUT_%s\"", - The_GetSuffix ()); - for (Year = 0; - Year <= Deg_MAX_YEARS_PER_DEGREE; - Year++) - HTM_OPTION (HTM_Type_UNSIGNED,&Year, - Year == Gbl.Hierarchy.Node[Hie_CRS].Specific.Year ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, - HTM_OPTION_ENABLED, - "%s",Txt_YEAR_OF_DEGREE[Year]); - HTM_SELECT_End (); - Frm_EndForm (); - } - else - HTM_Txt (Gbl.Hierarchy.Node[Hie_CRS].Specific.Year ? Txt_YEAR_OF_DEGREE[Gbl.Hierarchy.Node[Hie_CRS].Specific.Year] : + switch (PutForm) + { + case Frm_DONT_PUT_FORM: + HTM_Txt (Gbl.Hierarchy.Node[Hie_CRS].Specific.Year ? Txt_YEAR_OF_DEGREE[Gbl.Hierarchy.Node[Hie_CRS].Specific.Year] : Txt_Not_applicable); + break; + case Frm_PUT_FORM: + Frm_BeginForm (ActChgCrsYeaCfg); + HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,NULL, + "id=\"OthCrsYear\" name=\"OthCrsYear\"" + " class=\"INPUT_%s\"", + The_GetSuffix ()); + for (Year = 0; + Year <= Deg_MAX_YEARS_PER_DEGREE; + Year++) + HTM_OPTION (HTM_Type_UNSIGNED,&Year, + Year == Gbl.Hierarchy.Node[Hie_CRS].Specific.Year ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, + HTM_OPTION_ENABLED, + "%s",Txt_YEAR_OF_DEGREE[Year]); + HTM_SELECT_End (); + Frm_EndForm (); + break; + } HTM_TD_End (); HTM_TR_End (); @@ -337,34 +353,40 @@ static void CrsCfg_Year (bool PutForm) /************* Show institutional code in course configuration ***************/ /*****************************************************************************/ -static void CrsCfg_InstitutionalCode (bool PutForm) +static void CrsCfg_InstitutionalCode (Frm_PutForm_t PutForm) { extern const char *Txt_Institutional_code; + static const char *Id[Frm_NUM_PUT_FORM] = + { + [Frm_DONT_PUT_FORM] = NULL, + [Frm_PUT_FORM ] = "InsCrsCod", + }; /***** Institutional course code *****/ HTM_TR_Begin (NULL); /* Label */ - Frm_LabelColumn ("RT",PutForm ? "InsCrsCod" : - NULL, - Txt_Institutional_code); + Frm_LabelColumn ("RT",Id[PutForm],Txt_Institutional_code); /* Data */ HTM_TD_Begin ("class=\"LB DAT_%s\"",The_GetSuffix ()); - if (PutForm) - { - Frm_BeginForm (ActChgInsCrsCodCfg); - HTM_INPUT_TEXT ("InsCrsCod",Hie_MAX_CHARS_INSTITUTIONAL_COD, - Gbl.Hierarchy.Node[Hie_CRS].InstitutionalCod, - HTM_SUBMIT_ON_CHANGE, - "id=\"InsCrsCod\" size=\"%u\"" - " class=\"INPUT_INS_CODE INPUT_%s\"", - Hie_MAX_CHARS_INSTITUTIONAL_COD, - The_GetSuffix ()); - Frm_EndForm (); - } - else - HTM_Txt (Gbl.Hierarchy.Node[Hie_CRS].InstitutionalCod); + switch (PutForm) + { + case Frm_DONT_PUT_FORM: + HTM_Txt (Gbl.Hierarchy.Node[Hie_CRS].InstitutionalCod); + break; + case Frm_PUT_FORM: + Frm_BeginForm (ActChgInsCrsCodCfg); + HTM_INPUT_TEXT ("InsCrsCod",Hie_MAX_CHARS_INSTITUTIONAL_COD, + Gbl.Hierarchy.Node[Hie_CRS].InstitutionalCod, + HTM_SUBMIT_ON_CHANGE, + "id=\"InsCrsCod\" size=\"%u\"" + " class=\"INPUT_INS_CODE INPUT_%s\"", + Hie_MAX_CHARS_INSTITUTIONAL_COD, + The_GetSuffix ()); + Frm_EndForm (); + break; + } HTM_TD_End (); HTM_TR_End (); diff --git a/swad_degree_config.c b/swad_degree_config.c index 25c0c3df..b275393c 100644 --- a/swad_degree_config.c +++ b/swad_degree_config.c @@ -59,10 +59,10 @@ extern struct Globals Gbl; static void DegCfg_Configuration (Vie_ViewType_t ViewType); static void DegCfg_PutIconsToPrintAndUpload (__attribute__((unused)) void *Args); -static void DegCfg_Center (Vie_ViewType_t ViewType,bool PutForm); -static void DegCfg_FullName (bool PutForm); -static void DegCfg_ShrtName (bool PutForm); -static void DegCfg_WWW (Vie_ViewType_t ViewType,bool PutForm); +static void DegCfg_Center (Vie_ViewType_t ViewType,Frm_PutForm_t PutForm); +static void DegCfg_FullName (Frm_PutForm_t PutForm); +static void DegCfg_ShrtName (Frm_PutForm_t PutForm); +static void DegCfg_WWW (Vie_ViewType_t ViewType,Frm_PutForm_t PutForm); static void DegCfg_Shortcut (Vie_ViewType_t ViewType); static void DegCfg_QR (void); static void DegCfg_NumCrss (void); @@ -96,9 +96,9 @@ static void DegCfg_Configuration (Vie_ViewType_t ViewType) { extern const char *Hlp_DEGREE_Information; bool PutLink; - bool PutFormCtr; - bool PutFormName; - bool PutFormWWW; + Frm_PutForm_t PutFormCtr; + Frm_PutForm_t PutFormName; + Frm_PutForm_t PutFormWWW; /***** Trivial check *****/ if (Gbl.Hierarchy.Node[Hie_DEG].HieCod <= 0) // No degree selected @@ -106,9 +106,15 @@ static void DegCfg_Configuration (Vie_ViewType_t ViewType) /***** Initializations *****/ PutLink = ViewType == Vie_VIEW && Gbl.Hierarchy.Node[Hie_DEG].WWW[0]; - PutFormCtr = ViewType == Vie_VIEW && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM; - PutFormName = ViewType == Vie_VIEW && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM; - PutFormWWW = ViewType == Vie_VIEW && Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM; + PutFormCtr = (ViewType == Vie_VIEW && + Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) ? Frm_PUT_FORM : + Frm_DONT_PUT_FORM; + PutFormName = (ViewType == Vie_VIEW && + Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM) ? Frm_PUT_FORM : + Frm_DONT_PUT_FORM; + PutFormWWW = (ViewType == Vie_VIEW && + Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM) ? Frm_PUT_FORM : + Frm_DONT_PUT_FORM; /***** Begin box *****/ Box_BoxBegin (NULL,NULL, @@ -190,73 +196,77 @@ static void DegCfg_PutIconsToPrintAndUpload (__attribute__((unused)) void *Args) /******************** Show center in degree configuration ********************/ /*****************************************************************************/ -static void DegCfg_Center (Vie_ViewType_t ViewType,bool PutForm) +static void DegCfg_Center (Vie_ViewType_t ViewType,Frm_PutForm_t PutForm) { extern const char *Par_CodeStr[]; extern const char *Txt_Center; unsigned NumCtr; const struct Hie_Node *Ctr; + const char *Id[Frm_NUM_PUT_FORM] = + { + [Frm_DONT_PUT_FORM] = NULL, + [Frm_PUT_FORM ] = Par_CodeStr[ParCod_OthCtr], + }; /***** Center *****/ HTM_TR_Begin (NULL); /* Label */ - Frm_LabelColumn ("RT",PutForm ? Par_CodeStr[ParCod_OthCtr] : - NULL, - Txt_Center); + Frm_LabelColumn ("RT",Id[PutForm],Txt_Center); /* Data */ HTM_TD_Begin ("class=\"LB DAT_%s\"",The_GetSuffix ()); - if (PutForm) - { - /* Get list of centers of the current institution */ - Ctr_GetBasicListOfCenters (Gbl.Hierarchy.Node[Hie_INS].HieCod); + switch (PutForm) + { + case Frm_DONT_PUT_FORM: // I can not move degree to another center + if (ViewType == Vie_VIEW) + { + Frm_BeginFormGoTo (ActSeeCtrInf); + ParCod_PutPar (ParCod_Ctr,Gbl.Hierarchy.Node[Hie_CTR].HieCod); + HTM_BUTTON_Submit_Begin (Str_BuildGoToTitle (Gbl.Hierarchy.Node[Hie_CTR].ShrtName), + "class=\"LB BT_LINK\""); + Str_FreeGoToTitle (); + } + Lgo_DrawLogo (Hie_CTR, + Gbl.Hierarchy.Node[Hie_CTR].HieCod, + Gbl.Hierarchy.Node[Hie_CTR].ShrtName, + 20,"LM"); + HTM_NBSP (); + HTM_Txt (Gbl.Hierarchy.Node[Hie_CTR].FullName); + if (ViewType == Vie_VIEW) + { + HTM_BUTTON_End (); + Frm_EndForm (); + } + break; + case Frm_PUT_FORM: + /* Get list of centers of the current institution */ + Ctr_GetBasicListOfCenters (Gbl.Hierarchy.Node[Hie_INS].HieCod); - /* Put form to select center */ - Frm_BeginForm (ActChgDegCtrCfg); - HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,NULL, - "id=\"OthCtrCod\" name=\"OthCtrCod\"" - " class=\"INPUT_SHORT_NAME INPUT_%s\"", - The_GetSuffix ()); - for (NumCtr = 0; - NumCtr < Gbl.Hierarchy.List[Hie_INS].Num; - NumCtr++) - { - Ctr = &Gbl.Hierarchy.List[Hie_INS].Lst[NumCtr]; - HTM_OPTION (HTM_Type_LONG,&Ctr->HieCod, - Ctr->HieCod == Gbl.Hierarchy.Node[Hie_CTR].HieCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, - HTM_OPTION_ENABLED, - "%s",Ctr->ShrtName); - } - HTM_SELECT_End (); - Frm_EndForm (); - - /* Free list of centers */ - Hie_FreeList (Hie_INS); - } - else // I can not move degree to another center - { - if (ViewType == Vie_VIEW) - { - Frm_BeginFormGoTo (ActSeeCtrInf); - ParCod_PutPar (ParCod_Ctr,Gbl.Hierarchy.Node[Hie_CTR].HieCod); - HTM_BUTTON_Submit_Begin (Str_BuildGoToTitle (Gbl.Hierarchy.Node[Hie_CTR].ShrtName), - "class=\"LB BT_LINK\""); - Str_FreeGoToTitle (); - } - Lgo_DrawLogo (Hie_CTR, - Gbl.Hierarchy.Node[Hie_CTR].HieCod, - Gbl.Hierarchy.Node[Hie_CTR].ShrtName, - 20,"LM"); - HTM_NBSP (); - HTM_Txt (Gbl.Hierarchy.Node[Hie_CTR].FullName); - if (ViewType == Vie_VIEW) - { - HTM_BUTTON_End (); + /* Put form to select center */ + Frm_BeginForm (ActChgDegCtrCfg); + HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,NULL, + "id=\"OthCtrCod\" name=\"OthCtrCod\"" + " class=\"INPUT_SHORT_NAME INPUT_%s\"", + The_GetSuffix ()); + for (NumCtr = 0; + NumCtr < Gbl.Hierarchy.List[Hie_INS].Num; + NumCtr++) + { + Ctr = &Gbl.Hierarchy.List[Hie_INS].Lst[NumCtr]; + HTM_OPTION (HTM_Type_LONG,&Ctr->HieCod, + Ctr->HieCod == Gbl.Hierarchy.Node[Hie_CTR].HieCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, + HTM_OPTION_ENABLED, + "%s",Ctr->ShrtName); + } + HTM_SELECT_End (); Frm_EndForm (); - } - } + + /* Free list of centers */ + Hie_FreeList (Hie_INS); + break; + } HTM_TD_End (); HTM_TR_End (); @@ -266,7 +276,7 @@ static void DegCfg_Center (Vie_ViewType_t ViewType,bool PutForm) /************** Show degree full name in degree configuration ****************/ /*****************************************************************************/ -static void DegCfg_FullName (bool PutForm) +static void DegCfg_FullName (Frm_PutForm_t PutForm) { HieCfg_Name (PutForm,Hie_DEG,Nam_FULL_NAME); } @@ -275,7 +285,7 @@ static void DegCfg_FullName (bool PutForm) /************** Show degree short name in degree configuration ***************/ /*****************************************************************************/ -static void DegCfg_ShrtName (bool PutForm) +static void DegCfg_ShrtName (Frm_PutForm_t PutForm) { HieCfg_Name (PutForm,Hie_DEG,Nam_SHRT_NAME); } @@ -284,7 +294,7 @@ static void DegCfg_ShrtName (bool PutForm) /***************** Show degree WWW in degree configuration *******************/ /*****************************************************************************/ -static void DegCfg_WWW (Vie_ViewType_t ViewType,bool PutForm) +static void DegCfg_WWW (Vie_ViewType_t ViewType,Frm_PutForm_t PutForm) { HieCfg_WWW (ViewType,PutForm,ActChgDegWWWCfg,Gbl.Hierarchy.Node[Hie_DEG].WWW); } diff --git a/swad_exam.c b/swad_exam.c index 1d067762..daf6d8f9 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -406,8 +406,7 @@ void Exa_SeeOneExam (void) Exa_GetExamDataByCod (&Exams.Exam); /***** Show exam *****/ - Exa_ShowOnlyOneExam (&Exams,&Session, - false); // Do not put form for session + Exa_ShowOnlyOneExam (&Exams,&Session,Frm_DONT_PUT_FORM); } /*****************************************************************************/ @@ -416,7 +415,7 @@ void Exa_SeeOneExam (void) void Exa_ShowOnlyOneExam (struct Exa_Exams *Exams, struct ExaSes_Session *Session, - bool PutFormSession) + Frm_PutForm_t PutFormSession) { Exa_ShowOnlyOneExamBegin (Exams,Session,PutFormSession); Exa_ShowOnlyOneExamEnd (); @@ -424,7 +423,7 @@ void Exa_ShowOnlyOneExam (struct Exa_Exams *Exams, void Exa_ShowOnlyOneExamBegin (struct Exa_Exams *Exams, struct ExaSes_Session *Session, - bool PutFormSession) + Frm_PutForm_t PutFormSession) { extern const char *Hlp_ASSESSMENT_Exams; extern const char *Txt_Exam; diff --git a/swad_exam.h b/swad_exam.h index 38a8cb51..56be42aa 100644 --- a/swad_exam.h +++ b/swad_exam.h @@ -44,10 +44,10 @@ bool Exa_CheckIfICanEditExams (void); void Exa_SeeOneExam (void); void Exa_ShowOnlyOneExam (struct Exa_Exams *Exams, struct ExaSes_Session *Session, - bool PutFormSession); + Frm_PutForm_t PutFormSession); void Exa_ShowOnlyOneExamBegin (struct Exa_Exams *Exams, struct ExaSes_Session *Session, - bool PutFormSession); + Frm_PutForm_t PutFormSession); void Exa_ShowOnlyOneExamEnd (void); void Exa_SetCurrentExaCod (long ExaCod); diff --git a/swad_exam_result.c b/swad_exam_result.c index 6811f5b6..ea30a63a 100644 --- a/swad_exam_result.c +++ b/swad_exam_result.c @@ -201,16 +201,15 @@ void ExaRes_ShowMyResultsInExa (void) Exa_GetExamDataByCod (&Exams.Exam); /***** Exam begin *****/ - Exa_ShowOnlyOneExamBegin (&Exams,&Session, - false); // Do not put form to start new session + Exa_ShowOnlyOneExamBegin (&Exams,&Session,Frm_DONT_PUT_FORM); - /***** List my sessions results in exam *****/ - if (asprintf (&Title,Txt_Results_of_exam_X,Exams.Exam.Title) < 0) - Err_NotEnoughMemoryExit (); - ExaRes_ShowResultsBegin (&Exams,Title,false); // Do not list exams to select - free (Title); - ExaRes_ListMyResultsInExa (&Exams); - ExaRes_ShowResultsEnd (); + /***** List my sessions results in exam *****/ + if (asprintf (&Title,Txt_Results_of_exam_X,Exams.Exam.Title) < 0) + Err_NotEnoughMemoryExit (); + ExaRes_ShowResultsBegin (&Exams,Title,false); // Do not list exams to select + free (Title); + ExaRes_ListMyResultsInExa (&Exams); + ExaRes_ShowResultsEnd (); /***** Exam end *****/ Exa_ShowOnlyOneExamEnd (); @@ -249,16 +248,15 @@ void ExaRes_ShowMyResultsInSes (void) ExaSes_GetSessionDataByCod (&Session); /***** Exam begin *****/ - Exa_ShowOnlyOneExamBegin (&Exams,&Session, - false); // Do not put form to start new session + Exa_ShowOnlyOneExamBegin (&Exams,&Session,Frm_DONT_PUT_FORM); - /***** List my sessions results in session *****/ - if (asprintf (&Title,Txt_Results_of_session_X,Session.Title) < 0) - Err_NotEnoughMemoryExit (); - ExaRes_ShowResultsBegin (&Exams,Title,false); // Do not list exams to select - free (Title); - ExaRes_ListMyResultsInSes (&Exams,Session.SesCod); - ExaRes_ShowResultsEnd (); + /***** List my sessions results in session *****/ + if (asprintf (&Title,Txt_Results_of_session_X,Session.Title) < 0) + Err_NotEnoughMemoryExit (); + ExaRes_ShowResultsBegin (&Exams,Title,false); // Do not list exams to select + free (Title); + ExaRes_ListMyResultsInSes (&Exams,Session.SesCod); + ExaRes_ShowResultsEnd (); /***** Exam end *****/ Exa_ShowOnlyOneExamEnd (); @@ -393,16 +391,15 @@ void ExaRes_ShowAllResultsInExa (void) Exa_GetExamDataByCod (&Exams.Exam); /***** Exam begin *****/ - Exa_ShowOnlyOneExamBegin (&Exams,&Session, - false); // Do not put form to start new session + Exa_ShowOnlyOneExamBegin (&Exams,&Session,Frm_DONT_PUT_FORM); - /***** List sessions results in exam *****/ - if (asprintf (&Title,Txt_Results_of_exam_X,Exams.Exam.Title) < 0) - Err_NotEnoughMemoryExit (); - ExaRes_ShowResultsBegin (&Exams,Title,false); // Do not list exams to select - free (Title); - ExaRes_ListAllResultsInExa (&Exams); - ExaRes_ShowResultsEnd (); + /***** List sessions results in exam *****/ + if (asprintf (&Title,Txt_Results_of_exam_X,Exams.Exam.Title) < 0) + Err_NotEnoughMemoryExit (); + ExaRes_ShowResultsBegin (&Exams,Title,false); // Do not list exams to select + free (Title); + ExaRes_ListAllResultsInExa (&Exams); + ExaRes_ShowResultsEnd (); /***** Exam end *****/ Exa_ShowOnlyOneExamEnd (); @@ -465,16 +462,15 @@ void ExaRes_ShowAllResultsInSes (void) ExaSes_GetSessionDataByCod (&Session); /***** Exam begin *****/ - Exa_ShowOnlyOneExamBegin (&Exams,&Session, - false); // Do not put form to start new session + Exa_ShowOnlyOneExamBegin (&Exams,&Session,Frm_DONT_PUT_FORM); - /***** List sessions results in session *****/ - if (asprintf (&Title,Txt_Results_of_session_X,Session.Title) < 0) - Err_NotEnoughMemoryExit (); - ExaRes_ShowResultsBegin (&Exams,Title,false); // Do not list exams to select - free (Title); - ExaRes_ListAllResultsInSes (&Exams,Session.SesCod); - ExaRes_ShowResultsEnd (); + /***** List sessions results in session *****/ + if (asprintf (&Title,Txt_Results_of_session_X,Session.Title) < 0) + Err_NotEnoughMemoryExit (); + ExaRes_ShowResultsBegin (&Exams,Title,false); // Do not list exams to select + free (Title); + ExaRes_ListAllResultsInSes (&Exams,Session.SesCod); + ExaRes_ShowResultsEnd (); /***** Exam end *****/ Exa_ShowOnlyOneExamEnd (); diff --git a/swad_exam_session.c b/swad_exam_session.c index 86627414..24e67cc3 100644 --- a/swad_exam_session.c +++ b/swad_exam_session.c @@ -137,7 +137,7 @@ void ExaSes_ResetSession (struct ExaSes_Session *Session) void ExaSes_ListSessions (struct Exa_Exams *Exams, struct ExaSes_Session *Session, - bool PutFormSession) + Frm_PutForm_t PutFormSession) { extern const char *Hlp_ASSESSMENT_Exams_sessions; extern const char *Txt_Sessions; @@ -183,7 +183,7 @@ void ExaSes_ListSessions (struct Exa_Exams *Exams, case Rol_NET: case Rol_TCH: case Rol_SYS_ADM: - if (PutFormSession && Session->SesCod <= 0) + if (PutFormSession == Frm_PUT_FORM && Session->SesCod <= 0) { /* Reset session */ ExaSes_ResetSession (Session); @@ -720,8 +720,7 @@ void ExaSes_ToggleVisResultsSesUsr (void) Exa_DB_ToggleVisResultsSesUsr (&Session); /***** Show current exam *****/ - Exa_ShowOnlyOneExam (&Exams,&Session, - false); // Do not put form for session + Exa_ShowOnlyOneExam (&Exams,&Session,Frm_DONT_PUT_FORM); } /*****************************************************************************/ @@ -809,8 +808,7 @@ void ExaSes_ReqRemSession (void) Session.Title); /***** Show current exam *****/ - Exa_ShowOnlyOneExam (&Exams,&Session, - false); // Do not put form for session + Exa_ShowOnlyOneExam (&Exams,&Session,Frm_DONT_PUT_FORM); } /*****************************************************************************/ @@ -855,8 +853,7 @@ void ExaSes_RemoveSession (void) Exa_GetExamDataByCod (&Exams.Exam); /***** Show current exam *****/ - Exa_ShowOnlyOneExam (&Exams,&Session, - false); // Do not put form for session + Exa_ShowOnlyOneExam (&Exams,&Session,Frm_DONT_PUT_FORM); } /*****************************************************************************/ @@ -894,8 +891,7 @@ static void ExaSes_HideUnhideSession (HidVis_HiddenOrVisible_t HiddenOrVisible) Exa_DB_HideUnhideSession (&Session,HiddenOrVisible); /***** Show current exam *****/ - Exa_ShowOnlyOneExam (&Exams,&Session, - false); // Do not put form for session + Exa_ShowOnlyOneExam (&Exams,&Session,Frm_DONT_PUT_FORM); } /*****************************************************************************/ @@ -1098,8 +1094,7 @@ void ExaSes_ReqCreatOrEditSes (void) } /***** Show exam *****/ - Exa_ShowOnlyOneExam (&Exams,&Session, - true); // Put form for session + Exa_ShowOnlyOneExam (&Exams,&Session,Frm_PUT_FORM); // Put form for session } /*****************************************************************************/ @@ -1181,8 +1176,7 @@ void ExaSes_ReceiveFormSession (void) Exa_GetExamDataByCod (&Exams.Exam); /***** Show current exam *****/ - Exa_ShowOnlyOneExam (&Exams,&Session, - false); // Do not put form for session + Exa_ShowOnlyOneExam (&Exams,&Session,Frm_DONT_PUT_FORM); } /*****************************************************************************/ diff --git a/swad_exam_session.h b/swad_exam_session.h index 01f972fa..39c22fcb 100644 --- a/swad_exam_session.h +++ b/swad_exam_session.h @@ -52,7 +52,7 @@ void ExaSes_ResetSession (struct ExaSes_Session *Session); void ExaSes_ListSessions (struct Exa_Exams *Exams, struct ExaSes_Session *Session, - bool PutFormSession); + Frm_PutForm_t PutFormSession); void ExaSes_GetSessionDataByCod (struct ExaSes_Session *Session); void ExaSes_ToggleVisResultsSesUsr (void); diff --git a/swad_form.h b/swad_form.h index abc826ca..7a9d50a6 100644 --- a/swad_form.h +++ b/swad_form.h @@ -44,11 +44,12 @@ #define Frm_MAX_BYTES_PARAM_LOCATION 256 #define Frm_MAX_BYTES_PARAMS_STR (Frm_MAX_BYTES_PARAM_ACTION + Frm_MAX_BYTES_PARAM_SESSION + Frm_MAX_BYTES_PARAM_LOCATION) +#define Frm_NUM_PUT_FORM 2 typedef enum { - Frm_DONT_PUT_FORM_TO_GO, - Frm_PUT_FORM_TO_GO, - } Frm_PutFormToGo_t; + Frm_DONT_PUT_FORM, + Frm_PUT_FORM, + } Frm_PutForm_t; /*****************************************************************************/ /***************************** Public prototypes *****************************/ diff --git a/swad_game.c b/swad_game.c index 1ddcba50..29328c9e 100644 --- a/swad_game.c +++ b/swad_game.c @@ -453,7 +453,7 @@ void Gam_SeeOneGame (void) void Gam_ShowOnlyOneGame (struct Gam_Games *Games, bool ListGameQuestions, - bool PutFormNewMatch) + Frm_PutForm_t PutFormNewMatch) { Gam_ShowOnlyOneGameBegin (Games,ListGameQuestions,PutFormNewMatch); Gam_ShowOnlyOneGameEnd (); @@ -461,7 +461,7 @@ void Gam_ShowOnlyOneGame (struct Gam_Games *Games, void Gam_ShowOnlyOneGameBegin (struct Gam_Games *Games, bool ListGameQuestions, - bool PutFormNewMatch) + Frm_PutForm_t PutFormNewMatch) { extern const char *Hlp_ASSESSMENT_Games; extern const char *Txt_Game; @@ -2169,7 +2169,7 @@ void Gam_ReqNewMatch (void) /***** Show game *****/ Gam_ShowOnlyOneGame (&Games, false, // Do not list game questions - true); // Put form to start new match + Frm_PUT_FORM); } /*****************************************************************************/ diff --git a/swad_game.h b/swad_game.h index 9961dfb6..6ea26ab1 100644 --- a/swad_game.h +++ b/swad_game.h @@ -117,10 +117,10 @@ void Gam_ListAllGames (struct Gam_Games *Games); void Gam_SeeOneGame (void); void Gam_ShowOnlyOneGame (struct Gam_Games *Games, bool ListGameQuestions, - bool PutFormNewMatch); + Frm_PutForm_t PutFormNewMatch); void Gam_ShowOnlyOneGameBegin (struct Gam_Games *Games, bool ListGameQuestions, - bool PutFormNewMatch); + Frm_PutForm_t PutFormNewMatch); void Gam_ShowOnlyOneGameEnd (void); void Gam_SetCurrentGamCod (long GamCod); diff --git a/swad_group.c b/swad_group.c index 143be4dc..091dcf45 100644 --- a/swad_group.c +++ b/swad_group.c @@ -1704,7 +1704,8 @@ void Grp_ShowLstGrpsToChgMyGrps (void) unsigned NumGrpTyp; unsigned NumGrpsThisTypeIBelong; unsigned NumGrpsIBelong = 0; - bool PutFormToChangeGrps = !Frm_CheckIfInside (); // Not inside another form (record card) + Frm_PutForm_t PutFormToChangeGrps = Frm_CheckIfInside () ? Frm_DONT_PUT_FORM : // Inside another form (record card)? + Frm_PUT_FORM; bool ICanEdit = !Frm_CheckIfInside () && (Gbl.Usrs.Me.Role.Logged == Rol_TCH || Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM); diff --git a/swad_hierarchy_config.c b/swad_hierarchy_config.c index f2f2dd0f..f719ecee 100644 --- a/swad_hierarchy_config.c +++ b/swad_hierarchy_config.c @@ -85,7 +85,8 @@ void HieCfg_Title (bool PutLink,Hie_Level_t Level) /******************* Show short/full name in configuration *******************/ /*****************************************************************************/ -void HieCfg_Name (bool PutForm,Hie_Level_t Level,Nam_ShrtOrFullName_t ShrtOrFull) +void HieCfg_Name (Frm_PutForm_t PutForm,Hie_Level_t Level, + Nam_ShrtOrFullName_t ShrtOrFull) { extern const char *Nam_Params[Nam_NUM_SHRT_FULL_NAMES]; extern unsigned Nam_MaxChars[Nam_NUM_SHRT_FULL_NAMES]; @@ -103,7 +104,12 @@ void HieCfg_Name (bool PutForm,Hie_Level_t Level,Nam_ShrtOrFullName_t ShrtOrFull [Hie_CRS][Nam_SHRT_NAME] = ActRenCrsShoCfg, [Hie_CRS][Nam_FULL_NAME] = ActRenCrsFulCfg, }; - char *Name[Nam_NUM_SHRT_FULL_NAMES] = + const char *Id[Frm_NUM_PUT_FORM] = + { + [Frm_DONT_PUT_FORM] = NULL, + [Frm_PUT_FORM ] = Nam_Params[ShrtOrFull], + }; + const char *Name[Nam_NUM_SHRT_FULL_NAMES] = { [Nam_SHRT_NAME] = Gbl.Hierarchy.Node[Level].ShrtName, [Nam_FULL_NAME] = Gbl.Hierarchy.Node[Level].FullName, @@ -113,31 +119,33 @@ void HieCfg_Name (bool PutForm,Hie_Level_t Level,Nam_ShrtOrFullName_t ShrtOrFull HTM_TR_Begin (NULL); /* Label */ - Frm_LabelColumn ("RT",PutForm ? Nam_Params[ShrtOrFull] : - NULL, + Frm_LabelColumn ("RT",Id[PutForm], ShrtOrFull == Nam_SHRT_NAME ? Txt_Short_name : - *Hie_TxtLevel[Level]); + *Hie_TxtLevel[Level]); /* Data */ HTM_TD_Begin ("class=\"LB DAT_STRONG_%s\"",The_GetSuffix ()); - if (PutForm) - { - /* Form to change full name */ - Frm_BeginForm (Action[Level][ShrtOrFull]); - HTM_INPUT_TEXT (Nam_Params[ShrtOrFull], - Nam_MaxChars[ShrtOrFull], - Name[ShrtOrFull], - HTM_SUBMIT_ON_CHANGE, - "id=\"%s\"" - " class=\"%s INPUT_%s\"" - " required=\"required\"", - Nam_Params[ShrtOrFull], - Nam_Classes[ShrtOrFull], - The_GetSuffix ()); - Frm_EndForm (); - } - else // I can not edit full name - HTM_Txt (Name[ShrtOrFull]); + switch (PutForm) + { + case Frm_DONT_PUT_FORM: // I can not edit full name + HTM_Txt (Name[ShrtOrFull]); + break; + case Frm_PUT_FORM: + /* Form to change full name */ + Frm_BeginForm (Action[Level][ShrtOrFull]); + HTM_INPUT_TEXT (Nam_Params[ShrtOrFull], + Nam_MaxChars[ShrtOrFull], + Name[ShrtOrFull], + HTM_SUBMIT_ON_CHANGE, + "id=\"%s\"" + " class=\"%s INPUT_%s\"" + " required=\"required\"", + Nam_Params[ShrtOrFull], + Nam_Classes[ShrtOrFull], + The_GetSuffix ()); + Frm_EndForm (); + break; + } HTM_TD_End (); HTM_TR_End (); @@ -147,43 +155,47 @@ void HieCfg_Name (bool PutForm,Hie_Level_t Level,Nam_ShrtOrFullName_t ShrtOrFull /************************* Show web in configuration *************************/ /*****************************************************************************/ -void HieCfg_WWW (Vie_ViewType_t ViewType,bool PutForm,Act_Action_t NextAction, - const char WWW[Cns_MAX_BYTES_WWW + 1]) +void HieCfg_WWW (Vie_ViewType_t ViewType,Frm_PutForm_t PutForm, + Act_Action_t NextAction,const char WWW[Cns_MAX_BYTES_WWW + 1]) { extern const char *Txt_Web; + static const char *Id[Frm_NUM_PUT_FORM] = + { + [Frm_DONT_PUT_FORM] = NULL, + [Frm_PUT_FORM ] = "WWW", + }; /***** Web *****/ HTM_TR_Begin (NULL); /* Label */ - Frm_LabelColumn ("RT",PutForm ? "WWW" : - NULL, - Txt_Web); + Frm_LabelColumn ("RT",Id[PutForm],Txt_Web); /* Data */ HTM_TD_Begin ("class=\"LB DAT_%s\"",The_GetSuffix ()); - if (PutForm) - { - /* Form to change web */ - Frm_BeginForm (NextAction); - HTM_INPUT_URL ("WWW",WWW,HTM_SUBMIT_ON_CHANGE, - "id=\"WWW\" class=\"INPUT_WWW_WIDE INPUT_%s\"" - " required=\"required\"", - The_GetSuffix ()); - Frm_EndForm (); - } - else // I can not change web - { - HTM_DIV_Begin ("class=\"EXTERNAL_WWW_FULL\""); - if (ViewType == Vie_VIEW) - HTM_A_Begin ("href=\"%s\" target=\"_blank\"" - " class=\"DAT_%s\"", - WWW,The_GetSuffix ()); - HTM_Txt (WWW); - if (ViewType == Vie_VIEW) - HTM_A_End (); - HTM_DIV_End (); - } + switch (PutForm) + { + case Frm_DONT_PUT_FORM: // I can not change web + HTM_DIV_Begin ("class=\"EXTERNAL_WWW_FULL\""); + if (ViewType == Vie_VIEW) + HTM_A_Begin ("href=\"%s\" target=\"_blank\"" + " class=\"DAT_%s\"", + WWW,The_GetSuffix ()); + HTM_Txt (WWW); + if (ViewType == Vie_VIEW) + HTM_A_End (); + HTM_DIV_End (); + break; + case Frm_PUT_FORM: + /* Form to change web */ + Frm_BeginForm (NextAction); + HTM_INPUT_URL ("WWW",WWW,HTM_SUBMIT_ON_CHANGE, + "id=\"WWW\" class=\"INPUT_WWW_WIDE INPUT_%s\"" + " required=\"required\"", + The_GetSuffix ()); + Frm_EndForm (); + break; + } HTM_TD_End (); HTM_TR_End (); @@ -237,7 +249,7 @@ void HieCfg_Shortcut (Vie_ViewType_t ViewType,ParCod_Param_t ParCode,long HieCod /************************** Show number of centers ***************************/ /*****************************************************************************/ -void HieCfg_NumCtrs (unsigned NumCtrs,bool PutForm) +void HieCfg_NumCtrs (unsigned NumCtrs,Frm_PutForm_t PutForm) { extern const char *Txt_Centers; extern const char *Txt_Centers_of_INSTITUTION_X; @@ -251,7 +263,7 @@ void HieCfg_NumCtrs (unsigned NumCtrs,bool PutForm) /* Data */ HTM_TD_Begin ("class=\"LB DAT_%s\"",The_GetSuffix ()); - if (PutForm) + if (PutForm == Frm_PUT_FORM) { Frm_BeginFormGoTo (ActSeeCtr); ParCod_PutPar (ParCod_Ins,Gbl.Hierarchy.Node[Hie_INS].HieCod); @@ -262,7 +274,7 @@ void HieCfg_NumCtrs (unsigned NumCtrs,bool PutForm) free (Title); } HTM_Unsigned (NumCtrs); - if (PutForm) + if (PutForm == Frm_PUT_FORM) { HTM_BUTTON_End (); Frm_EndForm (); diff --git a/swad_hierarchy_config.h b/swad_hierarchy_config.h index 08bd4bb2..75fa7e17 100644 --- a/swad_hierarchy_config.h +++ b/swad_hierarchy_config.h @@ -34,11 +34,12 @@ /*****************************************************************************/ void HieCfg_Title (bool PutLink,Hie_Level_t LogoScope); -void HieCfg_Name (bool PutForm,Hie_Level_t Level,Nam_ShrtOrFullName_t ShrtOrFull); -void HieCfg_WWW (Vie_ViewType_t ViewType,bool PutForm,Act_Action_t NextAction, - const char WWW[Cns_MAX_BYTES_WWW + 1]); +void HieCfg_Name (Frm_PutForm_t PutForm,Hie_Level_t Level, + Nam_ShrtOrFullName_t ShrtOrFull); +void HieCfg_WWW (Vie_ViewType_t ViewType,Frm_PutForm_t PutForm, + Act_Action_t NextAction,const char WWW[Cns_MAX_BYTES_WWW + 1]); void HieCfg_Shortcut (Vie_ViewType_t ViewType,ParCod_Param_t ParCode,long HieCod); -void HieCfg_NumCtrs (unsigned NumCtrs,bool PutForm); +void HieCfg_NumCtrs (unsigned NumCtrs,Frm_PutForm_t PutForm); void HieCfg_NumCtrsWithMap (unsigned NumCtrs,unsigned NumCtrsWithMap); void HieCfg_QR (ParCod_Param_t ParCode,long HieCod); void HieCfg_NumUsrsInCrss (Hie_Level_t Level,long Cod,Rol_Role_t Role); diff --git a/swad_indicator.c b/swad_indicator.c index 8bc67f35..301fd032 100644 --- a/swad_indicator.c +++ b/swad_indicator.c @@ -85,7 +85,8 @@ static void Ind_GetNumCoursesWithIndicators (unsigned NumCrssWithIndicatorYes[1 unsigned NumCrss,MYSQL_RES *mysql_res); static void Ind_ShowNumCoursesWithIndicators (const struct Ind_Indicators *Indicators, unsigned NumCrssWithIndicatorYes[1 + Ind_NUM_INDICATORS], - unsigned NumCrss,bool PutForm); + unsigned NumCrss, + Frm_PutForm_t PutForm); static void Ind_ShowTableOfCoursesWithIndicators (const struct Ind_Indicators *Indicators, Ind_IndicatorsLayout_t IndicatorsLayout, unsigned NumCrss,MYSQL_RES *mysql_res); @@ -434,7 +435,8 @@ static void Ind_GetNumCoursesWithIndicators (unsigned NumCrssWithIndicatorYes[1 static void Ind_ShowNumCoursesWithIndicators (const struct Ind_Indicators *Indicators, unsigned NumCrssWithIndicatorYes[1 + Ind_NUM_INDICATORS], - unsigned NumCrss,bool PutForm) + unsigned NumCrss, + Frm_PutForm_t PutForm) { extern const char *Txt_Indicators; extern const char *Txt_Courses; @@ -455,7 +457,7 @@ static void Ind_ShowNumCoursesWithIndicators (const struct Ind_Indicators *Indic /* Header */ HTM_TR_Begin (NULL); - if (PutForm) + if (PutForm == Frm_PUT_FORM) HTM_TH_Empty (1); HTM_TH (Txt_Indicators,HTM_HEAD_RIGHT); HTM_TH_Span (Txt_Courses ,HTM_HEAD_RIGHT,1,2,NULL); @@ -469,7 +471,7 @@ static void Ind_ShowNumCoursesWithIndicators (const struct Ind_Indicators *Indic ClassNormal; HTM_TR_Begin (NULL); - if (PutForm) + if (PutForm == Frm_PUT_FORM) { HTM_TD_Begin ("class=\"%s\"",Class); HTM_INPUT_CHECKBOX ("Indicators",HTM_SUBMIT_ON_CHANGE, @@ -503,7 +505,7 @@ static void Ind_ShowNumCoursesWithIndicators (const struct Ind_Indicators *Indic /***** Write total of courses *****/ HTM_TR_Begin (NULL); - if (PutForm) + if (PutForm == Frm_PUT_FORM) HTM_TD_Empty (1); HTM_TD_LINE_TOP_Txt (Txt_Total); diff --git a/swad_institution_config.c b/swad_institution_config.c index b1a9b377..b991a9ec 100644 --- a/swad_institution_config.c +++ b/swad_institution_config.c @@ -65,10 +65,10 @@ extern struct Globals Gbl; static void InsCfg_Configuration (Vie_ViewType_t ViewType); static void InsCfg_PutIconsToPrintAndUpload (__attribute__((unused)) void *Args); static void InsCfg_Map (void); -static void InsCfg_Country (Vie_ViewType_t ViewType,bool PutForm); -static void InsCfg_FullName (bool PutForm); -static void InsCfg_ShrtName (bool PutForm); -static void InsCfg_WWW (Vie_ViewType_t ViewType,bool PutForm); +static void InsCfg_Country (Vie_ViewType_t ViewType,Frm_PutForm_t PutForm); +static void InsCfg_FullName (Frm_PutForm_t PutForm); +static void InsCfg_ShrtName (Frm_PutForm_t PutForm); +static void InsCfg_WWW (Vie_ViewType_t ViewType,Frm_PutForm_t PutForm); static void InsCfg_Shortcut (Vie_ViewType_t ViewType); static void InsCfg_QR (void); static void InsCfg_NumUsrs (void); @@ -105,9 +105,9 @@ static void InsCfg_Configuration (Vie_ViewType_t ViewType) { extern const char *Hlp_INSTITUTION_Information; bool PutLink; - bool PutFormCty; - bool PutFormName; - bool PutFormWWW; + Frm_PutForm_t PutFormCty; + Frm_PutForm_t PutFormName; + Frm_PutForm_t PutFormWWW; unsigned NumCtrs; unsigned NumCtrsWithMap; @@ -118,8 +118,12 @@ static void InsCfg_Configuration (Vie_ViewType_t ViewType) /***** Initializations *****/ PutLink = ViewType == Vie_VIEW && Gbl.Hierarchy.Node[Hie_INS].WWW[0]; PutFormCty = - PutFormName = ViewType == Vie_VIEW && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM; - PutFormWWW = ViewType == Vie_VIEW && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM; + PutFormName = (ViewType == Vie_VIEW && + Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) ? Frm_PUT_FORM : + Frm_DONT_PUT_FORM; + PutFormWWW = (ViewType == Vie_VIEW && + Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) ? Frm_PUT_FORM : + Frm_DONT_PUT_FORM; /***** Begin box *****/ Box_BoxBegin (NULL,NULL, @@ -297,12 +301,17 @@ static void InsCfg_Map (void) /***************** Show country in institution configuration *****************/ /*****************************************************************************/ -static void InsCfg_Country (Vie_ViewType_t ViewType,bool PutForm) +static void InsCfg_Country (Vie_ViewType_t ViewType,Frm_PutForm_t PutForm) { extern const char *Par_CodeStr[]; extern const char *Txt_Country; unsigned NumCty; const struct Hie_Node *Cty; + const char *Id[Frm_NUM_PUT_FORM] = + { + [Frm_DONT_PUT_FORM] = NULL, + [Frm_PUT_FORM ] = Par_CodeStr[ParCod_OthCty], + }; /***** Get list of countries *****/ Cty_GetBasicListOfCountries (); @@ -311,53 +320,52 @@ static void InsCfg_Country (Vie_ViewType_t ViewType,bool PutForm) HTM_TR_Begin (NULL); /* Label */ - Frm_LabelColumn ("RT",PutForm ? Par_CodeStr[ParCod_OthCty] : - NULL, - Txt_Country); + Frm_LabelColumn ("RT",Id[PutForm],Txt_Country); /* Data */ HTM_TD_Begin ("class=\"LT DAT_%s\"",The_GetSuffix ()); - if (PutForm) - { - /* Put form to select country */ - Frm_BeginForm (ActChgInsCtyCfg); - HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,NULL, - "id=\"OthCtyCod\" name=\"OthCtyCod\"" - " class=\"INPUT_SHORT_NAME INPUT_%s\"", - The_GetSuffix ()); - for (NumCty = 0; - NumCty < Gbl.Hierarchy.List[Hie_SYS].Num; - NumCty++) - { - Cty = &Gbl.Hierarchy.List[Hie_SYS].Lst[NumCty]; - HTM_OPTION (HTM_Type_LONG,&Cty->HieCod, - Cty->HieCod == Gbl.Hierarchy.Node[Hie_CTY].HieCod ? HTM_OPTION_SELECTED : - HTM_OPTION_UNSELECTED, - HTM_OPTION_ENABLED, - "%s",Cty->FullName); - } - HTM_SELECT_End (); - Frm_EndForm (); - } - else // I can not move institution to another country - { - if (ViewType == Vie_VIEW) - { - Frm_BeginFormGoTo (ActSeeCtyInf); - ParCod_PutPar (ParCod_Cty,Gbl.Hierarchy.Node[Hie_CTY].HieCod); - HTM_BUTTON_Submit_Begin (Str_BuildGoToTitle (Gbl.Hierarchy.Node[Hie_CTY].FullName), - "class=\"BT_LINK\""); - Str_FreeGoToTitle (); - } - Cty_DrawCountryMap (&Gbl.Hierarchy.Node[Hie_CTY],"COUNTRY_MAP_TINY"); - HTM_NBSP (); - HTM_Txt (Gbl.Hierarchy.Node[Hie_CTY].FullName); - if (ViewType == Vie_VIEW) - { - HTM_BUTTON_End (); + switch (PutForm) + { + case Frm_DONT_PUT_FORM: // I can not move institution to another country + if (ViewType == Vie_VIEW) + { + Frm_BeginFormGoTo (ActSeeCtyInf); + ParCod_PutPar (ParCod_Cty,Gbl.Hierarchy.Node[Hie_CTY].HieCod); + HTM_BUTTON_Submit_Begin (Str_BuildGoToTitle (Gbl.Hierarchy.Node[Hie_CTY].FullName), + "class=\"BT_LINK\""); + Str_FreeGoToTitle (); + } + Cty_DrawCountryMap (&Gbl.Hierarchy.Node[Hie_CTY],"COUNTRY_MAP_TINY"); + HTM_NBSP (); + HTM_Txt (Gbl.Hierarchy.Node[Hie_CTY].FullName); + if (ViewType == Vie_VIEW) + { + HTM_BUTTON_End (); + Frm_EndForm (); + } + break; + case Frm_PUT_FORM: + /* Put form to select country */ + Frm_BeginForm (ActChgInsCtyCfg); + HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,NULL, + "id=\"OthCtyCod\" name=\"OthCtyCod\"" + " class=\"INPUT_SHORT_NAME INPUT_%s\"", + The_GetSuffix ()); + for (NumCty = 0; + NumCty < Gbl.Hierarchy.List[Hie_SYS].Num; + NumCty++) + { + Cty = &Gbl.Hierarchy.List[Hie_SYS].Lst[NumCty]; + HTM_OPTION (HTM_Type_LONG,&Cty->HieCod, + Cty->HieCod == Gbl.Hierarchy.Node[Hie_CTY].HieCod ? HTM_OPTION_SELECTED : + HTM_OPTION_UNSELECTED, + HTM_OPTION_ENABLED, + "%s",Cty->FullName); + } + HTM_SELECT_End (); Frm_EndForm (); - } - } + break; + } HTM_TD_End (); HTM_TR_End (); @@ -369,7 +377,7 @@ static void InsCfg_Country (Vie_ViewType_t ViewType,bool PutForm) /********* Show institution full name in institution configuration ***********/ /*****************************************************************************/ -static void InsCfg_FullName (bool PutForm) +static void InsCfg_FullName (Frm_PutForm_t PutForm) { HieCfg_Name (PutForm,Hie_INS,Nam_FULL_NAME); } @@ -378,7 +386,7 @@ static void InsCfg_FullName (bool PutForm) /********* Show institution short name in institution configuration **********/ /*****************************************************************************/ -static void InsCfg_ShrtName (bool PutForm) +static void InsCfg_ShrtName (Frm_PutForm_t PutForm) { HieCfg_Name (PutForm,Hie_INS,Nam_SHRT_NAME); } @@ -387,7 +395,7 @@ static void InsCfg_ShrtName (bool PutForm) /************ Show institution WWW in institution configuration **************/ /*****************************************************************************/ -static void InsCfg_WWW (Vie_ViewType_t ViewType,bool PutForm) +static void InsCfg_WWW (Vie_ViewType_t ViewType,Frm_PutForm_t PutForm) { HieCfg_WWW (ViewType,PutForm,ActChgInsWWWCfg,Gbl.Hierarchy.Node[Hie_INS].WWW); } diff --git a/swad_match.c b/swad_match.c index b9101992..e86e3cb7 100644 --- a/swad_match.c +++ b/swad_match.c @@ -269,8 +269,7 @@ void Mch_ResetMatch (struct Mch_Match *Match) /************************* List the matches of a game ************************/ /*****************************************************************************/ -void Mch_ListMatches (struct Gam_Games *Games, - bool PutFormNewMatch) +void Mch_ListMatches (struct Gam_Games *Games,Frm_PutForm_t PutFormNewMatch) { extern const char *Hlp_ASSESSMENT_Games_matches; extern const char *Txt_Matches; @@ -315,7 +314,7 @@ void Mch_ListMatches (struct Gam_Games *Games, case Rol_NET: case Rol_TCH: case Rol_SYS_ADM: - if (PutFormNewMatch) + if (PutFormNewMatch == Frm_PUT_FORM) Mch_PutFormNewMatch (&Games->Game); // Form to fill in data and start playing a new match break; default: @@ -904,7 +903,7 @@ void Mch_ToggleVisResultsMchUsr (void) /***** Show current game *****/ Gam_ShowOnlyOneGame (&Games, false, // Do not list game questions - false); // Do not put form to start new match + Frm_DONT_PUT_FORM); } /*****************************************************************************/ @@ -1020,7 +1019,7 @@ void Mch_ReqRemMatch (void) /***** Show current game *****/ Gam_ShowOnlyOneGame (&Games, false, // Do not list game questions - false); // Do not put form to start new match + Frm_DONT_PUT_FORM); } /*****************************************************************************/ @@ -1055,7 +1054,7 @@ void Mch_RemoveMatch (void) /***** Show current game *****/ Gam_ShowOnlyOneGame (&Games, false, // Do not list game questions - false); // Do not put form to start new match + Frm_DONT_PUT_FORM); } /*****************************************************************************/ @@ -1144,7 +1143,7 @@ void Mch_EditMatch (void) /***** Show current game *****/ Gam_ShowOnlyOneGame (&Games, false, // Do not list game questions - false); // Do not put form to start new match + Frm_DONT_PUT_FORM); } /*****************************************************************************/ @@ -1431,7 +1430,7 @@ void Mch_ChangeMatch (void) /***** Show current game *****/ Gam_ShowOnlyOneGame (&Games, false, // Do not list game questions - false); // Do not put form to start new match + Frm_DONT_PUT_FORM); } /*****************************************************************************/ @@ -2332,10 +2331,21 @@ static void Mch_PutFormsCountdown (struct Mch_Match *Match) static void Mch_PutFormCountdown (struct Mch_Match *Match,long Seconds,const char *Color) { extern const char *Txt_Countdown; + static const char *fmt[Frm_NUM_PUT_FORM] = + { + [Frm_DONT_PUT_FORM] = "class=\"BT_LINK_OFF MCH_BUTTON_HIDDEN\"", + [Frm_PUT_FORM ] = "class=\"BT_LINK MCH_BUTTON_ON\"", + }; char *OnSubmit; - bool PutForm = Match->Status.Showing != Mch_END; + Frm_PutForm_t PutForm = (Match->Status.Showing != Mch_END) ? Frm_PUT_FORM : + Frm_DONT_PUT_FORM; + const char *Title[Frm_NUM_PUT_FORM] = + { + [Frm_DONT_PUT_FORM] = NULL, + [Frm_PUT_FORM ] = Txt_Countdown, + }; - if (PutForm) + if (PutForm == Frm_PUT_FORM) { /***** Begin form *****/ if (asprintf (&OnSubmit,"updateMatchTch('match_left'," @@ -2350,10 +2360,7 @@ static void Mch_PutFormCountdown (struct Mch_Match *Match,long Seconds,const cha /***** Put icon *****/ HTM_DIV_Begin ("class=\"MCH_SMALLBUTTON_CONT %s\"",Color); - HTM_BUTTON_Submit_Begin (PutForm ? Txt_Countdown : - NULL, - PutForm ? "class=\"BT_LINK MCH_BUTTON_ON\"" : - "class=\"BT_LINK_OFF MCH_BUTTON_HIDDEN\""); + HTM_BUTTON_Submit_Begin (Title[PutForm],fmt[PutForm]); HTM_NBSP (); if (Seconds >= 0) @@ -2369,7 +2376,7 @@ static void Mch_PutFormCountdown (struct Mch_Match *Match,long Seconds,const cha HTM_DIV_End (); /***** End form *****/ - if (PutForm) + if (PutForm == Frm_PUT_FORM) { Frm_EndForm (); free (OnSubmit); diff --git a/swad_match.h b/swad_match.h index 811e017c..4e5004f7 100644 --- a/swad_match.h +++ b/swad_match.h @@ -94,8 +94,7 @@ long Mch_GetMchCodBeingPlayed (void); void Mch_ResetMatch (struct Mch_Match *Match); -void Mch_ListMatches (struct Gam_Games *Games, - bool PutFormNewMatch); +void Mch_ListMatches (struct Gam_Games *Games,Frm_PutForm_t PutFormNewMatch); void Mch_GetMatchDataByCod (struct Mch_Match *Match); void Mch_ToggleVisResultsMchUsr (void); diff --git a/swad_match_result.c b/swad_match_result.c index 3a9cd43a..9d30b517 100644 --- a/swad_match_result.c +++ b/swad_match_result.c @@ -167,7 +167,7 @@ void MchRes_ShowMyMchResultsInGam (void) /***** Game begin *****/ Gam_ShowOnlyOneGameBegin (&Games, false, // Do not list game questions - false); // Do not put form to start new match + Frm_DONT_PUT_FORM); /***** List my matches results in game *****/ if (asprintf (&Title,Txt_Results_of_game_X,Games.Game.Title) < 0) @@ -217,7 +217,7 @@ void MchRes_ShowMyMchResultsInMch (void) /***** Game begin *****/ Gam_ShowOnlyOneGameBegin (&Games, false, // Do not list game questions - false); // Do not put form to start new match + Frm_DONT_PUT_FORM); /***** List my matches results in match *****/ if (asprintf (&Title,Txt_Results_of_match_X,Match.Title) < 0) @@ -360,7 +360,7 @@ void MchRes_ShowAllMchResultsInGam (void) /***** Game begin *****/ Gam_ShowOnlyOneGameBegin (&Games, false, // Do not list game questions - false); // Do not put form to start new match + Frm_DONT_PUT_FORM); /***** List matches results in game *****/ if (asprintf (&Title,Txt_Results_of_game_X,Games.Game.Title) < 0) @@ -432,7 +432,7 @@ void MchRes_ShowAllMchResultsInMch (void) /***** Game begin *****/ Gam_ShowOnlyOneGameBegin (&Games, false, // Do not list game questions - false); // Do not put form to start new match + Frm_DONT_PUT_FORM); /***** List matches results in match *****/ if (asprintf (&Title,Txt_Results_of_match_X,Match.Title) < 0) diff --git a/swad_name.c b/swad_name.c index 358097bc..e841e189 100644 --- a/swad_name.c +++ b/swad_name.c @@ -106,7 +106,7 @@ void Nam_NewShortAndFullNames (const char *Names[Nam_NUM_SHRT_FULL_NAMES]) void Nam_ExistingShortAndFullNames (const Act_Action_t ActionRename[Nam_NUM_SHRT_FULL_NAMES], ParCod_Param_t ParCod,long Cod, const char *Names[Nam_NUM_SHRT_FULL_NAMES], - bool PutForm) + Frm_PutForm_t PutForm) { Nam_ShrtOrFullName_t ShrtOrFull; @@ -115,19 +115,22 @@ void Nam_ExistingShortAndFullNames (const Act_Action_t ActionRename[Nam_NUM_SHRT ShrtOrFull++) { HTM_TD_Begin ("class=\"LM DAT_%s\"",The_GetSuffix ()); - if (PutForm) - { - Frm_BeginForm (ActionRename[ShrtOrFull]); - ParCod_PutPar (ParCod,Cod); - HTM_INPUT_TEXT (Nam_Params[ShrtOrFull],Nam_MaxChars[ShrtOrFull], - Names[ShrtOrFull], - HTM_SUBMIT_ON_CHANGE, - "class=\"%s INPUT_%s\" required=\"required\"", - Nam_Classes[ShrtOrFull],The_GetSuffix ()); - Frm_EndForm (); - } - else - HTM_Txt (Names[ShrtOrFull]); + switch (PutForm) + { + case Frm_DONT_PUT_FORM: + HTM_Txt (Names[ShrtOrFull]); + break; + case Frm_PUT_FORM: + Frm_BeginForm (ActionRename[ShrtOrFull]); + ParCod_PutPar (ParCod,Cod); + HTM_INPUT_TEXT (Nam_Params[ShrtOrFull],Nam_MaxChars[ShrtOrFull], + Names[ShrtOrFull], + HTM_SUBMIT_ON_CHANGE, + "class=\"%s INPUT_%s\" required=\"required\"", + Nam_Classes[ShrtOrFull],The_GetSuffix ()); + Frm_EndForm (); + break; + } HTM_TD_End (); } } diff --git a/swad_name.h b/swad_name.h index 39520908..01a85e98 100644 --- a/swad_name.h +++ b/swad_name.h @@ -28,6 +28,7 @@ /*****************************************************************************/ #include "swad_action.h" +#include "swad_form.h" #include "swad_parameter_code.h" #include "swad_string.h" @@ -64,7 +65,7 @@ void Nam_NewShortAndFullNames (const char *Names[Nam_NUM_SHRT_FULL_NAMES]); void Nam_ExistingShortAndFullNames (const Act_Action_t ActionRename[Nam_NUM_SHRT_FULL_NAMES], ParCod_Param_t ParCod,long Cod, const char *Names[Nam_NUM_SHRT_FULL_NAMES], - bool PutForm); + Frm_PutForm_t PutForm); bool Nam_CheckIfNameExists (bool (*FuncToCheck) (const char *FldName,const char *Name, long Cod,long PrtCod,unsigned Year), diff --git a/swad_notification.h b/swad_notification.h index 685d6f65..ce05b2a5 100644 --- a/swad_notification.h +++ b/swad_notification.h @@ -109,8 +109,6 @@ typedef enum Ntf_STATUS_EMAIL_SENT = 3, // --11 (Status & Ntf_STATUS_BIT_EMAIL) && (Status & Ntf_STATUS_BIT_SENT) } Ntf_StatusTxt_t; - -#define Ntf_NUM_GET_CONTENT 2 typedef enum { Ntf_DONT_GET_CONTENT = 0, diff --git a/swad_program_resource.c b/swad_program_resource.c index 94f8db6b..de6bb334 100644 --- a/swad_program_resource.c +++ b/swad_program_resource.c @@ -407,7 +407,7 @@ static void PrgRsc_WriteRowViewResource (unsigned NumRsc, The_GetSuffix (),The_GetColorRows1 (1)); HTM_Txt (Item->Resource.Title); HTM_BR (); - Rsc_WriteLinkName (&Item->Resource.Link,Frm_PUT_FORM_TO_GO); + Rsc_WriteLinkName (&Item->Resource.Link,Frm_PUT_FORM); HTM_TD_End (); /***** End row *****/ @@ -456,7 +456,7 @@ static void PrgRsc_WriteRowEditResource (unsigned NumRsc,unsigned NumResources, { case Vie_VIEW: /* Show current link */ - Rsc_WriteLinkName (&Item->Resource.Link,Frm_PUT_FORM_TO_GO); + Rsc_WriteLinkName (&Item->Resource.Link,Frm_PUT_FORM); break; case Vie_EDIT: /* Show clipboard to change resource link */ diff --git a/swad_project.c b/swad_project.c index dcc014cb..2d1c89cf 100644 --- a/swad_project.c +++ b/swad_project.c @@ -1692,7 +1692,7 @@ static void Prj_ShowReviewStatus (struct Prj_Projects *Projects, extern const char *Txt_PROJECT_REVIEW_SINGUL[Prj_NUM_REVIEW_STATUS]; extern const char *Txt_Comments; extern const char *Txt_Save_changes; - bool PutForm; + Frm_PutForm_t PutForm; static unsigned UniqueId = 0; char *Id; @@ -1700,10 +1700,11 @@ static void Prj_ShowReviewStatus (struct Prj_Projects *Projects, switch (Projects->View) { case Prj_PRINT_ONE_PROJECT: - PutForm = false; + PutForm = Frm_DONT_PUT_FORM; break; default: - PutForm = Prj_CheckIfICanReviewProjects (); + PutForm = Prj_CheckIfICanReviewProjects () ? Frm_PUT_FORM : + Frm_DONT_PUT_FORM; break; } @@ -1735,17 +1736,20 @@ static void Prj_ShowReviewStatus (struct Prj_Projects *Projects, break; } - if (PutForm) + switch (PutForm) { - /***** Begin form to change review status and text *****/ - Frm_BeginFormAnchor (ActChgPrjRev,Anchor); - Prj_PutCurrentPars (Projects); + case Frm_DONT_PUT_FORM: + HTM_Txt (Txt_PROJECT_REVIEW_SINGUL[Projects->Prj.Review.Status]); + break; + case Frm_PUT_FORM: + /***** Begin form to change review status and text *****/ + Frm_BeginFormAnchor (ActChgPrjRev,Anchor); + Prj_PutCurrentPars (Projects); - /***** Selector to change review status *****/ - Prj_PutSelectorReviewStatus (Projects); + /***** Selector to change review status *****/ + Prj_PutSelectorReviewStatus (Projects); + break; } - else - HTM_Txt (Txt_PROJECT_REVIEW_SINGUL[Projects->Prj.Review.Status]); HTM_NBSP (); Ico_PutIconOff (ReviewIcon[Projects->Prj.Review.Status].Icon, @@ -1776,47 +1780,51 @@ static void Prj_ShowReviewStatus (struct Prj_Projects *Projects, Prj_PutWarningIcon (); /***** Revision text *****/ - if (PutForm) + switch (PutForm) { - /* Show text form */ - HTM_BR (); - HTM_TEXTAREA_Begin ("name=\"ReviewTxt\" rows=\"1\"" - " class=\"TITLE_DESCRIPTION_WIDTH INPUT_%s\"" - " placeholder=\"%s…\"" - " onchange=\"unhideElement('prj_rev_%ld');return false;\"", - The_GetSuffix (),Txt_Comments, - Projects->Prj.PrjCod); + case Frm_DONT_PUT_FORM: + if (Projects->Prj.Review.Txt[0]) + { + /* Change text format */ + Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, + Projects->Prj.Review.Txt,Cns_MAX_BYTES_TEXT, + Str_DONT_REMOVE_SPACES); + switch (Projects->View) + { + case Prj_PRINT_ONE_PROJECT: + break; + default: + ALn_InsertLinks (Projects->Prj.Review.Txt,Cns_MAX_BYTES_TEXT,60); // Insert links + break; + } + + /* Show text */ + HTM_BR (); HTM_Txt (Projects->Prj.Review.Txt); - HTM_TEXTAREA_End (); + } + break; + case Frm_PUT_FORM: + /* Show text form */ + HTM_BR (); + HTM_TEXTAREA_Begin ("name=\"ReviewTxt\" rows=\"1\"" + " class=\"TITLE_DESCRIPTION_WIDTH INPUT_%s\"" + " placeholder=\"%s…\"" + " onchange=\"unhideElement('prj_rev_%ld');return false;\"", + The_GetSuffix (),Txt_Comments, + Projects->Prj.PrjCod); + HTM_Txt (Projects->Prj.Review.Txt); + HTM_TEXTAREA_End (); - /* Button to save changes. - Initially hidden, is shown when clicking on selector or text */ - HTM_DIV_Begin ("id=\"prj_rev_%ld\" style=\"display:none;\"", - Projects->Prj.PrjCod); - Btn_PutConfirmButtonInline (Txt_Save_changes); - HTM_DIV_End (); + /* Button to save changes. + Initially hidden, is shown when clicking on selector or text */ + HTM_DIV_Begin ("id=\"prj_rev_%ld\" style=\"display:none;\"", + Projects->Prj.PrjCod); + Btn_PutConfirmButtonInline (Txt_Save_changes); + HTM_DIV_End (); - /* End form */ - Frm_EndForm (); - } - else if (Projects->Prj.Review.Txt[0]) - { - /* Change text format */ - Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - Projects->Prj.Review.Txt,Cns_MAX_BYTES_TEXT, - Str_DONT_REMOVE_SPACES); - switch (Projects->View) - { - case Prj_PRINT_ONE_PROJECT: - break; - default: - ALn_InsertLinks (Projects->Prj.Review.Txt,Cns_MAX_BYTES_TEXT,60); // Insert links - break; - } - - /* Show text */ - HTM_BR (); - HTM_Txt (Projects->Prj.Review.Txt); + /* End form */ + Frm_EndForm (); + break; } HTM_TD_End (); diff --git a/swad_question.c b/swad_question.c index ab0bc54f..36691a37 100644 --- a/swad_question.c +++ b/swad_question.c @@ -1773,7 +1773,7 @@ void Qst_ShowFormEditOneQst (void) { extern const char *Txt_Question_removed; struct Qst_Question Question; - bool PutFormToEditQuestion; + Frm_PutForm_t PutFormToEditQuestion; /***** Create test question *****/ Qst_QstConstructor (&Question); @@ -1781,15 +1781,21 @@ void Qst_ShowFormEditOneQst (void) /***** Get question data *****/ Question.QstCod = ParCod_GetPar (ParCod_Qst); if (Question.QstCod <= 0) // New question - PutFormToEditQuestion = true; + PutFormToEditQuestion = Frm_PUT_FORM; else - PutFormToEditQuestion = Qst_GetQstDataByCod (&Question); + PutFormToEditQuestion = Qst_GetQstDataByCod (&Question) ? Frm_PUT_FORM : + Frm_DONT_PUT_FORM; /***** Put form to edit question *****/ - if (PutFormToEditQuestion) - Qst_PutFormEditOneQst (&Question); - else - Ale_ShowAlert (Ale_WARNING,Txt_Question_removed); + switch (PutFormToEditQuestion) + { + case Frm_DONT_PUT_FORM: + Ale_ShowAlert (Ale_WARNING,Txt_Question_removed); + break; + case Frm_PUT_FORM: + Qst_PutFormEditOneQst (&Question); + break; + } /***** Destroy test question *****/ Qst_QstDestructor (&Question); diff --git a/swad_record.c b/swad_record.c index 1847665e..50719b57 100644 --- a/swad_record.c +++ b/swad_record.c @@ -136,10 +136,12 @@ static void Rec_PutParsStdResults (__attribute__((unused)) void *Args); static void Rec_PutParsWorks (__attribute__((unused)) void *Args); static void Rec_PutParsStudent (__attribute__((unused)) void *Args); static void Rec_PutParsMsgUsr (__attribute__((unused)) void *Args); -static void Rec_ShowInstitutionInHead (struct Hie_Node *Ins,bool PutFormLinks); +static void Rec_ShowInstitutionInHead (struct Hie_Node *Ins, + Frm_PutForm_t PutFormLinks); static void Rec_ShowPhoto (struct Usr_Data *UsrDat); static void Rec_ShowFullName (struct Usr_Data *UsrDat); -static void Rec_ShowNickname (struct Usr_Data *UsrDat,bool PutFormLinks); +static void Rec_ShowNickname (struct Usr_Data *UsrDat, + Frm_PutForm_t PutFormLinks); static void Rec_ShowCountryInHead (struct Usr_Data *UsrDat,bool ShowData); static void Rec_ShowWebsAndSocialNets (struct Usr_Data *UsrDat, Rec_SharedRecordViewType_t TypeOfView); @@ -2031,7 +2033,7 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView, bool IAmLoggedAsTeacherOrSysAdm; bool CountryForm; Vie_ViewType_t ViewType; - bool PutFormLinks; // Put links (forms) inside record card + Frm_PutForm_t PutFormLinks; // Put links (forms) inside record card bool ShowData; bool ShowIDRows; bool ShowAddressRows; @@ -2084,8 +2086,9 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView, Rec_RecordHelp[Rec_SHA_RECORD_LIST] = Rec_RecordListHelp[UsrDat->Roles.InCurrentCrs]; - PutFormLinks = !Frm_CheckIfInside () && // Only if not inside another form - Act_GetBrowserTab (Gbl.Action.Act) == Act_BRW_1ST_TAB; // Only in main browser tab + PutFormLinks = (!Frm_CheckIfInside () && // Only if not inside another form + Act_GetBrowserTab (Gbl.Action.Act) == Act_BRW_1ST_TAB) ? Frm_PUT_FORM : // Only in main browser tab + Frm_DONT_PUT_FORM; Ins.HieCod = UsrDat->InsCod; if (Ins.HieCod > 0) @@ -2523,14 +2526,15 @@ static void Rec_PutParsMsgUsr (__attribute__((unused)) void *Args) /*********************** Show institution in record card *********************/ /*****************************************************************************/ -static void Rec_ShowInstitutionInHead (struct Hie_Node *Ins,bool PutFormLinks) +static void Rec_ShowInstitutionInHead (struct Hie_Node *Ins, + Frm_PutForm_t PutFormLinks) { /***** Institution logo *****/ HTM_TD_Begin ("rowspan=\"4\" class=\"REC_C1_TOP CM\""); if (Ins->HieCod > 0) { /* Form to go to the institution */ - if (PutFormLinks) + if (PutFormLinks == Frm_PUT_FORM) { Frm_BeginFormGoTo (ActSeeInsInf); ParCod_PutPar (ParCod_Ins,Ins->HieCod); @@ -2540,7 +2544,7 @@ static void Rec_ShowInstitutionInHead (struct Hie_Node *Ins,bool PutFormLinks) Ins->HieCod, Ins->ShrtName, Rec_INSTITUTION_LOGO_SIZE,NULL); - if (PutFormLinks) + if (PutFormLinks == Frm_PUT_FORM) { HTM_BUTTON_End (); Frm_EndForm (); @@ -2553,14 +2557,14 @@ static void Rec_ShowInstitutionInHead (struct Hie_Node *Ins,bool PutFormLinks) if (Ins->HieCod > 0) { /* Form to go to the institution */ - if (PutFormLinks) + if (PutFormLinks == Frm_PUT_FORM) { Frm_BeginFormGoTo (ActSeeInsInf); ParCod_PutPar (ParCod_Ins,Ins->HieCod); HTM_BUTTON_Submit_Begin (Ins->FullName,"class=\"BT_LINK\""); } HTM_Txt (Ins->FullName); - if (PutFormLinks) + if (PutFormLinks == Frm_PUT_FORM) { HTM_BUTTON_End (); Frm_EndForm (); @@ -2618,7 +2622,8 @@ static void Rec_ShowFullName (struct Usr_Data *UsrDat) /*************************** Show user's nickname ****************************/ /*****************************************************************************/ -static void Rec_ShowNickname (struct Usr_Data *UsrDat,bool PutFormLinks) +static void Rec_ShowNickname (struct Usr_Data *UsrDat, + Frm_PutForm_t PutFormLinks) { extern const char *Txt_My_public_profile; extern const char *Txt_Another_user_s_profile; @@ -2632,7 +2637,7 @@ static void Rec_ShowNickname (struct Usr_Data *UsrDat,bool PutFormLinks) HTM_DIV_Begin ("class=\"REC_NICK\""); if (UsrDat->Nickname[0]) { - if (PutFormLinks) + if (PutFormLinks == Frm_PUT_FORM) { /* Put form to go to public profile */ Frm_BeginForm (ActSeeOthPubPrf); @@ -2641,7 +2646,7 @@ static void Rec_ShowNickname (struct Usr_Data *UsrDat,bool PutFormLinks) "class=\"BT_LINK\""); } HTM_TxtF ("@%s",UsrDat->Nickname); - if (PutFormLinks) + if (PutFormLinks == Frm_PUT_FORM) { HTM_BUTTON_End (); Frm_EndForm (); diff --git a/swad_resource.c b/swad_resource.c index 6e5bfad4..b341770a 100644 --- a/swad_resource.c +++ b/swad_resource.c @@ -129,7 +129,7 @@ void Rsc_ShowClipboard (void) { Rsc_GetLinkDataFromRow (mysql_res,&Link); HTM_LI_Begin ("class=\"PRG_RSC_%s\"",The_GetSuffix ()); - Rsc_WriteLinkName (&Link,Frm_PUT_FORM_TO_GO); + Rsc_WriteLinkName (&Link,Frm_PUT_FORM); HTM_LI_End (); } DB_FreeMySQLResult (&mysql_res); @@ -213,7 +213,7 @@ void Rsc_WriteRowClipboard (const struct Rsc_Link *Link, ""); /***** Name *****/ - Rsc_WriteLinkName (Link,Frm_DONT_PUT_FORM_TO_GO); + Rsc_WriteLinkName (Link,Frm_DONT_PUT_FORM); HTM_LABEL_End (); @@ -225,7 +225,7 @@ void Rsc_WriteRowClipboard (const struct Rsc_Link *Link, /************* Write link name (filename, assignment title...) ***************/ /*****************************************************************************/ -void Rsc_WriteLinkName (const struct Rsc_Link *Link,Frm_PutFormToGo_t PutFormToGo) +void Rsc_WriteLinkName (const struct Rsc_Link *Link,Frm_PutForm_t PutFormToGo) { extern const char *Txt_Actions[ActLst_NUM_ACTIONS]; extern const char *Rsc_ResourceTypesIcons[Rsc_NUM_TYPES]; @@ -293,13 +293,13 @@ void Rsc_WriteLinkName (const struct Rsc_Link *Link,Frm_PutFormToGo_t PutFormToG /***** Put icon and title of resource *****/ switch (PutFormToGo) { - case Frm_DONT_PUT_FORM_TO_GO: + case Frm_DONT_PUT_FORM: /* Icon and title of resource */ Ico_PutIconOn (Rsc_ResourceTypesIcons[Link->Type],Ico_BLACK, Txt_RESOURCE_TYPES[Link->Type]); HTM_Txt (Title); break; - case Frm_PUT_FORM_TO_GO: + case Frm_PUT_FORM: /* Begin form to go to resource */ NextAction = (Link->Cod > 0) ? NextActions[Link->Type].IfCod : // Resource specified NextActions[Link->Type].IfNotCod; // All resources of this type diff --git a/swad_resource.h b/swad_resource.h index 95c6cccb..62f1c6c0 100644 --- a/swad_resource.h +++ b/swad_resource.h @@ -78,7 +78,7 @@ void Rsc_ShowClipboard (void); void Rsc_ShowClipboardToChangeLink (const struct Rsc_Link *CurrentLink); void Rsc_WriteRowClipboard (const struct Rsc_Link *Link, HTM_SubmitOnClick_t SubmitOnClick,bool Checked); -void Rsc_WriteLinkName (const struct Rsc_Link *Link,Frm_PutFormToGo_t PutFormToGo); +void Rsc_WriteLinkName (const struct Rsc_Link *Link,Frm_PutForm_t PutFormToGo); void Rsc_GetResourceTitleFromLink (const struct Rsc_Link *Link, char Title[Rsc_MAX_BYTES_RESOURCE_TITLE + 1]); diff --git a/swad_rubric_criteria.c b/swad_rubric_criteria.c index 29c97a40..be934539 100644 --- a/swad_rubric_criteria.c +++ b/swad_rubric_criteria.c @@ -963,7 +963,7 @@ static void RubCri_WriteTitle (const struct RubCri_Criterion *Criterion) static void RubCri_WriteLink (const struct RubCri_Criterion *Criterion) { HTM_TD_Begin ("class=\"LT DAT_%s %s\"",The_GetSuffix (),The_GetColorRows ()); - Rsc_WriteLinkName (&Criterion->Link,Frm_DONT_PUT_FORM_TO_GO); + Rsc_WriteLinkName (&Criterion->Link,Frm_DONT_PUT_FORM); HTM_TD_End (); } diff --git a/swad_survey.c b/swad_survey.c index 8d95a075..e6d450ad 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -123,10 +123,10 @@ static void Svy_PutIconToAddNewQuestion (void *Surveys); static void Svy_WriteQstStem (const char *Stem); static void Svy_WriteAnswersOfAQst (struct Svy_Survey *Svy, struct Svy_Question *SvyQst, - bool PutFormAnswerSurvey); + Frm_PutForm_t PutFormAnswerSurvey); static void Svy_WriteCommentsOfAQst (struct Svy_Survey *Svy, struct Svy_Question *SvyQst, - bool PutFormAnswerSurvey); + Frm_PutForm_t PutFormAnswerSurvey); static void Svy_DrawBarNumUsrs (unsigned NumUsrs,unsigned MaxUsrs); static void Svy_PutIconToRemoveOneQst (void *Surveys); @@ -2604,7 +2604,9 @@ static void Svy_ListSvyQuestions (struct Svy_Surveys *Surveys) Gbl.Action.Act == ActEdiOneSvyQst || Gbl.Action.Act == ActNewSvyQst || Gbl.Action.Act == ActChgSvyQst); - bool PutFormAnswerSurvey = Surveys->Svy.Status.ICanAnswer && !Editing; + Frm_PutForm_t PutFormAnswerSurvey = (Surveys->Svy.Status.ICanAnswer && + !Editing) ? Frm_PUT_FORM : + Frm_DONT_PUT_FORM; /***** Begin box *****/ if (Surveys->Svy.Status.ICanEdit) @@ -2619,7 +2621,7 @@ static void Svy_ListSvyQuestions (struct Svy_Surveys *Surveys) /***** Get data of questions from database *****/ if ((NumQsts = Svy_DB_GetSurveyQsts (&mysql_res,Surveys->Svy.SvyCod))) { - if (PutFormAnswerSurvey) + if (PutFormAnswerSurvey == Frm_PUT_FORM) { /***** Begin form to send answers to survey *****/ Frm_BeginForm (ActAnsSvy); @@ -2687,9 +2689,11 @@ static void Svy_ListSvyQuestions (struct Svy_Surveys *Surveys) The_GetSuffix (), The_GetColorRows ()); Svy_WriteQstStem (Stem); - Svy_WriteAnswersOfAQst (&Surveys->Svy,&SvyQst,PutFormAnswerSurvey); + Svy_WriteAnswersOfAQst (&Surveys->Svy,&SvyQst, + PutFormAnswerSurvey); if (SvyQst.CommentsAllowed) - Svy_WriteCommentsOfAQst (&Surveys->Svy,&SvyQst,PutFormAnswerSurvey); + Svy_WriteCommentsOfAQst (&Surveys->Svy,&SvyQst, + PutFormAnswerSurvey); HTM_TD_End (); @@ -2698,7 +2702,7 @@ static void Svy_ListSvyQuestions (struct Svy_Surveys *Surveys) HTM_TABLE_End (); - if (PutFormAnswerSurvey) + if (PutFormAnswerSurvey == Frm_PUT_FORM) { /***** Button to create/modify survey *****/ Btn_PutConfirmButton (Txt_Done); @@ -2799,7 +2803,7 @@ static void Svy_WriteQstStem (const char *Stem) static void Svy_WriteAnswersOfAQst (struct Svy_Survey *Svy, struct Svy_Question *SvyQst, - bool PutFormAnswerSurvey) + Frm_PutForm_t PutFormAnswerSurvey) { unsigned NumAnswers; unsigned NumAns; @@ -2844,7 +2848,7 @@ static void Svy_WriteAnswersOfAQst (struct Svy_Survey *Svy, /* Selectors and label with the letter of the answer */ HTM_TR_Begin (NULL); - if (PutFormAnswerSurvey) + if (PutFormAnswerSurvey == Frm_PUT_FORM) { /* Write selector to choice this answer */ HTM_TD_Begin ("class=\"LT\""); @@ -2913,7 +2917,7 @@ static void Svy_WriteAnswersOfAQst (struct Svy_Survey *Svy, static void Svy_WriteCommentsOfAQst (struct Svy_Survey *Svy, struct Svy_Question *SvyQst, - bool PutFormAnswerSurvey) + Frm_PutForm_t PutFormAnswerSurvey) { extern const char *Txt_Comments; unsigned NumComments; @@ -2921,56 +2925,60 @@ static void Svy_WriteCommentsOfAQst (struct Svy_Survey *Svy, MYSQL_RES *mysql_res; MYSQL_ROW row; - if (PutFormAnswerSurvey) + switch (PutFormAnswerSurvey) { - HTM_TEXTAREA_Begin ("name=\"Com%010u\"" - " cols=\"60\" rows=\"4\"" - " class=\"INPUT_%s\"" - " placeholder=\"%s…\"", - (unsigned) SvyQst->QstCod, - The_GetSuffix (), - Txt_Comments); - HTM_TEXTAREA_End (); - } - else if (Svy->Status.ICanViewComments) - { - HTM_DL_Begin (); + case Frm_DONT_PUT_FORM: + if (Svy->Status.ICanViewComments) + { + HTM_DL_Begin (); - HTM_DT_Begin (); - HTM_TxtColon (Txt_Comments); - HTM_DT_End (); + HTM_DT_Begin (); + HTM_TxtColon (Txt_Comments); + HTM_DT_End (); - HTM_DD_Begin (); + HTM_DD_Begin (); - /***** Get comments of this question *****/ - NumComments = Svy_DB_GetCommentsQst (&mysql_res,SvyQst->QstCod); + /***** Get comments of this question *****/ + NumComments = Svy_DB_GetCommentsQst (&mysql_res,SvyQst->QstCod); - /***** Write the answers *****/ - if (NumComments) - { - HTM_OL_Begin (); - - /* Write one row for each user who has commented */ - for (NumCom = 0; - NumCom < NumComments; - NumCom++) + /***** Write the answers *****/ + if (NumComments) { - row = mysql_fetch_row (mysql_res); + HTM_OL_Begin (); - HTM_LI_Begin (NULL); - HTM_Txt (row[0]); - HTM_LI_End (); + /* Write one row for each user who has commented */ + for (NumCom = 0; + NumCom < NumComments; + NumCom++) + { + row = mysql_fetch_row (mysql_res); + + HTM_LI_Begin (NULL); + HTM_Txt (row[0]); + HTM_LI_End (); + } + + HTM_OL_End (); } - HTM_OL_End (); - } + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); - /***** Free structure that stores the query result *****/ - DB_FreeMySQLResult (&mysql_res); + HTM_DD_End (); - HTM_DD_End (); - - HTM_DL_End (); + HTM_DL_End (); + } + break; + case Frm_PUT_FORM: + HTM_TEXTAREA_Begin ("name=\"Com%010u\"" + " cols=\"60\" rows=\"4\"" + " class=\"INPUT_%s\"" + " placeholder=\"%s…\"", + (unsigned) SvyQst->QstCod, + The_GetSuffix (), + Txt_Comments); + HTM_TEXTAREA_End (); + break; } } diff --git a/swad_user.c b/swad_user.c index bedcbc72..3d089ee3 100644 --- a/swad_user.c +++ b/swad_user.c @@ -228,8 +228,8 @@ static void Usr_ListRowsAllDataTchs (Rol_Role_t Role, static void Usr_PutLinkToSeeAdmins (void); static void Usr_PutLinkToSeeGuests (void); -static bool Usr_SetOptionsListUsrsAllowed (Rol_Role_t UsrsRole, - bool ICanChooseOption[Usr_LIST_USRS_NUM_OPTIONS]); +static Frm_PutForm_t Usr_SetOptionsListUsrsAllowed (Rol_Role_t UsrsRole, + bool ICanChooseOption[Usr_LIST_USRS_NUM_OPTIONS]); static void Usr_PutOptionsListUsrs (const bool ICanChooseOption[Usr_LIST_USRS_NUM_OPTIONS]); static void Usr_ShowOneListUsrsOption (Usr_ListUsrsOption_t ListUsrsAction, const char *Label); @@ -1613,12 +1613,12 @@ void Usr_ChkUsrAndGetUsrData (void) extern const char *Txt_The_session_has_expired; struct { - bool PutForm; + Frm_PutForm_t PutForm; Act_Action_t Action; void (*FuncPars) (void); } FormLogin = { - false, + Frm_DONT_PUT_FORM, ActLogIn, NULL }; @@ -1631,7 +1631,7 @@ void Usr_ChkUsrAndGetUsrData (void) Gbl.Action.Act = ActLogOut; Tab_SetCurrentTab (); Ale_ShowAlert (Ale_WARNING,Txt_The_session_has_expired); - FormLogin.PutForm = true; + FormLogin.PutForm = Frm_PUT_FORM; } } else // !Gbl.Session.HasBeenDisconnected @@ -1677,7 +1677,7 @@ void Usr_ChkUsrAndGetUsrData (void) } } else - FormLogin.PutForm = true; + FormLogin.PutForm = Frm_PUT_FORM; } else if (Gbl.Action.Act == ActLogIn || Gbl.Action.Act == ActLogInUsrAgd) // Login using @nickname, email or ID from form @@ -1694,7 +1694,7 @@ void Usr_ChkUsrAndGetUsrData (void) } else { - FormLogin.PutForm = true; + FormLogin.PutForm = Frm_PUT_FORM; if (Gbl.Action.Act == ActLogInUsrAgd) { FormLogin.Action = ActLogInUsrAgd; @@ -1721,13 +1721,13 @@ void Usr_ChkUsrAndGetUsrData (void) Set_SetSettingsFromIP (); // Set settings from current IP } else - FormLogin.PutForm = true; + FormLogin.PutForm = Frm_PUT_FORM; } } } /***** If session disconnected or error in login, show form to login *****/ - if (FormLogin.PutForm) + if (FormLogin.PutForm == Frm_PUT_FORM) { Usr_WriteFormLogin (FormLogin.Action,FormLogin.FuncPars); Err_ShowErrorAndExit (NULL); @@ -3683,7 +3683,7 @@ void Usr_PutFormToSelectUsrsToGoToAct (struct Usr_SelectedUsrs *SelectedUsrs, const char *Title, const char *HelpLink, const char *TxtButton, - bool PutFormDateRange) + Frm_PutForm_t PutFormDateRange) { extern const char *Txt_Select_users; extern const char *Txt_Users; @@ -3769,7 +3769,7 @@ void Usr_PutFormToSelectUsrsToGoToAct (struct Usr_SelectedUsrs *SelectedUsrs, HTM_TR_End (); /* Starting and ending dates in the search */ - if (PutFormDateRange) + if (PutFormDateRange == Frm_PUT_FORM) Dat_PutFormStartEndClientLocalDateTimesWithYesterdayToday (SetHMS); HTM_TABLE_End (); @@ -5026,7 +5026,7 @@ void Usr_SeeGuests (void) extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; extern const char *Txt_Scope; bool ICanChooseOption[Usr_LIST_USRS_NUM_OPTIONS]; - bool PutForm; + Frm_PutForm_t PutForm; /***** Contextual menu *****/ Mnu_ContextMenuBegin (); @@ -5085,10 +5085,11 @@ void Usr_SeeGuests (void) Lay_WriteHeaderClassPhoto (Vie_VIEW); /* Set options allowed */ - PutForm = Usr_SetOptionsListUsrsAllowed (Rol_GST,ICanChooseOption); + PutForm = Usr_SetOptionsListUsrsAllowed (Rol_GST,ICanChooseOption) ? Frm_PUT_FORM : + Frm_DONT_PUT_FORM; /* Begin form */ - if (PutForm) + if (PutForm == Frm_PUT_FORM) Frm_BeginForm (ActDoActOnSevGst); /* Begin table */ @@ -5113,7 +5114,7 @@ void Usr_SeeGuests (void) HTM_TABLE_End (); /***** Which action, show records, follow...? *****/ - if (PutForm) + if (PutForm == Frm_PUT_FORM) { Usr_PutOptionsListUsrs (ICanChooseOption); Frm_EndForm (); @@ -5144,7 +5145,7 @@ void Usr_SeeStudents (void) extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; extern const char *Txt_Scope; bool ICanChooseOption[Usr_LIST_USRS_NUM_OPTIONS]; - bool PutForm; + Frm_PutForm_t PutForm; /***** Put contextual links *****/ switch (Gbl.Usrs.Me.Role.Logged) @@ -5235,10 +5236,11 @@ void Usr_SeeStudents (void) Lay_WriteHeaderClassPhoto (Vie_VIEW); /* Set options allowed */ - PutForm = Usr_SetOptionsListUsrsAllowed (Rol_STD,ICanChooseOption); + PutForm = Usr_SetOptionsListUsrsAllowed (Rol_STD,ICanChooseOption) ? Frm_PUT_FORM : + Frm_DONT_PUT_FORM; /* Begin form */ - if (PutForm) + if (PutForm == Frm_PUT_FORM) { Frm_BeginForm (ActDoActOnSevStd); Grp_PutParsCodGrps (); @@ -5266,7 +5268,7 @@ void Usr_SeeStudents (void) HTM_TABLE_End (); /***** Which action, show records, follow...? *****/ - if (PutForm) + if (PutForm == Frm_PUT_FORM) { Usr_PutOptionsListUsrs (ICanChooseOption); Frm_EndForm (); @@ -5301,7 +5303,7 @@ void Usr_SeeTeachers (void) extern const char *Txt_Scope; unsigned NumUsrs; bool ICanChooseOption[Usr_LIST_USRS_NUM_OPTIONS]; - bool PutForm; + Frm_PutForm_t PutForm; /***** Put contextual links *****/ switch (Gbl.Usrs.Me.Role.Logged) @@ -5401,10 +5403,11 @@ void Usr_SeeTeachers (void) Lay_WriteHeaderClassPhoto (Vie_VIEW); /* Set options allowed */ - PutForm = Usr_SetOptionsListUsrsAllowed (Rol_TCH,ICanChooseOption); + PutForm = Usr_SetOptionsListUsrsAllowed (Rol_TCH,ICanChooseOption) ? Frm_PUT_FORM : + Frm_DONT_PUT_FORM; /* Begin form */ - if (PutForm) + if (PutForm == Frm_PUT_FORM) { Frm_BeginForm (ActDoActOnSevTch); Grp_PutParsCodGrps (); @@ -5443,7 +5446,7 @@ void Usr_SeeTeachers (void) HTM_TABLE_End (); /***** Which action, show records, follow...? *****/ - if (PutForm) + if (PutForm == Frm_PUT_FORM) { Usr_PutOptionsListUsrs (ICanChooseOption); Frm_EndForm (); @@ -5473,11 +5476,10 @@ void Usr_SeeTeachers (void) /*****************************************************************************/ // Returns true if any option is allowed -static bool Usr_SetOptionsListUsrsAllowed (Rol_Role_t UsrsRole, - bool ICanChooseOption[Usr_LIST_USRS_NUM_OPTIONS]) +static Frm_PutForm_t Usr_SetOptionsListUsrsAllowed (Rol_Role_t UsrsRole, + bool ICanChooseOption[Usr_LIST_USRS_NUM_OPTIONS]) { Usr_ListUsrsOption_t Opt; - bool OptionsAllowed; /***** Check which options I can choose *****/ /* Set default (I can not choose options) */ @@ -5525,19 +5527,17 @@ static bool Usr_SetOptionsListUsrsAllowed (Rol_Role_t UsrsRole, Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)); break; default: - return false; + return Frm_DONT_PUT_FORM; } /***** Count allowed options *****/ - OptionsAllowed = false; for (Opt = (Usr_ListUsrsOption_t) 1; // Skip unknown option - !OptionsAllowed && Opt <= (Usr_ListUsrsOption_t) (Usr_LIST_USRS_NUM_OPTIONS - 1); Opt++) if (ICanChooseOption[Opt]) - OptionsAllowed = true; + return Frm_PUT_FORM; - return OptionsAllowed; + return Frm_DONT_PUT_FORM; } /*****************************************************************************/ diff --git a/swad_user.h b/swad_user.h index deef50af..862835c0 100644 --- a/swad_user.h +++ b/swad_user.h @@ -403,7 +403,7 @@ void Usr_PutFormToSelectUsrsToGoToAct (struct Usr_SelectedUsrs *SelectedUsrs, const char *Title, const char *HelpLink, const char *TxtButton, - bool PutFormDateRange); + Frm_PutForm_t PutFormDateRange); void Usr_GetSelectedUsrsAndGoToAct (struct Usr_SelectedUsrs *SelectedUsrs, void (*FuncWhenUsrsSelected) (void *ArgsSelected),void *ArgsSelected, void (*FuncWhenNoUsrsSelected) (void *ArgsNoSelected),void *ArgsNoSelected);