From 4b7d7c3dc82a0c2bffe210c4350d639551c9ab9d Mon Sep 17 00:00:00 2001
From: Peter Rotich <peter@osticket.com>
Date: Sun, 24 Apr 2016 20:10:43 +0000
Subject: [PATCH] email: System email check + aliases

Include username when checking if a system email already exists. This
is important for emails that use aliases.
---
 include/class.email.php | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/class.email.php b/include/class.email.php
index e0bdb64bd..2b5f5e033 100644
--- a/include/class.email.php
+++ b/include/class.email.php
@@ -216,7 +216,10 @@ class Email extends VerySimpleModel {
     /******* Static functions ************/
 
    static function getIdByEmail($email) {
-        $qs = static::objects()->filter(array('email' => $email))
+        $qs = static::objects()->filter(Q::any(array(
+                        'email'  => $email,
+                        'userid' => $email
+                        )))
             ->values_flat('email_id');
 
         $row = $qs->first();
-- 
GitLab