* (bug 13879) Special:EmailUser shows a form in case no user was specified
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Thu, 21 Aug 2008 22:15:34 +0000 (22:15 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Thu, 21 Aug 2008 22:15:34 +0000 (22:15 +0000)
RELEASE-NOTES
includes/api/ApiEmailUser.php
includes/specials/SpecialEmailuser.php

index ddf5835..1c598af 100644 (file)
@@ -94,6 +94,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * HTML entities like &nbsp; now work (are not escaped) in edit summaries.
 * (bug 13815) In the comment for page moves, use the colon-separator message
   instead of a hardcoded colon.
+* (bug 13879) Special:EmailUser shows a form in case no user was specified
 
 === Bug fixes in 1.14 ===
 
index 7e08353..7d23dde 100644 (file)
@@ -52,6 +52,8 @@ class ApiEmailUser extends ApiBase {
                
                // Validate target 
                $targetUser = EmailUserForm::validateEmailTarget( $params['target'] );
+               if ( $targetUser === false )
+                       $this->dieUsageMsg( array( 'notargettitle' ) );
                if ( !( $targetUser instanceof User ) )
                        $this->dieUsageMsg( array( $targetUser[0] ) );
                
index d557c84..917ae92 100644 (file)
@@ -14,7 +14,7 @@ function wfSpecialEmailuser( $par ) {
        $target = isset($par) ? $par : $wgRequest->getVal( 'target' );
        $targetUser = EmailUserForm::validateEmailTarget( $target );
        
-       if ( !( $targetUser instanceof User ) ) {
+       if ( !( $targetUser instanceof User ) && $targetUser !== false ) {
                $wgOut->showErrorPage( $targetUser[0], $targetUser[1] );
                return;
        }
@@ -47,7 +47,7 @@ function wfSpecialEmailuser( $par ) {
        }       
                
        
-       if ( "submit" == $action && $wgRequest->wasPosted() ) {
+       if ( "submit" == $action && $wgRequest->wasPosted() && $targetUser !== false ) {
                $result = $form->doSubmit();
                
                if ( !is_null( $result ) ) {
@@ -98,8 +98,9 @@ class EmailUserForm {
                $senderLink = $skin->makeLinkObj(
                        $wgUser->getUserPage(), htmlspecialchars( $wgUser->getName() ) );
                $emt = wfMsg( "emailto" );
-               $recipientLink = $skin->makeLinkObj(
-                       $this->target->getUserPage(), htmlspecialchars( $this->target->getName() ) );
+               $recipient = $this->target instanceof User ? 
+                       htmlspecialchars( $this->target->getName() ) :
+                       '';
                $emr = wfMsg( "emailsubject" );
                $emm = wfMsg( "emailmessage" );
                $ems = wfMsg( "emailsend" );
@@ -107,8 +108,7 @@ class EmailUserForm {
                $encSubject = htmlspecialchars( $this->subject );
 
                $titleObj = SpecialPage::getTitleFor( "Emailuser" );
-               $action = $titleObj->escapeLocalURL( "target=" .
-                       urlencode( $this->target->getName() ) . "&action=submit" );
+               $action = $titleObj->escapeLocalURL( "action=submit" );
                $token = htmlspecialchars( $wgUser->editToken() );
 
                $wgOut->addHTML( "
@@ -118,7 +118,7 @@ class EmailUserForm {
 <td align='left'><strong>{$senderLink}</strong></td>
 </tr><tr>
 <td align='right'>{$emt}:</td>
-<td align='left'><strong>{$recipientLink}</strong></td>
+<td align='left'><input type='text' size='60' name='target' value='{$recipient}' /></td>
 </tr><tr>
 <td align='right'>{$emr}:</td>
 <td align='left'>
@@ -235,8 +235,7 @@ class EmailUserForm {
                        return array( "nosuchspecialpage", "nospecialpagetext" );
                
                if ( "" == $target ) {
-                       wfDebug( "Target is empty.\n" );
-                       return array( "notargettitle", "notargettext" );
+                       return false;
                }
        
                $nt = Title::newFromURL( $target );