protected function addField($code, $name, $type, $status, $order) { $formField = new Gpf_Db_FormField(); $formField->setFormId($this->formId); $formField->setCode($code); try { $formField->loadFromData(); } catch (Gpf_DbEngine_NoRowException $e) { $formField->setName($name); $formField->setType($type); $formField->setStatus($status); $formField->setAccountId($this->accountId); $formField->insert(); } }
private function migratePayoutOptionFields() { echo " Migrating payout option fields....."; $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->add('*'); $selectBuilder->from->add('wd_pa_payoutfields'); $result = $selectBuilder->getAllRows(); $count = 0; foreach($result as $record) { $obj = new Gpf_Db_FormField(); $obj->setAccountId(Pap3Compatibility_Migration_Pap3Constants::DEFAULT_ACCOUNT_ID); $obj->setFormId('payout_option_'.$record->get('payoptid')); $obj->setCode($record->get('code')); $obj->setName($record->get('name')); $obj->setType(($record->get('rtype') == 1 ? 'T' : 'L')); $obj->setStatus(($record->get('mandatory') == 1 ? 'M' : 'O')); $obj->save(); $count++; } echo " ($count) ..... DONE<br/>"; }
private function insertEmptySignupField() { $this->countSignupFields++; $obj = new Gpf_Db_FormField(); $obj->setAccountId(Pap3Compatibility_Migration_Pap3Constants::DEFAULT_ACCOUNT_ID); $obj->setFormId('affiliateForm'); $obj->setCode('data'.$this->countSignupFields); $obj->setName('Unused'); $obj->setType('T'); $obj->setStatus('D'); $obj->save(); }
private function processPreference($preference) { $type = (string) $preference['datatype']; if ($type == '' || $type == null) { $type = 'string'; } if ($type == 'hidden') { return; } $formField = new Gpf_Db_FormField(); $formField->setFormId($this->getPreferencesFormId()); $formField->setCode((string) $preference['name']); $displayName = (string) $preference['display_name']; if ($displayName == '') { $displayName = (string) $preference['name']; } $formField->setName($displayName); if ($preference['required'] == "true") { $formField->setStatus(Gpf_Db_FormField::STATUS_MANDATORY); } else { $formField->setStatus(Gpf_Db_FormField::STATUS_OPTIONAL); } switch ($type) { case 'string': $formField->setType(Gpf_Db_FormField::TYPE_TEXT); break; case 'bool': $formField->setType(Gpf_Db_FormField::TYPE_CHECKBOX); break; case 'enum': $formField->setType(Gpf_Db_FormField::TYPE_LISTBOX); $formField->clearAvailableValues(); foreach ($preference->EnumValue as $option) { $value = (string) $option['value']; $displayValue = (string) $option['display_value']; if ($displayValue == '') { $displayValue = $value; } $formField->addAvailableValue($value, $displayValue); } break; } $this->addPreferenceField($formField); }
private function addPayoutField($formId, $code, $name, $type, $status) { $payoutField = new Gpf_Db_FormField(); $payoutField->set('formid', $formId); $payoutField->set('code', $code); $payoutField->set('name', $name); $payoutField->set('rtype', $type); $payoutField->set('rstatus', $status); $payoutField->setAccountId($this->account->getId()); $payoutField->insert(); }
protected function addPreferenceField(Gpf_Db_FormField $formField) { $formField->setAccountId(Gpf_Session::getAuthUser()->getAccountId()); $this->preferenceFormFields[] = $formField; }
/** * @return Gpf_DbEngine_Row */ protected function createEmptyRow(Gpf_Rpc_Params $params) { $row = new Gpf_Db_FormField(); $row->set(Gpf_Db_Table_Accounts::ID, Gpf_Session::getAuthUser()->getAccountId()); $row->set(Gpf_Db_Table_FormFields::FORMID, $params->get('formid')); $row->set(Gpf_Db_Table_FormFields::CODE, "code"); $row->set(Gpf_Db_Table_FormFields::NAME, $this->_("New field")); $row->set(Gpf_Db_Table_FormFields::TYPE, Gpf_Db_FormField::TYPE_TEXT); $row->set(Gpf_Db_Table_FormFields::STATUS, Gpf_Db_FormField::STATUS_OPTIONAL); $row->set(Gpf_Db_Table_FormFields::SECTION, Gpf_Db_FormField::DEFAULT_SECTION); $i = 1; while ($i < 10) { try { $row->check(); break; } catch (Gpf_DbEngine_Row_CheckException $e) { $row->set(Gpf_Db_Table_FormFields::CODE, "code_".$i); $i++; } } return $row; }
/** * @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(); } }
/** * * @service gadget write * @param $fields * @return Gpf_Rpc_Form */ public function save(Gpf_Rpc_Params $params) { $form = new Gpf_Rpc_Form($params); $dbRow = $this->createDbRowObject(); $dbRow->setPrimaryKeyValue($this->getId($form)); try { $dbRow->load(); } catch (Gpf_DbEngine_NoRow $e) { $form->setErrorMessage($this->getDbRowObjectName() . $this->_(" does not exist")); return $form; } $dbRow->set(Gpf_Db_Table_Gadgets::NAME, $form->getFieldValue(self::FORM_GADGET_NAME)); if (!$this->checkBeforeSave($dbRow, $form, self::EDIT)) { return $form; } try { $dbRow->save(); $this->afterSave($dbRow, self::EDIT); } catch (Exception $e) { $form->setErrorMessage($e->getMessage()); return $form; } $form->setField(self::FORM_GADGET_NAME, $dbRow->get(Gpf_Db_Table_Gadgets::NAME)); $form->setInfoMessage($this->getDbRowObjectName() . $this->_(" saved")); $formField = new Gpf_Db_FormField(); $formField->setFormId($this->gadget->getPreferencesFormId()); foreach ($formField->loadCollection() as $field) { $code = $field->getCode(); $this->gadget->addProperty($code, $form->getFieldValue($code)); } return $form; }
private function processPreference($preference) { $type = (string) $preference['type']; if ($type == 'hidden') { return; } $formField = new Gpf_Db_FormField(); $formField->setFormId($this->getPreferencesFormId()); $formField->setName((string) $preference['label']); $formField->setCode((string) $preference['name']); $formField->setStatus(Gpf_Db_FormField::STATUS_OPTIONAL); switch ($type) { case 'password': $formField->setType(Gpf_Db_FormField::TYPE_PASSWORD); break; case 'text': $formField->setType(Gpf_Db_FormField::TYPE_TEXT); break; case 'boolean': $formField->setType(Gpf_Db_FormField::TYPE_CHECKBOX); break; case 'range': $formField->setType(Gpf_Db_FormField::TYPE_LISTBOX); $formField->clearAvailableValues(); for ($i = $preference['min']; $i <= $preference['max']; $i += $preference['step']) { $formField->addAvailableValue($i, $i); } break; case 'list': $formField->setType(Gpf_Db_FormField::TYPE_LISTBOX); $formField->clearAvailableValues(); foreach ($preference->option as $option) { $formField->addAvailableValue((string) $option['value'], (string) $option['label']); } break; } $this->addPreferenceField($formField); }
/** * @return Gpf_DbEngine_Row_Collection */ protected function getFormFields() { $field = new Gpf_Db_FormField(); $field->setAccountId(Gpf_Session::getAuthUser()->getAccountId()); $field->setFormId('affiliateForm'); return $field->loadCollection(); }