Commit 84957e0fcefc979e2be0f0d0d393f251584ec84f

Authored by Brad Shuttleworth
1 parent fafdc991

KTS-451: admin should be able to force checkin in admin mode.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5563 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/actions/documentaction.inc.php
@@ -37,6 +37,7 @@ class KTDocumentAction extends KTStandardDispatcher { @@ -37,6 +37,7 @@ class KTDocumentAction extends KTStandardDispatcher {
37 37
38 var $_sShowPermission = "ktcore.permissions.read"; 38 var $_sShowPermission = "ktcore.permissions.read";
39 var $_sDisablePermission; 39 var $_sDisablePermission;
  40 + var $bAllowInAdminMode = false;
40 var $sHelpPage = 'ktcore/browse.html'; 41 var $sHelpPage = 'ktcore/browse.html';
41 42
42 var $sSection = "view_details"; 43 var $sSection = "view_details";
@@ -63,7 +64,8 @@ class KTDocumentAction extends KTStandardDispatcher { @@ -63,7 +64,8 @@ class KTDocumentAction extends KTStandardDispatcher {
63 function _show() { 64 function _show() {
64 if (is_null($this->_sShowPermission)) { 65 if (is_null($this->_sShowPermission)) {
65 return true; 66 return true;
66 - } 67 + }
  68 +
67 if ($this->_bAdminAlwaysAvailable) { 69 if ($this->_bAdminAlwaysAvailable) {
68 if (Permission::userIsSystemAdministrator($this->oUser->getId())) { 70 if (Permission::userIsSystemAdministrator($this->oUser->getId())) {
69 return true; 71 return true;
@@ -82,6 +84,13 @@ class KTDocumentAction extends KTStandardDispatcher { @@ -82,6 +84,13 @@ class KTDocumentAction extends KTStandardDispatcher {
82 // be nasty in archive/delete status. 84 // be nasty in archive/delete status.
83 $status = $this->oDocument->getStatusID(); 85 $status = $this->oDocument->getStatusID();
84 if (($status == DELETED) || ($status == ARCHIVED)) { return false; } 86 if (($status == DELETED) || ($status == ARCHIVED)) { return false; }
  87 + if ($this->bAllowInAdminMode) {
  88 + // check if this user is in admin mode
  89 + $oFolder = Folder::get($this->oDocument->getFolderId());
  90 + if (KTBrowseUtil::inAdminMode($this->oUser, $oFolder)) {
  91 + return true;
  92 + }
  93 + }
85 return KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $this->oDocument); 94 return KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $this->oDocument);
86 } 95 }
87 96
@@ -149,7 +158,7 @@ class KTDocumentAction extends KTStandardDispatcher { @@ -149,7 +158,7 @@ class KTDocumentAction extends KTStandardDispatcher {
149 $oPortlet->setActions($actions, $this->sName); 158 $oPortlet->setActions($actions, $this->sName);
150 $this->oPage->addPortlet($oPortlet); 159 $this->oPage->addPortlet($oPortlet);
151 160
152 - $this->oPage->setSecondaryTitle($this->oDocument->getName()); 161 + $this->oPage->setSecondaryTitle($this->oDocument->getName());
153 162
154 return true; 163 return true;
155 } 164 }
plugins/ktcore/KTDocumentActions.php
@@ -269,6 +269,8 @@ class KTDocumentCancelCheckOutAction extends KTDocumentAction { @@ -269,6 +269,8 @@ class KTDocumentCancelCheckOutAction extends KTDocumentAction {
269 var $sName = 'ktcore.actions.document.cancelcheckout'; 269 var $sName = 'ktcore.actions.document.cancelcheckout';
270 270
271 var $_sShowPermission = "ktcore.permissions.write"; 271 var $_sShowPermission = "ktcore.permissions.write";
  272 + var $bAllowInAdminMode = true;
  273 + var $bInAdminMode = null;
272 274
273 function getDisplayName() { 275 function getDisplayName() {
274 return _kt('Cancel Checkout'); 276 return _kt('Cancel Checkout');
@@ -278,7 +280,15 @@ class KTDocumentCancelCheckOutAction extends KTDocumentAction { @@ -278,7 +280,15 @@ class KTDocumentCancelCheckOutAction extends KTDocumentAction {
278 if (!$this->oDocument->getIsCheckedOut()) { 280 if (!$this->oDocument->getIsCheckedOut()) {
279 return null; 281 return null;
280 } 282 }
281 - 283 + if (is_null($this->bInAdminMode)) {
  284 + $oFolder = Folder::get($this->oDocument->getFolderId());
  285 + if (KTBrowseUtil::inAdminMode($this->oUser, $oFolder)) {
  286 + $this->bAdminMode = true;
  287 + return parent::getInfo();
  288 + }
  289 + } else if ($this->bInAdminMode == true) {
  290 + return parent::getInfo();
  291 + }
282 if ($this->oDocument->getCheckedOutUserID() != $this->oUser->getId()) { 292 if ($this->oDocument->getCheckedOutUserID() != $this->oUser->getId()) {
283 return null; 293 return null;
284 } 294 }
@@ -287,6 +297,7 @@ class KTDocumentCancelCheckOutAction extends KTDocumentAction { @@ -287,6 +297,7 @@ class KTDocumentCancelCheckOutAction extends KTDocumentAction {
287 297
288 function check() { 298 function check() {
289 $res = parent::check(); 299 $res = parent::check();
  300 +
290 if ($res !== true) { 301 if ($res !== true) {
291 return $res; 302 return $res;
292 } 303 }
@@ -295,6 +306,16 @@ class KTDocumentCancelCheckOutAction extends KTDocumentAction { @@ -295,6 +306,16 @@ class KTDocumentCancelCheckOutAction extends KTDocumentAction {
295 controllerRedirect('viewDocument', 'fDocumentId=' . $this->oDocument->getId()); 306 controllerRedirect('viewDocument', 'fDocumentId=' . $this->oDocument->getId());
296 exit(0); 307 exit(0);
297 } 308 }
  309 + // hard override if we're in admin mode for this doc.
  310 + if (is_null($this->bInAdminMode)) {
  311 + $oFolder = Folder::get($this->oDocument->getFolderId());
  312 + if (KTBrowseUtil::inAdminMode($this->oUser, $oFolder)) {
  313 + $this->bAdminMode = true;
  314 + return true;
  315 + }
  316 + } else if ($this->bInAdminMode == true) {
  317 + return true;
  318 + }
298 if ($this->oDocument->getCheckedOutUserID() != $this->oUser->getId()) { 319 if ($this->oDocument->getCheckedOutUserID() != $this->oUser->getId()) {
299 $_SESSION['KTErrorMessage'][] = _kt("This document is checked out, but not by you"); 320 $_SESSION['KTErrorMessage'][] = _kt("This document is checked out, but not by you");
300 controllerRedirect('viewDocument', 'fDocumentId=' . $this->oDocument->getId()); 321 controllerRedirect('viewDocument', 'fDocumentId=' . $this->oDocument->getId());
templates/kt3/view_document.smarty
@@ -12,12 +12,20 @@ @@ -12,12 +12,20 @@
12 this is incorrect, or you no longer need to make changes to it, please cancel the checkout.{/i18n}</p> 12 this is incorrect, or you no longer need to make changes to it, please cancel the checkout.{/i18n}</p>
13 </div> 13 </div>
14 {else} 14 {else}
  15 +{if ($canCheckin)}
  16 +<div class="ktInfo">
  17 +<p>{i18n arg_checkoutuser=$checkout_user}This document is currently checked out by #checkoutuser#, but you
  18 +have sufficient priviledges to cancel their checkout.{/i18n}</p>
  19 +</div>
  20 +
  21 +{else}
15 <div class="ktInfo"> 22 <div class="ktInfo">
16 <p>{i18n arg_checkoutuser=$checkout_user}This document is currently checked out by #checkoutuser#. You cannot make 23 <p>{i18n arg_checkoutuser=$checkout_user}This document is currently checked out by #checkoutuser#. You cannot make
17 changes until that user checks it in. If you have urgent modifications to make, please 24 changes until that user checks it in. If you have urgent modifications to make, please
18 contact your KnowledgeTree Administrator.{/i18n}</p> 25 contact your KnowledgeTree Administrator.{/i18n}</p>
19 </div> 26 </div>
20 {/if} 27 {/if}
  28 +{/if}
21 {/if} 29 {/if}
22 {foreach item=oFieldset from=$fieldsets} 30 {foreach item=oFieldset from=$fieldsets}
23 {$oFieldset->render($document_data)} 31 {$oFieldset->render($document_data)}
view.php
@@ -55,6 +55,8 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { @@ -55,6 +55,8 @@ class ViewDocumentDispatcher extends KTStandardDispatcher {
55 55
56 var $sSection = "view_details"; 56 var $sSection = "view_details";
57 var $sHelpPage = 'ktcore/browse.html'; 57 var $sHelpPage = 'ktcore/browse.html';
  58 +
  59 + var $actions;
58 60
59 function ViewDocumentDispatcher() { 61 function ViewDocumentDispatcher() {
60 $this->aBreadcrumbs = array( 62 $this->aBreadcrumbs = array(
@@ -74,9 +76,9 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { @@ -74,9 +76,9 @@ class ViewDocumentDispatcher extends KTStandardDispatcher {
74 76
75 // FIXME identify the current location somehow. 77 // FIXME identify the current location somehow.
76 function addPortlets($currentaction = null) { 78 function addPortlets($currentaction = null) {
77 - $actions = KTDocumentActionUtil::getDocumentActionsForDocument($this->oDocument, $this->oUser); 79 + $this->actions = KTDocumentActionUtil::getDocumentActionsForDocument($this->oDocument, $this->oUser);
78 $oPortlet = new KTActionPortlet(_kt("Document Actions")); 80 $oPortlet = new KTActionPortlet(_kt("Document Actions"));
79 - $oPortlet->setActions($actions, $currentaction); 81 + $oPortlet->setActions($this->actions, $currentaction);
80 $this->oPage->addPortlet($oPortlet); 82 $this->oPage->addPortlet($oPortlet);
81 } 83 }
82 84
@@ -182,12 +184,25 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { @@ -182,12 +184,25 @@ class ViewDocumentDispatcher extends KTStandardDispatcher {
182 } 184 }
183 } 185 }
184 186
  187 + // is the checkout action active?
  188 + $bCanCheckin = false;
  189 + foreach ($this->actions as $oDocAction) {
  190 + $sActName = $oDocAction->sName;
  191 + if ($sActName == 'ktcore.actions.document.cancelcheckout') {
  192 + if ($oDocAction->_show()) {
  193 + $bCanCheckin = true;
  194 + }
  195 + }
  196 + }
  197 +
  198 +
185 $oTemplating =& KTTemplating::getSingleton(); 199 $oTemplating =& KTTemplating::getSingleton();
186 $oTemplate = $oTemplating->loadTemplate("kt3/view_document"); 200 $oTemplate = $oTemplating->loadTemplate("kt3/view_document");
187 $aTemplateData = array( 201 $aTemplateData = array(
188 "context" => $this, 202 "context" => $this,
189 "sCheckoutUser" => $checkout_user, 203 "sCheckoutUser" => $checkout_user,
190 "isCheckoutUser" => ($this->oUser->getId() == $oDocument->getCheckedOutUserId()), 204 "isCheckoutUser" => ($this->oUser->getId() == $oDocument->getCheckedOutUserId()),
  205 + "canCheckin" => $bCanCheckin,
191 "document_id" => $document_id, 206 "document_id" => $document_id,
192 "document" => $oDocument, 207 "document" => $oDocument,
193 "document_data" => $document_data, 208 "document_data" => $document_data,