3 function wfSpecialEmailuser()
5 global $wgUser, $wgOut, $action, $target;
7 if ( 0 == $wgUser->getID() ||
8 ( false === strpos( $wgUser->getEmail(), "@" ) ) ) {
9 $wgOut->errorpage( "mailnologin", "mailnologintext" );
12 $target = wfCleanQueryVar( $target );
13 if ( "" == $target ) {
14 $wgOut->errorpage( "notargettitle", "notargettext" );
17 $nt = Title
::newFromURL( $target );
18 $nu = User
::newFromName( $nt->getText() );
19 $id = $nu->idForName();
22 $wgOut->errorpage( "noemailtitle", "noemailtext" );
26 $address = $nu->getEmail();
28 if ( ( false === strpos( $address, "@" ) ) ||
29 ( 1 == $nu->getOption( "disablemail" ) ) ) {
30 $wgOut->errorpage( "noemailtitle", "noemailtext" );
33 $fields = array( "wpSubject", "wpText" );
34 wfCleanFormFields( $fields );
36 $f = new EmailUserForm( $nu->getName() . " <{$address}>" );
38 if ( "success" == $action ) { $f->showSuccess(); }
39 else if ( "submit" == $action ) { $f->doSubmit(); }
40 else { $f->showForm( "" ); }
47 function EmailUserForm( $addr )
49 $this->mAddress
= $addr;
52 function showForm( $err )
54 global $wgOut, $wgUser, $wgLang;
55 global $wpSubject, $wpText, $target;
57 $wgOut->setPagetitle( wfMsg( "emailpage" ) );
58 $wgOut->addWikiText( wfMsg( "emailpagetext" ) );
60 if ( ! $wpSubject ) { $wpSubject = "Wikipedia e-mail"; }
62 $emf = wfMsg( "emailfrom" );
63 $sender = $wgUser->getName();
64 $emt = wfMsg( "emailto" );
65 $rcpt = str_replace( "_", " ", urldecode( $target ) );
66 $emr = wfMsg( "emailsubject" );
67 $emm = wfMsg( "emailmessage" );
68 $ems = wfMsg( "emailsend" );
70 $action = wfLocalUrlE( $wgLang->specialPage( "Emailuser" ),
71 "target={$target}&action=submit" );
74 $wgOut->setSubtitle( wfMsg( "formerror" ) );
75 $wgOut->addHTML( "<p><font color='red' size='+1'>{$err}</font>\n" );
78 <form id=\"emailuser\" method=\"post\" action=\"{$action}\">
80 <td align=right>{$emf}:</td>
81 <td align=left><strong>{$sender}</strong></td>
83 <td align=right>{$emt}:</td>
84 <td align=left><strong>{$rcpt}</strong></td>
86 <td align=right>{$emr}:</td>
88 <input type=text name=\"wpSubject\" value=\"{$wpSubject}\">
91 <td align=right>{$emm}:</td>
93 <textarea name=\"wpText\" rows=10 cols=60 wrap=virtual>
97 <td> </td><td align=left>
98 <input type=submit name=\"wpSend\" value=\"{$ems}\">
106 global $wgOut, $wgUser, $wgLang, $wgOutputEncoding;
107 global $wpSubject, $wpText, $target;
109 $from = $wgUser->getName() . " <" . $wgUser->getEmail() . ">";
111 "MIME-Version: 1.0\r\n" .
112 "Content-type: text/plain; charset={$wgOutputEncoding}\r\n" .
113 "Content-transfer-encoding: 8bit\r\n" .
114 "From: {$from}\r\n" .
115 "Reply-To: {$from}\r\n" .
116 "To: {$this->mAddress}\r\n" .
117 "X-Mailer: Pediawiki interuser e-mailer";
118 mail( $this->mAddress
, $wpSubject, $wpText, $headers );
120 $success = wfLocalUrl( $wgLang->specialPage( "Emailuser" ),
121 "target={$target}&action=success" );
122 $wgOut->redirect( $success );
125 function showSuccess()
127 global $wgOut, $wgUser;
129 $wgOut->setPagetitle( wfMsg( "emailsent" ) );
130 $wgOut->addHTML( wfMsg( "emailsenttext" ) );
132 $wgOut->returnToMain( false );