blob: e9602d1cd353552188807ab2c94a9e770f58c16b [file] [log] [blame]
Edouard Poitras6d106062014-08-25 17:10:36 -04001<?php
2/*******************************************************************************
3 * Copyright (c) 2014 Eclipse Foundation and others.
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Edouard Poitras (Eclipse Foundation) - Further modifications
11 ******************************************************************************/
12
Edouard Poitras1a516b62014-12-11 15:31:01 -050013require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/evt_log.class.php");
Edouard Poitras6d106062014-08-25 17:10:36 -040014include_once "tshirt.php";
15
16define('HEADERS', 'From: Eclipse Webmaster (automated) <webmaster@eclipse.org>' . "\n" . 'Content-Type: text/plain; charset=UTF-8');
17define('FOE_LOGO_LINK', 'https://dev.eclipse.org/site_login/myaccount.php');
Edouard Poitras72a9a7c2015-01-07 16:43:19 -050018//define('MIRROR_SITE', 'https://friends.eclipse.org'); // Deprecated
Edouard Poitras6d106062014-08-25 17:10:36 -040019define('ECLIPSECON_CODE', 'FRIEND');
Edouard Poitras7d27b162015-04-02 16:00:04 -040020define('OREILLY_CODE', 'PCBW');
Edouard Poitras6d106062014-08-25 17:10:36 -040021
22function send_email($data) {
Edouard Poitras5d4f38b2014-12-23 12:17:32 -050023 if (!isset($data['firstname']) || $data['firstname'] == '') $data['firstname'] = $data['email'];
Edouard Poitras6d106062014-08-25 17:10:36 -040024 $content = get_email_content($data);
Edouard Poitras5d4f38b2014-12-23 12:17:32 -050025 $data['email'] = filter_var($data['email'], FILTER_SANITIZE_EMAIL);
26 _send_email($data['email'], "Thank You For Your Donation", $content);
Edouard Poitras6d106062014-08-25 17:10:36 -040027}
28
29function _send_email($to, $subject, $content) {
Edouard Poitras1a516b62014-12-11 15:31:01 -050030 mail($to, $subject, $content, HEADERS);
31 $EventLog = new EvtLog();
32 $EventLog->setLogTable("__paypal.class"); // To make browsing the log table easier
33 $EventLog->setPK1($to);
34 $EventLog->setPK2($_SERVER['REMOTE_ADDR']);
35 $EventLog->setLogAction("DONATION_EMAIL_SENT");
36 $EventLog->insertModLog($to);
Edouard Poitras6d106062014-08-25 17:10:36 -040037}
38
39function get_email_content($data) {
40 if ($data['amount'] >= 250) {
Edouard Poitras5d4f38b2014-12-23 12:17:32 -050041 $data['tshirt_link'] = get_tshirt_link($data['uid'], $data['transaction_id']);
Edouard Poitras1db7e9c2014-10-06 10:15:42 -040042 return _get_webmaster_idol_email($data);
Edouard Poitras6d106062014-08-25 17:10:36 -040043 } else if ($data['amount'] >= 100) {
Edouard Poitras5d4f38b2014-12-23 12:17:32 -050044 $data['tshirt_link'] = get_tshirt_link($data['uid'], $data['transaction_id']);
Edouard Poitras6d106062014-08-25 17:10:36 -040045 return _get_best_friend_email($data);
46 } else if ($data['amount'] >= 35) {
47 return _get_friend_email($data);
48 } else {
49 return _get_email($data);
50 }
51}
52
53function _get_email($data) {
54 $email = "Dear " . $data['firstname'] . ",\n\n";
55 $email .= "Thank you for your donation.\n\n";
56 $email .= "Regards,\nThe Eclipse Foundation";
57 return $email;
58}
59
60function _get_friend_email($data) {
Edouard Poitras4b0c0a52014-12-19 13:00:31 -050061 $email = "Dear " . $data['firstname'] . ",\n\n";
62 $email .= "Thank you for your donation. We are happy to welcome you as a Friend of Eclipse.\n\n";
63 $email .= "In recognition of your donation, we are pleased to provide the following Friend of Eclipse benefits:\n\n";
64 $email .= "\t-\tYou may use the Friend of Eclipse logo. It can be found here: " . FOE_LOGO_LINK . "\n";
Edouard Poitras72a9a7c2015-01-07 16:43:19 -050065 $email .= "\t-\tYou get access to the Mirror Site while downloading Eclipse when logged in.\n";
Edouard Poitras4b0c0a52014-12-19 13:00:31 -050066 $email .= "\t-\tYou get 40% off prints & 50% off ebooks at http://oreilly.com using the discount code: " . OREILLY_CODE . "\n\n";
67 $email .= "The Eclipse Foundation relies upon our users' generosity to make Eclipse a great place for open source software development. On behalf of the entire community, thank you for making it possible.\n\n";
68 $email .= "Best Regards,\n\nMike Milinkovich\nExecutive Director\nEclipse Foundation\n\n";
69 $email .= "http://www.eclipse.org/donate/\nfriends@eclipse.org\n\n";
70 $email .= "P.S. We have a Corporate Sponsor program for companies that want to support the Eclipse community. Please encourage your employer to contribute to the success of open source software at Eclipse.\nhttp://www.eclipse.org/corporate_sponsors/";
Edouard Poitras6d106062014-08-25 17:10:36 -040071 return $email;
72}
73
74function _get_best_friend_email($data) {
Edouard Poitras4b0c0a52014-12-19 13:00:31 -050075 $email = "Dear " . $data['firstname'] . ",\n\n";
76 $email .= "Thank you for your generous donation. We are happy to welcome you as a Best Friend of Eclipse.\n\n";
77 $email .= "In recognition of your donation, we are pleased to provide the following Best Friend of Eclipse benefits:\n\n";
78 $email .= "\t-\tYou may use the Friend of Eclipse logo. It can be found here: " . FOE_LOGO_LINK . "\n";
Edouard Poitras72a9a7c2015-01-07 16:43:19 -050079 $email .= "\t-\tYou get access to the Mirror Site while downloading Eclipse when logged in.\n";
Edouard Poitras4b0c0a52014-12-19 13:00:31 -050080 $email .= "\t-\tYou get 40% off prints & 50% off ebooks at http://oreilly.com using the discount code: " . OREILLY_CODE . "\n";
81 $email .= "\t-\tYou qualify for a Best Friend discount to attend an EclipseCon conference. The amount depends on the event but use the discount code: " . ECLIPSECON_CODE . "\n";
82 $email .= "\t-\tYou get an Eclipse T-Shirt! Claim it here: " . $data['tshirt_link'] . "\n\n";
83 $email .= "The Eclipse Foundation relies upon our users' generosity to make Eclipse a great place for open source software development. On behalf of the entire community, thank you for making it possible.\n\n";
84 $email .= "Best Regards,\n\nMike Milinkovich\nExecutive Director\nEclipse Foundation\n\n";
85 $email .= "http://www.eclipse.org/donate/\nfriends@eclipse.org\n\n";
86 $email .= "P.S. We have a Corporate Sponsor program for companies that want to support the Eclipse community. Please encourage your employer to contribute to the success of open source software at Eclipse.\nhttp://www.eclipse.org/corporate_sponsors/";
Edouard Poitras6d106062014-08-25 17:10:36 -040087 return $email;
88}
89
Edouard Poitras1db7e9c2014-10-06 10:15:42 -040090function _get_webmaster_idol_email($data) {
Edouard Poitras4b0c0a52014-12-19 13:00:31 -050091 $email = "Dear " . $data['firstname'] . ",\n\n";
92 $email .= "Thank you for your generous donation. We are happy to welcome you as a Best Friend of Eclipse.\n\n";
93 $email .= "In recognition of your donation, we are pleased to provide the following Best Friend of Eclipse benefits:\n\n";
94 $email .= "\t-\tYou may use the Friend of Eclipse logo. It can be found here: " . FOE_LOGO_LINK . "\n";
Edouard Poitras72a9a7c2015-01-07 16:43:19 -050095 $email .= "\t-\tYou get access to the Mirror Site while downloading Eclipse when logged in.\n";
Edouard Poitras4b0c0a52014-12-19 13:00:31 -050096 $email .= "\t-\tYou get 40% off prints & 50% off ebooks at http://oreilly.com using the discount code: " . OREILLY_CODE . "\n";
97 $email .= "\t-\tYou qualify for a Best Friend discount to attend an EclipseCon conference. The amount depends on the event but use the discount code: " . ECLIPSECON_CODE . "\n";
98 $email .= "\t-\tYou get an Eclipse T-Shirt! Claim it here: " . $data['tshirt_link'] . "\n\n";
99 $email .= "The Eclipse Foundation relies upon our users' generosity to make Eclipse a great place for open source software development. On behalf of the entire community, thank you for making it possible.\n\n";
100 $email .= "Best Regards,\n\nMike Milinkovich\nExecutive Director\nEclipse Foundation\n\n";
101 $email .= "http://www.eclipse.org/donate/\nfriends@eclipse.org\n\n";
102 $email .= "P.S. We have a Corporate Sponsor program for companies that want to support the Eclipse community. Please encourage your employer to contribute to the success of open source software at Eclipse.\nhttp://www.eclipse.org/corporate_sponsors/";
Edouard Poitras6d106062014-08-25 17:10:36 -0400103 return $email;
104}