Commit 1486cdc83837916361d04a7727f56a02cc390e42
1 parent
8626681e
Allow document actions to declare whether they are mutators (ie, they
change an aspect of the document), and whether changes should be available to users in admin mode even if the document is immutable. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5671 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
3 changed files
with
23 additions
and
2 deletions
lib/actions/documentaction.inc.php
| ... | ... | @@ -42,6 +42,9 @@ class KTDocumentAction extends KTStandardDispatcher { |
| 42 | 42 | |
| 43 | 43 | var $sSection = "view_details"; |
| 44 | 44 | |
| 45 | + var $_bMutator = false; | |
| 46 | + var $_bMutationAllowedByAdmin = true; | |
| 47 | + | |
| 45 | 48 | function KTDocumentAction($oDocument = null, $oUser = null, $oPlugin = null) { |
| 46 | 49 | $this->oDocument =& $oDocument; |
| 47 | 50 | $this->oUser =& $oUser; |
| ... | ... | @@ -64,7 +67,18 @@ class KTDocumentAction extends KTStandardDispatcher { |
| 64 | 67 | function _show() { |
| 65 | 68 | if (is_null($this->_sShowPermission)) { |
| 66 | 69 | return true; |
| 67 | - } | |
| 70 | + } | |
| 71 | + $oFolder = Folder::get($this->oDocument->getFolderId()); | |
| 72 | + | |
| 73 | + if ($this->_bMutator && $this->oDocument->getImmutable()) { | |
| 74 | + if ($this->_bMutationAllowedByAdmin === true) { | |
| 75 | + if (!KTBrowseUtil::inAdminMode($this->oUser, $oFolder)) { | |
| 76 | + return false; | |
| 77 | + } | |
| 78 | + } else { | |
| 79 | + return false; | |
| 80 | + } | |
| 81 | + } | |
| 68 | 82 | |
| 69 | 83 | if ($this->_bAdminAlwaysAvailable) { |
| 70 | 84 | if (Permission::userIsSystemAdministrator($this->oUser->getId())) { |
| ... | ... | @@ -86,7 +100,6 @@ class KTDocumentAction extends KTStandardDispatcher { |
| 86 | 100 | if (($status == DELETED) || ($status == ARCHIVED)) { return false; } |
| 87 | 101 | if ($this->bAllowInAdminMode) { |
| 88 | 102 | // check if this user is in admin mode |
| 89 | - $oFolder = Folder::get($this->oDocument->getFolderId()); | |
| 90 | 103 | if (KTBrowseUtil::inAdminMode($this->oUser, $oFolder)) { |
| 91 | 104 | return true; |
| 92 | 105 | } | ... | ... |
plugins/ktcore/KTDocumentActions.php
| ... | ... | @@ -96,6 +96,9 @@ class KTDocumentCheckOutAction extends KTDocumentAction { |
| 96 | 96 | |
| 97 | 97 | var $_sShowPermission = "ktcore.permissions.write"; |
| 98 | 98 | |
| 99 | + var $_bMutator = true; | |
| 100 | + var $_bMutationAllowedByAdmin = false; | |
| 101 | + | |
| 99 | 102 | function getDisplayName() { |
| 100 | 103 | return _kt('Checkout'); |
| 101 | 104 | } |
| ... | ... | @@ -381,6 +384,7 @@ class KTDocumentEditAction extends KTDocumentAction { |
| 381 | 384 | var $sName = 'ktcore.actions.document.edit'; |
| 382 | 385 | |
| 383 | 386 | var $_sShowPermission = "ktcore.permissions.write"; |
| 387 | + var $_bMutator = true; | |
| 384 | 388 | |
| 385 | 389 | function getInfo() { |
| 386 | 390 | if ($this->oDocument->getIsCheckedOut()) { |
| ... | ... | @@ -404,6 +408,7 @@ class KTDocumentDeleteAction extends KTDocumentAction { |
| 404 | 408 | var $sName = 'ktcore.actions.document.delete'; |
| 405 | 409 | |
| 406 | 410 | var $_sShowPermission = "ktcore.permissions.delete"; |
| 411 | + var $_bMutator = true; | |
| 407 | 412 | |
| 408 | 413 | function getDisplayName() { |
| 409 | 414 | return _kt('Delete'); |
| ... | ... | @@ -480,6 +485,7 @@ class KTDocumentMoveAction extends KTDocumentAction { |
| 480 | 485 | var $sName = 'ktcore.actions.document.move'; |
| 481 | 486 | |
| 482 | 487 | var $_sShowPermission = "ktcore.permissions.write"; |
| 488 | + var $_bMutator = true; | |
| 483 | 489 | |
| 484 | 490 | function getDisplayName() { |
| 485 | 491 | return _kt('Move'); |
| ... | ... | @@ -867,6 +873,7 @@ class KTDocumentVersionHistoryAction extends KTDocumentAction { |
| 867 | 873 | class KTDocumentArchiveAction extends KTDocumentAction { |
| 868 | 874 | var $sName = 'ktcore.actions.document.archive'; |
| 869 | 875 | var $_sShowPermission = "ktcore.permissions.write"; |
| 876 | + var $_bMutator = true; | |
| 870 | 877 | |
| 871 | 878 | function getDisplayName() { |
| 872 | 879 | return _kt('Archive'); | ... | ... |
plugins/ktcore/document/Rename.php
| ... | ... | @@ -42,6 +42,7 @@ class KTDocumentRenameAction extends KTDocumentAction { |
| 42 | 42 | var $sName = 'ktcore.actions.document.rename'; |
| 43 | 43 | |
| 44 | 44 | var $_sShowPermission = "ktcore.permissions.write"; |
| 45 | + var $_bMutator = true; | |
| 45 | 46 | |
| 46 | 47 | function getDisplayName() { |
| 47 | 48 | return _kt('Rename'); | ... | ... |