From 9fe54f18bc9ad04f851698065f57b889b2e90914 Mon Sep 17 00:00:00 2001 From: Julian Seidenberg Date: Fri, 21 Sep 2012 16:10:16 +1200 Subject: [PATCH] BUGFIX: newly added documents now always appear at the top of the list --- code/DMSDocument.php | 2 ++ code/cms/DMSUploadField.php | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/code/DMSDocument.php b/code/DMSDocument.php index 69831c7..2abf1ab 100644 --- a/code/DMSDocument.php +++ b/code/DMSDocument.php @@ -44,6 +44,8 @@ class DMSDocument extends DataObject implements DMSDocumentInterface { */ function addPage($pageObject) { $this->Pages()->add($pageObject); + + DB::query("UPDATE DMSDocument_Pages SET DocumentSort=DocumentSort+1 WHERE SiteTreeID = $pageObject->ID"); } /** diff --git a/code/cms/DMSUploadField.php b/code/cms/DMSUploadField.php index 0961e9d..ac71288 100644 --- a/code/cms/DMSUploadField.php +++ b/code/cms/DMSUploadField.php @@ -45,9 +45,6 @@ class DMSUploadField extends UploadField { // Relate to the underlying page being edited. // Not applicable when editing the document itself and replacing it. $doc->addPage($record); - - //increase the sort value by one for the newly uploaded document and every other document attached to this page - DB::query("UPDATE DMSDocument_Pages SET DocumentSort=DocumentSort+1 WHERE SiteTreeID = $record->ID"); } return $doc;