private function createTestAffiliateUser() {
        $affiliateUser = new Pap_Affiliates_User();
        $affiliateUser->setId('11111111');
        $affiliateUser->setDateInserted(Gpf_Common_DateUtils::now());
        $affiliateUser->setRefId("testaff");
        $affiliateUser->setPassword($this->account->getPassword());
        $affiliateUser->setUserName(Pap_Branding::DEMO_AFFILIATE_USERNAME);
        $affiliateUser->setFirstName("Test");
        $affiliateUser->setLastName("Affiliate");
        $affiliateUser->setAccountId($this->account->getId());
        $affiliateUser->setStatus(Gpf_Db_User::APPROVED);
        $affiliateUser->set('dateapproved', Gpf_Common_DateUtils::Now());
        $affiliateUser->save();

        $this->setQuickLaunchSettings($affiliateUser->getAccountUserId(), 'showDesktop');
        Gpf_Settings::set(Pap_Settings::DEFAULT_AFFILIATE_PANEL_THEME, Pap_Branding::DEFAULT_AFFILIATE_PANEL_THEME);
    }
Exemple #2
0
 /**
  * gets user by username
  * @param $username
  * @return Pap_Affiliates_User
  * @throws Gpf_Exception
  */
 public static function loadFromUsername($username)
 {
     $user = new Pap_Affiliates_User();
     $user->setUserName($username);
     $user->authUser->loadFromUsername();
     $user->accountUser->setAuthId($user->authUser->getId());
     $user->accountUser->loadFromData(array(Gpf_Db_Table_Users::AUTHID, Gpf_Db_Table_Users::ROLEID));
     $user->user->setAccountUserId($user->accountUser->getId());
     $user->user->loadFromData(array(Pap_Db_Table_Users::ACCOUNTUSERID, Pap_Db_Table_Users::TYPE));
     return $user;
 }
    private function insertUser($record) {
    	$user = new Pap_Affiliates_User();
    	$user->setId($record->get('userid'));
    	$user->setRefId(($record->get('refid') != '' ? $record->get('refid') : $record->get('userid')));
    	$user->setPassword($record->get('rpassword'));
    	$user->setUserName($record->get('username'));
    	$user->setFirstName($record->get('name'));
    	$user->setLastName($record->get('surname'));
    	$user->setAccountId(Pap3Compatibility_Migration_Pap3Constants::DEFAULT_ACCOUNT_ID);
    	$user->setDateInserted($record->get('dateinserted'));
    	if ($record->get('minimumpayout') != NULL) {
    		$user->setMinimumPayout($record->get('minimumpayout'));
    	} else {
    		$user->setMinimumPayout(Gpf_Settings::get(Pap_Settings::PAYOUTS_MINIMUM_PAYOUT_SETTING_NAME));
    	}
    	if($record->get('dateapproved') != null && $record->get('dateapproved') != '') {
    		$user->setDateApproved($record->get('dateapproved'));
    	}
    	if (Pap3Compatibility_Migration_Pap3Constants::translateStatus($record->get('rstatus')) == Pap_Common_Constants::STATUS_APPROVED && 
    	$user->getDateApproved() == null) {
    		$actualDate = new Gpf_DateTime();
    		$user->setDateApproved($actualDate->toDateTime());
    	}
    	$user->setStatus(Pap3Compatibility_Migration_Pap3Constants::translateStatus($record->get('rstatus')));
    	$user->setType('A');
        $user->set('numberuserid',1);
        
    	$this->setAffiliateField($user, $record, 'street');
    	$this->setAffiliateField($user, $record, 'city');
    	$this->setAffiliateField($user, $record, 'company_name');
    	$this->setAffiliateField($user, $record, 'state');
    	$this->setAffiliateField($user, $record, 'zipcode');
    	$this->setAffiliateField($user, $record, 'weburl');
    	$this->setAffiliateField($user, $record, 'phone');
    	$this->setAffiliateField($user, $record, 'fax');
    	$this->setAffiliateField($user, $record, 'tax_ssn');
    	$this->setAffiliateField($user, $record, 'country');
    	$this->setAffiliateField($user, $record, 'data1');
    	$this->setAffiliateField($user, $record, 'data2');
    	$this->setAffiliateField($user, $record, 'data3');
    	$this->setAffiliateField($user, $record, 'data4');
    	$this->setAffiliateField($user, $record, 'data5');

    	$user->setSendNotification(false);
    	$user->setPayoutOptionId($this->savePayoutData($record->get('userid')));
    	$user->save();
    	
    	// handle parent id
        $parentUserId = $record->get('parentuserid');
        if($parentUserId != '') {
            $updateBuilder = new Gpf_SqlBuilder_UpdateBuilder();
            $updateBuilder->from->add(Pap_Db_Table_Users::getName());
            $updateBuilder->set->add(Pap_Db_Table_Users::PARENTUSERID, $parentUserId);
            $updateBuilder->where->add(Pap_Db_Table_Users::ID, '=', $record->get('userid'));
            try {
                $updateBuilder->executeOne();
            } catch (Gpf_Exception $e) {
                Pap3Compatibility_Migration_OutputWriter::log("<br/>Error setting parentuserid: ".$e->getMessage());
            }
        }
        
    	
    	$this->countUsers++;
    }