From 84957e0fcefc979e2be0f0d0d393f251584ec84f Mon Sep 17 00:00:00 2001 From: Brad Shuttleworth Date: Tue, 13 Jun 2006 16:08:46 +0000 Subject: [PATCH] KTS-451: admin should be able to force checkin in admin mode. --- lib/actions/documentaction.inc.php | 13 +++++++++++-- plugins/ktcore/KTDocumentActions.php | 23 ++++++++++++++++++++++- templates/kt3/view_document.smarty | 8 ++++++++ view.php | 19 +++++++++++++++++-- 4 files changed, 58 insertions(+), 5 deletions(-) diff --git a/lib/actions/documentaction.inc.php b/lib/actions/documentaction.inc.php index d8643ae..e587ad8 100644 --- a/lib/actions/documentaction.inc.php +++ b/lib/actions/documentaction.inc.php @@ -37,6 +37,7 @@ class KTDocumentAction extends KTStandardDispatcher { var $_sShowPermission = "ktcore.permissions.read"; var $_sDisablePermission; + var $bAllowInAdminMode = false; var $sHelpPage = 'ktcore/browse.html'; var $sSection = "view_details"; @@ -63,7 +64,8 @@ class KTDocumentAction extends KTStandardDispatcher { function _show() { if (is_null($this->_sShowPermission)) { return true; - } + } + if ($this->_bAdminAlwaysAvailable) { if (Permission::userIsSystemAdministrator($this->oUser->getId())) { return true; @@ -82,6 +84,13 @@ class KTDocumentAction extends KTStandardDispatcher { // be nasty in archive/delete status. $status = $this->oDocument->getStatusID(); if (($status == DELETED) || ($status == ARCHIVED)) { return false; } + if ($this->bAllowInAdminMode) { + // check if this user is in admin mode + $oFolder = Folder::get($this->oDocument->getFolderId()); + if (KTBrowseUtil::inAdminMode($this->oUser, $oFolder)) { + return true; + } + } return KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $this->oDocument); } @@ -149,7 +158,7 @@ class KTDocumentAction extends KTStandardDispatcher { $oPortlet->setActions($actions, $this->sName); $this->oPage->addPortlet($oPortlet); - $this->oPage->setSecondaryTitle($this->oDocument->getName()); + $this->oPage->setSecondaryTitle($this->oDocument->getName()); return true; } diff --git a/plugins/ktcore/KTDocumentActions.php b/plugins/ktcore/KTDocumentActions.php index e58dd45..7a76364 100644 --- a/plugins/ktcore/KTDocumentActions.php +++ b/plugins/ktcore/KTDocumentActions.php @@ -269,6 +269,8 @@ class KTDocumentCancelCheckOutAction extends KTDocumentAction { var $sName = 'ktcore.actions.document.cancelcheckout'; var $_sShowPermission = "ktcore.permissions.write"; + var $bAllowInAdminMode = true; + var $bInAdminMode = null; function getDisplayName() { return _kt('Cancel Checkout'); @@ -278,7 +280,15 @@ class KTDocumentCancelCheckOutAction extends KTDocumentAction { if (!$this->oDocument->getIsCheckedOut()) { return null; } - + if (is_null($this->bInAdminMode)) { + $oFolder = Folder::get($this->oDocument->getFolderId()); + if (KTBrowseUtil::inAdminMode($this->oUser, $oFolder)) { + $this->bAdminMode = true; + return parent::getInfo(); + } + } else if ($this->bInAdminMode == true) { + return parent::getInfo(); + } if ($this->oDocument->getCheckedOutUserID() != $this->oUser->getId()) { return null; } @@ -287,6 +297,7 @@ class KTDocumentCancelCheckOutAction extends KTDocumentAction { function check() { $res = parent::check(); + if ($res !== true) { return $res; } @@ -295,6 +306,16 @@ class KTDocumentCancelCheckOutAction extends KTDocumentAction { controllerRedirect('viewDocument', 'fDocumentId=' . $this->oDocument->getId()); exit(0); } + // hard override if we're in admin mode for this doc. + if (is_null($this->bInAdminMode)) { + $oFolder = Folder::get($this->oDocument->getFolderId()); + if (KTBrowseUtil::inAdminMode($this->oUser, $oFolder)) { + $this->bAdminMode = true; + return true; + } + } else if ($this->bInAdminMode == true) { + return true; + } if ($this->oDocument->getCheckedOutUserID() != $this->oUser->getId()) { $_SESSION['KTErrorMessage'][] = _kt("This document is checked out, but not by you"); controllerRedirect('viewDocument', 'fDocumentId=' . $this->oDocument->getId()); diff --git a/templates/kt3/view_document.smarty b/templates/kt3/view_document.smarty index 2350ef0..773faa0 100644 --- a/templates/kt3/view_document.smarty +++ b/templates/kt3/view_document.smarty @@ -12,12 +12,20 @@ this is incorrect, or you no longer need to make changes to it, please cancel the checkout.{/i18n}

{else} +{if ($canCheckin)} +
+

{i18n arg_checkoutuser=$checkout_user}This document is currently checked out by #checkoutuser#, but you +have sufficient priviledges to cancel their checkout.{/i18n}

+
+ +{else}

{i18n arg_checkoutuser=$checkout_user}This document is currently checked out by #checkoutuser#. You cannot make changes until that user checks it in. If you have urgent modifications to make, please contact your KnowledgeTree Administrator.{/i18n}

{/if} +{/if} {/if} {foreach item=oFieldset from=$fieldsets} {$oFieldset->render($document_data)} diff --git a/view.php b/view.php index 86d4816..31d7191 100755 --- a/view.php +++ b/view.php @@ -55,6 +55,8 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { var $sSection = "view_details"; var $sHelpPage = 'ktcore/browse.html'; + + var $actions; function ViewDocumentDispatcher() { $this->aBreadcrumbs = array( @@ -74,9 +76,9 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { // FIXME identify the current location somehow. function addPortlets($currentaction = null) { - $actions = KTDocumentActionUtil::getDocumentActionsForDocument($this->oDocument, $this->oUser); + $this->actions = KTDocumentActionUtil::getDocumentActionsForDocument($this->oDocument, $this->oUser); $oPortlet = new KTActionPortlet(_kt("Document Actions")); - $oPortlet->setActions($actions, $currentaction); + $oPortlet->setActions($this->actions, $currentaction); $this->oPage->addPortlet($oPortlet); } @@ -182,12 +184,25 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { } } + // is the checkout action active? + $bCanCheckin = false; + foreach ($this->actions as $oDocAction) { + $sActName = $oDocAction->sName; + if ($sActName == 'ktcore.actions.document.cancelcheckout') { + if ($oDocAction->_show()) { + $bCanCheckin = true; + } + } + } + + $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate("kt3/view_document"); $aTemplateData = array( "context" => $this, "sCheckoutUser" => $checkout_user, "isCheckoutUser" => ($this->oUser->getId() == $oDocument->getCheckedOutUserId()), + "canCheckin" => $bCanCheckin, "document_id" => $document_id, "document" => $oDocument, "document_data" => $document_data, -- libgit2 0.21.4