Beispiel #1
0
 public function postReply($data, User $user, Borrower $borrower, Comment $parentComment)
 {
     $comment = new Comment();
     $comment->setUserId($user->getId());
     $comment->setMessage($data['message']);
     $comment->setBorrowerId($borrower->getId());
     $comment->setParentId($parentComment->getId());
     $comment->setLevel($parentComment->getLevel() + 1);
     $comment->setRootId($parentComment->getRootId());
     $comment->save();
     return $comment;
 }
Beispiel #2
0
 public function joinFacebookUser($facebookUser, $data)
 {
     $user = new User();
     $user->setUsername($data['username'])->setEmail($facebookUser['email'])->setFacebookId($facebookUser['id']);
     $lender = new Lender();
     $lender->setUser($user)->setFirstName($facebookUser['first_name'])->setLastName($facebookUser['last_name'])->setCountryId(1);
     $profile = new Profile();
     $profile->setAboutMe($data['aboutMe']);
     $lender->setProfile($profile);
     $lender->save();
     return $lender;
 }
 public function review(Borrower $borrower, User $user, $data)
 {
     $review = ReviewQuery::create()->filterByBorrower($borrower)->findOne();
     if (!$review) {
         $review = new Review();
         $review->setBorrower($borrower)->setCreatedBy($user->getId());
     } else {
         $review->setModifiedBy($user->getId());
     }
     $review->setIsAddressLocatable($data['isAddressLocatable'])->setIsAddressLocatableNote($data['isAddressLocatableNote']);
     PropelDB::transaction(function () use($review, $borrower) {
         $review->save();
         $borrower->setActivationStatus($review->isCompleted() ? Borrower::ACTIVATION_REVIEWED : Borrower::ACTIVATION_INCOMPLETE);
         $borrower->save();
     });
     return $review;
 }
Beispiel #4
0
 public function joinBorrower($data)
 {
     $volunteerMentor = VolunteerMentorQuery::create()->findOneByBorrowerId($data['volunteerMentorId']);
     $referrer = BorrowerQuery::create()->findOneById($data['referrerId']);
     $user = new User();
     $user->setUsername($data['username']);
     $user->setEmail($data['email']);
     $user->setFacebookId($data['facebookId']);
     $user->setRole('borrower');
     $borrower = new Borrower();
     $borrower->setFirstName($data['firstName']);
     $borrower->setLastName($data['lastName']);
     $borrower->setCountryId($data['countryId']);
     $borrower->setVolunteerMentor($volunteerMentor);
     $borrower->setReferrer($referrer);
     $borrower->setUser($user);
     $profile = new Profile();
     $profile->setAddress($data['address']);
     $profile->setAddressInstructions($data['addressInstructions']);
     $profile->setCity($data['city']);
     $profile->setNationalIdNumber($data['nationalIdNumber']);
     $profile->setPhoneNumber($data['phoneNumber']);
     $profile->setAlternatePhoneNumber($data['alternatePhoneNumber']);
     $borrower->setProfile($profile);
     $communityLeader = new Contact();
     $communityLeader->setType('communityLeader')->setFirstName($data['communityLeader']['firstName'])->setLastName($data['communityLeader']['lastName'])->setPhoneNumber($data['communityLeader']['phoneNumber'])->setDescription($data['communityLeader']['description']);
     $borrower->addContact($communityLeader);
     for ($i = 1; $i <= 3; $i++) {
         $familyMember = new Contact();
         $familyMember->setType('familyMember')->setFirstName($data['familyMember'][$i]['firstName'])->setLastName($data['familyMember'][$i]['lastName'])->setPhoneNumber($data['familyMember'][$i]['phoneNumber'])->setDescription($data['familyMember'][$i]['description']);
         $borrower->addContact($familyMember);
     }
     for ($i = 1; $i <= 3; $i++) {
         $neighbor = new Contact();
         $neighbor->setType('neighbor')->setFirstName($data['neighbor'][$i]['firstName'])->setLastName($data['neighbor'][$i]['lastName'])->setPhoneNumber($data['neighbor'][$i]['phoneNumber'])->setDescription($data['neighbor'][$i]['description']);
         $borrower->addContact($neighbor);
     }
     $borrower->save();
     $joinLog = new JoinLog();
     $joinLog->setIpAddress($data['ipAddress'])->setBorrower($borrower);
     $joinLog->save();
     $this->sendVerificationCode($borrower);
     $this->borrowerMailer->sendBorrowerJoinedConfirmationMail($borrower);
     if ($borrower->getVolunteerMentor()) {
         $this->borrowerMailer->sendBorrowerJoinedVolunteerMentorConfirmationMail($borrower);
     }
     foreach ($borrower->getContacts() as $contact) {
         $this->borrowerSmsService->sendBorrowerJoinedContactConfirmationSms($contact);
     }
     return $borrower;
 }
Beispiel #5
0
 public function sendLogoutEvent(User $user)
 {
     $data = array('$type' => '$logout', '$api_key' => $this->siftScienceKey, '$user_id' => $user->getId(), '$session_id' => $this->sessionId);
     $this->sendEvent($this->siftScienceUrl, json_encode($data));
 }