X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialUserrights.php;h=cf8c3f57d5b6d20b656b81903f5629ce4a0620f6;hb=a2c8c2969420a0f150c03f76e3a0bf9028fcda43;hp=d0a0317fa8f19bea1dd794197cafdb8fdc1850db;hpb=164ac518792eb0e5883c41b0a6101690c7f2e92d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialUserrights.php b/includes/specials/SpecialUserrights.php index d0a0317fa8..40f02a5f4d 100644 --- a/includes/specials/SpecialUserrights.php +++ b/includes/specials/SpecialUserrights.php @@ -326,8 +326,8 @@ class UserrightsPage extends SpecialPage { * @return array Tuple of added, then removed groups */ function doSaveUserGroups( $user, $add, $remove, $reason = '', $tags = [], - $groupExpiries = [] ) { - + $groupExpiries = [] + ) { // Validate input set... $isself = $user->getName() == $this->getUser()->getName(); $groups = $user->getGroups(); @@ -433,8 +433,8 @@ class UserrightsPage extends SpecialPage { * @param array $newUGMs Associative array of (group name => UserGroupMembership) */ protected function addLogEntry( $user, $oldGroups, $newGroups, $reason, $tags, - $oldUGMs, $newUGMs ) { - + $oldUGMs, $newUGMs + ) { // make sure $oldUGMs and $newUGMs are in the same order, and serialise // each UGM object to a simplified array $oldUGMs = array_map( function ( $group ) use ( $oldUGMs ) { @@ -716,6 +716,8 @@ class UserrightsPage extends SpecialPage { ->rawParams( $userToolLinks )->parse() ); if ( $canChangeAny ) { + $conf = $this->getConfig(); + $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD; $this->getOutput()->addHTML( $this->msg( 'userrights-groups-help', $user->getName() )->parse() . $grouplist . @@ -726,8 +728,13 @@ class UserrightsPage extends SpecialPage { Xml::label( $this->msg( 'userrights-reason' )->text(), 'wpReason' ) . " " . - Xml::input( 'user-reason', 60, $this->getRequest()->getVal( 'user-reason', false ), - [ 'id' => 'wpReason', 'maxlength' => 255 ] ) . + Xml::input( 'user-reason', 60, $this->getRequest()->getVal( 'user-reason', false ), [ + 'id' => 'wpReason', + // 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, + ] ) . " @@ -761,7 +768,7 @@ class UserrightsPage extends SpecialPage { /** * Adds a table with checkboxes where you can select what groups to add/remove * - * @param array $usergroups Associative array of (group name as string => + * @param UserGroupMembership[] $usergroups Associative array of (group name as string => * UserGroupMembership object) for groups the user belongs to * @param User $user * @return Array with 2 elements: the XHTML table element with checkxboes, and @@ -835,7 +842,10 @@ class UserrightsPage extends SpecialPage { } $ret .= "\t\n"; foreach ( $column as $group => $checkbox ) { - $attr = $checkbox['disabled'] ? [ 'disabled' => 'disabled' ] : []; + $attr = [ 'class' => 'mw-userrights-groupcheckbox' ]; + if ( $checkbox['disabled'] ) { + $attr['disabled'] = 'disabled'; + } $member = UserGroupMembership::getGroupMemberName( $group, $user->getName() ); if ( $checkbox['irreversible'] ) { @@ -847,10 +857,6 @@ class UserrightsPage extends SpecialPage { } $checkboxHtml = Xml::checkLabel( $text, "wpGroup-" . $group, "wpGroup-" . $group, $checkbox['set'], $attr ); - $ret .= "\t\t" . ( ( $checkbox['disabled'] && $checkbox['disabled-expiry'] ) - ? Xml::tags( 'div', [ 'class' => 'mw-userrights-disabled' ], $checkboxHtml ) - : Xml::tags( 'div', [], $checkboxHtml ) - ) . "\n"; if ( $this->canProcessExpiries() ) { $uiUser = $this->getUser(); @@ -874,6 +880,10 @@ class UserrightsPage extends SpecialPage { } else { $expiryHtml = $this->msg( 'userrights-expiry-none' )->text(); } + // T171345: Add a hidden form element so that other groups can still be manipulated, + // otherwise saving errors out with an invalid expiry time for this group. + $expiryHtml .= Html::Hidden( "wpExpiry-$group", + $currentExpiry ? 'existing' : 'infinite' ); $expiryHtml .= "
\n"; } else { $expiryHtml = Xml::element( 'span', null, @@ -920,7 +930,10 @@ class UserrightsPage extends SpecialPage { $expiryHtml .= $expiryFormOptions->getHTML() . '
'; // Add custom expiry field - $attribs = [ 'id' => "mw-input-wpExpiry-$group-other" ]; + $attribs = [ + 'id' => "mw-input-wpExpiry-$group-other", + 'class' => 'mw-userrights-expiryfield', + ]; if ( $checkbox['disabled-expiry'] ) { $attribs['disabled'] = 'disabled'; } @@ -939,8 +952,12 @@ class UserrightsPage extends SpecialPage { 'id' => "mw-userrights-nested-wpGroup-$group", 'class' => 'mw-userrights-nested', ]; - $ret .= "\t\t\t" . Xml::tags( 'div', $divAttribs, $expiryHtml ) . "\n"; + $checkboxHtml .= "\t\t\t" . Xml::tags( 'div', $divAttribs, $expiryHtml ) . "\n"; } + $ret .= "\t\t" . ( ( $checkbox['disabled'] && $checkbox['disabled-expiry'] ) + ? Xml::tags( 'div', [ 'class' => 'mw-userrights-disabled' ], $checkboxHtml ) + : Xml::tags( 'div', [], $checkboxHtml ) + ) . "\n"; } $ret .= "\t\n"; }