3 * Formatter for user rights 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
21 * @author Alexandre Emsenhuber
22 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
27 * This class formats rights log entries.
31 class RightsLogFormatter
extends LogFormatter
{
32 protected function makePageLink( Title
$title = null, $parameters = array() ) {
33 global $wgContLang, $wgUserrightsInterwikiDelimiter;
35 if ( !$this->plaintext
) {
36 $text = $wgContLang->ucfirst( $title->getText() );
37 $parts = explode( $wgUserrightsInterwikiDelimiter, $text, 2 );
39 if ( count( $parts ) === 2 ) {
40 $titleLink = WikiMap
::foreignUserLink( $parts[1], $parts[0],
41 htmlspecialchars( $title->getPrefixedText() ) );
43 if ( $titleLink !== false ) {
49 return parent
::makePageLink( $title, $parameters );
52 protected function getMessageKey() {
53 $key = parent
::getMessageKey();
54 $params = $this->getMessageParameters();
55 if ( !isset( $params[3] ) && !isset( $params[4] ) ) {
62 protected function getMessageParameters() {
63 $params = parent
::getMessageParameters();
66 if ( !isset( $params[3] ) && !isset( $params[4] ) ) {
70 $oldGroups = $params[3];
71 $newGroups = $params[4];
74 if ( $oldGroups === '' ) {
76 } elseif ( is_string( $oldGroups ) ) {
77 $oldGroups = array_map( 'trim', explode( ',', $oldGroups ) );
79 if ( $newGroups === '' ) {
81 } elseif ( is_string( $newGroups ) ) {
82 $newGroups = array_map( 'trim', explode( ',', $newGroups ) );
85 $userName = $this->entry
->getTarget()->getText();
86 if ( !$this->plaintext
&& count( $oldGroups ) ) {
87 foreach ( $oldGroups as &$group ) {
88 $group = User
::getGroupMember( $group, $userName );
91 if ( !$this->plaintext
&& count( $newGroups ) ) {
92 foreach ( $newGroups as &$group ) {
93 $group = User
::getGroupMember( $group, $userName );
97 $lang = $this->context
->getLanguage();
98 if ( count( $oldGroups ) ) {
99 $params[3] = $lang->listToText( $oldGroups );
101 $params[3] = $this->msg( 'rightsnone' )->text();
103 if ( count( $newGroups ) ) {
104 // Array_values is used here because of bug 42211
105 // see use of array_unique in UserrightsPage::doSaveUserGroups on $newGroups.
106 $params[4] = $lang->listToText( array_values( $newGroups ) );
108 $params[4] = $this->msg( 'rightsnone' )->text();