* Add option to maintenance/createAndPromote.php to give the user bureaucrat permissi...
[lhc/web/wiklou.git] / maintenance / createAndPromote.php
index df29c11..af4a1da 100644 (file)
@@ -3,14 +3,19 @@
 /**
  * Maintenance script to create an account and grant it administrator rights
  *
- * @package MediaWiki
- * @subpackage Maintenance
+ * @addtogroup Maintenance
  * @author Rob Church <robchur@gmail.com>
  */
+
+$options = array( 'help', 'bureaucrat' );
 require_once( 'commandLine.inc' );
 
-if( !count( $args ) == 2 ) {
+if( isset( $options['help'] ) ) {
+       showHelp();
+       exit( 1 );
+}
+
+if( count( $args ) < 2 ) {
        echo( "Please provide a username and password for the new account.\n" );
        die( 1 );
 }
@@ -18,8 +23,7 @@ if( !count( $args ) == 2 ) {
 $username = $args[0];
 $password = $args[1];
 
-global $wgDBname;
-echo( "{$wgDBname}: Creating and promoting User:{$username}..." );
+echo( wfWikiID() . ": Creating and promoting User:{$username}..." );
 
 # Validate username and check it doesn't exist
 $user = User::newFromName( $username );
@@ -38,6 +42,8 @@ $user->setToken();
 
 # Promote user
 $user->addGroup( 'sysop' );
+if( isset( $option['bureaucrat'] ) )
+       $user->addGroup( 'bureaucrat' );
 
 # Increment site_stats.ss_users
 $ssu = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
@@ -45,4 +51,17 @@ $ssu->doUpdate();
 
 echo( "done.\n" );
 
-?>
\ No newline at end of file
+function showHelp() {
+       echo( <<<EOT
+Create a new user account with administrator rights
+
+USAGE: php createAndPromote.php [--bureaucrat|--help] <username> <password>
+
+       --bureaucrat
+               Grant the account bureaucrat rights
+       --help
+               Show this help information
+
+EOT
+       );
+}
\ No newline at end of file