]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - includes/specials/SpecialConfirmemail.php
MediaWiki 1.17.0
[autoinstallsdev/mediawiki.git] / includes / specials / SpecialConfirmemail.php
index e19aa99b4af141c32f923b3a1f1a9f0e4cbade01..e556a60b5aeba5db34afe99b9cdebbdcc0e141ed 100644 (file)
@@ -1,4 +1,25 @@
 <?php
+/**
+ * Implements Special:Confirmemail and Special:Invalidateemail
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup SpecialPage
+ */
 
 /**
  * Special page allows users to request email confirmation message, and handles
@@ -25,6 +46,12 @@ class EmailConfirmation extends UnlistedSpecialPage {
        function execute( $code ) {
                global $wgUser, $wgOut;
                $this->setHeaders();
+               
+               if ( wfReadOnly() ) {
+                       $wgOut->readOnlyPage();
+                       return;
+               }
+               
                if( empty( $code ) ) {
                        if( $wgUser->isLoggedIn() ) {
                                if( User::isValidEmailAddr( $wgUser->getEmail() ) ) {
@@ -34,10 +61,13 @@ class EmailConfirmation extends UnlistedSpecialPage {
                                }
                        } else {
                                $title = SpecialPage::getTitleFor( 'Userlogin' );
-                               $self = SpecialPage::getTitleFor( 'Confirmemail' );
                                $skin = $wgUser->getSkin();
-                               $llink = $skin->makeKnownLinkObj( $title, wfMsgHtml( 'loginreqlink' ), 
-                                       'returnto=' . $self->getPrefixedUrl() );
+                               $llink = $skin->linkKnown(
+                                       $title,
+                                       wfMsgHtml( 'loginreqlink' ),
+                                       array(),
+                                       array( 'returnto' => $this->getTitle()->getPrefixedText() )
+                               );
                                $wgOut->addHTML( wfMsgWikiHtml( 'confirmemail_needlogin', $llink ) );
                        }
                } else {
@@ -51,11 +81,11 @@ class EmailConfirmation extends UnlistedSpecialPage {
        function showRequestForm() {
                global $wgOut, $wgUser, $wgLang, $wgRequest;
                if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getText( 'token' ) ) ) {
-                       $ok = $wgUser->sendConfirmationMail();
-                       if ( WikiError::isError( $ok ) ) {
-                               $wgOut->addWikiMsg( 'confirmemail_sendfailed', $ok->toString() );
-                       } else {
+                       $status = $wgUser->sendConfirmationMail();
+                       if ( $status->isGood() ) {
                                $wgOut->addWikiMsg( 'confirmemail_sent' );
+                       } else {
+                               $wgOut->addWikiText( $status->getWikiText( 'confirmemail_sendfailed' ) );
                        }
                } else {
                        if( $wgUser->isEmailConfirmed() ) {
@@ -68,13 +98,12 @@ class EmailConfirmation extends UnlistedSpecialPage {
                                $wgOut->addWikiMsg( 'emailauthenticated', $time, $d, $t );
                        }
                        if( $wgUser->isEmailConfirmationPending() ) {
-                               $wgOut->addWikiMsg( 'confirmemail_pending' );
+                               $wgOut->wrapWikiMsg( "<div class=\"error mw-confirmemail-pending\">\n$1\n</div>", 'confirmemail_pending' );
                        }
                        $wgOut->addWikiMsg( 'confirmemail_text' );
-                       $self = SpecialPage::getTitleFor( 'Confirmemail' );
-                       $form  = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $self->getLocalUrl() ) );
-                       $form .= Xml::hidden( 'token', $wgUser->editToken() );
-                       $form .= Xml::submitButton( wfMsgHtml( 'confirmemail_send' ) );
+                       $form  = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getTitle()->getLocalUrl() ) );
+                       $form .= Html::hidden( 'token', $wgUser->editToken() );
+                       $form .= Xml::submitButton( wfMsg( 'confirmemail_send' ) );
                        $form .= Xml::closeElement( 'form' );
                        $wgOut->addHTML( $form );
                }
@@ -119,6 +148,13 @@ class EmailInvalidation extends UnlistedSpecialPage {
 
        function execute( $code ) {
                $this->setHeaders();
+
+               if ( wfReadOnly() ) {
+                       global $wgOut;         
+                       $wgOut->readOnlyPage();
+                       return;
+               }
+               
                $this->attemptInvalidate( $code );
        }