Skip to content

Commit

Permalink
Now sends the message, still need to save state and postcode
Browse files Browse the repository at this point in the history
  • Loading branch information
henare committed May 12, 2011
1 parent c5a9ad2 commit 415a29b
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions salsa-australian-politicians.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,20 @@ function salsa_campaigns_shortcode($atts) {
$_POST['salsa_campaigns_mp_last_name']
);
break;
case 'send_message':
$details = array (
'action_key' => $_POST['salsa_campaigns_action_key'],
'recipient_key' => $_POST['salsa_campaigns_recipient_key'],
'subject' => $_POST['salsa_campaigns_subject'],
'message' => $_POST['salsa_campaigns_message'],
'firstname' => $_POST['salsa_campaigns_firstname'],
'lastname' => $_POST['salsa_campaigns_lastname'],
'email' => $_POST['salsa_campaigns_email'],
'postcode' => $_POST['salsa_campaigns_postcode'],
'state' => $_POST['salsa_campaigns_state']
);
return salsa_campaigns_send_message_page($details);
break;
}
} else {
return salsa_campaigns_postcode_page();
Expand Down Expand Up @@ -325,6 +339,7 @@ function salsa_campaigns_write_message_page($campaign_name, $mp_first_name, $mp_
<form name="form1" method="post" action="">
<input type="hidden" name="salsa_campaigns_method" value="send_message" />
<input type="hidden" name="salsa_campaigns_action_key" value="' . $current_action->action_KEY . '" />
<input type="hidden" name="salsa_campaigns_recipient_key" value="' . $recipient->recipient_KEY . '" />
<p>Subject</p>
<input type="text" name="salsa_campaigns_subject" value="' . $content->Recommended_Subject . '" />
Expand Down Expand Up @@ -365,6 +380,37 @@ function salsa_campaigns_write_message_page($campaign_name, $mp_first_name, $mp_
return $page;
}

function salsa_campaigns_send_message_page($details) {
$salsa = salsa_campaigns_salsa_logon();

# Add details we've collected to submit to Salsa
$p['action_KEY'] = $details['action_key'];
$p['target_key'] = $details['recipient_key'];
$p['Subject'] = $details['subject'];
$p['Content'] = $details['message'];
$p['First_Name'] = $details['firstname'];
$p['Last_Name'] = $details['lastname'];
$p['Email'] = $details['email'];
#$p[''] = $details['postcode'];
#$p[''] = $details['state'];
$p['linkKey'] = $details['action_key'];

# Add mandatory fields we need to submit to Salsa
$p['table'] = "supporter";
$p['link'] = "action";
$p['target_contentName'] = "Content";
$p['target_subjectName'] = "Subject";
$p['target_method'] = "Email/Webform";
$p['target_type'] = "recipient";

$result = $salsa->submitForm("/salsa/api/action/processAction2.jsp", $p);
if ($result) {
return $result;
}else{
return "Sorry, your message was not sent. Please contact the site owner to report this problem.";
}
}

// Authenticate and instantiate the Salsa connector
function salsa_campaigns_salsa_logon() {
$salsa_campaigns_options = get_option('salsa_campaigns_options');
Expand Down

0 comments on commit 415a29b

Please sign in to comment.