blob: e12a0e295864ecc23374c9921252e99f872f7d70 [file] [log] [blame]
<?php
/*******************************************************************************
* Copyright (c) 2014 Eclipse Foundation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://eclipse.org/legal/epl-v10.html
*
* Contributors:
* Edouard Poitras (Eclipse Foundation) - Further modifications
******************************************************************************/
include_once "tshirt.php";
define('HEADERS', 'From: Eclipse Webmaster (automated) <webmaster@eclipse.org>' . "\n" . 'Content-Type: text/plain; charset=UTF-8');
define('FOE_LOGO_LINK', 'https://dev.eclipse.org/site_login/myaccount.php');
define('MIRROR_SITE', 'https://friends.eclipse.org');
define('ECLIPSECON_CODE', 'FRIEND');
define('OREILLY_CODE', 'DSUG');
function send_email($data) {
if (!isset($data['firstname']) || $data['firstname'] == '') $data['firstname'] = $data['bugzilla_email'];
$content = get_email_content($data);
$data['bugzilla_email'] = filter_var($data['bugzilla_email'], FILTER_SANITIZE_EMAIL);
_send_email($data['bugzilla_email'], "Thank You For Your Donation", $content);
}
function _send_email($to, $subject, $content) {
mail($to, $subject, $content, HEADERS);
// This fails on staging but will probably succeed live
// Should I enable this???
//$EventLog = new EvtLog();
//$EventLog->setLogTable("__donations");
//$EventLog->setPK1($to);
//$EventLog->setPK2($_SERVER['REMOTE_ADDR']);
//$EventLog->setLogAction("DONATION_EMAIL_SENT");
//$EventLog->insertModLog($to);
}
function get_email_content($data) {
if ($data['amount'] >= 250) {
$data['tshirt_link'] = get_tshirt_link($data['bugzilla_id'], $data['transaction_id']);
return _get_webmaster_idol_email($data);
} else if ($data['amount'] >= 100) {
$data['tshirt_link'] = get_tshirt_link($data['bugzilla_id'], $data['transaction_id']);
return _get_best_friend_email($data);
} else if ($data['amount'] >= 35) {
return _get_friend_email($data);
} else {
return _get_email($data);
}
}
function _get_email($data) {
$email = "Dear " . $data['firstname'] . ",\n\n";
$email .= "Thank you for your donation.\n\n";
$email .= "Regards,\nThe Eclipse Foundation";
return $email;
}
function _get_friend_email($data) {
$email = "Dear " . $data['firstname'] . ",\n\n";
$email .= "Thank you for your donation.\n\n";
$email .= "We are happy to welcome you as a Friend of Eclipse. You are helping us make Eclipse even better.\n\n";
$email .= "Friend of Eclipse Benefits\n\n";
$email .= "\t-\tYou may use the Friend of Eclipse logo. It can now be found on your account page: " . FOE_LOGO_LINK . "\n";
$email .= "\t-\tYou get access to the Mirror Site here: " . MIRROR_SITE . "\n";
$email .= "\t-\tYou get 40% off prints & 50% off ebooks at http://oreilly.com using the discount code: " . OREILLY_CODE . "\n\n";
$email .= "Regards,\nThe Eclipse Foundation";
return $email;
}
function _get_best_friend_email($data) {
$email = "Dear " . $data['firstname'] . ",\n\n";
$email .= "Thank you for your donation.\n\n";
$email .= "We are happy to welcome you as a Best Friend of Eclipse. You are helping us make Eclipse even better.\n\n";
$email .= "Best Friend of Eclipse Benefits\n\n";
$email .= "\t-\tYou may use the Friend of Eclipse logo. It can now be found on your account page: " . FOE_LOGO_LINK . "\n";
$email .= "\t-\tYou get access to the Mirror Site here: " . MIRROR_SITE . "\n";
$email .= "\t-\tYou get 40% off prints & 50% off ebooks at http://oreilly.com using the discount code: " . OREILLY_CODE . "\n";
$email .= "\t-\tYou may use the friend discount to attend the three upcoming EclipseCon events. The discount code is: " . ECLIPSECON_CODE . "\n";
$email .= "\t-\tYou get an Eclipse T-Shirt! Claim it here: " . $data['tshirt_link'] . "\n\n";
$email .= "Regards,\nThe Eclipse Foundation";
return $email;
}
function _get_webmaster_idol_email($data) {
$email = "Dear " . $data['firstname'] . ",\n\n";
$email .= "Thank you for your donation.\n\n";
$email .= "We are happy to welcome you as a Webmaster Idol. You are helping us make Eclipse even better.\n\n";
$email .= "Webmaster Idol Eclipse Benefits\n\n";
$email .= "\t-\tYou may use the Friend of Eclipse logo. It can now be found on your account page: " . FOE_LOGO_LINK . "\n";
$email .= "\t-\tYou get access to the Mirror Site here: " . MIRROR_SITE . "\n";
$email .= "\t-\tYou get 40% off prints & 50% off ebooks at http://oreilly.com using the discount code: " . OREILLY_CODE . "\n";
$email .= "\t-\tYou may use the friend discount to attend the three upcoming EclipseCon events. The discount code is: " . ECLIPSECON_CODE . "\n";
$email .= "\t-\tYou get an Eclipse T-Shirt! Claim it here: " . $data['tshirt_link'] . "\n";
$email .= "\t-\tYou get the eternal gratitude of the Eclipse Webmasters!\n\n";
$email .= "Regards,\nThe Eclipse Foundation";
return $email;
}