<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.3 |
+ | CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
* Function to check duplicate for duplicate field in a group
*
* @param array $params an associative array with field and values
+ * @param $ids
+ *
+ * @return mixed
* @ids array $ids array that containd ids
*
* @access public
return $ufField->find(TRUE);
}
- /*
- *Does profile consists of a multi-record custom field
+ /**
+ * Does profile consists of a multi-record custom field
*/
public static function checkMultiRecordFieldExists($gId) {
$queryString = "SELECT f.field_name
* function to add the UF Field
*
* @param array $params (reference) array containing the values submitted by the form
- * @param array $ids (reference) array containing the id
+ * @param array $ids array containing the id
*
* @return object CRM_Core_BAO_UFField object
*
* @static
*
*/
- static function add(&$params, &$ids) {
+ static function add(&$params, $ids = array()) {
// set values for uf field properties and save
$ufField = new CRM_Core_DAO_UFField();
$ufField->field_type = $params['field_name'][0];
$oldWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFField', $params['field_id'], 'weight', 'id');
}
$fieldValues = array('uf_group_id' => $params['group_id']);
- return CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_UFField', $oldWeight, $params['weight'], $fieldValues);
+ return CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_UFField', $oldWeight, CRM_Utils_Array::value('weight', $params, 0), $fieldValues);
}
/**
}
/**
- * Function to copy exisiting profile fields to
+ * Function to copy existing profile fields to
* new profile from the already built profile
*
* @param int $old_id from which we need to copy
*
* @params int $UFFieldId uf field id
*
+ * @param $UFFieldId
+ *
* @return boolean false if custom field are disabled else true
* @static
* @access public
}
}
- /*
+ /**
* Function to find out whether given profile group using Activity
* Profile fields with contact fields
*/
return TRUE;
}
- /* Function to find out whether given profile group uses $required
- * and/or $optionalprofile types
+ /**
+ * Function to find out whether given profile group uses $required
+ * and/or $optional profile types
*
* @param integer $ufGroupId profile id
* @param array $required array of types those are required
* @params boolean $check this is to check mix profile (if true it will check if profile is
* pure ie. it contains only one contact type)
*
+ * @param $ufGroupId
+ *
* @return true for mix profile else false
* @acess public
* @static
/**
* function to get the profile type (eg: individual/organization/household)
*
- * @param int $ufGroupId uf group id
- * @param boolean $returnMixType this is true, then field type of mix profile field is returned
- * @param boolean $onlyPure true if only pure profiles are required
+ * @param int $ufGroupId uf group id
+ * @param boolean $returnMixType this is true, then field type of mix profile field is returned
+ * @param boolean $onlyPure true if only pure profiles are required
+ *
+ * @param bool $skipComponentType
*
* @return profile group_type
* @acess public
/**
* function to get the profile type (eg: individual/organization/household)
*
- * @param int $ufGroupId uf group id
- * @param boolean $returnMixType this is true, then field type of mix profile field is returned
- * @param boolean $onlyPure true if only pure profiles are required
+ * @param $ufGroupType
+ * @param boolean $returnMixType this is true, then field type of mix profile field is returned
+ * @param boolean $onlyPure true if only pure profiles are required
+ *
+ * @param bool $skipComponentType
*
+ * @internal param int $ufGroupId uf group id
* @return profile group_type
* @acess public
* @static
/**
* function to check for mix profiles groups (eg: individual + other contact types)
*
+ * @param $ctype
+ *
* @return true for mix profile group else false
* @acess public
* @static
*
* @params int $profileID profile id.
*
+ * @param $profileID
+ *
* @return boolean $result true/false.
*/
static function checkSearchableORInSelector($profileID) {
*
* @params int $profileID profile id.
*
+ * @param $profileID
+ *
* @return void.
*/
function resetInSelectorANDSearchable($profileID) {
* as this will be used to
* transfer profile address data to billing fields
* http://issues.civicrm.org/jira/browse/CRM-5869
+ *
* @param string $key Field key - e.g. street_address-Primary, first_name
- * @params array $profileAddressFields array of profile fields that relate to address fields
+ * @param array $profileAddressFields array of profile fields that relate to address fields
+ * @param array $profileFilter filter to apply to profile fields - expected usage is to only fill based on
+ * the bottom profile per CRM-13726
*/
- static function assignAddressField($key, &$profileAddressFields) {
+ static function assignAddressField($key, &$profileAddressFields, $profileFilter) {
$billing_id = CRM_Core_BAO_LocationType::getBilling();
list($prefixName, $index) = CRM_Utils_System::explode('-', $key, 2);
+ $profileFields = civicrm_api3('uf_field', 'get', array_merge($profileFilter, array('is_active' => 1, 'return' => 'field_name')));
//check for valid fields ( fields that are present in billing block )
$validBillingFields = array(
'first_name',
'postal_code',
'country'
);
+ $validProfileFields = array();
- if (!in_array($prefixName, $validBillingFields)) {
+ foreach ($profileFields['values'] as $field) {
+ if(in_array($field['field_name'], $validBillingFields)) {
+ $validProfileFields[] = $field['field_name'];
+ }
+ }
+
+ if (!in_array($prefixName, $validProfileFields) ) {
return;
}
'Organization' => CRM_Contact_BAO_Contact::importableFields('Organization', FALSE, FALSE, TRUE, TRUE, TRUE),
);
+ // include hook injected fields
+ $fields['Contact'] = array_merge($fields['Contact'], CRM_Contact_BAO_Query_Hook::singleton()->getFields());
+
// add current employer for individuals
$fields['Individual']['current_employer'] = array(
'name' => 'organization_name',
/**
* Get a list of fields which can be added to profiles
*
+ * @param bool $force
+ *
* @return array, multidimensional; e.g. $result['field_name']['label']
* @static
*/