public static function run($rideId = null) { info('ShowInterestNotifier: started'); if ($rideId === null) { $statuses = array(STATUS_LOOKING, STATUS_OFFERED, STATUS_SHARING); foreach ($statuses as $status) { foreach (array_keys(RegionManager::getInstance()->getRegions()) as $region) { $potentialRides = self::findPotentialRides($status, $region); $ridesToNotify = self::findRidesToNotify($status, $region); $results = self::searchForMatchingRides($potentialRides, $ridesToNotify); foreach ($results as $contactId => $potentialResults) { self::notify($contactId, $potentialRides, $potentialResults); } } } } else { $newRide = array(0 => DatabaseHelper::getInstance()->getRideById($rideId)); $newRideStatus = $newRide[0]['Status']; $region = $newRide[0]['Region']; $ridesToNotify = self::findRidesToNotify(self::getOppositeStatus($newRideStatus), $region); $results = self::searchForMatchingRides($newRide, $ridesToNotify); foreach ($results as $contactId => $potentialResults) { self::notify($contactId, $newRide, $potentialResults); } } DatabaseHelper::getInstance()->updateLastShowInterestNotifier(time()); info('ShowInterestNotifier: done'); }
</dl> </fieldset> </form> <form id="regionSelectorForm"> <dl> <?php if (RegionManager::getInstance()->isMultiRegion()) { ?> <dd> <label for="regionSelector"><?php echo _('Region'); ?> </label> <select id="regionSelector" name="regionSelector"> <?php foreach (RegionManager::getInstance()->getRegions() as $regionId => $region) { ?> <option value="<?php echo $regionId; ?> " <?php echo $regionId == $currentRegion ? 'selected="selected"' : ''; ?> ><?php echo _($region['Abbrev']); ?> </option> <?php } ?>
throw new Exception("Could not insert city {$destCity}"); } } if ($srcCityId == LOCATION_NOT_FOUND) { // Now need make sure that we didn't already insert this city if ($srcCity !== $destCity) { $srcCityId = $db->addCity($srcCity, $region); if (!$srcCityId) { throw new Exception("Could not insert city {$destCity}"); } } else { $srcCityId = $destCityId; } } // Update the region if (!RegionManager::getInstance()->setRegion($region)) { throw new Exception("Failed to update region"); } try { if ($isUpdateContact) { $updateParams = array('name' => $name, 'phone' => $phone); // In some scenarios, contact might exist before having a ride - // we need to set their role now $currentRole = AuthHandler::getRole(); if ($currentRole == ROLE_IDENTIFIED) { $updateParams['role'] = ROLE_IDENTIFIED_REGISTERED; AuthHandler::setRole(ROLE_IDENTIFIED_REGISTERED); } $updateParams['email'] = $canUpdateEmail ? $email : null; $db->updateContact($updateParams, $contactId); } else {
<?php include "../env.php"; include APP_PATH . "/Bootstrap.php"; if (ENV !== ENV_DEVELOPMENT && (!Utils::IsXhrRequest() || !AuthHandler::isSessionExisting())) { die; } extract($_GET, EXTR_SKIP); if (!isset($regionId)) { die; } try { $regionConfiguration = RegionManager::getInstance()->getRegionConfiguration($regionId); $cities = DatabaseHelper::getInstance()->getCities($regionId); if ($regionConfiguration !== false) { $res = array('status' => 'ok', 'results' => array('regionConfiguration' => $regionConfiguration, 'cities' => $cities)); } else { warn("Could not find configuration for region {$regionId}"); $res = array('status' => 'err', 'msg' => _("Region not found")); } } catch (Exception $e) { logException($e); $res = array('status' => 'err', 'msg' => _("Internal Error")); } echo json_encode($res);
<?php include "../env.php"; include APP_PATH . "/Bootstrap.php"; if (ENV !== ENV_DEVELOPMENT && (!Utils::IsXhrRequest() || !AuthHandler::isSessionExisting())) { die; } extract($_GET, EXTR_SKIP); $region = RegionManager::getInstance()->getCurrentRegionId(); $params = array('region' => $region); if (isset($srcCityId) && !empty($srcCityId) && !($srcCityId == LOCATION_DONT_CARE)) { info("SrcCityId {$srcCityId}"); $params['srcCityId'] = $srcCityId; } if (isset($destCityId) && !empty($destCityId) && !($destCityId == LOCATION_DONT_CARE)) { $params['destCityId'] = $destCityId; } if (isset($wantTo) && !empty($wantTo)) { $params['status'] = array($wantTo, STATUS_SHARING); } else { // We need to avoid displaying of inactive rides $params['status'] = array(STATUS_LOOKING, STATUS_OFFERED, STATUS_SHARING); } $server = DatabaseHelper::getInstance(); $rides = $server->searchRides($params); if ($rides !== false) { $res = array('status' => 'ok', 'results' => $rides); } else { $res = array('status' => 'err'); } echo json_encode($res);