1, ]; } } /** * Get campaign list output. * * @see _civicrm_api3_generic_getlist_output * * @param array $result * @param array $request * * @return array */ function _civicrm_api3_campaign_getlist_output($result, $request) { $output = []; if (!empty($result['values'])) { $config = CRM_Core_Config::singleton(); foreach ($result['values'] as $row) { $data = [ 'id' => $row[$request['id_field']], 'label' => $row[$request['label_field']], 'description' => [ CRM_Core_Pseudoconstant::getLabel('CRM_Campaign_BAO_Campaign', 'campaign_type_id', $row['campaign_type_id']), ], ]; if (!empty($row['status_id'])) { $data['description'][0] .= ': ' . CRM_Core_Pseudoconstant::getLabel('CRM_Campaign_BAO_Campaign', 'status_id', $row['status_id']); } $dateString = CRM_Utils_Date::customFormat($row['start_date'], $config->dateformatFull) . ' -'; if (!empty($row['end_date'])) { // Remove redundant years if (substr($row['start_date'], 0, 4) == substr($row['end_date'], 0, 4)) { $dateString = preg_replace('/[, ]*' . substr($row['start_date'], 0, 4) . '/', '', $dateString); } $dateString .= ' ' . CRM_Utils_Date::customFormat($row['end_date'], $config->dateformatFull); } $data['description'][] = $dateString; $output[] = $data; } } return $output; }