Commit b1db55d984687314fe23330b7e6716ca3839299e

Authored by Megan Watson
1 parent 4138d97d

KTC-271

"Bulk upload does not work"
Fixed. Added 'temp_file' to the options array. 

KTC-273
"All files uploaded with the function 'Import from Server Location' has a size of 0kb after upload"
Fixed.

Committed by: Megan Watson
Reviewed by: Conrad Vermeulen



git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7751 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 17 additions and 15 deletions
lib/import/bulkimport.inc.php
@@ -7,32 +7,32 @@ @@ -7,32 +7,32 @@
7 * KnowledgeTree Open Source Edition 7 * KnowledgeTree Open Source Edition
8 * Document Management Made Simple 8 * Document Management Made Simple
9 * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited 9 * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
10 - * 10 + *
11 * This program is free software; you can redistribute it and/or modify it under 11 * This program is free software; you can redistribute it and/or modify it under
12 * the terms of the GNU General Public License version 3 as published by the 12 * the terms of the GNU General Public License version 3 as published by the
13 * Free Software Foundation. 13 * Free Software Foundation.
14 - * 14 + *
15 * This program is distributed in the hope that it will be useful, but WITHOUT 15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18 * details. 18 * details.
19 - * 19 + *
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>. 21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 - * 22 + *
23 * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, 23 * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
24 * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. 24 * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com.
25 - * 25 + *
26 * The interactive user interfaces in modified source and object code versions 26 * The interactive user interfaces in modified source and object code versions
27 * of this program must display Appropriate Legal Notices, as required under 27 * of this program must display Appropriate Legal Notices, as required under
28 * Section 5 of the GNU General Public License version 3. 28 * Section 5 of the GNU General Public License version 3.
29 - * 29 + *
30 * In accordance with Section 7(b) of the GNU General Public License version 3, 30 * In accordance with Section 7(b) of the GNU General Public License version 3,
31 * these Appropriate Legal Notices must retain the display of the "Powered by 31 * these Appropriate Legal Notices must retain the display of the "Powered by
32 - * KnowledgeTree" logo and retain the original copyright notice. If the display of the 32 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
33 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices 33 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
34 - * must display the words "Powered by KnowledgeTree" and retain the original  
35 - * copyright notice. 34 + * must display the words "Powered by KnowledgeTree" and retain the original
  35 + * copyright notice.
36 * Contributor( s): ______________________________________ 36 * Contributor( s): ______________________________________
37 */ 37 */
38 38
@@ -72,7 +72,7 @@ class KTBulkImportManager { @@ -72,7 +72,7 @@ class KTBulkImportManager {
72 72
73 function _importfolder($oFolder, $sPath) { 73 function _importfolder($oFolder, $sPath) {
74 $oPermission = KTPermission::getByName('ktcore.permissions.addFolder'); 74 $oPermission = KTPermission::getByName('ktcore.permissions.addFolder');
75 - 75 +
76 $aDocPaths = $this->oStorage->listDocuments($sPath); 76 $aDocPaths = $this->oStorage->listDocuments($sPath);
77 if (PEAR::isError($aDocPaths)) { 77 if (PEAR::isError($aDocPaths)) {
78 return $aDocPaths; 78 return $aDocPaths;
@@ -91,7 +91,7 @@ class KTBulkImportManager { @@ -91,7 +91,7 @@ class KTBulkImportManager {
91 if (Folder::folderExistsName(utf8_encode(basename($sFolderPath)), KTUtil::getId($oFolder))) { 91 if (Folder::folderExistsName(utf8_encode(basename($sFolderPath)), KTUtil::getId($oFolder))) {
92 $_SESSION['KTErrorMessage'][] = sprintf(_kt("The folder %s is already present in %s. Adding files into pre-existing folder."), utf8_encode(basename($sFolderPath)), $oFolder->getName()); 92 $_SESSION['KTErrorMessage'][] = sprintf(_kt("The folder %s is already present in %s. Adding files into pre-existing folder."), utf8_encode(basename($sFolderPath)), $oFolder->getName());
93 $aOptions = Folder::getList("parent_id = " . KTUtil::getId($oFolder) . ' AND name = "' . DBUtil::escapeSimple(utf8_encode(basename($sFolderPath))) . '"'); 93 $aOptions = Folder::getList("parent_id = " . KTUtil::getId($oFolder) . ' AND name = "' . DBUtil::escapeSimple(utf8_encode(basename($sFolderPath))) . '"');
94 - if (PEAR::isError($aOptions)) { 94 + if (PEAR::isError($aOptions)) {
95 return $aOptions; 95 return $aOptions;
96 } 96 }
97 if (count($aOptions) != 1) { 97 if (count($aOptions) != 1) {
@@ -100,7 +100,7 @@ class KTBulkImportManager { @@ -100,7 +100,7 @@ class KTBulkImportManager {
100 $oThisFolder = $aOptions[0]; 100 $oThisFolder = $aOptions[0];
101 } 101 }
102 } else { 102 } else {
103 - 103 +
104 if(KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $oFolder)) 104 if(KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $oFolder))
105 { 105 {
106 $oThisFolder = KTFolderUtil::add($oFolder, utf8_encode(basename($sFolderPath)), $this->oUser); 106 $oThisFolder = KTFolderUtil::add($oFolder, utf8_encode(basename($sFolderPath)), $this->oUser);
@@ -119,7 +119,7 @@ class KTBulkImportManager { @@ -119,7 +119,7 @@ class KTBulkImportManager {
119 } 119 }
120 120
121 $res = $this->_importfolder($oThisFolder, $sFolderPath); 121 $res = $this->_importfolder($oThisFolder, $sFolderPath);
122 - 122 +
123 if (PEAR::isError($res)) { 123 if (PEAR::isError($res)) {
124 return $res; 124 return $res;
125 } 125 }
@@ -128,6 +128,7 @@ class KTBulkImportManager { @@ -128,6 +128,7 @@ class KTBulkImportManager {
128 128
129 function _importdocument($oFolder, $sPath) { 129 function _importdocument($oFolder, $sPath) {
130 $aInfo = $this->oStorage->getDocumentInfo($sPath); 130 $aInfo = $this->oStorage->getDocumentInfo($sPath);
  131 + $sTmpFileName = sprintf("%s/%s", $this->oStorage->sBasePath, $sPath);
131 if (PEAR::isError($aInfo)) { 132 if (PEAR::isError($aInfo)) {
132 return $aInfo; 133 return $aInfo;
133 } 134 }
@@ -135,7 +136,7 @@ class KTBulkImportManager { @@ -135,7 +136,7 @@ class KTBulkImportManager {
135 /*if (KTDocumentUtil::nameExists($oFolder, utf8_encode(basename($sPath)))) { 136 /*if (KTDocumentUtil::nameExists($oFolder, utf8_encode(basename($sPath)))) {
136 $_SESSION['KTErrorMessage'][] = sprintf(_kt("The document %s is already present in %s. Ignoring."), utf8_encode(basename($sPath)), $oFolder->getName()); 137 $_SESSION['KTErrorMessage'][] = sprintf(_kt("The document %s is already present in %s. Ignoring."), utf8_encode(basename($sPath)), $oFolder->getName());
137 $oDocument =& Document::getByNameAndFolder(utf8_encode(basename($sPath)), KTUtil::getId($oFolder)); 138 $oDocument =& Document::getByNameAndFolder(utf8_encode(basename($sPath)), KTUtil::getId($oFolder));
138 - return $oDocument; 139 + return $oDocument;
139 } else if (KTDocumentUtil::fileExists($oFolder, utf8_encode(basename($sPath)))) { 140 } else if (KTDocumentUtil::fileExists($oFolder, utf8_encode(basename($sPath)))) {
140 $_SESSION['KTErrorMessage'][] = sprintf(_kt("The document %s is already present in %s. Ignoring."), utf8_encode(basename($sPath)), $oFolder->getName()); 141 $_SESSION['KTErrorMessage'][] = sprintf(_kt("The document %s is already present in %s. Ignoring."), utf8_encode(basename($sPath)), $oFolder->getName());
141 $oDocument =& Document::getByFilenameAndFolder(utf8_encode(basename($sPath)), KTUtil::getId($oFolder)); 142 $oDocument =& Document::getByFilenameAndFolder(utf8_encode(basename($sPath)), KTUtil::getId($oFolder));
@@ -144,7 +145,8 @@ class KTBulkImportManager { @@ -144,7 +145,8 @@ class KTBulkImportManager {
144 // else 145 // else
145 $aOptions = array( 146 $aOptions = array(
146 // XXX: Multiversion Import 147 // XXX: Multiversion Import
147 - 'contents' => $aInfo->aVersions[0], 148 + //'contents' => $aInfo->aVersions[0],
  149 + 'temp_file' => $sTmpFileName,
148 'metadata' => $this->aMetadata, 150 'metadata' => $this->aMetadata,
149 'documenttype' => $this->oDocumentType, 151 'documenttype' => $this->oDocumentType,
150 ); 152 );