From: umherirrender Date: Tue, 5 Apr 2016 17:11:00 +0000 (+0200) Subject: Show absolute block expiry in user timezone on block logs X-Git-Tag: 1.31.0-rc.0~7339^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22upgrade%22%2C%22reinstall=non%22%29%20.%20%22?a=commitdiff_plain;h=afd72226b86d3f029dcc12aa7d07304da646c60c;p=lhc%2Fweb%2Fwiklou.git Show absolute block expiry in user timezone on block logs For this add an user parameter to Language::translateBlockExpiry. This allows the function to display the absolute block expiry in the user's time zone. Use this when formatting block log entries. This also avoids the use of $wgUser Bug: T131241 Change-Id: If0a1d3c88bb4242a016eb9b2df115413de786149 --- diff --git a/includes/logging/BlockLogFormatter.php b/includes/logging/BlockLogFormatter.php index aa90d1d369..21e40ec5fa 100644 --- a/includes/logging/BlockLogFormatter.php +++ b/includes/logging/BlockLogFormatter.php @@ -58,7 +58,8 @@ class BlockLogFormatter extends LogFormatter { // is shown on the correct side of the tooltip text. $durationTooltip = '‎' . htmlspecialchars( $params[4] ); $params[4] = Message::rawParam( "" . - $this->context->getLanguage()->translateBlockExpiry( $params[4] ) . '' ); + $this->context->getLanguage()->translateBlockExpiry( $params[4], + $this->context->getUser() ) . '' ); $params[5] = isset( $params[5] ) ? self::formatBlockFlags( $params[5], $this->context->getLanguage() ) : ''; } diff --git a/languages/Language.php b/languages/Language.php index f13f9d684b..4af48305c7 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -3966,10 +3966,11 @@ class Language { * match up with it. * * @param string $str The validated block duration in English + * @param User $user User object to use timezone from or null for $wgUser * @return string Somehow translated block duration * @see LanguageFi.php for example implementation */ - function translateBlockExpiry( $str ) { + function translateBlockExpiry( $str, User $user = null ) { $duration = SpecialBlock::getSuggestedDurations( $this ); foreach ( $duration as $show => $value ) { if ( strcmp( $str, $value ) == 0 ) { @@ -3995,10 +3996,12 @@ class Language { } else { // It's an absolute timestamp. if ( $time === 0 ) { // wfTimestamp() handles 0 as current time instead of epoch. - return $this->timeanddate( '19700101000000' ); - } else { - return $this->timeanddate( $time ); + $time = '19700101000000'; + } + if ( $user ) { + return $this->userTimeAndDate( $time, $user ); } + return $this->timeanddate( $time ); } } diff --git a/languages/classes/LanguageFi.php b/languages/classes/LanguageFi.php index c3c40efde6..867a2f67c8 100644 --- a/languages/classes/LanguageFi.php +++ b/languages/classes/LanguageFi.php @@ -85,10 +85,10 @@ class LanguageFi extends Language { /** * @param string $str - * @param bool $forContent + * @param User $user User object to use timezone from or null for $wgUser * @return string */ - function translateBlockExpiry( $str, $forContent = false ) { + function translateBlockExpiry( $str, User $user = null ) { /* 'ago', 'now', 'today', 'this', 'next', 'first', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth',