if (isset($object->$name) && $object->$name !== NULL) {
// hack for extends_entity_column_value
if ($name == 'extends_entity_column_value') {
- if ($object->extends == 'Event' ||
- $object->extends == 'Activity' ||
- $object->extends == 'Relationship'
- ) {
+ if (in_array($object->extends, array('Event', 'Activity', 'Relationship', 'Individual', 'Organization', 'Household'))) {
if ($object->extends == 'Event') {
$key = 'event_type';
}
elseif ($object->extends == 'Relationship') {
$key = 'relationship_type';
}
- $keyValues['extends_entity_column_value_option_group'] = $key;
$types = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($object->$name, 1, -1));
$values = array();
- foreach ($types as $type) {
- if (in_array($key, array('activity_type', 'event_type'))) {
- $ogID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $key, 'id', 'name');
- $ovParams = array('option_group_id' => $ogID, 'value' => $type);
- CRM_Core_BAO_OptionValue::retrieve($ovParams, $oValue);
- $values[] = $oValue['name'];
- }
- else {
- $relTypeName = CRM_Core_DAO::getFieldValue('CRM_Contact_BAO_RelationshipType', $type, 'name_a_b', 'id');
- $values[] = $relTypeName;
+ if (in_array($object->extends, array('Individual', 'Organization', 'Household'))) {
+ $key = 'contact_type';
+ $values = $types;
+ }
+ else {
+ foreach ($types as $type) {
+ if (in_array($key, array('activity_type', 'event_type'))) {
+ $ogID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $key, 'id', 'name');
+ $ovParams = array('option_group_id' => $ogID, 'value' => $type);
+ CRM_Core_BAO_OptionValue::retrieve($ovParams, $oValue);
+ $values[] = $oValue['name'];
+ }
+ else {
+ $relTypeName = CRM_Core_DAO::getFieldValue('CRM_Contact_BAO_RelationshipType', $type, 'name_a_b', 'id');
+ $values[] = $relTypeName;
+ }
}
}
+ $keyValues['extends_entity_column_value_option_group'] = $key;
$value = implode(',', $values);
$object->extends_entity_column_value = $value;
}
// fix extends stuff if it exists
if (isset($customGroupXML->extends_entity_column_value_option_group) &&
- isset($customGroupXML->extends_entity_column_value)
- ) {
+ isset($customGroupXML->extends_entity_column_value)) {
+ $valueIDs = array();
$optionValues = explode(",", $customGroupXML->extends_entity_column_value);
$optValues = implode("','", $optionValues);
if (trim($customGroup->extends) != 'Participant') {
$valueIDs[] = $relTypeId;
}
}
+ elseif (in_array($customGroup->extends, array('Individual', 'Organization', 'Household'))) {
+ $valueIDs = $optionValues;
+ }
else {
$sql = "
SELECT v.value
);
$dao = & CRM_Core_DAO::executeQuery($sql, $params);
- $valueIDs = array();
while ($dao->fetch()) {
$valueIDs[] = $dao->value;
}