diff --git a/Model/Wiki.php b/Model/Wiki.php
index 5b79bd0..fdac61e 100755
--- a/Model/Wiki.php
+++ b/Model/Wiki.php
@@ -102,6 +102,9 @@ public function reorderPages($project_id, $src_wiki_id, $target_wiki_id){
// retrieve wiki pages
$wikiPages = $this->getWikipages($project_id);
+ // echo json_encode($wikiPages), true;
+
+ // echo "project_id: " . $project_id . " src_wiki_id: " . $src_wiki_id . " target_wiki_id: " . $target_wiki_id . "
";
// change order of each in for loop, move matching id to one before target
$orderColumn = 1;
$targetColumn = 1;
@@ -114,21 +117,33 @@ public function reorderPages($project_id, $src_wiki_id, $target_wiki_id){
$orderColumn++;
$targetColumn = $orderColumn;
}
+ // echo " id: " . $id . " oldOrderColumn: " . $oldOrderColumn . " orderColumn: " . $orderColumn . "
";
if ($id == $src_wiki_id) {
$oldSourceColumn = $oldOrderColumn;
} else {
if ($oldOrderColumn != $orderColumn) {
- $this->savePagePosition($id, $orderColumn);
+ // echo "updating ". $id ." column to ". $orderColumn . "
";
+ $result = $this->savePagePosition($id, $orderColumn);
+ if(!$result){
+ return false;
+ }
}
- $orderColumn++;
}
+ $orderColumn++;
}
// update moved src
+ // echo "oldSourceColumn: " . $oldSourceColumn . " targetColumn: " . $targetColumn . "
";
if($oldSourceColumn != $targetColumn -1){
- $this->savePagePosition($src_wiki_id, $orderColumn);
+ // echo "updating src ". $src_wiki_id . " column to ". $targetColumn -1 . "
";
+ $result = $this->savePagePosition($src_wiki_id, $orderColumn -1);
+ if(!$result){
+ return false;
+ }
}
+
+ return true;
}
public function savePagePosition($wiki_id, $orderColumn) {