From 86bcfdcdee1c031d9f7d64682dc8ec5188636eff Mon Sep 17 00:00:00 2001 From: Megan Watson Date: Thu, 1 Nov 2007 12:39:05 +0000 Subject: [PATCH] KTS-2624 "Linux: FedoraCore5: Attempting to use the bulk action 'Checkout' on folders results in an empty zip being created." Fixed. Changed the check on checkedout documents to add an error message and not return out of the function. --- plugins/ktcore/KTBulkActions.php | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/plugins/ktcore/KTBulkActions.php b/plugins/ktcore/KTBulkActions.php index dfc21dc..f6fe09a 100644 --- a/plugins/ktcore/KTBulkActions.php +++ b/plugins/ktcore/KTBulkActions.php @@ -725,7 +725,13 @@ class KTBrowseBulkCheckoutAction extends KTBulkAction { function check_entity($oEntity) { if(is_a($oEntity, 'Document')) { if ($oEntity->getIsCheckedOut()) { - return PEAR::raiseError(_kt('Document is already checked out')); + $checkedOutUser = $oEntity->getCheckedOutUserID(); + $sUserId = $_SESSION['userID']; + + if($checkedOutUser != $sUserId){ + $oCheckedOutUser = User::get($checkedOutUser); + return PEAR::raiseError($oEntity->getName().': '._kt('Document has already been checked out by ').$oCheckedOutUser->getName()); + } } }else if(!is_a($oEntity, 'Folder')) { return PEAR::raiseError(_kt('Document cannot be checked out')); @@ -921,12 +927,29 @@ class KTBrowseBulkCheckoutAction extends KTBulkAction { foreach($aDocuments as $sDocId){ $oDocument = Document::get($sDocId); if(PEAR::isError($oDocument)) { - return PEAR::raiseError(_kt('Folder documents cannot be checked out')); + // add message, skip document and continue + $this->addErrorMessage($oDocument->getName().': '.$oDocument->getMessage()); + continue; } + // Checkout document - if it is already checked out, check the owner. + // If the current user is the owner, then include to the download, otherwise ignore. $res = KTDocumentUtil::checkout($oDocument, $sReason, $this->oUser); if(PEAR::isError($res)) { - return PEAR::raiseError($oDocument->getName().': '.$res->getMessage()); + if($oDocument->getIsCheckedOut()){ + $checkedOutUser = $oDocument->getCheckedOutUserID(); + $sUserId = $_SESSION['userID']; + + if($checkedOutUser != $sUserId){ + $oCheckedOutUser = User::get($checkedOutUser); + $this->addErrorMessage($oDocument->getName().': '._kt('Document has already been checked out by ').$oCheckedOutUser->getName()); + continue; + } + } + if($checkedOutUser != $sUserId){ + $this->addErrorMessage($oDocument->getName().': '.$res->getMessage()); + continue; + } } // Add document to the zip file -- libgit2 0.21.4