]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - maintenance/reassignEdits.php
MediaWiki 1.14.0-scripts
[autoinstallsdev/mediawiki.git] / maintenance / reassignEdits.php
1 <?php
2
3 /**
4  * Reassign edits from a user or IP address to another user
5  *
6  * @file
7  * @ingroup Maintenance
8  * @author Rob Church <robchur@gmail.com>
9  * @licence GNU General Public Licence 2.0 or later
10  */
11
12 $options = array( 'force', 'norc', 'quiet', 'report' );
13 require_once( 'commandLine.inc' );
14 require_once( 'reassignEdits.inc.php' );
15
16 # Set silent mode; --report overrides --quiet
17 if( !@$options['report'] && @$options['quiet'] )
18         setSilent();
19         
20 out( "Reassign Edits\n\n" );
21
22 if( @$args[0] && @$args[1] ) {
23
24         # Set up the users involved
25         $from =& initialiseUser( $args[0] );
26         $to   =& initialiseUser( $args[1] );
27         
28         # If the target doesn't exist, and --force is not set, stop here
29         if( $to->getId() || @$options['force'] ) {
30                 # Reassign the edits
31                 $report = @$options['report'];
32                 $count = reassignEdits( $from, $to, !@$options['norc'], $report );
33                 # If reporting, and there were items, advise the user to run without --report   
34                 if( $report )
35                         out( "Run the script again without --report to update.\n" );
36         } else {
37                 $ton = $to->getName();
38                 echo( "User '{$ton}' not found.\n" );
39         }
40         
41 } else {
42         ShowUsage();
43 }
44
45 /** Show script usage information */
46 function ShowUsage() {
47         echo( "Reassign edits from one user to another.\n\n" );
48         echo( "Usage: php reassignEdits.php [--force|--quiet|--norc|--report] <from> <to>\n\n" );
49         echo( "    <from> : Name of the user to assign edits from\n" );
50         echo( "      <to> : Name of the user to assign edits to\n" );
51         echo( "   --force : Reassign even if the target user doesn't exist\n" );
52         echo( "   --quiet : Don't print status information (except for errors)\n" );
53         echo( "    --norc : Don't update the recent changes table\n" );
54         echo( "  --report : Print out details of what would be changed, but don't update it\n\n" );
55 }
56