Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / logging / NewUsersLogFormatter.php
blobec640e77a696837da195dd3fa5784aa27c5e111d
1 <?php
2 /**
3 * Formatter for new user log entries.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
21 * @author Niklas Laxström
22 * @license GPL-2.0-or-later
23 * @since 1.22
26 use MediaWiki\Message\Message;
27 use MediaWiki\Title\Title;
28 use MediaWiki\User\User;
30 /**
31 * This class formats new user log entries.
33 * @since 1.19
35 class NewUsersLogFormatter extends LogFormatter {
36 protected function getMessageParameters() {
37 $params = parent::getMessageParameters();
38 $subtype = $this->entry->getSubtype();
39 if ( $subtype === 'create2' || $subtype === 'byemail' ) {
40 if ( isset( $params[3] ) ) {
41 $target = User::newFromId( $params[3] );
42 } else {
43 $target = User::newFromName( $this->entry->getTarget()->getText(), false );
45 $params[2] = Message::rawParam( $this->makeUserLink( $target ) );
46 $params[3] = $target->getName();
49 return $params;
52 public function getComment() {
53 $timestamp = wfTimestamp( TS_MW, $this->entry->getTimestamp() );
54 if ( $timestamp < '20080129000000' ) {
55 # Suppress $comment from old entries (before 2008-01-29),
56 # not needed and can contain incorrect links
57 return '';
60 return parent::getComment();
63 public function getPreloadTitles() {
64 $subtype = $this->entry->getSubtype();
65 if ( $subtype === 'create2' || $subtype === 'byemail' ) {
66 // add the user talk to LinkBatch for the userLink
67 return [ Title::makeTitle( NS_USER_TALK, $this->entry->getTarget()->getText() ) ];
70 return [];