$fields = $subset;
}
else {
- $ufGroups = CRM_Core_PseudoConstant::ufGroup();
+ $ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id');
$fields = array();
foreach ($ufGroups as $id => $title) {
$formattedFields = array();
foreach ($fieldArrs as $fieldArr) {
- //$field = new CRM_Core_DAO_UFField();
- //$field->copyValues($fieldArr); // no... converts string('') to string('null')
$field = (object) $fieldArr;
if (!self::filterUFField($field, $searchable, $showAll, $visibility)) {
continue;
'add_captcha' => isset($group->add_captcha) ? $group->add_captcha : NULL,
'field_type' => $field->field_type,
'field_id' => $field->id,
+ 'pseudoconstant' => CRM_Utils_Array::value(
+ 'pseudoconstant',
+ CRM_Utils_Array::value($field->field_name, $importableFields)
+ ),
+ // obsolete this when we remove the name / dbName discrepancy with gender/suffix/prefix
+ 'dbName' => CRM_Utils_Array::value(
+ 'dbName',
+ CRM_Utils_Array::value($field->field_name, $importableFields)
+ ),
'skipDisplay' => 0,
);
$config = CRM_Core_Config::singleton();
- $locationTypes = CRM_Core_PseudoConstant::locationType();
- $imProviders = CRM_Core_PseudoConstant::IMProvider();
- $websiteTypes = CRM_Core_PseudoConstant::websiteType();
+ $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
+ $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
+ $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
$multipleFields = array('url');
$nullIndex = $nullValueIndex = ' ';
$params[$index] = $details->$idx;
}
elseif ($name === 'preferred_communication_method') {
- $communicationFields = CRM_Core_PseudoConstant::pcm();
+ $communicationFields = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method');
$compref = array();
$pref = explode(CRM_Core_DAO::VALUE_SEPARATOR, $details->$name);
$values[$index] = implode(',', $compref);
}
elseif ($name === 'preferred_language') {
- $languages = CRM_Core_PseudoConstant::languages();
$params[$index] = $details->$name;
- $values[$index] = $languages[$details->$name];
+ $values[$index] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', 'preferred_language', $details->$name);
}
elseif ($name == 'group') {
$groups = CRM_Contact_BAO_GroupContact::getContactGroup($cid, 'Added', NULL, FALSE, TRUE);
}
elseif ($name == 'tag') {
$entityTags = CRM_Core_BAO_EntityTag::getTag($cid);
- $allTags = CRM_Core_PseudoConstant::tag();
+ $allTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
$title = array();
foreach ($entityTags as $tagId) {
$title[] = $allTags[$tagId];
*
* @return object
*/
- static function add(&$params, &$ids) {
+ static function add(&$params, $ids = array()) {
$fields = array('is_active', 'add_captcha', 'is_map', 'is_update_dupe', 'is_edit_link', 'is_uf_link', 'is_cms_user');
foreach ($fields as $field) {
$params[$field] = CRM_Utils_Array::value($field, $params, FALSE);
$ufGroup = new CRM_Core_DAO_UFGroup();
$ufGroup->copyValues($params);
- $ufGroupID = CRM_Utils_Array::value('ufgroup', $ids);
+ $ufGroupID = CRM_Utils_Array::value('ufgroup', $ids, CRM_Utils_Array::value('id', $params));
if (!$ufGroupID) {
$ufGroup->name = CRM_Utils_String::munge($ufGroup->title, '_', 56);
}
}
$form->add('select', $providerName, NULL,
array(
- '' => ts('- select -')) + CRM_Core_PseudoConstant::IMProvider(), $required
+ '' => ts('- select -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'), $required
);
}
else {
$form->add('select', $name . '-provider_id', $title,
array(
- '' => ts('- select -')) + CRM_Core_PseudoConstant::IMProvider(), $required
+ '' => ts('- select -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'), $required
);
}
}
elseif ($fieldName === 'gender') {
$genderOptions = array();
- $gender = CRM_Core_PseudoConstant::gender();
+ $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id');
foreach ($gender as $key => $var) {
$genderOptions[$key] = $form->createElement('radio', NULL, ts('Gender'), $var, $key);
}
elseif ($fieldName === 'individual_prefix') {
$form->add('select', $name, $title,
array(
- '' => ts('- select -')) + CRM_Core_PseudoConstant::individualPrefix(), $required
+ '' => ts('- select -')) + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'), $required
);
}
elseif ($fieldName === 'individual_suffix') {
$form->add('select', $name, $title,
array(
- '' => ts('- select -')) + CRM_Core_PseudoConstant::individualSuffix(), $required
+ '' => ts('- select -')) + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id'), $required
);
}
elseif ($fieldName === 'contact_sub_type') {
);
}
elseif ($fieldName === 'preferred_communication_method') {
- $communicationFields = CRM_Core_PseudoConstant::pcm();
+ $communicationFields = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method');
foreach ($communicationFields as $key => $var) {
if ($key == '') {
continue;
$form->add('select', $name, $title, CRM_Core_SelectValues::pmf());
}
elseif ($fieldName === 'preferred_language') {
- $form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::languages());
+ $form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contact_BAO_Contact::buildOptions('preferred_language'));
}
elseif ($fieldName == 'external_identifier') {
$form->add('text', $name, $title, $attributes, $required);
if (substr($name, -1) == ']') {
$websiteTypeName = substr($name, 0, -1) . '-website_type_id]';
}
- $form->addElement('select', $websiteTypeName, NULL, CRM_Core_PseudoConstant::websiteType());
+ $form->addElement('select', $websiteTypeName, NULL, CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'));
}
else {
- $form->addElement('select', $name . '-website_type_id', NULL, CRM_Core_PseudoConstant::websiteType());
+ $form->addElement('select', $name . '-website_type_id', NULL, CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'));
}
}
// Note should be rendered as textarea
}
elseif ($fieldName == 'soft_credit') {
CRM_Contact_Form_NewContact::buildQuickForm($form, $rowNumber, NULL, FALSE, 'soft_credit_');
+ $form->addMoney("soft_credit_amount[{$rowNumber}]", ts('Amount'), FALSE, NULL, FALSE);
}
elseif ($fieldName == 'product_name') {
list($products, $options) = CRM_Contribute_BAO_Premium::getPremiumProductInfo();
) as $suppress) {
unset($contributionStatuses[CRM_Utils_Array::key($suppress, $statusName)]);
}
-
+
$form->add('select', $name, $title,
array(
'' => ts('- select -')) + $contributionStatuses, $required
case 'Select Date':
// CRM-6681, set defult values according to date and time format (if any).
$dateFormat = NULL;
- if (CRM_Utils_Array::value('date_format', $field)) {
- $dateFormat = $field['date_format'];
+ if (CRM_Utils_Array::value('date_format', $customFields[$customFieldId])) {
+ $dateFormat = $customFields[$customFieldId]['date_format'];
}
- if (!CRM_Utils_Array::value('time_format', $field)) {
+ if (!CRM_Utils_Array::value('time_format', $customFields[$customFieldId])) {
list($defaults[$fldName]) = CRM_Utils_Date::setDateDefaults($details[$name], NULL,
$dateFormat
);
if (substr($fldName, -1) == ']') {
$timeElement = substr($fldName, 0, -1) . '_time]';
}
- list($defaults[$fldName], $defaults[$timeElement]) = CRM_Utils_Date::setDateDefaults($details[$name], NULL, $dateFormat, $field['time_format']);
+ list($defaults[$fldName], $defaults[$timeElement]) = CRM_Utils_Date::setDateDefaults($details[$name],
+ NULL, $dateFormat, $customFields[$customFieldId]['time_format']);
}
break;
*/
static function getProfiles($types, $onlyPure = FALSE) {
$profiles = array();
- $ufGroups = CRM_Core_PseudoConstant::ufgroup();
+ $ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id');
CRM_Utils_Hook::aclGroup(CRM_Core_Permission::ADMIN, NULL, 'civicrm_uf_group', $ufGroups, $ufGroups);
}
$profiles = array();
- $ufGroups = CRM_Core_PseudoConstant::ufgroup();
+ $ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id');
CRM_Utils_Hook::aclGroup(CRM_Core_Permission::ADMIN, NULL, 'civicrm_uf_group', $ufGroups, $ufGroups);