<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.3 |
+ | CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
}
elseif ($fieldName == 'im') {
$providerId = $detailName . '-provider_id';
- $providerName = $imProviders[$details->$providerId];
- if ($providerName) {
- $values[$index] = $details->$detailName . " (" . $providerName . ")";
+ if (isset($imProviders[$details->$providerId])) {
+ $values[$index] = $details->$detailName . " (" . $imProviders[$details->$providerId] . ")";
}
else {
$values[$index] = $details->$detailName;
* Function to get the uf group for a module
*
* @param string $moduleName module name
- * $param int $count no to increment the weight
- * $param bool $skipPermision - whether to add permission clause
- * $param int $op - which operation (view, edit, create, etc) to check permission for
+ * @param int $count no to increment the weight
+ * @param bool $skipPermision - whether to add permission clause
+ * @param int $op - which operation (view, edit, create, etc) to check permission for
+ * @param array|NULL $returnFields list of UFGroup fields to return; NULL for default
*
* @return array $ufGroups array of ufgroups for a module
* @access public
* @static
*/
- public static function getModuleUFGroup($moduleName = NULL, $count = 0, $skipPermission = TRUE, $op = CRM_Core_Permission::VIEW) {
- $queryString = 'SELECT civicrm_uf_group.id, title, created_id, description, civicrm_uf_group.is_active, is_reserved, group_type
+ public static function getModuleUFGroup($moduleName = NULL, $count = 0, $skipPermission = TRUE, $op = CRM_Core_Permission::VIEW, $returnFields = NULL) {
+ $selectFields = array('id', 'title', 'created_id', 'is_active', 'is_reserved', 'group_type');
+
+ if (!CRM_Core_Config::isUpgradeMode()) {
+ // CRM-13555, since description field was added later (4.4), and to avoid any problems with upgrade
+ $selectFields[] = 'description';
+ }
+
+ if (!empty($returnFields)) {
+ $selectFields = array_merge($returnFields, array_diff($selectFields, $returnFields));
+ }
+
+ $queryString = 'SELECT civicrm_uf_group.' . implode(', civicrm_uf_group.', $selectFields) . '
FROM civicrm_uf_group
LEFT JOIN civicrm_uf_join ON (civicrm_uf_group.id = uf_group_id)';
$p = array();
) {
continue;
}
- $ufGroups[$dao->id]['name'] = $dao->title;
- $ufGroups[$dao->id]['title'] = $dao->title;
- $ufGroups[$dao->id]['created_id'] = $dao->created_id;
- $ufGroups[$dao->id]['description'] = $dao->description;
- $ufGroups[$dao->id]['is_active'] = $dao->is_active;
- $ufGroups[$dao->id]['group_type'] = $dao->group_type;
- $ufGroups[$dao->id]['is_reserved'] = $dao->is_reserved;
+ foreach ($selectFields as $key => $field) {
+ if($field == 'id') {
+ continue;
+ }
+ elseif ($field == 'name') {
+ $ufGroups[$dao->id][$field] = $dao->title;
+ continue;
+ }
+ $ufGroups[$dao->id][$field] = $dao->$field;
+ }
}
// Allow other modules to alter/override the UFGroups.
$form->addRule($name, ts('%1 is a required field.', array(1 => $title)), 'required');
}
}
- elseif ($fieldName === 'prefix_id') {
- $form->add('select', $name, $title,
- array(
- '' => ts('- select -')) + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'), $required
- );
- }
- elseif ($fieldName === 'suffix_id') {
+ elseif ($fieldName === 'prefix_id' || $fieldName === 'suffix_id') {
$form->add('select', $name, $title,
array(
- '' => ts('- select -')) + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id'), $required
+ '' => ts('- select -')) + CRM_Core_PseudoConstant::get('CRM_Contact_BAO_Contact', $fieldName), $required
);
}
elseif ($fieldName === 'contact_sub_type') {
$defaults[$fldName] = $value['county_id'];
}
elseif ($fieldName == 'country') {
- $defaults[$fldName] = $value['country_id'];
if (!isset($value['country_id']) || !$value['country_id']) {
$config = CRM_Core_Config::singleton();
if ($config->defaultContactCountry) {
$defaults[$fldName] = $config->defaultContactCountry;
}
}
+ else {
+ $defaults[$fldName] = $value['country_id'];
+ }
}
elseif ($fieldName == 'phone') {
if ($phoneTypeId) {
foreach ($emailList as $emailTo) {
// FIXME: take the below out of the foreach loop
- CRM_Core_BAO_MessageTemplates::sendTemplate(
+ CRM_Core_BAO_MessageTemplate::sendTemplate(
array(
'groupName' => 'msg_tpl_workflow_uf',
'valueName' => 'uf_notify',
}
}
else {
+ // TODO: prefix, suffix and gender translation may no longer be necessary - check inputs
if ($key === 'individual_suffix') {
$data['suffix_id'] = $value;
}
*
* @return void.
*/
- function setComponentDefaults(&$fields, $componentId, $component, &$defaults, $isStandalone = FALSE) {
+ public static function setComponentDefaults(&$fields, $componentId, $component, &$defaults, $isStandalone = FALSE) {
if (!$componentId ||
!in_array($component, array('Contribute', 'Membership', 'Event', 'Activity'))
) {