From f365ff3ada8e4e0a24813e7b19dd1059dc89fabb Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Wed, 24 Aug 2016 12:26:21 +0800 Subject: [PATCH] Fixed issue with reordering retrieving more than one record --- classes/template.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/classes/template.php b/classes/template.php index 5fc04d4..33e7f3a 100644 --- a/classes/template.php +++ b/classes/template.php @@ -329,8 +329,15 @@ class template { } else { // Must be down. $sequence = $moveitem->sequence + 1; } - // Get the item we will be swapping with it. - $swapitem = $DB->get_record($table, array('sequence' => $sequence)); + + // Get the item we will be swapping with. Make sure it is related to the same template (if it's + // a page) or the same page (if it's an element). + if ($itemname == 'page') { + $params = array('templateid' => $moveitem->templateid); + } else { // Must be an element. + $params = array('pageid' => $moveitem->pageid); + } + $swapitem = $DB->get_record($table, $params + array('sequence' => $sequence)); } // Check that there is an item to move, and an item to swap it with.