Edouard Poitras | 6d10606 | 2014-08-25 17:10:36 -0400 | [diff] [blame] | 1 | <?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 Poitras | 1a516b6 | 2014-12-11 15:31:01 -0500 | [diff] [blame] | 13 | require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/evt_log.class.php"); |
Edouard Poitras | 6d10606 | 2014-08-25 17:10:36 -0400 | [diff] [blame] | 14 | include_once "tshirt.php"; |
| 15 | |
| 16 | define('HEADERS', 'From: Eclipse Webmaster (automated) <webmaster@eclipse.org>' . "\n" . 'Content-Type: text/plain; charset=UTF-8'); |
| 17 | define('FOE_LOGO_LINK', 'https://dev.eclipse.org/site_login/myaccount.php'); |
Edouard Poitras | 72a9a7c | 2015-01-07 16:43:19 -0500 | [diff] [blame] | 18 | //define('MIRROR_SITE', 'https://friends.eclipse.org'); // Deprecated |
Edouard Poitras | 6d10606 | 2014-08-25 17:10:36 -0400 | [diff] [blame] | 19 | define('ECLIPSECON_CODE', 'FRIEND'); |
Edouard Poitras | 7d27b16 | 2015-04-02 16:00:04 -0400 | [diff] [blame] | 20 | define('OREILLY_CODE', 'PCBW'); |
Edouard Poitras | 6d10606 | 2014-08-25 17:10:36 -0400 | [diff] [blame] | 21 | |
| 22 | function send_email($data) { |
Edouard Poitras | 5d4f38b | 2014-12-23 12:17:32 -0500 | [diff] [blame] | 23 | if (!isset($data['firstname']) || $data['firstname'] == '') $data['firstname'] = $data['email']; |
Edouard Poitras | 6d10606 | 2014-08-25 17:10:36 -0400 | [diff] [blame] | 24 | $content = get_email_content($data); |
Edouard Poitras | 5d4f38b | 2014-12-23 12:17:32 -0500 | [diff] [blame] | 25 | $data['email'] = filter_var($data['email'], FILTER_SANITIZE_EMAIL); |
| 26 | _send_email($data['email'], "Thank You For Your Donation", $content); |
Edouard Poitras | 6d10606 | 2014-08-25 17:10:36 -0400 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | function _send_email($to, $subject, $content) { |
Edouard Poitras | 1a516b6 | 2014-12-11 15:31:01 -0500 | [diff] [blame] | 30 | 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 Poitras | 6d10606 | 2014-08-25 17:10:36 -0400 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | function get_email_content($data) { |
| 40 | if ($data['amount'] >= 250) { |
Edouard Poitras | 5d4f38b | 2014-12-23 12:17:32 -0500 | [diff] [blame] | 41 | $data['tshirt_link'] = get_tshirt_link($data['uid'], $data['transaction_id']); |
Edouard Poitras | 1db7e9c | 2014-10-06 10:15:42 -0400 | [diff] [blame] | 42 | return _get_webmaster_idol_email($data); |
Edouard Poitras | 6d10606 | 2014-08-25 17:10:36 -0400 | [diff] [blame] | 43 | } else if ($data['amount'] >= 100) { |
Edouard Poitras | 5d4f38b | 2014-12-23 12:17:32 -0500 | [diff] [blame] | 44 | $data['tshirt_link'] = get_tshirt_link($data['uid'], $data['transaction_id']); |
Edouard Poitras | 6d10606 | 2014-08-25 17:10:36 -0400 | [diff] [blame] | 45 | 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 | |
| 53 | function _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 | |
| 60 | function _get_friend_email($data) { |
Edouard Poitras | 4b0c0a5 | 2014-12-19 13:00:31 -0500 | [diff] [blame] | 61 | $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 Poitras | 72a9a7c | 2015-01-07 16:43:19 -0500 | [diff] [blame] | 65 | $email .= "\t-\tYou get access to the Mirror Site while downloading Eclipse when logged in.\n"; |
Edouard Poitras | 4b0c0a5 | 2014-12-19 13:00:31 -0500 | [diff] [blame] | 66 | $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 Poitras | 6d10606 | 2014-08-25 17:10:36 -0400 | [diff] [blame] | 71 | return $email; |
| 72 | } |
| 73 | |
| 74 | function _get_best_friend_email($data) { |
Edouard Poitras | 4b0c0a5 | 2014-12-19 13:00:31 -0500 | [diff] [blame] | 75 | $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 Poitras | 72a9a7c | 2015-01-07 16:43:19 -0500 | [diff] [blame] | 79 | $email .= "\t-\tYou get access to the Mirror Site while downloading Eclipse when logged in.\n"; |
Edouard Poitras | 4b0c0a5 | 2014-12-19 13:00:31 -0500 | [diff] [blame] | 80 | $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 Poitras | 6d10606 | 2014-08-25 17:10:36 -0400 | [diff] [blame] | 87 | return $email; |
| 88 | } |
| 89 | |
Edouard Poitras | 1db7e9c | 2014-10-06 10:15:42 -0400 | [diff] [blame] | 90 | function _get_webmaster_idol_email($data) { |
Edouard Poitras | 4b0c0a5 | 2014-12-19 13:00:31 -0500 | [diff] [blame] | 91 | $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 Poitras | 72a9a7c | 2015-01-07 16:43:19 -0500 | [diff] [blame] | 95 | $email .= "\t-\tYou get access to the Mirror Site while downloading Eclipse when logged in.\n"; |
Edouard Poitras | 4b0c0a5 | 2014-12-19 13:00:31 -0500 | [diff] [blame] | 96 | $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 Poitras | 6d10606 | 2014-08-25 17:10:36 -0400 | [diff] [blame] | 103 | return $email; |
| 104 | } |