From e678360e28a3f5023cd569d6666187fa58904590 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Tue, 14 Jul 2015 11:04:55 -0500 Subject: [PATCH] oops: Fix warning on new ticket page for Thread::lastmessage --- include/ajax.staff.php | 2 ++ include/class.format.php | 11 +++++------ include/class.thread.php | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/ajax.staff.php b/include/ajax.staff.php index 54c0fed5b..e3fec3a65 100644 --- a/include/ajax.staff.php +++ b/include/ajax.staff.php @@ -29,6 +29,7 @@ class StaffAjaxAPI extends AjaxController { Http::response(404, 'No such agent'); $form = new PasswordResetForm($_POST); + $errors = array(); if (!$_POST && isset($_SESSION['new-agent-passwd'])) $form->data($_SESSION['new-agent-passwd']); @@ -76,6 +77,7 @@ class StaffAjaxAPI extends AjaxController { Http::response(404, 'No such agent'); $form = new PasswordChangeForm($_POST); + $errors = array(); if ($_POST && $form->isValid()) { $clean = $form->getClean(); diff --git a/include/class.format.php b/include/class.format.php index 4e5bb04b8..6c0ee841b 100644 --- a/include/class.format.php +++ b/include/class.format.php @@ -869,8 +869,6 @@ implements TemplateVariable { } function getVar($what) { - global $cfg; - // TODO: Rebase date format so that locale is discovered HERE. switch ($what) { @@ -906,20 +904,21 @@ extends FormattedLocalDate { return (string) new FormattedLocalDate($this->date, $cfg->getTimezone(), false, $this->fromdb); } - function getVar($what, $context) { + function getVar($what, $context=null) { global $cfg; - if ($rv = parent::getVar($what)) + if ($rv = parent::getVar($what, $context)) return $rv; switch ($what) { case 'user': // Fetch $recipient from the context and find that user's time zone - if ($recipient = $context->getObj('recipient')) { + if ($context && ($recipient = $context->getObj('recipient'))) { $tz = $recipient->getTimezone() ?: $cfg->getDefaultTimezone(); return new FormattedLocalDate($this->date, $tz, $recipient); } - break; + // Don't resolve the variable until correspondance is sent out + return false; case 'system': return new FormattedLocalDate($this->date, $cfg->getDefaultTimezone()); } diff --git a/include/class.thread.php b/include/class.thread.php index c0fbb8fec..81fb47aed 100644 --- a/include/class.thread.php +++ b/include/class.thread.php @@ -2447,7 +2447,7 @@ implements TemplateVariable { return $message; $this->lastmessage = SqlFunction::NOW(); - $this->save(); + $this->save(true); return $message; } @@ -2460,7 +2460,7 @@ implements TemplateVariable { return $resp; $this->lastresponse = SqlFunction::NOW(); - $this->save(); + $this->save(true); return $resp; } -- GitLab