2 require_once('SpecialValidate.php');
4 function wfSpecialContributions( $par = "" )
6 global $wgUser, $wgOut, $wgLang, $wgRequest;
7 $fname = "wfSpecialContributions";
8 $sysop = $wgUser->isSysop();
13 $target = $wgRequest->getVal( 'target' );
15 if ( "" == $target ) {
16 $wgOut->errorpage( "notargettitle", "notargettext" );
20 # FIXME: Change from numeric offsets to date offsets
21 list( $limit, $offset ) = wfCheckLimits( 50, "" );
22 $offlimit = $limit +
$offset;
23 $querylimit = $offlimit +
1;
24 $hideminor = ($wgRequest->getVal( 'hideminor' ) ?
1 : 0);
25 $sk = $wgUser->getSkin();
26 $dbr =& wfGetDB( DB_SLAVE
);
29 $nt = Title
::newFromURL( $target );
31 $wgOut->errorpage( "notargettitle", "notargettext" );
34 $nt->setNamespace( Namespace::getUser() );
36 $id = User
::idFromName( $nt->getText() );
41 $ul = $sk->makeLinkObj( $nt, htmlspecialchars( $nt->getText() ) );
42 $userCond = "=" . $id;
44 $talk = $nt->getTalkPage();
46 $ul .= " (" . $sk->makeLinkObj( $talk, $wgLang->getNsText(Namespace::getTalk(0)) ) . ")";
49 if ( $target == 'newbies' ) {
50 # View the contributions of all recently created accounts
51 $max = $dbr->selectField( 'user', 'max(user_id)', false, $fname );
52 $userCond = ">" . ($max - $max / 100);
53 $ul = wfMsg ( 'newbies' );
57 $wgOut->setSubtitle( wfMsg( "contribsub", $ul ) );
60 $cmq = "AND cur_minor_edit=0";
61 $omq = "AND old_minor_edit=0";
62 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
63 WfMsg( "show" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
64 "&offset={$offset}&limit={$limit}&hideminor=0" );
67 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
68 WfMsg( "hide" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
69 "&offset={$offset}&limit={$limit}&hideminor=1" );
72 extract( $dbr->tableNames( 'old', 'cur' ) );
73 if ( $userCond == "" ) {
74 $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit,cur_is_new,cur_user_text FROM $cur " .
75 "WHERE cur_user_text='" . $dbr->strencode( $nt->getText() ) . "' {$cmq} " .
76 "ORDER BY inverse_timestamp LIMIT {$querylimit}";
77 $res1 = $dbr->query( $sql, $fname );
79 $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit,old_user_text FROM $old " .
80 "WHERE old_user_text='" . $dbr->strencode( $nt->getText() ) . "' {$omq} " .
81 "ORDER BY inverse_timestamp LIMIT {$querylimit}";
82 $res2 = $dbr->query( $sql, $fname );
84 $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit,cur_is_new,cur_user_text FROM $cur " .
85 "WHERE cur_user {$userCond} {$cmq} ORDER BY inverse_timestamp LIMIT {$querylimit}";
86 $res1 = $dbr->query( $sql, $fname );
88 $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit,old_user_text FROM $old " .
89 "WHERE old_user {$userCond} {$omq} ORDER BY inverse_timestamp LIMIT {$querylimit}";
90 $res2 = $dbr->query( $sql, $fname );
92 $nCur = $dbr->numRows( $res1 );
93 $nOld = $dbr->numRows( $res2 );
95 $top = wfShowingResults( $offset, $limit );
96 $wgOut->addHTML( "<p>{$top}\n" );
98 $sl = wfViewPrevNext( $offset, $limit,
99 $wgLang->specialpage( "Contributions" ),
100 "hideminor={$hideminor}&target=" . wfUrlEncode( $target ),
101 ($nCur +
$nOld) <= $offlimit);
103 $shm = wfMsg( "showhideminor", $mlink );
104 $wgOut->addHTML( "<br />{$sl} ($shm)</p>\n");
107 if ( 0 == $nCur && 0 == $nOld ) {
108 $wgOut->addHTML( "\n<p>" . wfMsg( "nocontribs" ) . "</p>\n" );
111 if ( 0 != $nCur ) { $obj1 = $dbr->fetchObject( $res1 ); }
112 if ( 0 != $nOld ) { $obj2 = $dbr->fetchObject( $res2 ); }
114 $wgOut->addHTML( "<ul>\n" );
115 for( $n = 0; $n < $offlimit; $n++
) {
116 if ( 0 == $nCur && 0 == $nOld ) { break; }
118 if ( ( 0 == $nOld ) ||
120 ( $obj1->cur_timestamp
>= $obj2->old_timestamp
) ) ) {
121 $ns = $obj1->cur_namespace
;
122 $t = $obj1->cur_title
;
123 $ts = $obj1->cur_timestamp
;
124 $comment =$obj1->cur_comment
;
125 $me = $obj1->cur_minor_edit
;
126 $isnew = $obj1->cur_is_new
;
127 $usertext = $obj1->cur_user_text
;
129 $obj1 = $dbr->fetchObject( $res1 );
133 $ns = $obj2->old_namespace
;
134 $t = $obj2->old_title
;
135 $ts = $obj2->old_timestamp
;
136 $comment =$obj2->old_comment
;
137 $me = $obj2->old_minor_edit
;
138 $usertext = $obj2->old_user_text
;
140 $obj2 = $dbr->fetchObject( $res2 );
146 ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, ( $me > 0), $isnew, $usertext );
148 $wgOut->addHTML( "</ul>\n" );
151 global $wgUseValidation;
152 if( $wgUseValidation ) {
153 require_once( 'SpecialValidate.php' );
154 $val = new Validation
;
155 $val = $val->countUserValidations ( $id ) ;
156 $val = wfMsg ( 'val_user_validations', $val ) ;
157 $wgOut->addHTML( $val );
164 Generates each row in the contributions list.
166 Contributions which are marked "top" are currently on top of the history.
167 For these contributions, a [rollback] link is shown for users with sysop
168 privileges. The rollback link restores the most recent version that was not
169 written by the target user.
171 If the contributions page is called with the parameter &bot=1, all rollback
172 links also get that parameter. It causes the edit itself and the rollback
173 to be marked as "bot" edits. Bot edits are hidden by default from recent
174 changes, so this allows sysops to combat a busy vandal without bothering
177 TODO: This would probably look a lot nicer in a table.
180 function ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, $isminor, $isnew, $target )
182 global $wgLang, $wgOut, $wgUser, $wgRequest;
183 $page = Title
::makeName( $ns, $t );
184 $link = $sk->makeKnownLink( $page, "" );
188 $topmarktext .= $sk->makeKnownLink( $page, wfMsg("uctop"), "diff=0" );
190 $topmarktext .= wfMsg("newarticle");
192 $sysop = $wgUser->isSysop();
194 $extraRollback = $wgRequest->getBool( "bot" ) ?
'&bot=1' : '';
195 # $target = $wgRequest->getText( 'target' );
196 $topmarktext .= " [". $sk->makeKnownLink( $page,
197 wfMsg( "rollbacklink" ),
198 "action=rollback&from=" . urlencode( $target ) . $extraRollback ) ."]";
202 $histlink="(".$sk->makeKnownLink($page,wfMsg("hist"),"action=history").")";
206 $comment="<em>(". $sk->formatComment($comment, Title
::newFromText($t) ) .")</em> ";
209 $d = $wgLang->timeanddate( $ts, true );
212 $mflag = '<span class="minor">'.wfMsg( "minoreditletter" ).'</span> ';
217 $wgOut->addHTML( "<li>{$d} {$histlink} {$mflag} {$link} {$comment}{$topmarktext}</li>\n" );
220 function ucCountLink( $lim, $d )
222 global $wgUser, $wgLang, $wgRequest;
224 $target = $wgRequest->getText( 'target' );
225 $sk = $wgUser->getSkin();
226 $s = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
227 "{$lim}", "target={$target}&days={$d}&limit={$lim}" );
231 function ucDaysLink( $lim, $d )
233 global $wgUser, $wgLang, $wgRequest;
235 $target = $wgRequest->getText( 'target' );
236 $sk = $wgUser->getSkin();
237 $s = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
238 "{$d}", "target={$target}&days={$d}&limit={$lim}" );