5 * @subpackage SpecialPage
11 function wfSpecialContributions( $par = '' ) {
12 global $wgUser, $wgOut, $wgLang, $wgRequest;
13 $fname = "wfSpecialContributions";
14 $sysop = $wgUser->isSysop();
19 $target = $wgRequest->getVal( 'target' );
21 if ( "" == $target ) {
22 $wgOut->errorpage( "notargettitle", "notargettext" );
26 # FIXME: Change from numeric offsets to date offsets
27 list( $limit, $offset ) = wfCheckLimits( 50, "" );
28 $offlimit = $limit +
$offset;
29 $querylimit = $offlimit +
1;
30 $hideminor = ($wgRequest->getVal( 'hideminor' ) ?
1 : 0);
31 $sk = $wgUser->getSkin();
32 $dbr =& wfGetDB( DB_SLAVE
);
35 $nt = Title
::newFromURL( $target );
37 $wgOut->errorpage( "notargettitle", "notargettext" );
40 $nt->setNamespace( Namespace::getUser() );
42 $id = User
::idFromName( $nt->getText() );
47 $ul = $sk->makeLinkObj( $nt, htmlspecialchars( $nt->getText() ) );
48 $userCond = "=" . $id;
50 $talk = $nt->getTalkPage();
52 $ul .= " (" . $sk->makeLinkObj( $talk, $wgLang->getNsText(Namespace::getTalk(0)) ) . ")";
55 if ( $target == 'newbies' ) {
56 # View the contributions of all recently created accounts
57 $max = $dbr->selectField( 'user', 'max(user_id)', false, $fname );
58 $userCond = ">" . ($max - $max / 100);
59 $ul = wfMsg ( 'newbies' );
63 $wgOut->setSubtitle( wfMsg( "contribsub", $ul ) );
66 $cmq = "AND cur_minor_edit=0";
67 $omq = "AND old_minor_edit=0";
68 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
69 WfMsg( "show" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
70 "&offset={$offset}&limit={$limit}&hideminor=0" );
73 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
74 WfMsg( "hide" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
75 "&offset={$offset}&limit={$limit}&hideminor=1" );
78 extract( $dbr->tableNames( 'old', 'cur' ) );
79 if ( $userCond == "" ) {
80 $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit,cur_is_new,cur_user_text FROM $cur " .
81 "WHERE cur_user_text='" . $dbr->strencode( $nt->getText() ) . "' {$cmq} " .
82 "ORDER BY inverse_timestamp LIMIT {$querylimit}";
83 $res1 = $dbr->query( $sql, $fname );
85 $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit,old_user_text,old_id FROM $old " .
86 "WHERE old_user_text='" . $dbr->strencode( $nt->getText() ) . "' {$omq} " .
87 "ORDER BY inverse_timestamp LIMIT {$querylimit}";
88 $res2 = $dbr->query( $sql, $fname );
90 $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit,cur_is_new,cur_user_text FROM $cur " .
91 "WHERE cur_user {$userCond} {$cmq} ORDER BY inverse_timestamp LIMIT {$querylimit}";
92 $res1 = $dbr->query( $sql, $fname );
94 $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit,old_user_text,old_id FROM $old " .
95 "WHERE old_user {$userCond} {$omq} ORDER BY inverse_timestamp LIMIT {$querylimit}";
96 $res2 = $dbr->query( $sql, $fname );
98 $nCur = $dbr->numRows( $res1 );
99 $nOld = $dbr->numRows( $res2 );
101 $top = wfShowingResults( $offset, $limit );
102 $wgOut->addHTML( "<p>{$top}\n" );
104 $sl = wfViewPrevNext( $offset, $limit,
105 $wgLang->specialpage( "Contributions" ),
106 "hideminor={$hideminor}&target=" . wfUrlEncode( $target ),
107 ($nCur +
$nOld) <= $offlimit);
109 $shm = wfMsg( "showhideminor", $mlink );
110 $wgOut->addHTML( "<br />{$sl} ($shm)</p>\n");
113 if ( 0 == $nCur && 0 == $nOld ) {
114 $wgOut->addHTML( "\n<p>" . wfMsg( "nocontribs" ) . "</p>\n" );
117 if ( 0 != $nCur ) { $obj1 = $dbr->fetchObject( $res1 ); }
118 if ( 0 != $nOld ) { $obj2 = $dbr->fetchObject( $res2 ); }
120 $wgOut->addHTML( "<ul>\n" );
121 for( $n = 0; $n < $offlimit; $n++
) {
122 if ( 0 == $nCur && 0 == $nOld ) { break; }
124 if ( ( 0 == $nOld ) ||
126 ( $obj1->cur_timestamp
>= $obj2->old_timestamp
) ) ) {
127 $ns = $obj1->cur_namespace
;
128 $t = $obj1->cur_title
;
129 $ts = $obj1->cur_timestamp
;
130 $comment =$obj1->cur_comment
;
131 $me = $obj1->cur_minor_edit
;
132 $isnew = $obj1->cur_is_new
;
133 $usertext = $obj1->cur_user_text
;
135 $obj1 = $dbr->fetchObject( $res1 );
140 $ns = $obj2->old_namespace
;
141 $t = $obj2->old_title
;
142 $ts = $obj2->old_timestamp
;
143 $comment =$obj2->old_comment
;
144 $me = $obj2->old_minor_edit
;
145 $usertext = $obj2->old_user_text
;
146 $oldid = $obj2->old_id
;
148 $obj2 = $dbr->fetchObject( $res2 );
154 ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, ( $me > 0), $isnew, $usertext, $oldid );
156 $wgOut->addHTML( "</ul>\n" );
159 global $wgUseValidation;
160 if( $wgUseValidation ) {
161 require_once( 'SpecialValidate.php' );
162 $val = new Validation
;
163 $val = $val->countUserValidations ( $id ) ;
164 $wgOut->addHTML( wfMsg ( 'val_user_validations', $val ) );
170 * Generates each row in the contributions list.
172 * Contributions which are marked "top" are currently on top of the history.
173 * For these contributions, a [rollback] link is shown for users with sysop
174 * privileges. The rollback link restores the most recent version that was not
175 * written by the target user.
177 * If the contributions page is called with the parameter &bot=1, all rollback
178 * links also get that parameter. It causes the edit itself and the rollback
179 * to be marked as "bot" edits. Bot edits are hidden by default from recent
180 * changes, so this allows sysops to combat a busy vandal without bothering
183 * @todo This would probably look a lot nicer in a table.
185 function ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, $isminor, $isnew, $target, $oldid ) {
186 global $wgLang, $wgOut, $wgUser, $wgRequest;
187 $page = Title
::makeName( $ns, $t );
188 $link = $sk->makeKnownLink( $page, "" );
192 $topmarktext .= $sk->makeKnownLink( $page, wfMsg("uctop"), "diff=0" );
194 $topmarktext .= wfMsg("newarticle");
196 $sysop = $wgUser->isSysop();
198 $extraRollback = $wgRequest->getBool( "bot" ) ?
'&bot=1' : '';
199 # $target = $wgRequest->getText( 'target' );
200 $topmarktext .= " [". $sk->makeKnownLink( $page,
201 wfMsg( "rollbacklink" ),
202 "action=rollback&from=" . urlencode( $target ) . $extraRollback ) ."]";
207 $oldtext= $sk->makeKnownLink( $page, '('.wfMsg('diff').')', 'diff=prev&oldid='.$oldid );
208 } else { $oldtext=''; }
209 $histlink="(".$sk->makeKnownLink($page,wfMsg("hist"),"action=history").")";
213 $comment="<em>(". $sk->formatComment($comment, Title
::newFromText($t) ) .")</em> ";
216 $d = $wgLang->timeanddate( $ts, true );
219 $mflag = '<span class="minor">'.wfMsg( "minoreditletter" ).'</span> ';
224 $wgOut->addHTML( "<li>{$d} {$histlink} {$mflag} {$link} {$comment}{$topmarktext}{$oldtext}</li>\n" );
230 function ucCountLink( $lim, $d ) {
231 global $wgUser, $wgLang, $wgRequest;
233 $target = $wgRequest->getText( 'target' );
234 $sk = $wgUser->getSkin();
235 $s = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
236 "{$lim}", "target={$target}&days={$d}&limit={$lim}" );
243 function ucDaysLink( $lim, $d ) {
244 global $wgUser, $wgLang, $wgRequest;
246 $target = $wgRequest->getText( 'target' );
247 $sk = $wgUser->getSkin();
248 $s = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
249 "{$d}", "target={$target}&days={$d}&limit={$lim}" );