Commit 866549cecf5df7a5ba6b91f57bfa0fd1025ae195

Authored by Tohir Solomons
1 parent 778e46c5

Prevent error of document in recently viewed list, but has been deleted subsequently

Committed by: Tohir Solomons
webservice/clienttools/services/0.9.2/kt.php
@@ -1463,25 +1463,31 @@ Fatal error: Cannot unset string offsets in on line 981 @@ -1463,25 +1463,31 @@ Fatal error: Cannot unset string offsets in on line 981
1463 { 1463 {
1464 $folderObj = &$kt->get_folder_by_id ( $folder->getFolderId() ); 1464 $folderObj = &$kt->get_folder_by_id ( $folder->getFolderId() );
1465 1465
1466 - $folderArray = array();  
1467 - $folderArray['id'] = $folderObj->folderid;  
1468 - $folderArray['name'] = $folderObj->get_folder_name();  
1469 -  
1470 - $parentIds = explode(',', $folderObj->getParentFolderIds());  
1471 - $path = '/F_0';  
1472 -  
1473 - if (count($parentIds) > 0 && $folderObj->getParentFolderIds() != '') {  
1474 - foreach ($parentIds as $parentId)  
1475 - {  
1476 - $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 + }
1477 } 1482 }
1478 - }  
1479 -  
1480 - $path .= '/F_'.$folderObj->folderid;  
1481 -  
1482 - $folderArray['path'] = $path; 1483 +
  1484 + $path .= '/F_'.$folderObj->folderid;
  1485 +
  1486 + $folderArray['path'] = $path;
  1487 +
  1488 + $returnFoldersArray[] = $folderArray;
1483 1489
1484 - $returnFoldersArray[] = $folderArray; 1490 + }
1485 } 1491 }
1486 1492
1487 1493
@@ -1492,39 +1498,44 @@ Fatal error: Cannot unset string offsets in on line 981 @@ -1492,39 +1498,44 @@ Fatal error: Cannot unset string offsets in on line 981
1492 foreach ($items as $item) 1498 foreach ($items as $item)
1493 { 1499 {
1494 $document = $kt->get_document_by_id($item->getDocumentId()); 1500 $document = $kt->get_document_by_id($item->getDocumentId());
1495 - $documentDetail = $document->get_detail();  
1496 -  
1497 - $documentArray = array();  
1498 -  
1499 - $documentArray['id'] = $document->documentid;  
1500 - $documentArray['contentID'] = $document->documentid;  
1501 - $documentArray['title'] = $documentDetail['title'];  
1502 - $documentArray['folderId'] = $documentDetail['folder_id'];  
1503 1501
1504 - // Determine Icon Class  
1505 - $extpos = strrpos ( $documentDetail['filename'], '.' );  
1506 - if ($extpos === false) {  
1507 - $class = 'file-unknown'; 1502 + if (PEAR::isError ( $document )) {
  1503 + // Ignore, dont add to list
1508 } else { 1504 } else {
1509 - $class = 'file-' . substr ( $documentDetail['filename'], $extpos + 1 ); // Get Extension without the dot  
1510 - }  
1511 - $documentArray['iconCls'] = $class;  
1512 -  
1513 - // Determine Icon Path  
1514 - $folderObj = $kt->get_folder_by_id ( $documentDetail['folder_id']);  
1515 - $parentIds = explode(',', $folderObj->getParentFolderIds());  
1516 - $path = '/F_0';  
1517 - if (count($parentIds) > 0 && $folderObj->getParentFolderIds() != '') {  
1518 - foreach ($parentIds as $parentId)  
1519 - {  
1520 - $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
1521 } 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 + }
  1532 + }
  1533 + $path .= '/F_'.$documentDetail['folder_id'];
  1534 +
  1535 + $documentArray['folderPath'] = $path;
  1536 +
  1537 + $returnDocumentArray[] = $documentArray;
1522 } 1538 }
1523 - $path .= '/F_'.$documentDetail['folder_id'];  
1524 -  
1525 - $documentArray['folderPath'] = $path;  
1526 -  
1527 - $returnDocumentArray[] = $documentArray;  
1528 } 1539 }
1529 1540
1530 $this->setResponse(array('documents'=>$returnDocumentArray, 'folders'=>$returnFoldersArray)); 1541 $this->setResponse(array('documents'=>$returnDocumentArray, 'folders'=>$returnFoldersArray));