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);
24 $sk = $wgUser->getSkin();
25 $dbr =& wfGetDB( DB_SLAVE
);
28 $nt = Title
::newFromURL( $target );
30 $wgOut->errorpage( "notargettitle", "notargettext" );
33 $nt->setNamespace( Namespace::getUser() );
35 $id = User
::idFromName( $nt->getText() );
40 $ul = $sk->makeLinkObj( $nt, htmlspecialchars( $nt->getText() ) );
41 $userCond = "=" . $id;
43 $talk = $nt->getTalkPage();
45 $ul .= " (" . $sk->makeLinkObj( $talk, $wgLang->getNsText(Namespace::getTalk(0)) ) . ")";
48 if ( $target == 'newbies' ) {
49 # View the contributions of all recently created accounts
50 $max = $dbr->selectField( 'user', 'max(user_id)', false, $fname );
51 $userCond = ">" . ($max - $max / 100);
52 $ul = wfMsg ( 'newbies' );
56 $wgOut->setSubtitle( wfMsg( "contribsub", $ul ) );
59 $cmq = "AND cur_minor_edit=0";
60 $omq = "AND old_minor_edit=0";
61 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
62 WfMsg( "show" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
63 "&offset={$offset}&limit={$limit}&hideminor=0" );
66 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
67 WfMsg( "hide" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
68 "&offset={$offset}&limit={$limit}&hideminor=1" );
71 extract( $dbr->tableNames( 'old', 'cur' ) );
72 if ( $userCond == "" ) {
73 $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit,cur_is_new,cur_user_text FROM $cur " .
74 "WHERE cur_user_text='" . $dbr->strencode( $nt->getText() ) . "' {$cmq} " .
75 "ORDER BY inverse_timestamp LIMIT {$querylimit}";
76 $res1 = $dbr->query( $sql, $fname );
78 $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit,old_user_text,old_id FROM $old " .
79 "WHERE old_user_text='" . $dbr->strencode( $nt->getText() ) . "' {$omq} " .
80 "ORDER BY inverse_timestamp LIMIT {$querylimit}";
81 $res2 = $dbr->query( $sql, $fname );
83 $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit,cur_is_new,cur_user_text FROM $cur " .
84 "WHERE cur_user {$userCond} {$cmq} ORDER BY inverse_timestamp LIMIT {$querylimit}";
85 $res1 = $dbr->query( $sql, $fname );
87 $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit,old_user_text,old_id FROM $old " .
88 "WHERE old_user {$userCond} {$omq} ORDER BY inverse_timestamp LIMIT {$querylimit}";
89 $res2 = $dbr->query( $sql, $fname );
91 $nCur = $dbr->numRows( $res1 );
92 $nOld = $dbr->numRows( $res2 );
94 $top = wfShowingResults( $offset, $limit );
95 $wgOut->addHTML( "<p>{$top}\n" );
97 $sl = wfViewPrevNext( $offset, $limit,
98 $wgLang->specialpage( "Contributions" ),
99 "hideminor={$hideminor}&target=" . wfUrlEncode( $target ),
100 ($nCur +
$nOld) <= $offlimit);
102 $shm = wfMsg( "showhideminor", $mlink );
103 $wgOut->addHTML( "<br />{$sl} ($shm)</p>\n");
106 if ( 0 == $nCur && 0 == $nOld ) {
107 $wgOut->addHTML( "\n<p>" . wfMsg( "nocontribs" ) . "</p>\n" );
110 if ( 0 != $nCur ) { $obj1 = $dbr->fetchObject( $res1 ); }
111 if ( 0 != $nOld ) { $obj2 = $dbr->fetchObject( $res2 ); }
113 $wgOut->addHTML( "<ul>\n" );
114 for( $n = 0; $n < $offlimit; $n++
) {
115 if ( 0 == $nCur && 0 == $nOld ) { break; }
117 if ( ( 0 == $nOld ) ||
119 ( $obj1->cur_timestamp
>= $obj2->old_timestamp
) ) ) {
120 $ns = $obj1->cur_namespace
;
121 $t = $obj1->cur_title
;
122 $ts = $obj1->cur_timestamp
;
123 $comment =$obj1->cur_comment
;
124 $me = $obj1->cur_minor_edit
;
125 $isnew = $obj1->cur_is_new
;
126 $usertext = $obj1->cur_user_text
;
128 $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
;
139 $oldid = $obj2->old_id
;
141 $obj2 = $dbr->fetchObject( $res2 );
147 ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, ( $me > 0), $isnew, $usertext, $oldid );
149 $wgOut->addHTML( "</ul>\n" );
152 global $wgUseValidation;
153 if( $wgUseValidation ) {
154 require_once( 'SpecialValidate.php' );
155 $val = new Validation
;
156 $val = $val->countUserValidations ( $id ) ;
157 $wgOut->addHTML( wfMsg ( 'val_user_validations', $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, $oldid )
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 ) ."]";
203 $oldtext= $sk->makeKnownLink( $page, '('.wfMsg('diff').')', 'diff=prev&oldid='.$oldid );
204 } else { $oldtext=''; }
205 $histlink="(".$sk->makeKnownLink($page,wfMsg("hist"),"action=history").")";
209 $comment="<em>(". $sk->formatComment($comment, Title
::newFromText($t) ) .")</em> ";
212 $d = $wgLang->timeanddate( $ts, true );
215 $mflag = '<span class="minor">'.wfMsg( "minoreditletter" ).'</span> ';
220 $wgOut->addHTML( "<li>{$d} {$histlink} {$mflag} {$link} {$comment}{$topmarktext}{$oldtext}</li>\n" );
223 function ucCountLink( $lim, $d )
225 global $wgUser, $wgLang, $wgRequest;
227 $target = $wgRequest->getText( 'target' );
228 $sk = $wgUser->getSkin();
229 $s = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
230 "{$lim}", "target={$target}&days={$d}&limit={$lim}" );
234 function ucDaysLink( $lim, $d )
236 global $wgUser, $wgLang, $wgRequest;
238 $target = $wgRequest->getText( 'target' );
239 $sk = $wgUser->getSkin();
240 $s = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
241 "{$d}", "target={$target}&days={$d}&limit={$lim}" );