本文整理汇总了PHP中CRM_Core_Payment_Form::checkRequiredStateProvince方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Payment_Form::checkRequiredStateProvince方法的具体用法?PHP CRM_Core_Payment_Form::checkRequiredStateProvince怎么用?PHP CRM_Core_Payment_Form::checkRequiredStateProvince使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Payment_Form
的用法示例。
在下文中一共展示了CRM_Core_Payment_Form::checkRequiredStateProvince方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
/**
* Function to actually build the form
*
* @return void
* @access public
*/
public function buildQuickForm()
{
switch ($this->_mode) {
case self::MODE_CREATE:
case self::MODE_EDIT:
case self::MODE_REGISTER:
CRM_Utils_Hook::buildProfile($this->_ufGroupName);
break;
case self::MODE_SEARCH:
CRM_Utils_Hook::searchProfile($this->_ufGroupName);
break;
default:
}
//lets have single status message, CRM-4363
$return = FALSE;
$statusMessage = NULL;
if ($this->_multiRecord & CRM_Core_Action::ADD && $this->_maxRecordLimit) {
return;
}
if ($this->_multiRecord & CRM_Core_Action::DELETE) {
if (!$this->_recordExists) {
CRM_Core_Session::setStatus(ts('The record %1 doesnot exists', array(1 => $this->_recordId)), ts('Record doesnot exists'), 'alert');
} else {
$this->assign('deleteRecord', TRUE);
}
return;
}
CRM_Core_BAO_Address::checkContactSharedAddressFields($this->_fields, $this->_id);
// we should not allow component and mix profiles in search mode
if ($this->_mode != self::MODE_REGISTER) {
//check for mix profile fields (eg: individual + other contact type)
if (CRM_Core_BAO_UFField::checkProfileType($this->_gid)) {
if ($this->_mode & self::MODE_EDIT && $this->_isContactActivityProfile) {
$errors = self::validateContactActivityProfile($this->_activityId, $this->_id, $this->_gid);
if (!empty($errors)) {
$statusMessage = array_pop($errors);
$return = TRUE;
}
} else {
$statusMessage = ts('Profile search, view and edit are not supported for Profiles which include fields for more than one record type.');
$return = TRUE;
}
}
$profileType = CRM_Core_BAO_UFField::getProfileType($this->_gid);
if ($this->_id) {
$contactTypes = CRM_Contact_BAO_Contact::getContactTypes($this->_id);
$contactType = $contactTypes[0];
array_shift($contactTypes);
$contactSubtypes = $contactTypes;
$profileSubType = FALSE;
if (CRM_Contact_BAO_ContactType::isaSubType($profileType)) {
$profileSubType = $profileType;
$profileType = CRM_Contact_BAO_ContactType::getBasicType($profileType);
}
if ($profileType != 'Contact' && !$this->_isContactActivityProfile && ($profileSubType && !empty($contactSubtypes) && !in_array($profileSubType, $contactSubtypes) || $profileType != $contactType)) {
$return = TRUE;
if (!$statusMessage) {
$statusMessage = ts("This profile is configured for contact type '%1'. It cannot be used to edit contacts of other types.", array(1 => $profileSubType ? $profileSubType : $profileType));
}
}
}
if (in_array($profileType, array("Membership", "Participant", "Contribution"))) {
$return = TRUE;
if (!$statusMessage) {
$statusMessage = ts('Profile is not configured for the selected action.');
}
}
}
//lets have sigle status message,
$this->assign('statusMessage', $statusMessage);
if ($return) {
return FALSE;
}
if (count($this->_submitValues)) {
$locationTypeId = null;
foreach ($this->_fields as $field) {
if (!empty($field['location_type_id'])) {
$locationTypeId = $field['location_type_id'];
}
if (array_key_exists("country-{$locationTypeId}", $this->_fields) && array_key_exists("state_province-{$locationTypeId}", $this->_fields) && !empty($this->_submitValues["country-{$locationTypeId}"])) {
$this->_fields["state_province-{$locationTypeId}"]['is_required'] = CRM_Core_Payment_Form::checkRequiredStateProvince($this, "country-{$locationTypeId}");
}
}
}
$this->assign('id', $this->_id);
$this->assign('mode', $this->_mode);
$this->assign('action', $this->_action);
$this->assign('fields', $this->_fields);
$this->assign('fieldset', isset($this->_fieldset) ? $this->_fieldset : "");
// should we restrict what we display
$admin = TRUE;
if ($this->_mode == self::MODE_EDIT) {
$admin = FALSE;
// show all fields that are visibile:
//.........这里部分代码省略.........
示例2: buildCustom
/**
* Function to add the custom fields
*
* @return void
* @access public
*/
function buildCustom($id, $name, $viewOnly = FALSE, $profileContactType = NULL, $fieldTypes = NULL)
{
$stateCountryMap = array();
if ($id) {
$contactID = $this->getContactID();
// we don't allow conflicting fields to be
// configured via profile - CRM 2100
$fieldsToIgnore = array('receive_date' => 1, 'trxn_id' => 1, 'invoice_id' => 1, 'net_amount' => 1, 'fee_amount' => 1, 'non_deductible_amount' => 1, 'total_amount' => 1, 'amount_level' => 1, 'contribution_status_id' => 1, 'payment_instrument' => 1, 'check_number' => 1, 'financial_type' => 1);
$fields = NULL;
if ($contactID && CRM_Core_BAO_UFGroup::filterUFGroups($id, $contactID)) {
$fields = CRM_Core_BAO_UFGroup::getFields($id, FALSE, CRM_Core_Action::ADD, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL);
} else {
$fields = CRM_Core_BAO_UFGroup::getFields($id, FALSE, CRM_Core_Action::ADD, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL);
}
if ($fields) {
// unset any email-* fields since we already collect it, CRM-2888
foreach (array_keys($fields) as $fieldName) {
if (substr($fieldName, 0, 6) == 'email-') {
unset($fields[$fieldName]);
}
}
if (array_intersect_key($fields, $fieldsToIgnore)) {
$fields = array_diff_key($fields, $fieldsToIgnore);
CRM_Core_Session::setStatus(ts('Some of the profile fields cannot be configured for this page.'), ts('Warning'), 'alert');
}
$fields = array_diff_assoc($fields, $this->_fields);
CRM_Core_BAO_Address::checkContactSharedAddressFields($fields, $contactID);
$addCaptcha = FALSE;
foreach ($fields as $key => $field) {
if ($viewOnly && isset($field['data_type']) && $field['data_type'] == 'File' || $viewOnly && $field['name'] == 'image_URL') {
// ignore file upload fields
continue;
}
list($prefixName, $index) = CRM_Utils_System::explode('-', $key, 2);
if ($prefixName == 'state_province' || $prefixName == 'country' || $prefixName == 'county') {
if (!array_key_exists($index, $stateCountryMap)) {
$stateCountryMap[$index] = array();
}
$stateCountryMap[$index][$prefixName] = $key;
if ($prefixName == "state_province") {
if ($profileContactType == 'onbehalf') {
//CRM-11881: Bypass required-ness check for state/province on Contribution Confirm page
//as already done during Contribution registration via onBehalf's quickForm
$field['is_required'] = FALSE;
} else {
if (count($this->_submitValues)) {
$locationTypeId = $field['location_type_id'];
if (array_key_exists("country-{$locationTypeId}", $fields) && array_key_exists("state_province-{$locationTypeId}", $fields) && !empty($this->_submitValues["country-{$locationTypeId}"])) {
$field['is_required'] = CRM_Core_Payment_Form::checkRequiredStateProvince($this, "country-{$locationTypeId}");
}
}
}
}
}
if ($profileContactType) {
//Since we are showing honoree name separately so we are removing it from honoree profile just for display
$honoreeNamefields = array('prefix_id', 'first_name', 'last_name', 'suffix_id', 'organization_name', 'household_name');
if ($profileContactType == 'honor' && in_array($field['name'], $honoreeNamefields)) {
unset($fields[$field['name']]);
continue;
}
if (!empty($fieldTypes) && in_array($field['field_type'], $fieldTypes)) {
CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE, $contactID, TRUE, $profileContactType);
$this->_fields[$profileContactType][$key] = $field;
} else {
unset($fields[$key]);
}
} else {
CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE, $contactID, TRUE);
$this->_fields[$key] = $field;
}
// CRM-11316 Is ReCAPTCHA enabled for this profile AND is this an anonymous visitor
if ($field['add_captcha'] && !$this->_userID) {
$addCaptcha = TRUE;
}
}
$this->assign($name, $fields);
CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap);
if ($addCaptcha && !$viewOnly) {
$captcha = CRM_Utils_ReCAPTCHA::singleton();
$captcha->add($this);
$this->assign('isCaptcha', TRUE);
}
}
}
}
示例3: buildQuickForm
/**
* Function to build form for related contacts / on behalf of organization.
*
* @param $form object invoking Object
* @param $contactType string contact type
* @param $title string fieldset title
*
* @static
*/
static function buildQuickForm(&$form)
{
$form->assign('fieldSetTitle', ts('Organization Details'));
$form->assign('buildOnBehalfForm', TRUE);
$session = CRM_Core_Session::singleton();
$contactID = $session->get('userID');
if ($contactID && count($form->_employers) >= 1) {
$form->add('text', 'organization_id', ts('Select an existing related Organization OR enter a new one'));
$form->add('hidden', 'onbehalfof_id', '', array('id' => 'onbehalfof_id'));
$orgOptions = array(0 => ts('Select an existing organization'), 1 => ts('Enter a new organization'));
$form->addRadio('org_option', ts('options'), $orgOptions);
$form->setDefaults(array('org_option' => 0));
$form->add('checkbox', 'mode', '');
}
$profileFields = CRM_Core_BAO_UFGroup::getFields($form->_profileId, FALSE, CRM_Core_Action::VIEW, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL);
$fieldTypes = array('Contact', 'Organization');
$contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization');
$fieldTypes = array_merge($fieldTypes, $contactSubType);
if (is_array($form->_membershipBlock) && !empty($form->_membershipBlock)) {
$fieldTypes = array_merge($fieldTypes, array('Membership'));
} else {
$fieldTypes = array_merge($fieldTypes, array('Contribution'));
}
$stateCountryMap = array();
foreach ($profileFields as $name => $field) {
if (in_array($field['field_type'], $fieldTypes)) {
list($prefixName, $index) = CRM_Utils_System::explode('-', $name, 2);
if (in_array($prefixName, array('state_province', 'country', 'county'))) {
if (!array_key_exists($index, $stateCountryMap)) {
$stateCountryMap[$index] = array();
}
$stateCountryMap[$index][$prefixName] = 'onbehalf[' . $name . ']';
if (count($form->_submitValues)) {
$locationTypeId = $field['location_type_id'];
if (!empty($form->_submitValues['onbehalf']["country-{$locationTypeId}"]) && $prefixName == "state_province") {
$field['is_required'] = CRM_Core_Payment_Form::checkRequiredStateProvince($form, "country-{$locationTypeId}", TRUE);
}
}
} elseif (in_array($prefixName, array('organization_name', 'email')) && empty($field['is_required'])) {
$field['is_required'] = 1;
}
CRM_Core_BAO_UFGroup::buildProfile($form, $field, NULL, NULL, FALSE, TRUE);
}
}
if (!empty($stateCountryMap)) {
CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap);
// now fix all state country selectors
CRM_Core_BAO_Address::fixAllStateSelects($form, CRM_Core_DAO::$_nullArray);
}
$form->assign('onBehalfOfFields', $profileFields);
$form->addElement('hidden', 'hidden_onbehalf_profile', 1);
}