r42798 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r42797‎ | r42798 | r42799 >
Date:02:12, 30 October 2008
Author:tomasz
Status:old (Comments)
Tags:
Comment:
adding short circuit to work with fundraising story page
Modified paths:
  • /branches/ContactPageFundraiser/ContactPage.php (modified) (history)
  • /branches/ContactPageFundraiser/SpecialContact.php (modified) (history)

Diff [purge]

Index: branches/ContactPageFundraiser/SpecialContact.php
@@ -40,53 +40,82 @@
4141 wfLoadExtensionMessages( 'ContactPage' );
4242 $fname = "SpecialContact::execute";
4343
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 );
4847
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');
5061
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();
5668 }
5769
58 - $f = new EmailContactForm( $nu );
 70+ else {
 71+
 72+ }
 73+ if( !$wgEnableEmail || !$wgContactUser ) {
 74+ $wgOut->showErrorPage( "nosuchspecialpage", "nospecialpagetext" );
 75+ return;
 76+ }
5977
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' );
6579
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;
7285 }
7386
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" );
77117 $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();
85118 }
86 - } else {
87 - wfDebug( "$fname: form\n" );
88 - $f->showForm();
89119 }
90 - }
91120 }
92121
93122 /**
@@ -126,6 +155,10 @@
127156 $captcha->action = 'contact';
128157 }
129158 }
 159+
 160+ function setText( $text ) {
 161+ $this->text = $text;
 162+ }
130163
131164 function hasAllInfo() {
132165 global $wgContactRequireAll;
@@ -324,7 +357,7 @@
325358 wfDebug( "$fname: success\n" );
326359
327360 $titleObj = SpecialPage::getTitleFor( "Contact" );
328 - $wgOut->redirect( $titleObj->getFullURL( "action=success" ) );
 361+ $wgOut->redirect( "http://www.loldawgz.com/dawgz/All-Your-Base-AYBABTU.jpg");
329362 wfRunHooks( 'ContactFromComplete', array( $to, $replyto, $subject, $this->text ) );
330363 }
331364 }
Index: branches/ContactPageFundraiser/ContactPage.php
@@ -32,8 +32,8 @@
3333 $wgAutoloadClasses['SpecialContact'] = $dir . 'SpecialContact.php';
3434 $wgSpecialPages['Contact'] = 'SpecialContact';
3535
36 -$wgContactUser = NULL;
37 -$wgContactSender = NULL;
 36+$wgContactUser = 'Stories';
 37+$wgContactSender = 'stories@wikimedia.org';
3838 $wgContactSenderName = 'Contact Form on ' . $wgSitename;
3939
4040 $wgContactRequireAll = false;

Comments

#Comment by Tim Starling (talk | contribs)   07:59, 11 December 2009

Is it meant to be so broken? Is this still used anywhere, or can it be deleted now?

Status & tagging log