* Added wg prefix to globals

* Added $wgContribScoreIgnoreBlockedUsers option
This commit is contained in:
Tim Laqua 2008-04-17 17:31:22 +00:00
parent a8ea026569
commit 2e2162fdbc
2 changed files with 22 additions and 27 deletions

View file

@ -15,13 +15,15 @@ $wgExtensionCredits['specialpage'][] = array(
'author'=>'Tim Laqua', 'author'=>'Tim Laqua',
'description'=>'Polls wiki database for highest user contribution volume', 'description'=>'Polls wiki database for highest user contribution volume',
'descriptionmsg' => 'contributionscores-desc', 'descriptionmsg' => 'contributionscores-desc',
'version'=>'1.8' 'version'=>'1.9'
); );
define( 'CONTRIBUTIONSCORES_PATH', dirname( __FILE__ ) ); define( 'CONTRIBUTIONSCORES_PATH', dirname( __FILE__ ) );
define( 'CONTRIBUTIONSCORES_EXTPATH', str_replace( $_SERVER['DOCUMENT_ROOT'], '/', CONTRIBUTIONSCORES_PATH ) ); define( 'CONTRIBUTIONSCORES_EXTPATH', str_replace( $_SERVER['DOCUMENT_ROOT'], '/', CONTRIBUTIONSCORES_PATH ) );
define( 'CONTRIBUTIONSCORES_MAXINCLUDELIMIT', 50 ); define( 'CONTRIBUTIONSCORES_MAXINCLUDELIMIT', 50 );
$contribScoreReports = null; $wgContribScoreReports = null;
$wgContribScoreIgnoreBlockedUsers = false;
$wgContribScoreIgnoreBots = false;
$wgAutoloadClasses['ContributionScores'] = CONTRIBUTIONSCORES_PATH . '/ContributionScores_body.php'; $wgAutoloadClasses['ContributionScores'] = CONTRIBUTIONSCORES_PATH . '/ContributionScores_body.php';
$wgSpecialPages['ContributionScores'] = 'ContributionScores'; $wgSpecialPages['ContributionScores'] = 'ContributionScores';
@ -42,11 +44,3 @@ function efContributionScores() {
$wgMessageCache->addMessages( $messages[$key], $key ); $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;
}
*/

View file

@ -32,7 +32,7 @@ class ContributionScores extends IncludableSpecialPage
* @return HTML Table representing the requested Contribution Scores. * @return HTML Table representing the requested Contribution Scores.
*/ */
function genContributionScoreTable( $days, $limit, $title = null, $options = 'none' ) { function genContributionScoreTable( $days, $limit, $title = null, $options = 'none' ) {
global $contribScoreIgnoreBots, $wgUser; global $wgContribScoreIgnoreBots, $wgContribScoreIgnoreBlockedUsers, $wgUser;
$opts = explode(',', strtolower($options)); $opts = explode(',', strtolower($options));
@ -41,22 +41,26 @@ class ContributionScores extends IncludableSpecialPage
$userTable = $dbr->tableName('user'); $userTable = $dbr->tableName('user');
$userGroupTable = $dbr->tableName('user_groups'); $userGroupTable = $dbr->tableName('user_groups');
$revTable = $dbr->tableName('revision'); $revTable = $dbr->tableName('revision');
$ipBlocksTable = $dbr->tableName('ipblocks');
$sqlWhere = ""; $sqlWhere = "";
$nextPrefix = "WHERE";
if ( $days > 0 ) { if ( $days > 0 ) {
$date = time() - (60*60*24*$days); $date = time() - (60*60*24*$days);
$dateString = $dbr->timestamp($date); $dateString = $dbr->timestamp($date);
$sqlWhere .= " WHERE rev_timestamp > '$dateString' "; $sqlWhere .= " {$nextPrefix} rev_timestamp > '$dateString'";
$nextPrefix = "AND";
} }
if ( $contribScoreIgnoreBots ) { if ( $wgContribScoreIgnoreBlockedUsers ) {
if (preg_match("/where/i", $sqlWhere)) { $sqlWhere .= " {$nextPrefix} rev_user NOT IN (SELECT ipb_user FROM {$ipBlocksTable} WHERE ipb_user <> 0)";
$sqlWhere .= "AND "; $nextPrefix = "AND";
} else { }
$sqlWhere .= "WHERE ";
} if ( $wgContribScoreIgnoreBots ) {
$sqlWhere .= "rev_user NOT IN (SELECT ug_user FROM {$userGroupTable} WHERE ug_group='bot') "; $sqlWhere .= " {$nextPrefix} rev_user NOT IN (SELECT ug_user FROM {$userGroupTable} WHERE ug_group='bot')";
$nextPrefix = "AND";
} }
$sqlMostPages = "SELECT rev_user, $sqlMostPages = "SELECT rev_user,
@ -136,9 +140,6 @@ class ContributionScores extends IncludableSpecialPage
function execute( $par ) { function execute( $par ) {
global $wgRequest, $wgVersion, $wgOut, $wgHooks; global $wgRequest, $wgVersion, $wgOut, $wgHooks;
# Depreciated - manually set styles in MediaWiki:Common.css
# $wgHooks['BeforePageDisplay'][] = 'efContributionScores_addHeadScripts';
if( version_compare( $wgVersion, '1.11', '>=' ) ) if( version_compare( $wgVersion, '1.11', '>=' ) )
wfLoadExtensionMessages( 'ContributionScores' ); wfLoadExtensionMessages( 'ContributionScores' );
@ -187,10 +188,10 @@ class ContributionScores extends IncludableSpecialPage
} }
function showPage() { function showPage() {
global $wgOut, $contribScoreReports; global $wgOut, $wgContribScoreReports;
if (!is_array($contribScoreReports)) { if (!is_array($wgContribScoreReports)) {
$contribScoreReports = array( $wgContribScoreReports = array(
array(7,50), array(7,50),
array(30,50), array(30,50),
array(0,50)); array(0,50));
@ -198,7 +199,7 @@ class ContributionScores extends IncludableSpecialPage
$wgOut->addWikiText( wfMsg( 'contributionscores-info' ) ); $wgOut->addWikiText( wfMsg( 'contributionscores-info' ) );
foreach ( $contribScoreReports as $scoreReport) { foreach ( $wgContribScoreReports as $scoreReport) {
if ( $scoreReport[0] > 0 ) { if ( $scoreReport[0] > 0 ) {
$reportTitle = wfMsg( 'contributionscores-days', $scoreReport[0] ); $reportTitle = wfMsg( 'contributionscores-days', $scoreReport[0] );
} else { } else {