}
}
- CRM_Utils_Array::lookupValue($defaults, 'prefix', CRM_Core_PseudoConstant::individualPrefix(), $reverse);
- CRM_Utils_Array::lookupValue($defaults, 'suffix', CRM_Core_PseudoConstant::individualSuffix(), $reverse);
- CRM_Utils_Array::lookupValue($defaults, 'gender', CRM_Core_PseudoConstant::gender(), $reverse);
+ CRM_Utils_Array::lookupValue($defaults, 'prefix', CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'), $reverse);
+ CRM_Utils_Array::lookupValue($defaults, 'suffix', CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id'), $reverse);
+ CRM_Utils_Array::lookupValue($defaults, 'gender', CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), $reverse);
//lookup value of email/postal greeting, addressee, CRM-4575
foreach (self::$_greetingTypes as $greeting) {
foreach ($defaults[$name] as $count => & $values) {
//get location type id.
- CRM_Utils_Array::lookupValue($values, 'location_type', CRM_Core_PseudoConstant::locationType(), $reverse);
+ CRM_Utils_Array::lookupValue($values, 'location_type', CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'), $reverse);
if ($name == 'address') {
// FIXME: lookupValue doesn't work for vcard_name
if (CRM_Utils_Array::value('location_type_id', $values)) {
- $vcardNames = CRM_Core_PseudoConstant::locationVcardName();
+ $vcardNames = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'vcard_name'));
$values['vcard_name'] = $vcardNames[$values['location_type_id']];
}
if ($name == 'im') {
CRM_Utils_Array::lookupValue($values,
'provider',
- CRM_Core_PseudoConstant::IMProvider(),
+ CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'),
$reverse
);
}
if ($name == 'phone') {
CRM_Utils_Array::lookupValue($values,
'phone_type',
- CRM_Core_PseudoConstant::phoneType(),
+ CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'),
$reverse
);
}
return FALSE;
}
+ // CRM-12929
+ // Restrict contact to be delete if contact has financial trxns
+ $error = NULL;
+ if ($skipUndelete && CRM_Financial_BAO_FinancialItem::checkContactPresent(array($id), $error)) {
+ return FALSE;
+ }
+
// make sure this contact_id does not have any membership types
$membershipTypeID = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType',
$id,
* combine all the importable fields from the lower levels object
*
* The ordering is important, since currently we do not have a weight
- * scheme. Adding weight is super important and should be done in the
- * next week or so, before this can be called complete.
+ * scheme. Adding weight is super important
*
* @param int $contactType contact Type
* @param boolean $status status is used to manipulate first title
$fields = array_merge($fields, $locationFields);
- $fields = array_merge($fields,
- CRM_Contact_DAO_Contact::import()
- );
- $fields = array_merge($fields,
- CRM_Core_DAO_Note::import()
- );
+ $fields = array_merge($fields, CRM_Contact_DAO_Contact::import());
+ $fields = array_merge($fields, CRM_Core_DAO_Note::import());
//website fields
$fields = array_merge($fields, CRM_Core_DAO_Website::import());
$fields = CRM_Contact_DAO_Contact::export();
// the fields are meant for contact types
- if (in_array($contactType, array(
- 'Individual', 'Household', 'Organization', 'All'))) {
+ if (
+ in_array(
+ $contactType,
+ array('Individual', 'Household', 'Organization', 'All')
+ )
+ ) {
$fields = array_merge($fields, CRM_Core_OptionValue::getFields('', $contactType));
}
// add current employer for individuals
'legal_identifier', 'sic_code', 'home_URL', 'is_deceased',
'deceased_date', 'current_employer', 'email_greeting_custom',
'postal_greeting_custom', 'addressee_custom',
- 'individual_prefix', 'individual_suffix', 'gender',
+ 'prefix_id', 'suffix_id'
),
'Organization' => array(
'first_name', 'middle_name', 'last_name', 'job_title',
'gender_id', 'birth_date', 'household_name',
'email_greeting_custom',
- 'postal_greeting_custom', 'individual_prefix',
- 'individual_suffix', 'gender', 'addressee_custom',
+ 'postal_greeting_custom', 'prefix_id',
+ 'suffix_id', 'gender_id', 'addressee_custom',
'is_deceased', 'deceased_date', 'current_employer',
),
);
* @static
*/
static function &makeHierReturnProperties($fields, $contactId = NULL) {
- $locationTypes = CRM_Core_PseudoConstant::locationType();
+ $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
$returnProperties = array();
}
// get the billing location type
- $locationTypes = CRM_Core_PseudoConstant::locationType();
+ $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
$billingLocationTypeId = array_search('Billing', $locationTypes);
$blocks = array('email', 'phone', 'im', 'openid');
// get preferred languages
if (!empty($contact->preferred_language)) {
- $languages = CRM_Core_PseudoConstant::languages();
- $values['preferred_language'] = CRM_Utils_Array::value($contact->preferred_language, $languages);
+ $values['preferred_language'] = CRM_Core_PseudoConstant::getValue('CRM_Contact_DAO_Contact', 'preferred_language', $contact->preferred_language);
}
// Calculating Year difference
);
return CRM_Activity_BAO_Activity::getActivitiesCount($input);
+ case 'mailing':
+ $params = array(
+ 'contact_id' => $contactId,
+ 'admin' => FALSE,
+ );
+ return CRM_Mailing_BAO_Mailing::getContactMailingsCount($params);
+
default:
$custom = explode('_', $component);
if ($custom['0'] = 'custom') {
* @return array $locBlockIds loc block ids which fulfill condition.
* @static
*/
- static function getLocBlockIds($contactId, $criteria = array(
- ), $condOperator = 'AND') {
+ static function getLocBlockIds($contactId, $criteria = array(), $condOperator = 'AND') {
$locBlockIds = array();
if (!$contactId) {
return $locBlockIds;
}
- foreach (array(
- 'Email', 'OpenID', 'Phone', 'Address', 'IM') as $block) {
+ foreach (array('Email', 'OpenID', 'Phone', 'Address', 'IM') as $block) {
$name = strtolower($block);
- eval("\$blockDAO = new CRM_Core_DAO_$block();");
+ $className = "CRM_Core_DAO_$block";
+ $blockDAO = new $className();
// build the condition.
if (is_array($criteria)) {
- eval('$object = new CRM_Core_DAO_' . $block . '( );');
- $fields = $object->fields();
+ $fields = $blockDAO->fields();
$conditions = array();
foreach ($criteria as $field => $value) {
if (array_key_exists($field, $fields)) {
}
}
+ /**
+ * Get options for a given contact field.
+ * @see CRM_Core_DAO::buildOptions
+ *
+ * TODO: Should we always assume chainselect? What fn should be responsible for controlling that flow?
+ * TODO: In context of chainselect, what to return if e.g. a country has no states?
+ *
+ * @param String $fieldName
+ * @param String $context: @see CRM_Core_DAO::buildOptionsContext
+ * @param Array $props: whatever is known about this dao object
+ */
+ public static function buildOptions($fieldName, $context = NULL, $props = array()) {
+ $params = array();
+ // Special logic for fields whose options depend on context or properties
+ switch ($fieldName) {
+ case 'contact_sub_type':
+ if (!empty($props['contact_type'])) {
+ $params['condition'] = "parent_id = (SELECT id FROM civicrm_contact_type WHERE name='{$props['contact_type']}')";
+ }
+ break;
+ }
+ return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);
+ }
/**
* Delete a contact-related object that has an 'is_primary' field