[#640] Docman : Extract documents and directories as an archive : empty folder at the root of the zip file

Description

Summary:

Detailed description

When I try to extract all the documents and directories of a project (this is a functionality in Docman administration), an empty folder is abnormally present at the root of the generated zip file.

Windows zip utility isn't capable to show this empty folder, so it's a true problem. (with 7-zip, we can see this empty folder)

The problem is located in the function docmanfillzip() of "src\common\docman\include\utils.php" file.

I join a file with a possible correction of the function. (perhaps It can be improved)

General Information
Submitted by:
Matthieu DURAND
Date Submitted: 2014-03-10 14:44
Last Modified by: Nobody
Last Modified: 2017-11-02 20:00
Date Closed: 2014-05-18 16:58
Permalink: https://fusionforge.org/tracker/a_follow.php/640
Actions
Internal Fields
Data Type: Bugs
Assigned to: Franck Villaume (nerville)
State: Closed
Priority: 3
Extra Fields
Resolution:
Fixed
Severity:
normal
Target Release:
5.3.1
Follow-up tabs
Message  ↓
Date: 2014-05-18 16:58
Sender: Franck Villaume

fix in Branch53: 8230bec538932d3f9fc1d6e8cb1ea0dfe197b684

Date: 2014-03-18 15:09
Sender: Matthieu DURAND

Hi,

I put the function directly in my comment (10/03/2014), because upload of files seems to do not work.

Date: 2014-03-17 13:47
Sender: Franck Villaume

Hi,

looks like your attachments are empty. Can you re-post it ?

Date: 2014-03-13 13:32
Sender: Matthieu DURAND

The problem has occurred with different browsers : at least IE8 and Firefox 27.0.1.

Date: 2014-03-12 15:38
Sender: Franck Villaume

what browser is used to download ?

Date: 2014-03-11 15:22
Sender: Franck Villaume

already fixed in 5.3

Date: 2014-03-10 14:50
Sender: Matthieu DURAND

The file seems to do not work. Here is the function :

/** * docmanfillzip - Recursive function to add docgroup and documents inside zip for backup * * @param object $zip * @param array $nested groups * @param object $documentfactory * @param int $documentgroup id : default value = 0 * @param string $parentdocname parent name : default value = empty * @return boolean success or not * @access public */ function docmanfillzip($zip, $nestedgroups, $documentfactory, $docgroup = 0, $parentdocname = '') { if (isarray(@$nestedgroups[$docgroup])) { foreach ($nestedgroups[$docgroup] as $dg) { if ($parentdocname != '') { if (! $zip->addEmptyDir ( iconv ( "UTF-8", "ASCII//TRANSLIT", $parent_docname ) . '/' . iconv ( "UTF-8", "ASCII//TRANSLIT", $dg->getName () ) )) return false; } else { if (! $zip->addEmptyDir ( iconv ( "UTF-8", "ASCII//TRANSLIT", $dg->getName () ) )) return false; }

        $document_factory->setDocGroupID($dg->getID());
        $docs = $document_factory->getDocuments(1);  // no caching
        if (is_array($docs) && count($docs) > 0) {   // this group has documents
            foreach ($docs as $doc) {
                if ($parent_docname != '') {
                    if (! $zip->addFromString ( iconv ( "UTF-8", "ASCII//TRANSLIT", $parent_docname ) . '/' . iconv ( "UTF-8", "ASCII//TRANSLIT", $dg->getName () ) . '/' . iconv ( "UTF-8", "ASCII//TRANSLIT", $doc->getFileName () ), $doc->getFileData () ))
                        return false;
                } else {
                    if (! $zip->addFromString ( iconv ( "UTF-8", "ASCII//TRANSLIT", $dg->getName () ) . '/' . iconv ( "UTF-8", "ASCII//TRANSLIT", $doc->getFileName () ), $doc->getFileData () ))
                        return false;
                }
            }
        }
        if ($parent_docname != '') {
            if (! docman_fill_zip ( $zip, $nested_groups, $document_factory, $dg->getID (), iconv ( "UTF-8", "ASCII//TRANSLIT", $parent_docname ) . '/' . iconv ( "UTF-8", "ASCII//TRANSLIT", $dg->getName () ) )) {
                return false;
            }
        } else {
            if (! docman_fill_zip ( $zip, $nested_groups, $document_factory, $dg->getID (), iconv ( "UTF-8", "ASCII//TRANSLIT", $dg->getName () ) )) {
                return false;
            }
        }
    }
}
return true;

}

Attachments:
Size Name Date By Download
2 KiBdocman_fill_zip.php2014-03-18 15:09
Matthieu DURAND
docman_fill_zip.php
2 KiBdocman_fill_zip.php2014-03-10 14:44
Matthieu DURAND
docman_fill_zip.php
2 KiBdocman_fill_zip.php2014-03-10 14:50
Matthieu DURAND
docman_fill_zip.php

No related commits.

Field Old Value Date By
status_idOpen2014-05-18 16:58
Franck Villaume
close_dateNone2014-05-18 16:58
Franck Villaume
assigned_tonone2014-05-18 16:58
Franck Villaume
Target ReleaseNone2014-05-18 16:58
Franck Villaume
ResolutionNone2014-05-18 16:58
Franck Villaume
File Deleted402: Makefile2014-03-24 16:00
Roland Mas
File Added402: Makefile2014-03-24 15:59
Roland Mas
File Added401: docman_fill_zip.php2014-03-18 15:09
Matthieu DURAND
Target Release5.32014-03-11 14:19
Franck Villaume
File Added400: docman_fill_zip.php2014-03-10 14:50
Matthieu DURAND
File Added399: docman_fill_zip.php2014-03-10 14:44
Matthieu DURAND

No relations found.