From 036375ffe7c5d1ffd5a41be2a9b95b1e5d5921df Mon Sep 17 00:00:00 2001 From: acanas Date: Thu, 29 Sep 2022 09:50:31 +0200 Subject: [PATCH] Version 22.33: Sep 29, 2022 Changes in program resources, documents and mark files. --- swad_browser.c | 23 ++++--- swad_browser_resource.c | 145 ++++++++++++++++++++++++---------------- swad_changelog.h | 12 ++-- swad_program_resource.c | 2 +- 4 files changed, 109 insertions(+), 73 deletions(-) diff --git a/swad_browser.c b/swad_browser.c index e29b301d..d836a920 100644 --- a/swad_browser.c +++ b/swad_browser.c @@ -3575,6 +3575,13 @@ static void Brw_PutIconsFileBrowser (__attribute__((unused)) void *Args) break; } + /***** Put icon to get resource link *****/ + if (Brw_ActReqLnk[Gbl.FileBrowser.Type] != ActUnk && + (Gbl.Usrs.Me.Role.Logged == Rol_TCH || // Only if I am a teacher + Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) // or a superuser + Ico_PutContextualIconToGetLink (Brw_ActReqLnk[Gbl.FileBrowser.Type],NULL, + NULL,NULL); + /***** Put icon to show a figure *****/ switch (Gbl.FileBrowser.Type) { @@ -7855,7 +7862,6 @@ void Brw_ShowFileMetadata (void) bool ICanEdit; bool ICanChangePublic = false; bool FileHasPublisher; - bool PutIconToGetLink; Brw_License_t License; unsigned LicenseUnsigned; @@ -7943,15 +7949,12 @@ void Brw_ShowFileMetadata (void) FileNameToShow); /***** Begin box *****/ - PutIconToGetLink = (Gbl.FileBrowser.Type == Brw_SHOW_DOC_CRS || // Only document zone - Gbl.FileBrowser.Type == Brw_ADMI_DOC_CRS || - Gbl.FileBrowser.Type == Brw_SHOW_MRK_CRS || - Gbl.FileBrowser.Type == Brw_ADMI_MRK_CRS) && - (FileMetadata.FilFolLnk.Type == Brw_IS_FILE || // Only files or links - FileMetadata.FilFolLnk.Type == Brw_IS_LINK) && - (Gbl.Usrs.Me.Role.Logged == Rol_TCH || // Only if I am a teacher - Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM); // or a superuser - if (PutIconToGetLink) + // Put icon to get link? + if (Brw_ActReqLnk[Gbl.FileBrowser.Type] != ActUnk && + (FileMetadata.FilFolLnk.Type == Brw_IS_FILE || // Only files or links + FileMetadata.FilFolLnk.Type == Brw_IS_LINK) && + (Gbl.Usrs.Me.Role.Logged == Rol_TCH || // Only if I am a teacher + Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)) // or a superuser Box_BoxShadowBegin (NULL,NULL, Brw_PutIconToGetLinkToFile,&FileMetadata, NULL); diff --git a/swad_browser_resource.c b/swad_browser_resource.c index d84b55e7..09fec02b 100644 --- a/swad_browser_resource.c +++ b/swad_browser_resource.c @@ -26,6 +26,7 @@ #include "swad_action.h" #include "swad_browser.h" +#include "swad_browser_resource.h" #include "swad_error.h" #include "swad_form.h" #include "swad_global.h" @@ -46,43 +47,42 @@ extern struct Globals Gbl; void BrwRsc_GetLinkToFile (void) { extern const char *Txt_Link_to_resource_X_copied_into_clipboard; - struct Brw_FileMetadata FileMetadata; - bool Found; + long FilCod; + char Title[NAME_MAX + 1]; // File or link name PrgRsc_Type_t Type; /***** Get parameters related to file browser *****/ Brw_GetParAndInitFileBrowser (); - /***** Get file name *****/ - FileMetadata.FilCod = Brw_GetParamFilCod (); - Brw_GetFileNameByCod (&FileMetadata); - Found = Brw_GetFileTypeSizeAndDate (&FileMetadata); + /***** Get file code *****/ + FilCod = Brw_GetParamFilCod (); - if (Found) + /***** Get file title *****/ + switch (Gbl.Action.Act) { - /***** Copy link to file into resource clipboard *****/ - switch (Gbl.Action.Act) - { - case ActReqLnkSeeDocCrs: - case ActReqLnkAdmDocCrs: - Type = PrgRsc_DOCUMENT; - break; - case ActReqLnkSeeMrkCrs: - case ActReqLnkAdmMrkCrs: - Type = PrgRsc_MARKS; - break; - default: - Type = PrgRsc_NONE; // Initialized to avoid warning - Err_WrongTypeExit (); - break; - } - Prg_DB_CopyToClipboard (Type,FileMetadata.FilCod); - - /***** Write sucess message *****/ - Ale_ShowAlert (Ale_SUCCESS,Txt_Link_to_resource_X_copied_into_clipboard, - FileMetadata.FilFolLnk.Name); + case ActReqLnkSeeDocCrs: + case ActReqLnkAdmDocCrs: + Type = PrgRsc_DOCUMENT; + BrwRsc_GetDocTitleFromFilCod (FilCod,Title,sizeof (Title) - 1); + break; + case ActReqLnkSeeMrkCrs: + case ActReqLnkAdmMrkCrs: + Type = PrgRsc_MARKS; + BrwRsc_GetMrkTitleFromFilCod (FilCod,Title,sizeof (Title) - 1); + break; + default: + Type = PrgRsc_NONE; // Initialized to avoid warning + Err_WrongTypeExit (); + break; } + /***** Copy link to file into resource clipboard *****/ + Prg_DB_CopyToClipboard (Type,FilCod); + + /***** Write sucess message *****/ + Ale_ShowAlert (Ale_SUCCESS,Txt_Link_to_resource_X_copied_into_clipboard, + Title); + /***** Show again the file browser *****/ Brw_ShowAgainFileBrowserOrWorks (); } @@ -94,13 +94,25 @@ void BrwRsc_GetLinkToFile (void) void BrwRsc_WriteDocFileNameInCrsProgram (long FilCod,bool PutFormToGo, const char *Icon,const char *IconTitle) { + extern const char *Txt_Documents; extern const char *Txt_Actions[Act_NUM_ACTIONS]; Act_Action_t NextAction; struct Brw_FileMetadata FileMetadata; + char Title[NAME_MAX + 1]; // File or link name /***** Get file metadata *****/ FileMetadata.FilCod = FilCod; - Brw_GetFileMetadataByCod (&FileMetadata); + if (FileMetadata.FilCod > 0) + Brw_GetFileMetadataByCod (&FileMetadata); + // If file doesn't exist ==> file code is changed to -1 + + /***** Set title *****/ + if (FileMetadata.FilCod > 0) + /***** Copy file name into title *****/ + Str_Copy (Title,FileMetadata.FilFolLnk.Name,sizeof (Title) - 1); + else + /***** Generic title for all documents *****/ + Str_Copy (Title,Txt_Documents,sizeof (Title) - 1); /***** Begin form to go to file data *****/ if (PutFormToGo) @@ -108,35 +120,44 @@ void BrwRsc_WriteDocFileNameInCrsProgram (long FilCod,bool PutFormToGo, NextAction = (FileMetadata.FilCod > 0) ? ActReqDatSeeDocCrs : // Document specified ActSeeAdmDocCrsGrp; // All documents Frm_BeginForm (NextAction); - Brw_PutParamsFileBrowser (NULL, // Not used - NULL, // Not used - Brw_IS_UNKNOWN, // Not used - FileMetadata.FilCod); + if (FileMetadata.FilCod > 0) + Brw_PutParamsFileBrowser (NULL, // Not used + NULL, // Not used + Brw_IS_UNKNOWN, // Not used + FileMetadata.FilCod); HTM_BUTTON_Submit_Begin (Txt_Actions[NextAction], "class=\"LM BT_LINK PRG_LNK_%s\"", The_GetSuffix ()); } /***** Icon depending on type ******/ - switch (FileMetadata.FilFolLnk.Type) + if (FileMetadata.FilCod > 0) + switch (FileMetadata.FilFolLnk.Type) + { + case Brw_IS_FILE: + Brw_PutIconFile (FileMetadata.FilFolLnk.Name, + "CONTEXT_OPT ICO_HIGHLIGHT CONTEXT_ICO16x16", + PutFormToGo); // Put link to view metadata + break; + case Brw_IS_LINK: + if (PutFormToGo) + Ico_PutIconLink ("up-right-from-square.svg",Ico_BLACK,NextAction); + else + Ico_PutIconOn ("up-right-from-square.svg",Ico_BLACK,IconTitle); + break; + default: + break; + } + else // Documents zone { - case Brw_IS_FILE: - Brw_PutIconFile (FileMetadata.FilFolLnk.Name, - "CONTEXT_OPT ICO_HIGHLIGHT CONTEXT_ICO16x16", - PutFormToGo); // Put link to view metadata - break; - case Brw_IS_LINK: - if (PutFormToGo) - Ico_PutIconLink (Icon,Ico_BLACK,NextAction); - else - Ico_PutIconOn (Icon,Ico_BLACK,IconTitle); - break; - default: - break; + if (PutFormToGo) + Ico_PutIconLink (Icon,Ico_BLACK,NextAction); + else + Ico_PutIconOn (Icon,Ico_BLACK,IconTitle); } - /***** Write filename *****/ - HTM_Txt (FileMetadata.FilFolLnk.Name); + /***** Write title *****/ + HTM_Txt (Title); /***** End form to download file *****/ if (PutFormToGo) @@ -154,13 +175,25 @@ void BrwRsc_WriteDocFileNameInCrsProgram (long FilCod,bool PutFormToGo, void BrwRsc_WriteMrkFileNameInCrsProgram (long FilCod,bool PutFormToGo, const char *Icon,const char *IconTitle) { + extern const char *Txt_Marks_area; extern const char *Txt_Actions[Act_NUM_ACTIONS]; Act_Action_t NextAction; struct Brw_FileMetadata FileMetadata; + char Title[NAME_MAX + 1]; // File or link name /***** Get file metadata *****/ FileMetadata.FilCod = FilCod; - Brw_GetFileMetadataByCod (&FileMetadata); + if (FileMetadata.FilCod > 0) + Brw_GetFileMetadataByCod (&FileMetadata); + // If file doesn't exist ==> file code is changed to -1 + + /***** Set title *****/ + if (FileMetadata.FilCod > 0) + /***** Copy file name into title *****/ + Str_Copy (Title,FileMetadata.FilFolLnk.Name,sizeof (Title) - 1); + else + /***** Generic title for all documents *****/ + Str_Copy (Title,Txt_Marks_area,sizeof (Title) - 1); /***** Begin form to go to file data *****/ if (PutFormToGo) @@ -168,10 +201,11 @@ void BrwRsc_WriteMrkFileNameInCrsProgram (long FilCod,bool PutFormToGo, NextAction = (FileMetadata.FilCod > 0) ? ActReqDatSeeMrkCrs : // Marks file specified ActSeeAdmMrk; // All marks files Frm_BeginForm (NextAction); - Brw_PutParamsFileBrowser (NULL, // Not used - NULL, // Not used - Brw_IS_UNKNOWN, // Not used - FileMetadata.FilCod); + if (FileMetadata.FilCod > 0) + Brw_PutParamsFileBrowser (NULL, // Not used + NULL, // Not used + Brw_IS_UNKNOWN, // Not used + FileMetadata.FilCod); HTM_BUTTON_Submit_Begin (Txt_Actions[NextAction], "class=\"LM BT_LINK PRG_LNK_%s\"", The_GetSuffix ()); @@ -184,7 +218,7 @@ void BrwRsc_WriteMrkFileNameInCrsProgram (long FilCod,bool PutFormToGo, Ico_PutIconOn (Icon,Ico_BLACK,IconTitle); /***** Write filename *****/ - HTM_Txt (FileMetadata.FilFolLnk.Name); + HTM_Txt (Title); /***** End form to download file *****/ if (PutFormToGo) @@ -218,7 +252,6 @@ void BrwRsc_GetDocTitleFromFilCod (long FilCod,char *Title,size_t TitleSize) Str_Copy (Title,Txt_Documents,TitleSize); } - /*****************************************************************************/ /******************* Get marks file name from file code **********************/ /*****************************************************************************/ diff --git a/swad_changelog.h b/swad_changelog.h index 91ed7a19..ec62d048 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -606,15 +606,15 @@ 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.32.4 (2022-09-29)" +#define Log_PLATFORM_VERSION "SWAD 22.33 (2022-09-29)" #define CSS_FILE "swad22.22.1.css" #define JS_FILE "swad21.100.js" /* - Version 22.32.8: Sep 29, 2022 TODO: Changes in program resources and course forums. (? lines) - Version 22.32.7: Sep 29, 2022 TODO: Changes in program resources and attendance events. (? lines) - Version 22.32.6: Sep 29, 2022 TODO: Changes in program resources and mark files. (? lines) - Version 22.32.5: Sep 29, 2022 TODO: Changes in program resources and documents. (? lines) - Version 22.32.4: Sep 29, 2022 Changes in program resources and surveys. (? lines) + Version 22.33.3: Sep 29, 2022 TODO: Fix layout of marks file metadata. (? lines) + Version 22.33.2: Sep 29, 2022 TODO: Changes in program resources and course forums. (? lines) + Version 22.33.1: Sep 29, 2022 TODO: Changes in program resources and attendance events. (? lines) + Version 22.33: Sep 29, 2022 Changes in program resources, documents and mark files. (332683 lines) + Version 22.32.4: Sep 29, 2022 Changes in program resources and surveys. (332650 lines) Version 22.32.3: Sep 29, 2022 Changes in program resources and games. (332642 lines) Version 22.32.2: Sep 29, 2022 Changes in program resources and exams. (332637 lines) Version 22.32.1: Sep 29, 2022 Changes in program resources and calls for exams. (332635 lines) diff --git a/swad_program_resource.c b/swad_program_resource.c index ae479b79..1b401bf4 100644 --- a/swad_program_resource.c +++ b/swad_program_resource.c @@ -65,7 +65,7 @@ const char *Prg_ResourceTypesIcons[PrgRsc_NUM_TYPES] = [PrgRsc_EXAM ] = "file-signature.svg", [PrgRsc_GAME ] = "gamepad.svg", [PrgRsc_SURVEY ] = "poll.svg", - [PrgRsc_DOCUMENT ] = "up-right-from-square.svg", // for links because each file type has its own icon + [PrgRsc_DOCUMENT ] = "folder-open.svg", [PrgRsc_MARKS ] = "list-alt.svg", // grp GROUPS // ??? User select groups [PrgRsc_ATTENDANCE_EVENT] = "calendar-check.svg",