Пример #1
0
         throw $e;
     }
     // 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 {