From 66abd22ee539f6e10ea5afa0fcd6b20d88dc9afd Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Fri, 5 May 2017 15:35:39 +1200 Subject: [PATCH] FIX Allow linking existing documents to document sets via add existing upload field --- code/cms/DMSDocumentAddController.php | 13 ++++++------ javascript/DMSDocumentAddExistingField.js | 8 ++++---- javascript/DMSUploadField_addtemplate.js | 4 ++-- tests/DMSTest.php | 8 ++++---- tests/dmstest.yml | 20 +++++++++---------- tests/extensions/DMSSiteTreeExtensionTest.php | 5 ++--- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/code/cms/DMSDocumentAddController.php b/code/cms/DMSDocumentAddController.php index 77c4374..03691ca 100644 --- a/code/cms/DMSDocumentAddController.php +++ b/code/cms/DMSDocumentAddController.php @@ -218,16 +218,17 @@ class DMSDocumentAddController extends LeftAndMain return Convert::raw2json($return); } + /** + * Link an existing document to the given document set ID + * @return string JSON + */ public function linkdocument() { $return = array('error' => _t('UploadField.FIELDNOTSET', 'Could not add document to page')); -$return = array('error' => 'testing'); -return Convert::raw2json($return); - $page = $this->currentPage(); - if (!empty($page)) { + $documentSet = $this->getCurrentDocumentSet(); + if (!empty($documentSet)) { $document = DMSDocument::get()->byId($this->getRequest()->getVar('documentID')); - // @todo add sets - $document->addPage($page); + $documentSet->Documents()->add($document); $buttonText = '