SeedDMS_Core_Document::getCheckOutInfo() returns all checkout versions

This commit is contained in:
Uwe Steinmann 2020-11-24 08:04:44 +01:00
parent 858c449489
commit 152c943d5a
2 changed files with 25 additions and 13 deletions

View File

@ -1020,7 +1020,10 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
/** /**
* Get checkout info for document * Get checkout info for document
* *
* @return array/boolean record from table tblDocumentCheckOuts or false * This returns the checkouts for a document. There could be several checkouts
* for one document, but usually there is just one.
*
* @return array/boolean records from table tblDocumentCheckOuts or false
* in case of an error. * in case of an error.
*/ */
function getCheckOutInfo() { /* {{{ */ function getCheckOutInfo() { /* {{{ */
@ -1033,7 +1036,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
return false; return false;
} else { } else {
// A check out has been identified for this document. // A check out has been identified for this document.
return $resArr[0]; return $resArr;
} }
} /* }}} */ } /* }}} */
@ -1114,7 +1117,10 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
function checkIn($comment, $user, $reviewers=array(), $approvers=array(), $version=0, $attributes=array(), $workflow=null, $initstate=S_RELEASED) { /* {{{ */ function checkIn($comment, $user, $reviewers=array(), $approvers=array(), $version=0, $attributes=array(), $workflow=null, $initstate=S_RELEASED) { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
$info = self::getCheckOutInfo(); $infos = self::getCheckOutInfo();
if(!$infos)
return false;
$info = $infos[0];
$lc = self::getLatestContent(); $lc = self::getLatestContent();
/* If file doesn't exist anymore, then just remove the record from the db */ /* If file doesn't exist anymore, then just remove the record from the db */
@ -1168,12 +1174,14 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
function cancelCheckOut() { /* {{{ */ function cancelCheckOut() { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
$info = self::getCheckOutInfo(); $infos = self::getCheckOutInfo();
if($info) { if($infos) {
SeedDMS_Core_File::removeFile($info['filename']); $info = $infos[0];
$queryStr = "DELETE FROM `tblDocumentCheckOuts` WHERE `document` = ".$this->_id; $queryStr = "DELETE FROM `tblDocumentCheckOuts` WHERE `document` = ".$this->_id;
$db->getResult($queryStr); if (!$db->getResult($queryStr))
return false;
SeedDMS_Core_File::removeFile($info['filename']);
} }
return true; return true;
@ -1193,10 +1201,11 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
* 0=The checked out file is modified and check in will create a new version * 0=The checked out file is modified and check in will create a new version
*/ */
function checkOutStatus() { /* {{{ */ function checkOutStatus() { /* {{{ */
$info = self::getCheckOutInfo(); $infos = self::getCheckOutInfo();
if(!$info) if(!$infos)
return 4; return 4;
$info = $infos[0];
$lc = self::getLatestContent(); $lc = self::getLatestContent();
/* If file doesn't exist anymore, then just remove the record from the db */ /* If file doesn't exist anymore, then just remove the record from the db */

View File

@ -194,17 +194,20 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
$txt = $this->callHook('checkOutInfo', $document); $txt = $this->callHook('checkOutInfo', $document);
if(is_string($txt)) { if(is_string($txt)) {
echo $txt; echo $txt;
} elseif($info = $document->getCheckOutInfo()) { } elseif($infos = $document->getCheckOutInfo()) {
echo "<div class=\"alert alert-info\">";
$session = $this->params['session']; $session = $this->params['session'];
if($session->getSu()) { if($session->getSu()) {
$origuser = $dms->getUser($session->getUser()); $origuser = $dms->getUser($session->getUser());
$checkoutpath = sprintf($checkoutdir, preg_replace('/[^A-Za-z0-9_-]/', '', $origuser->getLogin())); $checkoutpath = sprintf($checkoutdir, preg_replace('/[^A-Za-z0-9_-]/', '', $origuser->getLogin()));
} else { } else {
$origuser = $user;
$checkoutpath = sprintf($checkoutdir, preg_replace('/[^A-Za-z0-9_-]/', '', $user->getLogin())); $checkoutpath = sprintf($checkoutdir, preg_replace('/[^A-Za-z0-9_-]/', '', $user->getLogin()));
} }
echo "<a href=\"file://".$info['filename']."\">".getMLText('copied_to_checkout_as', array('date'=>$info['date'], 'filename'=>substr($info['filename'], strlen($checkoutpath)+1)))."</a>"; foreach($infos as $info) {
echo "</div>"; echo "<div class=\"alert alert-info\">";
echo "<a href=\"file://".$info['filename']."\">".getMLText('copied_to_checkout_as', array('date'=>$info['date'], 'filename'=>substr($info['filename'], strlen($checkoutpath)+1)))."</a>";
echo "</div>";
}
} }
$this->contentContainerStart(); $this->contentContainerStart();
$txt = $this->callHook('preDocumentInfos', $document); $txt = $this->callHook('preDocumentInfos', $document);