Commit 07fd69fe773db8933b0965d167b8e7003f4e9365

Authored by Brad Shuttleworth
1 parent be8f7020

- make archive use new UI.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5838 c91229c3-7414-0410-bfa2-8a42b809f60b
plugins/ktcore/KTDocumentActions.php
... ... @@ -1210,32 +1210,62 @@ class KTDocumentArchiveAction extends KTDocumentAction {
1210 1210 return parent::getInfo();
1211 1211 }
1212 1212  
  1213 + function form_main() {
  1214 + $oForm = new KTForm;
  1215 + $oForm->setOptions(array(
  1216 + 'label' => _kt("Archive Document"),
  1217 + 'action' => 'archive',
  1218 + 'fail_action' => 'main',
  1219 + 'cancel_url' => KTBrowseUtil::getUrlForDocument($this->oDocument),
  1220 + 'submit_label' => _kt("Archive Document"),
  1221 + 'context' => &$this,
  1222 + ));
  1223 + $oForm->setWidgets(array(
  1224 + array('ktcore.widgets.reason', array(
  1225 + 'label' => _kt("Reason"),
  1226 + 'description' => _kt("Please specify why you are archiving this document. Please bear in mind that you can use a maximum of <strong>250</strong> characters."),
  1227 + 'name' => 'reason',
  1228 + )),
  1229 + ));
  1230 + $oForm->setValidators(array(
  1231 + array('ktcore.validators.string', array(
  1232 + 'test' => 'reason',
  1233 + 'max_length' => 250,
  1234 + 'output' => 'reason',
  1235 + )),
  1236 + ));
  1237 +
  1238 + return $oForm;
  1239 + }
  1240 +
1213 1241 function do_main() {
1214   - $this->oPage->setBreadcrumbDetails(_kt("archiving"));
  1242 + $this->oPage->setBreadcrumbDetails(_kt("Archive Document"));
1215 1243 $oTemplate =& $this->oValidator->validateTemplate('ktcore/action/archive');
1216   - $fields = array();
1217   - $fields[] = new KTStringWidget(_kt('Reason'), _kt('The reason for the archiving of this document. This will be displayed when the archived document is to be displayed.'), 'reason', "", $this->oPage, true);
  1244 +
  1245 + $oForm = $this->form_main();
1218 1246  
1219 1247 $oTemplate->setData(array(
1220 1248 'context' => &$this,
1221   - 'fields' => $fields,
  1249 + 'form' => $oForm,
1222 1250 ));
1223 1251 return $oTemplate->render();
1224 1252 }
1225 1253  
1226 1254 function do_archive() {
1227 1255  
1228   - $aErrorOptions = array(
1229   - 'redirect_to' => array('','fDocumentId=' . $this->oDocument->getId()),
1230   - 'message' => _kt("You must provide a reason"),
1231   - );
  1256 + $oForm = $this->form_main();
  1257 + $res = $oForm->validate();
  1258 + $data = $res['results'];
  1259 + if (!empty($res['errors'])) {
  1260 + return $oForm->handleError();
  1261 + }
1232 1262  
1233   - $sReason = $this->oValidator->validateString(KTUtil::arrayGet($_REQUEST, 'reason'), $aErrorOptions);
1234   -
  1263 + $sReason = $data['reason'];
1235 1264  
1236 1265 $this->startTransaction();
1237 1266 $this->oDocument->setStatusID(ARCHIVED);
1238   - if (!$this->oDocument->update()) {
  1267 + $res = $this->oDocument->update();
  1268 + if (PEAR::isError($res) || ($res === false)) {
1239 1269 $_SESSION['KTErrorMessage'][] = _kt("There was a database error while trying to archive this file");
1240 1270 controllerRedirect('viewDocument', 'fDocumentId=' . $this->oDocument->getId());
1241 1271 exit(0);
... ...
templates/ktcore/action/archive.smarty
  1 +<h2>{i18n arg_docname=$context->oDocument->getName()}Archive Document: #docname#{/i18n}</h2>
  2 +
1 3 <p class="descriptiveText">{i18n}Archiving a document changes the
2 4 document's state to invisible to non-administrative users. Only an
3 5 Administrator may unarchive a document. Please note that this is a
4 6 non-permanent change and does not delete the document from the
5 7 repository.{/i18n}</p>
6 8  
7   -{assign var=iDocumentId value=$context->oDocument->getId()}
8   -{capture assign=link}
9   -{"viewDocument"|generateControllerUrl:"fDocumentId=$iDocumentId"}
10   -{/capture}
11   -
12   -<p class="descriptiveText">{i18n arg_link=$link}If you do not intend to
13   -archive this document, you should <a href="#link#">cancel the
14   -archive</a>.{/i18n}</p>
15   -
16   -<form method="POST" action="{$smarty.server.PHP_SELF}">
17   -<fieldset><legend>{i18n}Archive{/i18n}</legend>
18   -<input type="hidden" name="action" value="archive" />
19   -<input type="hidden" name="fDocumentId" value="{$iDocumentId}" />
20   -{foreach from=$fields item=oWidget }
21   - {$oWidget->render()}
22   -{/foreach}
23   -
24   -<div class="form_actions">
25   -<input type="submit" name="submit[archive]" value="{i18n}Archive{/i18n}" />
26   -<input type="submit" name="submit[cancel]" value="{i18n}Cancel{/i18n}" />
27   -</div>
28   -</fieldset>
29   -</form>
  9 +{$form->render()}
... ...
templates/ktcore/action/assistance.smarty
  1 +<h2>{i18n arg_docname=$context->oDocument->getName()}Request Assistance: #docname#{/i18n}</h2>
  2 +
1 3 <p class="descriptiveText">{i18n}If you are unable to perform an action
2 4 on this document that you think you should be able to, or wish to
3 5 request a change in location, metadata values, or workflow status, you
... ...