浏览代码

sorting of addressbook_search fixed, thanks to the patch of Cor Bosman (xs4all)

teepe 23 年之前
父节点
当前提交
f8f2482615
共有 4 个文件被更改,包括 16 次插入13 次删除
  1. 12 1
      functions/addressbook.php
  2. 2 0
      src/addrbook_search.php
  3. 2 0
      src/addrbook_search_html.php
  4. 0 12
      src/addressbook.php

+ 12 - 1
functions/addressbook.php

@@ -314,7 +314,6 @@ class AddressBook {
         return $ret;
     }
 
-
     /*
      * Create a new address from $userdata, in backend $bnum.
      * Return the backend number that the/ address was added
@@ -511,4 +510,16 @@ class addressbook_backend {
 
 }
 
+/* Sort array by the key "name" */
+function alistcmp($a,$b) {
+    if ($a['backend'] > $b['backend']) {
+        return 1;
+    } else {
+        if ($a['backend'] < $b['backend']) {
+            return -1;
+        }
+    }
+    return (strtolower($a['name']) > strtolower($b['name'])) ? 1 : -1;
+}
+
 ?>

+ 2 - 0
src/addrbook_search.php

@@ -205,6 +205,7 @@ if ($show == 'form') {
             $res = $abook->list_addr($backend);
 
             if(is_array($res)) {
+                usort($res,'alistcmp');
                 display_result($res, false);
             } else {
                 echo '<P ALIGN=center><STRONG>' .
@@ -214,6 +215,7 @@ if ($show == 'form') {
             }
         } else {
             $res = $abook->list_addr();
+            usort($res,'alistcmp');
             display_result($res, true);
         }
 

+ 2 - 0
src/addrbook_search_html.php

@@ -168,6 +168,7 @@ if ($addrquery == '' || !empty($listall)) {
         $res = $abook->list_addr($backend);
 
         if (is_array($res)) {
+            usort($res,'alistcmp');
             addr_display_result($res, false);
         } else {
             echo '<P ALIGN=center><STRONG>' .
@@ -178,6 +179,7 @@ if ($addrquery == '' || !empty($listall)) {
 
     } else {
         $res = $abook->list_addr();
+        usort($res,'alistcmp');
         addr_display_result($res, true);
     }
     exit;

+ 0 - 12
src/addressbook.php

@@ -16,18 +16,6 @@ require_once('../functions/array.php');
 require_once('../functions/display_messages.php');
 require_once('../functions/addressbook.php');
 
-/* Sort array by the key "name" */
-function alistcmp($a,$b) {
-    if($a['backend'] > $b['backend']) {
-        return 1;
-    } else {
-        if($a['backend'] < $b['backend']) {
-            return -1;
-        }
-    }
-    return (strtolower($a['name']) > strtolower($b['name'])) ? 1 : -1;
-}
-
 /* Make an input field */
 function adressbook_inp_field($label, $field, $name, $size, $values, $add) {
     global $color;