Sanity check hideminor param; fix the hide link in rc
[lhc/web/wiklou.git] / includes / SpecialRecentchangeslinked.php
1 <?
2 include_once( "SpecialRecentchanges.php" );
3
4 function wfSpecialRecentchangeslinked( $par = NULL )
5 {
6 global $wgUser, $wgOut, $wgLang, $wgTitle;
7 global $days, $target, $hideminor; # From query string
8 $fname = "wfSpecialRecentchangeslinked";
9
10 $wgOut->setPagetitle( wfMsg( "recentchanges" ) );
11 $sk = $wgUser->getSkin();
12
13 if( $par ) {
14 $target = $par;
15 }
16 if ( "" == $target ) {
17 $wgOut->errorpage( "notargettitle", "notargettext" );
18 return;
19 }
20 $nt = Title::newFromURL( $target );
21 $wgOut->setSubtitle( wfMsg( "rclsub", $nt->getPrefixedText() ) );
22
23 if ( ! $days ) {
24 $days = $wgUser->getOption( "rcdays" );
25 if ( ! $days ) { $days = 7; }
26 }
27 $days = (int)$days;
28 list( $limit, $offset ) = wfCheckLimits( 100, "rclimit" );
29 $cutoff = wfUnix2Timestamp( time() - ( $days * 86400 ) );
30
31 $hideminor = ($hideminor ? 1 : 0);
32 if ( $hideminor ) {
33 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchangeslinked" ),
34 WfMsg( "show" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) .
35 "&days={$days}&limit={$limit}&hideminor=0" );
36 } else {
37 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchangeslinked" ),
38 WfMsg( "hide" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) .
39 "&days={$days}&limit={$limit}&hideminor=1" );
40 }
41 if ( $hideminor ) {
42 $cmq = "AND cur_minor_edit=0";
43 } else { $cmq = ""; }
44
45 $sql = "SELECT cur_id,cur_namespace,cur_title,cur_user,cur_comment," .
46 "cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new FROM links, cur " .
47 "WHERE cur_timestamp > '{$cutoff}' {$cmq} AND l_to=cur_id AND l_from='" .
48 wfStrencode( $nt->getPrefixedDBkey() ) . "' GROUP BY cur_id " .
49 "ORDER BY inverse_timestamp LIMIT {$limit}";
50 $res = wfQuery( $sql, DB_READ, $fname );
51
52 $note = wfMsg( "rcnote", $limit, $days );
53 $wgOut->addHTML( "<hr>\n{$note}\n<br>" );
54
55 $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked",
56 "target=" . $nt->getPrefixedURL() . "&hideminor={$hideminor}",
57 false, $mlink );
58
59 $wgOut->addHTML( "{$note}\n" );
60
61 $s = $sk->beginRecentChangesList();
62 $count = wfNumRows( $res );
63
64 while ( $limit ) {
65 if ( 0 == $count ) { break; }
66 $obj = wfFetchObject( $res );
67 --$count;
68
69 $ts = $obj->cur_timestamp;
70 $u = $obj->cur_user;
71 $ut = $obj->cur_user_text;
72 $ns = $obj->cur_namespace;
73 $ttl = $obj->cur_title;
74 $com = $obj->cur_comment;
75 $me = ( $obj->cur_minor_edit > 0 );
76 $new = ( $obj->cur_is_new > 0 );
77
78 $s .= $sk->recentChangesLine( $ts, $u, $ut, $ns, $ttl, $com, $me, $new );
79 --$limit;
80 }
81 $s .= $sk->endRecentChangesList();
82
83 wfFreeResult( $res );
84 $wgOut->addHTML( $s );
85 }
86
87 ?>