2 // $Id: Domain.php 45502 2013-02-08 13:32:55Z kurund $
6 +--------------------------------------------------------------------+
7 | CiviCRM version 4.3 |
8 +--------------------------------------------------------------------+
9 | Copyright CiviCRM LLC (c) 2004-2013 |
10 +--------------------------------------------------------------------+
11 | This file is a part of CiviCRM. |
13 | CiviCRM is free software; you can copy, modify, and distribute it |
14 | under the terms of the GNU Affero General Public License |
15 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
17 | CiviCRM is distributed in the hope that it will be useful, but |
18 | WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
20 | See the GNU Affero General Public License for more details. |
22 | You should have received a copy of the GNU Affero General Public |
23 | License and the CiviCRM Licensing Exception along |
24 | with this program; if not, contact CiviCRM LLC |
25 | at info[AT]civicrm[DOT]org. If you have questions about the |
26 | GNU Affero General Public License or the licensing of CiviCRM, |
27 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
28 +--------------------------------------------------------------------+
32 * File for the CiviCRM APIv2 domain functions
34 * @package CiviCRM_APIv2
35 * @subpackage API_Domain
37 * @copyright CiviCRM LLC (c) 2004-2013
38 * @version $Id: Domain.php 45502 2013-02-08 13:32:55Z kurund $
43 * Include utility functions
45 require_once 'api/v2/utils.php';
48 * Generic file to retrieve all the constants and
49 * pseudo constants used in CiviCRM
52 function civicrm_domain_get() {
53 require_once 'CRM/Core/BAO/Domain.php';
54 $dao = CRM_Core_BAO_Domain
::getDomain();
57 'entity_id' => $dao->id
,
58 'entity_table' => 'civicrm_domain',
60 require_once 'CRM/Core/BAO/Location.php';
61 $values['location'] = CRM_Core_BAO_Location
::getValues($params, TRUE);
62 $address_array = array(
63 'street_address', 'supplemental_address_1', 'supplemental_address_2',
64 'city', 'state_province_id', 'postal_code', 'country_id', 'geo_code_1', 'geo_code_2',
66 require_once 'CRM/Core/OptionGroup.php';
67 $domain[$dao->id
] = array(
69 'domain_name' => $dao->name
,
70 'description' => $dao->description
,
71 'domain_email' => CRM_Utils_Array
::value('email', $values['location']['email'][1]),
72 'domain_phone' => array(
73 'phone_type' => CRM_Core_OptionGroup
::getLabel('phone_type', CRM_Utils_Array
::value('phone_type_id', $values['location']['phone'][1])),
74 'phone' => CRM_Utils_Array
::value('phone', $values['location']['phone'][1]),
77 foreach ($address_array as $value) {
78 $domain[$dao->id
]['domain_address'][$value] = CRM_Utils_Array
::value($value, $values['location']['address'][1]);
80 list($domain[$dao->id
]['from_name'], $domain[$dao->id
]['from_email']) = CRM_Core_BAO_Domain
::getNameAndEmail();
87 * @param array $params
91 function civicrm_domain_create($params) {
92 require_once 'CRM/Core/BAO/Domain.php';
94 if (!is_array($params)) {
95 return civicrm_create_error('Params need to be of type array!');
99 return civicrm_create_error('Params cannot be empty!');
102 $domain = CRM_Core_BAO_Domain
::create($params);
103 $domain_array = array();
104 _civicrm_object_to_array($domain, $domain_array);
105 return $domain_array;