Commit 07127621e1afedbf9e2d5ee6dbcf135935dd0df6

Authored by Tohir Solomons
1 parent 31cb51ce

Fixes to cater for downloading multiple folders at a time

Committed by: Tohir Solomons
webservice/clienttools/services/0.9/kt.php
@@ -1222,29 +1222,44 @@ Fatal error: Cannot unset string offsets in on line 981 @@ -1222,29 +1222,44 @@ Fatal error: Cannot unset string offsets in on line 981
1222 function get_all_files($arr) 1222 function get_all_files($arr)
1223 { 1223 {
1224 $kt=&$this->KT; 1224 $kt=&$this->KT;
1225 -  
1226 - $folderId = str_replace('F_', '', $arr['folderid']);  
1227 1225
1228 - $folder=&$kt->get_folder_by_id($folderId);  
1229 - if (PEAR::isError($folder)){  
1230 - $this->setResponse('error 1');  
1231 - return false;  
1232 - } 1226 + $folders = array();
1233 1227
1234 - // Note 50 is set here as the level depth, inaccurate  
1235 - $listing = $folder->get_listing(50, 'DF'); //DF  
1236 -  
1237 - if ($folderId == '1') {  
1238 - $path = 'KnowledgeTree'; 1228 + if (is_array($arr['folderid'])) {
  1229 + foreach ($arr['folderid'] as $folder)
  1230 + {
  1231 + $folders[] = str_replace('F_', '', $folder);
  1232 + }
1239 } else { 1233 } else {
1240 - $path = $folder->get_folder_name(); 1234 + $folders[] = str_replace('F_', '', $arr['folderid']);
1241 } 1235 }
1242 1236
1243 1237
1244 $this->listOfFiles = array(); 1238 $this->listOfFiles = array();
1245 $this->listOfFoldersToBeCreated = array(); 1239 $this->listOfFoldersToBeCreated = array();
1246 1240
1247 - $this->addFolderToList($listing, $path); 1241 +
  1242 + foreach ($folders as $folderId)
  1243 + {
  1244 + $folder=&$kt->get_folder_by_id($folderId);
  1245 + if (PEAR::isError($folder)){
  1246 + $this->setResponse('error 1');
  1247 + return false;
  1248 + }
  1249 +
  1250 + // Note 50 is set here as the level depth, inaccurate
  1251 + $listing = $folder->get_listing(50, 'DF'); //DF
  1252 +
  1253 + if ($folderId == '1') {
  1254 + $path = 'KnowledgeTree';
  1255 + } else {
  1256 + $path = $folder->get_folder_name();
  1257 + }
  1258 +
  1259 + $this->addFolderToList($listing, $path);
  1260 +
  1261 + }
  1262 +
1248 1263
1249 // Sort Array by list of folders to be created in right order 1264 // Sort Array by list of folders to be created in right order
1250 sort($this->listOfFoldersToBeCreated); 1265 sort($this->listOfFoldersToBeCreated);