Commit 3df3251384138d51e2dd019c810a5eacef9f773a
1 parent
79e2c38d
- add "cancel checkout" document action
- improve the "checked out" notice - improve the "checkout" page. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4703 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
9 changed files
with
163 additions
and
32 deletions
lib/actions/documentaction.inc.php
| ... | ... | @@ -25,6 +25,8 @@ class KTDocumentAction extends KTStandardDispatcher { |
| 25 | 25 | $this->oDocument =& $oDocument; |
| 26 | 26 | $this->oUser =& $oUser; |
| 27 | 27 | $this->oPlugin =& $oPlugin; |
| 28 | + | |
| 29 | + | |
| 28 | 30 | parent::KTStandardDispatcher(); |
| 29 | 31 | } |
| 30 | 32 | |
| ... | ... | @@ -134,6 +136,13 @@ class KTDocumentAction extends KTStandardDispatcher { |
| 134 | 136 | ); |
| 135 | 137 | $this->aBreadcrumbs = array_merge($this->aBreadcrumbs, |
| 136 | 138 | KTBrowseUtil::breadcrumbsForDocument($this->oDocument, $aOptions)); |
| 139 | + | |
| 140 | + | |
| 141 | + $actions = KTDocumentActionUtil::getDocumentActionsForDocument($this->oDocument, $this->oUser); | |
| 142 | + $oPortlet = new KTActionPortlet(_("Document Actions")); | |
| 143 | + $oPortlet->setActions($actions, $this->sName); | |
| 144 | + $this->oPage->addPortlet($oPortlet); | |
| 145 | + | |
| 137 | 146 | return true; |
| 138 | 147 | } |
| 139 | 148 | ... | ... |
plugins/ktcore/KTCorePlugin.php
| ... | ... | @@ -11,6 +11,7 @@ class KTCorePlugin extends KTPlugin { |
| 11 | 11 | $this->registerAction('documentaction', 'KTDocumentDetailsAction', 'ktcore.actions.document.displaydetails', 'KTDocumentActions.php'); |
| 12 | 12 | $this->registerAction('documentaction', 'KTDocumentViewAction', 'ktcore.actions.document.view', 'KTDocumentActions.php'); |
| 13 | 13 | $this->registerAction('documentaction', 'KTDocumentCheckOutAction', 'ktcore.actions.document.checkout', 'KTDocumentActions.php'); |
| 14 | + $this->registerAction('documentaction', 'KTDocumentCancelCheckOutAction', 'ktcore.actions.document.cancelcheckout', 'KTDocumentActions.php'); | |
| 14 | 15 | $this->registerAction('documentaction', 'KTDocumentCheckInAction', 'ktcore.actions.document.checkin', 'KTDocumentActions.php'); |
| 15 | 16 | $this->registerAction('documentaction', 'KTDocumentEditAction', 'ktcore.actions.document.edit', 'KTDocumentActions.php'); |
| 16 | 17 | $this->registerAction('documentaction', 'KTDocumentDeleteAction', 'ktcore.actions.document.delete', 'KTDocumentActions.php'); | ... | ... |
plugins/ktcore/KTDocumentActions.php
| ... | ... | @@ -100,16 +100,6 @@ class KTDocumentCheckOutAction extends KTDocumentAction { |
| 100 | 100 | $oTemplate =& $this->oValidator->validateTemplate('ktcore/action/checkout_final'); |
| 101 | 101 | $sReason = $this->oValidator->validateString(KTUtil::arrayGet($_REQUEST, 'reason'), $aErrorOptions); |
| 102 | 102 | |
| 103 | - $oTemplate->setData(array( | |
| 104 | - 'context' => &$this, | |
| 105 | - 'reason' => $sReason, | |
| 106 | - )); | |
| 107 | - return $oTemplate->render(); | |
| 108 | - } | |
| 109 | - | |
| 110 | - function do_checkout_final() { | |
| 111 | - $sReason = KTUtil::arrayGet($_REQUEST, 'reason'); | |
| 112 | - $this->oValidator->notEmpty($sReason); | |
| 113 | 103 | |
| 114 | 104 | // flip the checkout status |
| 115 | 105 | $this->oDocument->setIsCheckedOut(true); |
| ... | ... | @@ -139,6 +129,18 @@ class KTDocumentCheckOutAction extends KTDocumentAction { |
| 139 | 129 | |
| 140 | 130 | $oDocumentTransaction = & new DocumentTransaction($this->oDocument, $sReason, 'ktcore.transactions.check_out'); |
| 141 | 131 | $oDocumentTransaction->create(); |
| 132 | + | |
| 133 | + $oTemplate->setData(array( | |
| 134 | + 'context' => &$this, | |
| 135 | + 'reason' => $sReason, | |
| 136 | + )); | |
| 137 | + return $oTemplate->render(); | |
| 138 | + } | |
| 139 | + | |
| 140 | + function do_checkout_final() { | |
| 141 | + $sReason = KTUtil::arrayGet($_REQUEST, 'reason'); | |
| 142 | + $this->oValidator->notEmpty($sReason); | |
| 143 | + | |
| 142 | 144 | |
| 143 | 145 | $oStorage =& KTStorageManagerUtil::getSingleton(); |
| 144 | 146 | $oStorage->download($this->oDocument); |
| ... | ... | @@ -224,6 +226,88 @@ class KTDocumentCheckInAction extends KTDocumentAction { |
| 224 | 226 | } |
| 225 | 227 | // }}} |
| 226 | 228 | |
| 229 | + | |
| 230 | +// {{{ KTDocumentCheckInAction | |
| 231 | +class KTDocumentCancelCheckOutAction extends KTDocumentAction { | |
| 232 | + var $sDisplayName = 'Cancel Checkout'; | |
| 233 | + var $sName = 'ktcore.actions.document.cancelcheckout'; | |
| 234 | + | |
| 235 | + var $_sShowPermission = "ktcore.permissions.write"; | |
| 236 | + | |
| 237 | + function getInfo() { | |
| 238 | + if (!$this->oDocument->getIsCheckedOut()) { | |
| 239 | + return null; | |
| 240 | + } | |
| 241 | + | |
| 242 | + if ($this->oDocument->getCheckedOutUserID() != $this->oUser->getId()) { | |
| 243 | + return null; | |
| 244 | + } | |
| 245 | + return parent::getInfo(); | |
| 246 | + } | |
| 247 | + | |
| 248 | + function check() { | |
| 249 | + $res = parent::check(); | |
| 250 | + if ($res !== true) { | |
| 251 | + return $res; | |
| 252 | + } | |
| 253 | + if (!$this->oDocument->getIsCheckedOut()) { | |
| 254 | + $_SESSION['KTErrorMessage'][] = _("This document is not checked out"); | |
| 255 | + controllerRedirect('viewDocument', 'fDocumentId=' . $this->oDocument->getId()); | |
| 256 | + exit(0); | |
| 257 | + } | |
| 258 | + if ($this->oDocument->getCheckedOutUserID() != $this->oUser->getId()) { | |
| 259 | + $_SESSION['KTErrorMessage'][] = _("This document is checked out, but not by you"); | |
| 260 | + controllerRedirect('viewDocument', 'fDocumentId=' . $this->oDocument->getId()); | |
| 261 | + exit(0); | |
| 262 | + } | |
| 263 | + return true; | |
| 264 | + } | |
| 265 | + | |
| 266 | + function do_main() { | |
| 267 | + $this->oPage->setBreadcrumbDetails("cancel checkin"); | |
| 268 | + $oTemplate =& $this->oValidator->validateTemplate('ktcore/action/cancel_checkout'); | |
| 269 | + | |
| 270 | + $sReason = KTUtil::arrayGet($_REQUEST, 'reason', ""); | |
| 271 | + $checkin_fields = array(); | |
| 272 | + $checkin_fields[] = new KTStringWidget(_('Reason'), _('Give a reason for cancelling this checkout.'), 'reason', $sReason, $this->oPage, true); | |
| 273 | + | |
| 274 | + $oTemplate->setData(array( | |
| 275 | + 'context' => &$this, | |
| 276 | + 'checkin_fields' => $checkin_fields, | |
| 277 | + 'document' => $this->oDocument, | |
| 278 | + )); | |
| 279 | + return $oTemplate->render(); | |
| 280 | + } | |
| 281 | + | |
| 282 | + function do_checkin() { | |
| 283 | + $sReason = KTUtil::arrayGet($_REQUEST, 'reason'); | |
| 284 | + $sReason = $this->oValidator->notEmpty($sReason); | |
| 285 | + | |
| 286 | + global $default; | |
| 287 | + | |
| 288 | + $this->startTransaction(); | |
| 289 | + // actually do the checkin. | |
| 290 | + $this->oDocument->setIsCheckedOut(0); | |
| 291 | + $this->oDocument->setCheckedOutUserID(-1); | |
| 292 | + if (!$this->oDocument->update()) { | |
| 293 | + $this->rollbackTransaction(); | |
| 294 | + return $this->errorRedirectToMain(_("Failed to force the document's checkin."),sprintf('fDocumentId=%d'),$this->oDocument->getId()); | |
| 295 | + } | |
| 296 | + | |
| 297 | + // checkout cancelled transaction | |
| 298 | + $oDocumentTransaction = & new DocumentTransaction($this->oDocument, "Document checked out cancelled", 'ktcore.transactions.force_checkin'); | |
| 299 | + $res = $oDocumentTransaction->create(); | |
| 300 | + if (PEAR::isError($res) || ($res == false)) { | |
| 301 | + $this->rollbackTransaction(); | |
| 302 | + return $this->errorRedirectToMain(_("Failed to force the document's checkin."),sprintf('fDocumentId=%d'),$this->oDocument->getId()); | |
| 303 | + } | |
| 304 | + $this->commitTransaction(); // FIXME do we want to do this if we can't created the document-transaction? | |
| 305 | + redirect("$default->rootUrl/control.php?action=viewDocument&fDocumentID=" . $this->oDocument->getID()); | |
| 306 | + } | |
| 307 | +} | |
| 308 | +// }}} | |
| 309 | + | |
| 310 | + | |
| 227 | 311 | // {{{ KTDocumentEditAction |
| 228 | 312 | class KTDocumentEditAction extends KTDocumentAction { |
| 229 | 313 | var $sDisplayName = 'Edit metadata'; |
| ... | ... | @@ -540,6 +624,15 @@ class KTDocumentArchiveAction extends KTDocumentAction { |
| 540 | 624 | } |
| 541 | 625 | |
| 542 | 626 | function do_archive() { |
| 627 | + | |
| 628 | + $aErrorOptions = array( | |
| 629 | + 'redirect_to' => array('','fDocumentId=' . $this->oDocument->getId()), | |
| 630 | + 'message' => "You must provide a reason" | |
| 631 | + ); | |
| 632 | + | |
| 633 | + $sReason = $this->oValidator->validateString(KTUtil::arrayGet($_REQUEST, 'reason'), $aErrorOptions); | |
| 634 | + | |
| 635 | + | |
| 543 | 636 | $this->startTransaction(); |
| 544 | 637 | $this->oDocument->setStatusID(ARCHIVED); |
| 545 | 638 | if (!$this->oDocument->update()) { |
| ... | ... | @@ -547,6 +640,9 @@ class KTDocumentArchiveAction extends KTDocumentAction { |
| 547 | 640 | controllerRedirect('viewDocument', 'fDocumentId=' . $this->oDocument->getId()); |
| 548 | 641 | exit(0); |
| 549 | 642 | } |
| 643 | + $oDocumentTransaction = & new DocumentTransaction($this->oDocument, sprintf(_("Document archived: %s"), $sReason), 'ktcore.transactions.update'); | |
| 644 | + $oDocumentTransaction->create(); | |
| 645 | + | |
| 550 | 646 | $this->commitTransaction(); |
| 551 | 647 | |
| 552 | 648 | $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); | ... | ... |
plugins/ktcore/admin/documentCheckout.php
| ... | ... | @@ -110,11 +110,11 @@ class KTCheckoutAdminDispatcher extends KTAdminDispatcher { |
| 110 | 110 | |
| 111 | 111 | // checkout cancelled transaction |
| 112 | 112 | $oDocumentTransaction = & new DocumentTransaction($oDocument, "Document checked out cancelled", 'ktcore.transactions.force_checkin'); |
| 113 | - if ($oDocumentTransaction->create()) { | |
| 114 | - $default->log->debug("editDocCheckoutBL.php created forced checkin document transaction for document ID=" . $oDocument->getID()); | |
| 115 | - } else { | |
| 116 | - $default->log->error("editDocCheckoutBL.php couldn't create create document transaction for document ID=" . $oDocument->getID()); | |
| 117 | - } | |
| 113 | + $res = $oDocumentTransaction->create(); | |
| 114 | + if (PEAR::isError($res) || ($res == false)) { | |
| 115 | + $this->rollbackTransaction(); | |
| 116 | + return $this->errorRedirectToMain(_("Failed to force the document's checkin.")); | |
| 117 | + } | |
| 118 | 118 | $this->commitTransaction(); // FIXME do we want to do this if we can't created the document-transaction? |
| 119 | 119 | return $this->successRedirectToMain(sprintf(_('Successfully forced "%s" to be checked in.'), $oDocument->getName())); |
| 120 | 120 | } | ... | ... |
templates/kt3/view_document.smarty
| ... | ... | @@ -6,11 +6,18 @@ |
| 6 | 6 | #version#</strong>{/i18n}</p> |
| 7 | 7 | {if ($document->getIsCheckedOut() == 1)} |
| 8 | 8 | {capture assign=checkout_user}<strong>{$sCheckoutUser}</strong>{/capture} |
| 9 | +{if ($isCheckoutUser)} | |
| 10 | +<div class="ktInfo"> | |
| 11 | +<p>{i18n}This document is currently checked out by <strong>you</strong>. If | |
| 12 | +this is incorrect, or you no longer need to make changes to it, please cancel the checkout.{/i18n}</p> | |
| 13 | +</div> | |
| 14 | +{else} | |
| 9 | 15 | <div class="ktInfo"> |
| 10 | 16 | <p>{i18n arg_checkoutuser=$checkout_user}This document is currently checked out by #checkoutuser#. You cannot make |
| 11 | 17 | changes until that user checks it in. If you have urgent modifications to make, please |
| 12 | 18 | contact your KnowledgeTree Administrator.{/i18n}</p> |
| 13 | 19 | </div> |
| 20 | +{/if} | |
| 14 | 21 | {/if} |
| 15 | 22 | {foreach item=oFieldset from=$fieldsets} |
| 16 | 23 | {$oFieldset->render($document_data)} | ... | ... |
templates/ktcore/action/cancel_checkout.smarty
0 → 100644
| 1 | +<h2>{i18n}Cancel Checkout{/i18n}</h2> | |
| 2 | + | |
| 3 | +<p class="descriptiveText">If you do not want to have this document be checked-out, | |
| 4 | +please give a reason and cancel the checkout.</p> | |
| 5 | + | |
| 6 | +<form method="POST" action="{$smarty.server.PHP_SELF}" enctype="multipart/form-data"> | |
| 7 | +<fieldset><legend>{i18n}Checkin{/i18n}</legend> | |
| 8 | +<input type="hidden" name="action" value="checkin" /> | |
| 9 | +<input type="hidden" name="fDocumentId" value="{$document->getId()}" /> | |
| 10 | +{foreach from=$checkin_fields item=oWidget } | |
| 11 | + {$oWidget->render()} | |
| 12 | +{/foreach} | |
| 13 | +<div class="form_actions"> | |
| 14 | +<input type="submit" name="submit" value="{i18n}Cancel Checkout{/i18n}" /> | |
| 15 | +</div> | |
| 16 | +</fieldset> | |
| 17 | +</form> | ... | ... |
templates/ktcore/action/checkout.smarty
| ... | ... | @@ -4,12 +4,6 @@ anyone else changing the document and placing it into the document |
| 4 | 4 | management system.{/i18n}</p> |
| 5 | 5 | |
| 6 | 6 | {assign var=iDocumentId value=$context->oDocument->getId()} |
| 7 | -{capture assign=link} | |
| 8 | -{"viewDocument"|generateControllerUrl:"fDocumentId=$iDocumentId"} | |
| 9 | -{/capture} | |
| 10 | -<p class="descriptiveText">{i18n arg_link=$link}If you do not intend to edit the document, and you | |
| 11 | -do not wish to prevent others from changing the document, you should | |
| 12 | -<a href="#link#">cancel this checkout</a>.{/i18n}</p> | |
| 13 | 7 | |
| 14 | 8 | <form method="POST" action="{$smarty.server.PHP_SELF}"> |
| 15 | 9 | <fieldset><legend>{i18n}Checkout{/i18n}</legend> | ... | ... |
templates/ktcore/metadata/listFieldsets.smarty
| ... | ... | @@ -8,19 +8,18 @@ |
| 8 | 8 | <table class="listing" cellpadding="1.5em" cellspacing="0"> |
| 9 | 9 | <thead> |
| 10 | 10 | <tr> |
| 11 | - <th colspan="2">{i18n}Name{/i18n}</th> | |
| 12 | - <th>{i18n}Generic{/i18n}</th> | |
| 11 | + <th>{i18n}Name{/i18n}</th> | |
| 12 | + <th>{i18n}Is Generic{/i18n}</th> | |
| 13 | 13 | <th>{i18n}Fields{/i18n}</th> |
| 14 | + <th>{i18n}Edit{/i18n}</th> | |
| 15 | + <th>{i18n}Delete{/i18n}</th> | |
| 14 | 16 | </tr> |
| 15 | 17 | </thead> |
| 16 | 18 | <tbody> |
| 17 | 19 | {foreach from=$fieldsets item=oFieldset} |
| 18 | 20 | <tr> |
| 19 | - <td> | |
| 20 | - <a href="?action=delete&fFieldsetId={$oFieldset->getId()}" class="ktAction ktDelete">{i18n}Delete{/i18n}</a> | |
| 21 | - </td> | |
| 22 | 21 | <td> |
| 23 | - <a href="?action=edit&fFieldsetId={$oFieldset->getId()}"> { $oFieldset->getName() } | |
| 22 | + { $oFieldset->getName() } | |
| 24 | 23 | </a> |
| 25 | 24 | </td> |
| 26 | 25 | <td> |
| ... | ... | @@ -33,15 +32,22 @@ |
| 33 | 32 | <td> |
| 34 | 33 | {assign var="aFields" value=$oFieldset->getFields()} |
| 35 | 34 | {if $aFields} |
| 36 | -<ul> | |
| 37 | -{foreach from=$aFields item=oField} | |
| 38 | - <li>{$oField->getName()}</li> | |
| 35 | + | |
| 36 | +{foreach from=$aFields item=oField name=fields} | |
| 37 | +{$oField->getName()}{if (!$smarty.foreach.fields.last)}, {/if} | |
| 39 | 38 | {/foreach} |
| 40 | -</ul> | |
| 39 | + | |
| 41 | 40 | {else} |
| 42 | - | |
| 41 | +— | |
| 43 | 42 | {/if} |
| 44 | 43 | </td> |
| 44 | + <td> | |
| 45 | + <a href="?action=edit&fFieldsetId={$oFieldset->getId()}" class="ktAction ktEdit">{i18n}Edit{/i18n}</a> | |
| 46 | + </td> | |
| 47 | + <td> | |
| 48 | + <a href="?action=delete&fFieldsetId={$oFieldset->getId()}" class="ktAction ktDelete">{i18n}Delete{/i18n}</a> | |
| 49 | + </td> | |
| 50 | + | |
| 45 | 51 | </tr> |
| 46 | 52 | </tbody> |
| 47 | 53 | {/foreach} | ... | ... |
view.php
| ... | ... | @@ -139,6 +139,7 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { |
| 139 | 139 | $aTemplateData = array( |
| 140 | 140 | "context" => $this, |
| 141 | 141 | "sCheckoutUser" => $checkout_user, |
| 142 | + "isCheckoutUser" => ($this->oUser->getId() == $oDocument->getCheckedOutUserId()), | |
| 142 | 143 | "document_id" => $document_id, |
| 143 | 144 | "document" => $oDocument, |
| 144 | 145 | "document_data" => $document_data, | ... | ... |