From 183851b06bd6c52f3cae5375f433da720d410447 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 11 Oct 2006 18:12:39 +0000 Subject: MediaWiki 1.7.1 wiederhergestellt --- maintenance/removeUnusedAccounts.inc | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 maintenance/removeUnusedAccounts.inc (limited to 'maintenance/removeUnusedAccounts.inc') diff --git a/maintenance/removeUnusedAccounts.inc b/maintenance/removeUnusedAccounts.inc new file mode 100644 index 00000000..ac15ebef --- /dev/null +++ b/maintenance/removeUnusedAccounts.inc @@ -0,0 +1,47 @@ + + */ + +/** + * Could the specified user account be deemed inactive? + * (No edits, no deleted edits, no log entries, no current/old uploads) + * + * @param $id User's ID + * @param $master Perform checking on the master + * @return bool + */ +function isInactiveAccount( $id, $master = false ) { + $dbo =& wfGetDB( $master ? DB_MASTER : DB_SLAVE ); + $fname = 'isInactiveAccount'; + $checks = array( 'revision' => 'rev', 'archive' => 'ar', 'logging' => 'log', + 'image' => 'img', 'oldimage' => 'oi' ); + $count = 0; + + $dbo->immediateBegin(); + foreach( $checks as $table => $fprefix ) { + $conds = array( $fprefix . '_user' => $id ); + $count += (int)$dbo->selectField( $table, 'COUNT(*)', $conds, $fname ); + } + $dbo->immediateCommit(); + + return $count == 0; +} + +/** + * Show help for the maintenance script + */ +function showHelp() { + echo( "Delete unused user accounts from the database.\n\n" ); + echo( "USAGE: php removeUnusedAccounts.php [--delete]\n\n" ); + echo( " --delete : Delete accounts which are discovered to be inactive\n" ); + echo( "\n" ); +} + +?> \ No newline at end of file -- cgit v1.2.3-54-g00ecf