public function getDataFieldsFromUserDw(array $contact, XenForo_DataWriter_User $dw, $updatedOnly = false) { $xenOptions = XenForo_Application::get('options'); $formFieldOptions = $xenOptions->th_infusionsoftApi_formFields; $customFields = array(); if ($updatedOnly) { $customFields = $dw->getUpdatedCustomFields(); } elseif ($dw->get('custom_fields')) { $customFields = unserialize($dw->get('custom_fields')); } /* @var $dataFormFieldModel ThemeHouse_Infusionsoft_Model_InfusionsoftApi_DataService_DataFormField */ $dataFormFieldModel = $this->getModelFromCache('ThemeHouse_Infusionsoft_Model_InfusionsoftApi_DataService_DataFormField'); foreach ($formFieldOptions as $userFieldName => $dataFormFieldName) { if ($dataFormFieldName) { $value = ''; $isUpdated = false; if (strlen($userFieldName) > strlen('custom_field_') && substr($userFieldName, 0, strlen('custom_field_')) == 'custom_field_') { $fieldId = substr($userFieldName, strlen('custom_field_')); if (isset($customFields[$fieldId])) { $value = $customFields[$fieldId]; $isUpdated = true; } } else { $value = $dw->get($userFieldName); $isUpdated = $dw->isChanged($userFieldName); } if ($updatedOnly && !$isUpdated) { continue; } if (substr($dataFormFieldName, 0, 1) == '_') { if (!isset($dataFormFields)) { $dataFormFields = $dataFormFieldModel->getDataFormFieldsForForm(-1); } foreach ($dataFormFields as $dataFormField) { if ($dataFormField['Name'] == substr($dataFormFieldName, 1)) { switch ($dataFormField['DataType']) { case ThemeHouse_Infusionsoft_Model_InfusionsoftApi_DataService_DataFormField::DATE: case ThemeHouse_Infusionsoft_Model_InfusionsoftApi_DataService_DataFormField::DATE_TIME: $contact[$dataFormFieldName] = new Zend_XmlRpc_Value_DateTime($value); break; case ThemeHouse_Infusionsoft_Model_InfusionsoftApi_DataService_DataFormField::TEXT: case ThemeHouse_Infusionsoft_Model_InfusionsoftApi_DataService_DataFormField::TEXTAREA: $contact[$dataFormFieldName] = (string) $value; break; default: // do nothing } break; } } } else { $contact[$dataFormFieldName] = (string) $value; } } } return $contact; }
protected function _validateBirthdayInput(XenForo_DataWriter_User $writer, &$error) { $options = XenForo_Application::getOptions(); $error = false; $writer->checkDob(); if (!$options->get('registrationSetup', 'requireDob')) { return true; } // dob required if (!$writer->get('dob_day') || !$writer->get('dob_month') || !$writer->get('dob_year')) { $error = new XenForo_Phrase('please_enter_valid_date_of_birth'); return false; } else { $userAge = $this->_getUserProfileModel()->getUserAge($writer->getMergedData(), true); if ($userAge < 1) { $error = new XenForo_Phrase('please_enter_valid_date_of_birth'); return false; } else { if ($userAge < intval($options->get('registrationSetup', 'minimumAge'))) { // TODO: set a cookie to prevent re-registration attempts $error = new XenForo_Phrase('sorry_you_too_young_to_create_an_account'); return false; } } } return true; }