bug 18472 Suppression log filtered by "offender", as Oversight log can be
[lhc/web/wiklou.git] / includes / specials / SpecialLog.php
1 <?php
2 # Copyright (C) 2008 Aaron Schulz
3 # http://www.mediawiki.org/
4 #
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.
9 #
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.
14 #
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
19
20 /**
21 * @file
22 * @ingroup SpecialPage
23 */
24
25 /**
26 * constructor
27 */
28 function wfSpecialLog( $par = '' ) {
29 global $wgRequest, $wgOut, $wgUser, $wgLogTypes;
30
31 # Get parameters
32 $parms = explode( '/', ($par = ( $par !== null ) ? $par : '' ) );
33 $symsForAll = array( '*', 'all' );
34 if ( $parms[0] != '' && ( in_array( $par, $wgLogTypes ) || in_array( $par, $symsForAll ) ) ) {
35 $type = $par;
36 $user = $wgRequest->getText( 'user' );
37 } else if ( count( $parms ) == 2 ) {
38 $type = $parms[0];
39 $user = $parms[1];
40 } else {
41 $type = $wgRequest->getVal( 'type' );
42 $user = ( $par != '' ) ? $par : $wgRequest->getText( 'user' );
43 }
44 $title = $wgRequest->getText( 'page' );
45 $pattern = $wgRequest->getBool( 'pattern' );
46 $y = $wgRequest->getIntOrNull( 'year' );
47 $m = $wgRequest->getIntOrNull( 'month' );
48 $tagFilter = $wgRequest->getVal( 'tagfilter' );
49 # Don't let the user get stuck with a certain date
50 $skip = $wgRequest->getText( 'offset' ) || $wgRequest->getText( 'dir' ) == 'prev';
51 if( $skip ) {
52 $y = '';
53 $m = '';
54 }
55 # Handle type-specific inputs
56 $qc = array();
57 if( $type == 'suppress' ) {
58 $offender = User::newFromName( $wgRequest->getVal('offender'), false );
59 if( $offender && $offender->getId() > 0 ) {
60 $qc = array( 'ls_field' => 'target_author_id', 'ls_value' => $offender->getId() );
61 } else if( $offender && IP::isIPAddress( $offender->getName() ) ) {
62 $qc = array( 'ls_field' => 'target_author_ip', 'ls_value' => $offender->getName() );
63 }
64 }
65 # Create a LogPager item to get the results and a LogEventsList item to format them...
66 $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, 0 );
67 $pager = new LogPager( $loglist, $type, $user, $title, $pattern, $qc, $y, $m, $tagFilter );
68 # Set title and add header
69 $loglist->showHeader( $pager->getType() );
70 # Show form options
71 $loglist->showOptions( $pager->getType(), $pager->getUser(), $pager->getPage(), $pager->getPattern(),
72 $pager->getYear(), $pager->getMonth(), $pager->getFilterParams(), $tagFilter );
73 # Insert list
74 $logBody = $pager->getBody();
75 if( $logBody ) {
76 $wgOut->addHTML(
77 $pager->getNavigationBar() .
78 $loglist->beginLogEventsList() .
79 $logBody .
80 $loglist->endLogEventsList() .
81 $pager->getNavigationBar()
82 );
83 } else {
84 $wgOut->addWikiMsg( 'logempty' );
85 }
86 }