From c21f8e9b5302aca4deceddc44a575192c6390f58 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Thu, 29 May 2014 09:46:51 -0500 Subject: [PATCH] user: Fix variable replacement for %{ticket.user} --- include/class.client.php | 12 +++++++++++- include/class.ticket.php | 3 +-- include/class.user.php | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/class.client.php b/include/class.client.php index c9f6fc394..b92159ee2 100644 --- a/include/class.client.php +++ b/include/class.client.php @@ -175,13 +175,23 @@ class EndUser extends AuthenticatedUser { if(!$this->user || !is_callable(array($this->user, $name))) - return false; + return $this->getVar(substr($name, 3)); return $args ? call_user_func_array(array($this->user, $name), $args) : call_user_func(array($this->user, $name)); } + function getVar($tag) { + $u = $this; + // Traverse the $user properties of all nested user objects to get + // to the User instance with the custom data + while (isset($u->user)) + $u = $u->user; + if (method_exists($u, 'getVar')) + return $u->getVar($tag); + } + function getId() { //We ONLY care about user ID at the ticket level if ($this->user instanceof Collaborator) diff --git a/include/class.ticket.php b/include/class.ticket.php index 8f29d7bb4..924cda4c8 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -1234,7 +1234,7 @@ class Ticket { if($tag && is_callable(array($this, 'get'.ucfirst($tag)))) return call_user_func(array($this, 'get'.ucfirst($tag))); - switch(strtolower($tag)) { + switch(mb_strtolower($tag)) { case 'phone': case 'phone_number': return $this->getPhoneNumber(); @@ -1282,7 +1282,6 @@ class Ticket { return $this->getOwner(); break; default: - $tag = mb_strtolower($tag); if (isset($this->_answers[$tag])) // The answer object is retrieved here which will // automatically invoke the toString() method when the diff --git a/include/class.user.php b/include/class.user.php index 172399ab6..527969306 100644 --- a/include/class.user.php +++ b/include/class.user.php @@ -160,7 +160,7 @@ class User extends UserModel { if($tag && is_callable(array($this, 'get'.ucfirst($tag)))) return call_user_func(array($this, 'get'.ucfirst($tag))); - $tag = strtolower($tag); + $tag = mb_strtolower($tag); foreach ($this->getDynamicData() as $e) if ($a = $e->getAnswer($tag)) return $a; -- GitLab