Commit 84957e0fcefc979e2be0f0d0d393f251584ec84f
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
Showing
4 changed files
with
58 additions
and
5 deletions
lib/actions/documentaction.inc.php
| ... | ... | @@ -37,6 +37,7 @@ class KTDocumentAction extends KTStandardDispatcher { |
| 37 | 37 | |
| 38 | 38 | var $_sShowPermission = "ktcore.permissions.read"; |
| 39 | 39 | var $_sDisablePermission; |
| 40 | + var $bAllowInAdminMode = false; | |
| 40 | 41 | var $sHelpPage = 'ktcore/browse.html'; |
| 41 | 42 | |
| 42 | 43 | var $sSection = "view_details"; |
| ... | ... | @@ -63,7 +64,8 @@ class KTDocumentAction extends KTStandardDispatcher { |
| 63 | 64 | function _show() { |
| 64 | 65 | if (is_null($this->_sShowPermission)) { |
| 65 | 66 | return true; |
| 66 | - } | |
| 67 | + } | |
| 68 | + | |
| 67 | 69 | if ($this->_bAdminAlwaysAvailable) { |
| 68 | 70 | if (Permission::userIsSystemAdministrator($this->oUser->getId())) { |
| 69 | 71 | return true; |
| ... | ... | @@ -82,6 +84,13 @@ class KTDocumentAction extends KTStandardDispatcher { |
| 82 | 84 | // be nasty in archive/delete status. |
| 83 | 85 | $status = $this->oDocument->getStatusID(); |
| 84 | 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 | 94 | return KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $this->oDocument); |
| 86 | 95 | } |
| 87 | 96 | |
| ... | ... | @@ -149,7 +158,7 @@ class KTDocumentAction extends KTStandardDispatcher { |
| 149 | 158 | $oPortlet->setActions($actions, $this->sName); |
| 150 | 159 | $this->oPage->addPortlet($oPortlet); |
| 151 | 160 | |
| 152 | - $this->oPage->setSecondaryTitle($this->oDocument->getName()); | |
| 161 | + $this->oPage->setSecondaryTitle($this->oDocument->getName()); | |
| 153 | 162 | |
| 154 | 163 | return true; |
| 155 | 164 | } | ... | ... |
plugins/ktcore/KTDocumentActions.php
| ... | ... | @@ -269,6 +269,8 @@ class KTDocumentCancelCheckOutAction extends KTDocumentAction { |
| 269 | 269 | var $sName = 'ktcore.actions.document.cancelcheckout'; |
| 270 | 270 | |
| 271 | 271 | var $_sShowPermission = "ktcore.permissions.write"; |
| 272 | + var $bAllowInAdminMode = true; | |
| 273 | + var $bInAdminMode = null; | |
| 272 | 274 | |
| 273 | 275 | function getDisplayName() { |
| 274 | 276 | return _kt('Cancel Checkout'); |
| ... | ... | @@ -278,7 +280,15 @@ class KTDocumentCancelCheckOutAction extends KTDocumentAction { |
| 278 | 280 | if (!$this->oDocument->getIsCheckedOut()) { |
| 279 | 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 | 292 | if ($this->oDocument->getCheckedOutUserID() != $this->oUser->getId()) { |
| 283 | 293 | return null; |
| 284 | 294 | } |
| ... | ... | @@ -287,6 +297,7 @@ class KTDocumentCancelCheckOutAction extends KTDocumentAction { |
| 287 | 297 | |
| 288 | 298 | function check() { |
| 289 | 299 | $res = parent::check(); |
| 300 | + | |
| 290 | 301 | if ($res !== true) { |
| 291 | 302 | return $res; |
| 292 | 303 | } |
| ... | ... | @@ -295,6 +306,16 @@ class KTDocumentCancelCheckOutAction extends KTDocumentAction { |
| 295 | 306 | controllerRedirect('viewDocument', 'fDocumentId=' . $this->oDocument->getId()); |
| 296 | 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 | 319 | if ($this->oDocument->getCheckedOutUserID() != $this->oUser->getId()) { |
| 299 | 320 | $_SESSION['KTErrorMessage'][] = _kt("This document is checked out, but not by you"); |
| 300 | 321 | controllerRedirect('viewDocument', 'fDocumentId=' . $this->oDocument->getId()); | ... | ... |
templates/kt3/view_document.smarty
| ... | ... | @@ -12,12 +12,20 @@ |
| 12 | 12 | this is incorrect, or you no longer need to make changes to it, please cancel the checkout.{/i18n}</p> |
| 13 | 13 | </div> |
| 14 | 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 | 22 | <div class="ktInfo"> |
| 16 | 23 | <p>{i18n arg_checkoutuser=$checkout_user}This document is currently checked out by #checkoutuser#. You cannot make |
| 17 | 24 | changes until that user checks it in. If you have urgent modifications to make, please |
| 18 | 25 | contact your KnowledgeTree Administrator.{/i18n}</p> |
| 19 | 26 | </div> |
| 20 | 27 | {/if} |
| 28 | +{/if} | |
| 21 | 29 | {/if} |
| 22 | 30 | {foreach item=oFieldset from=$fieldsets} |
| 23 | 31 | {$oFieldset->render($document_data)} | ... | ... |
view.php
| ... | ... | @@ -55,6 +55,8 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { |
| 55 | 55 | |
| 56 | 56 | var $sSection = "view_details"; |
| 57 | 57 | var $sHelpPage = 'ktcore/browse.html'; |
| 58 | + | |
| 59 | + var $actions; | |
| 58 | 60 | |
| 59 | 61 | function ViewDocumentDispatcher() { |
| 60 | 62 | $this->aBreadcrumbs = array( |
| ... | ... | @@ -74,9 +76,9 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { |
| 74 | 76 | |
| 75 | 77 | // FIXME identify the current location somehow. |
| 76 | 78 | function addPortlets($currentaction = null) { |
| 77 | - $actions = KTDocumentActionUtil::getDocumentActionsForDocument($this->oDocument, $this->oUser); | |
| 79 | + $this->actions = KTDocumentActionUtil::getDocumentActionsForDocument($this->oDocument, $this->oUser); | |
| 78 | 80 | $oPortlet = new KTActionPortlet(_kt("Document Actions")); |
| 79 | - $oPortlet->setActions($actions, $currentaction); | |
| 81 | + $oPortlet->setActions($this->actions, $currentaction); | |
| 80 | 82 | $this->oPage->addPortlet($oPortlet); |
| 81 | 83 | } |
| 82 | 84 | |
| ... | ... | @@ -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 | 199 | $oTemplating =& KTTemplating::getSingleton(); |
| 186 | 200 | $oTemplate = $oTemplating->loadTemplate("kt3/view_document"); |
| 187 | 201 | $aTemplateData = array( |
| 188 | 202 | "context" => $this, |
| 189 | 203 | "sCheckoutUser" => $checkout_user, |
| 190 | 204 | "isCheckoutUser" => ($this->oUser->getId() == $oDocument->getCheckedOutUserId()), |
| 205 | + "canCheckin" => $bCanCheckin, | |
| 191 | 206 | "document_id" => $document_id, |
| 192 | 207 | "document" => $oDocument, |
| 193 | 208 | "document_data" => $document_data, | ... | ... |