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 $wgOut->addHTML( wfMsg ( 'val_user_validations', $val ) );
163 Generates each row in the contributions list.
165 Contributions which are marked "top" are currently on top of the history.
166 For these contributions, a [rollback] link is shown for users with sysop
167 privileges. The rollback link restores the most recent version that was not
168 written by the target user.
170 If the contributions page is called with the parameter &bot=1, all rollback
171 links also get that parameter. It causes the edit itself and the rollback
172 to be marked as "bot" edits. Bot edits are hidden by default from recent
173 changes, so this allows sysops to combat a busy vandal without bothering
176 TODO: This would probably look a lot nicer in a table.
179 function ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, $isminor, $isnew, $target )
181 global $wgLang, $wgOut, $wgUser, $wgRequest;
182 $page = Title
::makeName( $ns, $t );
183 $link = $sk->makeKnownLink( $page, "" );
187 $topmarktext .= $sk->makeKnownLink( $page, wfMsg("uctop"), "diff=0" );
189 $topmarktext .= wfMsg("newarticle");
191 $sysop = $wgUser->isSysop();
193 $extraRollback = $wgRequest->getBool( "bot" ) ?
'&bot=1' : '';
194 # $target = $wgRequest->getText( 'target' );
195 $topmarktext .= " [". $sk->makeKnownLink( $page,
196 wfMsg( "rollbacklink" ),
197 "action=rollback&from=" . urlencode( $target ) . $extraRollback ) ."]";
201 $histlink="(".$sk->makeKnownLink($page,wfMsg("hist"),"action=history").")";
205 $comment="<em>(". $sk->formatComment($comment, Title
::newFromText($t) ) .")</em> ";
208 $d = $wgLang->timeanddate( $ts, true );
211 $mflag = '<span class="minor">'.wfMsg( "minoreditletter" ).'</span> ';
216 $wgOut->addHTML( "<li>{$d} {$histlink} {$mflag} {$link} {$comment}{$topmarktext}</li>\n" );
219 function ucCountLink( $lim, $d )
221 global $wgUser, $wgLang, $wgRequest;
223 $target = $wgRequest->getText( 'target' );
224 $sk = $wgUser->getSkin();
225 $s = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
226 "{$lim}", "target={$target}&days={$d}&limit={$lim}" );
230 function ucDaysLink( $lim, $d )
232 global $wgUser, $wgLang, $wgRequest;
234 $target = $wgRequest->getText( 'target' );
235 $sk = $wgUser->getSkin();
236 $s = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ),
237 "{$d}", "target={$target}&days={$d}&limit={$lim}" );