Commit efcfc23674492d5e6e41e2ea0e05b81feb9639b2
1 parent
755aa6db
- not all documents have states, so don't necessarily fail. (permissionutil)
- if we only have 1 version, don't offer to compare with other versions (KTS-187) git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4812 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
24 additions
and
16 deletions
lib/permissions/permissionutil.inc.php
| ... | ... | @@ -249,21 +249,23 @@ class KTPermissionUtil { |
| 249 | 249 | |
| 250 | 250 | if (!is_a($oFolderOrDocument, 'Folder')) { |
| 251 | 251 | $oState = KTWorkflowUtil::getWorkflowStateForDocument($oFolderOrDocument); |
| 252 | - $aWorkflowStatePermissionAssignments = KTWorkflowStatePermissionAssignment::getByState($oState); | |
| 253 | - foreach ($aWorkflowStatePermissionAssignments as $oAssignment) { | |
| 254 | - $iPermissionId = $oAssignment->getPermissionId(); | |
| 255 | - $iPermissionDescriptorId = $oAssignment->getDescriptorId(); | |
| 256 | - | |
| 257 | - $oPD = KTPermissionDescriptor::get($iPermissionDescriptorId); | |
| 258 | - $aGroupIDs = $oPD->getGroups(); | |
| 259 | - $aUserIDs = array(); | |
| 260 | - $aRoleIDs = $oPD->getRoles(); | |
| 261 | - $aAllowed = array( | |
| 262 | - "group" => $aGroupIDs, | |
| 263 | - "user" => $aUserIDs, | |
| 264 | - "role" => $aRoleIDs, | |
| 265 | - ); | |
| 266 | - $aMapPermAllowed[$iPermissionId] = $aAllowed; | |
| 252 | + if (!(PEAR::isError($oState) || is_null($oState) || ($oState == false))) { | |
| 253 | + $aWorkflowStatePermissionAssignments = KTWorkflowStatePermissionAssignment::getByState($oState); | |
| 254 | + foreach ($aWorkflowStatePermissionAssignments as $oAssignment) { | |
| 255 | + $iPermissionId = $oAssignment->getPermissionId(); | |
| 256 | + $iPermissionDescriptorId = $oAssignment->getDescriptorId(); | |
| 257 | + | |
| 258 | + $oPD = KTPermissionDescriptor::get($iPermissionDescriptorId); | |
| 259 | + $aGroupIDs = $oPD->getGroups(); | |
| 260 | + $aUserIDs = array(); | |
| 261 | + $aRoleIDs = $oPD->getRoles(); | |
| 262 | + $aAllowed = array( | |
| 263 | + "group" => $aGroupIDs, | |
| 264 | + "user" => $aUserIDs, | |
| 265 | + "role" => $aRoleIDs, | |
| 266 | + ); | |
| 267 | + $aMapPermAllowed[$iPermissionId] = $aAllowed; | |
| 268 | + } | |
| 267 | 269 | } |
| 268 | 270 | } |
| 269 | 271 | ... | ... |
templates/kt3/document/metadata_history.smarty
| ... | ... | @@ -30,7 +30,13 @@ |
| 30 | 30 | <a href="{addQS}action=viewComparison&fDocumentId={$document->getId()}&fBaseVersion={$oVersion->getMetadataVersionId()}&fComparisonVersion={$oVersion->getCurrentMetadataVersionId()}{/addQS}">{i18n}compare with current{/i18n}</a></td> |
| 31 | 31 | {/if} |
| 32 | 32 | </td> |
| 33 | - <td><a href="{addQS}action=startComparison&fDocumentId={$document->getId()}&fComparisonVersion={$oVersion->getCurrentMetadataVersionId()}{/addQS}">{i18n}compare with other version{/i18n}</a></td> | |
| 33 | + <td> | |
| 34 | + {if (count($versions) == 1)} | |
| 35 | + — | |
| 36 | + {else} | |
| 37 | + <a href="{addQS}action=startComparison&fDocumentId={$document->getId()}&fComparisonVersion={$oVersion->getCurrentMetadataVersionId()}{/addQS}">{i18n}compare with other version{/i18n}</a> | |
| 38 | + {/if} | |
| 39 | + </td> | |
| 34 | 40 | </tr> |
| 35 | 41 | {/foreach} |
| 36 | 42 | </tbody> | ... | ... |