* @author Rob Church <robchur@gmail.com>
*/
-
$options = array( 'help', 'delete' );
require_once( 'commandLine.inc' );
require_once( 'removeUnusedAccounts.inc' );
if( isset( $options['help'] ) ) {
showHelp();
- exit();
+ exit(1);
}
# Do an initial scan for inactive accounts and report the result
$del = array();
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select( 'user', array( 'user_id', 'user_name', 'user_touched' ), '', $fname );
-$excludedGroups = array( 'sysop', 'bureaucrat' );
+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 within the "sysop" or "bureaucrat" group.
+ # 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->getGroups(), $excludedGroups ) ) == 0
- && isInactiveAccount( $row->user_id, true )
- && wfTimestamp( TS_UNIX, $row->user_touched ) < wfTimestamp( TS_UNIX, time() - 604800 )
+ 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;