public function testLevelApplyingWithFreeRegistration() { $sylvheim = Member::getByNum(\SystemStats::ACCOUNT_SYLVHEIM); $sylvheim_total = new TransactionTotalsAssertions($sylvheim, $this); /* Setup - This member is set as paid but no money is spread. * Because this one is just for testing purpose ---------------------------------------------*/ $marketingLeader = DbEntityHelper::createMember($sylvheim, ['Type' => Member::TYPE_MARKETINGLEADER]); $marketingLeader->reload(self::$propelCon); $marketingLeader_total = new TransactionTotalsAssertions($marketingLeader, $this); /* Create invitation ---------------------------------------------*/ $invitation = Invitation::create($marketingLeader, ['type' => Member::TYPE_ORGLEADER, 'free_signup' => 1], self::$propelCon); /* Create member with created invitation code ---------------------------------------------*/ list($valid, $data, $referralMember, $invitation) = \Member::validateSignupForm(array_merge(self::$singupFormData, ['referral_member_num' => $marketingLeader->getNum(), 'invitation_code' => $invitation->getHash()])); // Because the marketing leader is level 1 this org leader will be // transfered to be child of sylvheim $orgLeader = \Member::createFromSignup($data, $marketingLeader, $invitation, self::$propelCon); $orgLeader->reload(self::$propelCon); // Because orgleaders parent has to be sylvhelm, advertising someone first time // needs to bonus sylvheim DbEntityHelper::createSignupMember($orgLeader); // Spread money for creating this last member $sylvheim_total->add(Transaction::REASON_SYLVHEIM, 1); $sylvheim_total->add(Transaction::REASON_ADVERTISED_INDIRECT, 1); // VL_BONUS - because, orgleader was VL first member and got transferred to // sylvheimm, therefore there is no VL between sylvheim and ol when ol // inviteds member $sylvheim_total->add(Transaction::REASON_VL_BONUS, 1); // marketing leader gets nothing from ol's advertising. $sylvheim_total->assertTotals(); $marketingLeader_total->assertTotals(); }
public function action_signup_submit() { $formErrors = []; list($valid, $data, $referralMember, $invitation) = \Member::validateSignupForm($_REQUEST); if ($valid !== true) { return ControllerDispatcher::renderModuleView(self::MODULE_NAME, 'signup', ['formErrors' => $data]); } $con = $con = \Propel::getConnection(); $member = \Member::createFromSignup($data, $referralMember, $invitation, $con); $member->reload(false, $con); Session::setLogin($member); return new ControllerActionRedirect(Router::toModule('account')); }
public static function createMemberWithInvitation($referrer, $invitationData, $data = []) { if (is_numeric($invitationData)) { $invitationData = ['type' => $invitationData]; } $data = array_merge(self::$memberInvitation, $data); /* Create invitation ---------------------------------------------*/ $invitation = Invitation::create($referrer, $invitationData, self::$con); /* Create member with created invitation code ---------------------------------------------*/ list($valid, $data, $referralMember, $invitation) = \Member::validateSignupForm(array_merge($data, ['referral_member_num' => $referrer->getNum(), 'invitation_code' => $invitation->getHash()])); $member = \Member::createFromSignup($data, $referrer, $invitation, self::$con); $member->reload(self::$con); if (!isset($invitationData['free_signup']) || !$invitationData['free_signup']) { $member->onReceivedMemberFee(self::$currency, time(), false, self::$con); } return $member; }
public function action_confirm_email_registration() { $valid = false; if (empty($_REQUEST['hash'])) { throw new PageNotFoundException(); } $emailValidation = \EmailValidation::validateHash($_REQUEST['hash']); if (!$emailValidation) { throw new InvalidDataException('Sorry the provided registration hash is invalid!'); } list($valid, $data, $referralMember, $invitation) = \Member::validateSignupForm(json_decode($emailValidation->getMeta(), true)); if ($valid !== true) { throw new \Exception('Doh, something is wrong with the registration data!'); } $con = \Propel::getConnection(); $member = \Activity::exec(['\\Member', 'activity_createFromSignup'], [$data, $referralMember, $invitation, $con], \Activity::ACT_MEMBER_SIGNUP, null, $referralMember, $con); $member->reload(false, $con); Session::setLogin($member); Session::set(Session::KEY_SIGNUP_MSG, true); return new ControllerActionRedirect(Router::toModule('account')); }
public function testInvitationCanFreeFromFee() { // NOTE: This tests what happen if one of my third+ advertisings gets // deleted due to not paiing fee. /* Setup ---------------------------------------------*/ DbEntityHelper::setCon(self::$propelCon); $marketingLeader = DbEntityHelper::createMember(null, ['type' => Member::TYPE_MARKETINGLEADER]); $marketingLeader->reload(self::$propelCon); /* Create invitation ---------------------------------------------*/ $invitation = Invitation::create($marketingLeader, ['type' => Member::TYPE_ORGLEADER, 'free_signup' => 1], self::$propelCon); /* Create member with created invitation code ---------------------------------------------*/ list($valid, $data, $referralMember, $invitation) = \Member::validateSignupForm(array_merge(self::$singupFormData, ['referral_member_num' => $marketingLeader->getNum(), 'invitation_code' => $invitation->getHash()])); $member = \Member::createFromSignup($data, $marketingLeader, $invitation, self::$propelCon); $member->reload(self::$propelCon); /* Assert proper member type ---------------------------------------------*/ $this->assertEquals(Member::TYPE_ORGLEADER, $member->getType()); $this->assertNotNull($member->getPaidDate()); }
public function testSubPromoterBonusSpreading() { // Deprecated $this->assertTrue(true); return; /** * PM * 1$ * * VL - S_PM - Neues Mitglied * 1$ - 1$ - 5$ * ------------------------------------------*/ /* Setup ---------------------------------------------*/ DbEntityHelper::setCon(self::$propelCon); $marketingLeader = DbEntityHelper::createMember(null, ['Type' => Member::TYPE_MARKETINGLEADER, 'FundsLevel' => Member::FUNDS_LEVEL2]); $marketingLeader->reload(self::$propelCon); $mLeaderTransfer = new TransactionTotalsAssertions($marketingLeader, $this); $promoter = DbEntityHelper::createSignupMember($marketingLeader); $mLeaderTransfer->add(Transaction::REASON_ADVERTISED_LVL2); $mLeaderTransfer->add(Transaction::REASON_VL_BONUS); $mLeaderTransfer->add(Transaction::REASON_OL_BONUS); $mLeaderTransfer->add(Transaction::REASON_PM_BONUS); /* Create invitation ---------------------------------------------*/ $invitation = Invitation::create($marketingLeader, ['type' => Member::TYPE_SUB_PROMOTER, 'free_signup' => 1, 'promoter_num' => $promoter->getNum(), 'promoter_id' => $promoter->getId()], self::$propelCon); /* Create member with created invitation code ---------------------------------------------*/ list($valid, $data, $referralMember, $invitation) = \Member::validateSignupForm(array_merge(self::$singupFormData, ['referral_member_num' => $marketingLeader->getNum(), 'invitation_code' => $invitation->getHash()])); $subPromoter = \Member::createFromSignup($data, $marketingLeader, $invitation, self::$propelCon); $subPromoter->reload(self::$propelCon); /* Sub promoter recruits anyone ---------------------------------------------*/ DbEntityHelper::createSignupMember($subPromoter); $subPromoterTransfer = new TransactionTotalsAssertions($subPromoter, $this); $promoterTransfer = new TransactionTotalsAssertions($promoter, $this); $mLeaderTransfer->add(Transaction::REASON_VL_BONUS); $mLeaderTransfer->add(Transaction::REASON_ADVERTISED_INDIRECT); $promoterTransfer->add(Transaction::REASON_SUB_PM_REF_BONUS); $subPromoterTransfer->add(Transaction::REASON_SUB_PM_BONUS); $subPromoterTransfer->add(Transaction::REASON_ADVERTISED_LVL1); $mLeaderTransfer->assertTotals(); $promoterTransfer->assertTotals(); $subPromoterTransfer->assertTotals(); }