19 protected static $right =
'translate-groupreview';
20 private LanguageNameUtils $languageNameUtils;
23 public function __construct(
26 LanguageNameUtils $languageNameUtils,
29 parent::__construct( $main, $action );
30 $this->languageNameUtils = $languageNameUtils;
31 $this->messageGroupReviewStore = $messageGroupReviewStore;
34 public function execute() {
35 $user = $this->getUser();
36 $requestParams = $this->extractRequestParams();
39 $code = $requestParams[
'language'];
41 if ( !$group || MessageGroups::isDynamic( $group ) ) {
42 $this->dieWithError( [
'apierror-badparameter',
'group' ] );
44 $stateConfig = $group->getMessageGroupStates()->getStates();
45 if ( !$stateConfig ) {
46 $this->dieWithError(
'apierror-translate-groupreviewdisabled',
'disabled' );
49 $this->checkUserRightsAny( self::$right );
51 $block = $user->getBlock();
53 $this->dieBlocked( $block );
56 $languages = $this->languageNameUtils->getLanguageNames();
57 if ( !isset( $languages[$code] ) ) {
58 $this->dieWithError( [
'apierror-badparameter',
'language' ] );
61 $targetState = $requestParams[
'state'];
62 if ( !isset( $stateConfig[$targetState] ) ) {
63 $this->dieWithError(
'apierror-translate-invalidstate',
'invalidstate' );
66 if ( is_array( $stateConfig[$targetState] )
67 && isset( $stateConfig[$targetState][
'right'] )
69 $this->checkUserRightsAny( $stateConfig[$targetState][
'right'] );
72 $this->messageGroupReviewStore->changeState( $group, $code, $targetState, $user );
74 $output = [
'review' => [
75 'group' => $group->getId(),
77 'state' => $targetState,
80 $this->getResult()->addValue(
null, $this->getModuleName(), $output );
83 public function isWriteMode():
bool {
87 public function needsToken():
string {
91 protected function getAllowedParams(): array {
94 ParamValidator::PARAM_TYPE =>
'string',
95 ParamValidator::PARAM_REQUIRED =>
true,
98 ParamValidator::PARAM_TYPE =>
'string',
99 ParamValidator::PARAM_DEFAULT =>
'en',
102 ParamValidator::PARAM_TYPE =>
'string',
103 ParamValidator::PARAM_REQUIRED =>
true,
108 protected function getExamplesMessages(): array {
110 'action=groupreview&group=page-Example&language=de&state=ready&token=foo'
111 =>
'apihelp-groupreview-example-1',