diff --git a/css/swad21.107.1.css b/css/swad22.3.css similarity index 99% rename from css/swad21.107.1.css rename to css/swad22.3.css index b14ea4c4..f953179f 100644 --- a/css/swad21.107.1.css +++ b/css/swad22.3.css @@ -1781,6 +1781,27 @@ a:hover img.CENTER_PHOTO_SHOW .PRG_RSC_PINK {color:#202020; font-size:14pt; font-weight:bold;} .PRG_RSC_DARK {color:#e0e0e0; font-size:14pt; font-weight:bold;} +/************************* Program resource clipboard ************************/ +.PRG_CLIPBOARD + { + box-sizing:border-box; + list-style-type:none; + padding:0; + margin:0; + text-align:left; + vertical-align:middle; + } +/* +.PRG_CLIPBOARD li + { + text-align:left; + vertical-align:middle; + } +.PRG_CLIPBOARD label + { + font-size:13pt; + } +*/ /********************************** Notice ***********************************/ .NOTICE_CONT { diff --git a/swad_action.c b/swad_action.c index 77e8522c..c737f515 100644 --- a/swad_action.c +++ b/swad_action.c @@ -454,7 +454,8 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = [ActUnhPrgRsc ] = {1922,-1,TabUnk,ActSeePrg ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,PrgRsc_UnhideResource ,NULL}, [ActUp_PrgRsc ] = {1923,-1,TabUnk,ActSeePrg ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,PrgRsc_MoveUpResource ,NULL}, [ActDwnPrgRsc ] = {1924,-1,TabUnk,ActSeePrg ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,PrgRsc_MoveDownResource ,NULL}, - [ActChgLnkPrgRsc ] = {1932,-1,TabUnk,ActSeePrg ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,PrgRsc_ShowClipboardToChgLink ,NULL}, + [ActSeeCliPrgRsc ] = {1932,-1,TabUnk,ActSeePrg ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,PrgRsc_ShowClipboardToChgLink ,NULL}, + [ActChgLnkPrgRsc ] = {1933,-1,TabUnk,ActSeePrg ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,PrgRsc_ChangeLink ,NULL}, [ActEdiTchGui ] = { 785,-1,TabUnk,ActSeeTchGui ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Inf_FormsToSelSendInfo ,NULL}, @@ -3774,7 +3775,8 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un ActNewPrgRsc, // #1929 ActReqLnkSeeDocCrs, // #1930 ActReqLnkAdmDocCrs, // #1931 - ActChgLnkPrgRsc, // #1932 + ActSeeCliPrgRsc, // #1932 + ActChgLnkPrgRsc, // #1933 }; /*****************************************************************************/ diff --git a/swad_action.h b/swad_action.h index d0243748..57e89d3a 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 1932 +#define Act_MAX_ACTION_COD 1933 #define Act_MAX_OPTIONS_IN_MENU_PER_TAB 13 @@ -420,108 +420,109 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to #define ActUnhPrgRsc (ActChgCrsSta + 37) #define ActUp_PrgRsc (ActChgCrsSta + 38) #define ActDwnPrgRsc (ActChgCrsSta + 39) -#define ActChgLnkPrgRsc (ActChgCrsSta + 40) -#define ActEdiTchGui (ActChgCrsSta + 41) -#define ActSeeSylLec (ActChgCrsSta + 42) -#define ActSeeSylPra (ActChgCrsSta + 43) -#define ActEdiSylLec (ActChgCrsSta + 44) -#define ActEdiSylPra (ActChgCrsSta + 45) -#define ActDelItmSylLec (ActChgCrsSta + 46) -#define ActDelItmSylPra (ActChgCrsSta + 47) -#define ActUp_IteSylLec (ActChgCrsSta + 48) -#define ActUp_IteSylPra (ActChgCrsSta + 49) -#define ActDwnIteSylLec (ActChgCrsSta + 50) -#define ActDwnIteSylPra (ActChgCrsSta + 51) -#define ActRgtIteSylLec (ActChgCrsSta + 52) -#define ActRgtIteSylPra (ActChgCrsSta + 53) -#define ActLftIteSylLec (ActChgCrsSta + 54) -#define ActLftIteSylPra (ActChgCrsSta + 55) -#define ActInsIteSylLec (ActChgCrsSta + 56) -#define ActInsIteSylPra (ActChgCrsSta + 57) -#define ActModIteSylLec (ActChgCrsSta + 58) -#define ActModIteSylPra (ActChgCrsSta + 59) +#define ActSeeCliPrgRsc (ActChgCrsSta + 40) +#define ActChgLnkPrgRsc (ActChgCrsSta + 41) +#define ActEdiTchGui (ActChgCrsSta + 42) +#define ActSeeSylLec (ActChgCrsSta + 43) +#define ActSeeSylPra (ActChgCrsSta + 44) +#define ActEdiSylLec (ActChgCrsSta + 45) +#define ActEdiSylPra (ActChgCrsSta + 46) +#define ActDelItmSylLec (ActChgCrsSta + 47) +#define ActDelItmSylPra (ActChgCrsSta + 48) +#define ActUp_IteSylLec (ActChgCrsSta + 49) +#define ActUp_IteSylPra (ActChgCrsSta + 50) +#define ActDwnIteSylLec (ActChgCrsSta + 51) +#define ActDwnIteSylPra (ActChgCrsSta + 52) +#define ActRgtIteSylLec (ActChgCrsSta + 53) +#define ActRgtIteSylPra (ActChgCrsSta + 54) +#define ActLftIteSylLec (ActChgCrsSta + 55) +#define ActLftIteSylPra (ActChgCrsSta + 56) +#define ActInsIteSylLec (ActChgCrsSta + 57) +#define ActInsIteSylPra (ActChgCrsSta + 58) +#define ActModIteSylLec (ActChgCrsSta + 59) +#define ActModIteSylPra (ActChgCrsSta + 60) -#define ActEdiBib (ActChgCrsSta + 60) -#define ActEdiFAQ (ActChgCrsSta + 61) -#define ActEdiCrsLnk (ActChgCrsSta + 62) +#define ActEdiBib (ActChgCrsSta + 61) +#define ActEdiFAQ (ActChgCrsSta + 62) +#define ActEdiCrsLnk (ActChgCrsSta + 63) -#define ActChgFrcReaCrsInf (ActChgCrsSta + 63) -#define ActChgFrcReaTchGui (ActChgCrsSta + 64) -#define ActChgFrcReaSylLec (ActChgCrsSta + 65) -#define ActChgFrcReaSylPra (ActChgCrsSta + 66) -#define ActChgFrcReaBib (ActChgCrsSta + 67) -#define ActChgFrcReaFAQ (ActChgCrsSta + 68) -#define ActChgFrcReaCrsLnk (ActChgCrsSta + 69) +#define ActChgFrcReaCrsInf (ActChgCrsSta + 64) +#define ActChgFrcReaTchGui (ActChgCrsSta + 65) +#define ActChgFrcReaSylLec (ActChgCrsSta + 66) +#define ActChgFrcReaSylPra (ActChgCrsSta + 67) +#define ActChgFrcReaBib (ActChgCrsSta + 68) +#define ActChgFrcReaFAQ (ActChgCrsSta + 69) +#define ActChgFrcReaCrsLnk (ActChgCrsSta + 70) -#define ActChgHavReaCrsInf (ActChgCrsSta + 70) -#define ActChgHavReaTchGui (ActChgCrsSta + 71) -#define ActChgHavReaSylLec (ActChgCrsSta + 72) -#define ActChgHavReaSylPra (ActChgCrsSta + 73) -#define ActChgHavReaBib (ActChgCrsSta + 74) -#define ActChgHavReaFAQ (ActChgCrsSta + 75) -#define ActChgHavReaCrsLnk (ActChgCrsSta + 76) +#define ActChgHavReaCrsInf (ActChgCrsSta + 71) +#define ActChgHavReaTchGui (ActChgCrsSta + 72) +#define ActChgHavReaSylLec (ActChgCrsSta + 73) +#define ActChgHavReaSylPra (ActChgCrsSta + 74) +#define ActChgHavReaBib (ActChgCrsSta + 75) +#define ActChgHavReaFAQ (ActChgCrsSta + 76) +#define ActChgHavReaCrsLnk (ActChgCrsSta + 77) -#define ActSelInfSrcCrsInf (ActChgCrsSta + 77) -#define ActSelInfSrcTchGui (ActChgCrsSta + 78) -#define ActSelInfSrcSylLec (ActChgCrsSta + 79) -#define ActSelInfSrcSylPra (ActChgCrsSta + 80) -#define ActSelInfSrcBib (ActChgCrsSta + 81) -#define ActSelInfSrcFAQ (ActChgCrsSta + 82) -#define ActSelInfSrcCrsLnk (ActChgCrsSta + 83) -#define ActRcvURLCrsInf (ActChgCrsSta + 84) -#define ActRcvURLTchGui (ActChgCrsSta + 85) -#define ActRcvURLSylLec (ActChgCrsSta + 86) -#define ActRcvURLSylPra (ActChgCrsSta + 87) -#define ActRcvURLBib (ActChgCrsSta + 88) -#define ActRcvURLFAQ (ActChgCrsSta + 89) -#define ActRcvURLCrsLnk (ActChgCrsSta + 90) -#define ActRcvPagCrsInf (ActChgCrsSta + 91) -#define ActRcvPagTchGui (ActChgCrsSta + 92) -#define ActRcvPagSylLec (ActChgCrsSta + 93) -#define ActRcvPagSylPra (ActChgCrsSta + 94) -#define ActRcvPagBib (ActChgCrsSta + 95) -#define ActRcvPagFAQ (ActChgCrsSta + 96) -#define ActRcvPagCrsLnk (ActChgCrsSta + 97) -#define ActEditorCrsInf (ActChgCrsSta + 98) -#define ActEditorTchGui (ActChgCrsSta + 99) -#define ActEditorSylLec (ActChgCrsSta + 100) -#define ActEditorSylPra (ActChgCrsSta + 101) -#define ActEditorBib (ActChgCrsSta + 102) -#define ActEditorFAQ (ActChgCrsSta + 103) -#define ActEditorCrsLnk (ActChgCrsSta + 104) -#define ActPlaTxtEdiCrsInf (ActChgCrsSta + 105) -#define ActPlaTxtEdiTchGui (ActChgCrsSta + 106) -#define ActPlaTxtEdiSylLec (ActChgCrsSta + 107) -#define ActPlaTxtEdiSylPra (ActChgCrsSta + 108) -#define ActPlaTxtEdiBib (ActChgCrsSta + 109) -#define ActPlaTxtEdiFAQ (ActChgCrsSta + 110) -#define ActPlaTxtEdiCrsLnk (ActChgCrsSta + 111) -#define ActRchTxtEdiCrsInf (ActChgCrsSta + 112) -#define ActRchTxtEdiTchGui (ActChgCrsSta + 113) -#define ActRchTxtEdiSylLec (ActChgCrsSta + 114) -#define ActRchTxtEdiSylPra (ActChgCrsSta + 115) -#define ActRchTxtEdiBib (ActChgCrsSta + 116) -#define ActRchTxtEdiFAQ (ActChgCrsSta + 117) -#define ActRchTxtEdiCrsLnk (ActChgCrsSta + 118) -#define ActRcvPlaTxtCrsInf (ActChgCrsSta + 119) -#define ActRcvPlaTxtTchGui (ActChgCrsSta + 120) -#define ActRcvPlaTxtSylLec (ActChgCrsSta + 121) -#define ActRcvPlaTxtSylPra (ActChgCrsSta + 122) -#define ActRcvPlaTxtBib (ActChgCrsSta + 123) -#define ActRcvPlaTxtFAQ (ActChgCrsSta + 124) -#define ActRcvPlaTxtCrsLnk (ActChgCrsSta + 125) -#define ActRcvRchTxtCrsInf (ActChgCrsSta + 126) -#define ActRcvRchTxtTchGui (ActChgCrsSta + 127) -#define ActRcvRchTxtSylLec (ActChgCrsSta + 128) -#define ActRcvRchTxtSylPra (ActChgCrsSta + 129) -#define ActRcvRchTxtBib (ActChgCrsSta + 130) -#define ActRcvRchTxtFAQ (ActChgCrsSta + 131) -#define ActRcvRchTxtCrsLnk (ActChgCrsSta + 132) +#define ActSelInfSrcCrsInf (ActChgCrsSta + 78) +#define ActSelInfSrcTchGui (ActChgCrsSta + 79) +#define ActSelInfSrcSylLec (ActChgCrsSta + 80) +#define ActSelInfSrcSylPra (ActChgCrsSta + 81) +#define ActSelInfSrcBib (ActChgCrsSta + 82) +#define ActSelInfSrcFAQ (ActChgCrsSta + 83) +#define ActSelInfSrcCrsLnk (ActChgCrsSta + 84) +#define ActRcvURLCrsInf (ActChgCrsSta + 85) +#define ActRcvURLTchGui (ActChgCrsSta + 86) +#define ActRcvURLSylLec (ActChgCrsSta + 87) +#define ActRcvURLSylPra (ActChgCrsSta + 88) +#define ActRcvURLBib (ActChgCrsSta + 89) +#define ActRcvURLFAQ (ActChgCrsSta + 90) +#define ActRcvURLCrsLnk (ActChgCrsSta + 91) +#define ActRcvPagCrsInf (ActChgCrsSta + 92) +#define ActRcvPagTchGui (ActChgCrsSta + 93) +#define ActRcvPagSylLec (ActChgCrsSta + 94) +#define ActRcvPagSylPra (ActChgCrsSta + 95) +#define ActRcvPagBib (ActChgCrsSta + 96) +#define ActRcvPagFAQ (ActChgCrsSta + 97) +#define ActRcvPagCrsLnk (ActChgCrsSta + 98) +#define ActEditorCrsInf (ActChgCrsSta + 99) +#define ActEditorTchGui (ActChgCrsSta + 100) +#define ActEditorSylLec (ActChgCrsSta + 101) +#define ActEditorSylPra (ActChgCrsSta + 102) +#define ActEditorBib (ActChgCrsSta + 103) +#define ActEditorFAQ (ActChgCrsSta + 104) +#define ActEditorCrsLnk (ActChgCrsSta + 105) +#define ActPlaTxtEdiCrsInf (ActChgCrsSta + 106) +#define ActPlaTxtEdiTchGui (ActChgCrsSta + 107) +#define ActPlaTxtEdiSylLec (ActChgCrsSta + 108) +#define ActPlaTxtEdiSylPra (ActChgCrsSta + 109) +#define ActPlaTxtEdiBib (ActChgCrsSta + 110) +#define ActPlaTxtEdiFAQ (ActChgCrsSta + 111) +#define ActPlaTxtEdiCrsLnk (ActChgCrsSta + 112) +#define ActRchTxtEdiCrsInf (ActChgCrsSta + 113) +#define ActRchTxtEdiTchGui (ActChgCrsSta + 114) +#define ActRchTxtEdiSylLec (ActChgCrsSta + 115) +#define ActRchTxtEdiSylPra (ActChgCrsSta + 116) +#define ActRchTxtEdiBib (ActChgCrsSta + 117) +#define ActRchTxtEdiFAQ (ActChgCrsSta + 118) +#define ActRchTxtEdiCrsLnk (ActChgCrsSta + 119) +#define ActRcvPlaTxtCrsInf (ActChgCrsSta + 120) +#define ActRcvPlaTxtTchGui (ActChgCrsSta + 121) +#define ActRcvPlaTxtSylLec (ActChgCrsSta + 122) +#define ActRcvPlaTxtSylPra (ActChgCrsSta + 123) +#define ActRcvPlaTxtBib (ActChgCrsSta + 124) +#define ActRcvPlaTxtFAQ (ActChgCrsSta + 125) +#define ActRcvPlaTxtCrsLnk (ActChgCrsSta + 126) +#define ActRcvRchTxtCrsInf (ActChgCrsSta + 127) +#define ActRcvRchTxtTchGui (ActChgCrsSta + 128) +#define ActRcvRchTxtSylLec (ActChgCrsSta + 129) +#define ActRcvRchTxtSylPra (ActChgCrsSta + 130) +#define ActRcvRchTxtBib (ActChgCrsSta + 131) +#define ActRcvRchTxtFAQ (ActChgCrsSta + 132) +#define ActRcvRchTxtCrsLnk (ActChgCrsSta + 133) -#define ActPrnCrsTT (ActChgCrsSta + 133) -#define ActEdiCrsTT (ActChgCrsSta + 134) -#define ActChgCrsTT (ActChgCrsSta + 135) -#define ActChgCrsTT1stDay (ActChgCrsSta + 136) +#define ActPrnCrsTT (ActChgCrsSta + 134) +#define ActEdiCrsTT (ActChgCrsSta + 135) +#define ActChgCrsTT (ActChgCrsSta + 136) +#define ActChgCrsTT1stDay (ActChgCrsSta + 137) /*****************************************************************************/ /***************************** Assessment tab ********************************/ diff --git a/swad_changelog.h b/swad_changelog.h index 98b3ad46..209e8990 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -606,17 +606,27 @@ 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 22.2 (2022-09-13)" -#define CSS_FILE "swad21.107.1.css" +#define Log_PLATFORM_VERSION "SWAD 22.3 (2022-09-14)" +#define CSS_FILE "swad22.3.css" #define JS_FILE "swad21.100.js" /* + Version 22.3: Sep 14, 2022 Listing program resource clipboard. (? lines) + 4 changes necessary in database: +ALTER TABLE prg_clipboards CHANGE COLUMN Type Type ENUM('non','asg','cfe','exa','gam','svy','doc','mrk','att','for') NOT NULL DEFAULT 'non'; +ALTER TABLE prg_resources DROP COLUMN Type; +ALTER TABLE prg_resources ADD COLUMN Type ENUM('non','asg','cfe','exa','gam','svy','doc','mrk','att','for') NOT NULL DEFAULT 'non' AFTER Hidden; +ALTER TABLE prg_resources ADD COLUMN Cod INT NOT NULL DEFAULT -1 AFTER Type; + +Copy the following icons to icon public directory: +sudo cp icon/link-slash.svg /var/www/html/swad/icon/ + Version 22.2: Sep 13, 2022 Code refactoring in program resources. (329795 lines) Version 22.1: Sep 13, 2022 Code refactoring in program resources. (329693 lines) Version 22.0: Sep 12, 2022 New action to change resource link. Not implemented. (329606 lines) Version 21.117.1: Sep 12, 2022 Copy link to file into resource clipboard. (329561 lines) Version 21.117: Sep 12, 2022 New database table with clipboards for program resources. New actions to get link to file in course document area. (329514 lines) - 1 change necessary in database: + 2 changes necessary in database: ALTER TABLE prg_resources ADD COLUMN Type ENUM('none','asg','cfe','exa','gam','svy','doc','mrk','att','for') NOT NULL DEFAULT 'none' AFTER Hidden; CREATE TABLE IF NOT EXISTS prg_clipboards (UsrCod INT NOT NULL,CrsCod INT NOT NULL,Type ENUM('none','asg','cfe','exa','gam','svy','doc','mrk','att','for') NOT NULL DEFAULT 'none',Cod INT NOT NULL DEFAULT -1,CopyTime TIMESTAMP,UNIQUE INDEX(UsrCod,CrsCod,Type,Cod),INDEX(CrsCod,Type,Cod),INDEX(CopyTime)); If you want to use MyISAM: diff --git a/swad_database.c b/swad_database.c index d3cd53b9..c33efee7 100644 --- a/swad_database.c +++ b/swad_database.c @@ -2453,22 +2453,22 @@ mysql> DESCRIBE plg_plugins; /***** Table prg_clipboards *****/ /* mysql> DESCRIBE prg_clipboards; -+----------+--------------------------------------------------------------------+------+-----+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+----------+--------------------------------------------------------------------+------+-----+---------+-------+ -| UsrCod | int | NO | PRI | NULL | | -| CrsCod | int | NO | PRI | NULL | | -| Type | enum('none','asg','cfe','exa','gam','svy','doc','mrk','att','for') | NO | PRI | none | | -| Cod | int | NO | PRI | -1 | | -| CopyTime | timestamp | YES | MUL | NULL | | -+----------+--------------------------------------------------------------------+------+-----+---------+-------+ ++----------+-------------------------------------------------------------------+------+-----+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++----------+-------------------------------------------------------------------+------+-----+---------+-------+ +| UsrCod | int | NO | PRI | NULL | | +| CrsCod | int | NO | PRI | NULL | | +| Type | enum('non','asg','cfe','exa','gam','svy','doc','mrk','att','for') | NO | PRI | non | | +| Cod | int | NO | PRI | -1 | | +| CopyTime | timestamp | YES | MUL | NULL | | ++----------+-------------------------------------------------------------------+------+-----+---------+-------+ 5 rows in set (0,00 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS prg_clipboards (" "UsrCod INT NOT NULL," "CrsCod INT NOT NULL," "Type ENUM(" - "'none'," + "'non'," "'asg'," "'cfe'," "'exa'," @@ -2477,7 +2477,7 @@ mysql> DESCRIBE prg_clipboards; "'doc'," "'mrk'," "'att'," - "'for') NOT NULL DEFAULT 'none'," + "'for') NOT NULL DEFAULT 'non'," "Cod INT NOT NULL DEFAULT -1," "CopyTime TIMESTAMP," "UNIQUE INDEX(UsrCod,CrsCod,Type,Cod)," @@ -2520,17 +2520,18 @@ mysql> DESCRIBE prg_items; /***** Table prg_resources *****/ /* mysql> DESCRIBE prg_resources; -+--------+--------------------------------------------------------------------+------+-----+---------+----------------+ -| Field | Type | Null | Key | Default | Extra | -+--------+--------------------------------------------------------------------+------+-----+---------+----------------+ -| RscCod | int | NO | PRI | NULL | auto_increment | -| ItmCod | int | NO | MUL | -1 | | -| RscInd | int | NO | | 0 | | -| Hidden | enum('N','Y') | NO | | N | | -| Type | enum('none','asg','cfe','exa','gam','svy','doc','mrk','att','for') | NO | | none | | -| Title | varchar(2047) | NO | | NULL | | -+--------+--------------------------------------------------------------------+------+-----+---------+----------------+ -6 rows in set (0,00 sec) ++--------+-------------------------------------------------------------------+------+-----+---------+----------------+ +| Field | Type | Null | Key | Default | Extra | ++--------+-------------------------------------------------------------------+------+-----+---------+----------------+ +| RscCod | int | NO | PRI | NULL | auto_increment | +| ItmCod | int | NO | MUL | -1 | | +| RscInd | int | NO | | 0 | | +| Hidden | enum('N','Y') | NO | | N | | +| Type | enum('non','asg','cfe','exa','gam','svy','doc','mrk','att','for') | NO | | non | | +| Cod | int | NO | | -1 | | +| Title | varchar(2047) | NO | | NULL | | ++--------+-------------------------------------------------------------------+------+-----+---------+----------------+ +7 rows in set (0,00 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS prg_resources (" "RscCod INT NOT NULL AUTO_INCREMENT," @@ -2538,7 +2539,7 @@ mysql> DESCRIBE prg_resources; "RscInd INT NOT NULL DEFAULT 0," "Hidden ENUM('N','Y') NOT NULL DEFAULT 'N'," "Type ENUM(" - "'none'," + "'non'," "'asg'," "'cfe'," "'exa'," @@ -2547,7 +2548,7 @@ mysql> DESCRIBE prg_resources; "'doc'," "'mrk'," "'att'," - "'for') NOT NULL DEFAULT 'none'," + "'for') NOT NULL DEFAULT 'non'," "Title VARCHAR(2047) NOT NULL," // PrgRsc_MAX_BYTES_PROGRAM_RESOURCE_TITLE "UNIQUE INDEX(RscCod)," "UNIQUE INDEX(ItmCod,RscInd))"); diff --git a/swad_program.c b/swad_program.c index 3fda4ee0..b7dbc795 100644 --- a/swad_program.c +++ b/swad_program.c @@ -1232,6 +1232,9 @@ void Prg_ResetItem (struct Prg_Item *Item) Item->Resource.Hierarchy.RscCod = -1L; Item->Resource.Hierarchy.RscInd = 0; Item->Resource.Hierarchy.Hidden = false; + Item->Resource.Type = PrgRsc_NONE; + Item->Resource.Cod = -1L; + Item->Resource.Title[0] = '\0'; Item->Resource.Title[0] = '\0'; } @@ -1300,7 +1303,7 @@ void Prg_ReqRemItem (void) /***** Get list of program items *****/ Prg_GetListItems (); - /***** Get data of the program item from database *****/ + /***** Get program item *****/ Prg_GetParams (&Item); if (Item.Hierarchy.ItmCod <= 0) Err_WrongItemExit (); @@ -1334,7 +1337,7 @@ void Prg_RemoveItem (void) /***** Get list of program items *****/ Prg_GetListItems (); - /***** Get data of the program item from database *****/ + /***** Get program item *****/ Prg_GetParams (&Item); if (Item.Hierarchy.ItmCod <= 0) Err_WrongItemExit (); @@ -1381,7 +1384,7 @@ static void Prg_HideOrUnhideItem (bool Hide) /***** Get list of program items *****/ Prg_GetListItems (); - /***** Get data of the item from database *****/ + /***** Get program item *****/ Prg_GetParams (&Item); if (Item.Hierarchy.ItmCod <= 0) Err_WrongItemExit (); @@ -1425,7 +1428,7 @@ static void Prg_MoveUpDownItem (Prg_MoveUpDown_t UpDown) /***** Get list of program items *****/ Prg_GetListItems (); - /***** Get data of the item from database *****/ + /***** Get program item *****/ Prg_GetParams (&Item); if (Item.Hierarchy.ItmCod <= 0) Err_WrongItemExit (); @@ -1626,7 +1629,7 @@ static void Prg_MoveLeftRightItem (Prg_MoveLeftRight_t LeftRight) /***** Get list of program items *****/ Prg_GetListItems (); - /***** Get data of the item from database *****/ + /***** Get program item *****/ Prg_GetParams (&Item); if (Item.Hierarchy.ItmCod <= 0) Err_WrongItemExit (); @@ -1731,7 +1734,7 @@ void Prg_ViewItemAfterEdit (void) /***** Get list of program items *****/ Prg_GetListItems (); - /***** Get the code of the program item *****/ + /***** Get program item *****/ Prg_GetParams (&Item); /***** Show current program items, if any *****/ @@ -1752,7 +1755,7 @@ void Prg_RequestChangeItem (void) /***** Get list of program items *****/ Prg_GetListItems (); - /***** Get the code of the program item *****/ + /***** Get program item *****/ Prg_GetParams (&Item); /***** Show current program items, if any *****/ @@ -1773,7 +1776,7 @@ void Prg_RequestCreateItem (void) /***** Get list of program items *****/ Prg_GetListItems (); - /***** Get the code of the parent program item *****/ + /***** Get program item *****/ Prg_GetParams (&Item); /***** Show current program items, if any *****/ @@ -1946,7 +1949,7 @@ void Prg_ReceiveFormChgItem (void) /***** Get list of program items *****/ Prg_GetListItems (); - /***** Get data of the item from database *****/ + /***** Get program item *****/ Prg_GetParams (&Item); if (Item.Hierarchy.ItmCod <= 0) Err_WrongItemExit (); @@ -1990,7 +1993,7 @@ void Prg_ReceiveFormNewItem (void) /***** Get list of program items *****/ Prg_GetListItems (); - /***** Get data of the program item from database *****/ + /***** Get program item *****/ Prg_GetParams (&Item); // If item code <= 0 ==> this is the first item in the program diff --git a/swad_program.h b/swad_program.h index 2908993d..a4488ba3 100644 --- a/swad_program.h +++ b/swad_program.h @@ -47,11 +47,28 @@ struct Prg_ResourceHierarchy bool Hidden; }; -struct Prg_Resource +#define PrgRsc_NUM_TYPES 10 +typedef enum { - struct Prg_ResourceHierarchy Hierarchy; - char Title[PrgRsc_MAX_BYTES_PROGRAM_RESOURCE_TITLE + 1]; - }; + PrgRsc_NONE, + // gui TEACHING_GUIDE // Link to teaching guide + // bib BIBLIOGRAPHY // Link to bibliography + // faq FAQ // Link to FAQ + // lnk LINKS // Link to links + // tmt TIMETABLE // Link to timetable + PrgRsc_ASSIGNMENT, + // prj PROJECT // A project is only for some students + PrgRsc_CALL_FOR_EXAM, + // tst TEST // User selects tags, teacher should select + PrgRsc_EXAM, + PrgRsc_GAME, + PrgRsc_SURVEY, + PrgRsc_DOCUMENT, + PrgRsc_MARKS, + // grp GROUPS // ??? User select groups + PrgRsc_ATTENDANCE_EVENT, + PrgRsc_FORUM_THREAD, + } PrgRsc_Type_t; #define Prg_MAX_CHARS_PROGRAM_ITEM_TITLE (128 - 1) // 127 #define Prg_MAX_BYTES_PROGRAM_ITEM_TITLE ((Prg_MAX_CHARS_PROGRAM_ITEM_TITLE + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 @@ -72,7 +89,13 @@ struct Prg_Item time_t TimeUTC[Dat_NUM_START_END_TIME]; bool Open; char Title[Prg_MAX_BYTES_PROGRAM_ITEM_TITLE + 1]; - struct Prg_Resource Resource; + struct + { + struct Prg_ResourceHierarchy Hierarchy; + PrgRsc_Type_t Type; + long Cod; + char Title[PrgRsc_MAX_BYTES_PROGRAM_RESOURCE_TITLE + 1]; + } Resource; }; struct Prg_ItemRange diff --git a/swad_program_database.c b/swad_program_database.c index 0ba05685..629a2e5a 100644 --- a/swad_program_database.c +++ b/swad_program_database.c @@ -509,7 +509,9 @@ unsigned Prg_DB_GetListResources (MYSQL_RES **mysql_res,long ItmCod, "prg_resources.RscCod," // row[1] "prg_resources.RscInd," // row[2] "prg_resources.Hidden," // row[3] - "prg_resources.Title" // row[4] + "prg_resources.Type," // row[4] + "prg_resources.Cod," // row[5] + "prg_resources.Title" // row[6] " FROM prg_resources," "prg_items" " WHERE prg_resources.ItmCod=%ld" @@ -534,7 +536,9 @@ unsigned Prg_DB_GetDataOfResourceByCod (MYSQL_RES **mysql_res,long RscCod) "prg_resources.RscCod," // row[1] "prg_resources.RscInd," // row[2] "prg_resources.Hidden," // row[3] - "prg_resources.Title" // row[4] + "prg_resources.Type," // row[4] + "prg_resources.Cod," // row[5] + "prg_resources.Title" // row[6] " FROM prg_resources," "prg_items" " WHERE prg_resources.RscCod=%ld" @@ -544,30 +548,6 @@ unsigned Prg_DB_GetDataOfResourceByCod (MYSQL_RES **mysql_res,long RscCod) Gbl.Hierarchy.Crs.CrsCod); } -/*****************************************************************************/ -/****************** Get item resource data using its code ********************/ -/*****************************************************************************/ - -unsigned Prg_DB_GetDataOfResourceByInd (MYSQL_RES **mysql_res, - long ItmCod,unsigned RscInd) - { - return (unsigned) - DB_QuerySELECT (mysql_res,"can not get item resource data", - "SELECT prg_resources.ItmCod," // row[0] - "prg_resources.RscCod," // row[1] - "prg_resources.RscInd," // row[2] - "prg_resources.Hidden," // row[3] - "prg_resources.Title" // row[4] - " FROM prg_resources," - "prg_items" - " WHERE prg_resources.ItmCod=%ld" - " AND prg_resources.RscInd=%u" - " AND prg_resources.ItmCod=prg_items.ItmCod" - " AND prg_items.CrsCod=%ld", // Extra check - ItmCod,RscInd, - Gbl.Hierarchy.Crs.CrsCod); - } - /*****************************************************************************/ /************* Get the resource index before/after a given one ***************/ /*****************************************************************************/ @@ -672,22 +652,26 @@ void Prg_DB_UpdateRscInd (long RscCod,int RscInd) RscCod); } +/*****************************************************************************/ +/************* Update the link of a resource given its code *****************/ +/*****************************************************************************/ + +void Prg_DB_UpdateRscLink (long RscCod,PrgRsc_Type_t Type,long Cod) + { + DB_QueryUPDATE ("can not update link of resource", + "UPDATE prg_resources" + " SET Type='%s'," + "Cod=%ld" + " WHERE RscCod=%ld", + Prg_ResourceTypesDB[Type], + Cod, + RscCod); + } + /*****************************************************************************/ /********************** Copy link to resource into clipboard *****************/ /*****************************************************************************/ -/* -mysql> DESCRIBE prg_clipboards; -+----------+--------------------------------------------------------------------+------+-----+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+----------+--------------------------------------------------------------------+------+-----+---------+-------+ -| UsrCod | int | NO | PRI | NULL | | -| CrsCod | int | NO | PRI | NULL | | -| Type | enum('none','asg','cfe','exa','gam','svy','doc','mrk','att','for') | NO | PRI | none | | -| Cod | int | NO | PRI | -1 | | -| CopyTime | timestamp | YES | MUL | NULL | | -+----------+--------------------------------------------------------------------+------+-----+---------+-------+ -5 rows in set (0,00 sec) -*/ + void Prg_DB_CopyToClipboard (PrgRsc_Type_t Type,long Cod) { DB_QueryREPLACE ("can not copy link to resource clipboard", @@ -704,16 +688,6 @@ void Prg_DB_CopyToClipboard (PrgRsc_Type_t Type,long Cod) /*****************************************************************************/ /**************** Get resources in the current course clipboard **************/ /*****************************************************************************/ -/* -mysql> SELECT * FROM prg_clipboards; -+--------+--------+------+-----+---------------------+ -| UsrCod | CrsCod | Type | Cod | CopyTime | -+--------+--------+------+-----+---------------------+ -| 1 | 1 | doc | 33 | 2022-09-12 12:08:25 | -| 1 | 1 | doc | 28 | 2022-09-12 12:08:31 | -+--------+--------+------+-----+---------------------+ -2 rows in set (0,00 sec) -*/ unsigned Prg_DB_GetClipboard (MYSQL_RES **mysql_res) { @@ -730,24 +704,19 @@ unsigned Prg_DB_GetClipboard (MYSQL_RES **mysql_res) } /*****************************************************************************/ -/********************** Get resource data from clipboard *********************/ +/*************************** Remove link from clipboard **********************/ /*****************************************************************************/ -void PrgRsc_GetDataOfLinkFromClipboard (struct PrgRsc_Link *Link, - MYSQL_RES **mysql_res) +void Prg_DB_RemoveLinkFromClipboard (PrgRsc_Type_t Type,long Cod) { - MYSQL_ROW row; - - /***** Get data of item resource from database *****/ - /* Get row */ - row = mysql_fetch_row (*mysql_res); - /* - Type row[0] - Cod row[1] - */ - /* Get type (row[0]) */ - Link->Type = PrgRsc_GetTypeFromString (row[0]); - - /* Get code (row[1]) */ - Link->Cod = Str_ConvertStrCodToLongCod (row[1]); + DB_QueryDELETE ("can not remove link from clipboard", + "DELETE FROM prg_clipboards" + " WHERE UsrCod=%ld" + " AND CrsCod=%ld" + " AND Type='%s'" + " AND Cod=%ld", + Gbl.Usrs.Me.UsrDat.UsrCod, + Gbl.Hierarchy.Crs.CrsCod, + Prg_ResourceTypesDB[Type], + Cod); } diff --git a/swad_program_database.h b/swad_program_database.h index a3529a67..153589d9 100644 --- a/swad_program_database.h +++ b/swad_program_database.h @@ -64,8 +64,7 @@ void Prg_DB_UpdateResourceTitle (long ItmCod,long RscCod, unsigned Prg_DB_GetListResources (MYSQL_RES **mysql_res,long ItmCod, bool ShowHiddenResources); unsigned Prg_DB_GetDataOfResourceByCod (MYSQL_RES **mysql_res,long RscCod); -unsigned Prg_DB_GetDataOfResourceByInd (MYSQL_RES **mysql_res, - long ItmCod,unsigned RscInd); + unsigned Prg_DB_GetRscIndBefore (long ItmCod,unsigned RscInd); unsigned Prg_DB_GetRscIndAfter (long ItmCod,unsigned RscInd); long Prg_DB_GetRscCodFromRscInd (long ItmCod,unsigned RscInd); @@ -76,11 +75,10 @@ void Prg_DB_HideOrUnhideResource (long RscCod,bool Hide); void Prg_DB_LockTableResources (void); void Prg_DB_UpdateRscInd (long RscCod,int RscInd); +void Prg_DB_UpdateRscLink (long RscCod,PrgRsc_Type_t Type,long Cod); void Prg_DB_CopyToClipboard (PrgRsc_Type_t Type,long Cod); - unsigned Prg_DB_GetClipboard (MYSQL_RES **mysql_res); -void PrgRsc_GetDataOfLinkFromClipboard (struct PrgRsc_Link *Link, - MYSQL_RES **mysql_res); +void Prg_DB_RemoveLinkFromClipboard (PrgRsc_Type_t Type,long Cod); #endif diff --git a/swad_program_resource.c b/swad_program_resource.c index 6733f383..311910ec 100644 --- a/swad_program_resource.c +++ b/swad_program_resource.c @@ -34,6 +34,32 @@ #include "swad_program_database.h" #include "swad_program_resource.h" +/*****************************************************************************/ +/**************************** Private constants ******************************/ +/*****************************************************************************/ + +const char *Prg_ResourceTypesLogos[PrgRsc_NUM_TYPES] = + { + [PrgRsc_NONE ] = "link-slash.svg", + // gui TEACHING_GUIDE // Link to teaching guide + // bib BIBLIOGRAPHY // Link to bibliography + // faq FAQ // Link to FAQ + // lnk LINKS // Link to links + // tmt TIMETABLE // Link to timetable + [PrgRsc_ASSIGNMENT ] = "edit.svg", + // prj PROJECT // A project is only for some students + [PrgRsc_CALL_FOR_EXAM ] = "bullhorn.svg", + // tst TEST // User selects tags, teacher should select + [PrgRsc_EXAM ] = "file-signature.svg", + [PrgRsc_GAME ] = "gamepad.svg", + [PrgRsc_SURVEY ] = "poll.svg", + [PrgRsc_DOCUMENT ] = "file.svg", + [PrgRsc_MARKS ] = "list-alt.svg", + // grp GROUPS // ??? User select groups + [PrgRsc_ATTENDANCE_EVENT] = "calendar-check.svg", + [PrgRsc_FORUM_THREAD ] = "comments.svg", + }; + /*****************************************************************************/ /************** External global variables from others modules ****************/ /*****************************************************************************/ @@ -85,9 +111,11 @@ static void PrgRsc_MoveUpDownResource (PrgRsc_MoveUpDown_t UpDown); static bool PrgRsc_ExchangeResources (const struct Prg_ResourceHierarchy *Rsc1, const struct Prg_ResourceHierarchy *Rsc2); -static void PrgRsc_ShowClipboard (void); -static void PrgRsc_WriteRowViewLink (unsigned NumLink, - const struct PrgRsc_Link *Link); +static void PrgRsc_ShowClipboard (const struct Prg_Item *Item); +static void PrgRsc_WriteRowClipboard (unsigned NumLink, + const struct PrgRsc_Link *Link); +static void PrgRsc_GetDataOfLinkFromClipboard (struct PrgRsc_Link *Link, + MYSQL_RES **mysql_res); /*****************************************************************************/ /****************************** View resources *******************************/ @@ -100,7 +128,7 @@ void PrgRsc_ViewResourcesAfterEdit (void) /***** Get list of program items *****/ Prg_GetListItems (); - /***** Get the code of the program item *****/ + /***** Get program item *****/ Prg_GetParams (&Item); /***** Show current program items, if any *****/ @@ -121,7 +149,7 @@ void PrgRsc_EditResources (void) /***** Get list of program items *****/ Prg_GetListItems (); - /***** Get the code of the program item *****/ + /***** Get program item *****/ Prg_GetParams (&Item); /***** Show current program items, if any *****/ @@ -362,7 +390,9 @@ static void PrgRsc_GetDataOfResource (struct Prg_Item *Item, RscCod row[1] RscInd row[2] Hidden row[3] - Title row[4] + Type row[4] + Cod row[5] + Title row[6] */ /* Get code of the program item (row[0]) */ Item->Hierarchy.ItmCod = Str_ConvertStrCodToLongCod (row[0]); @@ -374,8 +404,12 @@ static void PrgRsc_GetDataOfResource (struct Prg_Item *Item, /* Get whether the program item is hidden (row(3)) */ Item->Resource.Hierarchy.Hidden = (row[3][0] == 'Y'); - /* Get the title of the item resource (row[4]) */ - Str_Copy (Item->Resource.Title,row[4],sizeof (Item->Resource.Title) - 1); + /* Get link type and code (row[4], row[5]) */ + Item->Resource.Type = PrgRsc_GetTypeFromString (row[4]); + Item->Resource.Cod = Str_ConvertStrCodToLongCod (row[5]); + + /* Get the title of the item resource (row[6]) */ + Str_Copy (Item->Resource.Title,row[6],sizeof (Item->Resource.Title) - 1); } /*****************************************************************************/ @@ -445,8 +479,8 @@ static void PrgRsc_WriteRowEditResource (Prg_ListingType_t ListingType, HTM_TD_End (); /***** Icon to edit link *****/ - HTM_TD_Begin ("class=\"PRG_MAIN LT %s\"",The_GetColorRows1 (1)); - Ico_PutContextualIconToGetLink (ActChgLnkPrgRsc,PrgRsc_RESOURCE_SECTION_ID, + HTM_TD_Begin ("class=\"PRG_MAIN RT %s\"",The_GetColorRows1 (1)); + Ico_PutContextualIconToGetLink (ActSeeCliPrgRsc,PrgRsc_RESOURCE_SECTION_ID, Prg_PutParams,&ItmRscCodes); HTM_TD_End (); @@ -459,7 +493,7 @@ static void PrgRsc_WriteRowEditResource (Prg_ListingType_t ListingType, /* Show clipboard to change resource link */ if (ListingType == Prg_SHOW_CLIPBOARD && Item->Resource.Hierarchy.RscCod == SelectedItmRscCodes->RscCod) - PrgRsc_ShowClipboard (); + PrgRsc_ShowClipboard (Item); HTM_TD_End (); @@ -475,10 +509,13 @@ static void PrgRsc_WriteRowNewResource (Prg_ListingType_t ListingType, unsigned NumResources, struct Prg_ItmRscCodes *SelectedItmRscCodes) { + struct Prg_Item Item; struct Prg_ItmRscCodes ItmRscCodes; - ItmRscCodes.ItmCod = SelectedItmRscCodes->ItmCod; - ItmRscCodes.RscCod = -1L; + Prg_ResetItem (&Item); + Item.Hierarchy.ItmCod = SelectedItmRscCodes->ItmCod; + ItmRscCodes.ItmCod = Item.Hierarchy.ItmCod; + ItmRscCodes.RscCod = Item.Resource.Hierarchy.RscCod; /***** Begin row *****/ HTM_TR_Begin (NULL); @@ -501,14 +538,14 @@ static void PrgRsc_WriteRowNewResource (Prg_ListingType_t ListingType, HTM_SUBMIT_ON_CHANGE, "placeholder=\"%s\"" " class=\"INPUT_FULL_NAME INPUT_%s\"", - "Nuevo recurso", + "Nuevo recurso", // TODO: Need translation!!!!!!!!!!!!!!!!!!! The_GetSuffix ()); Frm_EndForm (); HTM_TD_End (); /***** Icon to edit link *****/ - HTM_TD_Begin ("class=\"PRG_MAIN LT %s\"",The_GetColorRows1 (1)); - Ico_PutContextualIconToGetLink (ActChgLnkPrgRsc,PrgRsc_RESOURCE_SECTION_ID, + HTM_TD_Begin ("class=\"PRG_MAIN RT %s\"",The_GetColorRows1 (1)); + Ico_PutContextualIconToGetLink (ActSeeCliPrgRsc,PrgRsc_RESOURCE_SECTION_ID, Prg_PutParams,&ItmRscCodes); HTM_TD_End (); @@ -518,7 +555,7 @@ static void PrgRsc_WriteRowNewResource (Prg_ListingType_t ListingType, /* Show clipboard to change resource link */ if (ListingType == Prg_SHOW_CLIPBOARD && SelectedItmRscCodes->RscCod <= 0) // No resource selected - PrgRsc_ShowClipboard (); + PrgRsc_ShowClipboard (&Item); HTM_TD_End (); @@ -557,17 +594,17 @@ static void PrgRsc_PutFormsToRemEditOneResource (unsigned NumRsc, /***** Icon to move up the item *****/ if (NumRsc > 0) - Lay_PutContextualLinkOnlyIcon (ActUp_PrgRsc,PrgRsc_RESOURCE_SECTION_ID, - Prg_PutParams,ItmRscCodes, - "arrow-up.svg",Ico_BLACK); + Lay_PutContextualLinkOnlyIcon (ActUp_PrgRsc,PrgRsc_RESOURCE_SECTION_ID, + Prg_PutParams,ItmRscCodes, + "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 (NumRsc < NumResources - 1) - Lay_PutContextualLinkOnlyIcon (ActDwnPrgRsc,PrgRsc_RESOURCE_SECTION_ID, - Prg_PutParams,ItmRscCodes, - "arrow-down.svg",Ico_BLACK); + Lay_PutContextualLinkOnlyIcon (ActDwnPrgRsc,PrgRsc_RESOURCE_SECTION_ID, + Prg_PutParams,ItmRscCodes, + "arrow-down.svg",Ico_BLACK); else Ico_PutIconOff ("arrow-down.svg",Ico_BLACK,Txt_Movement_not_allowed); break; @@ -609,7 +646,7 @@ void PrgRsc_CreateResource (void) Prg_GetListItems (); /***** Get parameters *****/ - /* Get the code of the program item */ + /* Get program item */ Prg_GetParams (&Item); /* Get the new title for the new resource */ @@ -637,7 +674,7 @@ void PrgRsc_RenameResource (void) /***** Get list of program items *****/ Prg_GetListItems (); - /***** Get data of the item resource from database *****/ + /***** Get program item and resource *****/ Prg_GetParams (&Item); if (Item.Hierarchy.ItmCod <= 0) Err_WrongResourceExit (); @@ -668,7 +705,7 @@ void PrgRsc_ReqRemResource (void) /***** Get list of program items *****/ Prg_GetListItems (); - /***** Get data of the item resource from database *****/ + /***** Get program item and resource *****/ Prg_GetParams (&Item); if (Item.Hierarchy.ItmCod <= 0) Err_WrongResourceExit (); @@ -737,7 +774,7 @@ static void PrgRsc_HideOrUnhideResource (bool Hide) /***** Get list of program items *****/ Prg_GetListItems (); - /***** Get data of the item resource from database *****/ + /***** Get program item and resource *****/ Prg_GetParams (&Item); if (Item.Hierarchy.ItmCod <= 0) Err_WrongResourceExit (); @@ -781,7 +818,7 @@ static void PrgRsc_MoveUpDownResource (PrgRsc_MoveUpDown_t UpDown) /***** Get list of program items *****/ Prg_GetListItems (); - /***** Get data of the item resource from database *****/ + /***** Get program item and resource *****/ Prg_GetParams (&Item); if (Item.Hierarchy.ItmCod <= 0) Err_WrongResourceExit (); @@ -863,7 +900,7 @@ void PrgRsc_ShowClipboardToChgLink (void) /***** Get list of program items *****/ Prg_GetListItems (); - /***** Get data of the item resource from database *****/ + /***** Get program item and resource *****/ Prg_GetParams (&Item); if (Item.Hierarchy.ItmCod <= 0) Err_WrongResourceExit (); @@ -875,42 +912,154 @@ void PrgRsc_ShowClipboardToChgLink (void) Prg_FreeListItems (); } -static void PrgRsc_ShowClipboard (void) +/*****************************************************************************/ +/***************** Show clipboard to change resource link ********************/ +/*****************************************************************************/ + +static void PrgRsc_ShowClipboard (const struct Prg_Item *Item) { MYSQL_RES *mysql_res; unsigned NumLink; unsigned NumLinks; struct PrgRsc_Link Link; + struct Prg_ItmRscCodes ItmRscCodes; - /***** Get list of item resources from database *****/ - NumLinks = Prg_DB_GetClipboard (&mysql_res); - if (NumLinks) + ItmRscCodes.ItmCod = Item->Hierarchy.ItmCod; + ItmRscCodes.RscCod = Item->Resource.Hierarchy.RscCod; + + /***** Begin form *****/ + Frm_BeginFormAnchor (ActChgLnkPrgRsc,PrgRsc_RESOURCE_SECTION_ID); + Prg_PutParams (&ItmRscCodes); + + /***** Begin list *****/ + HTM_UL_Begin ("class=\"PRG_CLIPBOARD\""); + + /***** Current link *****/ + Link.Type = Item->Resource.Type; + Link.Cod = Item->Resource.Cod; + PrgRsc_WriteRowClipboard (0,&Link); + + /***** Get list of item resources from database *****/ + NumLinks = Prg_DB_GetClipboard (&mysql_res); + + /***** Write all item resources *****/ + for (NumLink = 1; + NumLink <= NumLinks; + NumLink++) + { + /* Get data of this link */ + PrgRsc_GetDataOfLinkFromClipboard (&Link,&mysql_res); + + /* Show link */ + PrgRsc_WriteRowClipboard (NumLink,&Link); + } + + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); + + /***** End list *****/ + HTM_UL_End (); + + /***** End form *****/ + Frm_EndForm (); + } + +/*****************************************************************************/ +/************************ Show one link from clipboard ***********************/ +/*****************************************************************************/ + +static void PrgRsc_WriteRowClipboard (unsigned NumLink, + const struct PrgRsc_Link *Link) + { + extern const char *Prg_ResourceTypesDB[PrgRsc_NUM_TYPES]; + + HTM_LI_Begin ("class=\"DAT_%s\"",The_GetSuffix ()); + HTM_LABEL_Begin (NULL); + if (NumLink) + HTM_INPUT_RADIO ("Link",true, + "value=\"%s_%ld\"", + Prg_ResourceTypesDB[Link->Type],Link->Cod); + else + HTM_INPUT_RADIO ("Link",false, + "value=\"%s_%ld\" checked=\"checked\"", + Prg_ResourceTypesDB[Link->Type],Link->Cod); + + /***** Type *****/ + Ico_PutIconOn (Prg_ResourceTypesLogos[Link->Type],Ico_BLACK,Prg_ResourceTypesDB[Link->Type]); + + /***** Code *****/ + if (Link->Cod > 0) + HTM_Long (Link->Cod); + else + HTM_Txt ("sin enlace"); // TODO: Need translation!!!!! + + HTM_LABEL_End (); + HTM_LI_End (); + } + +/*****************************************************************************/ +/***************** Show clipboard to change resource link ********************/ +/*****************************************************************************/ + +void PrgRsc_ChangeLink (void) + { + extern const char *Prg_ResourceTypesDB[PrgRsc_NUM_TYPES]; + struct Prg_Item Item; + char TypeCod[3 + 1 + Cns_MAX_DECIMAL_DIGITS_LONG + 1]; + char TypeStr[3 + 1]; + PrgRsc_Type_t Type; + long Cod; + + /***** Get list of program items *****/ + Prg_GetListItems (); + + /***** Get parameters *****/ + /* Get program item and resource */ + Prg_GetParams (&Item); + if (Item.Hierarchy.ItmCod <= 0) + Err_WrongResourceExit (); + + /* Get link type and code */ + Par_GetParToText ("Link",TypeCod,sizeof (TypeCod) - 1); + if (sscanf (TypeCod,"%3s_%ld",TypeStr,&Cod) == 2) { - /***** Table *****/ - HTM_TABLE_BeginWideMarginPadding (2); - HTM_TBODY_Begin (NULL); + Type = PrgRsc_GetTypeFromString (TypeStr); - /***** Write all item resources *****/ - for (NumLink = 0, The_ResetRowColor1 (2); - NumLink < NumLinks; - NumLink++, The_ChangeRowColor1 (2)) - { - /* Get data of this link */ - PrgRsc_GetDataOfLinkFromClipboard (&Link,&mysql_res); + /***** Update resource link *****/ + Prg_DB_UpdateRscLink (Item.Resource.Hierarchy.RscCod,Type,Cod); - /* Show link */ - PrgRsc_WriteRowViewLink (NumLink,&Link); - } - - /***** End table *****/ - HTM_TBODY_End (); - HTM_TABLE_End (); + /***** Remove link from clipboard *****/ + Prg_DB_RemoveLinkFromClipboard (Type,Cod); } - else - Ale_ShowAlert (Ale_INFO,"Empty clipboard."); - /***** Free structure that stores the query result *****/ - DB_FreeMySQLResult (&mysql_res); + /***** Show current program items, if any *****/ + Prg_ShowAllItems (Prg_SHOW_CLIPBOARD,Item.Hierarchy.ItmCod,Item.Resource.Hierarchy.RscCod); + + /***** Free list of program items *****/ + Prg_FreeListItems (); + } + +/*****************************************************************************/ +/********************** Get resource data from clipboard *********************/ +/*****************************************************************************/ + +static void PrgRsc_GetDataOfLinkFromClipboard (struct PrgRsc_Link *Link, + MYSQL_RES **mysql_res) + { + MYSQL_ROW row; + + /***** Get data of item resource from database *****/ + /* Get row */ + row = mysql_fetch_row (*mysql_res); + /* + Type row[0] + Cod row[1] + */ + /* Get type (row[0]) */ + Link->Type = PrgRsc_GetTypeFromString (row[0]); + + /* Get code (row[1]) */ + Link->Cod = Str_ConvertStrCodToLongCod (row[1]); } /*****************************************************************************/ @@ -931,37 +1080,3 @@ PrgRsc_Type_t PrgRsc_GetTypeFromString (const char *Str) return PrgRsc_NONE; } - -/*****************************************************************************/ -/************************ Show one link from clipboard ***********************/ -/*****************************************************************************/ - -static void PrgRsc_WriteRowViewLink (unsigned NumLink, - const struct PrgRsc_Link *Link) - { - extern const char *Prg_ResourceTypesDB[PrgRsc_NUM_TYPES]; - - /***** Begin row *****/ - HTM_TR_Begin (NULL); - - /***** Link number *****/ - HTM_TD_Begin ("class=\"PRG_NUM PRG_RSC_%s RT %s\"", - The_GetSuffix (),The_GetColorRows1 (2)); - HTM_Unsigned (NumLink + 1); - HTM_TD_End (); - - /***** Type *****/ - HTM_TD_Begin ("class=\"PRG_MAIN PRG_RSC_%s %s\"", - The_GetSuffix (),The_GetColorRows1 (2)); - HTM_Txt (Prg_ResourceTypesDB[Link->Type]); - HTM_TD_End (); - - /***** Code *****/ - HTM_TD_Begin ("class=\"PRG_MAIN PRG_RSC_%s %s\"", - The_GetSuffix (),The_GetColorRows1 (2)); - HTM_Long (Link->Cod); - HTM_TD_End (); - - /***** End row *****/ - HTM_TR_End (); - } diff --git a/swad_program_resource.h b/swad_program_resource.h index ab1543e3..b5f591f1 100644 --- a/swad_program_resource.h +++ b/swad_program_resource.h @@ -31,29 +31,6 @@ /************************** Public types and constants ***********************/ /*****************************************************************************/ -#define PrgRsc_NUM_TYPES 10 -typedef enum - { - PrgRsc_NONE, - // gui TEACHING_GUIDE // Link to teaching guide - // bib BIBLIOGRAPHY // Link to bibliography - // faq FAQ // Link to FAQ - // lnk LINKS // Link to links - // tmt TIMETABLE // Link to timetable - PrgRsc_ASSIGNMENT, - // prj PROJECT // A project is only for some students - PrgRsc_CALL_FOR_EXAM, - // tst TEST // User selects tags, teacher should select - PrgRsc_EXAM, - PrgRsc_GAME, - PrgRsc_SURVEY, - PrgRsc_DOCUMENT, - PrgRsc_MARKS, - // grp GROUPS // ??? User select groups - PrgRsc_ATTENDANCE_EVENT, - PrgRsc_FORUM_THREAD, - } PrgRsc_Type_t; - struct PrgRsc_Link { PrgRsc_Type_t Type; @@ -89,6 +66,7 @@ void PrgRsc_MoveUpResource (void); void PrgRsc_MoveDownResource (void); void PrgRsc_ShowClipboardToChgLink (void); +void PrgRsc_ChangeLink (void); PrgRsc_Type_t PrgRsc_GetTypeFromString (const char *Str); diff --git a/swad_text_action.c b/swad_text_action.c index 1803ded7..3730ab4e 100644 --- a/swad_text_action.c +++ b/swad_text_action.c @@ -6270,6 +6270,29 @@ const char *Txt_Actions[Act_NUM_ACTIONS] = "Move down resource" // Precisa de tradução #elif L==10 // tr "Move down resource" // Çeviri lazim! +#endif + , + [ActSeeCliPrgRsc] = +#if L==1 // ca + "Edit resource link" // Necessita traducció +#elif L==2 // de + "Edit resource link" // Need Übersetzung +#elif L==3 // en + "Edit resource link" +#elif L==4 // es + "Editar enlace de recurso" +#elif L==5 // fr + "Edit resource link" // Besoin de traduction +#elif L==6 // gn + "Editar enlace de recurso" // Okoteve traducción +#elif L==7 // it + "Edit resource link" // Bisogno di traduzione +#elif L==8 // pl + "Edit resource link" // Potrzebujesz tlumaczenie +#elif L==9 // pt + "Edit resource link" // Precisa de tradução +#elif L==10 // tr + "Edit resource link" // Çeviri lazim! #endif , [ActChgLnkPrgRsc] = diff --git a/swad_theme.c b/swad_theme.c index 33c8d701..24dabc6e 100644 --- a/swad_theme.c +++ b/swad_theme.c @@ -234,7 +234,7 @@ static const char *The_ClassColorRows[2][The_NUM_THEMES] = const char *The_GetColorRows (void) { - return The_ClassColorRows[The_RowEvenOdd[0]][Gbl.Prefs.Theme]; + return The_GetColorRows1 (0); } const char *The_GetColorRows1 (unsigned Level) @@ -244,7 +244,7 @@ const char *The_GetColorRows1 (unsigned Level) void The_ResetRowColor (void) { - The_RowEvenOdd[0] = 0; + The_ResetRowColor1 (0); } void The_ResetRowColor1 (unsigned Level) @@ -254,7 +254,7 @@ void The_ResetRowColor1 (unsigned Level) void The_ChangeRowColor (void) { - The_RowEvenOdd[0] = 1 - The_RowEvenOdd[0]; + The_ChangeRowColor1 (0); } void The_ChangeRowColor1 (unsigned Level)