本文整理汇总了PHP中CRM_Core_BAO_CustomValue::updateValue方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_CustomValue::updateValue方法的具体用法?PHP CRM_Core_BAO_CustomValue::updateValue怎么用?PHP CRM_Core_BAO_CustomValue::updateValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_CustomValue
的用法示例。
在下文中一共展示了CRM_Core_BAO_CustomValue::updateValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
//.........这里部分代码省略.........
CRM_Core_DAO::transaction('BEGIN');
$params['contact_type'] = 'Individual';
$contact = CRM_Contact_BAO_Contact::add($params, $ids);
$params['contact_id'] = $contact->id;
require_once 'CRM/Contact/BAO/Individual.php';
CRM_Contact_BAO_Individual::add($params, $ids);
require_once 'CRM/Core/BAO/LocationType.php';
$locationType =& CRM_Core_BAO_LocationType::getDefault();
$locationTypeId = $locationType->id;
$locationIds = CRM_Utils_Array::value('location', $ids);
// extract the first location id
if ($locationIds) {
foreach ($locationIds as $dontCare => $locationId) {
$locationIds = $locationId;
break;
}
}
$location =& new CRM_Core_DAO_Location();
$location->location_type_id = $locationTypeId;
$location->entity_table = 'civicrm_contact';
$location->entity_id = $contact->id;
$location->id = CRM_Utils_Array::value('id', $locationIds);
if ($location->find(true)) {
if (!$location->is_primary) {
$location->is_primary = true;
}
} else {
$location->is_primary = true;
}
$location->save();
$address =& new CRM_Core_BAO_Address();
CRM_Core_BAO_Address::fixAddress($params);
if (!$address->copyValues($params)) {
$address->id = CRM_Utils_Array::value('address', $locationIds);
$address->location_id = $location->id;
$address->save();
}
$phone =& new CRM_Core_BAO_Phone();
if (!$phone->copyValues($params)) {
$blockIds = CRM_Utils_Array::value('phone', $locationIds);
$phone->id = CRM_Utils_Array::value(1, $blockIds);
$phone->location_id = $location->id;
$phone->is_primary = true;
$phone->save();
}
$email =& new CRM_Core_BAO_Email();
if (!$email->copyValues($params)) {
$blockIds = CRM_Utils_Array::value('email', $locationIds);
$email->id = CRM_Utils_Array::value(1, $blockIds);
$email->location_id = $location->id;
$email->is_primary = true;
$email->save();
}
/* Process custom field values and other values */
foreach ($params as $key => $value) {
if ($key == 'group') {
CRM_Contact_BAO_GroupContact::create($params['group'], $contact->id);
} else {
if ($key == 'tag') {
require_once 'CRM/Core/BAO/EntityTag.php';
CRM_Core_BAO_EntityTag::create($params['tag'], $contact->id);
} else {
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($key)) {
$custom_field_id = $cfID;
$cf =& new CRM_Core_BAO_CustomField();
$cf->id = $custom_field_id;
if ($cf->find(true)) {
switch ($cf->html_type) {
case 'Select Date':
$date = CRM_Utils_Date::format($value);
if (!$date) {
$date = '';
}
$customValue = $date;
break;
case 'CheckBox':
$customValue = implode(CRM_CORE_BAO_CUSTOMOPTION_VALUE_SEPERATOR, array_keys($value));
break;
//added a case for Multi-Select
//added a case for Multi-Select
case 'Multi-Select':
$customValue = implode(CRM_CORE_BAO_CUSTOMOPTION_VALUE_SEPERATOR, array_keys($value));
break;
default:
$customValue = $value;
}
}
CRM_Core_BAO_CustomValue::updateValue($contact->id, $custom_field_id, $customValue);
}
}
}
}
CRM_Core_DAO::transaction('COMMIT');
if (CRM_Utils_Array::value('contact', $ids)) {
CRM_Utils_Hook::post('edit', 'Individual', $contact->id, $contact);
} else {
CRM_Utils_Hook::post('create', 'Individual', $contact->id, $contact);
}
return $contact;
}