Reduced the scope of the hideminor user preference to just recent
[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 if ( $hideminor ) {
32 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchangeslinked" ),
33 WfMsg( "show" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) .
34 "&days={$days}&limit={$limit}&hideminor=0" );
35 } else {
36 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchangeslinked" ),
37 WfMsg( "hide" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) .
38 "&days={$days}&limit={$limit}&hideminor=1" );
39 }
40 if ( $hideminor ) {
41 $cmq = "AND cur_minor_edit=0";
42 } else { $cmq = ""; }
43
44 $sql = "SELECT cur_id,cur_namespace,cur_title,cur_user,cur_comment," .
45 "cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new FROM links, cur " .
46 "WHERE cur_timestamp > '{$cutoff}' {$cmq} AND l_to=cur_id AND l_from='" .
47 wfStrencode( $nt->getPrefixedDBkey() ) . "' GROUP BY cur_id " .
48 "ORDER BY inverse_timestamp LIMIT {$limit}";
49 $res = wfQuery( $sql, DB_READ, $fname );
50
51 $note = wfMsg( "rcnote", $limit, $days );
52 $wgOut->addHTML( "<hr>\n{$note}\n<br>" );
53
54 $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked",
55 "target=" . $nt->getPrefixedURL() . "&hideminor={$hideminor}",
56 false, $mlink );
57
58 $wgOut->addHTML( "{$note}\n" );
59
60 $s = $sk->beginRecentChangesList();
61 $count = wfNumRows( $res );
62
63 while ( $limit ) {
64 if ( 0 == $count ) { break; }
65 $obj = wfFetchObject( $res );
66 --$count;
67
68 $ts = $obj->cur_timestamp;
69 $u = $obj->cur_user;
70 $ut = $obj->cur_user_text;
71 $ns = $obj->cur_namespace;
72 $ttl = $obj->cur_title;
73 $com = $obj->cur_comment;
74 $me = ( $obj->cur_minor_edit > 0 );
75 $new = ( $obj->cur_is_new > 0 );
76
77 $s .= $sk->recentChangesLine( $ts, $u, $ut, $ns, $ttl, $com, $me, $new );
78 --$limit;
79 }
80 $s .= $sk->endRecentChangesList();
81
82 wfFreeResult( $res );
83 $wgOut->addHTML( $s );
84 }
85
86 ?>