Change sorting order on ML display to use sort_name.
authorAnne Limoges <anne.limoges_git@polytechnique.org>
Wed, 9 Apr 2014 18:48:47 +0000 (20:48 +0200)
committerNicolas Iooss <nicolas.iooss_git@polytechnique.org>
Wed, 9 Apr 2014 20:43:18 +0000 (22:43 +0200)
classes/profile.php
classes/user.php
modules/lists/lists.inc.php

index 7065598..6722784 100644 (file)
@@ -372,6 +372,11 @@ class Profile implements PlExportable
         return $this->short_name;
     }
 
+    public function sortName()
+    {
+        return $this->sort_name;
+    }
+
     public function firstName()
     {
         return $this->firstname_ordinary;
@@ -1137,7 +1142,7 @@ class Profile implements PlExportable
                                      IF (ppn.firstname_ordinary = \'\', ppn.firstname_main, ppn.firstname_ordinary) AS firstname_ordinary,
                                      IF (ppn.lastname_ordinary = \'\', ppn.lastname_main, ppn.lastname_ordinary) AS lastname_ordinary,
                                      pd.yourself, pd.promo, pd.short_name, pd.public_name AS full_name,
-                                     pd.directory_name, pd.public_name, pd.private_name,
+                                     pd.directory_name, pd.public_name, pd.private_name, pd.sort_name,
                                      IF (pp.pub >= {?}, pp.display_tel, NULL) AS mobile,
                                      (ph.pub >= {?} AND ph.attach IS NOT NULL) AS has_photo, ph.pub as photo_pub,
                                      ph.x AS photo_width, ph.y AS photo_height,
index e380dac..eb91985 100644 (file)
@@ -165,7 +165,7 @@ class User extends PlUser
                                       IF(ef.email IS NULL, NULL, CONCAT(ef.email, \'@\', df.name)) AS forlife_alternate,
                                       IF(eb.email IS NULL, NULL, CONCAT(eb.email, \'@\', mb.name)) AS bestalias,
                                       (er.redirect IS NULL AND a.state = \'active\' AND FIND_IN_SET(\'mail\', at.perms)) AS lost,
-                                      a.email, a.full_name, a.directory_name, a.display_name, a.sex = \'female\' AS gender,
+                                      a.email, a.full_name, a.directory_name, a.display_name, a.sort_name, a.sex = \'female\' AS gender,
                                       IF(a.state = \'active\', CONCAT(at.perms, \',\', IF(a.user_perms IS NULL, \'\', a.user_perms)), \'\') AS perms,
                                       a.user_perms, a.email_format, a.is_admin, a.state, a.type, at.description AS type_description, a.skin,
                                       FIND_IN_SET(\'watch\', a.flags) AS watch, a.comment,
@@ -352,6 +352,14 @@ class User extends PlUser
         return $this->profile()->directory_name;
     }
 
+    public function sortName()
+    {
+        if (!$this->hasProfile()) {
+            return $this->sort_name;
+        }
+        return $this->profile()->sort_name;
+    }
+
     static public function compareDirectoryName($a, $b)
     {
         return strcasecmp(replace_accent($a->directoryName()), replace_accent($b->directoryName()));
index 4e90b4c..233fc94 100644 (file)
@@ -69,7 +69,7 @@ function list_sort_owners($emails, $tri_promo = true)
             $name = $member['email'];
         } else {
             $category = $member['user']->category();
-            $name = $member['user']->directoryName();
+            $name = $member['user']->sortName();
         }
         if (empty($category)) {
             $category = "AAAAA";