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