From 63601400e476c6cf43d985f3e7b9864681695ed4 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 18 Jan 2013 16:46:04 +0100 Subject: Update to MediaWiki 1.20.2 this update includes: * adjusted Arch Linux skin * updated FluxBBAuthPlugin * patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024 --- includes/specials/SpecialEmailuser.php | 74 +++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 27 deletions(-) (limited to 'includes/specials/SpecialEmailuser.php') diff --git a/includes/specials/SpecialEmailuser.php b/includes/specials/SpecialEmailuser.php index 314da727..4d875e6e 100644 --- a/includes/specials/SpecialEmailuser.php +++ b/includes/specials/SpecialEmailuser.php @@ -33,6 +33,15 @@ class SpecialEmailUser extends UnlistedSpecialPage { parent::__construct( 'Emailuser' ); } + public function getDescription() { + $target = self::getTarget( $this->mTarget ); + if( !$target instanceof User ) { + return $this->msg( 'emailuser-title-notarget' )->text(); + } + + return $this->msg( 'emailuser-title-target', $target->getName() )->text(); + } + protected function getFormFields() { return array( 'From' => array( @@ -61,18 +70,19 @@ class SpecialEmailUser extends UnlistedSpecialPage { ), 'Subject' => array( 'type' => 'text', - 'default' => wfMsgExt( 'defemailsubject', array( 'content', 'parsemag' ), $this->getUser()->getName() ), + 'default' => $this->msg( 'defemailsubject', + $this->getUser()->getName() )->inContentLanguage()->text(), 'label-message' => 'emailsubject', 'maxlength' => 200, 'size' => 60, - 'required' => 1, + 'required' => true, ), 'Text' => array( 'type' => 'textarea', 'rows' => 20, 'cols' => 80, 'label-message' => 'emailmessage', - 'required' => 1, + 'required' => true, ), 'CCMe' => array( 'type' => 'check', @@ -83,13 +93,18 @@ class SpecialEmailUser extends UnlistedSpecialPage { } public function execute( $par ) { - $this->setHeaders(); - $this->outputHeader(); $out = $this->getOutput(); $out->addModuleStyles( 'mediawiki.special' ); + $this->mTarget = is_null( $par ) ? $this->getRequest()->getVal( 'wpTarget', $this->getRequest()->getVal( 'target', '' ) ) : $par; + + // This needs to be below assignment of $this->mTarget because + // getDescription() needs it to determine the correct page title. + $this->setHeaders(); + $this->outputHeader(); + // error out if sending user cannot do this $error = self::getPermissionsError( $this->getUser(), $this->getRequest()->getVal( 'wpEditToken' ) ); switch ( $error ) { @@ -124,18 +139,17 @@ class SpecialEmailUser extends UnlistedSpecialPage { $this->mTargetObj = $ret; $form = new HTMLForm( $this->getFormFields(), $this->getContext() ); - $form->addPreText( wfMsgExt( 'emailpagetext', 'parseinline' ) ); - $form->setSubmitText( wfMsg( 'emailsend' ) ); + $form->addPreText( $this->msg( 'emailpagetext' )->parse() ); + $form->setSubmitTextMsg( 'emailsend' ); $form->setTitle( $this->getTitle() ); - $form->setSubmitCallback( array( __CLASS__, 'submit' ) ); - $form->setWrapperLegend( wfMsgExt( 'email-legend', 'parsemag' ) ); + $form->setSubmitCallback( array( __CLASS__, 'uiSubmit' ) ); + $form->setWrapperLegendMsg( 'email-legend' ); $form->loadData(); if( !wfRunHooks( 'EmailUserForm', array( &$form ) ) ) { return false; } - $out->setPageTitle( $this->msg( 'emailpage' ) ); $result = $form->show(); if( $result === true || ( $result instanceof Status && $result->isGood() ) ) { @@ -224,14 +238,26 @@ class SpecialEmailUser extends UnlistedSpecialPage { $string = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'askusername' ) ) . Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . Xml::openElement( 'fieldset' ) . - Html::rawElement( 'legend', null, wfMessage( 'emailtarget' )->parse() ) . - Xml::inputLabel( wfMessage( 'emailusername' )->text(), 'target', 'emailusertarget', 30, $name ) . ' ' . - Xml::submitButton( wfMessage( 'emailusernamesubmit' )->text() ) . + Html::rawElement( 'legend', null, $this->msg( 'emailtarget' )->parse() ) . + Xml::inputLabel( $this->msg( 'emailusername' )->text(), 'target', 'emailusertarget', 30, $name ) . ' ' . + Xml::submitButton( $this->msg( 'emailusernamesubmit' )->text() ) . Xml::closeElement( 'fieldset' ) . Xml::closeElement( 'form' ) . "\n"; return $string; } + /** + * Submit callback for an HTMLForm object, will simply call submit(). + * + * @since 1.20 + * @param $data array + * @param $form HTMLForm object + * @return Status|string|bool + */ + public static function uiSubmit( array $data, HTMLForm $form ) { + return self::submit( $data, $form->getContext() ); + } + /** * Really send a mail. Permissions should have been checked using * getPermissionsError(). It is probably also a good @@ -240,25 +266,22 @@ class SpecialEmailUser extends UnlistedSpecialPage { * @return Mixed: Status object, or potentially a String on error * or maybe even true on success if anything uses the EmailUser hook. */ - public static function submit( $data ) { - global $wgUser, $wgUserEmailUseReplyTo; + public static function submit( array $data, IContextSource $context ) { + global $wgUserEmailUseReplyTo; $target = self::getTarget( $data['Target'] ); if( !$target instanceof User ) { - return wfMsgExt( $target . 'text', 'parse' ); + return $context->msg( $target . 'text' )->parseAsBlock(); } $to = new MailAddress( $target ); - $from = new MailAddress( $wgUser ); + $from = new MailAddress( $context->getUser() ); $subject = $data['Subject']; $text = $data['Text']; // Add a standard footer and trim up trailing newlines $text = rtrim( $text ) . "\n\n-- \n"; - $text .= wfMsgExt( - 'emailuserfooter', - array( 'content', 'parsemag' ), - array( $from->name, $to->name ) - ); + $text .= $context->msg( 'emailuserfooter', + $from->name, $to->name )->inContentLanguage()->text(); $error = ''; if( !wfRunHooks( 'EmailUser', array( &$to, &$from, &$subject, &$text, &$error ) ) ) { @@ -302,11 +325,8 @@ class SpecialEmailUser extends UnlistedSpecialPage { // unless they are emailing themselves, in which case one // copy of the message is sufficient. if ( $data['CCMe'] && $to != $from ) { - $cc_subject = wfMsg( - 'emailccsubject', - $target->getName(), - $subject - ); + $cc_subject = $context->msg( 'emailccsubject' )->rawParams( + $target->getName(), $subject )->text(); wfRunHooks( 'EmailUserCC', array( &$from, &$from, &$cc_subject, &$text ) ); $ccStatus = UserMailer::send( $from, $from, $cc_subject, $text ); $status->merge( $ccStatus ); -- cgit v1.2.2