From 9c490f279ce355b811d42136abdddafd7679df8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Tue, 22 Nov 2016 13:15:12 +0100 Subject: [PATCH] Version 16.68.4 --- swad_changelog.h | 3 ++- swad_file_browser.c | 60 +++++++++++++++------------------------------ swad_zip.c | 39 +++++++++++++++++++++++++++-- swad_zip.h | 2 -- 4 files changed, 59 insertions(+), 45 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index ea7be8ed..f6c69c23 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -172,13 +172,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.68.3 (2016-11-22)" +#define Log_PLATFORM_VERSION "SWAD 16.68.4 (2016-11-22)" #define CSS_FILE "swad16.68.css" #define JS_FILE "swad16.46.1.js" // Number of lines (includes comments but not blank lines) has been got with the following command: // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1 /* + Version 16.68.4: Nov 22, 2016 Code refactoring in file browser. (207447 lines) Version 16.68.3: Nov 22, 2016 Change in layout of contextual links in file browsers. (207436 lines) Version 16.68.2: Nov 22, 2016 Code refactoring related to file browser and contextual checkbox. (207438 lines) Version 16.68.1: Nov 22, 2016 Code refactoring related to notifications and contextual checkbox. (207438 lines) diff --git a/swad_file_browser.c b/swad_file_browser.c index fb62cb53..d2631170 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -1450,6 +1450,7 @@ static bool Brw_CheckIfQuotaExceded (void); static void Brw_ShowFileBrowserNormal (void); static void Brw_ShowFileBrowsersAsgWrkCrs (void); +static void Brw_PutLinkZIPAsgWrk (void); static void Brw_ShowFileBrowsersAsgWrkUsr (void); static void Brw_FormToChangeCrsGrpZone (void); @@ -3126,50 +3127,12 @@ static void Brw_ShowFileBrowsersAsgWrkCrs (void) extern const char *Txt_Assignments_and_other_works; extern const char *Txt_You_must_select_one_ore_more_users; const char *Ptr; - struct UsrData UsrDat; /***** Check the number of users whose works will be shown *****/ if (Usr_CountNumUsrsInListOfSelectedUsrs ()) // If some users are selected... { - if (Gbl.FileBrowser.ZIP.CreateZIP) - { - /***** Create zip file - with the assignments and works - of the selected users *****/ - /* Create temporary directory - for the compression of assignments and works */ - ZIP_CreateTmpDirForCompression (); - - /* Initialize structure with user's data */ - Usr_UsrDataConstructor (&UsrDat); - - /* Create temporary directory for each selected user - inside the directory used for compression */ - Ptr = Gbl.Usrs.Select.All; - while (*Ptr) - { - Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod, - Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64); - Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat); - - - if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get user's data from database - if (Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod, - Gbl.CurrentCrs.Crs.CrsCod, - false)) - ZIP_CreateDirCompressionUsr (&UsrDat); - } - - /* Free memory used for user's data */ - Usr_UsrDataDestructor (&UsrDat); - - /* Create the zip file and put a link to download it */ - ZIP_CreateZIPAsgWrk (); - } - else - /***** Button to create a zip file - with all the works of the selected users *****/ - ZIP_PutButtonToCreateZIPAsgWrk (); + /***** Put link to download / create zip file *****/ + Brw_PutLinkZIPAsgWrk (); /***** Write top before showing file browser *****/ Brw_WriteTopBeforeShowingFileBrowser (); @@ -3226,6 +3189,23 @@ static void Brw_ShowFileBrowsersAsgWrkCrs (void) Usr_FreeListsSelectedUsrsCods (); } +/*****************************************************************************/ +/******** Put link to download / create zip file in assigments / works *******/ +/*****************************************************************************/ + +static void Brw_PutLinkZIPAsgWrk (void) + { + if (Gbl.FileBrowser.ZIP.CreateZIP) + { + /* Create the zip file and put a link to download it */ + ZIP_CreateZIPAsgWrk (); + } + else + /***** Button to create a zip file + with all the works of the selected users *****/ + ZIP_PutButtonToCreateZIPAsgWrk (); + } + /*****************************************************************************/ /************ Show file browsers with works files of one user ****************/ /*****************************************************************************/ diff --git a/swad_zip.c b/swad_zip.c index bd0b33e0..88f1a213 100644 --- a/swad_zip.c +++ b/swad_zip.c @@ -104,6 +104,9 @@ extern struct Globals Gbl; static void ZIP_PutButtonToCreateZIPAsgWrkParams (void); +static void ZIP_CreateTmpDirForCompression (void); +static void ZIP_CreateDirCompressionUsr (struct UsrData *UsrDat); + static void ZIP_CompressFolderIntoZIP (void); static unsigned long long ZIP_CloneDir (const char *Path,const char *PathClone,const char *PathInTree); static void ZIP_ShowLinkToDownloadZIP (const char *FileName,const char *URL, @@ -153,6 +156,8 @@ bool ZIP_GetCreateZIPFromForm (void) void ZIP_CreateZIPAsgWrk (void) { extern const char *Txt_works_ZIP_FILE_NAME; + struct UsrData UsrDat; + const char *Ptr; char StrZip[100+PATH_MAX*2+1]; char Path[PATH_MAX+1]; int Result; @@ -162,6 +167,36 @@ void ZIP_CreateZIPAsgWrk (void) char URLWithSpaces[PATH_MAX+1]; char URL[PATH_MAX+1]; + /***** Create zip file + with the assignments and works + of the selected users *****/ + /* Create temporary directory + for the compression of assignments and works */ + ZIP_CreateTmpDirForCompression (); + + /* Initialize structure with user's data */ + Usr_UsrDataConstructor (&UsrDat); + + /* Create temporary directory for each selected user + inside the directory used for compression */ + Ptr = Gbl.Usrs.Select.All; + while (*Ptr) + { + Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod, + Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64); + Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat); + + + if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get user's data from database + if (Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod, + Gbl.CurrentCrs.Crs.CrsCod, + false)) + ZIP_CreateDirCompressionUsr (&UsrDat); + } + + /* Free memory used for user's data */ + Usr_UsrDataDestructor (&UsrDat); + /***** Create a temporary public directory used to download the zip file *****/ Brw_CreateDirDownloadTmp (); @@ -220,7 +255,7 @@ void ZIP_CreateZIPAsgWrk (void) /********* Create temporary directory to put the works to compress ***********/ /*****************************************************************************/ -void ZIP_CreateTmpDirForCompression (void) +static void ZIP_CreateTmpDirForCompression (void) { char PathZipPriv[PATH_MAX+1]; char PathDirTmp[PATH_MAX+1]; @@ -247,7 +282,7 @@ void ZIP_CreateTmpDirForCompression (void) /**************** in the temporary directory of compression ******************/ /*****************************************************************************/ -void ZIP_CreateDirCompressionUsr (struct UsrData *UsrDat) +static void ZIP_CreateDirCompressionUsr (struct UsrData *UsrDat) { char FullNameAndUsrID[(Usr_MAX_BYTES_NAME+1)*3+ ID_MAX_LENGTH_USR_ID+1+ diff --git a/swad_zip.h b/swad_zip.h index a7eff393..b3450478 100644 --- a/swad_zip.h +++ b/swad_zip.h @@ -46,8 +46,6 @@ void ZIP_PutButtonToCreateZIPAsgWrk (void); bool ZIP_GetCreateZIPFromForm (void); void ZIP_CreateZIPAsgWrk (void); -void ZIP_CreateTmpDirForCompression (void); -void ZIP_CreateDirCompressionUsr (struct UsrData *UsrDat); void ZIP_PutButtonToDownloadZIPOfAFolder (const char *PathInTree,const char *FileName); void ZIP_CompressFileTree (void);