r33496 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r33495‎ | r33496 | r33497 >
Date:17:31, 17 April 2008
Author:tlaqua
Status:old
Tags:
Comment:
* Added wg prefix to globals
* Added $wgContribScoreIgnoreBlockedUsers option
Modified paths:
  • /trunk/extensions/ContributionScores/ContributionScores.php (modified) (history)
  • /trunk/extensions/ContributionScores/ContributionScores_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ContributionScores/ContributionScores_body.php
@@ -32,7 +32,7 @@
3333 * @return HTML Table representing the requested Contribution Scores.
3434 */
3535 function genContributionScoreTable( $days, $limit, $title = null, $options = 'none' ) {
36 - global $contribScoreIgnoreBots, $wgUser;
 36+ global $wgContribScoreIgnoreBots, $wgContribScoreIgnoreBlockedUsers, $wgUser;
3737
3838 $opts = explode(',', strtolower($options));
3939
@@ -41,24 +41,28 @@
4242 $userTable = $dbr->tableName('user');
4343 $userGroupTable = $dbr->tableName('user_groups');
4444 $revTable = $dbr->tableName('revision');
 45+ $ipBlocksTable = $dbr->tableName('ipblocks');
4546
4647 $sqlWhere = "";
 48+ $nextPrefix = "WHERE";
4749
4850 if ( $days > 0 ) {
4951 $date = time() - (60*60*24*$days);
5052 $dateString = $dbr->timestamp($date);
51 - $sqlWhere .= " WHERE rev_timestamp > '$dateString' ";
 53+ $sqlWhere .= " {$nextPrefix} rev_timestamp > '$dateString'";
 54+ $nextPrefix = "AND";
5255 }
5356
54 - if ( $contribScoreIgnoreBots ) {
55 - if (preg_match("/where/i", $sqlWhere)) {
56 - $sqlWhere .= "AND ";
57 - } else {
58 - $sqlWhere .= "WHERE ";
59 - }
60 - $sqlWhere .= "rev_user NOT IN (SELECT ug_user FROM {$userGroupTable} WHERE ug_group='bot') ";
 57+ if ( $wgContribScoreIgnoreBlockedUsers ) {
 58+ $sqlWhere .= " {$nextPrefix} rev_user NOT IN (SELECT ipb_user FROM {$ipBlocksTable} WHERE ipb_user <> 0)";
 59+ $nextPrefix = "AND";
6160 }
6261
 62+ if ( $wgContribScoreIgnoreBots ) {
 63+ $sqlWhere .= " {$nextPrefix} rev_user NOT IN (SELECT ug_user FROM {$userGroupTable} WHERE ug_group='bot')";
 64+ $nextPrefix = "AND";
 65+ }
 66+
6367 $sqlMostPages = "SELECT rev_user,
6468 COUNT(DISTINCT rev_page) AS page_count,
6569 COUNT(rev_id) AS rev_count
@@ -136,9 +140,6 @@
137141 function execute( $par ) {
138142 global $wgRequest, $wgVersion, $wgOut, $wgHooks;
139143
140 - # Depreciated - manually set styles in MediaWiki:Common.css
141 - # $wgHooks['BeforePageDisplay'][] = 'efContributionScores_addHeadScripts';
142 -
143144 if( version_compare( $wgVersion, '1.11', '>=' ) )
144145 wfLoadExtensionMessages( 'ContributionScores' );
145146
@@ -187,10 +188,10 @@
188189 }
189190
190191 function showPage() {
191 - global $wgOut, $contribScoreReports;
 192+ global $wgOut, $wgContribScoreReports;
192193
193 - if (!is_array($contribScoreReports)) {
194 - $contribScoreReports = array(
 194+ if (!is_array($wgContribScoreReports)) {
 195+ $wgContribScoreReports = array(
195196 array(7,50),
196197 array(30,50),
197198 array(0,50));
@@ -198,7 +199,7 @@
199200
200201 $wgOut->addWikiText( wfMsg( 'contributionscores-info' ) );
201202
202 - foreach ( $contribScoreReports as $scoreReport) {
 203+ foreach ( $wgContribScoreReports as $scoreReport) {
203204 if ( $scoreReport[0] > 0 ) {
204205 $reportTitle = wfMsg( 'contributionscores-days', $scoreReport[0] );
205206 } else {
Index: trunk/extensions/ContributionScores/ContributionScores.php
@@ -1,6 +1,6 @@
22 <?php
33 /** \file
4 -* \brief Contains setup code for the Contribution Scores Extension.
 4+* \brief Contains setup code for the Contribution Scores Extension.
55 */
66
77 # Not a valid entry point, skip unless MEDIAWIKI is defined
@@ -15,13 +15,15 @@
1616 'author'=>'Tim Laqua',
1717 'description'=>'Polls wiki database for highest user contribution volume',
1818 'descriptionmsg' => 'contributionscores-desc',
19 - 'version'=>'1.8'
 19+ 'version'=>'1.9'
2020 );
2121
2222 define( 'CONTRIBUTIONSCORES_PATH', dirname( __FILE__ ) );
2323 define( 'CONTRIBUTIONSCORES_EXTPATH', str_replace( $_SERVER['DOCUMENT_ROOT'], '/', CONTRIBUTIONSCORES_PATH ) );
2424 define( 'CONTRIBUTIONSCORES_MAXINCLUDELIMIT', 50 );
25 -$contribScoreReports = null;
 25+$wgContribScoreReports = null;
 26+$wgContribScoreIgnoreBlockedUsers = false;
 27+$wgContribScoreIgnoreBots = false;
2628
2729 $wgAutoloadClasses['ContributionScores'] = CONTRIBUTIONSCORES_PATH . '/ContributionScores_body.php';
2830 $wgSpecialPages['ContributionScores'] = 'ContributionScores';
@@ -42,11 +44,3 @@
4345 $wgMessageCache->addMessages( $messages[$key], $key );
4446 }
4547 }
46 -
47 -# Depreciated in v1.8 - manually add CSS via MediaWiki:Common.css
48 -/*
49 -function efContributionScores_addHeadScripts(&$out) {
50 - $out->addScript( '<link rel="stylesheet" type="text/css" href="' . CONTRIBUTIONSCORES_EXTPATH . '/ContributionScores.css" />' . "\n" );
51 - return true;
52 -}
53 -*/

Status & tagging log