übersichtlichere Auswahlliste mit Realnames
Bernd Wurst

Bernd Wurst commited on 2013-01-21 17:28:12
Zeige 2 geänderte Dateien mit 14 Einfügungen und 8 Löschungen.

... ...
@@ -72,10 +72,10 @@ function find_users_for_customer($id)
72 72
 {
73 73
   $id = (int) $id;
74 74
   $return = array();
75
-  $result = db_query("SELECT uid, username FROM system.useraccounts WHERE ".
75
+  $result = db_query("SELECT uid, username, name FROM system.useraccounts WHERE ".
76 76
                      "kunde='{$id}';");
77 77
   while ($entry = mysql_fetch_assoc($result))
78
-    $return[$entry['uid']] = $entry['username'];
78
+    $return[] = $entry;
79 79
 
80 80
   return $return;
81 81
 }
... ...
@@ -50,13 +50,19 @@ foreach ($result as $val) {
50 50
     add(90, "c{$c->id}", "Kunde {$c->id}: {$c->fullname}");
51 51
   }
52 52
   $users = find_users_for_customer($c->id);
53
-  foreach ($users as $uid => $username) {
54
-    if ($uid == $term || $username == $term) {
55
-      add(15, "u{$uid}", "User {$uid}: {$username}");
56
-    } elseif (strstr($username, $term)) {
57
-      add(20, "u{$uid}", "User {$uid}: {$username}");
53
+  foreach ($users as $u) {
54
+    $realname = $c->fullname;
55
+    if ($u['name']) {
56
+      $realname = $u['name'];
57
+    }
58
+    if ($u['uid'] == $term || $u['username'] == $term) {
59
+      add(15, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
60
+    } elseif (strstr($u['username'], $term)) {
61
+      add(20, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
62
+    } elseif (strstr($u['name'], $term)) {
63
+      add(25, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
58 64
     } else {
59
-      add(85, "u{$uid}", "User {$uid}: {$username}");
65
+      add(85, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
60 66
     }
61 67
   }
62 68
 }
63 69