From: Matthew Flaschen Date: Wed, 1 Jul 2015 07:21:53 +0000 (-0400) Subject: Allow using createAndPromote.php with custom groups X-Git-Tag: 1.31.0-rc.0~10848^2 X-Git-Url: http://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_vote_del%27%2C%20idvote=vote.voteid%29%20%7D%7D?a=commitdiff_plain;h=ab23aad688242fc17eebe28cab9590ec317d8bcf;p=lhc%2Fweb%2Fwiklou.git Allow using createAndPromote.php with custom groups This lets any group(s) be added using a comma-separated argument, in addition to the --sysop, --bureaucrat, and --bot that already existed. Bug: T105079 Change-Id: I1274b065e3dad917e545f9278b996da014d87ae9 --- diff --git a/maintenance/createAndPromote.php b/maintenance/createAndPromote.php index 79f725426d..861b364b68 100644 --- a/maintenance/createAndPromote.php +++ b/maintenance/createAndPromote.php @@ -43,6 +43,14 @@ class CreateAndPromote extends Maintenance { 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 ); } @@ -69,8 +77,19 @@ class CreateAndPromote extends Maintenance { $inGroups = $user->getGroups(); } + $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( - array_filter( self::$permitRoles, array( $this, 'hasOption' ) ), + $groups, $inGroups );