+ $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();
+ $uiLanguage = $this->getLanguage();
+
+ $currentExpiry = isset( $usergroups[$group] ) ?
+ $usergroups[$group]->getExpiry() :
+ null;
+
+ // If the user can't modify the expiry, print the current expiry below
+ // it in plain text. Otherwise provide UI to set/change the expiry
+ if ( $checkbox['set'] &&
+ ( $checkbox['irreversible'] || $checkbox['disabled-expiry'] )
+ ) {
+ if ( $currentExpiry ) {
+ $expiryFormatted = $uiLanguage->userTimeAndDate( $currentExpiry, $uiUser );
+ $expiryFormattedD = $uiLanguage->userDate( $currentExpiry, $uiUser );
+ $expiryFormattedT = $uiLanguage->userTime( $currentExpiry, $uiUser );
+ $expiryHtml = $this->msg( 'userrights-expiry-current' )->params(
+ $expiryFormatted, $expiryFormattedD, $expiryFormattedT )->text();
+ } else {
+ $expiryHtml = $this->msg( 'userrights-expiry-none' )->text();
+ }
+ $expiryHtml .= "<br />\n";
+ } else {
+ $expiryHtml = Xml::element( 'span', null,
+ $this->msg( 'userrights-expiry' )->text() );
+ $expiryHtml .= Xml::openElement( 'span' );
+
+ // add a form element to set the expiry date
+ $expiryFormOptions = new XmlSelect(
+ "wpExpiry-$group",
+ "mw-input-wpExpiry-$group", // forward compatibility with HTMLForm
+ $currentExpiry ? 'existing' : 'infinite'
+ );
+ if ( $checkbox['disabled-expiry'] ) {
+ $expiryFormOptions->setAttribute( 'disabled', 'disabled' );
+ }
+
+ if ( $currentExpiry ) {
+ $timestamp = $uiLanguage->userTimeAndDate( $currentExpiry, $uiUser );
+ $d = $uiLanguage->userDate( $currentExpiry, $uiUser );
+ $t = $uiLanguage->userTime( $currentExpiry, $uiUser );
+ $existingExpiryMessage = $this->msg( 'userrights-expiry-existing',
+ $timestamp, $d, $t );
+ $expiryFormOptions->addOption( $existingExpiryMessage->text(), 'existing' );
+ }
+
+ $expiryFormOptions->addOption(
+ $this->msg( 'userrights-expiry-none' )->text(),
+ 'infinite'
+ );
+ $expiryFormOptions->addOption(
+ $this->msg( 'userrights-expiry-othertime' )->text(),
+ 'other'
+ );
+ foreach ( $expiryOptions as $option ) {
+ if ( strpos( $option, ":" ) === false ) {
+ $displayText = $value = $option;
+ } else {
+ list( $displayText, $value ) = explode( ":", $option );
+ }
+ $expiryFormOptions->addOption( $displayText, htmlspecialchars( $value ) );
+ }
+
+ // Add expiry dropdown
+ $expiryHtml .= $expiryFormOptions->getHTML() . '<br />';
+
+ // Add custom expiry field
+ $attribs = [ 'id' => "mw-input-wpExpiry-$group-other" ];
+ if ( $checkbox['disabled-expiry'] ) {
+ $attribs['disabled'] = 'disabled';
+ }
+ $expiryHtml .= Xml::input( "wpExpiry-$group-other", 30, '', $attribs );
+
+ // If the user group is set but the checkbox is disabled, mimic a
+ // checked checkbox in the form submission
+ if ( $checkbox['set'] && $checkbox['disabled'] ) {
+ $expiryHtml .= Html::hidden( "wpGroup-$group", 1 );
+ }
+
+ $expiryHtml .= Xml::closeElement( 'span' );
+ }
+
+ $divAttribs = [
+ 'id' => "mw-userrights-nested-wpGroup-$group",
+ 'class' => 'mw-userrights-nested',
+ ];
+ $ret .= "\t\t\t" . Xml::tags( 'div', $divAttribs, $expiryHtml ) . "\n";
+ }