19 protected static $right =
'translate-groupreview';
21 public function __construct(
24 private readonly LanguageNameUtils $languageNameUtils,
27 parent::__construct( $main, $action );
30 public function execute() {
31 $user = $this->getUser();
32 $requestParams = $this->extractRequestParams();
35 $code = $requestParams[
'language'];
37 if ( !$group || MessageGroups::isDynamic( $group ) ) {
38 $this->dieWithError( [
'apierror-badparameter',
'group' ] );
40 $stateConfig = $group->getMessageGroupStates()->getStates();
41 if ( !$stateConfig ) {
42 $this->dieWithError(
'apierror-translate-groupreviewdisabled',
'disabled' );
45 $this->checkUserRightsAny( self::$right );
47 $block = $user->getBlock();
49 $this->dieBlocked( $block );
52 $languages = $this->languageNameUtils->getLanguageNames();
53 if ( !isset( $languages[$code] ) ) {
54 $this->dieWithError( [
'apierror-badparameter',
'language' ] );
57 $targetState = $requestParams[
'state'];
58 if ( !isset( $stateConfig[$targetState] ) ) {
59 $this->dieWithError(
'apierror-translate-invalidstate',
'invalidstate' );
62 if ( is_array( $stateConfig[$targetState] )
63 && isset( $stateConfig[$targetState][
'right'] )
65 $this->checkUserRightsAny( $stateConfig[$targetState][
'right'] );
68 $this->messageGroupReviewStore->changeState( $group, $code, $targetState, $user );
70 $output = [
'review' => [
71 'group' => $group->getId(),
73 'state' => $targetState,
76 $this->getResult()->addValue(
null, $this->getModuleName(), $output );
79 public function isWriteMode():
bool {
83 public function needsToken():
string {
87 protected function getAllowedParams(): array {
90 ParamValidator::PARAM_TYPE =>
'string',
91 ParamValidator::PARAM_REQUIRED =>
true,
94 ParamValidator::PARAM_TYPE =>
'string',
95 ParamValidator::PARAM_DEFAULT =>
'en',
98 ParamValidator::PARAM_TYPE =>
'string',
99 ParamValidator::PARAM_REQUIRED =>
true,
104 protected function getExamplesMessages(): array {
106 'action=groupreview&group=page-Example&language=de&state=ready&token=foo'
107 =>
'apihelp-groupreview-example-1',