Commit 5f56a01bf247a3c6e55efaa54d3caae2bb9fa561
1 parent
3c893bec
- ensure that dynamic conditions are copied with other permissions
- fix for KTS-1186: inherit permissions always shows. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5741 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
5 changed files
with
43 additions
and
7 deletions
lib/permissions/permissionutil.inc.php
| ... | ... | @@ -476,6 +476,18 @@ class KTPermissionUtil { |
| 476 | 476 | $oDocumentOrFolder->setPermissionObjectID($oNewPO->getID()); |
| 477 | 477 | $oDocumentOrFolder->update(); |
| 478 | 478 | |
| 479 | + // copy any dynamic conditions | |
| 480 | + $aDPO = KTPermissionDynamicCondition::getByPermissionObject($oOrigPO); | |
| 481 | + foreach ($aDPO as $oOrigDC) { | |
| 482 | + $oNewDC = KTPermissionDynamicCondition::createFromArray(array( | |
| 483 | + 'permissionobjectid' => $oNewPO->getId(), | |
| 484 | + 'groupid' => $oOrigDC->getGroupId(), | |
| 485 | + 'conditionid' => $oOrigDC->getConditionId(), | |
| 486 | + )); | |
| 487 | + | |
| 488 | + $oNewDC->saveAssignment($oOrigDC->getAssignment()); | |
| 489 | + } | |
| 490 | + | |
| 479 | 491 | if (!is_a($oDocumentOrFolder, 'Folder')) { |
| 480 | 492 | KTPermissionUtil::updatePermissionLookup($oDocumentOrFolder); |
| 481 | 493 | return; | ... | ... |
plugins/ktcore/folder/Permissions.php
| ... | ... | @@ -104,6 +104,10 @@ class KTFolderPermissionsAction extends KTFolderAction { |
| 104 | 104 | $iInheritedFolderId = $oInherited->getId(); |
| 105 | 105 | $sInherited = join(" » ", $oInherited->getPathArray()); |
| 106 | 106 | } |
| 107 | + // only allow inheritance if not inherited, -and- folders is editable | |
| 108 | + $bInheritable = $bEdit && ($oInherited->getId() !== $this->oFolder->getId()); | |
| 109 | + // only allow edit if the folder is editable. | |
| 110 | + $bEdit = $bEdit && ($oInherited->getId() == $this->oFolder->getId()); | |
| 107 | 111 | |
| 108 | 112 | $aConditions = array(); |
| 109 | 113 | $aDynConditions = KTPermissionDynamicCondition::getByPermissionObject($oPO); |
| ... | ... | @@ -139,6 +143,7 @@ class KTFolderPermissionsAction extends KTFolderAction { |
| 139 | 143 | "aMapPermissionRole" => $aMapPermissionRole, |
| 140 | 144 | "aMapPermissionUser" => $aMapPermissionUser, |
| 141 | 145 | "edit" => $bEdit, |
| 146 | + 'inheritable' => $bInheritable, | |
| 142 | 147 | "inherited" => $sInherited, |
| 143 | 148 | 'foldername' => $this->oFolder->getName(), |
| 144 | 149 | 'conditions' => $aConditions, |
| ... | ... | @@ -247,10 +252,17 @@ class KTFolderPermissionsAction extends KTFolderAction { |
| 247 | 252 | $this->oValidator->userHasPermissionOnItem($this->oUser, $this->_sEditShowPermission, $this->oFolder, $aOptions); |
| 248 | 253 | } |
| 249 | 254 | |
| 250 | - // copy permissions if they were inherited | |
| 255 | + // copy permissions if they were inherited | |
| 251 | 256 | $oInherited = KTPermissionUtil::findRootObjectForPermissionObject($oPO); |
| 252 | 257 | if ($oInherited->getId() !== $this->oFolder->getId()) { |
| 253 | - $this->_copyPermissions(); | |
| 258 | + $override = KTUtil::arrayGet($_REQUEST, 'override', false); | |
| 259 | + if (empty($override)) { | |
| 260 | + $this->errorRedirectToMain(_kt("This folder does not override its permissions"), sprintf("fFolderId=%d", $this->oFolder->getId())); | |
| 261 | + } | |
| 262 | + $this->startTransaction(); | |
| 263 | + $this->_copyPermissions(); | |
| 264 | + $this->commitTransaction(); | |
| 265 | + $oPO = KTPermissionObject::get($this->oFolder->getPermissionObjectId()); | |
| 254 | 266 | } |
| 255 | 267 | |
| 256 | 268 | |
| ... | ... | @@ -475,7 +487,7 @@ class KTFolderPermissionsAction extends KTFolderAction { |
| 475 | 487 | $this->oValidator->notErrorFalse($oTransaction, $aOptions); |
| 476 | 488 | |
| 477 | 489 | KTPermissionUtil::inheritPermissionObject($this->oFolder); |
| 478 | - return $this->successRedirectTo('edit', _kt('Permissions updated'), | |
| 490 | + return $this->successRedirectTo('main', _kt('Permissions updated'), | |
| 479 | 491 | array('fFolderId' => $this->oFolder->getId())); |
| 480 | 492 | } |
| 481 | 493 | ... | ... |
templates/ktcore/folder/permissions.smarty
| ... | ... | @@ -20,7 +20,6 @@ |
| 20 | 20 | <a class="ktActionLink ktDelete" |
| 21 | 21 | kt:deleteMessage="Are you sure you wish to reinstate inherited permissions?" |
| 22 | 22 | href="{addQS}action=inheritPermissions&fFolderId={$iFolderId}{/addQS}">{i18n}Inherit permissions{/i18n}</a> |
| 23 | -</span> | |
| 24 | 23 | </div> |
| 25 | 24 | {/if} |
| 26 | 25 | ... | ... |
templates/ktcore/folder/resolved_permissions_user.smarty
| ... | ... | @@ -12,8 +12,12 @@ this folder.{/i18n}</p> |
| 12 | 12 | <div class="ktInfo"><p>{i18n}No users have permissions on this item.{/i18n}</p></div> |
| 13 | 13 | {else} |
| 14 | 14 | |
| 15 | -<p>{i18n}Manage security{/i18n}: <a href="{addQS}fFolderId={$iFolderId}{/addQS}">{i18n}View permissions overview{/i18n}</a> | |
| 16 | -| <a href="{addQS}action=edit&fFolderId={$oFolder->getId()}{/addQS}">{i18n}Edit permissions{/i18n}</a></p> | |
| 15 | +{if $edit} | |
| 16 | +{i18n}Manage security{/i18n}: <a href="{addQS}action=edit&fFolderId={$oFolder->getId()}{/addQS}">{i18n}Edit permissions{/i18n}</a> | |
| 17 | +| <a href="{addQS}fFolderId={$oFolder->getId()}{/addQS}">{i18n}View permissions overview{/i18n}</a> | |
| 18 | +{else} | |
| 19 | +{i18n}Manage security{/i18n}: <a href="{addQS}fFolderId={$oFolder->getId()}{/addQS}">{i18n}View permissions overview{/i18n}</a> | |
| 20 | +{/if} | |
| 17 | 21 | |
| 18 | 22 | <table class="kt_collection narrow" cellspacing="0" cellpadding="0" border="0"> |
| 19 | 23 | <thead> | ... | ... |
templates/ktcore/folder/view_permissions.smarty
| ... | ... | @@ -7,12 +7,21 @@ assigned are shown.{/i18n}</p> |
| 7 | 7 | {if $edit} |
| 8 | 8 | {i18n}Manage security{/i18n}: <a href="{addQS}action=edit&fFolderId={$oFolder->getId()}{/addQS}">{i18n}Edit permissions{/i18n}</a> |
| 9 | 9 | | <a href="{addQS}action=resolved_users&fFolderId={$oFolder->getId()}{/addQS}">{i18n}View resolved permissions for user{/i18n}</a> |
| 10 | +{else} | |
| 11 | +{i18n}Manage security{/i18n}: <a href="{addQS}action=resolved_users&fFolderId={$oFolder->getId()}{/addQS}">{i18n}View resolved permissions for user{/i18n}</a> | |
| 10 | 12 | {/if} |
| 11 | 13 | |
| 14 | + | |
| 12 | 15 | {if $iFolderId != 1} |
| 13 | 16 | <div class="ktInfo"> |
| 14 | 17 | { if $inherited } |
| 15 | -<p>{i18n arg_permission_source=$inherited}This folder <strong>inherits</strong> its permissions from #permission_source#.{/i18n}</p> | |
| 18 | +<p>{i18n arg_permission_source=$inherited}This folder <strong>inherits</strong> its permissions from #permission_source#.{/i18n} | |
| 19 | +{if $inheritable} | |
| 20 | +<a class="ktActionLink ktDelete" | |
| 21 | + kt:deleteMessage="Are you sure you wish to override the permissions?" | |
| 22 | + href="{addQS}action=edit&fFolderId={$oFolder->getId()}&override=1{/addQS}">{i18n}Override permissions{/i18n}</a> | |
| 23 | +{/if} | |
| 24 | +</p> | |
| 16 | 25 | { else } |
| 17 | 26 | <p>{i18n}This folder defines its own permissions.{/i18n}</p> |
| 18 | 27 | { /if } | ... | ... |