Commit 864f1f34f4e751bcb6ef3c89b1613abf5d684aa6
1 parent
68cc3880
WSA-49
"Improve the document_detail and folder_detail records to incorporate more fields available on the document" Updated. Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7763 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
3 changed files
with
58 additions
and
17 deletions
ktapi/KTAPIDocument.inc.php
| ... | ... | @@ -261,7 +261,7 @@ class KTAPI_Document extends KTAPI_FolderItem |
| 261 | 261 | return new KTAPI_Error(KTAPI_ERROR_INTERNAL_ERROR,$res); |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - $oDocumentTransaction = & new DocumentTransaction($this->document, $reason, 'ktcore.transactions.force_checkin'); | |
| 264 | + $oDocumentTransaction = new DocumentTransaction($this->document, $reason, 'ktcore.transactions.force_checkin'); | |
| 265 | 265 | |
| 266 | 266 | $res = $oDocumentTransaction->create(); |
| 267 | 267 | if (($res === false) || PEAR::isError($res)) { |
| ... | ... | @@ -280,13 +280,15 @@ class KTAPI_Document extends KTAPI_FolderItem |
| 280 | 280 | dcv.size, |
| 281 | 281 | w.name as workflow, |
| 282 | 282 | ws.name as workflow_state, |
| 283 | - dlt.name as link_type | |
| 283 | + dlt.name as link_type, dtl.name as document_type, | |
| 284 | + dcv.major_version, dcv.minor_version | |
| 284 | 285 | FROM |
| 285 | 286 | document_link dl |
| 286 | 287 | INNER JOIN document_link_types dlt ON dl.link_type_id=dlt.id |
| 287 | 288 | INNER JOIN documents d ON dl.child_document_id=d.id |
| 288 | 289 | INNER JOIN document_metadata_version dmv ON d.metadata_version_id=dmv.id |
| 289 | 290 | INNER JOIN document_content_version dcv ON dmv.content_version_id=dcv.id |
| 291 | + INNER JOIN document_types_lookup dtl ON dtl.id=dmv.document_type_id | |
| 290 | 292 | LEFT OUTER JOIN workflow_documents wd ON d.id=wd.document_id |
| 291 | 293 | LEFT OUTER JOIN workflows w ON w.id=wd.workflow_id |
| 292 | 294 | LEFT OUTER JOIN workflow_states ws ON wd.state_id=ws.id |
| ... | ... | @@ -319,8 +321,12 @@ class KTAPI_Document extends KTAPI_FolderItem |
| 319 | 321 | |
| 320 | 322 | $result[] = array( |
| 321 | 323 | 'document_id'=>(int)$row['document_id'], |
| 324 | + 'custom_document_no'=>'n/a', | |
| 325 | + 'oem_document_no'=>'n/a', | |
| 322 | 326 | 'title'=> $row['title'], |
| 323 | - 'size'=>(int)$row['size'], | |
| 327 | + 'document_type'=> $row['document_type'], | |
| 328 | + 'version'=> (float) ($row['major_version'] . '.' . $row['minor_version']), | |
| 329 | + 'filesize'=>(int)$row['size'], | |
| 324 | 330 | 'workflow'=>empty($row['workflow'])?'n/a':$row['workflow'], |
| 325 | 331 | 'workflow_state'=>empty($row['workflow_state'])?'n/a':$row['workflow_state'], |
| 326 | 332 | 'link_type'=>empty($row['link_type'])?'unknown':$row['link_type'], |
| ... | ... | @@ -432,7 +438,7 @@ class KTAPI_Document extends KTAPI_FolderItem |
| 432 | 438 | return new KTAPI_Error(KTAPI_ERROR_INTERNAL_ERROR,$res ); |
| 433 | 439 | } |
| 434 | 440 | |
| 435 | - $oDocumentTransaction = & new DocumentTransaction($this->document, $reason, 'ktcore.transactions.permissions_change'); | |
| 441 | + $oDocumentTransaction = new DocumentTransaction($this->document, $reason, 'ktcore.transactions.permissions_change'); | |
| 436 | 442 | |
| 437 | 443 | $res = $oDocumentTransaction->create(); |
| 438 | 444 | if (($res === false) || PEAR::isError($res)) { |
| ... | ... | @@ -776,7 +782,7 @@ class KTAPI_Document extends KTAPI_FolderItem |
| 776 | 782 | return new KTAPI_Error(KTAPI_ERROR_INTERNAL_ERROR, $res); |
| 777 | 783 | } |
| 778 | 784 | |
| 779 | - $oDocumentTransaction = & new DocumentTransaction($this->document, sprintf(_kt('Document archived: %s'), $reason), 'ktcore.transactions.update'); | |
| 785 | + $oDocumentTransaction = new DocumentTransaction($this->document, sprintf(_kt('Document archived: %s'), $reason), 'ktcore.transactions.update'); | |
| 780 | 786 | $oDocumentTransaction->create(); |
| 781 | 787 | |
| 782 | 788 | DBUtil::commit(); |
| ... | ... | @@ -1339,7 +1345,7 @@ class KTAPI_Document extends KTAPI_FolderItem |
| 1339 | 1345 | $workflowid=$this->document->getWorkflowId(); |
| 1340 | 1346 | if (empty($workflowid)) |
| 1341 | 1347 | { |
| 1342 | - return new PEAR_Error(KTAPI_ERROR_WORKFLOW_NOT_IN_PROGRESS); | |
| 1348 | + return array(); | |
| 1343 | 1349 | } |
| 1344 | 1350 | |
| 1345 | 1351 | $result = array(); |
| ... | ... | @@ -1402,12 +1408,18 @@ class KTAPI_Document extends KTAPI_FolderItem |
| 1402 | 1408 | // make sure we ge tthe latest |
| 1403 | 1409 | $this->clearCache(); |
| 1404 | 1410 | |
| 1411 | + $config = KTConfig::getSingleton(); | |
| 1412 | + $wsversion = $config->get('webservice/version', LATEST_WEBSERVICE_VERSION); | |
| 1413 | + | |
| 1405 | 1414 | $detail = array(); |
| 1406 | 1415 | $document = $this->document; |
| 1407 | 1416 | |
| 1408 | 1417 | // get the document id |
| 1409 | 1418 | $detail['document_id'] = (int) $document->getId(); |
| 1410 | 1419 | |
| 1420 | + $detail['custom_document_no'] = 'n/a'; | |
| 1421 | + $detail['oem_document_no'] = 'n/a'; | |
| 1422 | + | |
| 1411 | 1423 | // get the title |
| 1412 | 1424 | $detail['title'] = $document->getName(); |
| 1413 | 1425 | |
| ... | ... | @@ -1510,12 +1522,16 @@ class KTAPI_Document extends KTAPI_FolderItem |
| 1510 | 1522 | |
| 1511 | 1523 | // get the version |
| 1512 | 1524 | $detail['version'] = $document->getVersion(); |
| 1525 | + if ($wsversion >= 2) | |
| 1526 | + { | |
| 1527 | + $detail['version'] = (float) $detail['version']; | |
| 1528 | + } | |
| 1513 | 1529 | |
| 1514 | 1530 | // check immutability |
| 1515 | 1531 | $detail['is_immutable'] = (bool) $document->getImmutable(); |
| 1516 | 1532 | |
| 1517 | 1533 | // check permissions |
| 1518 | - $detail['permissions'] = 'not available'; | |
| 1534 | + $detail['permissions'] = 'n/a'; | |
| 1519 | 1535 | |
| 1520 | 1536 | // get workflow name |
| 1521 | 1537 | $workflowid = $document->getWorkflowId(); |
| ... | ... | @@ -1550,7 +1566,7 @@ class KTAPI_Document extends KTAPI_FolderItem |
| 1550 | 1566 | $mimetypeid = $document->getMimeTypeID(); |
| 1551 | 1567 | $detail['mime_type'] =KTMime::getMimeTypeName($mimetypeid); |
| 1552 | 1568 | $detail['mime_icon_path'] =KTMime::getIconPath($mimetypeid); |
| 1553 | - $detail['mime_display'] =KTMime::getFriendlyNameForString($type); | |
| 1569 | + $detail['mime_display'] =KTMime::getFriendlyNameForString($detail['mime_type']); | |
| 1554 | 1570 | |
| 1555 | 1571 | // get the storage path |
| 1556 | 1572 | $detail['storage_path'] = $document->getStoragePath(); |
| ... | ... | @@ -1574,7 +1590,7 @@ class KTAPI_Document extends KTAPI_FolderItem |
| 1574 | 1590 | $options = array(); |
| 1575 | 1591 | |
| 1576 | 1592 | |
| 1577 | - $oDocumentTransaction = & new DocumentTransaction($this->document, 'Document downloaded', 'ktcore.transactions.download', $aOptions); | |
| 1593 | + $oDocumentTransaction = new DocumentTransaction($this->document, 'Document downloaded', 'ktcore.transactions.download', $aOptions); | |
| 1578 | 1594 | $oDocumentTransaction->create(); |
| 1579 | 1595 | } |
| 1580 | 1596 | |
| ... | ... | @@ -1597,6 +1613,13 @@ class KTAPI_Document extends KTAPI_FolderItem |
| 1597 | 1613 | return new KTAPI_Error(KTAPI_ERROR_INTERNAL_ERROR, $transactions ); |
| 1598 | 1614 | } |
| 1599 | 1615 | |
| 1616 | + $config = KTConfig::getSingleton(); | |
| 1617 | + $wsversion = $config->get('webservice/version', LATEST_WEBSERVICE_VERSION); | |
| 1618 | + foreach($transactions as $key=>$transaction) | |
| 1619 | + { | |
| 1620 | + $transactions[$key]['version'] = (float) $transaction['version']; | |
| 1621 | + } | |
| 1622 | + | |
| 1600 | 1623 | return $transactions; |
| 1601 | 1624 | } |
| 1602 | 1625 | |
| ... | ... | @@ -1609,6 +1632,9 @@ class KTAPI_Document extends KTAPI_FolderItem |
| 1609 | 1632 | { |
| 1610 | 1633 | $metadata_versions = KTDocumentMetadataVersion::getByDocument($this->document); |
| 1611 | 1634 | |
| 1635 | + $config = KTConfig::getSingleton(); | |
| 1636 | + $wsversion = $config->get('webservice/version', LATEST_WEBSERVICE_VERSION); | |
| 1637 | + | |
| 1612 | 1638 | $versions = array(); |
| 1613 | 1639 | foreach ($metadata_versions as $version) |
| 1614 | 1640 | { |
| ... | ... | @@ -1618,18 +1644,20 @@ class KTAPI_Document extends KTAPI_FolderItem |
| 1618 | 1644 | |
| 1619 | 1645 | $userid = $document->getModifiedUserId(); |
| 1620 | 1646 | $user = User::get($userid); |
| 1621 | - if (PEAR::isError($user)) | |
| 1622 | - { | |
| 1623 | - $username = $user->getName(); | |
| 1624 | - } | |
| 1625 | - else | |
| 1647 | + $username = 'Unknown'; | |
| 1648 | + if (!PEAR::isError($user)) | |
| 1626 | 1649 | { |
| 1627 | - $username = 'Unknown'; | |
| 1650 | + $username = is_null($user)?'n/a':$user->getName(); | |
| 1628 | 1651 | } |
| 1629 | 1652 | |
| 1630 | 1653 | $version['user'] = $username; |
| 1631 | 1654 | $version['metadata_version'] = $document->getMetadataVersion(); |
| 1632 | 1655 | $version['content_version'] = $document->getVersion(); |
| 1656 | + if ($wsversion >= 2) | |
| 1657 | + { | |
| 1658 | + $version['metadata_version'] = (int) $version['metadata_version']; | |
| 1659 | + $version['content_version'] = (float) $version['content_version']; | |
| 1660 | + } | |
| 1633 | 1661 | |
| 1634 | 1662 | $versions[] = $version; |
| 1635 | 1663 | } |
| ... | ... | @@ -1649,7 +1677,7 @@ class KTAPI_Document extends KTAPI_FolderItem |
| 1649 | 1677 | } |
| 1650 | 1678 | DBUtil::startTransaction(); |
| 1651 | 1679 | |
| 1652 | - $transaction = & new DocumentTransaction($this->document, "Document expunged", 'ktcore.transactions.expunge'); | |
| 1680 | + $transaction = new DocumentTransaction($this->document, "Document expunged", 'ktcore.transactions.expunge'); | |
| 1653 | 1681 | |
| 1654 | 1682 | $transaction->create(); |
| 1655 | 1683 | ... | ... |
ktapi/KTAPIFolder.inc.php
| ... | ... | @@ -197,6 +197,7 @@ class KTAPI_Folder extends KTAPI_FolderItem |
| 197 | 197 | function get_full_path() |
| 198 | 198 | { |
| 199 | 199 | $path = $this->folder->getFullPath() . '/' . $this->folder->getName(); |
| 200 | + if (substr($path,0,1) == '/') $path = substr($path,1); | |
| 200 | 201 | |
| 201 | 202 | return $path; |
| 202 | 203 | } |
| ... | ... | @@ -350,7 +351,11 @@ class KTAPI_Folder extends KTAPI_FolderItem |
| 350 | 351 | 'id' => (int) $folder->getId(), |
| 351 | 352 | 'item_type' => 'F', |
| 352 | 353 | |
| 354 | + 'custom_document_no'=>'n/a', | |
| 355 | + 'oem_document_no'=>'n/a', | |
| 356 | + | |
| 353 | 357 | 'title' => $folder->getName(), |
| 358 | + 'document_type' => 'n/a', | |
| 354 | 359 | 'filename' => $folder->getName(), |
| 355 | 360 | 'filesize' => 'n/a', |
| 356 | 361 | |
| ... | ... | @@ -469,11 +474,19 @@ class KTAPI_Folder extends KTAPI_FolderItem |
| 469 | 474 | |
| 470 | 475 | if ($wsversion >= 2) |
| 471 | 476 | { |
| 477 | + $docTypeId = $document->getDocumentTypeID(); | |
| 478 | + $documentType = DocumentType::get($docTypeId); | |
| 479 | + | |
| 480 | + | |
| 472 | 481 | $contents[] = array( |
| 473 | 482 | 'id' => (int) $document->getId(), |
| 474 | 483 | 'item_type' => 'D', |
| 475 | 484 | |
| 485 | + 'custom_document_no'=>'n/a', | |
| 486 | + 'oem_document_no'=>'n/a', | |
| 487 | + | |
| 476 | 488 | 'title' => $document->getName(), |
| 489 | + 'document_type'=>$documentType->getName(), | |
| 477 | 490 | 'filename' => $document->getFileName(), |
| 478 | 491 | 'filesize' => $document->getFileSize(), |
| 479 | 492 | ... | ... |
ktapi/KTAPISession.inc.php
| ... | ... | @@ -54,7 +54,7 @@ class KTAPI_Session |
| 54 | 54 | |
| 55 | 55 | $this->ktapi=&$ktapi; |
| 56 | 56 | $this->user=&$user; |
| 57 | - $this->origUserId = $_SESSION['userID']; | |
| 57 | + $this->origUserId = isset($_SESSION['userID'])?$_SESSION['userID']:null; | |
| 58 | 58 | $_SESSION['userID']=$user->getId(); |
| 59 | 59 | $this->active = false; |
| 60 | 60 | } | ... | ... |