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