Commit 86e9dd1aca93025ba76fa2de53d871e2ce513d61
1 parent
007187de
Story ID:2678491
"GUID not working in Office 2003 Add-in port" Committed by: Martin Kirsten Reviewed by: Megan Watson
Showing
2 changed files
with
28 additions
and
9 deletions
ktapi/KTAPIDocument.inc.php
| ... | ... | @@ -2141,6 +2141,18 @@ class KTAPI_Document extends KTAPI_FolderItem |
| 2141 | 2141 | } |
| 2142 | 2142 | |
| 2143 | 2143 | /** |
| 2144 | + * Gets the content version id of the document | |
| 2145 | + * | |
| 2146 | + * @author KnowledgeTree Team | |
| 2147 | + * @access public | |
| 2148 | + * @return integer the content version id | |
| 2149 | + */ | |
| 2150 | + function get_content_version() | |
| 2151 | + { | |
| 2152 | + return $this->document->getContentVersionId(); | |
| 2153 | + } | |
| 2154 | + | |
| 2155 | + /** | |
| 2144 | 2156 | * Gets the url which can be used to download the document. |
| 2145 | 2157 | * |
| 2146 | 2158 | * @param int $version Not implemented. The content version of the document | ... | ... |
ktapi/ktapi.inc.php
| ... | ... | @@ -4735,21 +4735,28 @@ class KTAPI |
| 4735 | 4735 | } |
| 4736 | 4736 | return $response; |
| 4737 | 4737 | } |
| 4738 | - | |
| 4738 | + | |
| 4739 | + /** | |
| 4740 | + * Method to check whether content version is the latest for a specific document | |
| 4741 | + * | |
| 4742 | + * @author KnowledgeTree Team | |
| 4743 | + * @access public | |
| 4744 | + * @param string $documentID The id of the document | |
| 4745 | + * @param string $contentID The id of the content version to check | |
| 4746 | + * @return bool $response The formatted response array | |
| 4747 | + */ | |
| 4739 | 4748 | public function is_latest_version($documentID, $contentID) |
| 4740 | - { | |
| 4741 | - $sql = 'SELECT COUNT(document_content_version.id) AS newdocumentcount | |
| 4742 | - FROM document_content_version | |
| 4743 | - WHERE document_content_version.document_id ="'.$documentID.'" AND | |
| 4744 | - document_content_version.id > "'.$contentID.'"'; | |
| 4749 | + { | |
| 4750 | + $document = $this->get_document_by_id($documentID); | |
| 4745 | 4751 | |
| 4746 | - $row = DBUtil::getOneResult($sql); | |
| 4747 | - $row = (int)$row['newdocumentcount']; | |
| 4752 | + $maxcontentID = $document->get_content_version(); | |
| 4748 | 4753 | |
| 4749 | - if ($row > 0) { | |
| 4754 | + if ($maxcontentID > $contentID) { | |
| 4750 | 4755 | $response['is_latest'] = 'FALSE'; |
| 4756 | + $response['max_contentID'] = $maxcontentID; | |
| 4751 | 4757 | } else { |
| 4752 | 4758 | $response['is_latest'] = 'TRUE'; |
| 4759 | + $response['max_contentID'] = $contentID; | |
| 4753 | 4760 | } |
| 4754 | 4761 | |
| 4755 | 4762 | $response['status_code'] = 0; | ... | ... |