8e6001d9 |
1 | <?php |
2 | /* |
3 | +--------------------------------------------------------------------+ |
4 | | CiviCRM version 4.7 | |
5 | +--------------------------------------------------------------------+ |
6 | | Copyright CiviCRM LLC (c) 2004-2017 | |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | |
9 | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | |
11 | | under the terms of the GNU Affero General Public License | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | |
13 | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
17 | | See the GNU Affero General Public License for more details. | |
18 | | | |
19 | | You should have received a copy of the GNU Affero General Public | |
20 | | License and the CiviCRM Licensing Exception along | |
21 | | with this program; if not, contact CiviCRM LLC | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | |
25 | +--------------------------------------------------------------------+ |
26 | */ |
27 | |
28 | /** |
29 | * @package CiviCRM_APIv3 |
30 | */ |
31 | |
32 | /** |
33 | * Generic api wrapper used to get all unique fields for a given entity. |
34 | * |
35 | * @param array $apiRequest |
36 | * |
37 | * @return mixed |
38 | */ |
445eab89 |
39 | function civicrm_api3_generic_getunique($apiRequest) { |
8e6001d9 |
40 | $entity = _civicrm_api_get_entity_name_from_camel($apiRequest['entity']); |
41 | $uniqueFields = array(); |
42 | |
5f262bb2 |
43 | $dao = _civicrm_api3_get_DAO($entity); |
44 | $uFields = $dao::indices(); |
8e6001d9 |
45 | |
5f262bb2 |
46 | foreach($uFields as $fieldKey => $field) { |
47 | if(!isset($field['unique']) || !$field['unique']) { |
48 | continue; |
49 | } |
50 | $uniqueFields[$fieldKey] = $field['field']; |
8e6001d9 |
51 | } |
52 | |
53 | return civicrm_api3_create_success($uniqueFields); |
54 | } |
55 | |