Пример #1
0
 function addColumns()
 {
     // add all the fields for chosen groups
     $this->_tables = $this->_options = array();
     foreach ($this->_groupTree as $groupID => $group) {
         if (!CRM_Utils_Array::value($groupID, $this->_customGroupIDs)) {
             continue;
         }
         // now handle all the fields
         foreach ($group['fields'] as $fieldID => $field) {
             $this->_columns[$field['label']] = "custom_{$field['id']}";
             if (!array_key_exists($group['table_name'], $this->_tables)) {
                 $this->_tables[$group['table_name']] = array();
             }
             $this->_tables[$group['table_name']][$field['id']] = $field['column_name'];
             // also build the option array
             $this->_options[$field['id']] = array();
             CRM_Core_BAO_CustomField::buildOption($field, $this->_options[$field['id']]);
         }
     }
 }
 public static function getCustomFieldDataLabels($data)
 {
     if (empty($data)) {
         return $data;
     }
     $tempArray = array();
     $data = explode('<br/>', $data);
     foreach ($data as $value) {
         if (empty($value)) {
             continue;
         }
         $value = explode('::::', $value);
         if (CRM_Utils_Array::value(1, $value)) {
             if (empty(self::$_customFieldOptions[$value[1]])) {
                 $result = civicrm_api3('CustomField', 'getsingle', array('sequential' => 1, 'id' => $value[1]));
                 $options[$value[1]] = array();
                 CRM_Core_BAO_CustomField::buildOption($result, $options[$value[1]]);
                 self::$_customFieldOptions[$value[1]] = $options;
             }
             $tempArray[] = CRM_Core_BAO_CustomField::getDisplayValue($value[0], $value[1], self::$_customFieldOptions[$value[1]]);
         } else {
             $tempArray[] = $value[0];
         }
     }
     return implode('<br/>', $tempArray);
 }