Commit 1486cdc83837916361d04a7727f56a02cc390e42

Authored by Neil Blakey-Milner
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
lib/actions/documentaction.inc.php
@@ -42,6 +42,9 @@ class KTDocumentAction extends KTStandardDispatcher { @@ -42,6 +42,9 @@ class KTDocumentAction extends KTStandardDispatcher {
42 42
43 var $sSection = "view_details"; 43 var $sSection = "view_details";
44 44
  45 + var $_bMutator = false;
  46 + var $_bMutationAllowedByAdmin = true;
  47 +
45 function KTDocumentAction($oDocument = null, $oUser = null, $oPlugin = null) { 48 function KTDocumentAction($oDocument = null, $oUser = null, $oPlugin = null) {
46 $this->oDocument =& $oDocument; 49 $this->oDocument =& $oDocument;
47 $this->oUser =& $oUser; 50 $this->oUser =& $oUser;
@@ -64,7 +67,18 @@ class KTDocumentAction extends KTStandardDispatcher { @@ -64,7 +67,18 @@ class KTDocumentAction extends KTStandardDispatcher {
64 function _show() { 67 function _show() {
65 if (is_null($this->_sShowPermission)) { 68 if (is_null($this->_sShowPermission)) {
66 return true; 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 if ($this->_bAdminAlwaysAvailable) { 83 if ($this->_bAdminAlwaysAvailable) {
70 if (Permission::userIsSystemAdministrator($this->oUser->getId())) { 84 if (Permission::userIsSystemAdministrator($this->oUser->getId())) {
@@ -86,7 +100,6 @@ class KTDocumentAction extends KTStandardDispatcher { @@ -86,7 +100,6 @@ class KTDocumentAction extends KTStandardDispatcher {
86 if (($status == DELETED) || ($status == ARCHIVED)) { return false; } 100 if (($status == DELETED) || ($status == ARCHIVED)) { return false; }
87 if ($this->bAllowInAdminMode) { 101 if ($this->bAllowInAdminMode) {
88 // check if this user is in admin mode 102 // check if this user is in admin mode
89 - $oFolder = Folder::get($this->oDocument->getFolderId());  
90 if (KTBrowseUtil::inAdminMode($this->oUser, $oFolder)) { 103 if (KTBrowseUtil::inAdminMode($this->oUser, $oFolder)) {
91 return true; 104 return true;
92 } 105 }
plugins/ktcore/KTDocumentActions.php
@@ -96,6 +96,9 @@ class KTDocumentCheckOutAction extends KTDocumentAction { @@ -96,6 +96,9 @@ class KTDocumentCheckOutAction extends KTDocumentAction {
96 96
97 var $_sShowPermission = "ktcore.permissions.write"; 97 var $_sShowPermission = "ktcore.permissions.write";
98 98
  99 + var $_bMutator = true;
  100 + var $_bMutationAllowedByAdmin = false;
  101 +
99 function getDisplayName() { 102 function getDisplayName() {
100 return _kt('Checkout'); 103 return _kt('Checkout');
101 } 104 }
@@ -381,6 +384,7 @@ class KTDocumentEditAction extends KTDocumentAction { @@ -381,6 +384,7 @@ class KTDocumentEditAction extends KTDocumentAction {
381 var $sName = 'ktcore.actions.document.edit'; 384 var $sName = 'ktcore.actions.document.edit';
382 385
383 var $_sShowPermission = "ktcore.permissions.write"; 386 var $_sShowPermission = "ktcore.permissions.write";
  387 + var $_bMutator = true;
384 388
385 function getInfo() { 389 function getInfo() {
386 if ($this->oDocument->getIsCheckedOut()) { 390 if ($this->oDocument->getIsCheckedOut()) {
@@ -404,6 +408,7 @@ class KTDocumentDeleteAction extends KTDocumentAction { @@ -404,6 +408,7 @@ class KTDocumentDeleteAction extends KTDocumentAction {
404 var $sName = 'ktcore.actions.document.delete'; 408 var $sName = 'ktcore.actions.document.delete';
405 409
406 var $_sShowPermission = "ktcore.permissions.delete"; 410 var $_sShowPermission = "ktcore.permissions.delete";
  411 + var $_bMutator = true;
407 412
408 function getDisplayName() { 413 function getDisplayName() {
409 return _kt('Delete'); 414 return _kt('Delete');
@@ -480,6 +485,7 @@ class KTDocumentMoveAction extends KTDocumentAction { @@ -480,6 +485,7 @@ class KTDocumentMoveAction extends KTDocumentAction {
480 var $sName = 'ktcore.actions.document.move'; 485 var $sName = 'ktcore.actions.document.move';
481 486
482 var $_sShowPermission = "ktcore.permissions.write"; 487 var $_sShowPermission = "ktcore.permissions.write";
  488 + var $_bMutator = true;
483 489
484 function getDisplayName() { 490 function getDisplayName() {
485 return _kt('Move'); 491 return _kt('Move');
@@ -867,6 +873,7 @@ class KTDocumentVersionHistoryAction extends KTDocumentAction { @@ -867,6 +873,7 @@ class KTDocumentVersionHistoryAction extends KTDocumentAction {
867 class KTDocumentArchiveAction extends KTDocumentAction { 873 class KTDocumentArchiveAction extends KTDocumentAction {
868 var $sName = 'ktcore.actions.document.archive'; 874 var $sName = 'ktcore.actions.document.archive';
869 var $_sShowPermission = "ktcore.permissions.write"; 875 var $_sShowPermission = "ktcore.permissions.write";
  876 + var $_bMutator = true;
870 877
871 function getDisplayName() { 878 function getDisplayName() {
872 return _kt('Archive'); 879 return _kt('Archive');
plugins/ktcore/document/Rename.php
@@ -42,6 +42,7 @@ class KTDocumentRenameAction extends KTDocumentAction { @@ -42,6 +42,7 @@ class KTDocumentRenameAction extends KTDocumentAction {
42 var $sName = 'ktcore.actions.document.rename'; 42 var $sName = 'ktcore.actions.document.rename';
43 43
44 var $_sShowPermission = "ktcore.permissions.write"; 44 var $_sShowPermission = "ktcore.permissions.write";
  45 + var $_bMutator = true;
45 46
46 function getDisplayName() { 47 function getDisplayName() {
47 return _kt('Rename'); 48 return _kt('Rename');