X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FcreateAndPromote.php;h=861b364b68c09059d75969b9d72cda3048569a3b;hb=b96b465f7f22d3ffa7fd6728535aa9aeb511ef8a;hp=a8de640b0154465d9ac888e6af3bceb942d51e85;hpb=229e1f4fdbda91f10f5ce78f0d35db973c714b1d;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/createAndPromote.php b/maintenance/createAndPromote.php index a8de640b01..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,13 +77,25 @@ 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 ); 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";