private static function notify($contactId, &$allRides, $potentialRideIds) { debug(__METHOD__ . "({$contactId}, " . json_encode($potentialRideIds) . ")"); $toNotify = array(); foreach ($allRides as $ride) { if (in_array($ride['Id'], $potentialRideIds)) { $toNotify[] = $ride; } } $contact = DatabaseHelper::getInstance()->getContactById($contactId); $mailBody = MailHelper::render(VIEWS_PATH . '/showInterestMail.php', array('rides' => $toNotify), $contact); Utils::sendMail(Utils::buildEmail($contact['Email']), $contact['Email'], getConfiguration('mail.addr'), getConfiguration('mail.display'), 'New rides from carpool', $mailBody); }
include "env.php"; include APP_PATH . "/Bootstrap.php"; $feedbackOptions = array(1 => _("Report a bug"), 2 => _("Ask a question"), 3 => _("Request a feature"), 4 => _("Contact"), 5 => _("Other")); // This is a post - form submitted if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (!AuthHandler::isSessionExisting()) { // Try to discard bots by dropping requests with no session die; } extract($_POST); if (!Utils::isEmptyString($feedback)) { $mailHelper = new MailHelper(); $wantToStr = isset($wantTo) && isset($feedbackOptions[$wantTo]) ? $feedbackOptions[$wantTo] : _("Other"); $params = array('wantTo' => $wantToStr, 'feedback' => $feedback, 'email' => $email); $body = $mailHelper->render('views/feedbackMail.php', $params); $to = getConfiguration('feedback.mail'); $toName = getConfiguration('feedback.to.name'); $from = getConfiguration('feedback.from'); $fromName = getConfiguration('feedback.from.name'); $replyTo = Utils::isEmptyString($email) ? null : Utils::buildEmail($email); Utils::sendMail($to, $toName, $from, 'Carpool feedback', 'New carpool feedback', $body, $replyTo, $replyTo); GlobalMessage::setGlobalMessage(_('Thanks for the feedback!')); } else { GlobalMessage::setGlobalMessage(_('Please write something.'), GlobalMessage::ERROR); } // Get after post Utils::redirect('feedback.php'); } else { AuthHandler::putUserToken(); ?>
<?php include '../tests/testenv.php'; /* ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Carpool</title> </head> <body> <?php */ //$rides = DatabaseHelper::getInstance()->searchRides(array()); //echo MailHelper::render(VIEWS_PATH . '/showInterestMail.php', array('rides' => $rides)); $contact = DatabaseHelper::getInstance()->getContactById(1); echo MailHelper::render(VIEWS_PATH . '/registrationMail.php', array('contact' => $contact));
} // Add or update ride $rideParams = array('SrcCityId' => $srcCityId, 'SrcLocation' => $srcLocation, 'DestCityId' => $destCityId, 'DestLocation' => $destLocation, 'TimeMorning' => $timeMorning, 'TimeEvening' => $timeEvening, 'Comment' => $comment, 'Notify' => $notify, 'Status' => $wantTo, 'Region' => $region); if ($isUpdateRide) { if ($db->updateRide($rideId, $srcCityId, $srcLocation, $destCityId, $destLocation, $timeMorning, $timeEvening, $comment, $wantTo, $notify, $region)) { GlobalMessage::setGlobalMessage(_("Ride successfully updated.")); } else { throw new Exception("Could not update ride"); } } else { $rideId = $db->addRide($srcCityId, $srcLocation, $destCityId, $destLocation, $timeMorning, $timeEvening, $contactId, $comment, $wantTo, $notify, $region); if (!$rideId) { throw new Exception("Could not add ride"); } AuthHandler::updateRegisteredRideStatus(true); $mailBody = MailHelper::render(VIEWS_PATH . '/registrationMail.php', array('contact' => $db->getContactById($contactId))); Utils::sendMail(Utils::buildEmail($email), $name, getConfiguration('mail.addr'), getConfiguration('mail.display'), getConfiguration('app.name') . ' Registration', $mailBody); } $db->commit(); // XXX: Should show interest even if it's update? if (!$isUpdateRide && getConfiguration('notify.immediate') == 1) { Service_ShowInterest::run($rideId); } echo json_encode(array('status' => 'ok', 'action' => $action)); } catch (PDOException $e) { $db->rollBack(); if ($e->getCode() == 23000) { // If this is a unique constraint problem - we want to display the correct message echo json_encode(array('status' => 'invalid', 'action' => $action, 'messages' => $messages)); } else { logException($e);