diff --git a/include/class.thread.php b/include/class.thread.php index 21ac9336cde18cdf3cfe4631aee13b09e436f731..595b9671b7ef4828593d7ebdf59737d877d8b11b 100644 --- a/include/class.thread.php +++ b/include/class.thread.php @@ -1607,9 +1607,10 @@ class ThreadEvent extends VerySimpleModel { } function template($description) { + global $thisstaff; $self = $this; return preg_replace_callback('/\{(<(?P<type>([^>]+))>)?(?P<key>[^}.]+)(\.(?P<data>[^}]+))?\}/', - function ($m) use ($self) { + function ($m) use ($self, $thisstaff) { switch ($m['key']) { case 'assignees': $assignees = array(); @@ -1628,10 +1629,22 @@ class ThreadEvent extends VerySimpleModel { $name = $avatar.$name; return $name; case 'timestamp': - return sprintf('<time class="relative" datetime="%s" title="%s">%s</time>', + $timeFormat = null; + if ($thisstaff + && !strcasecmp($thisstaff->datetime_format, + 'relative')) { + $timeFormat = function ($timestamp) { + return Format::relativeTime(Misc::db2gmtime($timestamp)); + }; + } + + return sprintf('<time %s datetime="%s" + data-toggle="tooltip" title="%s">%s</time>', + $timeFormat ? 'class="relative"' : '', date(DateTime::W3C, Misc::db2gmtime($self->timestamp)), Format::daydatetime($self->timestamp), - Format::relativeTime(Misc::db2gmtime($self->timestamp)) + $timeFormat ? $timeFormat($self->timestamp) : + Format::datetime($self->timestamp) ); case 'agent': $name = $self->agent->getName(); diff --git a/include/client/templates/thread-entry.tmpl.php b/include/client/templates/thread-entry.tmpl.php index 9e42b053a841fbd971eaef0165ae29cc79b4c283..938a6912fc14ac3d904090f7a99cae39f43ef266 100644 --- a/include/client/templates/thread-entry.tmpl.php +++ b/include/client/templates/thread-entry.tmpl.php @@ -25,10 +25,10 @@ if ($user) </div> <?php echo sprintf(__('<b>%s</b> posted %s'), $name, - sprintf('<time class="relative" datetime="%s" title="%s">%s</time>', + sprintf('<time datetime="%s" title="%s">%s</time>', date(DateTime::W3C, Misc::db2gmtime($entry->created)), Format::daydatetime($entry->created), - Format::relativeTime(Misc::db2gmtime($entry->created)) + Format::datetime($entry->created) ) ); ?> <span style="max-width:500px" class="faded title truncate"><?php diff --git a/include/staff/profile.inc.php b/include/staff/profile.inc.php index aacea1421dfe5af611ac965bc1fcdc42cb72d35b..c3fd062b8cdd2d1f03eb3207a56dc75a85620485 100644 --- a/include/staff/profile.inc.php +++ b/include/staff/profile.inc.php @@ -208,7 +208,9 @@ if ($avatar->isChangeable()) { ?> 'email' => __("Email Address Name"), 'dept' => sprintf(__("Department Name (%s)"), __('if public' /* This is used in 'Department's Name (>if public<)' */)), - 'mine' => __('My Name')); + 'mine' => __('My Name'), + '' => '— '.__('System Default').' —', + ); if ($cfg->hideStaffName()) unset($options['mine']); @@ -276,6 +278,23 @@ if ($avatar->isChangeable()) { ?> <div class="error"><?php echo $errors['timezone']; ?></div> </td> </tr> + <tr><td><?php echo __('Time Format');?>:</td> + <td> + <select name="datetime_format"> +<?php + $datetime_format = $staff->datetime_format; + foreach (array( + 'relative' => __('Relative Time'), + '' => '— '.__('System Default').' —', +) as $v=>$name) { ?> + <option value="<?php echo $v; ?>" <?php + if ($v == $datetime_format) + echo 'selected="selected"'; + ?>><?php echo $name; ?></option> +<?php } ?> + </select> + </td> + </tr> <?php if ($cfg->getSecondaryLanguages()) { ?> <tr> <td><?php echo __('Preferred Language'); ?>:</td> diff --git a/include/staff/templates/thread-entry.tmpl.php b/include/staff/templates/thread-entry.tmpl.php index eeec47f8b85e2c4cfeb0c2f37fc8dfbc03e86ee8..5ae84d4eb6e716748e868f4e7c1fe44d9d68111c 100644 --- a/include/staff/templates/thread-entry.tmpl.php +++ b/include/staff/templates/thread-entry.tmpl.php @@ -1,4 +1,12 @@ <?php +global $thisstaff; +$timeFormat = null; +if ($thisstaff && !strcasecmp($thisstaff->datetime_format, 'relative')) { + $timeFormat = function($datetime) { + return Format::relativeTime(Misc::db2gmtime($datetime)); + }; +} + $entryTypes = array('M'=>'message', 'R'=>'response', 'N'=>'note'); $user = $entry->getUser() ?: $entry->getStaff(); $name = $user ? $user->getName() : $entry->poster; @@ -51,16 +59,17 @@ if ($user) </span> </div> <?php - echo sprintf(__('<b>%s</b> posted %s'), - $entry->isSystem() ? __('SYSTEM') : $name, - sprintf('<a name="entry-%d" href="#entry-%1$s"><time class="relative" datetime="%s" title="%s">%s</time></a>', + echo sprintf(__('<b>%s</b> posted %s'), $name, + sprintf('<a name="entry-%d" href="#entry-%1$s"><time %s + datetime="%s" data-toggle="tooltip" title="%s">%s</time></a>', $entry->id, + $timeFormat ? 'class="relative"' : '', date(DateTime::W3C, Misc::db2gmtime($entry->created)), Format::daydatetime($entry->created), - Format::relativeTime(Misc::db2gmtime($entry->created)) + $timeFormat ? $timeFormat($entry->created) : Format::datetime($entry->created) ) ); ?> - <span style="max-width:500px" class="faded title truncate"><?php + <span style="max-width:400px" class="faded title truncate"><?php echo $entry->title; ?></span> </span> </div> diff --git a/scp/css/scp.css b/scp/css/scp.css index d487797241bd860f90d5ba51bfd9babe32304666..1aa6361639c51abee2bff81811197a7d4fb31669 100644 --- a/scp/css/scp.css +++ b/scp/css/scp.css @@ -74,7 +74,7 @@ div#header a { time[title]:hover { text-decoration: underline; } -a time.relative { +a time { color: initial; }