public static function validateContactForm(array $data = array())
 {
     $data = self::initContactForm($data);
     $res = \Tbmt\Validator::getErrors($data, self::$CONTACT_FORM_FILTERS);
     if ($res !== false) {
         return [false, $res];
     }
     return [true, $data];
 }
Example #2
0
 public static function validatePasswordResetForm(array $data = array())
 {
     $data = self::initPasswordResetForm($data);
     $res = \Tbmt\Validator::getErrors($data, self::$PASSWORD_RESET_FORM_FILTERS);
     if ($res !== false) {
         return [false, $res, null];
     }
     $recipient = \MemberQuery::create()->filterByDeletionDate(null, \Criteria::ISNULL)->findOneByNum($data['num']);
     if ($recipient == null) {
         return [false, ['num' => \Tbmt\Localizer::get('error.member_num')], null];
     }
     return [true, $data, $recipient];
 }
Example #3
0
 public static function validateBonusTransactionForm(array $data = array())
 {
     $data = self::initBonusTransactionForm($data);
     $res = \Tbmt\Validator::getErrors($data, self::$BONUS_TRANSACTION_FORM_FILTERS);
     if ($res !== false) {
         return [false, $res, null];
     }
     $recipient = \MemberQuery::create()->filterByDeletionDate(null, Criteria::ISNULL)->findOneByNum($data['recipient_num']);
     if ($recipient == null) {
         return [false, ['recipient_num' => \Tbmt\Localizer::get('error.member_num')], null];
     }
     if (!$recipient->hadPaid()) {
         return [false, ['recipient_num' => \Tbmt\Localizer::get('error.member_num_unpaid')], null];
     }
     return [true, $data, $recipient];
 }
Example #4
0
 public function validateSignupForm(array $data = array())
 {
     $data['referral_member_num'] = Session::hasValidToken();
     $data = $this->initSignupForm($data);
     if ($data['password'] !== $data['password2']) {
         return [false, ['password' => \Tbmt\Localizer::get('error.password_unequal')], null, null];
     }
     $res = \Tbmt\Validator::getErrors($data, $this->SIGNUP_FORM_FILTERS);
     if ($res !== false) {
         return [false, $res, null, null];
     }
     // Validate member number exists
     $parentMember = \MemberQuery::create()->filterByDeletionDate(null, \Criteria::ISNULL)->filterByType(\Member::TYPE_SYSTEM, \Criteria::NOT_EQUAL)->findOneByHash($data['referral_member_num'])->findOneByIsExtended(1);
     if ($parentMember == null || $parentMember->getNum() == 0) {
         return [false, ['referral_member_num' => \Tbmt\Localizer::get('error.referral_member_num')], null, null];
     }
     // else if ( $parentMember->hadPaid() ) {
     //   return [false, ['referral_member_num' => \Tbmt\Localizer::get('error.referrer_paiment_outstanding')], null];
     // }
     $invitation = null;
     if ($data['invitation_code'] !== '') {
         $invitation = \InvitationQuery::create()->findOneByHash($data['invitation_code']);
         if ($parentMember == null) {
             return [false, ['invitation_code' => \Tbmt\Localizer::get('error.invitation_code_inexisting')], null, null];
         }
         if ($invitation->getMemberId() != $parentMember->getId()) {
             return [false, ['invitation_code' => \Tbmt\Localizer::get('error.invitation_code_invalid')], null, null];
         }
         if ($invitation->getAcceptedMemberId()) {
             return [false, ['invitation_code' => \Tbmt\Localizer::get('error.invitation_code_used')], null, null];
         }
     }
     if (!isset($data['email'])) {
         $data['email'] = '';
     }
     return [true, $data, $parentMember, $invitation];
 }