3 * Entry point to confirm a user's e-mail address.
4 * When a new address is entered, a random unique code is generated and
5 * mailed to the user. A clickable link to this page is provided.
8 * @subpackage SpecialPage
12 function wfSpecialConfirmemail( $code ) {
13 $form = new ConfirmationForm();
17 /** @package MediaWiki */
18 class ConfirmationForm
{
20 function show( $code ) {
21 if( empty( $code ) ) {
22 $this->showEmpty( $this->checkAndSend() );
24 $this->showCode( $code );
29 function showCode( $code ) {
30 $user = User
::newFromConfirmationCode( $code );
31 if( is_null( $user ) ) {
32 $this->showInvalidCode();
34 $this->confirmAndShow( $user );
39 function confirmAndShow( $user ) {
40 if( $user->confirmEmail() ) {
48 function checkAndSend() {
49 global $wgUser, $wgRequest;
50 if( $wgRequest->wasPosted() &&
51 $wgUser->isLoggedIn() &&
52 $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
53 $result = $wgUser->sendConfirmationMail();
54 if( WikiError
::isError( $result ) ) {
55 return 'confirmemail_sendfailed';
57 return 'confirmemail_sent';
66 function showEmpty( $err ) {
67 require_once( 'templates/Confirmemail.php' );
68 global $wgOut, $wgUser;
70 $tpl = new ConfirmemailTemplate();
71 $tpl->set( 'error', $err );
72 $tpl->set( 'edittoken', $wgUser->editToken() );
74 $title = Title
::makeTitle( NS_SPECIAL
, 'Confirmemail' );
75 $tpl->set( 'action', $title->getLocalUrl() );
78 $wgOut->addTemplate( $tpl );
82 function showInvalidCode() {
84 $wgOut->addWikiText( wfMsg( 'confirmemail_invalid' ) );
88 function showError() {
90 $wgOut->addWikiText( wfMsg( 'confirmemail_error' ) );
94 function showSuccess() {
95 global $wgOut, $wgRequest, $wgUser;
97 if( $wgUser->isLoggedIn() ) {
98 $wgOut->addWikiText( wfMsg( 'confirmemail_loggedin' ) );
100 $wgOut->addWikiText( wfMsg( 'confirmemail_success' ) );
101 require_once( 'SpecialUserlogin.php' );
102 $form = new LoginForm( $wgRequest );