X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialBlock.php;h=e47ef0619ca12a5104ab6b030ba07675a04a2c9e;hb=043a9087464a4f1e3346a317342111e56a23f5f3;hp=c9ce2b0837823bf5619ad56b36b1e61537859de1;hpb=9b98959aedcafe01906a259cf926fa88d203a166;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index c9ce2b0837..e47ef0619c 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -156,22 +156,31 @@ class SpecialBlock extends FormSpecialPage { 'type' => 'user', 'ipallowed' => true, 'iprange' => true, - 'label-message' => 'ipaddressorusername', 'id' => 'mw-bi-target', 'size' => '45', 'autofocus' => true, 'required' => true, 'validation-callback' => [ __CLASS__, 'validateTargetField' ], + 'section' => 'target', + ]; + + $a['Editing'] = [ + 'type' => 'check', + 'label-message' => 'block-prevent-edit', + 'default' => true, + 'section' => 'actions', + 'disabled' => $enablePartialBlocks ? false : true, ]; if ( $enablePartialBlocks ) { $a['EditingRestriction'] = [ 'type' => 'radio', - 'label' => $this->msg( 'ipb-type-label' )->text(), + 'cssclass' => 'mw-block-editing-restriction', 'options' => [ $this->msg( 'ipb-sitewide' )->text() => 'sitewide', $this->msg( 'ipb-partial' )->text() => 'partial', ], + 'section' => 'actions', ]; $a['PageRestrictions'] = [ 'type' => 'titlesmultiselect', @@ -183,38 +192,22 @@ class SpecialBlock extends FormSpecialPage { 'input' => [ 'autocomplete' => false ], + 'section' => 'actions', ]; } - $a['Expiry'] = [ - 'type' => 'expiry', - 'label-message' => 'ipbexpiry', - 'required' => true, - 'options' => $suggestedDurations, - 'default' => $this->msg( 'ipb-default-expiry' )->inContentLanguage()->text(), - ]; - - $a['Reason'] = [ - 'type' => 'selectandother', - // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP - // (e.g. emojis) count for two each. This limit is overridden in JS to instead count - // Unicode codepoints (or 255 UTF-8 bytes for old schema). - 'maxlength' => $oldCommentSchema ? 255 : CommentStore::COMMENT_CHARACTER_LIMIT, - 'maxlength-unit' => 'codepoints', - 'label-message' => 'ipbreason', - 'options-message' => 'ipbreason-dropdown', - ]; - $a['CreateAccount'] = [ 'type' => 'check', 'label-message' => 'ipbcreateaccount', 'default' => true, + 'section' => 'actions', ]; if ( self::canBlockEmail( $user ) ) { $a['DisableEmail'] = [ 'type' => 'check', 'label-message' => 'ipbemailban', + 'section' => 'actions', ]; } @@ -223,13 +216,34 @@ class SpecialBlock extends FormSpecialPage { 'type' => 'check', 'label-message' => 'ipb-disableusertalk', 'default' => false, + 'section' => 'actions', ]; } + $a['Expiry'] = [ + 'type' => 'expiry', + 'required' => true, + 'options' => $suggestedDurations, + 'default' => $this->msg( 'ipb-default-expiry' )->inContentLanguage()->text(), + 'section' => 'expiry', + ]; + + $a['Reason'] = [ + 'type' => 'selectandother', + // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP + // (e.g. emojis) count for two each. This limit is overridden in JS to instead count + // Unicode codepoints (or 255 UTF-8 bytes for old schema). + 'maxlength' => $oldCommentSchema ? 255 : CommentStore::COMMENT_CHARACTER_LIMIT, + 'maxlength-unit' => 'codepoints', + 'options-message' => 'ipbreason-dropdown', + 'section' => 'reason', + ]; + $a['AutoBlock'] = [ 'type' => 'check', 'label-message' => 'ipbenableautoblock', 'default' => true, + 'section' => 'options', ]; # Allow some users to hide name from block log, blocklist and listusers @@ -238,6 +252,7 @@ class SpecialBlock extends FormSpecialPage { 'type' => 'check', 'label-message' => 'ipbhidename', 'cssclass' => 'mw-block-hideuser', + 'section' => 'options', ]; } @@ -246,6 +261,7 @@ class SpecialBlock extends FormSpecialPage { $a['Watch'] = [ 'type' => 'check', 'label-message' => 'ipbwatchuser', + 'section' => 'options', ]; } @@ -253,6 +269,7 @@ class SpecialBlock extends FormSpecialPage { 'type' => 'check', 'label-message' => 'ipb-hardblock', 'default' => false, + 'section' => 'options', ]; # This is basically a copy of the Target field, but the user can't change it, so we @@ -382,6 +399,10 @@ class SpecialBlock extends FormSpecialPage { $pageRestrictions[] = $restriction->getTitle()->getPrefixedText(); } + if ( !$block->isSitewide() && empty( $pageRestrictions ) ) { + $fields['Editing']['default'] = false; + } + // Sort the restrictions so they are in alphabetical order. sort( $pageRestrictions ); $fields['PageRestrictions']['default'] = implode( "\n", $pageRestrictions ); @@ -394,7 +415,10 @@ class SpecialBlock extends FormSpecialPage { * @return string */ protected function preText() { - $this->getOutput()->addModuleStyles( 'mediawiki.widgets.TagMultiselectWidget.styles' ); + $this->getOutput()->addModuleStyles( [ + 'mediawiki.widgets.TagMultiselectWidget.styles', + 'mediawiki.special', + ] ); $this->getOutput()->addModules( [ 'mediawiki.special.block' ] ); $blockCIDRLimit = $this->getConfig()->get( 'BlockCIDRLimit' ); @@ -1138,6 +1162,12 @@ class SpecialBlock extends FormSpecialPage { * @return bool|array True for success, false for didn't-try, array of errors on failure */ public function onSubmit( array $data, HTMLForm $form = null ) { + // If "Editing" checkbox is unchecked, the block must be a partial block affecting + // actions other than editing, and there must be no restrictions. + if ( isset( $data['Editing'] ) && $data['Editing'] === false ) { + $data['EditingRestriction'] = 'partial'; + $data['PageRestrictions'] = []; + } return self::processForm( $data, $form->getContext() ); }