本文整理汇总了PHP中CRM_Contact_BAO_Contact::lookupValue方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Contact::lookupValue方法的具体用法?PHP CRM_Contact_BAO_Contact::lookupValue怎么用?PHP CRM_Contact_BAO_Contact::lookupValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_Contact
的用法示例。
在下文中一共展示了CRM_Contact_BAO_Contact::lookupValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Create a new CustomValue record
*
* @param array $params The values for the new record
*
* @return object The new BAO
* @access public
* @static
*/
function create(&$params)
{
$customValue =& new CRM_Core_BAO_CustomValue();
$customValue->copyValues($params);
switch ($params['type']) {
case 'StateProvince':
//$states =& CRM_Core_PseudoConstant::stateProvince();
//$customValue->int_data = CRM_Utils_Array::key($params['value'], $states);
//$customValue->char_data = $params['value'];
if (!is_numeric($params['value'])) {
$states = array();
$states['state_province'] = $params['value'];
CRM_Contact_BAO_Contact::lookupValue($states, 'state_province', CRM_Core_PseudoConstant::stateProvince(), true);
if (!$states['state_province_id']) {
CRM_Contact_BAO_Contact::lookupValue($states, 'state_province', CRM_Core_PseudoConstant::stateProvinceAbbreviation(), true);
}
$customValue->int_data = $states['state_province_id'];
} else {
$customValue->int_data = $params['value'];
}
break;
case 'Country':
//$countries =& CRM_Core_PseudoConstant::country();
//$customValue->int_data = CRM_Utils_Array::key($params['value'], $countries);
//$customValue->char_data = $params['value'];
if (!is_numeric($params['value'])) {
$countries = array();
$countries['country'] = $params['value'];
CRM_Contact_BAO_Contact::lookupValue($countries, 'country', CRM_Core_PseudoConstant::country(), true);
if (!$countries['country_id']) {
CRM_Contact_BAO_Contact::lookupValue($countries, 'country', CRM_Core_PseudoConstant::countryIsoCode(), true);
}
$customValue->int_data = $countries['country_id'];
} else {
$customValue->int_data = $params['value'];
}
break;
case 'String':
$customValue->char_data = $params['value'];
break;
case 'Boolean':
$customValue->int_data = CRM_Utils_String::strtobool($params['value']);
break;
case 'Int':
$customValue->int_data = $params['value'];
break;
case 'Float':
$customValue->float_data = $params['value'];
break;
case 'Money':
$customValue->decimal_data = number_format($params['value'], 2, '.', '');
break;
case 'Memo':
$customValue->memo_data = $params['value'];
break;
case 'Date':
$customValue->date_data = $params['value'];
break;
}
$customValue->save();
return $customValue;
}
示例2: resolveDefaults
/**
*
* Get the values for pseudoconstants for name->value and reverse.
*
* @param array $defaults (reference) the default values, some of which need to be resolved.
* @param boolean $reverse true if we want to resolve the values in the reverse direction (value -> name)
*
* @return none
* @access public
* @static
*/
function resolveDefaults(&$defaults, $reverse = false)
{
// hack for birth_date
if (CRM_Utils_Array::value('birth_date', $defaults)) {
if (is_array($defaults['birth_date'])) {
$defaults['birth_date'] = CRM_Utils_Date::format($defaults['birth_date'], '-');
}
}
if (CRM_Utils_Array::value('prefix', $defaults)) {
CRM_Contact_BAO_Contact::lookupValue($defaults, 'prefix', CRM_Core_PseudoConstant::individualPrefix(), $reverse);
}
if (CRM_Utils_Array::value('suffix', $defaults)) {
CRM_Contact_BAO_Contact::lookupValue($defaults, 'suffix', CRM_Core_PseudoConstant::individualSuffix(), $reverse);
}
if (CRM_Utils_Array::value('gender', $defaults)) {
CRM_Contact_BAO_Contact::lookupValue($defaults, 'gender', CRM_Core_PseudoConstant::gender(), $reverse);
}
if (array_key_exists('location', $defaults)) {
$locations =& $defaults['location'];
foreach ($locations as $index => $location) {
$location =& $locations[$index];
CRM_Contact_BAO_Contact::lookupValue($location, 'location_type', CRM_Core_PseudoConstant::locationType(), $reverse);
// FIXME: lookupValue doesn't work for vcard_name
$vcardNames =& CRM_Core_PseudoConstant::locationVcardName();
$location['vcard_name'] = $vcardNames[$location['location_type_id']];
if (array_key_exists('address', $location)) {
if (!CRM_Contact_BAO_Contact::lookupValue($location['address'], 'state_province', CRM_Core_PseudoConstant::stateProvince(), $reverse) && $reverse) {
CRM_Contact_BAO_Contact::lookupValue($location['address'], 'state_province', CRM_Core_PseudoConstant::stateProvinceAbbreviation(), $reverse);
}
if (!CRM_Contact_BAO_Contact::lookupValue($location['address'], 'country', CRM_Core_PseudoConstant::country(), $reverse) && $reverse) {
CRM_Contact_BAO_Contact::lookupValue($location['address'], 'country', CRM_Core_PseudoConstant::countryIsoCode(), $reverse);
}
CRM_Contact_BAO_Contact::lookupValue($location['address'], 'county', CRM_Core_SelectValues::county(), $reverse);
}
if (array_key_exists('im', $location)) {
$ims =& $location['im'];
foreach ($ims as $innerIndex => $im) {
$im =& $ims[$innerIndex];
CRM_Contact_BAO_Contact::lookupValue($im, 'provider', CRM_Core_PseudoConstant::IMProvider(), $reverse);
unset($im);
}
}
unset($location);
}
}
}