diff --git a/include/class.client.php b/include/class.client.php index 704b046c6b8384bef8eba09f7a2e275e2726fd69..25b03281b9abd31d359d265592dcdc7058061a24 100644 --- a/include/class.client.php +++ b/include/class.client.php @@ -62,8 +62,9 @@ implements EmailContact, ITicketUser, TemplateVariable { static function getVarScope() { return array( + 'email' => __('Email address'), 'name' => array('class' => 'PersonsName', 'desc' => __('Full name')), - 'ticket_link' => __('Link to the ticket'), + 'ticket_link' => __('Auth. token used for auto-login'), ); } diff --git a/include/class.format.php b/include/class.format.php index 59becb5d231ee103831dc1f6421b80ed8ef7a63d..52b2bcff56f6c1612b9b0dd100c30c54ec4af3dd 100644 --- a/include/class.format.php +++ b/include/class.format.php @@ -828,6 +828,8 @@ implements TemplateVariable { if (method_exists($this, 'get' . ucfirst($what))) return call_user_func(array($this, 'get'.ucfirst($what))); + // TODO: Rebase date format so that locale is discovered HERE. + switch ($what) { case 'short': return Format::date($this->date, $this->fromdb, false, $this->timezone, $this->user); diff --git a/include/class.forms.php b/include/class.forms.php index f0ddc5df0f5799113b0065190a1133c42ae24fa4..77744763a91a7852b4631fcb10f9dc725caafdad 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -2210,6 +2210,8 @@ class FileFieldAttachments { function getVar($tag) { switch ($tag) { + case 'names': + return $this->__toString(); case 'files': throw new OOBContent(OOBContent::FILES, $this->files->all()); } @@ -2217,6 +2219,7 @@ class FileFieldAttachments { static function getVarScope() { return array( + 'names' => __('List of file names'), 'files' => __('Attached files'), ); } diff --git a/include/class.organization.php b/include/class.organization.php index 16ba01293ddc54c6699d06b0e1ff1d81735120c1..cc011495fa3e13114ffd8af3e2863946ca86d3f8 100644 --- a/include/class.organization.php +++ b/include/class.organization.php @@ -315,10 +315,10 @@ implements TemplateVariable { static function getVarScope() { $base = array( - 'contacts' => array('class' => 'UserList', 'desc' => 'Primary contacts'), - 'manager' => 'Account manager', - 'members' => array('class' => 'UserList', 'desc' => 'Organization members'), - 'name' => 'Organization name', + 'contacts' => array('class' => 'UserList', 'desc' => __('Primary Contacts')), + 'manager' => __('Account Manager'), + 'members' => array('class' => 'UserList', 'desc' => __('Organization Members')), + 'name' => __('Name'), ); $extra = VariableReplacer::compileFormScope(OrganizationForm::getInstance()); return $base + $extra; diff --git a/include/class.priority.php b/include/class.priority.php index 68f1c39d6cc2cbab3eddf6957fcd9aed1087849d..8721ad81182028b942d7bc565ca71458f7bd3620 100644 --- a/include/class.priority.php +++ b/include/class.priority.php @@ -51,7 +51,7 @@ implements TemplateVariable { function asVar() { return $this->getDesc(); } static function getVarScope() { return array( - 'desc' => 'Priority description', + 'desc' => __('Priority Level'), ); } diff --git a/include/class.sla.php b/include/class.sla.php index f26a399f648ffb00aeef9f0520e3e7ab3f1b992d..c1b4ead65df6f5d1ec796f7655e1d0a4322519f1 100644 --- a/include/class.sla.php +++ b/include/class.sla.php @@ -103,8 +103,8 @@ implements TemplateVariable { static function getVarScope() { return array( - 'name' => 'SLA Name', - 'graceperiod' => 'Grace period (in hours)', + 'name' => __('SLA Plan'), + 'graceperiod' => __("Grace Period (hrs)"), ); } diff --git a/include/class.staff.php b/include/class.staff.php index 47bda2352b3aa5183c8388d76055e7af5b12fbfb..9e093d7fcc93dcf349b1761f1bacd1a77ef2d839 100644 --- a/include/class.staff.php +++ b/include/class.staff.php @@ -80,18 +80,28 @@ implements AuthenticatedUser, EmailContact, TemplateVariable { static function getVarScope() { return array( - 'dept' => array('class' => 'Dept', 'desc' => 'Department'), - 'email' => 'Email address', + 'dept' => array('class' => 'Dept', 'desc' => __('Department')), + 'email' => __('Email Address'), 'name' => array( - 'class' => 'PersonsName', 'desc' => 'Name of the agent', + 'class' => 'PersonsName', 'desc' => __('Agent name'), ), - 'phone' => 'Phone number', - 'signature' => "Agent's signature", + 'mobile' => __('Mobile Number'), + 'phone' => __('Phone Number'), + 'signature' => __('Signature'), 'timezone' => "Agent's configured timezone", 'username' => 'Access username', ); } + function getVar($tag) { + switch ($tag) { + case 'mobile': + return Format::phone($this->ht['mobile']); + case 'phone': + return Format::phone($this->ht['phone']); + } + } + function getHashtable() { $base = $this->ht; $base['group'] = $base['group_id']; diff --git a/include/class.team.php b/include/class.team.php index 1d4358bfab656339fa16b6e09152c38737a67c96..04427634a0bcce591e1e460737f34cd445e5e56b 100644 --- a/include/class.team.php +++ b/include/class.team.php @@ -45,12 +45,12 @@ implements TemplateVariable { static function getVarScope() { return array( - 'name' => 'Team name', + 'name' => __('Team Name'), 'lead' => array( - 'class' => 'Staff', 'desc' => 'Team leader', + 'class' => 'Staff', 'desc' => __('Team Lead'), ), 'members' => array( - 'class' => 'UserList', 'desc' => 'Team members', + 'class' => 'UserList', 'desc' => __('Team Members'), ), ); } diff --git a/include/class.thread.php b/include/class.thread.php index 9a2dde5b9223ba7cfa98eff0a779c7cff863d9bf..744e9a3e36ce98ba8cdc0a5bbb27d310ddc6eaa2 100644 --- a/include/class.thread.php +++ b/include/class.thread.php @@ -857,16 +857,19 @@ implements TemplateVariable { static function getVarScope() { return array( - 'body' => 'Formatted message body', - 'create_date' => 'Date created', - 'ip_address' => 'IP address of remote user, for web submissions', - 'poster' => 'Name of the thread item originator', + 'files' => __('Attached files'), + 'body' => __('Message body'), + 'create_date' => array( + 'class' => 'FormattedDate', 'desc' => __('Date created'), + ), + 'ip_address' => __('IP address of remote user, for web submissions'), + 'poster' => __('Submitter of the thread item'), 'staff' => array( - 'class' => 'Staff', 'desc' => 'Agent posting the note or response', + 'class' => 'Staff', 'desc' => __('Agent posting the note or response'), ), - 'subject' => 'Subject of the message, if any', + 'title' => __('Subject, if any'), 'user' => array( - 'class' => 'User', 'desc' => 'User posting the message', + 'class' => 'User', 'desc' => __('User posting the message'), ), ); } diff --git a/include/class.ticket.php b/include/class.ticket.php index dc2d831e1c27fc742eabf4b9416766bdc61d0224..d0a766aefebd7991b3645de4dcb21834edddbb34 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -1834,9 +1834,10 @@ implements RestrictedAccess, Threadable, TemplateVariable { if ($this->isClosed()) return new FormattedDate($this->getCloseDate()); break; + case 'last_update': + return new FormattedDate($upd); case 'user': return $this->getOwner(); - break; default: if (isset($this->_answers[$tag])) // The answer object is retrieved here which will @@ -1850,33 +1851,33 @@ implements RestrictedAccess, Threadable, TemplateVariable { static function getVarScope() { $base = array( - 'assigned' => 'Assigned agent and/or team', + 'assigned' => __('Assigned agent and/or team'), 'close_date' => array( - 'class' => 'FormattedDate', 'desc' => 'Date of ticket closure', + 'class' => 'FormattedDate', 'desc' => __('Date Closed'), ), 'create_date' => array( - 'class' => 'FormattedDate', 'desc' => 'Ticket create date', + 'class' => 'FormattedDate', 'desc' => __('Date created'), ), 'dept' => array( - 'class' => 'Dept', 'desc' => 'Department', + 'class' => 'Dept', 'desc' => __('Department'), ), 'due_date' => array( - 'class' => 'FormattedDate', 'desc' => 'Ticket due date', + 'class' => 'FormattedDate', 'desc' => __('Due Date'), ), - 'email' => 'Default email address of ticket owner', + 'email' => __('Default email address of ticket owner'), 'name' => array( 'class' => 'PersonsName', 'desc' => __('Name of ticket owner'), ), - 'number' => 'Ticket number', - 'phone' => 'Phone number of ticket owner', + 'number' => __('Ticket number'), + 'phone' => __('Phone number of ticket owner'), 'priority' => array( - 'class' => 'Priority', 'desc' => __('Ticket priority'), + 'class' => 'Priority', 'desc' => __('Priority'), ), 'recipients' => array( - 'class' => 'UserList', 'desc' => 'Ticket participant list', + 'class' => 'UserList', 'desc' => __('List of all recipient names'), ), 'status' => array( - 'class' => 'TicketStatus', 'desc' => __('Ticket status'), + 'class' => 'TicketStatus', 'desc' => __('Status'), ), 'staff' => array( 'class' => 'Staff', 'desc' => __('Assigned/closing agent'), @@ -1886,10 +1887,14 @@ implements RestrictedAccess, Threadable, TemplateVariable { 'class' => 'Team', 'desc' => __('Assigned/closing team'), ), 'thread' => array( - 'class' => 'TicketThread', 'desc' => 'Ticket thread', + 'class' => 'TicketThread', 'desc' => __('Ticket Thread'), ), 'topic' => array( - 'class' => 'Topic', 'desc' => 'Help topic', + 'class' => 'Topic', 'desc' => __('Help topic'), + ), + // XXX: Isn't lastreponse and lastmessage more useful + 'last_update' => array( + 'class' => 'FormattedDate', 'desc' => __('Time of last update'), ), 'user' => array( 'class' => 'User', 'desc' => __('Ticket owner'), diff --git a/include/class.topic.php b/include/class.topic.php index c60aa2c9e2695407deb58bc226ec261cec2e7bb7..776f99e896905946fb5d973b2fc8b930e1104f5a 100644 --- a/include/class.topic.php +++ b/include/class.topic.php @@ -76,15 +76,15 @@ implements TemplateVariable { static function getVarScope() { return array( 'dept' => array( - 'class' => 'Dept', 'desc' => 'Department', + 'class' => 'Dept', 'desc' => __('Department'), ), - 'fullname' => 'Help topic full path', - 'name' => 'Help topic name', + 'fullname' => __('Help topic full path'), + 'name' => __('Help topic'), 'parent' => array( - 'class' => 'Topic', 'desc' => 'Parent help topic', + 'class' => 'Topic', 'desc' => __('Parent'), ), 'sla' => array( - 'class' => 'SLA', 'desc' => 'Service Level Agreement', + 'class' => 'SLA', 'desc' => __('Service Level Agreement'), ), ); } diff --git a/include/class.user.php b/include/class.user.php index 028832c7d743c767c6fd7e27fba0c0fa31822539..f4b3c18eda09a321dc4b0edf81b98aa411a66175 100644 --- a/include/class.user.php +++ b/include/class.user.php @@ -262,7 +262,7 @@ implements TemplateVariable { } function getEmail() { - return $this->default_email->address; + return new EmailAddress($this->default_email->address); } function getFullName() { @@ -344,11 +344,13 @@ implements TemplateVariable { static function getVarScope() { $base = array( - 'email' => 'Default email address', + 'email' => array( + 'class' => 'EmailAddress', 'desc' => __('Default email address') + ), 'name' => array( 'class' => 'PersonsName', 'desc' => 'User name, default format' ), - 'organization' => array('class' => 'Organization', 'desc' => 'Organization'), + 'organization' => array('class' => 'Organization', 'desc' => __('Organization')), ); $extra = VariableReplacer::compileFormScope(UserForm::getInstance()); return $base + $extra; @@ -665,6 +667,47 @@ implements TemplateVariable { } } +class EmailAddress +implements TemplateVariable { + var $address; + + function __construct($address) { + $this->address = $address; + } + + function __toString() { + return $this->address; + } + + function getVar($what) { + require_once PEAR_DIR . 'Mail/RFC822.php'; + require_once PEAR_DIR . 'PEAR.php'; + if (!($mails = Mail_RFC822::parseAddressList($this->address)) || PEAR::isError($mails)) + return ''; + + if (!$list && count($mails) > 1) + return ''; + + $info = $mails[0]; + switch ($what) { + case 'domain': + return $info->host; + case 'personal': + return $info->personal; + case 'mailbox': + return $info->mailbox; + } + } + + static function getVarScope() { + return array( + 'domain' => __('Domain'), + 'mailbox' => __('Mailbox'), + 'personal' => __('Personal name'), + ); + } +} + class PersonsName implements TemplateVariable { var $format; @@ -1266,13 +1309,11 @@ implements TemplateVariable { } function getNames() { - $list = array(); foreach($this->storage as $user) { if (is_object($user)) $list [] = $user->getName(); } - return $list ? implode(', ', $list) : ''; } @@ -1292,15 +1333,14 @@ implements TemplateVariable { if (is_object($user)) $list[] = $user->getEmail(); } - return $list ? implode(', ', $list) : ''; } static function getVarScope() { return array( - 'names' => 'List of names', - 'emails' => 'List of email addresses', - 'full' => 'List of names and email addresses', + 'names' => __('List of names'), + 'emails' => __('List of email addresses'), + 'full' => __('List of names and email addresses'), ); } } diff --git a/include/class.variable.php b/include/class.variable.php index 6401007aee906045f70c78f51ead62ef15c34a17..e47b74d742770df073538355a660ee39f7d50c2c 100644 --- a/include/class.variable.php +++ b/include/class.variable.php @@ -310,7 +310,7 @@ class PlaceholderList if (count($items) == 1) { return $items[0]; } - return new static($items); + return new static(array_filter($items)); } }