From a448e8f9f1cb288db7b61a0770ebd9ecbd4b363a Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Wed, 4 Jun 2008 20:07:56 +0000 Subject: [PATCH] Recommitting User::isActiveUser() as User::isActiveEditor() per suggestions from Brion. --- RELEASE-NOTES | 6 ++++++ includes/DefaultSettings.php | 8 ++++++++ includes/User.php | 26 ++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 6b92d83312..4739e15d1e 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -49,6 +49,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN (default 100) with the new subpage-move functionality of Special:Movepage * Hooks display in Special:Version is now disabled by default, use $wgSpecialVersionShowHooks = true; to enable it. +* $wgActiveUserEditCount sets the number of edits that must be performed over + a certain number of days to be considered active +* $wgActiveUserDays is that number of days === New features in 1.13 === @@ -135,6 +138,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 14263) Show a diff of the revert on rollback notification page. * (bug 13434) Show a warning when hash identical files exist * Sidebar is now cached for all languages +* The User class now contains a public function called isActiveEditor. Figures + out if a user is active based on at least $wgActiveUserEditCount number of + edits in the last $wgActiveUserDays days. === Bug fixes in 1.13 === diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 26ec50ba9a..52fd2ac628 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1280,6 +1280,14 @@ $wgAvailableRights = array(); */ $wgDeleteRevisionsLimit = 0; +/** + * Used to figure out if a user is "active" or not. User::isActiveEditor() + * sees if a user has made at least $wgActiveUserEditCount number of edits + * within the last $wgActiveUserDays days. + */ +$wgActiveUserEditCount = 30; +$wgActiveUserDays = 30; + # Proxy scanner settings # diff --git a/includes/User.php b/includes/User.php index 5a36eea029..689857a8b9 100644 --- a/includes/User.php +++ b/includes/User.php @@ -2445,6 +2445,32 @@ class User { function isNewbie() { return !$this->isAllowed( 'autoconfirmed' ); } + + /** + * Is the user active? We check to see if they've made at least + * X number of edits in the last Y days. + * + * @return bool true if the user is active, false if not + */ + public function isActiveEditor() { + global $wgActiveUserEditCount, $wgActiveUserDays; + $dbr = wfGetDB( DB_SLAVE ); + + // Stolen without shame from RC + $cutoff_unixtime = time() - ( $wgActiveUserDays * 86400 ); + $cutoff_unixtime = $cutoff_unixtime - ( $cutoff_unixtime % 86400 ); + $oldTime = $dbr->addQuotes( $dbr->timestamp( $cutoff_unixtime ) ); + + $res = $dbr->select( 'revision', '1', + array( 'rev_user_text' => $this->getName(), "rev_timestamp > $oldTime"), + __METHOD__, + array('LIMIT' => $wgActiveUserEditCount ) ); + + $count = $dbr->numRows($res); + $dbr->freeResult($res); + + return $count == $wgActiveUserEditCount; + } /** * Check to see if the given clear-text password is one of the accepted passwords -- 2.20.1