Home My Page Projects FusionForge
Summary Activity Forums Tracker Lists News SCM Files Mediawiki Hudson/Jenkins

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

Date:
2014-03-10 14:44
Priority:
3
State:
Closed
Submitted by:
Matthieu DURAND (mdurand)
Assigned to:
Franck Villaume (nerville)
Target Release:
5.3.1
Found in Version:
5.2.3
Severity:
normal
Resolution:
Fixed
Summary:
Docman : Extract documents and directories as an archive : empty folder at the root of the zip file

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 docman_fill_zip() of "src\common\docman\include\utils.php" file.

I join a file with a possible correction of the function. (perhaps It can be improved)
Message  ↓
Date: 2014-05-18 16:58
Sender: Franck Villaume

fix in Branch_5_3: 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 :

/**
* docman_fill_zip - 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 $parent_docname parent name : default value = empty
* @return boolean success or not
* @access public
*/
function docman_fill_zip($zip, $nested_groups, $document_factory, $docgroup = 0, $parent_docname = '') {
if (is_array(@$nested_groups[$docgroup])) {
foreach ($nested_groups[$docgroup] as $dg) {
if ($parent_docname != '') {
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:09mduranddocman_fill_zip.php
2 KiBdocman_fill_zip.php2014-03-10 14:44mduranddocman_fill_zip.php
2 KiBdocman_fill_zip.php2014-03-10 14:50mduranddocman_fill_zip.php
Field Old Value Date By
status_idOpen2014-05-18 16:58nerville
close_dateNone2014-05-18 16:58nerville
assigned_tonone2014-05-18 16:58nerville
Target ReleaseNone2014-05-18 16:58nerville
ResolutionNone2014-05-18 16:58nerville
File Deleted402: Makefile2014-03-24 16:00lolando
File Added402: Makefile2014-03-24 15:59lolando
File Added401: docman_fill_zip.php2014-03-18 15:09mdurand
Target Release5.32014-03-11 14:19nerville
File Added400: docman_fill_zip.php2014-03-10 14:50mdurand
File Added399: docman_fill_zip.php2014-03-10 14:44mdurand