Commit 86bcfdcdee1c031d9f7d64682dc8ec5188636eff

Authored by Megan Watson
1 parent 52e8564b

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.

Committed by: Megan Watson
Reviewed by: Conrad Vermeulen



git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7620 c91229c3-7414-0410-bfa2-8a42b809f60b
plugins/ktcore/KTBulkActions.php
@@ -725,7 +725,13 @@ class KTBrowseBulkCheckoutAction extends KTBulkAction { @@ -725,7 +725,13 @@ class KTBrowseBulkCheckoutAction extends KTBulkAction {
725 function check_entity($oEntity) { 725 function check_entity($oEntity) {
726 if(is_a($oEntity, 'Document')) { 726 if(is_a($oEntity, 'Document')) {
727 if ($oEntity->getIsCheckedOut()) { 727 if ($oEntity->getIsCheckedOut()) {
728 - return PEAR::raiseError(_kt('Document is already checked out')); 728 + $checkedOutUser = $oEntity->getCheckedOutUserID();
  729 + $sUserId = $_SESSION['userID'];
  730 +
  731 + if($checkedOutUser != $sUserId){
  732 + $oCheckedOutUser = User::get($checkedOutUser);
  733 + return PEAR::raiseError($oEntity->getName().': '._kt('Document has already been checked out by ').$oCheckedOutUser->getName());
  734 + }
729 } 735 }
730 }else if(!is_a($oEntity, 'Folder')) { 736 }else if(!is_a($oEntity, 'Folder')) {
731 return PEAR::raiseError(_kt('Document cannot be checked out')); 737 return PEAR::raiseError(_kt('Document cannot be checked out'));
@@ -921,12 +927,29 @@ class KTBrowseBulkCheckoutAction extends KTBulkAction { @@ -921,12 +927,29 @@ class KTBrowseBulkCheckoutAction extends KTBulkAction {
921 foreach($aDocuments as $sDocId){ 927 foreach($aDocuments as $sDocId){
922 $oDocument = Document::get($sDocId); 928 $oDocument = Document::get($sDocId);
923 if(PEAR::isError($oDocument)) { 929 if(PEAR::isError($oDocument)) {
924 - return PEAR::raiseError(_kt('Folder documents cannot be checked out')); 930 + // add message, skip document and continue
  931 + $this->addErrorMessage($oDocument->getName().': '.$oDocument->getMessage());
  932 + continue;
925 } 933 }
926 934
  935 + // Checkout document - if it is already checked out, check the owner.
  936 + // If the current user is the owner, then include to the download, otherwise ignore.
927 $res = KTDocumentUtil::checkout($oDocument, $sReason, $this->oUser); 937 $res = KTDocumentUtil::checkout($oDocument, $sReason, $this->oUser);
928 if(PEAR::isError($res)) { 938 if(PEAR::isError($res)) {
929 - return PEAR::raiseError($oDocument->getName().': '.$res->getMessage()); 939 + if($oDocument->getIsCheckedOut()){
  940 + $checkedOutUser = $oDocument->getCheckedOutUserID();
  941 + $sUserId = $_SESSION['userID'];
  942 +
  943 + if($checkedOutUser != $sUserId){
  944 + $oCheckedOutUser = User::get($checkedOutUser);
  945 + $this->addErrorMessage($oDocument->getName().': '._kt('Document has already been checked out by ').$oCheckedOutUser->getName());
  946 + continue;
  947 + }
  948 + }
  949 + if($checkedOutUser != $sUserId){
  950 + $this->addErrorMessage($oDocument->getName().': '.$res->getMessage());
  951 + continue;
  952 + }
930 } 953 }
931 954
932 // Add document to the zip file 955 // Add document to the zip file