diff --git a/lib/foldermanagement/compressionArchiveUtil.inc.php b/lib/foldermanagement/compressionArchiveUtil.inc.php
index e90c7f2..353df40 100644
--- a/lib/foldermanagement/compressionArchiveUtil.inc.php
+++ b/lib/foldermanagement/compressionArchiveUtil.inc.php
@@ -5,32 +5,32 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- *
+ *
* You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com.
- *
+ *
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
- *
+ *
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
- * KnowledgeTree" logo and retain the original copyright notice. If the display of the
+ * KnowledgeTree" logo and retain the original copyright notice. If the display of the
* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
- * must display the words "Powered by KnowledgeTree" and retain the original
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*
*/
@@ -79,10 +79,17 @@ class ZipFolder {
/**
* Add a document to the zip file
*/
- function addDocumentToZip($oDocument) {
- $sParentFolder = str_replace('<', '', str_replace('', '', str_replace('>', '', sprintf('%s/%s', $this->sTmpPath, $oDocument->getFullPath()))));
+ function addDocumentToZip($oDocument, $oFolder = null) {
+ if(empty($oFolder)){
+ $oFolder = Folder::get($oDocument->getFolderID());
+ }
+
+ $sDocPath = $oFolder->getFullPath().'/'.$oFolder->getName();
+ $sDocName = $oDocument->getFileName();
+
+ $sParentFolder = str_replace('<', '', str_replace('', '', str_replace('>', '', sprintf('%s/%s', $this->sTmpPath, $sDocPath))));
$newDir = $this->sTmpPath;
- $sFullPath = str_replace('<', '', str_replace('', '', str_replace('>', '', $this->_convertEncoding($oDocument->getFullPath(), true))));
+ $sFullPath = str_replace('<', '', str_replace('', '', str_replace('>', '', $this->_convertEncoding($sDocPath, true))));
foreach (split('/', $sFullPath) as $dirPart) {
$newDir = sprintf("%s/%s", $newDir, $dirPart);
if (!file_exists($newDir)) {
@@ -91,11 +98,11 @@ class ZipFolder {
}
$sOrigFile = str_replace('<', '', str_replace('', '', str_replace('>', '', $this->oStorage->temporaryFile($oDocument))));
- $sFilename = sprintf("%s/%s", $sParentFolder, str_replace('<', '', str_replace('', '', str_replace('>', '', $oDocument->getFileName()))));
+ $sFilename = sprintf("%s/%s", $sParentFolder, str_replace('<', '', str_replace('', '', str_replace('>', '', $sDocName))));
$sFilename = $this->_convertEncoding($sFilename, true);
copy($sOrigFile, $sFilename);
- $sPath = str_replace('<', '', str_replace('', '', str_replace('>', '', sprintf("%s/%s", $oDocument->getFullPath(), $oDocument->getFileName()))));
+ $sPath = str_replace('<', '', str_replace('', '', str_replace('>', '', sprintf("%s/%s", $sDocPath, $sDocName))));
$sPath = str_replace($this->aReplaceKeys, $this->aReplaceValues, $sPath);
$sPath = $this->_convertEncoding($sPath, true);
diff --git a/plugins/ktcore/KTBulkActions.php b/plugins/ktcore/KTBulkActions.php
index e2d53fa..d8d84f3 100644
--- a/plugins/ktcore/KTBulkActions.php
+++ b/plugins/ktcore/KTBulkActions.php
@@ -661,6 +661,9 @@ class KTBrowseBulkExportAction extends KTBulkAction {
parent_folder_ids LIKE '%,{$sFolderId}'";
$aFolderList = $this->oFolder->getList($sWhereClause);
+ $aFolderObjects = array();
+ $aFolderObjects[$sFolderId] = $oFolder;
+
// Export the folder structure to ensure the export of empty directories
if(!empty($aFolderList)){
foreach($aFolderList as $k => $oFolderItem){
@@ -673,6 +676,7 @@ class KTBrowseBulkExportAction extends KTBulkAction {
$aDocuments = array_merge($aDocuments, $aFolderDocs);
}
$this->oZip->addFolderToZip($oFolderItem);
+ $aFolderObjects[$oFolderItem->getId()] = $oFolderItem;
}
}
@@ -680,6 +684,8 @@ class KTBrowseBulkExportAction extends KTBulkAction {
if(!empty($aDocuments)){
foreach($aDocuments as $sDocumentId){
$oDocument = Document::get($sDocumentId);
+ $sDocFolderId = $oDocument->getFolderID();
+ $oFolder = isset($aFolderObjects[$sDocFolderId]) ? $aFolderObjects[$sDocFolderId] : Folder::get($sDocFolderId);
if ($this->bNoisy) {
$oDocumentTransaction = new DocumentTransaction($oDocument, "Document part of bulk export", 'ktstandard.transactions.bulk_export', array());
@@ -689,11 +695,10 @@ class KTBrowseBulkExportAction extends KTBulkAction {
// fire subscription alerts for the downloaded document
if($this->bNotifications){
$oSubscriptionEvent = new SubscriptionEvent();
- $oFolder = Folder::get($oDocument->getFolderID());
$oSubscriptionEvent->DownloadDocument($oDocument, $oFolder);
}
- $this->oZip->addDocumentToZip($oDocument);
+ $this->oZip->addDocumentToZip($oDocument, $oFolder);
}
}
}
@@ -906,6 +911,9 @@ class KTBrowseBulkCheckoutAction extends KTBulkAction {
parent_folder_ids LIKE '%,{$sFolderId}'";
$aFolderList = $this->oFolder->getList($sWhereClause);
+ $aFolderObjects = array();
+ $aFolderObjects[$sFolderId] = $oFolder;
+
// Get the documents within the folder
if(!empty($aFolderList)){
foreach($aFolderList as $k => $oFolderItem){
@@ -921,6 +929,7 @@ class KTBrowseBulkCheckoutAction extends KTBulkAction {
// Add the folder to the zip file
if($this->bDownload){
$this->oZip->addFolderToZip($oFolderItem);
+ $aFolderObjects[$oFolderItem->getId()] = $oFolderItem;
}
}
}
@@ -961,7 +970,9 @@ class KTBrowseBulkCheckoutAction extends KTBulkAction {
$oDocumentTransaction = new DocumentTransaction($oDocument, "Document part of bulk checkout", 'ktstandard.transactions.check_out', array());
$oDocumentTransaction->create();
}
- $this->oZip->addDocumentToZip($oDocument);
+ $sDocFolderId = $oDocument->getFolderID();
+ $oFolder = isset($aFolderObjects[$sDocFolderId]) ? $aFolderObjects[$sDocFolderId] : Folder::get($sDocFolderId);
+ $this->oZip->addDocumentToZip($oDocument, $oFolder);
}
}
}
diff --git a/plugins/ktstandard/KTBulkExportPlugin.php b/plugins/ktstandard/KTBulkExportPlugin.php
index ad78a59..8207a01 100644
--- a/plugins/ktstandard/KTBulkExportPlugin.php
+++ b/plugins/ktstandard/KTBulkExportPlugin.php
@@ -5,32 +5,32 @@
* KnowledgeTree Open Source Edition
* Document Management Made Simple
* Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- *
+ *
* You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
* Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com.
- *
+ *
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
- *
+ *
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
- * KnowledgeTree" logo and retain the original copyright notice. If the display of the
+ * KnowledgeTree" logo and retain the original copyright notice. If the display of the
* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
- * must display the words "Powered by KnowledgeTree" and retain the original
- * copyright notice.
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
* Contributor( s): ______________________________________
*
*/
@@ -109,9 +109,24 @@ class KTBulkExportAction extends KTFolderAction {
$this->oPage->template = "kt3/minimal_page";
$this->handleOutput("");
+ // Create associative array of folder items for use by the contained documents
+ $aFolderObjects = array();
+ $aFolderObjects[$sCurrentFolderId] = $this->oFolder;
+
+ // Export the folder structure to ensure the export of empty directories
+ if(!empty($aFolderList)){
+ foreach($aFolderList as $k => $oFolderItem){
+ $this->oZip->addFolderToZip($oFolderItem);
+ $aFolderObjects[$oFolderItem->getId()] = $oFolderItem;
+ }
+ }
+
if(!empty($aDocumentIds)){
foreach ($aDocumentIds as $iId) {
$oDocument = Document::get($iId);
+ $sFolderId = $oDocument->getFolderID();
+
+ $oFolder = isset($aFolderObjects[$sFolderId]) ? $aFolderObjects[$sFolderId] : Folder::get($sFolderId);
if ($bNoisy) {
$oDocumentTransaction = & new DocumentTransaction($oDocument, "Document part of bulk export", 'ktstandard.transactions.bulk_export', array());
@@ -121,19 +136,13 @@ class KTBulkExportAction extends KTFolderAction {
// fire subscription alerts for the downloaded document
if($bNotifications){
$oSubscriptionEvent = new SubscriptionEvent();
- $oFolder = Folder::get($oDocument->getFolderID());
$oSubscriptionEvent->DownloadDocument($oDocument, $oFolder);
}
- $this->oZip->addDocumentToZip($oDocument);
+ $this->oZip->addDocumentToZip($oDocument, $oFolder);
}
}
- // Export the folder structure to ensure the export of empty directories
- foreach($aFolderList as $k => $oFolderItem){
- $this->oZip->addFolderToZip($oFolderItem);
- }
-
$sExportCode = $this->oZip->createZipFile(TRUE);
$oTransaction = KTFolderTransaction::createFromArray(array(
@@ -168,7 +177,7 @@ class KTBulkExportAction extends KTFolderAction {
return $res;
}
list($sPermissionString, $aPermissionParams, $sPermissionJoin) = $res;
- $aPotentialWhere = array($sPermissionString, 'D.parent_folder_ids = ? OR D.parent_folder_ids LIKE ?', 'D.status_id = 1');
+ $aPotentialWhere = array($sPermissionString, 'D.folder_id = ? OR D.parent_folder_ids = ? OR D.parent_folder_ids LIKE ?', 'D.status_id = 1');
$aWhere = array();
foreach ($aPotentialWhere as $sWhere) {
if (empty($sWhere)) {
@@ -202,6 +211,7 @@ class KTBulkExportAction extends KTFolderAction {
array_shift($aParentFolderIds);
}
$sParentFolderIds = join(',', $aParentFolderIds);
+ $aParams[] = $this->oFolder->getId();
$aParams[] = $sParentFolderIds;
$aParams[] = $sParentFolderIds . ",%";
return array($sQuery, $aParams);