3 function wfSpecialContributions( $par = "" )
5 global $wgUser, $wgOut, $wgLang, $wgRequest;
6 $fname = "wfSpecialContributions";
7 $sysop = $wgUser->isSysop();
12 $target = $wgRequest->getVal( 'target' );
14 if ( "" == $target ) {
15 $wgOut->errorpage( "notargettitle", "notargettext" );
19 # FIXME: Change from numeric offsets to date offsets
20 list( $limit, $offset ) = wfCheckLimits( 50, "" );
21 $offlimit = $limit +
$offset;
22 $querylimit = $offlimit +
1;
23 $hideminor = ($wgRequest->getVal( 'hideminor' ) ?
1 : 0);
25 $nt = Title
::newFromURL( $target );
26 $nt->setNamespace( Namespace::getUser() );
28 $sk = $wgUser->getSkin();
29 $id = User
::idFromName( $nt->getText() );
34 $ul = $sk->makeLinkObj( $nt, $nt->getText() );
36 $talk = $nt->getTalkPage();
38 $ul .= " (" . $sk->makeLinkObj( $talk, $wgLang->getNsText(Namespace::getTalk(0)) ) . ")";
41 $wgOut->setSubtitle( wfMsg( "contribsub", $ul ) );
44 $cmq = "AND cur_minor_edit=0";
45 $omq = "AND old_minor_edit=0";
46 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
47 WfMsg( "show" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) .
48 "&offset={$offset}&limit={$limit}&hideminor=0" );
51 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
52 WfMsg( "hide" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) .
53 "&offset={$offset}&limit={$limit}&hideminor=1" );
57 $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit FROM cur " .
58 "WHERE cur_user_text='" . wfStrencode( $nt->getText() ) . "' {$cmq} " .
59 "ORDER BY inverse_timestamp LIMIT {$querylimit}";
60 $res1 = wfQuery( $sql, DB_READ
, $fname );
62 $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit FROM old " .
63 "WHERE old_user_text='" . wfStrencode( $nt->getText() ) . "' {$omq} " .
64 "ORDER BY inverse_timestamp LIMIT {$querylimit}";
65 $res2 = wfQuery( $sql, DB_READ
, $fname );
67 $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit FROM cur " .
68 "WHERE cur_user={$id} {$cmq} ORDER BY inverse_timestamp LIMIT {$querylimit}";
69 $res1 = wfQuery( $sql, DB_READ
, $fname );
71 $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit FROM old " .
72 "WHERE old_user={$id} {$omq} ORDER BY inverse_timestamp LIMIT {$querylimit}";
73 $res2 = wfQuery( $sql, DB_READ
, $fname );
75 $nCur = wfNumRows( $res1 );
76 $nOld = wfNumRows( $res2 );
78 $top = wfShowingResults( $offset, $limit );
79 $wgOut->addHTML( "<p>{$top}\n" );
81 $sl = wfViewPrevNext( $offset, $limit,
82 $wgLang->specialpage( "Contributions" ),
83 "hideminor={$hideminor}&target=" . wfUrlEncode( $target ),
84 ($nCur +
$nOld) <= $offlimit);
86 $shm = wfMsg( "showhideminor", $mlink );
87 $wgOut->addHTML( "<br>{$sl} ($shm) \n");
90 if ( 0 == $nCur && 0 == $nOld ) {
91 $wgOut->addHTML( "\n<p>" . wfMsg( "nocontribs" ) . "</p>\n" );
94 if ( 0 != $nCur ) { $obj1 = wfFetchObject( $res1 ); }
95 if ( 0 != $nOld ) { $obj2 = wfFetchObject( $res2 ); }
97 $wgOut->addHTML( "<ul>\n" );
98 for( $n = 0; $n < $offlimit; $n++
) {
99 if ( 0 == $nCur && 0 == $nOld ) { break; }
101 if ( ( 0 == $nOld ) ||
103 ( $obj1->cur_timestamp
>= $obj2->old_timestamp
) ) ) {
104 $ns = $obj1->cur_namespace
;
105 $t = $obj1->cur_title
;
106 $ts = $obj1->cur_timestamp
;
107 $comment =$obj1->cur_comment
;
108 $me = $obj1->cur_minor_edit
;
110 $obj1 = wfFetchObject( $res1 );
114 $ns = $obj2->old_namespace
;
115 $t = $obj2->old_title
;
116 $ts = $obj2->old_timestamp
;
117 $comment =$obj2->old_comment
;
118 $me = $obj2->old_minor_edit
;
120 $obj2 = wfFetchObject( $res2 );
125 ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, ( $me > 0) );
127 $wgOut->addHTML( "</ul>\n" );
133 Generates each row in the contributions list.
135 Contributions which are marked "top" are currently on top of the history.
136 For these contributions, a [rollback] link is shown for users with sysop
137 privileges. The rollback link restores the most recent version that was not
138 written by the target user.
140 If the contributions page is called with the parameter &bot=1, all rollback
141 links also get that parameter. It causes the edit itself and the rollback
142 to be marked as "bot" edits. Bot edits are hidden by default from recent
143 changes, so this allows sysops to combat a busy vandal without bothering
146 TODO: This would probably look a lot nicer in a table.
149 function ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, $isminor )
151 global $wgLang, $wgOut, $wgUser, $wgRequest, $target;
152 $page = Title
::makeName( $ns, $t );
153 $link = $sk->makeKnownLink( $page, "" );
156 $topmarktext .= $sk->makeKnownLink( $page, wfMsg("uctop"), "diff=0" );
157 $sysop = $wgUser->isSysop();
159 $extraRollback = $wgRequest->getBool( "bot" ) ?
'&bot=1' : '';
160 $topmarktext .= " [". $sk->makeKnownLink( $page,
161 wfMsg( "rollbacklink" ),
162 "action=rollback&from=" . urlencode( $target ) . $extraRollback ) ."]";
166 $histlink="(".$sk->makeKnownLink($page,wfMsg("hist"),"action=history").")";
170 $comment="<em>(". htmlspecialchars( $comment ) .")</em> ";
173 $d = $wgLang->timeanddate( $ts, true );
176 $mflag = "<strong>" . wfMsg( "minoreditletter" ) . "</strong> ";
181 $wgOut->addHTML( "<li>{$d} {$histlink} {$mflag} {$link} {$comment}{$topmarktext}</li>\n" );
184 function ucCountLink( $lim, $d )
186 global $wgUser, $wgLang, $target;
188 $sk = $wgUser->getSkin();
189 $s = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
190 "{$lim}", "target={$target}&days={$d}&limit={$lim}" );
194 function ucDaysLink( $lim, $d )
196 global $wgUser, $wgLang, $target;
198 $sk = $wgUser->getSkin();
199 $s = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
200 "{$d}", "target={$target}&days={$d}&limit={$lim}" );