Commit 49788932002f235962e3de0ffeb31b4562931dff
1 parent
6482d2aa
WSA-93
"Add integration/oem no so that integrators may associate a custom document reference" Implemented. Committed By: Conrad Vermeulen Reviewed By: Megan Watson git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7858 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
48 additions
and
1 deletions
ktapi/KTAPIFolder.inc.php
| ... | ... | @@ -121,6 +121,7 @@ class KTAPI_Folder extends KTAPI_FolderItem |
| 121 | 121 | */ |
| 122 | 122 | function get_detail() |
| 123 | 123 | { |
| 124 | + $this->clearCache(); | |
| 124 | 125 | $detail = array( |
| 125 | 126 | 'id'=>(int) $this->folderid, |
| 126 | 127 | 'folder_name'=>$this->get_folder_name(), |
| ... | ... | @@ -131,6 +132,19 @@ class KTAPI_Folder extends KTAPI_FolderItem |
| 131 | 132 | return $detail; |
| 132 | 133 | } |
| 133 | 134 | |
| 135 | + function clearCache() | |
| 136 | + { | |
| 137 | + // TODO: we should only clear the cache for the document we are working on | |
| 138 | + // this is a quick fix but not optimal!! | |
| 139 | + | |
| 140 | + $cache = KTCache::getSingleton(); | |
| 141 | + | |
| 142 | + $cache->remove('Folder/id', $this->folderid); | |
| 143 | + | |
| 144 | + $this->folder = &Folder::get($this->folderid); | |
| 145 | + } | |
| 146 | + | |
| 147 | + | |
| 134 | 148 | function get_parent_folder_id() |
| 135 | 149 | { |
| 136 | 150 | return (int) $this->folder->getParentID(); |
| ... | ... | @@ -479,13 +493,16 @@ class KTAPI_Folder extends KTAPI_FolderItem |
| 479 | 493 | $docTypeId = $document->getDocumentTypeID(); |
| 480 | 494 | $documentType = DocumentType::get($docTypeId); |
| 481 | 495 | |
| 496 | + $oemDocumentNo = $document->getOemNo(); | |
| 497 | + if (empty($oemDocumentNo)) $oemDocumentNo = 'n/a'; | |
| 498 | + | |
| 482 | 499 | |
| 483 | 500 | $contents[] = array( |
| 484 | 501 | 'id' => (int) $document->getId(), |
| 485 | 502 | 'item_type' => 'D', |
| 486 | 503 | |
| 487 | 504 | 'custom_document_no'=>'n/a', |
| 488 | - 'oem_document_no'=>'n/a', | |
| 505 | + 'oem_document_no'=>$oemDocumentNo, | |
| 489 | 506 | |
| 490 | 507 | 'title' => $document->getName(), |
| 491 | 508 | 'document_type'=>$documentType->getName(), | ... | ... |
ktapi/ktapi.inc.php
| ... | ... | @@ -179,6 +179,36 @@ class KTAPI |
| 179 | 179 | return $user; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | + /** | |
| 183 | + * Search for documents matching the oem_no. | |
| 184 | + * | |
| 185 | + * Note that oem_no is associated with a document and not with version of file (document content). | |
| 186 | + * oem_no is set on a document using document::update_sysdata(). | |
| 187 | + * | |
| 188 | + * @param string $oem_no | |
| 189 | + * @param boolean idsOnly Defaults to true | |
| 190 | + * @return array | |
| 191 | + */ | |
| 192 | + function get_documents_by_oem_no($oem_no, $idsOnly=true) | |
| 193 | + { | |
| 194 | + $sql = array("SELECT id FROM documents WHERE oem_no=?",$oem_no); | |
| 195 | + $rows = DBUtil::getResultArray($sql); | |
| 196 | + if (is_null($rows) || PEAR::isError($rows)) | |
| 197 | + { | |
| 198 | + return new KTAPI_Error(KTAPI_ERROR_INTERNAL_ERROR, $rows); | |
| 199 | + } | |
| 200 | + | |
| 201 | + $result = array(); | |
| 202 | + foreach($rows as $row) | |
| 203 | + { | |
| 204 | + $documentid = $row['id']; | |
| 205 | + | |
| 206 | + $result[] = $idsOnly?$documentid:KTAPI_Document::get($this, $documentid); | |
| 207 | + } | |
| 208 | + | |
| 209 | + return $result; | |
| 210 | + } | |
| 211 | + | |
| 182 | 212 | /** |
| 183 | 213 | * This returns a session object based on a session string. |
| 184 | 214 | * | ... | ... |