* Added wg prefix to globals
* Added $wgContribScoreIgnoreBlockedUsers option
This commit is contained in:
parent
a8ea026569
commit
2e2162fdbc
2 changed files with 22 additions and 27 deletions
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/** \file
|
||||
* \brief Contains setup code for the Contribution Scores Extension.
|
||||
* \brief Contains setup code for the Contribution Scores Extension.
|
||||
*/
|
||||
|
||||
# Not a valid entry point, skip unless MEDIAWIKI is defined
|
||||
|
@ -15,13 +15,15 @@ $wgExtensionCredits['specialpage'][] = array(
|
|||
'author'=>'Tim Laqua',
|
||||
'description'=>'Polls wiki database for highest user contribution volume',
|
||||
'descriptionmsg' => 'contributionscores-desc',
|
||||
'version'=>'1.8'
|
||||
'version'=>'1.9'
|
||||
);
|
||||
|
||||
define( 'CONTRIBUTIONSCORES_PATH', dirname( __FILE__ ) );
|
||||
define( 'CONTRIBUTIONSCORES_EXTPATH', str_replace( $_SERVER['DOCUMENT_ROOT'], '/', CONTRIBUTIONSCORES_PATH ) );
|
||||
define( 'CONTRIBUTIONSCORES_MAXINCLUDELIMIT', 50 );
|
||||
$contribScoreReports = null;
|
||||
$wgContribScoreReports = null;
|
||||
$wgContribScoreIgnoreBlockedUsers = false;
|
||||
$wgContribScoreIgnoreBots = false;
|
||||
|
||||
$wgAutoloadClasses['ContributionScores'] = CONTRIBUTIONSCORES_PATH . '/ContributionScores_body.php';
|
||||
$wgSpecialPages['ContributionScores'] = 'ContributionScores';
|
||||
|
@ -42,11 +44,3 @@ function efContributionScores() {
|
|||
$wgMessageCache->addMessages( $messages[$key], $key );
|
||||
}
|
||||
}
|
||||
|
||||
# Depreciated in v1.8 - manually add CSS via MediaWiki:Common.css
|
||||
/*
|
||||
function efContributionScores_addHeadScripts(&$out) {
|
||||
$out->addScript( '<link rel="stylesheet" type="text/css" href="' . CONTRIBUTIONSCORES_EXTPATH . '/ContributionScores.css" />' . "\n" );
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -32,7 +32,7 @@ class ContributionScores extends IncludableSpecialPage
|
|||
* @return HTML Table representing the requested Contribution Scores.
|
||||
*/
|
||||
function genContributionScoreTable( $days, $limit, $title = null, $options = 'none' ) {
|
||||
global $contribScoreIgnoreBots, $wgUser;
|
||||
global $wgContribScoreIgnoreBots, $wgContribScoreIgnoreBlockedUsers, $wgUser;
|
||||
|
||||
$opts = explode(',', strtolower($options));
|
||||
|
||||
|
@ -41,24 +41,28 @@ class ContributionScores extends IncludableSpecialPage
|
|||
$userTable = $dbr->tableName('user');
|
||||
$userGroupTable = $dbr->tableName('user_groups');
|
||||
$revTable = $dbr->tableName('revision');
|
||||
$ipBlocksTable = $dbr->tableName('ipblocks');
|
||||
|
||||
$sqlWhere = "";
|
||||
$nextPrefix = "WHERE";
|
||||
|
||||
if ( $days > 0 ) {
|
||||
$date = time() - (60*60*24*$days);
|
||||
$dateString = $dbr->timestamp($date);
|
||||
$sqlWhere .= " WHERE rev_timestamp > '$dateString' ";
|
||||
$sqlWhere .= " {$nextPrefix} rev_timestamp > '$dateString'";
|
||||
$nextPrefix = "AND";
|
||||
}
|
||||
|
||||
if ( $contribScoreIgnoreBots ) {
|
||||
if (preg_match("/where/i", $sqlWhere)) {
|
||||
$sqlWhere .= "AND ";
|
||||
} else {
|
||||
$sqlWhere .= "WHERE ";
|
||||
}
|
||||
$sqlWhere .= "rev_user NOT IN (SELECT ug_user FROM {$userGroupTable} WHERE ug_group='bot') ";
|
||||
if ( $wgContribScoreIgnoreBlockedUsers ) {
|
||||
$sqlWhere .= " {$nextPrefix} rev_user NOT IN (SELECT ipb_user FROM {$ipBlocksTable} WHERE ipb_user <> 0)";
|
||||
$nextPrefix = "AND";
|
||||
}
|
||||
|
||||
if ( $wgContribScoreIgnoreBots ) {
|
||||
$sqlWhere .= " {$nextPrefix} rev_user NOT IN (SELECT ug_user FROM {$userGroupTable} WHERE ug_group='bot')";
|
||||
$nextPrefix = "AND";
|
||||
}
|
||||
|
||||
$sqlMostPages = "SELECT rev_user,
|
||||
COUNT(DISTINCT rev_page) AS page_count,
|
||||
COUNT(rev_id) AS rev_count
|
||||
|
@ -136,9 +140,6 @@ class ContributionScores extends IncludableSpecialPage
|
|||
function execute( $par ) {
|
||||
global $wgRequest, $wgVersion, $wgOut, $wgHooks;
|
||||
|
||||
# Depreciated - manually set styles in MediaWiki:Common.css
|
||||
# $wgHooks['BeforePageDisplay'][] = 'efContributionScores_addHeadScripts';
|
||||
|
||||
if( version_compare( $wgVersion, '1.11', '>=' ) )
|
||||
wfLoadExtensionMessages( 'ContributionScores' );
|
||||
|
||||
|
@ -187,10 +188,10 @@ class ContributionScores extends IncludableSpecialPage
|
|||
}
|
||||
|
||||
function showPage() {
|
||||
global $wgOut, $contribScoreReports;
|
||||
global $wgOut, $wgContribScoreReports;
|
||||
|
||||
if (!is_array($contribScoreReports)) {
|
||||
$contribScoreReports = array(
|
||||
if (!is_array($wgContribScoreReports)) {
|
||||
$wgContribScoreReports = array(
|
||||
array(7,50),
|
||||
array(30,50),
|
||||
array(0,50));
|
||||
|
@ -198,7 +199,7 @@ class ContributionScores extends IncludableSpecialPage
|
|||
|
||||
$wgOut->addWikiText( wfMsg( 'contributionscores-info' ) );
|
||||
|
||||
foreach ( $contribScoreReports as $scoreReport) {
|
||||
foreach ( $wgContribScoreReports as $scoreReport) {
|
||||
if ( $scoreReport[0] > 0 ) {
|
||||
$reportTitle = wfMsg( 'contributionscores-days', $scoreReport[0] );
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue