Index: branches/ContactPageFundraiser/SpecialContact.php |
— | — | @@ -40,53 +40,82 @@ |
41 | 41 | wfLoadExtensionMessages( 'ContactPage' ); |
42 | 42 | $fname = "SpecialContact::execute"; |
43 | 43 | |
44 | | - if( !$wgEnableEmail || !$wgContactUser ) { |
45 | | - $wgOut->showErrorPage( "nosuchspecialpage", "nospecialpagetext" ); |
46 | | - return; |
47 | | - } |
| 44 | + if ( $wgRequest->wasPosted() ) { |
| 45 | + $nu = User::newFromName( $wgContactUser ); |
| 46 | + $f = new EmailContactForm( $nu ); |
48 | 47 | |
49 | | - $action = $wgRequest->getVal( 'action' ); |
| 48 | + $form['fname'] = $wgRequest->getVal('fname'); |
| 49 | + $form['lname'] = $wgRequest->getVal('lname'); |
| 50 | + $form['orgname'] = $wgRequest->getVal('orgname'); |
| 51 | + $form['jobname'] = $wgRequest->getVal('jobname'); |
| 52 | + $form['urlname'] = $wgRequest->getVal('urlname'); |
| 53 | + $form['email'] = $wgRequest->getVal('email'); |
| 54 | + $form['telephone'] = $wgRequest->getVal('telephone'); |
| 55 | + $form['other'] = $wgRequest->getVal('other'); |
| 56 | + $form['url'] = $wgRequest->getVal('url'); |
| 57 | + $form['country'] = $wgRequest->getVal('country'); |
| 58 | + $form['citytown'] = $wgRequest->getVal('city-town'); |
| 59 | + $form['provstat'] = $wgRequest->getVal('prov-state'); |
| 60 | + $form['story'] = $wgRequest->getVal('story'); |
50 | 61 | |
51 | | - $nu = User::newFromName( $wgContactUser ); |
52 | | - if( is_null( $nu ) || !$nu->canReceiveEmail() ) { |
53 | | - wfDebug( "Target is invalid user or can't receive.\n" ); |
54 | | - $wgOut->showErrorPage( "noemailtitle", "noemailtext" ); |
55 | | - return; |
| 62 | + $text = ''; |
| 63 | + foreach( $form as $key => $value) { |
| 64 | + $text .= "$key\t\t\t:\t\t\t$value\n"; |
| 65 | + } |
| 66 | + $f->setText( $text ); |
| 67 | + $f->doSubmit(); |
56 | 68 | } |
57 | 69 | |
58 | | - $f = new EmailContactForm( $nu ); |
| 70 | + else { |
| 71 | + |
| 72 | + } |
| 73 | + if( !$wgEnableEmail || !$wgContactUser ) { |
| 74 | + $wgOut->showErrorPage( "nosuchspecialpage", "nospecialpagetext" ); |
| 75 | + return; |
| 76 | + } |
59 | 77 | |
60 | | - if ( "success" == $action ) { |
61 | | - wfDebug( "$fname: success.\n" ); |
62 | | - $f->showSuccess( ); |
63 | | - } else if ( "submit" == $action && $wgRequest->wasPosted() && $f->hasAllInfo() ) { |
64 | | - $token = $wgRequest->getVal( 'wpEditToken' ); |
| 78 | + $action = $wgRequest->getVal( 'action' ); |
65 | 79 | |
66 | | - if( $wgUser->isAnon() ) { |
67 | | - # Anonymous users may not have a session |
68 | | - # open. Check for suffix anyway. |
69 | | - $tokenOk = ( EDIT_TOKEN_SUFFIX == $token ); |
70 | | - } else { |
71 | | - $tokenOk = $wgUser->matchEditToken( $token ); |
| 80 | + $nu = User::newFromName( $wgContactUser ); |
| 81 | + if( is_null( $nu ) || !$nu->canReceiveEmail() ) { |
| 82 | + wfDebug( "Target is invalid user or can't receive.\n" ); |
| 83 | + $wgOut->showErrorPage( "noemailtitle", "noemailtext" ); |
| 84 | + return; |
72 | 85 | } |
73 | 86 | |
74 | | - if ( !$tokenOk ) { |
75 | | - wfDebug( "$fname: bad token (".($wgUser->isAnon()?'anon':'user')."): $token\n" ); |
76 | | - $wgOut->addWikiText( wfMsg( 'sessionfailure' ) ); |
| 87 | + $f = new EmailContactForm( $nu ); |
| 88 | + |
| 89 | + if ( "success" == $action ) { |
| 90 | + wfDebug( "$fname: success.\n" ); |
| 91 | + $f->showSuccess( ); |
| 92 | + } else if ( "submit" == $action && $wgRequest->wasPosted() && $f->hasAllInfo() ) { |
| 93 | + $token = $wgRequest->getVal( 'wpEditToken' ); |
| 94 | + |
| 95 | + if( $wgUser->isAnon() ) { |
| 96 | + # Anonymous users may not have a session |
| 97 | + # open. Check for suffix anyway. |
| 98 | + $tokenOk = ( EDIT_TOKEN_SUFFIX == $token ); |
| 99 | + } else { |
| 100 | + $tokenOk = $wgUser->matchEditToken( $token ); |
| 101 | + } |
| 102 | + |
| 103 | + if ( !$tokenOk ) { |
| 104 | + wfDebug( "$fname: bad token (".($wgUser->isAnon()?'anon':'user')."): $token\n" ); |
| 105 | + $wgOut->addWikiText( wfMsg( 'sessionfailure' ) ); |
| 106 | + $f->showForm(); |
| 107 | + } else if ( !$f->passCaptcha() ) { |
| 108 | + wfDebug( "$fname: captcha failed" ); |
| 109 | + $wgOut->addWikiText( wfMsg( 'contactpage-captcha-failed' ) ); //TODO: provide a message for this! |
| 110 | + $f->showForm(); |
| 111 | + } else { |
| 112 | + wfDebug( "$fname: submit\n" ); |
| 113 | + $f->doSubmit(); |
| 114 | + } |
| 115 | + } else { |
| 116 | + wfDebug( "$fname: form\n" ); |
77 | 117 | $f->showForm(); |
78 | | - } else if ( !$f->passCaptcha() ) { |
79 | | - wfDebug( "$fname: captcha failed" ); |
80 | | - $wgOut->addWikiText( wfMsg( 'contactpage-captcha-failed' ) ); //TODO: provide a message for this! |
81 | | - $f->showForm(); |
82 | | - } else { |
83 | | - wfDebug( "$fname: submit\n" ); |
84 | | - $f->doSubmit(); |
85 | 118 | } |
86 | | - } else { |
87 | | - wfDebug( "$fname: form\n" ); |
88 | | - $f->showForm(); |
89 | 119 | } |
90 | | - } |
91 | 120 | } |
92 | 121 | |
93 | 122 | /** |
— | — | @@ -126,6 +155,10 @@ |
127 | 156 | $captcha->action = 'contact'; |
128 | 157 | } |
129 | 158 | } |
| 159 | + |
| 160 | + function setText( $text ) { |
| 161 | + $this->text = $text; |
| 162 | + } |
130 | 163 | |
131 | 164 | function hasAllInfo() { |
132 | 165 | global $wgContactRequireAll; |
— | — | @@ -324,7 +357,7 @@ |
325 | 358 | wfDebug( "$fname: success\n" ); |
326 | 359 | |
327 | 360 | $titleObj = SpecialPage::getTitleFor( "Contact" ); |
328 | | - $wgOut->redirect( $titleObj->getFullURL( "action=success" ) ); |
| 361 | + $wgOut->redirect( "http://www.loldawgz.com/dawgz/All-Your-Base-AYBABTU.jpg"); |
329 | 362 | wfRunHooks( 'ContactFromComplete', array( $to, $replyto, $subject, $this->text ) ); |
330 | 363 | } |
331 | 364 | } |
Index: branches/ContactPageFundraiser/ContactPage.php |
— | — | @@ -32,8 +32,8 @@ |
33 | 33 | $wgAutoloadClasses['SpecialContact'] = $dir . 'SpecialContact.php'; |
34 | 34 | $wgSpecialPages['Contact'] = 'SpecialContact'; |
35 | 35 | |
36 | | -$wgContactUser = NULL; |
37 | | -$wgContactSender = NULL; |
| 36 | +$wgContactUser = 'Stories'; |
| 37 | +$wgContactSender = 'stories@wikimedia.org'; |
38 | 38 | $wgContactSenderName = 'Contact Form on ' . $wgSitename; |
39 | 39 | |
40 | 40 | $wgContactRequireAll = false; |