Пример #1
0
 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 {
         // If it is a new ride - register this contact
         $contactId = $db->addContact($name, $phone, $email, ROLE_IDENTIFIED_REGISTERED, $password);
         AuthHandler::authByContactId($contactId);
         AuthHandler::setRole(ROLE_IDENTIFIED_REGISTERED);
     }
 } catch (PDOException $e) {
     if ($e->getCode() == 23000) {
         $messages[] = _("This email address is already in use");
     }
     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");