4 * Maintenance script to create an account and grant it administrator rights
6 * @addtogroup Maintenance
7 * @author Rob Church <robchur@gmail.com>
10 $options = array( 'help', 'bureaucrat' );
11 require_once( 'commandLine.inc' );
13 if( isset( $options['help'] ) ) {
18 if( count( $args ) < 2 ) {
19 echo( "Please provide a username and password for the new account.\n" );
26 echo( wfWikiID() . ": Creating and promoting User:{$username}..." );
28 # Validate username and check it doesn't exist
29 $user = User
::newFromName( $username );
30 if( !is_object( $user ) ) {
31 echo( "invalid username.\n" );
33 } elseif( 0 != $user->idForName() ) {
34 echo( "account exists.\n" );
38 # Insert the account into the database
39 $user->addToDatabase();
40 $user->setPassword( $password );
44 $user->addGroup( 'sysop' );
45 if( isset( $option['bureaucrat'] ) )
46 $user->addGroup( 'bureaucrat' );
48 # Increment site_stats.ss_users
49 $ssu = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
56 Create a new user account with administrator rights
58 USAGE: php createAndPromote.php [--bureaucrat|--help] <username> <password>
61 Grant the account bureaucrat rights
63 Show this help information