From afa7436f01cbf76dcc7edbdddfff8e06e5d6f529 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 28 Apr 2014 18:59:35 +0200 Subject: [PATCH] Fixing document list order see BT#7070 and BT#6548 Fixing be2304e4bb659a4f545a9f09d8d013c6c77f468d --- main/document/document.php | 4 +++- main/inc/lib/table_sort.class.php | 14 +++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/main/document/document.php b/main/document/document.php index f55b9ed2e7..4066e21fc1 100644 --- a/main/document/document.php +++ b/main/document/document.php @@ -761,6 +761,7 @@ $documentAndFolders = DocumentManager::get_all_document_data( $is_allowed_to_edit || $group_member_with_upload_rights, false ); + $count = 1; $jquery = null; @@ -1725,7 +1726,8 @@ $table = new SortableTableFromArrayConfig( $tableName, $column_show, $column_order, - 'ASC' + 'ASC', + true ); $query_vars = array(); if (isset($_GET['keyword'])) { diff --git a/main/inc/lib/table_sort.class.php b/main/inc/lib/table_sort.class.php index 70ebee512d..322d548f83 100644 --- a/main/inc/lib/table_sort.class.php +++ b/main/inc/lib/table_sort.class.php @@ -98,6 +98,7 @@ class TableSort if (!is_array($data) || empty($data)) { return array(); } + if ($column != strval(intval($column))) { // Probably an attack return $data; @@ -125,7 +126,7 @@ class TableSort } } - //This fixs only works in the document tool when ordering by name + //This fixes only works in the document tool when ordering by name if ($doc_filter && in_array($type, array(SORT_STRING))) { $folder_to_sort = array(); $new_data = array(); @@ -138,21 +139,23 @@ class TableSort } $new_data[$document['id']] = $document; } + if ($direction == SORT_ASC) { if (!empty($docs_to_sort)) { - api_natrsort($docs_to_sort); + api_natsort($docs_to_sort); } if (!empty($folder_to_sort)) { - api_natrsort($folder_to_sort); + api_natsort($folder_to_sort); } } else { if (!empty($docs_to_sort)) { - api_natsort($docs_to_sort); + api_natrsort($docs_to_sort); } if (!empty($folder_to_sort)) { - api_natsort($folder_to_sort); + api_natrsort($folder_to_sort); } } + $new_data_order = array(); if (!empty($docs_to_sort)) { foreach($docs_to_sort as $id => $document) { @@ -161,6 +164,7 @@ class TableSort } } } + if (!empty($folder_to_sort)) { foreach($folder_to_sort as $id => $document) { if (isset($new_data[$id])) {