diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2009-02-22 13:37:51 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2009-02-22 13:37:51 +0100 |
commit | b9b85843572bf283f48285001e276ba7e61b63f6 (patch) | |
tree | 4c6f4571552ada9ccfb4030481dcf77308f8b254 /maintenance/removeUnusedAccounts.php | |
parent | d9a20acc4e789cca747ad360d87ee3f3e7aa58c1 (diff) |
updated to MediaWiki 1.14.0
Diffstat (limited to 'maintenance/removeUnusedAccounts.php')
-rw-r--r-- | maintenance/removeUnusedAccounts.php | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/maintenance/removeUnusedAccounts.php b/maintenance/removeUnusedAccounts.php index 636832cb..419955b0 100644 --- a/maintenance/removeUnusedAccounts.php +++ b/maintenance/removeUnusedAccounts.php @@ -8,10 +8,6 @@ * @author Rob Church <robchur@gmail.com> */ -/** - * @todo Don't delete sysops or bureaucrats - */ - $options = array( 'help', 'delete' ); require_once( 'commandLine.inc' ); require_once( 'removeUnusedAccounts.inc' ); @@ -27,10 +23,29 @@ if( isset( $options['help'] ) ) { echo( "Checking for unused user accounts...\n" ); $del = array(); $dbr = wfGetDB( DB_SLAVE ); -$res = $dbr->select( 'user', array( 'user_id', 'user_name' ), '', $fname ); +$res = $dbr->select( 'user', array( 'user_id', 'user_name', 'user_touched' ), '', $fname ); +if( isset( $options['ignore-groups'] ) ) { + $excludedGroups = explode( ',', $options['ignore-groups'] ); +} else { $excludedGroups = array(); } +$touchedSeconds = 0; +if( isset( $options['ignore-touched'] ) ) { + $touchedParamError = 0; + if( ctype_digit( $options['ignore-touched'] ) ) { + if( $options['ignore-touched'] <= 0 ) { + $touchedParamError = 1; + } + } else { $touchedParamError = 1; } + if( $touchedParamError == 1 ) { + die( "Please put a valid positive integer on the --ignore-touched parameter.\n" ); + } else { $touchedSeconds = 86400 * $options['ignore-touched']; } +} while( $row = $dbr->fetchObject( $res ) ) { - # Check the account, but ignore it if it's the primary administrator - if( $row->user_id > 1 && isInactiveAccount( $row->user_id, true ) ) { + # Check the account, but ignore it if it's within a $excludedGroups group or if it's touched within the $touchedSeconds seconds. + $instance = User::newFromId( $row->user_id ); + if( count( array_intersect( $instance->getEffectiveGroups(), $excludedGroups ) ) == 0 + && isInactiveAccount( $row->user_id, true ) + && wfTimestamp( TS_UNIX, $row->user_touched ) < wfTimestamp( TS_UNIX, time() - $touchedSeconds ) + ) { # Inactive; print out the name and flag it $del[] = $row->user_id; echo( $row->user_name . "\n" ); @@ -53,5 +68,3 @@ if( $count > 0 && isset( $options['delete'] ) ) { echo( "\nRun the script again with --delete to remove them from the database.\n" ); } echo( "\n" ); - - |