From c1791ef7429ff76cc3db22749beebd912b2b25c6 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Tue, 23 Jan 2007 21:20:49 +0000 Subject: [PATCH] This script pass through all users and change their skins from 'oldSkinName' to 'newSkinName'. There is NO validation about the new skin existence! Made on an original idea by Fooey (freenode) --- maintenance/cleanupSkin.php | 93 +++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 maintenance/cleanupSkin.php diff --git a/maintenance/cleanupSkin.php b/maintenance/cleanupSkin.php new file mode 100644 index 0000000000..32bad30984 --- /dev/null +++ b/maintenance/cleanupSkin.php @@ -0,0 +1,93 @@ + + */ + +// Options we will use +$options = array( 'quick' ); +$optionsWithArgs = array( 'old', 'new' ); + +// This is a command line script, load tools and parse args +require_once( 'commandLine.inc' ); + +// Check for mandatory options or print an usage message +if( !(isset($options['old']) && isset($options['new']) ) ) { +print << --new + [--quick] [--quiet] + +Options: + --old : the old skin name + --new : new skin name to update users with + --quick : hides the 5 seconds warning + --quiet : do not print what is happening + + +USAGE; + exit(0); +} + +// Load up the arguments: +$oldSkinName = $options['old']; +$newSkinName = $options['new']; +$quick = isset($options['quick']); +$quiet = isset($options['quiet']); + +// We list the user by user_id from one of the slave databases +$dbr = wfGetDB( DB_SLAVE ); +$result = $dbr->select( 'user', + array( 'user_id' ), + array(), + __FILE__ + ); + +// The warning message and countdown +if( !$quick ) { +print <<=1;) { + print_c($i, --$i); + sleep(1); + } + print "\n"; +} + +// Iterate through the users +while( $id = $dbr->fetchObject( $result ) ) { + + $user = User::newFromId( $id->user_id ); + + // We get this users informations + $curSkinName = $user->getOption( 'skin' ); + $username = $user->getName(); + + // Is he using the skin we want to migrate ? + if( $curSkinName == $oldSkinName ) { + + if(!$quiet) print "Changing skin for $username ('$oldSkinName' -> '$newSkinName'):"; + + // Change skin and save it + $user->setOption( 'skin', $newSkinName ); + $user->saveSettings(); + + if(!$quiet) print " OK\n"; + } elseif(!$quiet) { + print "Not changing '$username' using skin '$curSkinName'\n"; + } +} +print "Done.\n"; +?> -- 2.20.1