Use Doxygen @addtogroup instead of phpdoc @package && @subpackage
[lhc/web/wiklou.git] / maintenance / removeUnusedAccounts.inc
1 <?php
2
3 /**
4 * Support functions for the removeUnusedAccounts maintenance script
5 *
6 *
7 * @addtogroup Maintenance
8 * @author Rob Church <robchur@gmail.com>
9 */
10
11 /**
12 * Could the specified user account be deemed inactive?
13 * (No edits, no deleted edits, no log entries, no current/old uploads)
14 *
15 * @param $id User's ID
16 * @param $master Perform checking on the master
17 * @return bool
18 */
19 function isInactiveAccount( $id, $master = false ) {
20 $dbo =& wfGetDB( $master ? DB_MASTER : DB_SLAVE );
21 $fname = 'isInactiveAccount';
22 $checks = array( 'revision' => 'rev', 'archive' => 'ar', 'logging' => 'log',
23 'image' => 'img', 'oldimage' => 'oi' );
24 $count = 0;
25
26 $dbo->immediateBegin();
27 foreach( $checks as $table => $fprefix ) {
28 $conds = array( $fprefix . '_user' => $id );
29 $count += (int)$dbo->selectField( $table, 'COUNT(*)', $conds, $fname );
30 }
31 $dbo->immediateCommit();
32
33 return $count == 0;
34 }
35
36 /**
37 * Show help for the maintenance script
38 */
39 function showHelp() {
40 echo( "Delete unused user accounts from the database.\n\n" );
41 echo( "USAGE: php removeUnusedAccounts.php [--delete]\n\n" );
42 echo( " --delete : Delete accounts which are discovered to be inactive\n" );
43 echo( "\n" );
44 }
45
46 ?>