Fixes bug #2632 : new image height when zooming without using "thumb" was not computed.
[lhc/web/wiklou.git] / includes / SpecialConfirmemail.php
1 <?php
2 /**
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.
6 *
7 * @package MediaWiki
8 * @subpackage SpecialPage
9 */
10
11 function wfSpecialConfirmemail( $code ) {
12 $form = new ConfirmationForm();
13 $form->show( $code );
14 }
15
16 class ConfirmationForm {
17 function show( $code ) {
18 if( empty( $code ) ) {
19 $this->showEmpty( $this->checkAndSend() );
20 } else {
21 $this->showCode( $code );
22 }
23 }
24
25 function showCode( $code ) {
26 $user = User::newFromConfirmationCode( $code );
27 if( is_null( $user ) ) {
28 $this->showInvalidCode();
29 } else {
30 $this->confirmAndShow( $user );
31 }
32 }
33
34
35 function confirmAndShow( $user ) {
36 if( $user->confirmEmail() ) {
37 $this->showSuccess();
38 } else {
39 $this->showError();
40 }
41 }
42
43 function checkAndSend() {
44 global $wgUser, $wgRequest;
45 if( $wgRequest->wasPosted() &&
46 $wgUser->isLoggedIn() &&
47 $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
48 $result = $wgUser->sendConfirmationMail();
49 if( WikiError::isError( $result ) ) {
50 return 'confirmemail_sendfailed';
51 } else {
52 return 'confirmemail_sent';
53 }
54 } else {
55 # boo
56 return '';
57 }
58 }
59
60 function showEmpty( $err ) {
61 require_once( 'templates/Confirmemail.php' );
62 global $wgOut, $wgUser;
63
64 $tpl = new ConfirmemailTemplate();
65 $tpl->set( 'error', $err );
66 $tpl->set( 'edittoken', $wgUser->editToken() );
67
68 $title = Title::makeTitle( NS_SPECIAL, 'Confirmemail' );
69 $tpl->set( 'action', $title->getLocalUrl() );
70
71
72 $wgOut->addTemplate( $tpl );
73 }
74
75 function showInvalidCode() {
76 global $wgOut;
77 $wgOut->addWikiText( wfMsg( 'confirmemail_invalid' ) );
78 }
79
80 function showError() {
81 global $wgOut;
82 $wgOut->addWikiText( wfMsg( 'confirmemail_error' ) );
83 }
84
85 function showSuccess() {
86 global $wgOut, $wgRequest, $wgUser;
87
88 if( $wgUser->isLoggedIn() ) {
89 $wgOut->addWikiText( wfMsg( 'confirmemail_loggedin' ) );
90 } else {
91 $wgOut->addWikiText( wfMsg( 'confirmemail_success' ) );
92 require_once( 'SpecialUserlogin.php' );
93 $form = new LoginForm( $wgRequest );
94 $form->execute();
95 }
96 }
97 }
98
99 ?>