From 2668623eea385062eff341bca42da8a65cc7f548 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Tue, 17 Feb 2015 12:17:31 -0600 Subject: [PATCH] mailer: Merge #1730 to develop-next --- include/class.mailer.php | 40 +++++++++++++++++++--------------------- include/class.staff.php | 3 +++ 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/include/class.mailer.php b/include/class.mailer.php index 99e0ba095..b5d759cb4 100644 --- a/include/class.mailer.php +++ b/include/class.mailer.php @@ -144,26 +144,24 @@ class Mailer { 'abcdefghiklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_='); $sig = $this->getEmail()?$this->getEmail()->getEmail():'@osTicketMailer'; $sysid = static::getSystemMessageIdCode(); - if ($recipient instanceof EmailContact) { - // Create a tag for the outbound email - $entry = (isset($options['thread']) && $options['thread'] instanceof ThreadEntry) - ? $options['thread'] : false; - $thread = $entry ? $entry->getThread() - : (isset($options['thread']) && $options['thread'] instanceof Thread - ? $options['thread'] : false); - $tag = pack('VVVa', - $recipient->getId(), - $entry ? $entry->getId() : 0, - $thread ? $thread->getId() : 0, - ($recipient instanceof Staff ? 'S' - : ($recipient instanceof TicketOwner ? 'U' - : ($recipient instanceof Collaborator ? 'C' - : '?'))) - ); - // Sign the tag with the system secret salt - $tag .= substr(hash_hmac('sha1', $tag.$rand.$sysid, SECRET_SALT, true), -5); - $tag = str_replace('=','',base64_encode($tag)); - } + // Create a tag for the outbound email + $entry = (isset($options['thread']) && $options['thread'] instanceof ThreadEntry) + ? $options['thread'] : false; + $thread = $entry ? $entry->getThread() + : (isset($options['thread']) && $options['thread'] instanceof Thread + ? $options['thread'] : false); + $tag = pack('VVVa', + $recipient instanceof EmailContact ? $recipient->getUserId() : 0, + $entry ? $entry->getId() : 0, + $thread ? $thread->getId() : 0, + ($recipient instanceof Staff ? 'S' + : ($recipient instanceof TicketOwner ? 'U' + : ($recipient instanceof Collaborator ? 'C' + : '?'))) + ); + // Sign the tag with the system secret salt + $tag .= substr(hash_hmac('sha1', $tag.$rand.$sysid, SECRET_SALT, true), -5); + $tag = str_replace('=','',base64_encode($tag)); return sprintf('B%s-%s-%s-%s', $sysid, $rand, $tag, $sig); } @@ -258,7 +256,7 @@ class Mailer { // Attempt to make the user-id more specific $classes = array( - 'S' => 'staffId', 'U' => 'userId' + 'S' => 'staffId', 'U' => 'userId', 'C' => 'userId', ); if (isset($classes[$rv['userClass']])) $rv[$classes[$rv['userClass']]] = $rv['uid']; diff --git a/include/class.staff.php b/include/class.staff.php index 87bb3e073..57e0ee30b 100644 --- a/include/class.staff.php +++ b/include/class.staff.php @@ -172,6 +172,9 @@ implements AuthenticatedUser, EmailContact { function getId() { return $this->staff_id; } + function getUserId() { + return $this->getId(); + } function getEmail() { return $this->email; -- GitLab