diff --git a/include/class.ticket.php b/include/class.ticket.php index 82cc169a59eb019fe6c2d87a61f1052561f66586..c6c1b25dc47f99184d8e5f28ee5066d7f389ba5c 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -1093,6 +1093,9 @@ class Ticket { return $closedate; break; + case 'user': + return $this->getOwner(); + break; default: if (isset($this->_answers[$tag])) // The answer object is retrieved here which will diff --git a/include/class.user.php b/include/class.user.php index b38ec252886395ecdba9580990fe648fb03e4149..0b2f30c50ce9f7464049f8a8980b87372971e7cd 100644 --- a/include/class.user.php +++ b/include/class.user.php @@ -107,15 +107,31 @@ class User extends UserModel { return new PersonsName($this->name); } + function asVar() { + return (string) $this->getName(); + } + + function getVar($tag) { + if($tag && is_callable(array($this, 'get'.ucfirst($tag)))) + return call_user_func(array($this, 'get'.ucfirst($tag))); + + $tag = strtolower($tag); + foreach ($this->getDynamicData() as $e) + if ($e->getAnswer($tag)) + return $e; + } + function getDynamicData() { - $data = DynamicFormEntry::forClient($this->id); - if (!$data[0]) { - $data = array(); - $g = UserForm::getInstance(); - $g->setClientId($this->id); - $data[] = $g; + if (!isset($this->_entries)) { + $this->_entries = DynamicFormEntry::forClient($this->id); + if (!$this->_entries[0]) { + $this->_entries = array(); + $g = UserForm::getInstance(); + $g->setClientId($this->id); + $this->_entries[] = $g; + } } - return $data; + return $this->_entries; } function save($refetch=false) {