),
);
+ /**
+ * URL to mediawiki-announce subscription
+ */
+ protected $mediaWikiAnnounceUrl = 'https://lists.wikimedia.org/mailman/subscribe/mediawiki-announce';
+
+ /**
+ * Supported language codes for Mailman
+ */
+ protected $mediaWikiAnnounceLanguages = array(
+ 'ca', 'cs', 'da', 'de', 'en', 'es', 'et', 'eu', 'fi', 'fr', 'hr', 'hu',
+ 'it', 'ja', 'ko', 'lt', 'nl', 'no', 'pl', 'pt', 'pt-br', 'ro', 'ru',
+ 'sl', 'sr', 'sv', 'tr', 'uk'
+ );
+
/**
* TODO: document
*
*/
public abstract function showStatusMessage( Status $status );
-
/**
* Constructor, always call this from child classes.
*/
$user->addGroup( 'sysop' );
$user->addGroup( 'bureaucrat' );
+ if( $this->getVar( '_AdminEmail' ) ) {
+ $user->setEmail( $this->getVar( '_AdminEmail' ) );
+ }
$user->saveSettings();
}
+ $status = Status::newGood();
- return Status::newGood();
+ if( $this->getVar( '_Subscribe' ) && $this->getVar( '_AdminEmail' ) ) {
+ $this->subscribeToMediaWikiAnnounce( $status );
+ }
+
+ return $status;
+ }
+
+ private function subscribeToMediaWikiAnnounce( Status $s ) {
+ $params = array(
+ 'email' => $this->getVar( '_AdminEmail' ),
+ 'language' => 'en',
+ 'digest' => 0
+ );
+
+ // Mailman doesn't support as many languages as we do, so check to make
+ // sure their selected language is available
+ $myLang = $this->getVar( '_UserLang' );
+ if( in_array( $myLang, $this->mediaWikiAnnounceLanguages ) ) {
+ $myLang = $myLang == 'pt-br' ? 'pt_BR' : $myLang; // rewrite to Mailman's pt_BR
+ $params['language'] = $myLang;
+ }
+
+ $res = Http::post( $this->mediaWikiAnnounceUrl, array( 'postData' => $params ) );
+ if( !$res ) {
+ $s->warning( 'config-install-subscribe-fail' );
+ }
}
/**
'config-admin-email-help' => 'Enter an e-mail address here to allow you to receive e-mail from other users on the wiki, reset your password, and be notified of changes to pages on your watchlist.',
'config-admin-error-user' => 'Internal error when creating an admin with the name "<nowiki>$1</nowiki>".',
'config-admin-error-password' => 'Internal error when setting a password for the admin "<nowiki>$1</nowiki>": <pre>$2</pre>',
+ 'config-admin-error-bademail' => 'You have entered an invalid e-mail address',
'config-subscribe' => 'Subscribe to the [https://lists.wikimedia.org/mailman/listinfo/mediawiki-announce release announcements mailing list].',
'config-subscribe-help' => 'This is a low-volume mailing list used for release announcements, including important security announcements.
You should subscribe to it and update your MediaWiki installation when new versions come out.',
Consider changing it manually.",
'config-install-upgradekey' => 'Generating default upgrade key',
'config-install-sysop' => 'Creating administrator user account',
+ 'config-install-subscribe-fail' => 'Unable to subscribe to mediawiki-announce',
'config-install-mainpage' => 'Creating main page with default content',
'config-install-mainpage-failed' => 'Could not insert main page.',
'config-install-done' => "'''Congratulations!'''
'label' => 'config-admin-email',
'help' => $this->parent->getHelpBox( 'config-admin-email-help' )
) ) .
- /**
- * Uncomment this feature once we've got some sort of API to mailman
- * to handle these subscriptions. Some dummy wrapper script on the
- * mailman box that shell's out to mailman/bin/add_members would do
- $this->parent->getCheckBox( array(
+ $this->parent->getCheckBox( array(
'var' => '_Subscribe',
'label' => 'config-subscribe',
'help' => $this->parent->getHelpBox( 'config-subscribe-help' )
) ) .
- */
$this->getFieldSetEnd() .
$this->parent->getInfoBox( wfMsg( 'config-almost-done' ) ) .
$this->parent->getRadioSet( array(
$this->setVar( '_AdminPassword2', '' );
$retVal = false;
}
+
+ // Validate e-mail if provided
+ $email = $this->getVar( '_AdminEmail' );
+ if( $email && !User::isValidEmailAddr( $email ) ) {
+ $this->parent->showError( 'config-admin-error-bademail' );
+ $retVal = false;
+ }
+
return $retVal;
}