Commit 8a07991bd59d92eced1de56f3cf1b7b40261ee87

Authored by sergem
Committed by Megan Watson
1 parent c527aeaa

Merged across changes made in the 0.9.2 webservices into 0.9.1 for the Explorer CP release

Committed by: Serge Meunier
webservice/clienttools/services/0.9.1/kt.php
@@ -161,7 +161,7 @@ class kt extends client_service { @@ -161,7 +161,7 @@ class kt extends client_service {
161 161
162 $folder->addFolderToUserHistory(); 162 $folder->addFolderToUserHistory();
163 163
164 - $types = (isset ( $arr ['types'] ) ? $arr ['types'] : 'DF'); 164 + $types = (isset ( $arr ['types'] ) ? $arr ['types'] : 'DFS');
165 165
166 $listing = $folder->get_listing ( 1, $types ); 166 $listing = $folder->get_listing ( 1, $types );
167 167
@@ -220,9 +220,29 @@ class kt extends client_service { @@ -220,9 +220,29 @@ class kt extends client_service {
220 $perms = substr ( $perms, 0, strlen ( $perms ) - 2 ); 220 $perms = substr ( $perms, 0, strlen ( $perms ) - 2 );
221 } 221 }
222 222
223 - if ($itemType == 'F') { 223 + // This is done here because a shortcut can be a document or folder
  224 + switch ($itemType)
  225 + {
  226 + case 'F': $docOrFolder = 'F'; break;
  227 + case 'D': $docOrFolder = 'D'; break;
  228 + case 'S':
  229 + if (array_key_exists('linked_folder_id', $item)) {
  230 + $docOrFolder = 'F';
  231 + } else {
  232 + $docOrFolder = 'D';
  233 + }
  234 + break;
  235 + }
  236 +
  237 + if ($docOrFolder == 'F') {
224 $qtip .= $this->xlate ( 'Folder name' ) . ": {$filename}<br>"; 238 $qtip .= $this->xlate ( 'Folder name' ) . ": {$filename}<br>";
225 - $class = 'folder'; 239 +
  240 + if ($itemType == 'S') {
  241 + $class = 'folder_shortcut';
  242 + } else {
  243 + $class = 'folder';
  244 + }
  245 +
226 $qtip .= $this->xlate ( 'Permissions:' ) . " {$perms}<br>"; 246 $qtip .= $this->xlate ( 'Permissions:' ) . " {$perms}<br>";
227 $qtip .= $canWrite ? $this->xlate ( 'You may add content to this folder' ) : $this->xlate ( 'You may not add content to this folder' ); 247 $qtip .= $canWrite ? $this->xlate ( 'You may add content to this folder' ) : $this->xlate ( 'You may not add content to this folder' );
228 } 248 }
@@ -239,6 +259,11 @@ class kt extends client_service { @@ -239,6 +259,11 @@ class kt extends client_service {
239 $class = 'file-' . substr ( $filename, $extpos + 1 ); // Get Extension without the dot 259 $class = 'file-' . substr ( $filename, $extpos + 1 ); // Get Extension without the dot
240 } 260 }
241 261
  262 + if ($itemType == 'S') {
  263 + $class .= '_shortcut';
  264 + }
  265 +
  266 +
242 $extensions = explode ( ',', $arr ['extensions'] ); 267 $extensions = explode ( ',', $arr ['extensions'] );
243 if (! in_array ( strtolower ( $ext ), $extensions ) && ! in_array ( '*', $extensions )) { 268 if (! in_array ( strtolower ( $ext ), $extensions ) && ! in_array ( '*', $extensions )) {
244 $includeMe = false; 269 $includeMe = false;
@@ -300,7 +325,14 @@ class kt extends client_service { @@ -300,7 +325,14 @@ class kt extends client_service {
300 $item ['filesize'] = - 1; 325 $item ['filesize'] = - 1;
301 } 326 }
302 327
303 - return array ('text' => htmlspecialchars ( $item ['title'] ), 'originaltext' => $item ['title'], 'id' => $item ['id'], 'filename' => $item ['filename'], 'cls' => $class, 'owner' => $item ['created_by'], 'document_type' => $item ['document_type'], 'item_type' => $item ['item_type'], 'permissions' => $item ['permissions'], 'created_date' => $item ['created_date'], 'content_id' => $item ['content_id'], 'filesize' => $item ['filesize'], 'filesize_bytes' => $item ['filesize_bytes'], 'modified' => $item ['modified_date'], 'checked_out_by' => $item ['checked_out_by'], 'version' => $item ['version'], 'is_immutable' => $item ['is_immutable'] ); 328 + if (array_key_exists('linked_folder_id', $item)) {
  329 + $linkedId = 'F_'.$item['linked_folder_id'];
  330 + } else {
  331 + $linkedId = 'D_'.$item['linked_document_id'];
  332 + }
  333 +
  334 +
  335 + return array ('text' => htmlspecialchars ( $item ['title'] ), 'originaltext' => $item ['title'], 'id' => $item ['id'], 'filename' => $item ['filename'], 'cls' => $class, 'owner' => $item ['created_by'], 'document_type' => $item ['document_type'], 'item_type' => $item ['item_type'], 'permissions' => $item ['permissions'], 'created_date' => $item ['created_date'], 'content_id' => $item ['content_id'], 'filesize' => $item ['filesize'], 'filesize_bytes' => $item ['filesize_bytes'], 'modified' => $item ['modified_date'], 'checked_out_by' => $item ['checked_out_by'], 'version' => $item ['version'], 'is_immutable' => $item ['is_immutable'], 'linked_item'=>$linkedId );
304 } 336 }
305 337
306 public function get_metadata($params) { 338 public function get_metadata($params) {
@@ -1284,7 +1316,7 @@ Fatal error: Cannot unset string offsets in on line 981 @@ -1284,7 +1316,7 @@ Fatal error: Cannot unset string offsets in on line 981
1284 } 1316 }
1285 1317
1286 // Note 50 is set here as the level depth, inaccurate 1318 // Note 50 is set here as the level depth, inaccurate
1287 - $listing = $folder->get_listing(50, 'DF'); //DF 1319 + $listing = $folder->get_listing(50, 'DFS'); //DFS
1288 1320
1289 if ($folderId == '1') { 1321 if ($folderId == '1') {
1290 $path = 'KnowledgeTree'; 1322 $path = 'KnowledgeTree';
@@ -1328,11 +1360,54 @@ Fatal error: Cannot unset string offsets in on line 981 @@ -1328,11 +1360,54 @@ Fatal error: Cannot unset string offsets in on line 981
1328 $this->addFolderToList($item['items'], $path.'/'.$item['filename']); 1360 $this->addFolderToList($item['items'], $path.'/'.$item['filename']);
1329 1361
1330 1362
  1363 + } else if ($item['item_type'] == 'S') {
  1364 + if (isset($item['linked_document_id']) && $item['linked_document_id'] != '') {
  1365 +
  1366 +
  1367 + $this->listOfFiles[] = array(
  1368 + 'folderName' => $path,
  1369 + 'documentId' => $item['linked_document_id'],
  1370 + 'filename' => $item['filename'],
  1371 + 'fullpath' => $path.'/'.$item['filename']
  1372 + );
  1373 +
  1374 +
  1375 + // Need to delved again if it is a shortcut folder
  1376 + } else if (isset($item['linked_folder_id']) && $item['linked_folder_id']) {
  1377 +
  1378 +
  1379 +
  1380 + $folder = $this->KT->get_folder_by_id($item['linked_folder_id']);
  1381 +
  1382 + if (PEAR::isError($folder)){
  1383 +
  1384 + } else {
  1385 + // Note 50 is set here as the level depth, inaccurate
  1386 + $listing2 = $folder->get_listing(50, 'DFS'); //DF
  1387 +
  1388 + /*
  1389 + if ($folderId == '1') {
  1390 + $path = 'KnowledgeTree';
  1391 + } else {
  1392 + $path = $item['filename'];
  1393 + }*/
  1394 +
  1395 + $this->addFolderToList($listing2, $path.'/'.$item['filename']);
  1396 + }
  1397 +
  1398 +
  1399 +
  1400 +
  1401 + }
  1402 +
  1403 +
1331 } 1404 }
1332 1405
1333 } 1406 }
1334 } 1407 }
1335 1408
  1409 + // ***********************************************
  1410 +
1336 private function convert_size_to_num($size) 1411 private function convert_size_to_num($size)
1337 { 1412 {
1338 //This function transforms the php.ini notation for numbers (like '2M') to an integer (2*1024*1024 in this case) 1413 //This function transforms the php.ini notation for numbers (like '2M') to an integer (2*1024*1024 in this case)
@@ -1388,25 +1463,31 @@ Fatal error: Cannot unset string offsets in on line 981 @@ -1388,25 +1463,31 @@ Fatal error: Cannot unset string offsets in on line 981
1388 { 1463 {
1389 $folderObj = &$kt->get_folder_by_id ( $folder->getFolderId() ); 1464 $folderObj = &$kt->get_folder_by_id ( $folder->getFolderId() );
1390 1465
1391 - $folderArray = array();  
1392 - $folderArray['id'] = $folderObj->folderid;  
1393 - $folderArray['name'] = $folderObj->get_folder_name();  
1394 -  
1395 - $parentIds = explode(',', $folderObj->getParentFolderIds());  
1396 - $path = '/F_0';  
1397 -  
1398 - if (count($parentIds) > 0 && $folderObj->getParentFolderIds() != '') {  
1399 - foreach ($parentIds as $parentId)  
1400 - {  
1401 - $path .= '/F_'.$parentId; 1466 + if (PEAR::isError ( $folderObj )) {
  1467 + // Ignore, dont add to list
  1468 + } else {
  1469 +
  1470 + $folderArray = array();
  1471 + $folderArray['id'] = $folderObj->folderid;
  1472 + $folderArray['name'] = $folderObj->get_folder_name();
  1473 +
  1474 + $parentIds = explode(',', $folderObj->getParentFolderIds());
  1475 + $path = '/F_0';
  1476 +
  1477 + if (count($parentIds) > 0 && $folderObj->getParentFolderIds() != '') {
  1478 + foreach ($parentIds as $parentId)
  1479 + {
  1480 + $path .= '/F_'.$parentId;
  1481 + }
1402 } 1482 }
1403 - }  
1404 -  
1405 - $path .= '/F_'.$folderObj->folderid;  
1406 -  
1407 - $folderArray['path'] = $path; 1483 +
  1484 + $path .= '/F_'.$folderObj->folderid;
  1485 +
  1486 + $folderArray['path'] = $path;
  1487 +
  1488 + $returnFoldersArray[] = $folderArray;
1408 1489
1409 - $returnFoldersArray[] = $folderArray; 1490 + }
1410 } 1491 }
1411 1492
1412 1493
@@ -1417,39 +1498,44 @@ Fatal error: Cannot unset string offsets in on line 981 @@ -1417,39 +1498,44 @@ Fatal error: Cannot unset string offsets in on line 981
1417 foreach ($items as $item) 1498 foreach ($items as $item)
1418 { 1499 {
1419 $document = $kt->get_document_by_id($item->getDocumentId()); 1500 $document = $kt->get_document_by_id($item->getDocumentId());
1420 - $documentDetail = $document->get_detail();  
1421 -  
1422 - $documentArray = array();  
1423 1501
1424 - $documentArray['id'] = $document->documentid;  
1425 - $documentArray['contentID'] = $document->documentid;  
1426 - $documentArray['title'] = $documentDetail['title'];  
1427 - $documentArray['folderId'] = $documentDetail['folder_id'];  
1428 -  
1429 - // Determine Icon Class  
1430 - $extpos = strrpos ( $documentDetail['filename'], '.' );  
1431 - if ($extpos === false) {  
1432 - $class = 'file-unknown'; 1502 + if (PEAR::isError ( $document )) {
  1503 + // Ignore, dont add to list
1433 } else { 1504 } else {
1434 - $class = 'file-' . substr ( $documentDetail['filename'], $extpos + 1 ); // Get Extension without the dot  
1435 - }  
1436 - $documentArray['iconCls'] = $class;  
1437 -  
1438 - // Determine Icon Path  
1439 - $folderObj = $kt->get_folder_by_id ( $documentDetail['folder_id']);  
1440 - $parentIds = explode(',', $folderObj->getParentFolderIds());  
1441 - $path = '/F_0';  
1442 - if (count($parentIds) > 0 && $folderObj->getParentFolderIds() != '') {  
1443 - foreach ($parentIds as $parentId)  
1444 - {  
1445 - $path .= '/F_'.$parentId; 1505 + $documentDetail = $document->get_detail();
  1506 +
  1507 + $documentArray = array();
  1508 +
  1509 + $documentArray['id'] = $document->documentid;
  1510 + $documentArray['contentID'] = $document->documentid;
  1511 + $documentArray['title'] = $documentDetail['title'];
  1512 + $documentArray['folderId'] = $documentDetail['folder_id'];
  1513 +
  1514 + // Determine Icon Class
  1515 + $extpos = strrpos ( $documentDetail['filename'], '.' );
  1516 + if ($extpos === false) {
  1517 + $class = 'file-unknown';
  1518 + } else {
  1519 + $class = 'file-' . substr ( $documentDetail['filename'], $extpos + 1 ); // Get Extension without the dot
  1520 + }
  1521 + $documentArray['iconCls'] = $class;
  1522 +
  1523 + // Determine Icon Path
  1524 + $folderObj = $kt->get_folder_by_id ( $documentDetail['folder_id']);
  1525 + $parentIds = explode(',', $folderObj->getParentFolderIds());
  1526 + $path = '/F_0';
  1527 + if (count($parentIds) > 0 && $folderObj->getParentFolderIds() != '') {
  1528 + foreach ($parentIds as $parentId)
  1529 + {
  1530 + $path .= '/F_'.$parentId;
  1531 + }
1446 } 1532 }
  1533 + $path .= '/F_'.$documentDetail['folder_id'];
  1534 +
  1535 + $documentArray['folderPath'] = $path;
  1536 +
  1537 + $returnDocumentArray[] = $documentArray;
1447 } 1538 }
1448 - $path .= '/F_'.$documentDetail['folder_id'];  
1449 -  
1450 - $documentArray['folderPath'] = $path;  
1451 -  
1452 - $returnDocumentArray[] = $documentArray;  
1453 } 1539 }
1454 1540
1455 $this->setResponse(array('documents'=>$returnDocumentArray, 'folders'=>$returnFoldersArray)); 1541 $this->setResponse(array('documents'=>$returnDocumentArray, 'folders'=>$returnFoldersArray));