From: Chad Horohoe Date: Wed, 5 Jan 2011 22:37:14 +0000 (+0000) Subject: * Validate e-mail address if provided X-Git-Tag: 1.31.0-rc.0~32790 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=d0f8d6ea2e9236a5ca396375052d79ccc4c12532;p=lhc%2Fweb%2Fwiklou.git * Validate e-mail address if provided * Actually setEmail() on the sysop account we're creating * Reinstate "subscribe to mediawiki-announce" feature (reverts r79089) which actually works --- diff --git a/includes/installer/CoreInstaller.php b/includes/installer/CoreInstaller.php index 54b6234dbc..b8380a3515 100644 --- a/includes/installer/CoreInstaller.php +++ b/includes/installer/CoreInstaller.php @@ -178,6 +178,20 @@ abstract class CoreInstaller extends Installer { ), ); + /** + * 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 * @@ -185,7 +199,6 @@ abstract class CoreInstaller extends Installer { */ public abstract function showStatusMessage( Status $status ); - /** * Constructor, always call this from child classes. */ @@ -480,10 +493,39 @@ abstract class CoreInstaller extends Installer { $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' ); + } } /** diff --git a/includes/installer/Installer.i18n.php b/includes/installer/Installer.i18n.php index 0934b15639..da67390e59 100644 --- a/includes/installer/Installer.i18n.php +++ b/includes/installer/Installer.i18n.php @@ -343,6 +343,7 @@ Specify a different username.', '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 "$1".', 'config-admin-error-password' => 'Internal error when setting a password for the admin "$1":
$2
', + '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.', @@ -465,6 +466,7 @@ Skipping default list.", 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!''' diff --git a/includes/installer/WebInstallerPage.php b/includes/installer/WebInstallerPage.php index ed745b76eb..c3e5d267d5 100644 --- a/includes/installer/WebInstallerPage.php +++ b/includes/installer/WebInstallerPage.php @@ -596,16 +596,11 @@ class WebInstaller_Name extends WebInstallerPage { '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( @@ -708,6 +703,14 @@ class WebInstaller_Name extends WebInstallerPage { $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; }