4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.4 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2013 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
30 * File for the CiviCRM APIv3 domain functions
32 * @package CiviCRM_APIv3
33 * @subpackage API_Domain
35 * @copyright CiviCRM LLC (c) 2004-2013
36 * @version $Id: Domain.php 30171 2010-10-14 09:11:27Z mover $
41 * Get CiviCRM domain details
42 * {@getfields domain_create}
43 * @example DomainGet.php
45 function civicrm_api3_domain_get($params) {
47 $params['version'] = CRM_Utils_array
::value('domain_version', $params);
48 unset($params['version']);
50 $bao = new CRM_Core_BAO_Domain();
51 if (CRM_Utils_Array
::value('current_domain', $params)) {
52 $domainBAO = CRM_Core_Config
::domainID();
53 $params['id'] = $domainBAO;
56 _civicrm_api3_dao_set_filter($bao, $params, true, 'domain');
57 $domains = _civicrm_api3_dao_to_array($bao, $params, true,'domain');
59 foreach ($domains as $domain) {
60 if(!empty($domain['contact_id'])){
63 'contact_id' => $domain['contact_id']
65 $values['location'] = CRM_Core_BAO_Location
::getValues($locparams, TRUE);
67 $address_array = array(
68 'street_address', 'supplemental_address_1', 'supplemental_address_2',
69 'city', 'state_province_id', 'postal_code', 'country_id',
70 'geo_code_1', 'geo_code_2',
73 if ( !empty( $values['location']['email'] ) ) {
74 $domain['domain_email'] = CRM_Utils_Array
::value('email', $values['location']['email'][1]);
77 if ( !empty( $values['location']['phone'] ) ) {
78 $domain['domain_phone'] = array(
79 'phone_type' => CRM_Core_OptionGroup
::getLabel(
81 CRM_Utils_Array
::value(
83 $values['location']['phone'][1]
86 'phone' => CRM_Utils_Array
::value(
88 $values['location']['phone'][1]
93 if ( !empty( $values['location']['address'] ) ) {
94 foreach ($address_array as $value) {
95 $domain['domain_address'][$value] = CRM_Utils_Array
::value($value,
96 $values['location']['address'][1]
101 list($domain['from_name'],
102 $domain['from_email']
103 ) = CRM_Core_BAO_Domain
::getNameAndEmail(TRUE);
104 $domains[$domain['id']] = array_merge($domains[$domain['id']], $domain);
109 return civicrm_api3_create_success($domains, $params, 'domain', 'get', $bao);
113 * Adjust Metadata for Get action
115 * The metadata is used for setting defaults, documentation & validation
116 * @param array $params array or parameters determined by getfields
118 function _civicrm_api3_domain_get_spec(&$params) {
119 $params['current_domain'] = array('title' => "get loaded domain");
123 * Create a new domain
125 * @param array $params
128 * @example DomainCreate.php
129 * {@getfields domain_create}
131 function civicrm_api3_domain_create($params) {
132 $params['version'] = $params['domain_version'];
133 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__
), $params);
137 * Adjust Metadata for Create action
139 * The metadata is used for setting defaults, documentation & validation
140 * @param array $params array or parameters determined by getfields
142 function _civicrm_api3_domain_create_spec(&$params) {
143 $params['domain_version'] = $params['version'];
144 $params['domain_version']['api.required'] = 1;
145 unset($params['version']);
146 $params['name']['api.required'] = 1;