From 183851b06bd6c52f3cae5375f433da720d410447 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 11 Oct 2006 18:12:39 +0000 Subject: MediaWiki 1.7.1 wiederhergestellt --- includes/SpecialConfirmemail.php | 97 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 includes/SpecialConfirmemail.php (limited to 'includes/SpecialConfirmemail.php') diff --git a/includes/SpecialConfirmemail.php b/includes/SpecialConfirmemail.php new file mode 100644 index 00000000..fd0425a8 --- /dev/null +++ b/includes/SpecialConfirmemail.php @@ -0,0 +1,97 @@ + + */ + +/** + * Main execution point + * + * @param $par Parameters passed to the page + */ +function wfSpecialConfirmemail( $par ) { + $form = new EmailConfirmation(); + $form->execute( $par ); +} + +class EmailConfirmation extends SpecialPage { + + /** + * Main execution point + * + * @param $code Confirmation code passed to the page + */ + function execute( $code ) { + global $wgUser, $wgOut; + if( empty( $code ) ) { + if( $wgUser->isLoggedIn() ) { + $this->showRequestForm(); + } else { + $title = Title::makeTitle( NS_SPECIAL, 'Userlogin' ); + $self = Title::makeTitle( NS_SPECIAL, 'Confirmemail' ); + $skin = $wgUser->getSkin(); + $llink = $skin->makeKnownLinkObj( $title, wfMsgHtml( 'loginreqlink' ), 'returnto=' . $self->getPrefixedUrl() ); + $wgOut->addHtml( wfMsgWikiHtml( 'confirmemail_needlogin', $llink ) ); + } + } else { + $this->attemptConfirm( $code ); + } + } + + /** + * Show a nice form for the user to request a confirmation mail + */ + function showRequestForm() { + global $wgOut, $wgUser, $wgLang, $wgRequest; + if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getText( 'token' ) ) ) { + $ok = $wgUser->sendConfirmationMail(); + $message = WikiError::isError( $ok ) ? 'confirmemail_sendfailed' : 'confirmemail_sent'; + $wgOut->addWikiText( wfMsg( $message ) ); + } else { + if( $wgUser->isEmailConfirmed() ) { + $time = $wgLang->timeAndDate( $wgUser->mEmailAuthenticated, true ); + $wgOut->addWikiText( wfMsg( 'emailauthenticated', $time ) ); + } + $wgOut->addWikiText( wfMsg( 'confirmemail_text' ) ); + $self = Title::makeTitle( NS_SPECIAL, 'Confirmemail' ); + $form = wfOpenElement( 'form', array( 'method' => 'post', 'action' => $self->getLocalUrl() ) ); + $form .= wfHidden( 'token', $wgUser->editToken() ); + $form .= wfSubmitButton( wfMsgHtml( 'confirmemail_send' ) ); + $form .= wfCloseElement( 'form' ); + $wgOut->addHtml( $form ); + } + } + + /** + * Attempt to confirm the user's email address and show success or failure + * as needed; if successful, take the user to log in + * + * @param $code Confirmation code + */ + function attemptConfirm( $code ) { + global $wgUser, $wgOut; + $user = User::newFromConfirmationCode( $code ); + if( is_object( $user ) ) { + if( $user->confirmEmail() ) { + $message = $wgUser->isLoggedIn() ? 'confirmemail_loggedin' : 'confirmemail_success'; + $wgOut->addWikiText( wfMsg( $message ) ); + if( !$wgUser->isLoggedIn() ) { + $title = Title::makeTitle( NS_SPECIAL, 'Userlogin' ); + $wgOut->returnToMain( true, $title->getPrefixedText() ); + } + } else { + $wgOut->addWikiText( wfMsg( 'confirmemail_error' ) ); + } + } else { + $wgOut->addWikiText( wfMsg( 'confirmemail_invalid' ) ); + } + } + +} + +?> -- cgit v1.2.3-54-g00ecf