Commit 57776dcdfb3c794175127061cac1f3fac374a84f

Authored by Megan Watson
1 parent 47bc4537

KTS-1489

"Unarchival action not recorded within document transaction history"
Fixed. Added a transaction in.

KTS-3029
"On restoring archived documents, all documents in the list are selected"
Fixed. Removed the collection widget which only works properly for single selections.

Committed by: Megan Watson
Reviewed by: Conrad Vermeulen




git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@8049 c91229c3-7414-0410-bfa2-8a42b809f60b
plugins/ktcore/admin/archivedDocuments.php
... ... @@ -5,32 +5,32 @@
5 5 * KnowledgeTree Open Source Edition
6 6 * Document Management Made Simple
7 7 * Copyright (C) 2004 - 2008 The Jam Warehouse Software (Pty) Limited
8   - *
  8 + *
9 9 * This program is free software; you can redistribute it and/or modify it under
10 10 * the terms of the GNU General Public License version 3 as published by the
11 11 * Free Software Foundation.
12   - *
  12 + *
13 13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 16 * details.
17   - *
  17 + *
18 18 * You should have received a copy of the GNU General Public License
19 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20   - *
  20 + *
21 21 * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
22 22 * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com.
23   - *
  23 + *
24 24 * The interactive user interfaces in modified source and object code versions
25 25 * of this program must display Appropriate Legal Notices, as required under
26 26 * Section 5 of the GNU General Public License version 3.
27   - *
  27 + *
28 28 * In accordance with Section 7(b) of the GNU General Public License version 3,
29 29 * these Appropriate Legal Notices must retain the display of the "Powered by
30   - * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  30 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
31 31 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
32   - * must display the words "Powered by KnowledgeTree" and retain the original
33   - * copyright notice.
  32 + * must display the words "Powered by KnowledgeTree" and retain the original
  33 + * copyright notice.
34 34 * Contributor( s): ______________________________________
35 35 *
36 36 */
... ... @@ -53,12 +53,12 @@ require_once(KT_LIB_DIR . &quot;/documentmanagement/PhysicalDocumentManager.inc&quot;);
53 53  
54 54 // FIXME chain in a notification alert for un-archival requests.
55 55 class KTArchiveTitle extends TitleColumn {
56   -
  56 +
57 57 function renderDocumentLink($aDataRow) {
58 58 $outStr .= $aDataRow["document"]->getName();
59 59 return $outStr;
60   - }
61   -
  60 + }
  61 +
62 62 function buildFolderLink($aDataRow) {
63 63 return KTUtil::addQueryString($_SERVER['PHP_SELF'], sprintf('fFolderId=%d', $aDataRow["folder"]->getId()));
64 64 }
... ... @@ -68,94 +68,88 @@ class ArchivedDocumentsDispatcher extends KTAdminDispatcher {
68 68 var $sHelpPage = 'ktcore/admin/archived documents.html';
69 69 function do_main () {
70 70 $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Archived Documents'));
71   -
  71 +
72 72 $this->oPage->setBreadcrumbDetails(_kt('browse'));
73   -
  73 +
74 74 $oFolder = Folder::get(KTUtil::arrayGet($_REQUEST, 'fFolderId', 1));
75   - if (PEAR::isError($oFolder)) {
  75 + if (PEAR::isError($oFolder)) {
76 76 $this->errorRedirectToMain(_kt('Invalid folder selected.'));
77 77 exit(0);
78 78 }
79   -
80   - // Setup the collection for move display.
81   -
  79 +
  80 + // Setup the collection for restore display.
82 81 $aBaseParams = array();
83 82  
84 83 $collection = new AdvancedCollection();
85 84  
86 85 $oCR =& KTColumnRegistry::getSingleton();
87   -
88   - // selection col
89 86 $col = $oCR->getColumn('ktcore.columns.selection');
90   - $col->setOptions(array('show_folders' => false, 'rangename' => '_d[]'));
  87 + $aColOptions = array();
  88 + //$aColOptions['qs_params'] = kt_array_merge($aBaseParams, array('fFolderId'=>$oFolder->getId()));
  89 + $aColOptions['show_folders'] = false;
  90 + $aColOptions['show_documents'] = true;
  91 + $aColOptions['rangename'] = '_d[]';
  92 + $col->setOptions($aColOptions);
91 93 $collection->addColumn($col);
92   -
93   - // title col
  94 +
94 95 $col = $oCR->getColumn('ktcore.columns.title');
  96 + //$col->setOptions(array('qs_params'=>kt_array_merge($aBaseParams, array('action' => 'new', 'fFolderId'=>$oFolder->getId()))));
95 97 $col->setOptions(array('link_documents' => false));
96   -
97 98 $collection->addColumn($col);
98 99  
  100 + //$qObj = new BrowseQuery($iFolderId);
99 101 $qObj = new ArchivedBrowseQuery($oFolder->getId());
100 102 $collection->setQueryObject($qObj);
101 103  
102 104 $aOptions = $collection->getEnvironOptions();
103   - $aOptions['result_url'] = KTUtil::addQueryString($_SERVER['PHP_SELF'],
  105 + $aOptions['result_url'] = KTUtil::addQueryString($_SERVER['PHP_SELF'],
104 106 array(kt_array_merge($aBaseParams, array('fFolderId' => $oFolder->getId()))));
105 107  
106 108 $collection->setOptions($aOptions);
107 109  
108   - $oWF =& KTWidgetFactory::getSingleton();
109   - $oWidget = $oWF->get('ktcore.widgets.collection',
110   - array('label' => _kt('Target Documents'),
111   - 'description' => _kt('Use the folder collection and path below to browse to the folder containing the documents you wish to restore.'),
112   - 'required' => true,
113   - 'name' => 'browse',
114   - 'folder_id' => $oFolder->getId(),
115   - 'bcurl_params' => $aBaseParams,
116   - 'collection' => $collection));
  110 + $aURLParams = $aBaseParams;
  111 + $aURLParams['action'] = 'restore';
  112 + $aBreadcrumbs = KTUtil::generate_breadcrumbs($oFolder, $iFolderId, $aURLParams);
117 113  
118   -
119   - $oTemplating =& KTTemplating::getSingleton();
120   - $oTemplate = $oTemplating->loadTemplate("ktcore/document/admin/archivebrowse");
121 114 $aTemplateData = array(
122   - "context" => $this,
  115 + 'context' => $this,
123 116 'folder' => $oFolder,
124 117 'breadcrumbs' => $aBreadcrumbs,
125   - 'collection' => $oWidget,
  118 + 'collection' => $collection
126 119 );
127   -
128   - return $oTemplate->render($aTemplateData);
  120 +
  121 + $oTemplate =& $this->oValidator->validateTemplate('ktcore/document/admin/archivebrowse');
  122 + return $oTemplate->render($aTemplateData);
129 123 }
130   -
  124 +
131 125 /*
132 126 * Provide for "archived" browsing.
133 127 */
134 128 function do_browse() {
135   -
  129 +
136 130 }
137   -
  131 +
138 132 function do_confirm_restore() {
139 133 $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Archived Documents'));
140   -
141   - $selected_docs = KTUtil::arrayGet($_REQUEST, '_d', array());
142   -
  134 +
  135 + $selected_docs = KTUtil::arrayGet($_REQUEST, '_d', array());
  136 +
143 137 $this->oPage->setTitle(sprintf(_kt('Confirm Restore of %d documents'), count($selected_docs)));
144   -
  138 +
145 139 $this->oPage->setBreadcrumbDetails(sprintf(_kt('confirm restore of %d documents'), count($selected_docs)));
146   -
  140 +
147 141 $aDocuments = array();
148 142 foreach ($selected_docs as $doc_id) {
149 143 $oDoc =& Document::get($doc_id);
150   - if (PEAR::isError($oDoc) || ($oDoc === false)) {
  144 + if (PEAR::isError($oDoc) || ($oDoc === false)) {
151 145 $this->errorRedirectToMain(_kt('Invalid document id specified. Aborting restore.'));
152 146 } else if ($oDoc->getStatusId() != ARCHIVED) {
153 147 $this->errorRedirectToMain(sprintf(_kt('%s is not an archived document. Aborting restore.'), $oDoc->getName()));
154 148 }
155 149 $aDocuments[] = $oDoc;
156 150 }
157   -
158   -
  151 +
  152 +
159 153 $oTemplating =& KTTemplating::getSingleton();
160 154 $oTemplate = $oTemplating->loadTemplate('ktcore/document/admin/dearchiveconfirmlist');
161 155 $oTemplate->setData(array(
... ... @@ -167,22 +161,22 @@ class ArchivedDocumentsDispatcher extends KTAdminDispatcher {
167 161  
168 162 function do_finish_restore() {
169 163  
170   -
171   - $selected_docs = KTUtil::arrayGet($_REQUEST, 'selected_docs', array());
172   -
  164 +
  165 + $selected_docs = KTUtil::arrayGet($_REQUEST, 'selected_docs', array());
  166 +
173 167 $aDocuments = array();
174 168 foreach ($selected_docs as $doc_id) {
175 169 $oDoc =& Document::get($doc_id);
176   - if (PEAR::isError($oDoc) || ($oDoc === false)) {
  170 + if (PEAR::isError($oDoc) || ($oDoc === false)) {
177 171 $this->errorRedirectToMain(_kt('Invalid document id specified. Aborting restore.'));
178 172 } else if ($oDoc->getStatusId() != ARCHIVED) {
179 173 $this->errorRedirectToMain(sprintf(_kt('%s is not an archived document. Aborting restore.'), $oDoc->getName()));
180 174 }
181 175 $aDocuments[] = $oDoc;
182 176 }
183   -
  177 +
184 178 $this->startTransaction();
185   -
  179 +
186 180 foreach ($aDocuments as $oDoc) {
187 181 // FIXME find de-archival source.
188 182 // FIXME purge old notifications.
... ... @@ -192,11 +186,15 @@ class ArchivedDocumentsDispatcher extends KTAdminDispatcher {
192 186 if (PEAR::isError($res) || ($res == false)) {
193 187 $this->errorRedirectToMain(sprintf(_kt('%s could not be made "live".'), $oDoc->getName));
194 188 }
  189 + $oDocumentTransaction = & new DocumentTransaction($oDoc, _kt('Document restored.'), 'ktcore.transactions.update');
  190 + $oDocumentTransaction->create();
195 191 }
  192 +
196 193 $this->commitTransaction();
197 194 $msg = sprintf(_kt('%d documents made active.'), count($aDocuments));
198 195 $this->successRedirectToMain($msg);
199 196 }
  197 +
200 198 }
201 199  
202 200 ?>
... ...
templates/ktcore/document/admin/archivebrowse.smarty
... ... @@ -7,17 +7,23 @@ will typically be done within the system and will generate a
7 7 notification to you.{/i18n}
8 8 </p>
9 9  
  10 +<p>{i18n}Use the folder collection and path below to browse to the folder containing the documents you wish to restore.{/i18n}
  11 +</p>
  12 +<br />
  13 +
  14 +{foreach from=$breadcrumbs item=breadcrumb name=bc}
  15 + {if !$smarty.foreach.bc.last}
  16 + <a href="{$breadcrumb.url}">{$breadcrumb.name|sanitize}</a> &raquo;
  17 + {else}
  18 + {$breadcrumb.name|sanitize}
  19 + {/if}
  20 +{/foreach}
  21 +
10 22 <form method="POST" action="{$smarty.server.PHP_SELF}">
11 23 <input type="hidden" name="action" value="confirm_restore" />
12 24 <input type="hidden" name="fFolderId" value="{$folder->getId()}" />
13   -{foreach from=$collection_breadcrumbs item=breadcrumb name=bc}
14   -<a href="{$breadcrumb.url}">{$breadcrumb.name}</a>
15   -{if !$smarty.foreach.bc.last}
16   -&raquo;
17   -{/if}
18   -{/foreach}
19   -{$collection->render()}
20 25  
  26 +{$collection->render()}
21 27  
22 28 <div class="form_actions">
23 29 <input type="submit" name="submit[move]" value="{i18n}Restore{/i18n}" />
... ...