Index: trunk/extensions/ContributionScores/ContributionScores_body.php |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | * @return HTML Table representing the requested Contribution Scores. |
34 | 34 | */ |
35 | 35 | function genContributionScoreTable( $days, $limit, $title = null, $options = 'none' ) { |
36 | | - global $contribScoreIgnoreBots, $wgUser; |
| 36 | + global $wgContribScoreIgnoreBots, $wgContribScoreIgnoreBlockedUsers, $wgUser; |
37 | 37 | |
38 | 38 | $opts = explode(',', strtolower($options)); |
39 | 39 | |
— | — | @@ -41,24 +41,28 @@ |
42 | 42 | $userTable = $dbr->tableName('user'); |
43 | 43 | $userGroupTable = $dbr->tableName('user_groups'); |
44 | 44 | $revTable = $dbr->tableName('revision'); |
| 45 | + $ipBlocksTable = $dbr->tableName('ipblocks'); |
45 | 46 | |
46 | 47 | $sqlWhere = ""; |
| 48 | + $nextPrefix = "WHERE"; |
47 | 49 | |
48 | 50 | if ( $days > 0 ) { |
49 | 51 | $date = time() - (60*60*24*$days); |
50 | 52 | $dateString = $dbr->timestamp($date); |
51 | | - $sqlWhere .= " WHERE rev_timestamp > '$dateString' "; |
| 53 | + $sqlWhere .= " {$nextPrefix} rev_timestamp > '$dateString'"; |
| 54 | + $nextPrefix = "AND"; |
52 | 55 | } |
53 | 56 | |
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"; |
61 | 60 | } |
62 | 61 | |
| 62 | + if ( $wgContribScoreIgnoreBots ) { |
| 63 | + $sqlWhere .= " {$nextPrefix} rev_user NOT IN (SELECT ug_user FROM {$userGroupTable} WHERE ug_group='bot')"; |
| 64 | + $nextPrefix = "AND"; |
| 65 | + } |
| 66 | + |
63 | 67 | $sqlMostPages = "SELECT rev_user, |
64 | 68 | COUNT(DISTINCT rev_page) AS page_count, |
65 | 69 | COUNT(rev_id) AS rev_count |
— | — | @@ -136,9 +140,6 @@ |
137 | 141 | function execute( $par ) { |
138 | 142 | global $wgRequest, $wgVersion, $wgOut, $wgHooks; |
139 | 143 | |
140 | | - # Depreciated - manually set styles in MediaWiki:Common.css |
141 | | - # $wgHooks['BeforePageDisplay'][] = 'efContributionScores_addHeadScripts'; |
142 | | - |
143 | 144 | if( version_compare( $wgVersion, '1.11', '>=' ) ) |
144 | 145 | wfLoadExtensionMessages( 'ContributionScores' ); |
145 | 146 | |
— | — | @@ -187,10 +188,10 @@ |
188 | 189 | } |
189 | 190 | |
190 | 191 | function showPage() { |
191 | | - global $wgOut, $contribScoreReports; |
| 192 | + global $wgOut, $wgContribScoreReports; |
192 | 193 | |
193 | | - if (!is_array($contribScoreReports)) { |
194 | | - $contribScoreReports = array( |
| 194 | + if (!is_array($wgContribScoreReports)) { |
| 195 | + $wgContribScoreReports = array( |
195 | 196 | array(7,50), |
196 | 197 | array(30,50), |
197 | 198 | array(0,50)); |
— | — | @@ -198,7 +199,7 @@ |
199 | 200 | |
200 | 201 | $wgOut->addWikiText( wfMsg( 'contributionscores-info' ) ); |
201 | 202 | |
202 | | - foreach ( $contribScoreReports as $scoreReport) { |
| 203 | + foreach ( $wgContribScoreReports as $scoreReport) { |
203 | 204 | if ( $scoreReport[0] > 0 ) { |
204 | 205 | $reportTitle = wfMsg( 'contributionscores-days', $scoreReport[0] ); |
205 | 206 | } else { |
Index: trunk/extensions/ContributionScores/ContributionScores.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | /** \file |
4 | | -* \brief Contains setup code for the Contribution Scores Extension. |
| 4 | +* \brief Contains setup code for the Contribution Scores Extension. |
5 | 5 | */ |
6 | 6 | |
7 | 7 | # Not a valid entry point, skip unless MEDIAWIKI is defined |
— | — | @@ -15,13 +15,15 @@ |
16 | 16 | 'author'=>'Tim Laqua', |
17 | 17 | 'description'=>'Polls wiki database for highest user contribution volume', |
18 | 18 | 'descriptionmsg' => 'contributionscores-desc', |
19 | | - 'version'=>'1.8' |
| 19 | + 'version'=>'1.9' |
20 | 20 | ); |
21 | 21 | |
22 | 22 | define( 'CONTRIBUTIONSCORES_PATH', dirname( __FILE__ ) ); |
23 | 23 | define( 'CONTRIBUTIONSCORES_EXTPATH', str_replace( $_SERVER['DOCUMENT_ROOT'], '/', CONTRIBUTIONSCORES_PATH ) ); |
24 | 24 | define( 'CONTRIBUTIONSCORES_MAXINCLUDELIMIT', 50 ); |
25 | | -$contribScoreReports = null; |
| 25 | +$wgContribScoreReports = null; |
| 26 | +$wgContribScoreIgnoreBlockedUsers = false; |
| 27 | +$wgContribScoreIgnoreBots = false; |
26 | 28 | |
27 | 29 | $wgAutoloadClasses['ContributionScores'] = CONTRIBUTIONSCORES_PATH . '/ContributionScores_body.php'; |
28 | 30 | $wgSpecialPages['ContributionScores'] = 'ContributionScores'; |
— | — | @@ -42,11 +44,3 @@ |
43 | 45 | $wgMessageCache->addMessages( $messages[$key], $key ); |
44 | 46 | } |
45 | 47 | } |
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 | | -*/ |