diff --git a/ktapi/KTAPIDocument.inc.php b/ktapi/KTAPIDocument.inc.php index 3ab4902..5fb3bbb 100644 --- a/ktapi/KTAPIDocument.inc.php +++ b/ktapi/KTAPIDocument.inc.php @@ -1405,123 +1405,156 @@ class KTAPI_Document extends KTAPI_FolderItem $detail = array(); $document = $this->document; + // get the document id + $detail['document_id'] = (int) $document->getId(); + + // get the title $detail['title'] = $document->getName(); + // get the document type $documenttypeid=$document->getDocumentTypeID(); + $documenttype = '* unknown *'; if (is_numeric($documenttypeid)) { - $documenttype = DocumentType::get($documenttypeid); + $dt = DocumentType::get($documenttypeid); - $documenttype=$documenttype->getName(); - } - else - { - $documenttype = '* unknown *'; + if (!is_null($dt) && !PEAR::isError($dt)) + { + $documenttype=$dt->getName(); + } } $detail['document_type'] = $documenttype; - $detail['version'] = $document->getVersion(); + // get the filename $detail['filename'] = $document->getFilename(); - $detail['created_date'] = $document->getCreatedDateTime(); + // get the filesize + $detail['filesize'] = (int) $document->getFileSize(); + // get the folder id + $detail['folder_id'] = (int) $document->getFolderID(); + + // get the creator $userid = $document->getCreatorID(); + $username='n/a'; if (is_numeric($userid)) { + $username = '* unknown *'; $user = User::get($userid); - $username=(is_null($user) || PEAR::isError($user))?'* unknown *':$user->getName(); - } - else - { - $username='n/a'; + if (!is_null($user) && !PEAR::isError($user)) + { + $username = $user->getName(); + } } $detail['created_by'] = $username; - $detail['updated_date'] = $document->getLastModifiedDate(); - $detail['modified_date'] = $document->getLastModifiedDate(); - $userid = $document->getModifiedUserId(); + // get the creation date + $detail['created_date'] = $document->getCreatedDateTime(); + + // get the checked out user + $userid = $document->getCheckedOutUserID(); + $username='n/a'; if (is_numeric($userid)) { + $username = '* unknown *'; $user = User::get($userid); - $username=(is_null($user) || PEAR::isError($user))?'* unknown *':$user->getName(); - } - else - { - $username='n/a'; - } - $detail['modified_by'] = $username; - $detail['updated_by'] = $username; - $detail['document_id'] = (int) $document->getId(); - $detail['folder_id'] = (int) $document->getFolderID(); - - $workflowid = $document->getWorkflowId(); - if (is_numeric($workflowid)) - { - $workflow = KTWorkflow::get($workflowid); - $workflowname=(is_null($workflow) || PEAR::isError($workflow))?'* unknown *':$workflow->getName(); - } - else - { - $workflowname='n/a'; + if (!is_null($user) && !PEAR::isError($user)) + { + $username = $user->getName(); + } } - $detail['workflow'] = $workflowname; + $detail['checked_out_by'] = $username; - $stateid = $document->getWorkflowStateId(); - if (is_numeric($stateid)) + // get the checked out date + list($major, $minor, $fix) = explode('.', $default->systemVersion); + if ($major == 3 && $minor >= 5) { - $state = KTWorkflowState::get($stateid); - $workflowstate=(is_null($state) || PEAR::isError($state))?'* unknown *':$state->getName(); + $detail['checked_out_date'] = $document->getCheckedOutDate(); } else { - $workflowstate = 'n/a'; + $detail['checked_out_date'] = $detail['modified_date']; } - $detail['workflow_state']=$workflowstate; - - $userid = $document->getOwnerID(); + if (is_null($detail['checked_out_date'])) $detail['checked_out_date'] = 'n/a'; + // get the modified user + $userid = $document->getModifiedUserId(); + $username='n/a'; if (is_numeric($userid)) { + $username = '* unknown *'; $user = User::get($userid); - $username=(is_null($user) || PEAR::isError($user))?'* unknown *':$user->getName(); - } - else - { - $username = 'n/a'; + if (!is_null($user) && !PEAR::isError($user)) + { + $username = $user->getName(); + } } - $detail['owner'] = $username; - - $detail['is_immutable'] = (bool) $document->getImmutable(); - + $detail['modified_by'] = $detail['updated_by'] = $username; - $userid = $document->getCheckedOutUserID(); + // get the modified date + $detail['updated_date'] = $detail['modified_date'] = $document->getLastModifiedDate(); + // get the owner + $userid = $document->getOwnerID(); + $username='n/a'; if (is_numeric($userid)) { + $username = '* unknown *'; $user = User::get($userid); - $username=(is_null($user) || PEAR::isError($user))?'* unknown *':$user->getName(); - } - else - { - $username = 'n/a'; + if (!is_null($user) && !PEAR::isError($user)) + { + $username = $user->getName(); + } } - $detail['checked_out_by'] = $username; + $detail['owned_by'] = $username; - list($major, $minor, $fix) = explode('.', $default->systemVersion); + // get the version + $detail['version'] = $document->getVersion(); + // check immutability + $detail['is_immutable'] = (bool) $document->getImmutable(); - if ($major == 3 && $minor >= 5) + // check permissions + $detail['permissions'] = 'not available'; + + // get workflow name + $workflowid = $document->getWorkflowId(); + $workflowname='n/a'; + if (is_numeric($workflowid)) { - $detail['checked_out_date'] = $document->getCheckedOutDate(); + $workflow = KTWorkflow::get($workflowid); + if (!is_null($workflow) && !PEAR::isError($workflow)) + { + $workflowname = $workflow->getName(); + } } - else + $detail['workflow'] = $workflowname; + + // get the workflow state + $stateid = $document->getWorkflowStateId(); + $workflowstate = 'n/a'; + if (is_numeric($stateid)) { - $detail['checked_out_date'] = $detail['modified_date']; + $state = KTWorkflowState::get($stateid); + if (!is_null($state) && !PEAR::isError($state)) + { + $workflowstate = $state->getName(); + } } - if (is_null($detail['checked_out_date'])) $detail['checked_out_date'] = 'n/a'; + $detail['workflow_state']=$workflowstate; + // get the full path $detail['full_path'] = $this->ktapi_folder->get_full_path() . '/' . $this->get_title(); + // get mime info + $mimetypeid = $document->getMimeTypeID(); + $detail['mime_type'] =KTMime::getMimeTypeName($mimetypeid); + $detail['mime_icon_path'] =KTMime::getIconPath($mimetypeid); + $detail['mime_display'] =KTMime::getFriendlyNameForString($type); + + // get the storage path + $detail['storage_path'] = $document->getStoragePath(); + return $detail; } diff --git a/ktapi/KTAPIFolder.inc.php b/ktapi/KTAPIFolder.inc.php index 5962c79..c20d588 100644 --- a/ktapi/KTAPIFolder.inc.php +++ b/ktapi/KTAPIFolder.inc.php @@ -367,7 +367,7 @@ class KTAPI_Folder extends KTAPI_FolderItem 'version' => 'n/a', - 'immutable'=> 'n/a', + 'is_immutable'=> 'n/a', 'permissions' => 'n/a', 'workflow'=>'n/a', @@ -490,7 +490,7 @@ class KTAPI_Folder extends KTAPI_FolderItem 'version' => $document->getMajorVersionNumber() . '.' . $document->getMinorVersionNumber(), - 'immutable'=> $document->getImmutable()?'true':'false', + 'is_immutable'=> $document->getImmutable()?'true':'false', 'permissions' => 'n/a', 'workflow'=> $workflow, diff --git a/ktwebservice/webservice.php b/ktwebservice/webservice.php index 28efcd3..03b8381 100644 --- a/ktwebservice/webservice.php +++ b/ktwebservice/webservice.php @@ -183,6 +183,7 @@ class KTWebService 'item_type' => 'string', 'title' => 'string', + 'document_type' => 'string', 'filename' => 'string', 'filesize' => 'string', @@ -199,7 +200,7 @@ class KTWebService 'version' => 'string', - 'immutable'=>'boolean', + 'is_immutable'=>'string', 'permissions' => 'string', 'workflow'=>'string', @@ -258,23 +259,40 @@ class KTWebService array( 'status_code'=>'int', 'message'=>'string', + + 'document_id' => 'int', 'title' => 'string', 'document_type' => 'string', - 'version' => 'string', 'filename' => 'string', - 'created_date' => 'string', + 'filesize' => 'int', + 'folder_id' => 'int', + 'created_by' => 'string', - 'modified_date' => 'string', + 'created_date' => 'string', + + 'checked_out_by'=>'string', + 'checked_out_date'=>'string', + 'modified_by' => 'string', - 'document_id' => 'int', - 'folder_id' => 'int', + 'modified_date' => 'string', + + 'owned_by'=>'string', + + 'version' => 'string', + + 'is_immutable'=>'boolean', + 'permissions' => 'string', + 'workflow' => 'string', 'workflow_state' => 'string', 'full_path' => 'string', - 'owner'=>'string', - 'is_immutable'=>'boolean', - 'checked_out_date'=>'string', - 'checked_out_by'=>'string', + + 'mime_type' => 'string', + 'mime_icon_path' => 'string', + 'mime_display' => 'string', + + 'storage_path' => 'string', + 'metadata' => "{urn:$this->namespace}kt_metadata_fieldsets", 'links' => "{urn:$this->namespace}kt_linked_documents", 'transitions' => "{urn:$this->namespace}kt_workflow_transitions",