Index: trunk/phase3/includes/specials/SpecialConfirmemail.php |
— | — | @@ -44,31 +44,27 @@ |
45 | 45 | * @param $code Confirmation code passed to the page |
46 | 46 | */ |
47 | 47 | function execute( $code ) { |
48 | | - global $wgUser, $wgOut; |
49 | 48 | $this->setHeaders(); |
50 | 49 | |
51 | 50 | if ( wfReadOnly() ) { |
52 | | - $wgOut->readOnlyPage(); |
53 | | - return; |
| 51 | + throw new ReadOnlyError; |
54 | 52 | } |
55 | 53 | |
56 | 54 | if( empty( $code ) ) { |
57 | | - if( $wgUser->isLoggedIn() ) { |
58 | | - if( Sanitizer::validateEmail( $wgUser->getEmail() ) ) { |
| 55 | + if( $this->getUser()->isLoggedIn() ) { |
| 56 | + if( Sanitizer::validateEmail( $this->getUser()->getEmail() ) ) { |
59 | 57 | $this->showRequestForm(); |
60 | 58 | } else { |
61 | | - $wgOut->addWikiMsg( 'confirmemail_noemail' ); |
| 59 | + $this->getOutput()->addWikiMsg( 'confirmemail_noemail' ); |
62 | 60 | } |
63 | 61 | } else { |
64 | | - $title = SpecialPage::getTitleFor( 'Userlogin' ); |
65 | | - $skin = $this->getSkin(); |
66 | | - $llink = $skin->linkKnown( |
67 | | - $title, |
| 62 | + $llink = Linker::linkKnown( |
| 63 | + SpecialPage::getTitleFor( 'Userlogin' ), |
68 | 64 | wfMsgHtml( 'loginreqlink' ), |
69 | 65 | array(), |
70 | 66 | array( 'returnto' => $this->getTitle()->getPrefixedText() ) |
71 | 67 | ); |
72 | | - $wgOut->addWikiMsgArray( 'confirmemail_needlogin', array( $llink ), array( 'replaceafter' ) ); |
| 68 | + $this->getOutput()->addHTML( wfMessage( 'confirmemail_needlogin' )->rawParams( $llink )->parse() ); |
73 | 69 | } |
74 | 70 | } else { |
75 | 71 | $this->attemptConfirm( $code ); |
— | — | @@ -79,33 +75,34 @@ |
80 | 76 | * Show a nice form for the user to request a confirmation mail |
81 | 77 | */ |
82 | 78 | function showRequestForm() { |
83 | | - global $wgOut, $wgUser, $wgLang, $wgRequest; |
84 | | - if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getText( 'token' ) ) ) { |
85 | | - $status = $wgUser->sendConfirmationMail(); |
| 79 | + $user = $this->getUser(); |
| 80 | + $out = $this->getOutput(); |
| 81 | + if( $this->getRequest()->wasPosted() && $user->matchEditToken( $this->getRequest()->getText( 'token' ) ) ) { |
| 82 | + $status = $user->sendConfirmationMail(); |
86 | 83 | if ( $status->isGood() ) { |
87 | | - $wgOut->addWikiMsg( 'confirmemail_sent' ); |
| 84 | + $out->addWikiMsg( 'confirmemail_sent' ); |
88 | 85 | } else { |
89 | | - $wgOut->addWikiText( $status->getWikiText( 'confirmemail_sendfailed' ) ); |
| 86 | + $out->addWikiText( $status->getWikiText( 'confirmemail_sendfailed' ) ); |
90 | 87 | } |
91 | 88 | } else { |
92 | | - if( $wgUser->isEmailConfirmed() ) { |
| 89 | + if( $user->isEmailConfirmed() ) { |
93 | 90 | // date and time are separate parameters to facilitate localisation. |
94 | 91 | // $time is kept for backward compat reasons. |
95 | 92 | // 'emailauthenticated' is also used in SpecialPreferences.php |
96 | | - $time = $wgLang->timeAndDate( $wgUser->mEmailAuthenticated, true ); |
97 | | - $d = $wgLang->date( $wgUser->mEmailAuthenticated, true ); |
98 | | - $t = $wgLang->time( $wgUser->mEmailAuthenticated, true ); |
99 | | - $wgOut->addWikiMsg( 'emailauthenticated', $time, $d, $t ); |
| 93 | + $time = $this->getLang()->timeAndDate( $user->mEmailAuthenticated, true ); |
| 94 | + $d = $this->getLang()->date( $user->mEmailAuthenticated, true ); |
| 95 | + $t = $this->getLang()->time( $user->mEmailAuthenticated, true ); |
| 96 | + $out->addWikiMsg( 'emailauthenticated', $time, $d, $t ); |
100 | 97 | } |
101 | | - if( $wgUser->isEmailConfirmationPending() ) { |
102 | | - $wgOut->wrapWikiMsg( "<div class=\"error mw-confirmemail-pending\">\n$1\n</div>", 'confirmemail_pending' ); |
| 98 | + if( $user->isEmailConfirmationPending() ) { |
| 99 | + $out->wrapWikiMsg( "<div class=\"error mw-confirmemail-pending\">\n$1\n</div>", 'confirmemail_pending' ); |
103 | 100 | } |
104 | | - $wgOut->addWikiMsg( 'confirmemail_text' ); |
| 101 | + $out->addWikiMsg( 'confirmemail_text' ); |
105 | 102 | $form = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getTitle()->getLocalUrl() ) ); |
106 | | - $form .= Html::hidden( 'token', $wgUser->editToken() ); |
| 103 | + $form .= Html::hidden( 'token', $user->editToken() ); |
107 | 104 | $form .= Xml::submitButton( wfMsg( 'confirmemail_send' ) ); |
108 | 105 | $form .= Xml::closeElement( 'form' ); |
109 | | - $wgOut->addHTML( $form ); |
| 106 | + $out->addHTML( $form ); |
110 | 107 | } |
111 | 108 | } |
112 | 109 | |
— | — | @@ -116,19 +113,18 @@ |
117 | 114 | * @param $code Confirmation code |
118 | 115 | */ |
119 | 116 | function attemptConfirm( $code ) { |
120 | | - global $wgUser, $wgOut; |
121 | 117 | $user = User::newFromConfirmationCode( $code ); |
122 | 118 | if( is_object( $user ) ) { |
123 | 119 | $user->confirmEmail(); |
124 | 120 | $user->saveSettings(); |
125 | | - $message = $wgUser->isLoggedIn() ? 'confirmemail_loggedin' : 'confirmemail_success'; |
126 | | - $wgOut->addWikiMsg( $message ); |
127 | | - if( !$wgUser->isLoggedIn() ) { |
| 121 | + $message = $this->getUser()->isLoggedIn() ? 'confirmemail_loggedin' : 'confirmemail_success'; |
| 122 | + $this->getOutput()->addWikiMsg( $message ); |
| 123 | + if( !$this->getUser()->isLoggedIn() ) { |
128 | 124 | $title = SpecialPage::getTitleFor( 'Userlogin' ); |
129 | | - $wgOut->returnToMain( true, $title ); |
| 125 | + $this->getOutput()->returnToMain( true, $title ); |
130 | 126 | } |
131 | 127 | } else { |
132 | | - $wgOut->addWikiMsg( 'confirmemail_invalid' ); |
| 128 | + $this->getOutput()->addWikiMsg( 'confirmemail_invalid' ); |
133 | 129 | } |
134 | 130 | } |
135 | 131 | |
— | — | @@ -150,9 +146,7 @@ |
151 | 147 | $this->setHeaders(); |
152 | 148 | |
153 | 149 | if ( wfReadOnly() ) { |
154 | | - global $wgOut; |
155 | | - $wgOut->readOnlyPage(); |
156 | | - return; |
| 150 | + throw new ReadOnlyError; |
157 | 151 | } |
158 | 152 | |
159 | 153 | $this->attemptInvalidate( $code ); |
— | — | @@ -165,17 +159,16 @@ |
166 | 160 | * @param $code Confirmation code |
167 | 161 | */ |
168 | 162 | function attemptInvalidate( $code ) { |
169 | | - global $wgUser, $wgOut; |
170 | 163 | $user = User::newFromConfirmationCode( $code ); |
171 | 164 | if( is_object( $user ) ) { |
172 | 165 | $user->invalidateEmail(); |
173 | 166 | $user->saveSettings(); |
174 | | - $wgOut->addWikiMsg( 'confirmemail_invalidated' ); |
175 | | - if( !$wgUser->isLoggedIn() ) { |
176 | | - $wgOut->returnToMain(); |
| 167 | + $this->getOutput()->addWikiMsg( 'confirmemail_invalidated' ); |
| 168 | + if( !$this->getUser()->isLoggedIn() ) { |
| 169 | + $this->getOutput()->returnToMain(); |
177 | 170 | } |
178 | 171 | } else { |
179 | | - $wgOut->addWikiMsg( 'confirmemail_invalid' ); |
| 172 | + $this->getOutput()->addWikiMsg( 'confirmemail_invalid' ); |
180 | 173 | } |
181 | 174 | } |
182 | 175 | } |