/** * @param string $objectName * Business-entity/xml-tag name. * @param CRM_Core_DAO $object * @param $mappedFields * * @return array */ public function exportDAO($objectName, $object, $mappedFields) { $dbFields =& $object->fields(); // Filter the list of keys and values so that we only export interesting stuff $keyValues = array(); foreach ($dbFields as $name => $dontCare) { // ignore all ids if ($name == 'id' || substr($name, -3, 3) == '_id') { continue; } if (isset($object->{$name}) && $object->{$name} !== NULL) { // hack for extends_entity_column_value if ($name == 'extends_entity_column_value') { if (in_array($object->extends, array('Event', 'Activity', 'Relationship', 'Individual', 'Organization', 'Household', 'Case'))) { if ($object->extends == 'Event') { $key = 'event_type'; } elseif ($object->extends == 'Activity') { $key = 'activity_type'; } elseif ($object->extends == 'Relationship') { $key = 'relationship_type'; } elseif ($object->extends == 'Case') { $key = 'case_type'; } $types = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($object->{$name}, 1, -1)); $values = array(); 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', 'case_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; } else { echo "This extension: {$object->extends} is not yet handled"; exit; } } $value = $object->{$name}; if ($name == 'field_name') { // hack for profile field_name if (substr($value, 0, 7) == 'custom_') { $cfID = substr($value, 7); list($tableName, $columnName, $groupID) = CRM_Core_BAO_CustomField::getTableColumnGroup($cfID); $value = "custom.{$tableName}.{$columnName}"; } } $keyValues[$name] = $value; } } $keyValues += $this->computeMappedFields($mappedFields, $object); return $keyValues; }
/** * check method getInstrumentFinancialAccount() */ function testGetInstrumentFinancialAccount() { $paymentInstrumentValue = 1; $params = array('name' => 'Donations', 'is_deductible' => 0, 'is_active' => 1); $ids = array(); $financialAccount = CRM_Financial_BAO_FinancialAccount::add($params, $ids); $optionParams = array('name' => 'Credit Card', 'value' => $paymentInstrumentValue); $optionValue = CRM_Core_BAO_OptionValue::retrieve($optionParams, $defaults); $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' ")); $financialParams = array('entity_table' => 'civicrm_option_value', 'entity_id' => $optionValue->id, 'account_relationship' => $relationTypeId, 'financial_account_id' => $financialAccount->id); CRM_Financial_BAO_FinancialTypeAccount::add($financialParams, $ids); $financialAccountId = CRM_Financial_BAO_FinancialTypeAccount::getInstrumentFinancialAccount($paymentInstrumentValue); $this->assertEquals($financialAccountId, $financialAccount->id, 'Verify Payment Instrument'); }
/** * Implementation of hook_civicrm_uninstall */ function hrui_civicrm_uninstall() { //Enable Individual sub types _hrui_toggleContactSubType(TRUE); // get a list of all tab options $options = CRM_Core_OptionGroup::values('contact_view_options', TRUE, FALSE); $tabsToSet = array($options['Activities'], $options['Tags']); // get tab options from DB $options = hrui_getViewOptionsSetting(); // set activity & tag tab options foreach ($tabsToSet as $key) { $options[$key] = 1; } $options = array_keys($options); // set modified options in the DB hrui_setViewOptionsSetting($options); _hrui_setActiveFields(TRUE); // show communication preferences block $groupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'contact_edit_options', 'id', 'name'); $params = array('option_group_id' => $groupID, 'name' => 'CommunicationPreferences'); CRM_Core_BAO_OptionValue::retrieve($params, $defaults); $defaults['is_active'] = 1; CRM_Core_BAO_OptionValue::create($defaults); _hrui_wordReplacement(TRUE); return _hrui_civix_civicrm_uninstall(); }