take out duplicate getLatestContent()

This commit is contained in:
Uwe Steinmann 2017-10-27 16:47:50 +02:00
parent 68ccb13a72
commit 3d6dcbd181

View File

@ -1957,49 +1957,6 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
return $this->_latestContent; return $this->_latestContent;
} /* }}} */ } /* }}} */
/**
* Get the latest version of document
*
* This function returns the latest accessible version of a document.
* If content access has been restricted by setting
* {@link SeedDMS_Core_DMS::noReadForStatus} the function will go
* backwards in history until an accessible version is found. If none
* is found null will be returned.
* Access rights based on the document status are calculated for the
* currently logged in user.
*
* @return object object of class {@link SeedDMS_Core_DocumentContent}
*/
function getLatestContent() { /* {{{ */
if (!$this->_latestContent) {
$db = $this->_dms->getDB();
$queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` = ".$this->_id." ORDER BY `version` DESC";
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && !$res)
return false;
$classname = $this->_dms->getClassname('documentcontent');
$user = $this->_dms->getLoggedInUser();
foreach ($resArr as $row) {
if (!$this->_latestContent) {
$content = new $classname($row["id"], $this, $row["version"], $row["comment"], $row["date"], $row["createdBy"], $row["dir"], $row["orgFileName"], $row["fileType"], $row["mimeType"], $row['fileSize'], $row['checksum']);
if($user) {
/* If the user may even write the document, then also allow to see all content.
* This is needed because the user could upload a new version
*/
if($content->getAccessMode($user) >= M_READ) {
$this->_latestContent = $content;
}
} else {
$this->_latestContent = $content;
}
}
}
}
return $this->_latestContent;
} /* }}} */
/** /**
* Remove version of document * Remove version of document
* *