From 83f67ca3d46650a5d8ad1bf985eef0214808223d Mon Sep 17 00:00:00 2001 From: Neil Blakey-Milner Date: Tue, 18 Apr 2006 14:48:05 +0000 Subject: [PATCH] Use newCopy() to create copies of existing metadata and content versions --- lib/documentmanagement/Document.inc | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/documentmanagement/Document.inc b/lib/documentmanagement/Document.inc index f2f70a9..627d873 100644 --- a/lib/documentmanagement/Document.inc +++ b/lib/documentmanagement/Document.inc @@ -508,11 +508,11 @@ class Document { // {{{ startNewMetadataVersion function startNewMetadataVersion($oUser) { $iUserId = KTUtil::getId($oUser); - $this->_oDocumentMetadataVersion->setId(-1); + $this->_oDocumentMetadataVersion =& $this->_oDocumentMetadataVersion->newCopy(); $this->_oDocumentMetadataVersion->bumpMetadataVersion(); $this->_oDocumentMetadataVersion->setVersionCreated(getCurrentDateTime()); $this->_oDocumentMetadataVersion->setVersionCreatorId($iUserId); - $this->_oDocumentMetadataVersion->create(); + $this->_oDocumentMetadataVersion->update(); $this->_oDocumentCore->setMetadataVersion($this->_oDocumentMetadataVersion->getMetadataVersion()); $this->_oDocumentCore->setMetadataVersionId($this->_oDocumentMetadataVersion->iId); } @@ -521,18 +521,13 @@ class Document { // {{{ startNewContentVersion function startNewContentVersion($oUser) { $iUserId = KTUtil::getId($oUser); - $this->_oDocumentContentVersion->setId(-1); - $res = $this->_oDocumentContentVersion->create(); - if (PEAR::isError($res)) { - var_dump($res); - return $res; - } - $this->_oDocumentMetadataVersion->setId(-1); + $this->_oDocumentContentVersion =& $this->_oDocumentContentVersion->newCopy(); + $this->_oDocumentMetadataVersion =& $this->_oDocumentMetadataVersion->newCopy(); $this->_oDocumentMetadataVersion->bumpMetadataVersion(); $this->_oDocumentMetadataVersion->setVersionCreated(getCurrentDateTime()); $this->_oDocumentMetadataVersion->setVersionCreatorId($iUserId); $this->_oDocumentMetadataVersion->setContentVersionId($this->_oDocumentContentVersion->getId()); - $res = $this->_oDocumentMetadataVersion->create(); + $res = $this->_oDocumentMetadataVersion->update(); if (PEAR::isError($res)) { var_dump($res); return $res; -- libgit2 0.21.4