+
+ function getTarget() {
+ return $this->target;
+ }
+
+ static function getPermissionsError ( $target ) {
+ global $wgUser, $wgRequest, $wgEnableEmail, $wgEnableUserEmail;
+
+ if( !( $wgEnableEmail && $wgEnableUserEmail ) )
+ return array( "nosuchspecialpage", "nospecialpagetext" );
+
+ if( !$wgUser->canSendEmail() ) {
+ wfDebug( "User can't send.\n" );
+ return array( "mailnologin", "mailnologintext" );
+ }
+
+ if( $wgUser->isBlockedFromEmailuser() ) {
+ wfDebug( "User is blocked from sending e-mail.\n" );
+ return array( "blockedemailuser", "" );
+ }
+
+ if ( "" == $target ) {
+ wfDebug( "Target is empty.\n" );
+ return array( "notargettitle", "notargettext" );
+ }
+
+ $nt = Title::newFromURL( $target );
+ if ( is_null( $nt ) ) {
+ wfDebug( "Target is invalid title.\n" );
+ return array( "notargettitle", "notargettext" );
+ }
+
+ $nu = User::newFromName( $nt->getText() );
+ if( is_null( $nu ) || !$nu->canReceiveEmail() ) {
+ wfDebug( "Target is invalid user or can't receive.\n" );
+ return array( "noemailtitle", "noemailtext" );
+ }
+
+ return;
+ }
+
+ static function newFromURL( $target, $text, $subject, $cc_me )
+ {
+ $nt = Title::newFromURL( $target );
+ $nu = User::newFromName( $nt->getText() );
+ return new EmailUserForm( $nu, $text, $subject, $cc_me );
+ }