3 * Script to change users skins on the fly.
4 * This is for at least MediaWiki 1.10alpha (r19611) and have not been
5 * tested with previous versions. It should probably work with 1.7+.
7 * Made on an original idea by Fooey (freenode)
9 * @author Ashar Voultoiz <hashar@altern.org>
12 // Options we will use
13 $options = array( 'quick' );
14 $optionsWithArgs = array( 'old', 'new' );
16 // This is a command line script, load tools and parse args
17 require_once( 'commandLine.inc' );
19 // Check for mandatory options or print an usage message
20 if( !(isset($options['old']) && isset($options['new']) ) ) {
22 This script pass through all users and change their skins from 'oldSkinName'
23 to 'newSkinName'. There is NO validation about the new skin existence!
25 Usage: php cleanupSkin.php --old <oldSkinName> --new <newSkinName>
29 --old <oldSkinName> : the old skin name
30 --new <newSkinName> : new skin name to update users with
31 --quick : hides the 5 seconds warning
32 --quiet : do not print what is happening
39 // Load up the arguments:
40 $oldSkinName = $options['old'];
41 $newSkinName = $options['new'];
42 $quick = isset($options['quick']);
43 $quiet = isset($options['quiet']);
45 // We list the user by user_id from one of the slave databases
46 $dbr = wfGetDB( DB_SLAVE
);
47 $result = $dbr->select( 'user',
53 // The warning message and countdown
56 The script is about to change the skin for ALL USERS in the database.
57 Users with skin '$oldSkinName' will be made to use '$newSkinName'.
59 Abort with control-c in the next five seconds....
61 require('counter.php');
69 // Iterate through the users
70 while( $id = $dbr->fetchObject( $result ) ) {
72 $user = User
::newFromId( $id->user_id
);
74 // We get this users informations
75 $curSkinName = $user->getOption( 'skin' );
76 $username = $user->getName();
78 // Is he using the skin we want to migrate ?
79 if( $curSkinName == $oldSkinName ) {
81 if(!$quiet) print "Changing skin for $username ('$oldSkinName' -> '$newSkinName'):";
83 // Change skin and save it
84 $user->setOption( 'skin', $newSkinName );
85 $user->saveSettings();
87 if(!$quiet) print " OK\n";
89 print "Not changing '$username' using skin '$curSkinName'\n";