diff options
author | Marc Alexander <admin@m-a-styles.de> | 2017-06-25 10:10:09 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2017-06-25 10:10:09 +0200 |
commit | c5501d90a48c76b63debdabbd5306d3cb232b5f6 (patch) | |
tree | 364cc51eb0155e12ea31d893f34b6b6c805f9b50 | |
parent | b59073cf3ed54d040aef0f02cb3e5c28fb768b5b (diff) | |
parent | 27b2d91713dfbad1e87ae83336559d22ac9ec399 (diff) | |
download | forums-c5501d90a48c76b63debdabbd5306d3cb232b5f6.tar forums-c5501d90a48c76b63debdabbd5306d3cb232b5f6.tar.gz forums-c5501d90a48c76b63debdabbd5306d3cb232b5f6.tar.bz2 forums-c5501d90a48c76b63debdabbd5306d3cb232b5f6.tar.xz forums-c5501d90a48c76b63debdabbd5306d3cb232b5f6.zip |
Merge pull request #4824 from senky/ticket/15217
[ticket/15217] Add core.user_format_date_override event
-rw-r--r-- | phpBB/phpbb/user.php | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php index 305510851c..d4097f53ee 100644 --- a/phpBB/phpbb/user.php +++ b/phpBB/phpbb/user.php @@ -588,6 +588,7 @@ class user extends \phpbb\session */ function format_date($gmepoch, $format = false, $forcedate = false) { + global $phpbb_dispatcher; static $utc; if (!isset($utc)) @@ -595,10 +596,34 @@ class user extends \phpbb\session $utc = new \DateTimeZone('UTC'); } - $time = new $this->datetime($this, '@' . (int) $gmepoch, $utc); - $time->setTimezone($this->timezone); + $format_date_override = false; + $function_arguments = func_get_args(); + /** + * Execute code and/or override format_date() + * + * To override the format_date() function generated value + * set $format_date_override to new return value + * + * @event core.user_format_date_override + * @var DateTimeZone utc Is DateTimeZone in UTC + * @var array function_arguments is array comprising a function's argument list + * @var string format_date_override Shall we return custom format (string) or not (false) + * @since 3.2.1-RC1 + */ + $vars = array('utc', 'function_arguments', 'format_date_override'); + extract($phpbb_dispatcher->trigger_event('core.user_format_date_override', compact($vars))); - return $time->format($format, $forcedate); + if (!$format_date_override) + { + $time = new $this->datetime($this, '@' . (int) $gmepoch, $utc); + $time->setTimezone($this->timezone); + + return $time->format($format, $forcedate); + } + else + { + return $format_date_override; + } } /** |