3 function wfSpecialContributions( $par = "" )
5 global $wgUser, $wgOut, $wgLang, $wgRequest, $wgIsPg;
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" );
56 $oldtable=$wgIsPg?
'"old"':'old';
58 $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit,cur_is_new FROM cur " .
59 "WHERE cur_user_text='" . wfStrencode( $nt->getText() ) . "' {$cmq} " .
60 "ORDER BY inverse_timestamp LIMIT {$querylimit}";
61 $res1 = wfQuery( $sql, DB_READ
, $fname );
63 $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit FROM $oldtable " .
64 "WHERE old_user_text='" . wfStrencode( $nt->getText() ) . "' {$omq} " .
65 "ORDER BY inverse_timestamp LIMIT {$querylimit}";
66 $res2 = wfQuery( $sql, DB_READ
, $fname );
68 $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit,cur_is_new FROM cur " .
69 "WHERE cur_user={$id} {$cmq} ORDER BY inverse_timestamp LIMIT {$querylimit}";
70 $res1 = wfQuery( $sql, DB_READ
, $fname );
72 $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit FROM $oldtable " .
73 "WHERE old_user={$id} {$omq} ORDER BY inverse_timestamp LIMIT {$querylimit}";
74 $res2 = wfQuery( $sql, DB_READ
, $fname );
76 $nCur = wfNumRows( $res1 );
77 $nOld = wfNumRows( $res2 );
79 $top = wfShowingResults( $offset, $limit );
80 $wgOut->addHTML( "<p>{$top}\n" );
82 $sl = wfViewPrevNext( $offset, $limit,
83 $wgLang->specialpage( "Contributions" ),
84 "hideminor={$hideminor}&target=" . wfUrlEncode( $target ),
85 ($nCur +
$nOld) <= $offlimit);
87 $shm = wfMsg( "showhideminor", $mlink );
88 $wgOut->addHTML( "<br />{$sl} ($shm)</p>\n");
91 if ( 0 == $nCur && 0 == $nOld ) {
92 $wgOut->addHTML( "\n<p>" . wfMsg( "nocontribs" ) . "</p>\n" );
95 if ( 0 != $nCur ) { $obj1 = wfFetchObject( $res1 ); }
96 if ( 0 != $nOld ) { $obj2 = wfFetchObject( $res2 ); }
98 $wgOut->addHTML( "<ul>\n" );
99 for( $n = 0; $n < $offlimit; $n++
) {
100 if ( 0 == $nCur && 0 == $nOld ) { break; }
102 if ( ( 0 == $nOld ) ||
104 ( $obj1->cur_timestamp
>= $obj2->old_timestamp
) ) ) {
105 $ns = $obj1->cur_namespace
;
106 $t = $obj1->cur_title
;
107 $ts = $obj1->cur_timestamp
;
108 $comment =$obj1->cur_comment
;
109 $me = $obj1->cur_minor_edit
;
110 $isnew = $obj1->cur_is_new
;
111 $obj1 = wfFetchObject( $res1 );
115 $ns = $obj2->old_namespace
;
116 $t = $obj2->old_title
;
117 $ts = $obj2->old_timestamp
;
118 $comment =$obj2->old_comment
;
119 $me = $obj2->old_minor_edit
;
121 $obj2 = wfFetchObject( $res2 );
127 ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, ( $me > 0), $isnew );
129 $wgOut->addHTML( "</ul>\n" );
135 Generates each row in the contributions list.
137 Contributions which are marked "top" are currently on top of the history.
138 For these contributions, a [rollback] link is shown for users with sysop
139 privileges. The rollback link restores the most recent version that was not
140 written by the target user.
142 If the contributions page is called with the parameter &bot=1, all rollback
143 links also get that parameter. It causes the edit itself and the rollback
144 to be marked as "bot" edits. Bot edits are hidden by default from recent
145 changes, so this allows sysops to combat a busy vandal without bothering
148 TODO: This would probably look a lot nicer in a table.
151 function ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, $isminor, $isnew )
153 global $wgLang, $wgOut, $wgUser, $wgRequest;
154 $page = Title
::makeName( $ns, $t );
155 $link = $sk->makeKnownLink( $page, "" );
159 $topmarktext .= $sk->makeKnownLink( $page, wfMsg("uctop"), "diff=0" );
161 $topmarktext .= wfMsg("newarticle");
163 $sysop = $wgUser->isSysop();
165 $extraRollback = $wgRequest->getBool( "bot" ) ?
'&bot=1' : '';
166 $target = $wgRequest->getText( 'target' );
167 $topmarktext .= " [". $sk->makeKnownLink( $page,
168 wfMsg( "rollbacklink" ),
169 "action=rollback&from=" . urlencode( $target ) . $extraRollback ) ."]";
173 $histlink="(".$sk->makeKnownLink($page,wfMsg("hist"),"action=history").")";
177 $comment="<em>(". $sk->formatComment($comment ) .")</em> ";
180 $d = $wgLang->timeanddate( $ts, true );
183 $mflag = "<strong>" . wfMsg( "minoreditletter" ) . "</strong> ";
188 $wgOut->addHTML( "<li>{$d} {$histlink} {$mflag} {$link} {$comment}{$topmarktext}</li>\n" );
191 function ucCountLink( $lim, $d )
193 global $wgUser, $wgLang, $wgRequest;
195 $target = $wgRequest->getText( 'target' );
196 $sk = $wgUser->getSkin();
197 $s = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
198 "{$lim}", "target={$target}&days={$d}&limit={$lim}" );
202 function ucDaysLink( $lim, $d )
204 global $wgUser, $wgLang, $wgRequest;
206 $target = $wgRequest->getText( 'target' );
207 $sk = $wgUser->getSkin();
208 $s = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
209 "{$d}", "target={$target}&days={$d}&limit={$lim}" );