Index: trunk/phase3/includes/installer/CoreInstaller.php |
— | — | @@ -179,13 +179,26 @@ |
180 | 180 | ); |
181 | 181 | |
182 | 182 | /** |
| 183 | + * URL to mediawiki-announce subscription |
| 184 | + */ |
| 185 | + protected $mediaWikiAnnounceUrl = 'https://lists.wikimedia.org/mailman/subscribe/mediawiki-announce'; |
| 186 | + |
| 187 | + /** |
| 188 | + * Supported language codes for Mailman |
| 189 | + */ |
| 190 | + protected $mediaWikiAnnounceLanguages = array( |
| 191 | + 'ca', 'cs', 'da', 'de', 'en', 'es', 'et', 'eu', 'fi', 'fr', 'hr', 'hu', |
| 192 | + 'it', 'ja', 'ko', 'lt', 'nl', 'no', 'pl', 'pt', 'pt-br', 'ro', 'ru', |
| 193 | + 'sl', 'sr', 'sv', 'tr', 'uk' |
| 194 | + ); |
| 195 | + |
| 196 | + /** |
183 | 197 | * TODO: document |
184 | 198 | * |
185 | 199 | * @param $status Status |
186 | 200 | */ |
187 | 201 | public abstract function showStatusMessage( Status $status ); |
188 | 202 | |
189 | | - |
190 | 203 | /** |
191 | 204 | * Constructor, always call this from child classes. |
192 | 205 | */ |
— | — | @@ -480,12 +493,41 @@ |
481 | 494 | |
482 | 495 | $user->addGroup( 'sysop' ); |
483 | 496 | $user->addGroup( 'bureaucrat' ); |
| 497 | + if( $this->getVar( '_AdminEmail' ) ) { |
| 498 | + $user->setEmail( $this->getVar( '_AdminEmail' ) ); |
| 499 | + } |
484 | 500 | $user->saveSettings(); |
485 | 501 | } |
| 502 | + $status = Status::newGood(); |
486 | 503 | |
487 | | - return Status::newGood(); |
| 504 | + if( $this->getVar( '_Subscribe' ) && $this->getVar( '_AdminEmail' ) ) { |
| 505 | + $this->subscribeToMediaWikiAnnounce( $status ); |
| 506 | + } |
| 507 | + |
| 508 | + return $status; |
488 | 509 | } |
489 | 510 | |
| 511 | + private function subscribeToMediaWikiAnnounce( Status $s ) { |
| 512 | + $params = array( |
| 513 | + 'email' => $this->getVar( '_AdminEmail' ), |
| 514 | + 'language' => 'en', |
| 515 | + 'digest' => 0 |
| 516 | + ); |
| 517 | + |
| 518 | + // Mailman doesn't support as many languages as we do, so check to make |
| 519 | + // sure their selected language is available |
| 520 | + $myLang = $this->getVar( '_UserLang' ); |
| 521 | + if( in_array( $myLang, $this->mediaWikiAnnounceLanguages ) ) { |
| 522 | + $myLang = $myLang == 'pt-br' ? 'pt_BR' : $myLang; // rewrite to Mailman's pt_BR |
| 523 | + $params['language'] = $myLang; |
| 524 | + } |
| 525 | + |
| 526 | + $res = Http::post( $this->mediaWikiAnnounceUrl, array( 'postData' => $params ) ); |
| 527 | + if( !$res ) { |
| 528 | + $s->warning( 'config-install-subscribe-fail' ); |
| 529 | + } |
| 530 | + } |
| 531 | + |
490 | 532 | /** |
491 | 533 | * Insert Main Page with default content. |
492 | 534 | * |
Index: trunk/phase3/includes/installer/Installer.i18n.php |
— | — | @@ -343,6 +343,7 @@ |
344 | 344 | '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.', |
345 | 345 | 'config-admin-error-user' => 'Internal error when creating an admin with the name "<nowiki>$1</nowiki>".', |
346 | 346 | 'config-admin-error-password' => 'Internal error when setting a password for the admin "<nowiki>$1</nowiki>": <pre>$2</pre>', |
| 347 | + 'config-admin-error-bademail' => 'You have entered an invalid e-mail address', |
347 | 348 | 'config-subscribe' => 'Subscribe to the [https://lists.wikimedia.org/mailman/listinfo/mediawiki-announce release announcements mailing list].', |
348 | 349 | 'config-subscribe-help' => 'This is a low-volume mailing list used for release announcements, including important security announcements. |
349 | 350 | You should subscribe to it and update your MediaWiki installation when new versions come out.', |
— | — | @@ -465,6 +466,7 @@ |
466 | 467 | Consider changing it manually.", |
467 | 468 | 'config-install-upgradekey' => 'Generating default upgrade key', |
468 | 469 | 'config-install-sysop' => 'Creating administrator user account', |
| 470 | + 'config-install-subscribe-fail' => 'Unable to subscribe to mediawiki-announce', |
469 | 471 | 'config-install-mainpage' => 'Creating main page with default content', |
470 | 472 | 'config-install-mainpage-failed' => 'Could not insert main page.', |
471 | 473 | 'config-install-done' => "'''Congratulations!''' |
Index: trunk/phase3/includes/installer/WebInstallerPage.php |
— | — | @@ -596,16 +596,11 @@ |
597 | 597 | 'label' => 'config-admin-email', |
598 | 598 | 'help' => $this->parent->getHelpBox( 'config-admin-email-help' ) |
599 | 599 | ) ) . |
600 | | - /** |
601 | | - * Uncomment this feature once we've got some sort of API to mailman |
602 | | - * to handle these subscriptions. Some dummy wrapper script on the |
603 | | - * mailman box that shell's out to mailman/bin/add_members would do |
604 | | - $this->parent->getCheckBox( array( |
| 600 | + $this->parent->getCheckBox( array( |
605 | 601 | 'var' => '_Subscribe', |
606 | 602 | 'label' => 'config-subscribe', |
607 | 603 | 'help' => $this->parent->getHelpBox( 'config-subscribe-help' ) |
608 | 604 | ) ) . |
609 | | - */ |
610 | 605 | $this->getFieldSetEnd() . |
611 | 606 | $this->parent->getInfoBox( wfMsg( 'config-almost-done' ) ) . |
612 | 607 | $this->parent->getRadioSet( array( |
— | — | @@ -708,6 +703,14 @@ |
709 | 704 | $this->setVar( '_AdminPassword2', '' ); |
710 | 705 | $retVal = false; |
711 | 706 | } |
| 707 | + |
| 708 | + // Validate e-mail if provided |
| 709 | + $email = $this->getVar( '_AdminEmail' ); |
| 710 | + if( $email && !User::isValidEmailAddr( $email ) ) { |
| 711 | + $this->parent->showError( 'config-admin-error-bademail' ); |
| 712 | + $retVal = false; |
| 713 | + } |
| 714 | + |
712 | 715 | return $retVal; |
713 | 716 | } |
714 | 717 | |