diff --git a/swad_action.c b/swad_action.c index 71dbeaaef..242ae0b45 100644 --- a/swad_action.c +++ b/swad_action.c @@ -443,6 +443,7 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = [ActRgtPrgItm ] = {1833,-1,TabUnk,ActSeePrg ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Prg_MoveRightItem ,NULL}, [ActFrmNewPrgRsc ] = {1918,-1,TabUnk,ActSeePrg ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Prg_RequestChangeItem ,NULL}, + [ActReqRemPrgRsc ] = {1919,-1,TabUnk,ActSeePrg ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,PrgRsc_ReqRemResource ,NULL}, [ActEdiTchGui ] = { 785,-1,TabUnk,ActSeeTchGui ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Inf_FormsToSelSendInfo ,NULL}, @@ -3747,6 +3748,7 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un -1, // #1916 (obsolete action) ActChgUsrPho, // #1917 ActFrmNewPrgRsc, // #1918 + ActReqRemPrgRsc, // #1919 }; /*****************************************************************************/ diff --git a/swad_action.h b/swad_action.h index c426c243c..f0982c75c 100644 --- a/swad_action.h +++ b/swad_action.h @@ -65,7 +65,7 @@ typedef enum typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to indicate obsolete action -#define Act_MAX_ACTION_COD 1918 +#define Act_MAX_ACTION_COD 1919 #define Act_MAX_OPTIONS_IN_MENU_PER_TAB 13 @@ -409,107 +409,108 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to #define ActLftPrgItm (ActChgCrsSta + 26) #define ActRgtPrgItm (ActChgCrsSta + 27) #define ActFrmNewPrgRsc (ActChgCrsSta + 28) -#define ActEdiTchGui (ActChgCrsSta + 29) -#define ActSeeSylLec (ActChgCrsSta + 30) -#define ActSeeSylPra (ActChgCrsSta + 31) -#define ActEdiSylLec (ActChgCrsSta + 32) -#define ActEdiSylPra (ActChgCrsSta + 33) -#define ActDelItmSylLec (ActChgCrsSta + 34) -#define ActDelItmSylPra (ActChgCrsSta + 35) -#define ActUp_IteSylLec (ActChgCrsSta + 36) -#define ActUp_IteSylPra (ActChgCrsSta + 37) -#define ActDwnIteSylLec (ActChgCrsSta + 38) -#define ActDwnIteSylPra (ActChgCrsSta + 39) -#define ActRgtIteSylLec (ActChgCrsSta + 40) -#define ActRgtIteSylPra (ActChgCrsSta + 41) -#define ActLftIteSylLec (ActChgCrsSta + 42) -#define ActLftIteSylPra (ActChgCrsSta + 43) -#define ActInsIteSylLec (ActChgCrsSta + 44) -#define ActInsIteSylPra (ActChgCrsSta + 45) -#define ActModIteSylLec (ActChgCrsSta + 46) -#define ActModIteSylPra (ActChgCrsSta + 47) +#define ActReqRemPrgRsc (ActChgCrsSta + 29) +#define ActEdiTchGui (ActChgCrsSta + 30) +#define ActSeeSylLec (ActChgCrsSta + 31) +#define ActSeeSylPra (ActChgCrsSta + 32) +#define ActEdiSylLec (ActChgCrsSta + 33) +#define ActEdiSylPra (ActChgCrsSta + 34) +#define ActDelItmSylLec (ActChgCrsSta + 35) +#define ActDelItmSylPra (ActChgCrsSta + 36) +#define ActUp_IteSylLec (ActChgCrsSta + 37) +#define ActUp_IteSylPra (ActChgCrsSta + 38) +#define ActDwnIteSylLec (ActChgCrsSta + 39) +#define ActDwnIteSylPra (ActChgCrsSta + 40) +#define ActRgtIteSylLec (ActChgCrsSta + 41) +#define ActRgtIteSylPra (ActChgCrsSta + 42) +#define ActLftIteSylLec (ActChgCrsSta + 43) +#define ActLftIteSylPra (ActChgCrsSta + 44) +#define ActInsIteSylLec (ActChgCrsSta + 45) +#define ActInsIteSylPra (ActChgCrsSta + 46) +#define ActModIteSylLec (ActChgCrsSta + 47) +#define ActModIteSylPra (ActChgCrsSta + 48) -#define ActEdiBib (ActChgCrsSta + 48) -#define ActEdiFAQ (ActChgCrsSta + 49) -#define ActEdiCrsLnk (ActChgCrsSta + 50) +#define ActEdiBib (ActChgCrsSta + 49) +#define ActEdiFAQ (ActChgCrsSta + 50) +#define ActEdiCrsLnk (ActChgCrsSta + 51) -#define ActChgFrcReaCrsInf (ActChgCrsSta + 51) -#define ActChgFrcReaTchGui (ActChgCrsSta + 52) -#define ActChgFrcReaSylLec (ActChgCrsSta + 53) -#define ActChgFrcReaSylPra (ActChgCrsSta + 54) -#define ActChgFrcReaBib (ActChgCrsSta + 55) -#define ActChgFrcReaFAQ (ActChgCrsSta + 56) -#define ActChgFrcReaCrsLnk (ActChgCrsSta + 57) +#define ActChgFrcReaCrsInf (ActChgCrsSta + 52) +#define ActChgFrcReaTchGui (ActChgCrsSta + 53) +#define ActChgFrcReaSylLec (ActChgCrsSta + 54) +#define ActChgFrcReaSylPra (ActChgCrsSta + 55) +#define ActChgFrcReaBib (ActChgCrsSta + 56) +#define ActChgFrcReaFAQ (ActChgCrsSta + 57) +#define ActChgFrcReaCrsLnk (ActChgCrsSta + 58) -#define ActChgHavReaCrsInf (ActChgCrsSta + 58) -#define ActChgHavReaTchGui (ActChgCrsSta + 59) -#define ActChgHavReaSylLec (ActChgCrsSta + 60) -#define ActChgHavReaSylPra (ActChgCrsSta + 61) -#define ActChgHavReaBib (ActChgCrsSta + 62) -#define ActChgHavReaFAQ (ActChgCrsSta + 63) -#define ActChgHavReaCrsLnk (ActChgCrsSta + 64) +#define ActChgHavReaCrsInf (ActChgCrsSta + 59) +#define ActChgHavReaTchGui (ActChgCrsSta + 60) +#define ActChgHavReaSylLec (ActChgCrsSta + 61) +#define ActChgHavReaSylPra (ActChgCrsSta + 62) +#define ActChgHavReaBib (ActChgCrsSta + 63) +#define ActChgHavReaFAQ (ActChgCrsSta + 64) +#define ActChgHavReaCrsLnk (ActChgCrsSta + 65) -#define ActSelInfSrcCrsInf (ActChgCrsSta + 65) -#define ActSelInfSrcTchGui (ActChgCrsSta + 66) -#define ActSelInfSrcSylLec (ActChgCrsSta + 67) -#define ActSelInfSrcSylPra (ActChgCrsSta + 68) -#define ActSelInfSrcBib (ActChgCrsSta + 69) -#define ActSelInfSrcFAQ (ActChgCrsSta + 70) -#define ActSelInfSrcCrsLnk (ActChgCrsSta + 71) -#define ActRcvURLCrsInf (ActChgCrsSta + 72) -#define ActRcvURLTchGui (ActChgCrsSta + 73) -#define ActRcvURLSylLec (ActChgCrsSta + 74) -#define ActRcvURLSylPra (ActChgCrsSta + 75) -#define ActRcvURLBib (ActChgCrsSta + 76) -#define ActRcvURLFAQ (ActChgCrsSta + 77) -#define ActRcvURLCrsLnk (ActChgCrsSta + 78) -#define ActRcvPagCrsInf (ActChgCrsSta + 79) -#define ActRcvPagTchGui (ActChgCrsSta + 80) -#define ActRcvPagSylLec (ActChgCrsSta + 81) -#define ActRcvPagSylPra (ActChgCrsSta + 82) -#define ActRcvPagBib (ActChgCrsSta + 83) -#define ActRcvPagFAQ (ActChgCrsSta + 84) -#define ActRcvPagCrsLnk (ActChgCrsSta + 85) -#define ActEditorCrsInf (ActChgCrsSta + 86) -#define ActEditorTchGui (ActChgCrsSta + 87) -#define ActEditorSylLec (ActChgCrsSta + 88) -#define ActEditorSylPra (ActChgCrsSta + 89) -#define ActEditorBib (ActChgCrsSta + 90) -#define ActEditorFAQ (ActChgCrsSta + 91) -#define ActEditorCrsLnk (ActChgCrsSta + 92) -#define ActPlaTxtEdiCrsInf (ActChgCrsSta + 93) -#define ActPlaTxtEdiTchGui (ActChgCrsSta + 94) -#define ActPlaTxtEdiSylLec (ActChgCrsSta + 95) -#define ActPlaTxtEdiSylPra (ActChgCrsSta + 96) -#define ActPlaTxtEdiBib (ActChgCrsSta + 97) -#define ActPlaTxtEdiFAQ (ActChgCrsSta + 98) -#define ActPlaTxtEdiCrsLnk (ActChgCrsSta + 99) -#define ActRchTxtEdiCrsInf (ActChgCrsSta + 100) -#define ActRchTxtEdiTchGui (ActChgCrsSta + 101) -#define ActRchTxtEdiSylLec (ActChgCrsSta + 102) -#define ActRchTxtEdiSylPra (ActChgCrsSta + 103) -#define ActRchTxtEdiBib (ActChgCrsSta + 104) -#define ActRchTxtEdiFAQ (ActChgCrsSta + 105) -#define ActRchTxtEdiCrsLnk (ActChgCrsSta + 106) -#define ActRcvPlaTxtCrsInf (ActChgCrsSta + 107) -#define ActRcvPlaTxtTchGui (ActChgCrsSta + 108) -#define ActRcvPlaTxtSylLec (ActChgCrsSta + 109) -#define ActRcvPlaTxtSylPra (ActChgCrsSta + 110) -#define ActRcvPlaTxtBib (ActChgCrsSta + 111) -#define ActRcvPlaTxtFAQ (ActChgCrsSta + 112) -#define ActRcvPlaTxtCrsLnk (ActChgCrsSta + 113) -#define ActRcvRchTxtCrsInf (ActChgCrsSta + 114) -#define ActRcvRchTxtTchGui (ActChgCrsSta + 115) -#define ActRcvRchTxtSylLec (ActChgCrsSta + 116) -#define ActRcvRchTxtSylPra (ActChgCrsSta + 117) -#define ActRcvRchTxtBib (ActChgCrsSta + 118) -#define ActRcvRchTxtFAQ (ActChgCrsSta + 119) -#define ActRcvRchTxtCrsLnk (ActChgCrsSta + 120) +#define ActSelInfSrcCrsInf (ActChgCrsSta + 66) +#define ActSelInfSrcTchGui (ActChgCrsSta + 67) +#define ActSelInfSrcSylLec (ActChgCrsSta + 68) +#define ActSelInfSrcSylPra (ActChgCrsSta + 69) +#define ActSelInfSrcBib (ActChgCrsSta + 70) +#define ActSelInfSrcFAQ (ActChgCrsSta + 71) +#define ActSelInfSrcCrsLnk (ActChgCrsSta + 72) +#define ActRcvURLCrsInf (ActChgCrsSta + 73) +#define ActRcvURLTchGui (ActChgCrsSta + 74) +#define ActRcvURLSylLec (ActChgCrsSta + 75) +#define ActRcvURLSylPra (ActChgCrsSta + 76) +#define ActRcvURLBib (ActChgCrsSta + 77) +#define ActRcvURLFAQ (ActChgCrsSta + 78) +#define ActRcvURLCrsLnk (ActChgCrsSta + 79) +#define ActRcvPagCrsInf (ActChgCrsSta + 80) +#define ActRcvPagTchGui (ActChgCrsSta + 81) +#define ActRcvPagSylLec (ActChgCrsSta + 82) +#define ActRcvPagSylPra (ActChgCrsSta + 83) +#define ActRcvPagBib (ActChgCrsSta + 84) +#define ActRcvPagFAQ (ActChgCrsSta + 85) +#define ActRcvPagCrsLnk (ActChgCrsSta + 86) +#define ActEditorCrsInf (ActChgCrsSta + 87) +#define ActEditorTchGui (ActChgCrsSta + 88) +#define ActEditorSylLec (ActChgCrsSta + 89) +#define ActEditorSylPra (ActChgCrsSta + 90) +#define ActEditorBib (ActChgCrsSta + 91) +#define ActEditorFAQ (ActChgCrsSta + 92) +#define ActEditorCrsLnk (ActChgCrsSta + 93) +#define ActPlaTxtEdiCrsInf (ActChgCrsSta + 94) +#define ActPlaTxtEdiTchGui (ActChgCrsSta + 95) +#define ActPlaTxtEdiSylLec (ActChgCrsSta + 96) +#define ActPlaTxtEdiSylPra (ActChgCrsSta + 97) +#define ActPlaTxtEdiBib (ActChgCrsSta + 98) +#define ActPlaTxtEdiFAQ (ActChgCrsSta + 99) +#define ActPlaTxtEdiCrsLnk (ActChgCrsSta + 100) +#define ActRchTxtEdiCrsInf (ActChgCrsSta + 101) +#define ActRchTxtEdiTchGui (ActChgCrsSta + 102) +#define ActRchTxtEdiSylLec (ActChgCrsSta + 103) +#define ActRchTxtEdiSylPra (ActChgCrsSta + 104) +#define ActRchTxtEdiBib (ActChgCrsSta + 105) +#define ActRchTxtEdiFAQ (ActChgCrsSta + 106) +#define ActRchTxtEdiCrsLnk (ActChgCrsSta + 107) +#define ActRcvPlaTxtCrsInf (ActChgCrsSta + 108) +#define ActRcvPlaTxtTchGui (ActChgCrsSta + 109) +#define ActRcvPlaTxtSylLec (ActChgCrsSta + 110) +#define ActRcvPlaTxtSylPra (ActChgCrsSta + 111) +#define ActRcvPlaTxtBib (ActChgCrsSta + 112) +#define ActRcvPlaTxtFAQ (ActChgCrsSta + 113) +#define ActRcvPlaTxtCrsLnk (ActChgCrsSta + 114) +#define ActRcvRchTxtCrsInf (ActChgCrsSta + 115) +#define ActRcvRchTxtTchGui (ActChgCrsSta + 116) +#define ActRcvRchTxtSylLec (ActChgCrsSta + 117) +#define ActRcvRchTxtSylPra (ActChgCrsSta + 118) +#define ActRcvRchTxtBib (ActChgCrsSta + 119) +#define ActRcvRchTxtFAQ (ActChgCrsSta + 120) +#define ActRcvRchTxtCrsLnk (ActChgCrsSta + 121) -#define ActPrnCrsTT (ActChgCrsSta + 121) -#define ActEdiCrsTT (ActChgCrsSta + 122) -#define ActChgCrsTT (ActChgCrsSta + 123) -#define ActChgCrsTT1stDay (ActChgCrsSta + 124) +#define ActPrnCrsTT (ActChgCrsSta + 122) +#define ActEdiCrsTT (ActChgCrsSta + 123) +#define ActChgCrsTT (ActChgCrsSta + 124) +#define ActChgCrsTT1stDay (ActChgCrsSta + 125) /*****************************************************************************/ /***************************** Assessment tab ********************************/ diff --git a/swad_changelog.h b/swad_changelog.h index 885432bbd..59f3d10d0 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -606,11 +606,12 @@ TODO: Fix bug: error al enviar un mensaje a dos recipientes, error on duplicate TODO: Attach pdf files in multimedia. */ -#define Log_PLATFORM_VERSION "SWAD 21.104 (2022-07-12)" +#define Log_PLATFORM_VERSION "SWAD 21.104.1 (2022-07-13)" #define CSS_FILE "swad21.103.6.css" #define JS_FILE "swad21.100.js" /* - Version 21.104: Jul 12, 2022 Adding resources to program items. (? lines) + Version 21.104.1: Jul 13, 2022 Adding resources to program items. (328504 lines) + Version 21.104: Jul 12, 2022 Adding resources to program items. (328263 lines) 1 change necessary in database: CREATE TABLE IF NOT EXISTS prg_resources (RscCod INT NOT NULL AUTO_INCREMENT,ItmCod INT NOT NULL DEFAULT -1,RscInd INT NOT NULL DEFAULT 0,Hidden ENUM('N','Y') NOT NULL DEFAULT 'N',Title VARCHAR(2047) NOT NULL,UNIQUE INDEX(RscCod),UNIQUE INDEX(ItmCod,RscInd)); diff --git a/swad_error.c b/swad_error.c index 4e7ac64fb..f94d53211 100644 --- a/swad_error.c +++ b/swad_error.c @@ -184,6 +184,11 @@ void Err_WrongItemExit (void) Err_ShowErrorAndExit ("Wrong item."); } +void Err_WrongResourceExit (void) + { + Err_ShowErrorAndExit ("Wrong resource."); + } + /*****************************************************************************/ /********** Write error message and exit when wrong syllabus format **********/ /*****************************************************************************/ diff --git a/swad_error.h b/swad_error.h index 35c76f0b1..ee92c22bc 100644 --- a/swad_error.h +++ b/swad_error.h @@ -46,6 +46,7 @@ void Err_WrongDateExit (void); void Err_WrongPluginExit (void); void Err_WrongItemsListExit (void); void Err_WrongItemExit (void); +void Err_WrongResourceExit (void); void Err_WrongSyllabusFormatExit (void); void Err_WrongFileBrowserExit (void); void Err_FileFolderNotFoundExit (void); diff --git a/swad_program.c b/swad_program.c index f9baa2f93..aaf4476ed 100644 --- a/swad_program.c +++ b/swad_program.c @@ -61,14 +61,6 @@ extern struct Globals Gbl; /******************************* Private types *******************************/ /*****************************************************************************/ -#define Prg_NUM_TYPES_FORMS 3 -typedef enum - { - Prg_DONT_PUT_FORM_ITEM, - Prg_PUT_FORM_CREATE_ITEM, - Prg_PUT_FORM_CHANGE_ITEM, - } Prg_CreateOrChangeItem_t; - #define Prg_NUM_MOVEMENTS_UP_DOWN 2 typedef enum { @@ -113,10 +105,6 @@ static struct /***************************** Private prototypes ****************************/ /*****************************************************************************/ -static void Prg_ShowCourseProgramHighlightingItem (const struct Prg_ItemRange *ToHighlight); -static void Prg_ShowAllItems (Prg_CreateOrChangeItem_t CreateOrChangeItem, - const struct Prg_ItemRange *ToHighlight, - long ParentItmCod,long ItmCodBeforeForm,unsigned FormLevel); static void Prg_PutIconsListItems (__attribute__((unused)) void *Args); static void Prg_PutIconToCreateNewItem (void); static void Prg_PutButtonToCreateNewItem (void); @@ -149,18 +137,14 @@ static bool Prg_CheckIfMoveDownIsAllowed (unsigned NumItem); static bool Prg_CheckIfMoveLeftIsAllowed (unsigned NumItem); static bool Prg_CheckIfMoveRightIsAllowed (unsigned NumItem); -static void Prg_GetListItems (void); static void Prg_GetDataOfItemByCod (struct Prg_Item *Item); static void Prg_GetDataOfItem (struct Prg_Item *Item, MYSQL_RES **mysql_res, unsigned NumRows); static void Prg_ResetItem (struct Prg_Item *Item); -static void Prg_FreeListItems (void); static void Prg_PutParamItmCod (long ItmCod); static long Prg_GetParamItmCod (void); -static unsigned Prg_GetNumItemFromItmCod (long ItmCod); - static void Prg_HideOrUnhideItem (bool Hide); static void Prg_MoveUpDownItem (Prg_MoveUpDown_t UpDown); @@ -170,7 +154,6 @@ static int Prg_GetNextBrother (int NumItem); static void Prg_MoveLeftRightItem (Prg_MoveLeftRight_t LeftRight); -static void Prg_SetItemRangeEmpty (struct Prg_ItemRange *ItemRange); static void Prg_SetItemRangeOnlyItem (unsigned Index,struct Prg_ItemRange *ItemRange); static void Prg_SetItemRangeWithAllChildren (unsigned NumItem,struct Prg_ItemRange *ItemRange); static unsigned Prg_GetLastChild (int NumItem); @@ -203,7 +186,7 @@ void Prg_ShowCourseProgram (void) Prg_FreeListItems (); } -static void Prg_ShowCourseProgramHighlightingItem (const struct Prg_ItemRange *ToHighlight) +void Prg_ShowCourseProgramHighlightingItem (const struct Prg_ItemRange *ToHighlight) { /***** Show all program items *****/ Prg_ShowAllItems (Prg_DONT_PUT_FORM_ITEM,ToHighlight,-1L,-1L,0); @@ -213,9 +196,9 @@ static void Prg_ShowCourseProgramHighlightingItem (const struct Prg_ItemRange *T /************************* Show all program items ****************************/ /*****************************************************************************/ -static void Prg_ShowAllItems (Prg_CreateOrChangeItem_t CreateOrChangeItem, - const struct Prg_ItemRange *ToHighlight, - long ParentItmCod,long ItmCodBeforeForm,unsigned FormLevel) +void Prg_ShowAllItems (Prg_CreateOrChangeItem_t CreateOrChangeItem, + const struct Prg_ItemRange *ToHighlight, + long ParentItmCod,long ItmCodBeforeForm,unsigned FormLevel) { extern const char *Hlp_COURSE_Program; extern const char *Txt_Course_program; @@ -397,7 +380,7 @@ static void Prg_WriteRowItem (unsigned NumItem,struct Prg_Item *Item, /***** Forms to remove/edit this program item *****/ if (!PrintView) { - HTM_TD_Begin ("class=\"PRG_COL1 LT %s\"",The_GetColorRows ()); + HTM_TD_Begin ("rowspan=\"2\" class=\"PRG_COL1 LT %s\"",The_GetColorRows ()); Prg_PutFormsToRemEditOneItem (NumItem,Item); HTM_TD_End (); } @@ -407,44 +390,25 @@ static void Prg_WriteRowItem (unsigned NumItem,struct Prg_Item *Item, NumCol < Item->Hierarchy.Level; NumCol++) { - HTM_TD_Begin ("class=\"%s\"",The_GetColorRows ()); + HTM_TD_Begin ("rowspan=\"2\" class=\"%s\"",The_GetColorRows ()); HTM_TD_End (); } /***** Item number *****/ - HTM_TD_Begin ("class=\"PRG_NUM %s RT %s\"", + HTM_TD_Begin ("rowspan=\"2\" class=\"PRG_NUM %s RT %s\"", TitleClass,The_GetColorRows ()); Prg_WriteNumItem (Item->Hierarchy.Level); HTM_TD_End (); - /***** Title and text *****/ - /* Begin title and text */ + /***** Title *****/ ColSpan = (Prg_GetMaxItemLevel () + 2) - Item->Hierarchy.Level; if (PrintView) - HTM_TD_Begin ("colspan=\"%u\" class=\"PRG_MAIN\"", - ColSpan); - else HTM_TD_Begin ("colspan=\"%u\" class=\"PRG_MAIN %s\"", - ColSpan,The_GetColorRows ()); - - /* Title */ - HTM_DIV_Begin ("class=\"%s\"",TitleClass); - HTM_Txt (Item->Title); - HTM_DIV_End (); - - /* Text */ - Prg_DB_GetItemTxt (Item->Hierarchy.ItmCod,Txt); - Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - Txt,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to recpectful HTML - ALn_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links - HTM_DIV_Begin ("class=\"PAR PRG_TXT_%s%s\"", - The_GetSuffix (), - LightStyle ? " PRG_HIDDEN" : - ""); - HTM_Txt (Txt); - HTM_DIV_End (); - - /* End title and text */ + ColSpan,TitleClass); + else + HTM_TD_Begin ("colspan=\"%u\" class=\"PRG_MAIN %s %s\"", + ColSpan,TitleClass,The_GetColorRows ()); + HTM_Txt (Item->Title); HTM_TD_End (); /***** Start/end date/time *****/ @@ -483,6 +447,39 @@ static void Prg_WriteRowItem (unsigned NumItem,struct Prg_Item *Item, /***** End row *****/ HTM_TR_End (); + /***** Begin row *****/ + HTM_TR_Begin (NULL); + + /* Begin text and resources */ + ColSpan += 2; + if (PrintView) + HTM_TD_Begin ("colspan=\"%u\" class=\"PRG_MAIN\"", + ColSpan); + else + HTM_TD_Begin ("colspan=\"%u\" class=\"PRG_MAIN %s\"", + ColSpan,The_GetColorRows ()); + + /* Text */ + Prg_DB_GetItemTxt (Item->Hierarchy.ItmCod,Txt); + Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, + Txt,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to recpectful HTML + ALn_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links + HTM_DIV_Begin ("class=\"PAR PRG_TXT_%s%s\"", + The_GetSuffix (), + LightStyle ? " PRG_HIDDEN" : + ""); + HTM_Txt (Txt); + HTM_DIV_End (); + + /* List of resources */ + PrgRsc_ShowResources (Item->Hierarchy.ItmCod); + + /* End text and resources */ + HTM_TD_End (); + + /***** End row *****/ + HTM_TR_End (); + /***** Free title CSS class *****/ Prg_FreeTitleClass (TitleClass); } @@ -551,7 +548,7 @@ static void Prg_WriteRowWithItemForm (Prg_CreateOrChangeItem_t CreateOrChangeIte if (CreateOrChangeItem == Prg_PUT_FORM_CHANGE_ITEM) { HTM_ARTICLE_Begin ("rsc_form"); - PrgRsc_ShowAllResources (ItmCod); + PrgRsc_EditResources (ItmCod); HTM_ARTICLE_End (); } HTM_TD_End (); @@ -610,8 +607,8 @@ static unsigned Prg_CalculateMaxItemLevel (void) for (NumItem = 0; NumItem < Prg_Gbl.List.NumItems; NumItem++) - if (Prg_Gbl.List.Items[NumItem].Level > MaxLevel) - MaxLevel = Prg_Gbl.List.Items[NumItem].Level; + if (Prg_GetLevelFromNumItem (NumItem) > MaxLevel) + MaxLevel = Prg_GetLevelFromNumItem (NumItem); return MaxLevel; } @@ -826,8 +823,8 @@ static bool Prg_CheckIfMoveUpIsAllowed (unsigned NumItem) /***** Move up is allowed if the item has brothers before it *****/ // NumItem >= 2 - return Prg_Gbl.List.Items[NumItem - 1].Level >= - Prg_Gbl.List.Items[NumItem ].Level; + return Prg_GetLevelFromNumItem (NumItem - 1) >= + Prg_GetLevelFromNumItem (NumItem ); } /*****************************************************************************/ @@ -845,14 +842,14 @@ static bool Prg_CheckIfMoveDownIsAllowed (unsigned NumItem) /***** Move down is allowed if the item has brothers after it *****/ // NumItem + 1 < Prg_Gbl.List.NumItems - Level = Prg_Gbl.List.Items[NumItem].Level; + Level = Prg_GetLevelFromNumItem (NumItem); for (i = NumItem + 1; i < Prg_Gbl.List.NumItems; i++) { - if (Prg_Gbl.List.Items[i].Level == Level) + if (Prg_GetLevelFromNumItem (i) == Level) return true; // Next brother found - if (Prg_Gbl.List.Items[i].Level < Level) + if (Prg_GetLevelFromNumItem (i) < Level) return false; // Next lower level found ==> there are no more brothers } return false; // End reached ==> there are no more brothers @@ -865,7 +862,7 @@ static bool Prg_CheckIfMoveDownIsAllowed (unsigned NumItem) static bool Prg_CheckIfMoveLeftIsAllowed (unsigned NumItem) { /***** Move left is allowed if the item has parent *****/ - return Prg_Gbl.List.Items[NumItem].Level > 1; + return Prg_GetLevelFromNumItem (NumItem) > 1; } /*****************************************************************************/ @@ -880,8 +877,8 @@ static bool Prg_CheckIfMoveRightIsAllowed (unsigned NumItem) /***** Move right is allowed if the item has brothers before it *****/ // NumItem >= 2 - return Prg_Gbl.List.Items[NumItem - 1].Level >= - Prg_Gbl.List.Items[NumItem ].Level; + return Prg_GetLevelFromNumItem (NumItem - 1) >= + Prg_GetLevelFromNumItem (NumItem ); } /*****************************************************************************/ @@ -899,7 +896,7 @@ void Prg_PutParams (void *ItmCod) /************************** List all program items ***************************/ /*****************************************************************************/ -static void Prg_GetListItems (void) +void Prg_GetListItems (void) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1047,7 +1044,7 @@ static void Prg_ResetItem (struct Prg_Item *Item) /************************ Free list of program items *************************/ /*****************************************************************************/ -static void Prg_FreeListItems (void) +void Prg_FreeListItems (void) { if (Prg_Gbl.List.IsRead && Prg_Gbl.List.Items) { @@ -1074,7 +1071,6 @@ static void Prg_PutParamItmCod (long ItmCod) static long Prg_GetParamItmCod (void) { - /***** Get code of program item *****/ return Par_GetParToLong ("ItmCod"); } @@ -1082,7 +1078,7 @@ static long Prg_GetParamItmCod (void) /**************** Get number of item in list from item code ******************/ /*****************************************************************************/ -static unsigned Prg_GetNumItemFromItmCod (long ItmCod) +unsigned Prg_GetNumItemFromItmCod (long ItmCod) { unsigned NumItem; @@ -1102,6 +1098,15 @@ static unsigned Prg_GetNumItemFromItmCod (long ItmCod) return 0; // Not reached } +/*****************************************************************************/ +/****************** Get level of item from number of item ********************/ +/*****************************************************************************/ + +inline unsigned Prg_GetLevelFromNumItem (unsigned NumItem) + { + return Prg_Gbl.List.Items[NumItem].Level; + } + /*****************************************************************************/ /************* Ask for confirmation of removing a program item ***************/ /*****************************************************************************/ @@ -1381,14 +1386,14 @@ static int Prg_GetPrevBrother (int NumItem) /***** Get previous brother before item *****/ // 1 <= NumItem < Prg_Gbl.List.NumItems - Level = Prg_Gbl.List.Items[NumItem].Level; + Level = Prg_GetLevelFromNumItem (NumItem); for (i = NumItem - 1; i >= 0; i--) { - if (Prg_Gbl.List.Items[i].Level == Level) + if (Prg_GetLevelFromNumItem (i) == Level) return i; // Previous brother before item found - if (Prg_Gbl.List.Items[i].Level < Level) + if (Prg_GetLevelFromNumItem (i) < Level) return -1; // Previous lower level found ==> there are no brothers before item } return -1; // Start reached ==> there are no brothers before item @@ -1411,14 +1416,14 @@ static int Prg_GetNextBrother (int NumItem) /***** Get next brother after item *****/ // 0 <= NumItem < Prg_Gbl.List.NumItems - 1 - Level = Prg_Gbl.List.Items[NumItem].Level; + Level = Prg_GetLevelFromNumItem (NumItem); for (i = NumItem + 1; i < (int) Prg_Gbl.List.NumItems; i++) { - if (Prg_Gbl.List.Items[i].Level == Level) + if (Prg_GetLevelFromNumItem (i) == Level) return i; // Next brother found - if (Prg_Gbl.List.Items[i].Level < Level) + if (Prg_GetLevelFromNumItem (i) < Level) return -1; // Next lower level found ==> there are no brothers after item } return -1; // End reached ==> there are no brothers after item @@ -1493,7 +1498,7 @@ static void Prg_MoveLeftRightItem (Prg_MoveLeftRight_t LeftRight) /****** Set subtree begin and end from number of item in course program ******/ /*****************************************************************************/ -static void Prg_SetItemRangeEmpty (struct Prg_ItemRange *ItemRange) +void Prg_SetItemRangeEmpty (struct Prg_ItemRange *ItemRange) { /***** List of items must be filled *****/ if (!Prg_Gbl.List.IsRead) @@ -1550,12 +1555,12 @@ static unsigned Prg_GetLastChild (int NumItem) /***** Get next brother after item *****/ // 0 <= NumItem < Prg_Gbl.List.NumItems - Level = Prg_Gbl.List.Items[NumItem].Level; + Level = Prg_GetLevelFromNumItem (NumItem); for (i = NumItem + 1; i < (int) Prg_Gbl.List.NumItems; i++) { - if (Prg_Gbl.List.Items[i].Level <= Level) + if (Prg_GetLevelFromNumItem (i) <= Level) return i - 1; // Last child found } return Prg_Gbl.List.NumItems - 1; // End reached ==> all items after the given item are its children @@ -1582,7 +1587,7 @@ void Prg_RequestCreateItem (void) { NumItem = Prg_GetNumItemFromItmCod (ParentItmCod); ItmCodBeforeForm = Prg_Gbl.List.Items[Prg_GetLastChild (NumItem)].ItmCod; - FormLevel = Prg_Gbl.List.Items[NumItem].Level + 1; + FormLevel = Prg_GetLevelFromNumItem (NumItem) + 1; } else // No parent item (user clicked on button to add a new first-level item at the end) { @@ -1616,7 +1621,7 @@ void Prg_RequestChangeItem (void) ItmCodBeforeForm = Prg_GetParamItmCod (); if (ItmCodBeforeForm > 0) - FormLevel = Prg_Gbl.List.Items[Prg_GetNumItemFromItmCod (ItmCodBeforeForm)].Level; + FormLevel = Prg_GetLevelFromNumItem (Prg_GetNumItemFromItmCod (ItmCodBeforeForm)); else FormLevel = 0; diff --git a/swad_program.h b/swad_program.h index 46252dff7..53a682e6f 100644 --- a/swad_program.h +++ b/swad_program.h @@ -64,6 +64,14 @@ struct Prg_ItemRange unsigned End; // Index of the last item in the subtree }; +#define Prg_NUM_TYPES_FORMS 3 +typedef enum + { + Prg_DONT_PUT_FORM_ITEM, + Prg_PUT_FORM_CREATE_ITEM, + Prg_PUT_FORM_CHANGE_ITEM, + } Prg_CreateOrChangeItem_t; + #define Prg_NUM_MOVEMENTS_LEFT_RIGHT 2 typedef enum { @@ -76,9 +84,20 @@ typedef enum /*****************************************************************************/ void Prg_ShowCourseProgram (void); +void Prg_ShowCourseProgramHighlightingItem (const struct Prg_ItemRange *ToHighlight); + +void Prg_ShowAllItems (Prg_CreateOrChangeItem_t CreateOrChangeItem, + const struct Prg_ItemRange *ToHighlight, + long ParentItmCod,long ItmCodBeforeForm,unsigned FormLevel); bool Prg_CheckIfICanCreateItems (void); void Prg_PutParams (void *ItmCod); + +void Prg_GetListItems (void); +void Prg_FreeListItems (void); +unsigned Prg_GetNumItemFromItmCod (long ItmCod); +unsigned Prg_GetLevelFromNumItem (unsigned NumItem); + void Prg_RequestCreateItem (void); void Prg_RequestChangeItem (void); void Prg_ReceiveFormNewItem (void); @@ -94,6 +113,8 @@ void Prg_MoveDownItem (void); void Prg_MoveLeftItem (void); void Prg_MoveRightItem (void); +void Prg_SetItemRangeEmpty (struct Prg_ItemRange *ItemRange); + //-------------------------------- Figures ------------------------------------ void Prg_GetAndShowCourseProgramStats (void); // TODO: Change function from assignments to schedule diff --git a/swad_program_database.c b/swad_program_database.c index 4119739a3..5f62afde8 100644 --- a/swad_program_database.c +++ b/swad_program_database.c @@ -293,8 +293,7 @@ unsigned Prg_DB_GetListResources (MYSQL_RES **mysql_res,long ItmCod) /****************** Get item resource data using its code ********************/ /*****************************************************************************/ -unsigned Prg_DB_GetDataOfResourceByCod (MYSQL_RES **mysql_res, - long ItmCod,long RscCod) +unsigned Prg_DB_GetDataOfResourceByCod (MYSQL_RES **mysql_res,long RscCod) { return (unsigned) DB_QuerySELECT (mysql_res,"can not get item resource data", @@ -303,9 +302,8 @@ unsigned Prg_DB_GetDataOfResourceByCod (MYSQL_RES **mysql_res, "Hidden," // row[2] "Title" // row[3] " FROM prg_resources" - " WHERE RscCod=%ld" - " AND ItmCod=%ld", // Extra check - RscCod,ItmCod); + " WHERE RscCod=%ld", + RscCod); } /*****************************************************************************/ diff --git a/swad_program_database.h b/swad_program_database.h index a0d34e10d..6dfe2f03a 100644 --- a/swad_program_database.h +++ b/swad_program_database.h @@ -49,8 +49,7 @@ unsigned Prg_DB_GetDataOfItemByCod (MYSQL_RES **mysql_res,long ItmCod); void Prg_DB_GetItemTxt (long ItmCod,char Txt[Cns_MAX_BYTES_TEXT + 1]); unsigned Prg_DB_GetListResources (MYSQL_RES **mysql_res,long ItmCod); -unsigned Prg_DB_GetDataOfResourceByCod (MYSQL_RES **mysql_res, - long ItmCod,long RscCod); +unsigned Prg_DB_GetDataOfResourceByCod (MYSQL_RES **mysql_res,long RscCod); unsigned Prg_DB_GetNumCoursesWithItems (HieLvl_Level_t Scope); unsigned Prg_DB_GetNumItems (HieLvl_Level_t Scope); diff --git a/swad_program_resource.c b/swad_program_resource.c index b73ac1f8d..d0caa57c8 100644 --- a/swad_program_resource.c +++ b/swad_program_resource.c @@ -35,7 +35,7 @@ // #include "swad_autolink.h" // #include "swad_box.h" // #include "swad_database.h" -// #include "swad_error.h" +#include "swad_error.h" // #include "swad_figure.h" #include "swad_form.h" #include "swad_global.h" @@ -121,14 +121,68 @@ static void PrgRsc_GetDataOfResourceByCod (struct PrgRsc_Resource *Resource); static void PrgRsc_GetDataOfResource (struct PrgRsc_Resource *Resource, MYSQL_RES **mysql_res); static void PrgRsc_ResetResource (struct PrgRsc_Resource *Resource); -static void PrgRsc_WriteRowResource (unsigned NumRsc,struct PrgRsc_Resource *Resource, - bool PrintView); +static void PrgRsc_WriteRowShowResource (unsigned NumRsc, + struct PrgRsc_Resource *Resource); +static void PrgRsc_WriteRowEditResource (unsigned NumRsc, + struct PrgRsc_Resource *Resource); +static void PrgRsc_PutFormsToRemEditOneResource (struct PrgRsc_Resource *Resource); +static void PrgRsc_PutParams (void *RscCod); +static void PrgRsc_PutParamRscCod (long RscCod); +static long PrgRsc_GetParamRscCod (void); /*****************************************************************************/ -/************************* Show all program items ****************************/ +/****************************** Show resources *******************************/ /*****************************************************************************/ -void PrgRsc_ShowAllResources (long ItmCod) +void PrgRsc_ShowResources (long ItmCod) + { + MYSQL_RES *mysql_res; + unsigned NumRsc; + unsigned NumResources; + struct PrgRsc_Resource Resource; + + /***** Trivial check *****/ + if (ItmCod <= 0) + return; + + /***** Get list of item resources from database *****/ + if ((NumResources = Prg_DB_GetListResources (&mysql_res,ItmCod))) // Resources found... + { + /***** Begin box *****/ + Box_BoxBegin ("100%",NULL, + NULL,NULL, + NULL,Box_NOT_CLOSABLE); + + /***** Table *****/ + HTM_TABLE_BeginWideMarginPadding (2); + HTM_TBODY_Begin (NULL); // 1st tbody start + + /***** Write all item resources *****/ + for (NumRsc = 1; + NumRsc <= NumResources; + NumRsc++) + { + /* Get data of this item resource */ + PrgRsc_GetDataOfResource (&Resource,&mysql_res); + + /* Show item */ + PrgRsc_WriteRowShowResource (NumRsc,&Resource); + } + + /***** End table *****/ + HTM_TBODY_End (); // 3rd tbody end + HTM_TABLE_End (); + + /***** End box *****/ + Box_BoxEnd (); + } + } + +/*****************************************************************************/ +/****************************** Edit resources *******************************/ +/*****************************************************************************/ + +void PrgRsc_EditResources (long ItmCod) { extern const char *Hlp_COURSE_Program; extern const char *Txt_Resources; @@ -141,13 +195,13 @@ void PrgRsc_ShowAllResources (long ItmCod) if (ItmCod <= 0) return; + /***** Get list of item resources from database *****/ + NumResources = Prg_DB_GetListResources (&mysql_res,ItmCod); // Resources found... + /***** Begin box *****/ Box_BoxBegin ("100%",Txt_Resources, - PrgRsc_PutIconsListResources,&ItmCod, - Hlp_COURSE_Program,Box_NOT_CLOSABLE); - - /***** Get list of item resources from database *****/ - NumResources = Prg_DB_GetListResources (&mysql_res,ItmCod); // Resources found... + PrgRsc_PutIconsListResources,&ItmCod, + Hlp_COURSE_Program,Box_NOT_CLOSABLE); /***** Table *****/ HTM_TABLE_BeginWideMarginPadding (2); @@ -159,28 +213,10 @@ void PrgRsc_ShowAllResources (long ItmCod) NumRsc++) { /* Get data of this item resource */ - PrgRsc_GetDataOfResource (&Resource,&mysql_res); + PrgRsc_GetDataOfResource (&Resource,&mysql_res); /* Show item */ - PrgRsc_WriteRowResource (NumRsc,&Resource,false); // Not print view - - /* Show form to create/change item */ - /* - if (Item.Hierarchy.ItmCod == ItmCodBeforeForm) - switch (CreateOrChangeItem) - { - case Prg_DONT_PUT_FORM_ITEM: - break; - case Prg_PUT_FORM_CREATE_ITEM: - Prg_WriteRowWithItemForm (Prg_PUT_FORM_CREATE_ITEM, - ParentItmCod,FormLevel); - break; - case Prg_PUT_FORM_CHANGE_ITEM: - Prg_WriteRowWithItemForm (Prg_PUT_FORM_CHANGE_ITEM, - ItmCodBeforeForm,FormLevel); - break; - } - */ + PrgRsc_WriteRowEditResource (NumRsc,&Resource); The_ChangeRowColor (); } @@ -196,8 +232,7 @@ void PrgRsc_ShowAllResources (long ItmCod) HTM_TABLE_End (); /***** Button to create a new program item *****/ - if (Prg_CheckIfICanCreateItems ()) - PrgRsc_PutButtonToCreateNewResource (ItmCod); + PrgRsc_PutButtonToCreateNewResource (ItmCod); /***** End box *****/ Box_BoxEnd (); @@ -277,20 +312,20 @@ static void PrgRsc_GetDataOfResourceByCod (struct PrgRsc_Resource *Resource) { MYSQL_RES *mysql_res; - /***** Clear all item resource data *****/ - PrgRsc_ResetResource (Resource); - if (Resource->RscCod > 0) { /***** Get data of item resource *****/ - if (Prg_DB_GetDataOfResourceByCod (&mysql_res, - Resource->ItmCod, - Resource->RscCod)) + if (Prg_DB_GetDataOfResourceByCod (&mysql_res,Resource->RscCod)) PrgRsc_GetDataOfResource (Resource,&mysql_res); + else + PrgRsc_ResetResource (Resource); /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); } + else + /***** Clear all item resource data *****/ + PrgRsc_ResetResource (Resource); } /*****************************************************************************/ @@ -330,48 +365,194 @@ static void PrgRsc_GetDataOfResource (struct PrgRsc_Resource *Resource, static void PrgRsc_ResetResource (struct PrgRsc_Resource *Resource) { + Resource->ItmCod = -1L; + Resource->RscCod = -1L; Resource->Hidden = false; Resource->Title[0] = '\0'; } /*****************************************************************************/ -/************************** Show one program item ****************************/ +/************************** Show one item resource ***************************/ /*****************************************************************************/ -static void PrgRsc_WriteRowResource (unsigned NumRsc,struct PrgRsc_Resource *Resource, - bool PrintView) +static void PrgRsc_WriteRowShowResource (unsigned NumRsc, + struct PrgRsc_Resource *Resource) { /***** Begin row *****/ HTM_TR_Begin (NULL); - /***** Forms to remove/edit this item resource *****/ - if (!PrintView) - { - HTM_TD_Begin ("class=\"PRG_COL1 LT %s\"",The_GetColorRows ()); - // Prg_PutFormsToRemEditOneItem (NumItem,Item); - HTM_TD_End (); - } - /***** Resource number *****/ HTM_TD_Begin ("class=\"PRG_NUM RT %s\"",The_GetColorRows ()); HTM_Unsigned (NumRsc); HTM_TD_End (); - /***** Title and text *****/ - /* Begin title and text */ - if (PrintView) - HTM_TD_Begin ("class=\"PRG_MAIN\""); - else - HTM_TD_Begin ("class=\"PRG_MAIN %s\"",The_GetColorRows ()); - - /* Title */ - HTM_DIV_Begin ("class=\"DAT\""); + /***** Title *****/ + HTM_TD_Begin ("class=\"PRG_MAIN %s\"",The_GetColorRows ()); HTM_Txt (Resource->Title); - HTM_DIV_End (); - - /* End title and text */ HTM_TD_End (); /***** End row *****/ HTM_TR_End (); } + +/*****************************************************************************/ +/************************** Edit one item resource ***************************/ +/*****************************************************************************/ + +static void PrgRsc_WriteRowEditResource (unsigned NumRsc, + struct PrgRsc_Resource *Resource) + { + /***** Begin row *****/ + HTM_TR_Begin (NULL); + + /***** Forms to remove/edit this item resource *****/ + HTM_TD_Begin ("class=\"PRG_COL1 LT %s\"",The_GetColorRows ()); + PrgRsc_PutFormsToRemEditOneResource (Resource); + HTM_TD_End (); + + /***** Resource number *****/ + HTM_TD_Begin ("class=\"PRG_NUM RT %s\"",The_GetColorRows ()); + HTM_Unsigned (NumRsc); + HTM_TD_End (); + + /***** Title *****/ + HTM_TD_Begin ("class=\"PRG_MAIN %s\"",The_GetColorRows ()); + HTM_Txt (Resource->Title); + HTM_TD_End (); + + /***** End row *****/ + HTM_TR_End (); + } + +/*****************************************************************************/ +/**************** Put a link (form) to edit one program item *****************/ +/*****************************************************************************/ + +static void PrgRsc_PutFormsToRemEditOneResource (struct PrgRsc_Resource *Resource) + { + extern const char *Txt_Movement_not_allowed; + // char StrItemIndex[Cns_MAX_DECIMAL_DIGITS_UINT + 1]; + + /***** Initialize item index string *****/ + // snprintf (StrItemIndex,sizeof (StrItemIndex),"%u",Item->Hierarchy.Index); + + switch (Gbl.Usrs.Me.Role.Logged) + { + case Rol_TCH: + case Rol_SYS_ADM: + /***** Put form to remove program item *****/ + Ico_PutContextualIconToRemove (ActReqRemPrgRsc,"rsc_form", + PrgRsc_PutParams,&Resource->RscCod); + + /***** Put form to hide/show program item *****/ + //if (Item->Hierarchy.Hidden) + // Ico_PutContextualIconToUnhide (ActShoPrgItm,"prg_highlighted", + // Prg_PutParams,&Item->Hierarchy.ItmCod); + //else + // Ico_PutContextualIconToHide (ActHidPrgItm,"prg_highlighted", + // Prg_PutParams,&Item->Hierarchy.ItmCod); + + /***** Put form to edit program item *****/ + // Ico_PutContextualIconToEdit (ActFrmChgPrgItm,"item_form", + // Prg_PutParams,&Item->Hierarchy.ItmCod); + + /***** Put form to add a new child item inside this item *****/ + // Ico_PutContextualIconToAdd (ActFrmNewPrgItm,"item_form", + // Prg_PutParams,&Item->Hierarchy.ItmCod); + + HTM_BR (); + + /***** Put icon to move up the item *****/ + // if (Prg_CheckIfMoveUpIsAllowed (NumItem)) + // Lay_PutContextualLinkOnlyIcon (ActUp_PrgItm,"prg_highlighted", + // Prg_PutParams,&Item->Hierarchy.ItmCod, + // "arrow-up.svg",Ico_BLACK); + // else + Ico_PutIconOff ("arrow-up.svg",Ico_BLACK,Txt_Movement_not_allowed); + + /***** Put icon to move down the item *****/ + // if (Prg_CheckIfMoveDownIsAllowed (NumItem)) + // Lay_PutContextualLinkOnlyIcon (ActDwnPrgItm,"prg_highlighted", + // Prg_PutParams,&Item->Hierarchy.ItmCod, + // "arrow-down.svg",Ico_BLACK); + //else + Ico_PutIconOff ("arrow-down.svg",Ico_BLACK,Txt_Movement_not_allowed); + break; + case Rol_STD: + case Rol_NET: + break; + default: + break; + } + } + +/*****************************************************************************/ +/******************** Params used to edit a program item *********************/ +/*****************************************************************************/ + +static void PrgRsc_PutParams (void *RscCod) + { + if (RscCod) + if (*((long *) RscCod) > 0) + PrgRsc_PutParamRscCod (*((long *) RscCod)); + } + +/*****************************************************************************/ +/**************** Write parameter with code of program item ******************/ +/*****************************************************************************/ + +static void PrgRsc_PutParamRscCod (long RscCod) + { + Par_PutHiddenParamLong (NULL,"RscCod",RscCod); + } + +/*****************************************************************************/ +/***************** Get parameter with code of item resource ******************/ +/*****************************************************************************/ + +static long PrgRsc_GetParamRscCod (void) + { + return Par_GetParToLong ("RscCod"); + } + +/*****************************************************************************/ +/************ Ask for confirmation of removing an item resource **************/ +/*****************************************************************************/ + +void PrgRsc_ReqRemResource (void) + { + extern const char *Txt_Do_you_really_want_to_remove_the_resource_X; + extern const char *Txt_Remove_resource; + struct PrgRsc_Resource Resource; + long ItmCodBeforeForm; + unsigned FormLevel; + struct Prg_ItemRange ToHighlight; + + /***** Get list of program items *****/ + Prg_GetListItems (); + + /***** Get data of the item resource from database *****/ + Resource.RscCod = PrgRsc_GetParamRscCod (); + PrgRsc_GetDataOfResourceByCod (&Resource); + if (Resource.ItmCod <= 0) + Err_WrongResourceExit (); + + /***** Show question and button to remove the item resource *****/ + Ale_ShowAlertAndButton (ActRemPrgItm,NULL,NULL, + PrgRsc_PutParams,&Resource.RscCod, + Btn_REMOVE_BUTTON,Txt_Remove_resource, + Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_resource_X, + Resource.Title); + + /***** Get the code of the program item *****/ + ItmCodBeforeForm = Resource.ItmCod; + FormLevel = Prg_GetLevelFromNumItem (Prg_GetNumItemFromItmCod (Resource.ItmCod)); + + /***** Show current program items, if any *****/ + Prg_SetItemRangeEmpty (&ToHighlight); + Prg_ShowAllItems (Prg_PUT_FORM_CHANGE_ITEM, + &ToHighlight,-1L,ItmCodBeforeForm,FormLevel); + + /***** Free list of program items *****/ + Prg_FreeListItems (); + } diff --git a/swad_program_resource.h b/swad_program_resource.h index fdc4124b2..fd0e36140 100644 --- a/swad_program_resource.h +++ b/swad_program_resource.h @@ -39,15 +39,7 @@ #define PrgRsc_MAX_CHARS_PROGRAM_RESOURCE_TITLE (128 - 1) // 127 #define PrgRsc_MAX_BYTES_PROGRAM_RESOURCE_TITLE ((PrgRsc_MAX_CHARS_PROGRAM_RESOURCE_TITLE + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 -/* -struct Prg_ItemHierarchy - { - long ItmCod; - unsigned Index; - unsigned Level; - bool Hidden; - }; -*/ + struct PrgRsc_Resource { long ItmCod; @@ -55,25 +47,14 @@ struct PrgRsc_Resource bool Hidden; char Title[PrgRsc_MAX_BYTES_PROGRAM_RESOURCE_TITLE + 1]; }; -/* -struct Prg_ItemRange - { - unsigned Begin; // Index of the first item in the subtree - unsigned End; // Index of the last item in the subtree - }; -#define Prg_NUM_MOVEMENTS_LEFT_RIGHT 2 -typedef enum - { - Prg_MOVE_LEFT, - Prg_MOVE_RIGHT, - } Prg_MoveLeftRight_t; -*/ /*****************************************************************************/ /***************************** Public prototypes *****************************/ /*****************************************************************************/ -void PrgRsc_ShowAllResources (long ItmCod); +void PrgRsc_ShowResources (long ItmCod); +void PrgRsc_EditResources (long ItmCod); void PrgRsc_RequestCreateResource (void); +void PrgRsc_ReqRemResource (void); #endif diff --git a/swad_text.c b/swad_text.c index 81f568445..b97e99d1e 100644 --- a/swad_text.c +++ b/swad_text.c @@ -9749,7 +9749,7 @@ const char *Txt_Do_you_really_want_to_delete_all_messages_received_from_USER_X_f #elif L==7 // it "Vuoi realmente rimuovere tutti i messaggi ricevuti da %s da %s?"; #elif L==8 // pl - "Czy na pewno chcesz usunac wszystkie wiadomosci otrzymane od %s z %s?"; + "Czy na pewno chcesz usunąć wszystkie wiadomosci otrzymane od %s z %s?"; #elif L==9 // pt "Você realmente deseja eliminar todas as mensagens recebidas de %s de %s?"; #elif L==10 // tr @@ -9779,7 +9779,7 @@ const char *Txt_Do_you_really_want_to_delete_all_messages_received_from_USER_X_f "Vuoi realmente rimuovere tutti i messaggi" " ricevuti da %s da %s relativi a %s?"; #elif L==8 // pl - "Czy na pewno chcesz usunac wszystkie wiadomosci" + "Czy na pewno chcesz usunąć wszystkie wiadomosci" " otrzymane od %s z %s podobne do %s?"; #elif L==9 // pt "Você realmente deseja eliminar todas as mensagens" @@ -9805,7 +9805,7 @@ const char *Txt_Do_you_really_want_to_delete_all_messages_sent_to_USER_X_from_CO #elif L==7 // it "Vuoi realmente rimuovere tutti i messaggi inviati a %s da %s?"; #elif L==8 // pl - "Czy na pewno chcesz usunac wszystkie wiadomosci wyslane do %s z %s?"; + "Czy na pewno chcesz usunąć wszystkie wiadomosci wyslane do %s z %s?"; #elif L==9 // pt "Você realmente deseja eliminar todas as mensagens enviadas para %s de %s?"; #elif L==10 // tr @@ -9828,7 +9828,7 @@ const char *Txt_Do_you_really_want_to_delete_all_messages_sent_to_USER_X_from_CO #elif L==7 // it "Vuoi realmente rimuovere tutti i messaggi inviati a %s da %s relativi a%s?"; #elif L==8 // pl - "Czy na pewno chcesz usunac wszystkie wiadomosci wyslane do %s z %s podobne do %s?"; + "Czy na pewno chcesz usunąć wszystkie wiadomosci wyslane do %s z %s podobne do %s?"; #elif L==9 // pt "Você realmente deseja eliminar todas as mensagens enviadas para %s de %s relacionadas com %s?"; #elif L==10 // tr @@ -9851,7 +9851,7 @@ const char *Txt_Do_you_really_want_to_delete_the_unread_messages_received_from_U #elif L==7 // it "Vuoi realmente rimuovere tutti i messaggi non letti ricevuti da %s da %s?"; #elif L==8 // pl - "Czy na pewno chcesz usunac nieprzeczytanych wiadomosci otrzymane od %s z %s?"; + "Czy na pewno chcesz usunąć nieprzeczytanych wiadomosci otrzymane od %s z %s?"; #elif L==9 // pt "Você realmente deseja eliminar as mensagens não lidas recebidas de %s de %s?"; #elif L==10 // tr @@ -9881,7 +9881,7 @@ const char *Txt_Do_you_really_want_to_delete_the_unread_messages_received_from_U "Vuoi realmente rimuovere tutti i messaggi non letti" " ricevuti da %s da %s relativi a %s?"; #elif L==8 // pl - "Czy na pewno chcesz usunac nieprzeczytanych wiadomosci" + "Czy na pewno chcesz usunąć nieprzeczytanych wiadomosci" " otrzymane od %s z %s podobne do %s?"; #elif L==9 // pt "Você realmente deseja eliminar as mensagens não lidas" @@ -10018,7 +10018,7 @@ const char *Txt_Do_you_really_want_to_remove_the_X_students_from_the_course_Y_ = " le loro schede per questo corso," " e la loro registrazione nei gruppi di questo corso saranno rimossi."; #elif L==8 // pl - "Czy na pewno chcesz usunac %u studentów z kursu %s?
" + "Czy na pewno chcesz usunąć %u studentów z kursu %s?
" "Although students' data will not be removed in other courses," " nie beda juz zarejestrowane w tym kurs" " a takze wszystkie prace zlozone przez nich w tym kursie," @@ -10056,7 +10056,7 @@ const char *Txt_Do_you_really_want_to_remove_the_assignment_X = // Warning: it i #elif L==7 // it "Vuoi realmente rimuovere l'attività %s?"; #elif L==8 // pl - "Czy na pewno chcesz usunac przypisanie %s?"; + "Czy na pewno chcesz usunąć przypisanie %s?"; #elif L==9 // pt "Você realmente deseja remover a atividade %s?"; #elif L==10 // tr @@ -10079,7 +10079,7 @@ const char *Txt_Do_you_really_want_to_remove_the_entire_thread = #elif L==7 // it "Vuoi realmente rimuovere l'intera discussione?"; #elif L==8 // pl - "Czy na pewno chcesz usunac caly watek?"; + "Czy na pewno chcesz usunąć caly watek?"; #elif L==9 // pt "Você realmente deseja remover toda a discussão?"; #elif L==10 // tr @@ -10102,7 +10102,7 @@ const char *Txt_Do_you_really_want_to_remove_the_entire_thread_X = // Warning: i #elif L==7 // it "Vuoi realmente rimuovere l'intera discussione %s?"; #elif L==8 // pl - "Czy na pewno chcesz usunac caly watek %s?"; + "Czy na pewno chcesz usunąć caly watek %s?"; #elif L==9 // pt "Você realmente deseja remover toda a discussão %s?"; #elif L==10 // tr @@ -10125,7 +10125,7 @@ const char *Txt_Do_you_really_want_to_remove_the_event_X = // Warning: it is ver #elif L==7 // it "Vuoi realmente rimuovere l'evento %s?"; #elif L==8 // pl - "Czy na pewno chcesz usunac wydarzenie %s?"; + "Czy na pewno chcesz usunąć wydarzenie %s?"; #elif L==9 // pt "Você realmente deseja remover o evento %s?"; #elif L==10 // tr @@ -10148,7 +10148,7 @@ const char *Txt_Do_you_really_want_to_remove_the_exam_X = // Warning: it is very #elif L==7 // it "Vuoi realmente rimuovere l'esame %s?"; #elif L==8 // pl - "Czy na pewno chcesz usunac egzaminu %s?"; + "Czy na pewno chcesz usunąć egzaminu %s?"; #elif L==9 // pt "Você realmente deseja remover o exame %s?"; #elif L==10 // tr @@ -10214,7 +10214,7 @@ const char *Txt_Do_you_really_want_to_remove_FILE_OR_LINK_X = // Warning: it is #elif L==7 // it "Vuoi realmente rimuovere %s?"; #elif L==8 // pl - "Czy na pewno chcesz usunac %s?"; + "Czy na pewno chcesz usunąć %s?"; #elif L==9 // pt "Você realmente deseja remover %s?"; #elif L==10 // tr @@ -10244,7 +10244,7 @@ const char *Txt_Do_you_really_want_to_remove_the_folder_X = // Warning: it is ve "Vuoi realmente rimuovere" " la cartella %s e tutto il suo contenuto?"; #elif L==8 // pl - "Czy na pewno chcesz usunac" + "Czy na pewno chcesz usunąć" " folder %s i wszystkie jego skladniki?"; #elif L==9 // pt "Você realmente deseja remover" @@ -10293,7 +10293,7 @@ const char *Txt_Do_you_really_want_to_remove_the_following_notice = #elif L==7 // it "Vuoi realmente rimuovere il seguente avviso?"; #elif L==8 // pl - "Czy na pewno chcesz usunac nastepujace obwieszczenie?"; + "Czy na pewno chcesz usunąć nastepujace obwieszczenie?"; #elif L==9 // pt "Você realmente deseja remover o seguinte aviso?"; #elif L==10 // tr @@ -10316,7 +10316,7 @@ const char *Txt_Do_you_really_want_to_remove_the_following_comment = #elif L==7 // it "Vuoi realmente rimuovere il seguente commento?"; #elif L==8 // pl - "Czy na pewno chcesz usunac nastepujace komentarz?"; + "Czy na pewno chcesz usunąć nastepujace komentarz?"; #elif L==9 // pt "Você realmente deseja remover o seguinte comentário?"; #elif L==10 // tr @@ -10339,7 +10339,7 @@ const char *Txt_Do_you_really_want_to_remove_the_following_post = #elif L==7 // it "Vuoi realmente rimuovere il seguente post?"; #elif L==8 // pl - "Czy na pewno chcesz usunac nastepujace post?"; + "Czy na pewno chcesz usunąć nastepujace post?"; #elif L==9 // pt "Você realmente deseja remover o seguinte post?"; #elif L==10 // tr @@ -10369,7 +10369,7 @@ const char *Txt_Do_you_really_want_to_remove_the_following_user_as_an_administra "Vuoi realmente rimuovere il seguente utente" " come amministratore de %s?"; #elif L==8 // pl - "Czy na pewno chcesz usunac nastepujace użytkownika" + "Czy na pewno chcesz usunąć nastepujace użytkownika" " jako administratora %s?"; #elif L==9 // pt "Você realmente deseja remover o seguinte usuário" @@ -10461,7 +10461,7 @@ const char *Txt_Do_you_really_want_to_remove_the_game_X = // Warning: it is very #elif L==7 // it "Vuoi realmente rimuovere il gioco %s?"; #elif L==8 // pl - "Czy na pewno chcesz usunac gra %s?"; + "Czy na pewno chcesz usunąć gra %s?"; #elif L==9 // pt "Você realmente deseja remover o jogo %s?"; #elif L==10 // tr @@ -10484,7 +10484,7 @@ const char *Txt_Do_you_really_want_to_remove_the_group_X = // Warning: it is ver #elif L==7 // it "Vuoi realmente rimuovere il gruppo %s?"; #elif L==8 // pl - "Czy na pewno chcesz usunac grupe %s?"; + "Czy na pewno chcesz usunąć grupe %s?"; #elif L==9 // pt "Você realmente quer remover o grupo %s?"; #elif L==10 // tr @@ -10573,7 +10573,7 @@ const char *Txt_Do_you_really_want_to_remove_the_item_X = // Warning: it is very #elif L==7 // it "Vuoi realmente rimuovere il articolo %s?"; #elif L==8 // pl - "Czy na pewno chcesz usunac przedmiot %s?"; + "Czy na pewno chcesz usunąć przedmiot %s?"; #elif L==9 // pt "Você realmente deseja remover o item %s?"; #elif L==10 // tr @@ -10596,7 +10596,7 @@ const char *Txt_Do_you_really_want_to_remove_the_match_X = // Warning: it is ver #elif L==7 // it "Vuoi realmente rimuovere la partita %s?"; #elif L==8 // pl - "Czy na pewno chcesz usunac mecz %s?"; + "Czy na pewno chcesz usunąć mecz %s?"; #elif L==9 // pt "Você realmente deseja remover o jogo %s?"; #elif L==10 // tr @@ -10642,7 +10642,7 @@ const char *Txt_Do_you_really_want_to_remove_the_project_X = // Warning: it is v #elif L==7 // it "Vuoi realmente rimuovere il progetto %s?"; #elif L==8 // pl - "Czy na pewno chcesz usunac projekt %s?"; + "Czy na pewno chcesz usunąć projekt %s?"; #elif L==9 // pt "Você realmente deseja remover o projeto %s?"; #elif L==10 // tr @@ -10665,13 +10665,36 @@ const char *Txt_Do_you_really_want_to_remove_the_question_X = // Warning: it is #elif L==7 // it "Vuoi realmente rimuovere la domanda %ld?"; #elif L==8 // pl - "Czy na pewno chcesz usunac pytanie %ld?"; + "Czy na pewno chcesz usunąć pytanie %ld?"; #elif L==9 // pt "Você realmente deseja remover a pergunta %ld?"; #elif L==10 // tr "Do you really want to remove the question %ld?"; // Çeviri lazim! #endif +const char *Txt_Do_you_really_want_to_remove_the_resource_X = // Warning: it is very important to include %s in the following sentences +#if L==1 // ca + "De veres voleu eliminar el recurs %s?"; +#elif L==2 // de + "Wollen Sie die Ressource %s wirklich entfernen?"; +#elif L==3 // en + "Do you really want to remove the resource %s?"; +#elif L==4 // es + "¿Realmente desea eliminar el recurso %s?"; +#elif L==5 // fr + "Voulez-vous vraiment supprimer la ressource %s?"; +#elif L==6 // gn + "¿Realmente desea eliminar el recurso %s?"; // Okoteve traducción +#elif L==7 // it + "Vuoi realmente rimuovere la risorsa %s?"; +#elif L==8 // pl + "Czy na pewno chcesz usunąć zasób %s?"; +#elif L==9 // pt + "Você realmente deseja remover o recurso %s?"; +#elif L==10 // tr + "%s kaynağını gerçekten kaldırmak istiyor musunuz?"; +#endif + const char *Txt_Do_you_really_want_to_remove_the_selected_questions = #if L==1 // ca "Realment voleu eliminar les preguntes seleccionades?"; @@ -10711,7 +10734,7 @@ const char *Txt_Do_you_really_want_to_remove_the_session_X = // Warning: it is v #elif L==7 // it "Vuoi realmente rimuovere la sessione %s?"; #elif L==8 // pl - "Czy na pewno chcesz usunac sesji %s?"; + "Czy na pewno chcesz usunąć sesji %s?"; #elif L==9 // pt "Você realmente deseja remover a sessão %s?"; #elif L==10 // tr @@ -10734,7 +10757,7 @@ const char *Txt_Do_you_really_want_to_remove_the_set_of_questions_X = // Warning #elif L==7 // it "Vuoi realmente rimuovere il set di domande %s?"; #elif L==8 // pl - "Czy na pewno chcesz usunac zestaw pytań %s?"; + "Czy na pewno chcesz usunąć zestaw pytań %s?"; #elif L==9 // pt "Você realmente deseja remover o conjunto de perguntas %s?"; #elif L==10 // tr @@ -10757,7 +10780,7 @@ const char *Txt_Do_you_really_want_to_remove_the_survey_X = // Warning: it is ve #elif L==7 // it "Vuoi realmente rimuovere il sondaggio %s?"; #elif L==8 // pl - "Czy na pewno chcesz usunac badania %s?"; + "Czy na pewno chcesz usunąć badania %s?"; #elif L==9 // pt "Você realmente deseja remover o inquérito %s?"; #elif L==10 // tr @@ -35043,6 +35066,29 @@ const char *Txt_Remove_record_field = "Remove record field"; // Çeviri lazim! #endif +const char *Txt_Remove_resource = +#if L==1 // ca + "Eliminar recurs"; +#elif L==2 // de + "Entfernen Ressource"; +#elif L==3 // en + "Remove resource"; +#elif L==4 // es + "Eliminar recurso"; +#elif L==5 // fr + "Supprimer ressource"; +#elif L==6 // gn + "Eliminar recurso"; // Okoteve traducción +#elif L==7 // it + "Rimuovere risorsa"; +#elif L==8 // pl + "Usuń zasób"; +#elif L==9 // pt + "Remover recurso"; +#elif L==10 // tr + "Kaynağı kaynak"; +#endif + const char *Txt_Remove_session = #if L==1 // ca "Eliminar sessió"; diff --git a/swad_text_action.c b/swad_text_action.c index c5bab5c58..dfa721dbf 100644 --- a/swad_text_action.c +++ b/swad_text_action.c @@ -5695,6 +5695,52 @@ const char *Txt_Actions[Act_NUM_ACTIONS] = "Move right program item" // Precisa de tradução #elif L==10 // tr "Move right program item" // Çeviri lazim! +#endif + , + [ActFrmNewPrgRsc] = +#if L==1 // ca + "Request new resource" // Necessita traducció +#elif L==2 // de + "Request new resource" // Need Übersetzung +#elif L==3 // en + "Request new resource" +#elif L==4 // es + "Solicitar nuevo recurso" +#elif L==5 // fr + "Request new resource" // Besoin de traduction +#elif L==6 // gn + "Solicitar nuevo recurso" // Okoteve traducción +#elif L==7 // it + "Request new resource" // Bisogno di traduzione +#elif L==8 // pl + "Request new resource" // Potrzebujesz tlumaczenie +#elif L==9 // pt + "Request new resource" // Precisa de tradução +#elif L==10 // tr + "Request new resource" // Çeviri lazim! +#endif + , + [ActReqRemPrgRsc] = +#if L==1 // ca + "Request removal of resource" // Necessita traducció +#elif L==2 // de + "Request removal of resource" // Need Übersetzung +#elif L==3 // en + "Request removal of resource" +#elif L==4 // es + "Solicitar eliminación de recurso" +#elif L==5 // fr + "Request removal of resource" // Besoin de traduction +#elif L==6 // gn + "Solicitar eliminación de recurso" // Okoteve traducción +#elif L==7 // it + "Request removal of resource" // Bisogno di traduzione +#elif L==8 // pl + "Request removal of resource" // Potrzebujesz tlumaczenie +#elif L==9 // pt + "Request removal of resource" // Precisa de tradução +#elif L==10 // tr + "Request removal of resource" // Çeviri lazim! #endif , [ActSeeTchGui] =