Commit c24a2736f483671bce9f61fb96126844445ca4ef

Authored by Megan Watson
1 parent 32d2b2b4

KTS-3777

"CLONE -Permissions of a document can be inconsistent with the permissions of the folder(SUP-1080)"
Fixed. A copy now checks if the permissions were inherited and inherits the new parent folder permissions.

Committed by: Megan Watson
Reviewed by: Conrad Vermeulen



git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@9493 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/foldermanagement/folderutil.inc.php
... ... @@ -200,6 +200,9 @@ class KTFolderUtil {
200 200 return $res;
201 201 }
202 202  
  203 + // Regenerate the folder object - ensure the updated information is taken into account
  204 + $oFolder = Folder::get($oFolder->getID());
  205 +
203 206 $res = $oStorage->moveFolder($oFolder, $oNewParentFolder);
204 207 if (PEAR::isError($res)) {
205 208 return $res;
... ... @@ -450,6 +453,19 @@ class KTFolderUtil {
450 453 return PEAR::raiseError(_kt('You are not allowed to create folders in the destination.'));
451 454 }
452 455  
  456 + // Check if the source folder inherits its permissions
  457 + // Get source PO id and its parent PO id
  458 + $iSrcPoId = $oSrcFolder->getPermissionObjectID();
  459 + $oSrcParent = Folder::get($oSrcFolder->getParentID());
  460 + $iSrcParentPoId = $srcParent->getPermissionObjectID();
  461 +
  462 + // If the folder defines its own permissions then we leave it
  463 + // If the source folder inherits permissions we must change it to inherit from the new parent folder
  464 + $bInheritPermissions = false;
  465 + if($iSrcPoId == $iSrcParentPoId){
  466 + $bInheritPermissions = true;
  467 + }
  468 +
453 469 $aFolderIds = array(); // of oFolder
454 470 $aDocuments = array(); // of oDocument
455 471 $aFailedDocuments = array(); // of String
... ... @@ -592,6 +608,14 @@ class KTFolderUtil {
592 608 }
593 609 }
594 610  
  611 + // If the folder inherits its permissions then we set it to inherit from the new parent folder and update permissions
  612 + if($bInheritPermissions){
  613 + $aOptions = array(
  614 + 'evenifnotowner' => true, // Inherit from parent folder, even though not permission owner
  615 + );
  616 + KTPermissionUtil::inheritPermissionObject($oNewBaseFolder, $aOptions);
  617 + }
  618 +
595 619 // and store
596 620 DBUtil::commit();
597 621  
... ...