X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=maintenance%2FcreateAndPromote.php;h=79f725426d23df768369f31e5c929d19cbbbb3c2;hb=94b49f04d5601e181a0a6c486bf603dbe79287eb;hp=81fbbb3d3246042ca671b6c4d0ba3f2a2e0204d1;hpb=2ca0d60987f4019992daab9baadd94bed9ee8212;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/createAndPromote.php b/maintenance/createAndPromote.php index 81fbbb3d32..79f725426d 100644 --- a/maintenance/createAndPromote.php +++ b/maintenance/createAndPromote.php @@ -1,6 +1,6 @@ */ -require_once( __DIR__ . '/Maintenance.php' ); +require_once __DIR__ . '/Maintenance.php'; /** - * Maintenance script to create an account and grant it administrator rights. + * Maintenance script to create an account and grant it rights. * * @ingroup Maintenance */ class CreateAndPromote extends Maintenance { - - static $permitRoles = array( 'sysop', 'bureaucrat' ); + private static $permitRoles = array( 'sysop', 'bureaucrat', 'bot' ); public function __construct() { parent::__construct(); $this->mDescription = "Create a new user account and/or grant it additional rights"; - $this->addOption( "force", "If acccount exists already, just grant it rights or change password." ); - foreach( self::$permitRoles as $role ) { + $this->addOption( + 'force', + 'If acccount exists already, just grant it rights or change password.' + ); + foreach ( self::$permitRoles as $role ) { $this->addOption( $role, "Add the account to the {$role} group" ); } $this->addArg( "username", "Username of new user" ); - $this->addArg( "password", "Password to set (not required if --force is used)", false); + $this->addArg( "password", "Password to set (not required if --force is used)", false ); } public function execute() { @@ -60,19 +62,23 @@ class CreateAndPromote extends Maintenance { if ( $exists && !$force ) { $this->error( "Account exists. Perhaps you want the --force option?", true ); - } else if ( !$exists && !$password ) { + } elseif ( !$exists && !$password ) { $this->error( "Argument required!", false ); $this->maybeHelp( true ); - } else if ( $exists ) { + } elseif ( $exists ) { $inGroups = $user->getGroups(); } - $promotions = array_diff( array_filter( self::$permitRoles, array( $this, 'hasOption' ) ), $inGroups ); + $promotions = array_diff( + array_filter( self::$permitRoles, array( $this, 'hasOption' ) ), + $inGroups + ); if ( $exists && !$password && count( $promotions ) === 0 ) { $this->output( "Account exists and nothing to do.\n" ); + return; - } else if ( count( $promotions ) !== 0 ) { + } elseif ( count( $promotions ) !== 0 ) { $promoText = "User:{$username} into " . implode( ', ', $promotions ) . "...\n"; if ( $exists ) { $this->output( wfWikiID() . ": Promoting $promoText" ); @@ -114,4 +120,4 @@ class CreateAndPromote extends Maintenance { } $maintClass = "CreateAndPromote"; -require_once( RUN_MAINTENANCE_IF_MAIN ); +require_once RUN_MAINTENANCE_IF_MAIN;