X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSpecialContributions.php;h=d90540fb2ff3889348f500a910d0d6bd3a348ac8;hb=ba6b4c048e434ddc495e96976a9f12aea208449c;hp=a68c7c20b7a593a01adc5af814e91118397c9619;hpb=014093acc4e0c277d0d92fdc54fb620210d6ec8a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SpecialContributions.php b/includes/SpecialContributions.php index a68c7c20b7..d90540fb2f 100644 --- a/includes/SpecialContributions.php +++ b/includes/SpecialContributions.php @@ -1,79 +1,106 @@ isSysop(); if( $par ) $target = $par; else - $target = $wgResult->getVal( 'target' ); + $target = $wgRequest->getVal( 'target' ); if ( "" == $target ) { $wgOut->errorpage( "notargettitle", "notargettext" ); return; } - + # FIXME: Change from numeric offsets to date offsets list( $limit, $offset ) = wfCheckLimits( 50, "" ); $offlimit = $limit + $offset; $querylimit = $offlimit + 1; $hideminor = ($wgRequest->getVal( 'hideminor' ) ? 1 : 0); + $sk = $wgUser->getSkin(); + $dbr =& wfGetDB( DB_SLAVE ); + $userCond = ""; $nt = Title::newFromURL( $target ); + if ( !$nt ) { + $wgOut->errorpage( "notargettitle", "notargettext" ); + return; + } $nt->setNamespace( Namespace::getUser() ); - $sk = $wgUser->getSkin(); $id = User::idFromName( $nt->getText() ); if ( 0 == $id ) { $ul = $nt->getText(); } else { - $ul = $sk->makeLinkObj( $nt, $nt->getText() ); + $ul = $sk->makeLinkObj( $nt, htmlspecialchars( $nt->getText() ) ); + $userCond = "=" . $id; } $talk = $nt->getTalkPage(); - if( $talk ) + if( $talk ) { $ul .= " (" . $sk->makeLinkObj( $talk, $wgLang->getNsText(Namespace::getTalk(0)) ) . ")"; - else - $ul .= "brrrp"; + } + + + if ( $target == 'newbies' ) { + # View the contributions of all recently created accounts + $max = $dbr->selectField( 'user', 'max(user_id)', false, $fname ); + $userCond = ">" . ($max - $max / 100); + $ul = wfMsg ( 'newbies' ); + $id = 0; + } + $wgOut->setSubtitle( wfMsg( "contribsub", $ul ) ); if ( $hideminor ) { $cmq = "AND cur_minor_edit=0"; $omq = "AND old_minor_edit=0"; $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ), - WfMsg( "show" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) . + WfMsg( "show" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) . "&offset={$offset}&limit={$limit}&hideminor=0" ); } else { $cmq = $omq = ""; $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ), - WfMsg( "hide" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) . + WfMsg( "hide" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) . "&offset={$offset}&limit={$limit}&hideminor=1" ); } - if ( 0 == $id ) { - $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit FROM cur " . - "WHERE cur_user_text='" . wfStrencode( $nt->getText() ) . "' {$cmq} " . + extract( $dbr->tableNames( 'old', 'cur' ) ); + if ( $userCond == "" ) { + $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit,cur_is_new,cur_user_text FROM $cur " . + "WHERE cur_user_text='" . $dbr->strencode( $nt->getText() ) . "' {$cmq} " . "ORDER BY inverse_timestamp LIMIT {$querylimit}"; - $res1 = wfQuery( $sql, DB_READ, $fname ); + $res1 = $dbr->query( $sql, $fname ); - $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit FROM old " . - "WHERE old_user_text='" . wfStrencode( $nt->getText() ) . "' {$omq} " . + $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit,old_user_text,old_id FROM $old " . + "WHERE old_user_text='" . $dbr->strencode( $nt->getText() ) . "' {$omq} " . "ORDER BY inverse_timestamp LIMIT {$querylimit}"; - $res2 = wfQuery( $sql, DB_READ, $fname ); + $res2 = $dbr->query( $sql, $fname ); } else { - $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit FROM cur " . - "WHERE cur_user={$id} {$cmq} ORDER BY inverse_timestamp LIMIT {$querylimit}"; - $res1 = wfQuery( $sql, DB_READ, $fname ); + $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit,cur_is_new,cur_user_text FROM $cur " . + "WHERE cur_user {$userCond} {$cmq} ORDER BY inverse_timestamp LIMIT {$querylimit}"; + $res1 = $dbr->query( $sql, $fname ); - $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit FROM old " . - "WHERE old_user={$id} {$omq} ORDER BY inverse_timestamp LIMIT {$querylimit}"; - $res2 = wfQuery( $sql, DB_READ, $fname ); + $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit,old_user_text,old_id FROM $old " . + "WHERE old_user {$userCond} {$omq} ORDER BY inverse_timestamp LIMIT {$querylimit}"; + $res2 = $dbr->query( $sql, $fname ); } - $nCur = wfNumRows( $res1 ); - $nOld = wfNumRows( $res2 ); + $nCur = $dbr->numRows( $res1 ); + $nOld = $dbr->numRows( $res2 ); $top = wfShowingResults( $offset, $limit ); $wgOut->addHTML( "
{$top}\n" );
@@ -84,15 +111,15 @@ function wfSpecialContributions( $par = "" )
($nCur + $nOld) <= $offlimit);
$shm = wfMsg( "showhideminor", $mlink );
- $wgOut->addHTML( "
{$sl} ($shm) \n");
-
+ $wgOut->addHTML( "
{$sl} ($shm)
" . wfMsg( "nocontribs" ) . "
\n" ); return; } - if ( 0 != $nCur ) { $obj1 = wfFetchObject( $res1 ); } - if ( 0 != $nOld ) { $obj2 = wfFetchObject( $res2 ); } + if ( 0 != $nCur ) { $obj1 = $dbr->fetchObject( $res1 ); } + if ( 0 != $nOld ) { $obj2 = $dbr->fetchObject( $res2 ); } $wgOut->addHTML( "