9 function wfSpecialContributions( $par = '' ) {
10 global $wgUser, $wgOut, $wgLang, $wgRequest;
11 $fname = "wfSpecialContributions";
12 $sysop = $wgUser->isSysop();
17 $target = $wgRequest->getVal( 'target' );
19 if ( "" == $target ) {
20 $wgOut->errorpage( "notargettitle", "notargettext" );
24 # FIXME: Change from numeric offsets to date offsets
25 list( $limit, $offset ) = wfCheckLimits( 50, "" );
26 $offlimit = $limit +
$offset;
27 $querylimit = $offlimit +
1;
28 $hideminor = ($wgRequest->getVal( 'hideminor' ) ?
1 : 0);
29 $sk = $wgUser->getSkin();
30 $dbr =& wfGetDB( DB_SLAVE
);
33 $nt = Title
::newFromURL( $target );
35 $wgOut->errorpage( "notargettitle", "notargettext" );
38 $nt->setNamespace( Namespace::getUser() );
40 $id = User
::idFromName( $nt->getText() );
45 $ul = $sk->makeLinkObj( $nt, htmlspecialchars( $nt->getText() ) );
46 $userCond = "=" . $id;
48 $talk = $nt->getTalkPage();
50 $ul .= " (" . $sk->makeLinkObj( $talk, $wgLang->getNsText(Namespace::getTalk(0)) ) . ")";
53 if ( $target == 'newbies' ) {
54 # View the contributions of all recently created accounts
55 $max = $dbr->selectField( 'user', 'max(user_id)', false, $fname );
56 $userCond = ">" . ($max - $max / 100);
57 $ul = wfMsg ( 'newbies' );
61 $wgOut->setSubtitle( wfMsg( "contribsub", $ul ) );
64 $cmq = "AND cur_minor_edit=0";
65 $omq = "AND old_minor_edit=0";
66 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
67 WfMsg( "show" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
68 "&offset={$offset}&limit={$limit}&hideminor=0" );
71 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
72 WfMsg( "hide" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
73 "&offset={$offset}&limit={$limit}&hideminor=1" );
76 extract( $dbr->tableNames( 'old', 'cur' ) );
77 if ( $userCond == "" ) {
78 $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit,cur_is_new,cur_user_text FROM $cur " .
79 "WHERE cur_user_text='" . $dbr->strencode( $nt->getText() ) . "' {$cmq} " .
80 "ORDER BY inverse_timestamp LIMIT {$querylimit}";
81 $res1 = $dbr->query( $sql, $fname );
83 $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit,old_user_text,old_id FROM $old " .
84 "WHERE old_user_text='" . $dbr->strencode( $nt->getText() ) . "' {$omq} " .
85 "ORDER BY inverse_timestamp LIMIT {$querylimit}";
86 $res2 = $dbr->query( $sql, $fname );
88 $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit,cur_is_new,cur_user_text FROM $cur " .
89 "WHERE cur_user {$userCond} {$cmq} ORDER BY inverse_timestamp LIMIT {$querylimit}";
90 $res1 = $dbr->query( $sql, $fname );
92 $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit,old_user_text,old_id FROM $old " .
93 "WHERE old_user {$userCond} {$omq} ORDER BY inverse_timestamp LIMIT {$querylimit}";
94 $res2 = $dbr->query( $sql, $fname );
96 $nCur = $dbr->numRows( $res1 );
97 $nOld = $dbr->numRows( $res2 );
99 $top = wfShowingResults( $offset, $limit );
100 $wgOut->addHTML( "<p>{$top}\n" );
102 $sl = wfViewPrevNext( $offset, $limit,
103 $wgLang->specialpage( "Contributions" ),
104 "hideminor={$hideminor}&target=" . wfUrlEncode( $target ),
105 ($nCur +
$nOld) <= $offlimit);
107 $shm = wfMsg( "showhideminor", $mlink );
108 $wgOut->addHTML( "<br />{$sl} ($shm)</p>\n");
111 if ( 0 == $nCur && 0 == $nOld ) {
112 $wgOut->addHTML( "\n<p>" . wfMsg( "nocontribs" ) . "</p>\n" );
115 if ( 0 != $nCur ) { $obj1 = $dbr->fetchObject( $res1 ); }
116 if ( 0 != $nOld ) { $obj2 = $dbr->fetchObject( $res2 ); }
118 $wgOut->addHTML( "<ul>\n" );
119 for( $n = 0; $n < $offlimit; $n++
) {
120 if ( 0 == $nCur && 0 == $nOld ) { break; }
122 if ( ( 0 == $nOld ) ||
124 ( $obj1->cur_timestamp
>= $obj2->old_timestamp
) ) ) {
125 $ns = $obj1->cur_namespace
;
126 $t = $obj1->cur_title
;
127 $ts = $obj1->cur_timestamp
;
128 $comment =$obj1->cur_comment
;
129 $me = $obj1->cur_minor_edit
;
130 $isnew = $obj1->cur_is_new
;
131 $usertext = $obj1->cur_user_text
;
133 $obj1 = $dbr->fetchObject( $res1 );
138 $ns = $obj2->old_namespace
;
139 $t = $obj2->old_title
;
140 $ts = $obj2->old_timestamp
;
141 $comment =$obj2->old_comment
;
142 $me = $obj2->old_minor_edit
;
143 $usertext = $obj2->old_user_text
;
144 $oldid = $obj2->old_id
;
146 $obj2 = $dbr->fetchObject( $res2 );
152 ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, ( $me > 0), $isnew, $usertext, $oldid );
154 $wgOut->addHTML( "</ul>\n" );
157 global $wgUseValidation;
158 if( $wgUseValidation ) {
159 require_once( 'SpecialValidate.php' );
160 $val = new Validation
;
161 $val = $val->countUserValidations ( $id ) ;
162 $wgOut->addHTML( wfMsg ( 'val_user_validations', $val ) );
168 * Generates each row in the contributions list.
170 * Contributions which are marked "top" are currently on top of the history.
171 * For these contributions, a [rollback] link is shown for users with sysop
172 * privileges. The rollback link restores the most recent version that was not
173 * written by the target user.
175 * If the contributions page is called with the parameter &bot=1, all rollback
176 * links also get that parameter. It causes the edit itself and the rollback
177 * to be marked as "bot" edits. Bot edits are hidden by default from recent
178 * changes, so this allows sysops to combat a busy vandal without bothering
181 * @todo This would probably look a lot nicer in a table.
183 function ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, $isminor, $isnew, $target, $oldid ) {
184 global $wgLang, $wgOut, $wgUser, $wgRequest;
185 $page = Title
::makeName( $ns, $t );
186 $link = $sk->makeKnownLink( $page, "" );
190 $topmarktext .= $sk->makeKnownLink( $page, wfMsg("uctop"), "diff=0" );
192 $topmarktext .= wfMsg("newarticle");
194 $sysop = $wgUser->isSysop();
196 $extraRollback = $wgRequest->getBool( "bot" ) ?
'&bot=1' : '';
197 # $target = $wgRequest->getText( 'target' );
198 $topmarktext .= " [". $sk->makeKnownLink( $page,
199 wfMsg( "rollbacklink" ),
200 "action=rollback&from=" . urlencode( $target ) . $extraRollback ) ."]";
205 $oldtext= $sk->makeKnownLink( $page, '('.wfMsg('diff').')', 'diff=prev&oldid='.$oldid );
206 } else { $oldtext=''; }
207 $histlink="(".$sk->makeKnownLink($page,wfMsg("hist"),"action=history").")";
211 $comment="<em>(". $sk->formatComment($comment, Title
::newFromText($t) ) .")</em> ";
214 $d = $wgLang->timeanddate( $ts, true );
217 $mflag = '<span class="minor">'.wfMsg( "minoreditletter" ).'</span> ';
222 $wgOut->addHTML( "<li>{$d} {$histlink} {$mflag} {$link} {$comment}{$topmarktext}{$oldtext}</li>\n" );
228 function ucCountLink( $lim, $d ) {
229 global $wgUser, $wgLang, $wgRequest;
231 $target = $wgRequest->getText( 'target' );
232 $sk = $wgUser->getSkin();
233 $s = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
234 "{$lim}", "target={$target}&days={$d}&limit={$lim}" );
241 function ucDaysLink( $lim, $d ) {
242 global $wgUser, $wgLang, $wgRequest;
244 $target = $wgRequest->getText( 'target' );
245 $sk = $wgUser->getSkin();
246 $s = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
247 "{$d}", "target={$target}&days={$d}&limit={$lim}" );