From 35b5d27b6ff3a5d2179190485f70c196bfa73237 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Tue, 22 Apr 2014 12:42:49 -0500
Subject: [PATCH] Fallback to client email display on user directory

---
 include/class.user.php      | 6 +++++-
 include/staff/users.inc.php | 7 ++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/include/class.user.php b/include/class.user.php
index ad599b5d0..e0042c1a2 100644
--- a/include/class.user.php
+++ b/include/class.user.php
@@ -215,7 +215,11 @@ class User extends UserModel {
     }
 
     function getName() {
-        return new PersonsName($this->name);
+        if (!$this->name)
+            list($name) = explode('@', $this->getDefaultEmailAddress(), 2);
+        else
+            $name = $this->name;
+        return new PersonsName($name);
     }
 
     function getUpdateDate() {
diff --git a/include/staff/users.inc.php b/include/staff/users.inc.php
index 97e5862fd..e02c9dbc8 100644
--- a/include/staff/users.inc.php
+++ b/include/staff/users.inc.php
@@ -115,7 +115,12 @@ else
         if($res && db_num_rows($res)):
             $ids=($errors && is_array($_POST['ids']))?$_POST['ids']:null;
             while ($row = db_fetch_array($res)) {
-                $name = new PersonsName($row['name']);
+                // Default to email address mailbox if no name specified
+                if (!$row['name'])
+                    list($name) = explode('@', $row['email']);
+                else
+                    $name = new PersonsName($row['name']);
+
                 // Account status
                 if ($row['account_id'])
                     $status = new UserAccountStatus($row['status']);
-- 
GitLab