X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FcreateAndPromote.php;h=861b364b68c09059d75969b9d72cda3048569a3b;hb=d4a0af097ee72437d7ccd6811dd13be7c0a9b352;hp=aa25ee602248c2881fa705bfee39778140c9ba72;hpb=6d4f5d142f28ade566dd6cd97af129c582e6f27b;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/createAndPromote.php b/maintenance/createAndPromote.php index aa25ee6022..861b364b68 100644 --- a/maintenance/createAndPromote.php +++ b/maintenance/createAndPromote.php @@ -31,16 +31,26 @@ require_once __DIR__ . '/Maintenance.php'; * @ingroup Maintenance */ class CreateAndPromote extends Maintenance { - - static $permitRoles = array( 'sysop', 'bureaucrat', 'bot' ); + 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." ); + $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->addOption( + 'custom-groups', + 'Comma-separated list of groups to add the user to', + false, + true + ); + $this->addArg( "username", "Username of new user" ); $this->addArg( "password", "Password to set (not required if --force is used)", false ); } @@ -67,10 +77,25 @@ class CreateAndPromote extends Maintenance { $inGroups = $user->getGroups(); } - $promotions = array_diff( array_filter( self::$permitRoles, array( $this, 'hasOption' ) ), $inGroups ); + $groups = array_filter( self::$permitRoles, array( $this, 'hasOption' ) ); + if ( $this->hasOption( 'custom-groups' ) ) { + $customGroupsText = $this->getOption( 'custom-groups' ); + if ( $customGroupsText !== '' ) { + $customGroups = explode( ',', $customGroupsText ); + foreach ( $customGroups as $customGroup ) { + $groups[] = trim( $customGroup ); + } + } + } + + $promotions = array_diff( + $groups, + $inGroups + ); if ( $exists && !$password && count( $promotions ) === 0 ) { $this->output( "Account exists and nothing to do.\n" ); + return; } elseif ( count( $promotions ) !== 0 ) { $promoText = "User:{$username} into " . implode( ', ', $promotions ) . "...\n";