Beispiel #1
0
    public function recodeAllValues($newKey, $newIv) {        
        $oldEncoder = $this->getEncoder();
        $newEncoder = new Pap_Features_PayoutFieldsEncryption_Encoder($newKey, $newIv);
        
        $userOptions = new Pap_Db_UserPayoutOption();

        foreach ($userOptions->loadCollection() as $userOption) {
            $cleanValue = $oldEncoder->decrypt($userOption->get(Pap_Db_Table_UserPayoutOptions::VALUE));
            $userOption->set(Pap_Db_Table_UserPayoutOptions::VALUE, $newEncoder->encrypt($cleanValue));
            $userOption->save();
        }
   }
	/**
	 * @return array<Pap_Db_UserPayoutOption>
	 */
	public function getValues($formName, $userId) {
		$select = new Gpf_SqlBuilder_SelectBuilder();
		
		$select->select->add('ff.'.Gpf_Db_Table_FormFields::ID, Gpf_Db_Table_FormFields::ID);
		$select->select->add('ff.'.Gpf_Db_Table_FormFields::CODE, Gpf_Db_Table_FormFields::CODE);
		$select->select->add('upo.'.self::VALUE, self::VALUE);
		$select->select->add('upo.'.self::USERID, self::USERID);
		
		$select->from->add(Gpf_Db_Table_FormFields::getName(), 'ff');
		$select->from->addInnerJoin(self::getName(), 'upo', 'upo.formfieldid=ff.formfieldid');
		
		$select->where->add('upo.'.self::USERID, '=', $userId);
		$select->where->add('ff.'.Gpf_Db_Table_FormFields::FORMID, '=', $formName);
		
		$values = array();
		foreach ($select->getAllRowsIterator() as $row) {
		    $payoutOption = new Pap_Db_UserPayoutOption();
		    $payoutOption->fillFromRecord($row);
		    $values[$row->get('code')] = $payoutOption;
		}
		return $values;
	}
    protected function savePayoutFields(Gpf_Rpc_Form $form) {
        $this->user = $this->createDbRowObject();
        $this->user->setPrimaryKeyValue($form->getFieldValue("Id"));
        try {
            $this->user->load();
        } catch (Gpf_DbEngine_NoRow $e) {
            throw new Exception($this->getDbRowObjectName().$this->_(" does not exist"));
        }

        $payoutOptionId = $form->getFieldValue(Pap_Db_Table_Users::PAYOUTOPTION_ID);
        $formFields = Gpf_Db_Table_FormFields::getInstance();
        $formName = self::PAYOUT_OPTION . $payoutOptionId;
        $payoutOptionFields = $formFields->getFieldsNoRpc($formName);

        foreach ($payoutOptionFields as $field) {
            $payoutOptionUserValue = new Pap_Db_UserPayoutOption();
            $payoutOptionUserValue->setUserId($this->user->getId());
            $payoutOptionUserValue->setFormFieldId($field->get("id"));
            $payoutOptionUserValue->setValue($form->getFieldValue($field->get("code")));
            $payoutOptionUserValue->save();
        }

        $form->setInfoMessage($this->_("Payout settings saved"));
        return $form;
    }
 private function savePayoutData($userID) {
 	$pap3PayoutSettings = $this->getPap3UserPayoutData($userID);
 	
 	try {
 		$payoutOptionId = $pap3PayoutSettings->getRecord('Aff_payout_type')->get('value');	
 	} catch (Gpf_Data_RecordSetNoRowException $e) {
 		return Gpf_DbEngine_Row::NULL;	
 	}
     
     $formFields = Gpf_Db_Table_FormFields::getInstance();
     $formName = Pap_Merchants_User_AffiliateForm::PAYOUT_OPTION . $payoutOptionId;
     $payoutOptionFields = $formFields->getFieldsNoRpc($formName);
     
     foreach ($payoutOptionFields as $field) {
         $payoutOptionUserValue = new Pap_Db_UserPayoutOption();
         $payoutOptionUserValue->setUserId($userID);
         $payoutOptionUserValue->setFormFieldId($field->get("id"));
         try {
         	$payoutOptionValue = $pap3PayoutSettings->getRecord('Aff_payoptionfield_' . 
         	   $this->getFieldCode($field->get("code"), $payoutOptionId))->get('value');
         } catch (Gpf_Exception $e) {
         	$payoutOptionValue = '';
         }
         $payoutOptionUserValue->setValue($payoutOptionValue);
         $payoutOptionUserValue->save();
     }
     
     return $payoutOptionId;
 }
    /**
     * @param array $payoutOptionData
     */
    private function processPayoutOption($payoutOptionData, $row) {
        $user = new Pap_Affiliates_User();
        $user->setId($payoutOptionData[Pap_Db_Table_UserPayoutOptions::USERID]);
        try {
            $user->load();

            $payoutOption = new Pap_Db_PayoutOption();
            $payoutOption->setID($user->getPayoutOptionId());
            $payoutOption->load();

            $payoutField = new Gpf_Db_FormField();
            $payoutField->setFormId($payoutOption->getFormId());
            $payoutField->setCode($payoutOptionData[Gpf_Db_Table_FormFields::CODE]);
            $payoutField->loadFromData(array(Gpf_Db_Table_FormFields::FORMID, Gpf_Db_Table_FormFields::CODE));

            $userPayoutOption = new Pap_Db_UserPayoutOption();
            $userPayoutOption->setUserId($payoutOptionData[Pap_Db_Table_UserPayoutOptions::USERID]);
            $userPayoutOption->setFormFieldId($payoutField->getId());
            $userPayoutOption->setValue($payoutOptionData[Pap_Db_Table_UserPayoutOptions::VALUE]);
            $userPayoutOption->save();
            $this->incrementSuccessfulCount();
            $this->logger->debug('Data from line: ' . $this->getFile()->getActualCSVLineNumber() . ' was inserted.');
        } catch (Gpf_Exception $e) {
        	$this->logError('Payout option', $row, $e);
        	$this->appendOutputMessage($this->getSaveErrorMessage($this->getFile()->getActualCSVLineNumber(), $e->getMessage()));
            $this->incrementWrongCount();
        }
    }
    protected function addRow(Gpf_Rpc_Form $form, Gpf_DbEngine_RowBase $row) {
        parent::addRow($form, $row);

        $payoutOptionId = $form->getFieldValue(Pap_Db_Table_Users::PAYOUTOPTION_ID);
        if ($payoutOptionId != null && $payoutOptionId != "") {
            $formFields = Gpf_Db_Table_FormFields::getInstance();
            $formName = self::PAYOUT_OPTION . $payoutOptionId;
            $payoutOptionFields = $formFields->getFieldsNoRpc($formName);

            foreach ($payoutOptionFields as $field) {
                try {
                    $payoutOptionUserValue = new Pap_Db_UserPayoutOption();
                    $payoutOptionUserValue->setUserId($row->getId());
                    $payoutOptionUserValue->setFormFieldId($field->get("id"));
                    $payoutOptionUserValue->setValue($form->getFieldValue($field->get("code")));
                    $payoutOptionUserValue->save();
                } catch (Exception $e) {
                }
            }
        }

        $attribute = new Gpf_Db_UserAttribute();
        $attribute->setName('quickLaunchSetting');
        $attribute->set(Gpf_Db_Table_UserAttributes::VALUE, 'showDesktop');
        $attribute->setAccountUserId($row->getAccountUserId());
        $attribute->save();

        self::setAffiliateLanguage($form, $row->getAccountUserId());
    }
	/**
	 * @param Gpf_Data_Row $row
	 */
	private function addPayoutData(Gpf_Data_Row $row) {
		$payoutData = '';
		foreach ($this->buildUserPayoutOptions($row)->getAllRows() as $payoutOptionRow) {
			if ($payoutData !== '') {
				$payoutData .= ', ';
			}
			$userPayoutOption = new Pap_Db_UserPayoutOption();
			$userPayoutOption->fillFromRecord($payoutOptionRow);
			$payoutData .= $this->_localize($payoutOptionRow->get("payoutFieldName")).": ".$userPayoutOption->getValue();
		}

		$row->add("payoutData", $payoutData);
	}