function displayDonationMenuModule() { $menuItemInfo = $GLOBALS['menu_item_info']; if ($menuItemInfo['itemtype'] != "donation") { return false; } global $mysqli; if (!class_exists("DonationCampaign")) { include BASE_DIRECTORY . "plugins/donations/classes/campaign.php"; } $campaignObj = new DonationCampaign($mysqli); $donationObj = new btPlugin($mysqli); if ($campaignObj->select($menuItemInfo['itemtype_id']) && $donationObj->selectByName("Donations")) { $progressBarColor = $donationObj->getConfigInfo("goalprogresscolor"); $progressBarBackColor = $donationObj->getConfigInfo("goalprogressbackcolor"); $campaignInfo = $campaignObj->get_info_filtered(); $campaignDesc = $campaignObj->get_info("description"); $dispCampaignDesc = substr($campaignDesc, 0, 100); $dispCampaignDesc = $campaignDesc != $dispCampaignDesc ? $dispCampaignDesc . "..." : $dispCampaignDesc; $dispCampaignDesc = nl2br(parseBBCode(filterText($dispCampaignDesc))); $daysLeft = ""; if ($campaignInfo['dateend'] != 0 || $campaignInfo['dateend'] == 0 && $campaignInfo['currentperiod'] != 0) { $daysLeft = $campaignObj->getDaysLeft(); } $dispGoal = ""; if ($campaignInfo['goalamount'] > 0) { // Graph $goalCompletePercent = round($campaignObj->getTotalDonationAmount() / $campaignInfo['goalamount'] * 100); $goalCompletePercent = $goalCompletePercent > 100 ? "100%" : $goalCompletePercent . "%"; $dispGoal = " of " . $campaignObj->formatAmount($campaignInfo['goalamount'], 2) . " goal"; $dispProgressBar = "\n\t\t\t\t\t<div class='donationProgressContainer' style='background-color: " . $progressBarBackColor . "'>\n\t\t\t\t\t\t<div style='width: " . $goalCompletePercent . "; background-color: " . $progressBarColor . "'></div>\n\t\t\t\t\t</div>\n\t\t\t\t"; } $donationsInfo = $campaignObj->getDonationInfo(); $totalDonations = count($donationsInfo); $donationsFormatted = $campaignObj->formatAmount($campaignObj->getTotalDonationAmount()); $currentEndDate = $campaignObj->getCurrentEndDate(); $dispEndingDate = ""; if ($currentEndDate != 0) { $dispExclaimation = $daysLeft < 3 ? "!" : ""; $dispEndingDate = "<div class='donateMenuItemStat'><b>" . $campaignObj->getFormattedEndDate() . " left" . $dispExclaimation . "</b></div>"; } echo "\n\t\t\t\n\t\t\t\t<div class='donateMenuItemContainer'>\n\t\t\t\t\t<div class='donateMenuItemTitle'><a href='" . $campaignObj->getLink() . "'>" . $campaignInfo['title'] . "</a></div>\n\t\t\t\t\t<div class='donateMenuItemDesc main'>\n\t\t\t\t\t\t" . $dispCampaignDesc . "\t\t\t\t\t\n\t\t\t\t\t</div>\n\t\t\t\t\t<p align='center'>\n\t\t\t\t\t\t<a href='" . $campaignObj->getLink() . "'><input type='button' value='Donate!' class='submitButton'></a>\n\t\t\t\t\t</p>\n\t\t\t\t\t<div class='donateMenuItemStatsDiv main'>" . $dispProgressBar . "\n\t\t\t\t\t\t<div class='donateMenuItemStat'><b>" . $donationsFormatted . "</b><br>raised" . $dispGoal . "</div>\n\t\t\t\t\t\t" . $dispEndingDate . "\n\t\t\t\t\t\t<div style='clear: both'></div>\n\t\t\t\t\t</div>\n\t\t\t"; if (count($donationsInfo) > 0) { echo "<p class='donateMenuItemTitle'><b>Latest Donators:</b></p>"; $campaignObj->showDonatorList(false, 2); } echo "\n\t\t\t\t</div>\n\t\t\t\n\t\t\t"; } }
<?php include "../../_setup.php"; include "classes/donate-paypalclass.php"; include "classes/donation.php"; include "classes/campaign.php"; $donationPlugin = new btPlugin($mysqli); if ($donationPlugin->selectByName("Donations")) { $donationObj = new Donation($mysqli); $p = new paypal_class(); $arrColumns = array("donationcampaign_id", "member_id", "name", "message", "datesent", "amount", "paypalemail", "transaction_id", "response"); $p->setMode($donationPlugin->getConfigInfo("mode")); if ($p->validate_ipn() && $p->ipn_data['payment_status'] != "Failed" && $p->ipn_data['payment_status'] != "Denied") { $member = new Member($mysqli); $campaignObj = new DonationCampaign($mysqli); $arrData = $p->ipn_data; $data = json_encode($arrData); $customVars = json_decode($arrData['custom'], true); if ($campaignObj->select($customVars['campaign_id']) && $member->select($customVars['member_id'])) { $campaignName = $campaignObj->get_info_filtered("title"); $medalID = $campaignObj->get_info("awardmedal"); $member->awardMedal($medalID, "Donated to " . $campaignName . " campaign"); } $arrValues = array($customVars['campaign_id'], $customVars['member_id'], $customVars['name'], $customVars['message'], time(), $arrData['mc_gross'], $arrData['payer_email'], $arrData['txn_id'], $data); $donationObj->addNew($arrColumns, $arrValues); } else { $data = json_encode($p->ipn_data); $data = "ERROR: - " . $p->last_error . " - " . $data; $donationObj->logError($data); } }
$hooksObj->addHook("breadcrumb", "setThankYouPageBreadcrumb"); break; default: if (isset($_GET['custom']) && isset($_GET['payment_status'])) { $customVars = json_decode($_GET['custom'], true); header("Location: " . FULL_SITE_URL . "plugins/donations/?campaign_id=" . $customVars['campaign_id'] . "&p=thankyou"); } else { $webInfoObj->setPage("plugins/donations/include/main.php"); } } $campaignObj = new DonationCampaign($mysqli); $donationPlugin = new btPlugin($mysqli); if (!$donationPlugin->selectByName("Donations") || !$campaignObj->select($_GET['campaign_id'])) { echo "<script type='text/javascript'>window.location = '" . $MAIN_ROOT . "';</script>"; exit; } elseif ($donationPlugin->selectByName("Donations") && $donationPlugin->getConfigInfo("email") == "") { echo "\n\t\t<script type='text/javascript'>\n\t\t\talert('Please complete the plugin configuration before continuing!');\n\t\t\twindow.location = '" . $MAIN_ROOT . "';\n\t\t</script>\n\t"; exit; } $campaignObj->updateCurrentPeriod(); $campaignInfo = $campaignObj->get_info_filtered(); // Start Page $PAGE_NAME = $campaignInfo['title'] . " - "; include $prevFolder . "themes/" . $THEME . "/_header.php"; $member = new Member($mysqli); $breadcrumbObj->setTitle($campaignInfo['title']); $breadcrumbObj->addCrumb("Home", $MAIN_ROOT); $breadcrumbObj->addCrumb("Donation Campaign: " . $campaignInfo['title']); include $prevFolder . "include/breadcrumb.php"; $webInfoObj->displayPage(); include $prevFolder . "themes/" . $THEME . "/_footer.php";