Commit 232c44ab9208ebae41b6f0b42b94eae49cb6c6cc

Authored by Tohir Solomons
1 parent d260e321

KTE-100 On the R-click menu the 'Download' is not working for folders

Fixed. Functionality has been implemented

Committed by: Tohir Solomons
webservice/clienttools/services/0.9/kt.php
@@ -1216,5 +1216,68 @@ Fatal error: Cannot unset string offsets in on line 981 @@ -1216,5 +1216,68 @@ Fatal error: Cannot unset string offsets in on line 981
1216 return true; 1216 return true;
1217 } 1217 }
1218 } 1218 }
  1219 +
  1220 + function get_all_files($arr)
  1221 + {
  1222 + $kt=&$this->KT;
  1223 +
  1224 + $folderId = str_replace('F_', '', $arr['folderid']);
  1225 +
  1226 + $folder=&$kt->get_folder_by_id($folderId);
  1227 + if (PEAR::isError($folder)){
  1228 + $this->setResponse('error 1');
  1229 + return false;
  1230 + }
  1231 +
  1232 + // Note 50 is set here as the level depth, inaccurate
  1233 + $listing = $folder->get_listing(50, 'DF'); //DF
  1234 +
  1235 + if ($folderId == '1') {
  1236 + $path = 'KnowledgeTree';
  1237 + } else {
  1238 + $path = $folder->get_folder_name();
  1239 + }
  1240 +
  1241 +
  1242 + $this->listOfFiles = array();
  1243 + $this->listOfFoldersToBeCreated = array();
  1244 +
  1245 + $this->addFolderToList($listing, $path);
  1246 +
  1247 + // Sort Array by list of folders to be created in right order
  1248 + sort($this->listOfFoldersToBeCreated);
  1249 +
  1250 + $this->setResponse(array('items'=>$this->listOfFiles, 'folders'=>$this->listOfFoldersToBeCreated));
  1251 + return true;
  1252 + }
  1253 +
  1254 +
  1255 + function addFolderToList(&$listing, $path)
  1256 + {
  1257 + if (!in_array($path, $this->listOfFoldersToBeCreated)) {
  1258 + $this->listOfFoldersToBeCreated[] = $path;
  1259 + }
  1260 +
  1261 + foreach ($listing as $item)
  1262 + {
  1263 + if ($item['item_type'] == 'D') {
  1264 + $this->listOfFiles[] = array(
  1265 + 'folderName' => $path,
  1266 + 'documentId' => $item['id'],
  1267 + 'filename' => $item['filename'],
  1268 + 'fullpath' => $path.'/'.$item['filename']
  1269 + );
  1270 +
  1271 + } else if ($item['item_type'] == 'F') {
  1272 +
  1273 +
  1274 +
  1275 + $this->addFolderToList($item['items'], $path.'/'.$item['filename']);
  1276 +
  1277 +
  1278 + }
  1279 +
  1280 + }
  1281 + }
1219 } 1282 }
1220 ?> 1283 ?>
1221 \ No newline at end of file 1284 \ No newline at end of file