Commit ab3b60494dca8d55411e57fa1680b5a1fc85cb54

Authored by Conrad Vermeulen
1 parent 76a2cec3

WSA-72

"Add missing fields to document detail structure in web services"
Updated.

Committed By: Conrad Vermeulen
Reviewed By: Megan Watson

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7742 c91229c3-7414-0410-bfa2-8a42b809f60b
ktapi/KTAPIDocument.inc.php
... ... @@ -1405,123 +1405,156 @@ class KTAPI_Document extends KTAPI_FolderItem
1405 1405 $detail = array();
1406 1406 $document = $this->document;
1407 1407  
  1408 + // get the document id
  1409 + $detail['document_id'] = (int) $document->getId();
  1410 +
  1411 + // get the title
1408 1412 $detail['title'] = $document->getName();
1409 1413  
  1414 + // get the document type
1410 1415 $documenttypeid=$document->getDocumentTypeID();
  1416 + $documenttype = '* unknown *';
1411 1417 if (is_numeric($documenttypeid))
1412 1418 {
1413   - $documenttype = DocumentType::get($documenttypeid);
  1419 + $dt = DocumentType::get($documenttypeid);
1414 1420  
1415   - $documenttype=$documenttype->getName();
1416   - }
1417   - else
1418   - {
1419   - $documenttype = '* unknown *';
  1421 + if (!is_null($dt) && !PEAR::isError($dt))
  1422 + {
  1423 + $documenttype=$dt->getName();
  1424 + }
1420 1425 }
1421 1426 $detail['document_type'] = $documenttype;
1422 1427  
1423   - $detail['version'] = $document->getVersion();
  1428 + // get the filename
1424 1429 $detail['filename'] = $document->getFilename();
1425 1430  
1426   - $detail['created_date'] = $document->getCreatedDateTime();
  1431 + // get the filesize
  1432 + $detail['filesize'] = (int) $document->getFileSize();
1427 1433  
  1434 + // get the folder id
  1435 + $detail['folder_id'] = (int) $document->getFolderID();
  1436 +
  1437 + // get the creator
1428 1438 $userid = $document->getCreatorID();
  1439 + $username='n/a';
1429 1440 if (is_numeric($userid))
1430 1441 {
  1442 + $username = '* unknown *';
1431 1443 $user = User::get($userid);
1432   - $username=(is_null($user) || PEAR::isError($user))?'* unknown *':$user->getName();
1433   - }
1434   - else
1435   - {
1436   - $username='n/a';
  1444 + if (!is_null($user) && !PEAR::isError($user))
  1445 + {
  1446 + $username = $user->getName();
  1447 + }
1437 1448 }
1438 1449 $detail['created_by'] = $username;
1439   - $detail['updated_date'] = $document->getLastModifiedDate();
1440   - $detail['modified_date'] = $document->getLastModifiedDate();
1441 1450  
1442   - $userid = $document->getModifiedUserId();
  1451 + // get the creation date
  1452 + $detail['created_date'] = $document->getCreatedDateTime();
  1453 +
  1454 + // get the checked out user
  1455 + $userid = $document->getCheckedOutUserID();
  1456 + $username='n/a';
1443 1457 if (is_numeric($userid))
1444 1458 {
  1459 + $username = '* unknown *';
1445 1460 $user = User::get($userid);
1446   - $username=(is_null($user) || PEAR::isError($user))?'* unknown *':$user->getName();
1447   - }
1448   - else
1449   - {
1450   - $username='n/a';
1451   - }
1452   - $detail['modified_by'] = $username;
1453   - $detail['updated_by'] = $username;
1454   - $detail['document_id'] = (int) $document->getId();
1455   - $detail['folder_id'] = (int) $document->getFolderID();
1456   -
1457   - $workflowid = $document->getWorkflowId();
1458   - if (is_numeric($workflowid))
1459   - {
1460   - $workflow = KTWorkflow::get($workflowid);
1461   - $workflowname=(is_null($workflow) || PEAR::isError($workflow))?'* unknown *':$workflow->getName();
1462   - }
1463   - else
1464   - {
1465   - $workflowname='n/a';
  1461 + if (!is_null($user) && !PEAR::isError($user))
  1462 + {
  1463 + $username = $user->getName();
  1464 + }
1466 1465 }
1467   - $detail['workflow'] = $workflowname;
  1466 + $detail['checked_out_by'] = $username;
1468 1467  
1469   - $stateid = $document->getWorkflowStateId();
1470   - if (is_numeric($stateid))
  1468 + // get the checked out date
  1469 + list($major, $minor, $fix) = explode('.', $default->systemVersion);
  1470 + if ($major == 3 && $minor >= 5)
1471 1471 {
1472   - $state = KTWorkflowState::get($stateid);
1473   - $workflowstate=(is_null($state) || PEAR::isError($state))?'* unknown *':$state->getName();
  1472 + $detail['checked_out_date'] = $document->getCheckedOutDate();
1474 1473 }
1475 1474 else
1476 1475 {
1477   - $workflowstate = 'n/a';
  1476 + $detail['checked_out_date'] = $detail['modified_date'];
1478 1477 }
1479   - $detail['workflow_state']=$workflowstate;
1480   -
1481   - $userid = $document->getOwnerID();
  1478 + if (is_null($detail['checked_out_date'])) $detail['checked_out_date'] = 'n/a';
1482 1479  
  1480 + // get the modified user
  1481 + $userid = $document->getModifiedUserId();
  1482 + $username='n/a';
1483 1483 if (is_numeric($userid))
1484 1484 {
  1485 + $username = '* unknown *';
1485 1486 $user = User::get($userid);
1486   - $username=(is_null($user) || PEAR::isError($user))?'* unknown *':$user->getName();
1487   - }
1488   - else
1489   - {
1490   - $username = 'n/a';
  1487 + if (!is_null($user) && !PEAR::isError($user))
  1488 + {
  1489 + $username = $user->getName();
  1490 + }
1491 1491 }
1492   - $detail['owner'] = $username;
1493   -
1494   - $detail['is_immutable'] = (bool) $document->getImmutable();
1495   -
  1492 + $detail['modified_by'] = $detail['updated_by'] = $username;
1496 1493  
1497   - $userid = $document->getCheckedOutUserID();
  1494 + // get the modified date
  1495 + $detail['updated_date'] = $detail['modified_date'] = $document->getLastModifiedDate();
1498 1496  
  1497 + // get the owner
  1498 + $userid = $document->getOwnerID();
  1499 + $username='n/a';
1499 1500 if (is_numeric($userid))
1500 1501 {
  1502 + $username = '* unknown *';
1501 1503 $user = User::get($userid);
1502   - $username=(is_null($user) || PEAR::isError($user))?'* unknown *':$user->getName();
1503   - }
1504   - else
1505   - {
1506   - $username = 'n/a';
  1504 + if (!is_null($user) && !PEAR::isError($user))
  1505 + {
  1506 + $username = $user->getName();
  1507 + }
1507 1508 }
1508   - $detail['checked_out_by'] = $username;
  1509 + $detail['owned_by'] = $username;
1509 1510  
1510   - list($major, $minor, $fix) = explode('.', $default->systemVersion);
  1511 + // get the version
  1512 + $detail['version'] = $document->getVersion();
1511 1513  
  1514 + // check immutability
  1515 + $detail['is_immutable'] = (bool) $document->getImmutable();
1512 1516  
1513   - if ($major == 3 && $minor >= 5)
  1517 + // check permissions
  1518 + $detail['permissions'] = 'not available';
  1519 +
  1520 + // get workflow name
  1521 + $workflowid = $document->getWorkflowId();
  1522 + $workflowname='n/a';
  1523 + if (is_numeric($workflowid))
1514 1524 {
1515   - $detail['checked_out_date'] = $document->getCheckedOutDate();
  1525 + $workflow = KTWorkflow::get($workflowid);
  1526 + if (!is_null($workflow) && !PEAR::isError($workflow))
  1527 + {
  1528 + $workflowname = $workflow->getName();
  1529 + }
1516 1530 }
1517   - else
  1531 + $detail['workflow'] = $workflowname;
  1532 +
  1533 + // get the workflow state
  1534 + $stateid = $document->getWorkflowStateId();
  1535 + $workflowstate = 'n/a';
  1536 + if (is_numeric($stateid))
1518 1537 {
1519   - $detail['checked_out_date'] = $detail['modified_date'];
  1538 + $state = KTWorkflowState::get($stateid);
  1539 + if (!is_null($state) && !PEAR::isError($state))
  1540 + {
  1541 + $workflowstate = $state->getName();
  1542 + }
1520 1543 }
1521   - if (is_null($detail['checked_out_date'])) $detail['checked_out_date'] = 'n/a';
  1544 + $detail['workflow_state']=$workflowstate;
1522 1545  
  1546 + // get the full path
1523 1547 $detail['full_path'] = $this->ktapi_folder->get_full_path() . '/' . $this->get_title();
1524 1548  
  1549 + // get mime info
  1550 + $mimetypeid = $document->getMimeTypeID();
  1551 + $detail['mime_type'] =KTMime::getMimeTypeName($mimetypeid);
  1552 + $detail['mime_icon_path'] =KTMime::getIconPath($mimetypeid);
  1553 + $detail['mime_display'] =KTMime::getFriendlyNameForString($type);
  1554 +
  1555 + // get the storage path
  1556 + $detail['storage_path'] = $document->getStoragePath();
  1557 +
1525 1558 return $detail;
1526 1559 }
1527 1560  
... ...
ktapi/KTAPIFolder.inc.php
... ... @@ -367,7 +367,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
367 367  
368 368 'version' => 'n/a',
369 369  
370   - 'immutable'=> 'n/a',
  370 + 'is_immutable'=> 'n/a',
371 371 'permissions' => 'n/a',
372 372  
373 373 'workflow'=>'n/a',
... ... @@ -490,7 +490,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
490 490  
491 491 'version' => $document->getMajorVersionNumber() . '.' . $document->getMinorVersionNumber(),
492 492  
493   - 'immutable'=> $document->getImmutable()?'true':'false',
  493 + 'is_immutable'=> $document->getImmutable()?'true':'false',
494 494 'permissions' => 'n/a',
495 495  
496 496 'workflow'=> $workflow,
... ...
ktwebservice/webservice.php
... ... @@ -183,6 +183,7 @@ class KTWebService
183 183 'item_type' => 'string',
184 184  
185 185 'title' => 'string',
  186 + 'document_type' => 'string',
186 187 'filename' => 'string',
187 188 'filesize' => 'string',
188 189  
... ... @@ -199,7 +200,7 @@ class KTWebService
199 200  
200 201 'version' => 'string',
201 202  
202   - 'immutable'=>'boolean',
  203 + 'is_immutable'=>'string',
203 204 'permissions' => 'string',
204 205  
205 206 'workflow'=>'string',
... ... @@ -258,23 +259,40 @@ class KTWebService
258 259 array(
259 260 'status_code'=>'int',
260 261 'message'=>'string',
  262 +
  263 + 'document_id' => 'int',
261 264 'title' => 'string',
262 265 'document_type' => 'string',
263   - 'version' => 'string',
264 266 'filename' => 'string',
265   - 'created_date' => 'string',
  267 + 'filesize' => 'int',
  268 + 'folder_id' => 'int',
  269 +
266 270 'created_by' => 'string',
267   - 'modified_date' => 'string',
  271 + 'created_date' => 'string',
  272 +
  273 + 'checked_out_by'=>'string',
  274 + 'checked_out_date'=>'string',
  275 +
268 276 'modified_by' => 'string',
269   - 'document_id' => 'int',
270   - 'folder_id' => 'int',
  277 + 'modified_date' => 'string',
  278 +
  279 + 'owned_by'=>'string',
  280 +
  281 + 'version' => 'string',
  282 +
  283 + 'is_immutable'=>'boolean',
  284 + 'permissions' => 'string',
  285 +
271 286 'workflow' => 'string',
272 287 'workflow_state' => 'string',
273 288 'full_path' => 'string',
274   - 'owner'=>'string',
275   - 'is_immutable'=>'boolean',
276   - 'checked_out_date'=>'string',
277   - 'checked_out_by'=>'string',
  289 +
  290 + 'mime_type' => 'string',
  291 + 'mime_icon_path' => 'string',
  292 + 'mime_display' => 'string',
  293 +
  294 + 'storage_path' => 'string',
  295 +
278 296 'metadata' => "{urn:$this->namespace}kt_metadata_fieldsets",
279 297 'links' => "{urn:$this->namespace}kt_linked_documents",
280 298 'transitions' => "{urn:$this->namespace}kt_workflow_transitions",
... ...