]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix sorting in the backend 3889/head
authorMorris Jobke <hey@morrisjobke.de>
Wed, 22 Mar 2017 23:11:09 +0000 (17:11 -0600)
committerMorris Jobke <hey@morrisjobke.de>
Thu, 23 Mar 2017 21:41:25 +0000 (15:41 -0600)
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
core/js/sharedialogview.js
core/js/tests/specs/sharedialogviewSpec.js
lib/private/User/Database.php
lib/private/User/Manager.php

index 78168336bb73c26cbe1b37f52889b7fcb5c5b1e0..a63960da2b8bd981e8c5595c59dfef8d5ac04652 100644 (file)
                                                var suggestions = users.concat(groups).concat(remotes).concat(emails).concat(lookup);
 
                                                if (suggestions.length > 0) {
-                                                       suggestions.sort(function (a, b) {
-                                                               return OC.Util.naturalSortCompare(a.label, b.label);
-                                                       });
                                                        $shareWithField
                                                                .autocomplete("option", "autoFocus", true);
 
index 7e3232f86e17f16c368da2906572e029ce71f728..307adea85ffd5d409d79b27ee96aee347c3ef4a4 100644 (file)
@@ -490,80 +490,6 @@ describe('OC.Share.ShareDialogView', function() {
                });
        });
        describe('autocompletion of users', function() {
-               it('is sorted naturally', function () {
-                       dialog.render();
-                       var response = sinon.stub();
-                       dialog.autocompleteHandler({term: 'p'}, response);
-                       var jsonData = JSON.stringify({
-                               'ocs' : {
-                                       'meta' : {
-                                               'status' : 'success',
-                                               'statuscode' : 100,
-                                               'message' : null
-                                       },
-                                       'data' : {
-                                               'exact' : {
-                                                       'users'  : [],
-                                                       'groups' : [],
-                                                       'remotes': []
-                                               },
-                                               'users'  : [{
-                                                       "label": "Peter A.",
-                                                       "value": {
-                                                               "shareType": 0,
-                                                               "shareWith": "Peter A."
-                                                       }
-                                               },
-                                                       {
-                                                               "label": "Petra",
-                                                               "value": {
-                                                                       "shareType": 0,
-                                                                       "shareWith": "Petra"
-                                                               }
-                                                       },
-                                                       {
-                                                               "label": "peter B.",
-                                                               "value": {
-                                                                       "shareType": 0,
-                                                                       "shareWith": "peter B."
-                                                               }
-                                                       }],
-                                               'groups' : [],
-                                               'remotes': []
-                                       }
-                               }
-                       });
-
-                       fakeServer.requests[0].respond(
-                               200,
-                               {'Content-Type': 'application/json'},
-                               jsonData
-                       );
-
-                       expect(response.calledWithExactly([
-                               {
-                                       "label": "Peter A.",
-                                       "value": {
-                                               "shareType": 0,
-                                               "shareWith": "Peter A."
-                                       }
-                               },
-                               {
-                                       "label": "peter B.",
-                                       "value": {
-                                               "shareType": 0,
-                                               "shareWith": "peter B."
-                                       }
-                               },
-                               {
-                                       "label": "Petra",
-                                       "value": {
-                                               "shareType": 0,
-                                               "shareWith": "Petra"
-                                       }
-                               }
-                       ])).toEqual(true);
-               });
                it('triggers autocomplete display and focus with data when ajax search succeeds', function () {
                        dialog.render();
                        var response = sinon.stub();
index a281572ad55848836dee2013ce791ec7b344274c..dfbd995fb2ef2f4951c924d95b29556afbcddc78 100644 (file)
@@ -193,7 +193,7 @@ class Database extends Backend implements IUserBackend {
 
                $displayNames = array();
                $query = \OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users`'
-                       . $searchLike .' ORDER BY `uid` ASC', $limit, $offset);
+                       . $searchLike .' ORDER BY LOWER(`displayname`), LOWER(`uid`) ASC', $limit, $offset);
                $result = $query->execute($parameters);
                while ($row = $result->fetchRow()) {
                        $displayNames[$row['uid']] = $row['displayname'];
@@ -279,7 +279,7 @@ class Database extends Backend implements IUserBackend {
                        $searchLike = ' WHERE LOWER(`uid`) LIKE LOWER(?)';
                }
 
-               $query = \OC_DB::prepare('SELECT `uid` FROM `*PREFIX*users`' . $searchLike . ' ORDER BY `uid` ASC', $limit, $offset);
+               $query = \OC_DB::prepare('SELECT `uid` FROM `*PREFIX*users`' . $searchLike . ' ORDER BY LOWER(`uid`) ASC', $limit, $offset);
                $result = $query->execute($parameters);
                $users = array();
                while ($row = $result->fetchRow()) {
index 3d016700ee333968997cb80e97dbd6d5f379d153..77741efcc759fba28450242a6dc759073c010191 100644 (file)
@@ -254,7 +254,7 @@ class Manager extends PublicEmitter implements IUserManager {
                         * @var \OC\User\User $a
                         * @var \OC\User\User $b
                         */
-                       return strcmp($a->getDisplayName(), $b->getDisplayName());
+                       return strcmp(strtolower($a->getDisplayName()), strtolower($b->getDisplayName()));
                });
                return $users;
        }