Commit a24f1962e17a1a5998d171ee2a6e3fa56ee8a5e1
1 parent
1a396b9c
corrected version_history and metadata history.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4268 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
4 changed files
with
117 additions
and
20 deletions
presentation/lookAndFeel/knowledgeTree/documentmanagement/editDocument.php
| ... | ... | @@ -246,8 +246,26 @@ class KTEditDocumentDispatcher extends KTStandardDispatcher { |
| 246 | 246 | //return '<pre>' . print_r($field_values, true) . '</pre>'; |
| 247 | 247 | $this->startTransaction(); |
| 248 | 248 | |
| 249 | + $res = KTDocumentUtil::createMetadataVersion($oDocument); | |
| 250 | + if (PEAR::isError($res)) { | |
| 251 | + $this->errorRedirectToMain('Unable to create a metadata version of the document.'); | |
| 252 | + } | |
| 253 | + | |
| 254 | + $oDocument->setLastModifiedDate(getCurrentDateTime()); | |
| 255 | + $oDocument->setModifiedUserId($this->oUser->getId()); | |
| 256 | + $oDocumentTransaction = & new DocumentTransaction($oDocument->getID(), 'update metadata.', UPDATE); | |
| 249 | 257 | |
| 258 | + $res = $oDocumentTransaction->create(); | |
| 259 | + if (PEAR::isError($res)) { | |
| 260 | + $this->errorRedirectToMain('Failed to create transaction.'); | |
| 261 | + } | |
| 262 | + | |
| 263 | + $res = $oDocument->update(); | |
| 264 | + if (PEAR::isError($res)) { | |
| 265 | + $this->errorRedirectToMain('Failed to change basic details about the document..'); | |
| 266 | + } | |
| 250 | 267 | $res = KTDocumentUtil::saveMetadata($oDocument, $field_values); |
| 268 | + | |
| 251 | 269 | if (PEAR::isError($res)) { |
| 252 | 270 | $this->rollbackTransaction(); |
| 253 | 271 | ... | ... |
presentation/lookAndFeel/knowledgeTree/documentmanagement/view.php
| ... | ... | @@ -185,6 +185,45 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | |
| 188 | + function do_versionhistory() { | |
| 189 | + // this is the list of documents past. | |
| 190 | + $document_data = array(); | |
| 191 | + $document_id = KTUtil::arrayGet($_REQUEST, 'fDocumentId'); | |
| 192 | + if ($document_id === null) { | |
| 193 | + $this->oPage->addError('No document was requested. Please <a href="/presentation/lookAndFeel/knowledgeTree/browse.php">browse</a> for one.'); | |
| 194 | + return $this->do_error(); | |
| 195 | + } | |
| 196 | + $document_data["document_id"] = $document_id; | |
| 197 | + | |
| 198 | + // try get the document. | |
| 199 | + $oDocument =& Document::get($document_id); | |
| 200 | + if (PEAR::isError($oDocument)) { | |
| 201 | + $this->oPage->addError('The document you attempted to retrieve is invalid. Please <a href="/presentation/lookAndFeel/knowledgeTree/browse.php">browse</a> for one.'); | |
| 202 | + return $this->do_error(); | |
| 203 | + } | |
| 204 | + // fixme check perms | |
| 205 | + | |
| 206 | + $this->oDocument =& $oDocument; | |
| 207 | + $this->aBreadcrumbs = array_merge($this->aBreadcrumbs, KTBrowseUtil::breadcrumbsForDocument($oDocument)); | |
| 208 | + $this->oPage->setBreadcrumbDetails("history"); | |
| 209 | + $this->addPortlets("History"); | |
| 210 | + | |
| 211 | + $aVersions = Document::getByLiveDocument($oDocument); | |
| 212 | + //var_dump($aVersions); | |
| 213 | + | |
| 214 | + // render pass. | |
| 215 | + $this->oPage->title = "Document History : " . $oDocument->getName(); | |
| 216 | + $oTemplating = new KTTemplating; | |
| 217 | + $oTemplate = $oTemplating->loadTemplate("kt3/document/metadata_history"); | |
| 218 | + $aTemplateData = array( | |
| 219 | + "context" => $this, | |
| 220 | + "document_id" => $document_id, | |
| 221 | + "document" => $oDocument, | |
| 222 | + "versions" => $aVersions, | |
| 223 | + ); | |
| 224 | + return $oTemplate->render($aTemplateData); | |
| 225 | + } | |
| 226 | + | |
| 188 | 227 | // FIXME refactor out the document-info creation into a single utility function. |
| 189 | 228 | // this gets in: |
| 190 | 229 | // fDocumentId (document to compare against) |
| ... | ... | @@ -219,17 +258,20 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { |
| 219 | 258 | return $this->do_error(); |
| 220 | 259 | } |
| 221 | 260 | |
| 222 | - // FIXME when transaction history accurately stores metadata_version, this is no longer required. | |
| 223 | - // FIXME detect that the metadata_version was "manufactured" | |
| 224 | - // <testing> | |
| 225 | - $oComparison =& $oDocument; | |
| 226 | - $comparison_data =& $document_data; // no copy. | |
| 227 | - | |
| 228 | - // </testing> | |
| 229 | - | |
| 230 | - | |
| 261 | + $oComparison =& Document::get($comparison_version); | |
| 262 | + if (PEAR::isError($oComparison)) { | |
| 263 | + $this->errorRedirectToMain('Invalid document to compare against.'); | |
| 264 | + } | |
| 265 | + $comparison_data = array(); | |
| 266 | + $comparison_data['document_id'] = $oComparison->getId(); | |
| 267 | + | |
| 231 | 268 | $document_data["document"] = $oDocument; |
| 269 | + $comparison_data['document'] = $oComparison; | |
| 270 | + | |
| 232 | 271 | $document_data["document_type"] =& DocumentType::get($oDocument->getDocumentTypeID()); |
| 272 | + $comparison_data["document_type"] =& DocumentType::get($oComparison->getDocumentTypeID()); | |
| 273 | + | |
| 274 | + // follow twice: once for normal, once for comparison. | |
| 233 | 275 | $is_valid_doctype = true; |
| 234 | 276 | |
| 235 | 277 | if (PEAR::isError($document_data["document_type"])) { |
| ... | ... | @@ -247,9 +289,16 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { |
| 247 | 289 | |
| 248 | 290 | $document_data["field_values"] = $field_values; |
| 249 | 291 | |
| 292 | + $mdlist =& DocumentFieldLink::getList(array('document_id = ?', array($comparison_version))); | |
| 293 | + | |
| 294 | + $field_values = array(); | |
| 295 | + foreach ($mdlist as $oFieldLink) { | |
| 296 | + $field_values[$oFieldLink->getDocumentFieldID()] = $oFieldLink->getValue(); | |
| 297 | + } | |
| 298 | + | |
| 299 | + $comparison_data["field_values"] = $field_values; | |
| 300 | + | |
| 250 | 301 | |
| 251 | - // FIXME generate portlets | |
| 252 | - // FIXME generate breadcrumb | |
| 253 | 302 | |
| 254 | 303 | // Fieldset generation. |
| 255 | 304 | // |
| ... | ... | @@ -281,11 +330,7 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { |
| 281 | 330 | array_push($fieldsets, new $displayClass($oFieldset)); |
| 282 | 331 | } |
| 283 | 332 | } |
| 284 | - | |
| 285 | - // <testing> | |
| 286 | - $document_data["is_manufactured"] = 1; | |
| 287 | - // </testing> | |
| 288 | - | |
| 333 | + | |
| 289 | 334 | // FIXME handle ad-hoc fieldsets. |
| 290 | 335 | |
| 291 | 336 | $oTemplating = new KTTemplating; |
| ... | ... | @@ -308,6 +353,11 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { |
| 308 | 353 | return ''; // allow normal rendering of errors. |
| 309 | 354 | // FIXME show something useful / generic. |
| 310 | 355 | } |
| 356 | + | |
| 357 | + function getUserForId($iUserId) { | |
| 358 | + $u = User::get($iUserId); | |
| 359 | + return $u->getName(); | |
| 360 | + } | |
| 311 | 361 | } |
| 312 | 362 | |
| 313 | 363 | $oDispatcher = new ViewDocumentDispatcher; | ... | ... |
templates/kt3/document/metadata_history.smarty
0 → 100644
| 1 | +<h2>Metadata History: {$document->getName()}</h2> | |
| 2 | + | |
| 3 | +<p class="descriptiveText">This lists the older versions of the document, as the metadata about it has been changed.</p> | |
| 4 | + | |
| 5 | + | |
| 6 | + <table class="document_history" summary="Document History for KnowledgeTree New UI Presentation" cellspacing="0"> | |
| 7 | + | |
| 8 | + <thead> | |
| 9 | + <tr> | |
| 10 | + <th class="username">User</th> | |
| 11 | + <th class="date">Content Version</th> | |
| 12 | + <th class="compare">Compare</th> | |
| 13 | + | |
| 14 | + </tr> | |
| 15 | + </thead> | |
| 16 | + <tbody> | |
| 17 | + <tr class="{cycle options=even,odd}"> | |
| 18 | + <td class="username">{$context->getUserForId($document->getModifiedUserId())}</td> | |
| 19 | + <td class="date">{$document->getMajorVersionNumber()}.{$document->getMinorVersionNumber()}</td> | |
| 20 | + <td class="compare">Current</td> | |
| 21 | + </tr> | |
| 22 | + | |
| 23 | + {foreach item=oVersion from=$versions} | |
| 24 | + <tr class="{cycle options=even,odd}"> | |
| 25 | + <td class="username">{$context->getUserForId($oVersion->getModifiedUserId())}</td> | |
| 26 | + <td class="date">{$oVersion->getMajorVersionNumber()}.{$oVersion->getMinorVersionNumber()}</td> | |
| 27 | + <td class="compare"><a href="{$smarty.server.PHP_SELF}?action=viewComparison&fDocumentId={$document->getId()}&fComparisonVersion={$oVersion->getId()}">compare with current</a></td> | |
| 28 | + </tr> | |
| 29 | + {/foreach} | |
| 30 | + </tbody> | |
| 31 | + | |
| 32 | + </table> | ... | ... |
templates/kt3/view_document_history.smarty
| ... | ... | @@ -11,7 +11,7 @@ |
| 11 | 11 | <th class="action">Action</th> |
| 12 | 12 | <th class="date">Date</th> |
| 13 | 13 | <th class="contentversion">Content version</th> |
| 14 | - <th class="comment" colspan="2">Comment</th> | |
| 14 | + <th class="comment">Comment</th> | |
| 15 | 15 | </tr> |
| 16 | 16 | </thead> |
| 17 | 17 | <tbody> |
| ... | ... | @@ -22,9 +22,6 @@ |
| 22 | 22 | <td class="date">{$aTransactionRow.datetime}</td> |
| 23 | 23 | <td class="contentversion">{$aTransactionRow.version}</td> |
| 24 | 24 | <td class="comment">{$aTransactionRow.comment}</td> |
| 25 | - <td class="compare"> | |
| 26 | - <a href="?action=viewComparison&fDocumentId={$document_id}&fComparisonVersion={$aTransactionRow.version}">Compare with current version</a> | |
| 27 | - </td> | |
| 28 | 25 | </tr> |
| 29 | 26 | {/foreach} |
| 30 | 27 | </tbody> | ... | ... |