diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/editDocument.php b/presentation/lookAndFeel/knowledgeTree/documentmanagement/editDocument.php index 41fa0c9..2ebb44d 100644 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/editDocument.php +++ b/presentation/lookAndFeel/knowledgeTree/documentmanagement/editDocument.php @@ -246,8 +246,26 @@ class KTEditDocumentDispatcher extends KTStandardDispatcher { //return '
' . print_r($field_values, true) . ''; $this->startTransaction(); + $res = KTDocumentUtil::createMetadataVersion($oDocument); + if (PEAR::isError($res)) { + $this->errorRedirectToMain('Unable to create a metadata version of the document.'); + } + + $oDocument->setLastModifiedDate(getCurrentDateTime()); + $oDocument->setModifiedUserId($this->oUser->getId()); + $oDocumentTransaction = & new DocumentTransaction($oDocument->getID(), 'update metadata.', UPDATE); + $res = $oDocumentTransaction->create(); + if (PEAR::isError($res)) { + $this->errorRedirectToMain('Failed to create transaction.'); + } + + $res = $oDocument->update(); + if (PEAR::isError($res)) { + $this->errorRedirectToMain('Failed to change basic details about the document..'); + } $res = KTDocumentUtil::saveMetadata($oDocument, $field_values); + if (PEAR::isError($res)) { $this->rollbackTransaction(); diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/view.php b/presentation/lookAndFeel/knowledgeTree/documentmanagement/view.php index 55d2302..d261d7c 100644 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/view.php +++ b/presentation/lookAndFeel/knowledgeTree/documentmanagement/view.php @@ -185,6 +185,45 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { } + function do_versionhistory() { + // this is the list of documents past. + $document_data = array(); + $document_id = KTUtil::arrayGet($_REQUEST, 'fDocumentId'); + if ($document_id === null) { + $this->oPage->addError('No document was requested. Please browse for one.'); + return $this->do_error(); + } + $document_data["document_id"] = $document_id; + + // try get the document. + $oDocument =& Document::get($document_id); + if (PEAR::isError($oDocument)) { + $this->oPage->addError('The document you attempted to retrieve is invalid. Please browse for one.'); + return $this->do_error(); + } + // fixme check perms + + $this->oDocument =& $oDocument; + $this->aBreadcrumbs = array_merge($this->aBreadcrumbs, KTBrowseUtil::breadcrumbsForDocument($oDocument)); + $this->oPage->setBreadcrumbDetails("history"); + $this->addPortlets("History"); + + $aVersions = Document::getByLiveDocument($oDocument); + //var_dump($aVersions); + + // render pass. + $this->oPage->title = "Document History : " . $oDocument->getName(); + $oTemplating = new KTTemplating; + $oTemplate = $oTemplating->loadTemplate("kt3/document/metadata_history"); + $aTemplateData = array( + "context" => $this, + "document_id" => $document_id, + "document" => $oDocument, + "versions" => $aVersions, + ); + return $oTemplate->render($aTemplateData); + } + // FIXME refactor out the document-info creation into a single utility function. // this gets in: // fDocumentId (document to compare against) @@ -219,17 +258,20 @@ class ViewDocumentDispatcher extends KTStandardDispatcher { return $this->do_error(); } - // FIXME when transaction history accurately stores metadata_version, this is no longer required. - // FIXME detect that the metadata_version was "manufactured" - //
This lists the older versions of the document, as the metadata about it has been changed.
+ + +| User | +Content Version | +Compare | + +
|---|---|---|
| {$context->getUserForId($document->getModifiedUserId())} | +{$document->getMajorVersionNumber()}.{$document->getMinorVersionNumber()} | +Current | +
| {$context->getUserForId($oVersion->getModifiedUserId())} | +{$oVersion->getMajorVersionNumber()}.{$oVersion->getMinorVersionNumber()} | +compare with current | +