No need for (1), keep tinyint consistent with the other booleans.
[lhc/web/wiklou.git] / maintenance / reassignEdits.php
index 751d200..07f81b8 100644 (file)
@@ -3,29 +3,40 @@
 /**
  * Reassign edits from a user or IP address to another user
  *
- * @package MediaWiki
- * @subpackage Maintenance
+ * @addtogroup Maintenance
  * @author Rob Church <robchur@gmail.com>
+ * @licence GNU General Public Licence 2.0 or later
  */
 
-$options = array( 'force' );
+$options = array( 'force', 'norc', 'quiet', 'report' );
 require_once( 'commandLine.inc' );
-require_once( 'reassignEdits.inc' );
+require_once( 'reassignEdits.inc.php' );
 
-echo( "Reassign Edits\n\n" );
+# Set silent mode; --report overrides --quiet
+if( !@$options['report'] && @$options['quiet'] )
+       setSilent();
+       
+out( "Reassign Edits\n\n" );
 
 if( @$args[0] && @$args[1] ) {
 
-       $from = GetUserDetails( $args[0] );
-       $to   = GetUserDetails( $args[1] );
-       $tor  = $args[1];
+       # Set up the users involved
+       $from =& initialiseUser( $args[0] );
+       $to   =& initialiseUser( $args[1] );
        
-       if( $to['valid'] || @$options['force'] ) {
-               ReassignEdits( $from, $to );
+       # If the target doesn't exist, and --force is not set, stop here
+       if( $to->getId() || @$options['force'] ) {
+               # Reassign the edits
+               $report = @$options['report'];
+               $count = reassignEdits( $from, $to, !@$options['norc'], $report );
+               # If reporting, and there were items, advise the user to run without --report   
+               if( $report )
+                       out( "Run the script again without --report to update.\n" );
        } else {
-               echo( "User \"$tor\" not found.\n" );
+               $ton = $to->getName();
+               echo( "User '{$ton}' not found.\n" );
        }
-
+       
 } else {
        ShowUsage();
 }
@@ -33,10 +44,12 @@ if( @$args[0] && @$args[1] ) {
 /** Show script usage information */
 function ShowUsage() {
        echo( "Reassign edits from one user to another.\n\n" );
-       echo( "Usage: php reassignEdits.php <from> <to> [--force]\n\n" );
+       echo( "Usage: php reassignEdits.php [--force|--quiet|--norc|--report] <from> <to>\n\n" );
        echo( "    <from> : Name of the user to assign edits from\n" );
        echo( "      <to> : Name of the user to assign edits to\n" );
-       echo( "   --force : Reassign even if the target user doesn't exist\n\n" );
+       echo( "   --force : Reassign even if the target user doesn't exist\n" );
+       echo( "   --quiet : Don't print status information (except for errors)\n" );
+       echo( "    --norc : Don't update the recent changes table\n" );
+       echo( "  --report : Print out details of what would be changed, but don't update it\n\n" );
 }
 
-?>
\ No newline at end of file