- /**
- * Submit callback for an HTMLForm object, will simply call submit().
- *
- * @since 1.20
- * @param array $data
- * @param HTMLForm $form
- * @return Status|bool
- */
- public static function uiSubmit( array $data, HTMLForm $form ) {
- return self::submit( $data, $form->getContext() );
+ public function sendEmailForm() {
+ $out = $this->getOutput();
+
+ $ret = $this->mTargetObj;
+ if ( !$ret instanceof User ) {
+ if ( $this->mTarget != '' ) {
+ // Messages used here: notargettext, noemailtext, nowikiemailtext
+ $ret = ( $ret == 'notarget' ) ? 'emailnotarget' : ( $ret . 'text' );
+ return Status::newFatal( $ret );
+ }
+ return false;
+ }
+
+ $htmlForm = HTMLForm::factory( 'ooui', $this->getFormFields(), $this->getContext() );
+ // By now we are supposed to be sure that $this->mTarget is a user name
+ $htmlForm
+ ->addPreText( $this->msg( 'emailpagetext', $this->mTarget )->parse() )
+ ->setSubmitTextMsg( 'emailsend' )
+ ->setSubmitCallback( [ __CLASS__, 'submit' ] )
+ ->setFormIdentifier( 'sendEmailForm' )
+ ->setWrapperLegendMsg( 'email-legend' )
+ ->loadData();
+
+ if ( !Hooks::run( 'EmailUserForm', [ &$htmlForm ] ) ) {
+ return false;
+ }
+
+ $result = $htmlForm->show();
+
+ if ( $result === true || ( $result instanceof Status && $result->isGood() ) ) {
+ $out->setPageTitle( $this->msg( 'emailsent' ) );
+ $out->addWikiMsg( 'emailsenttext', $this->mTarget );
+ $out->returnToMain( false, $ret->getUserPage() );
+ }
+ return true;