Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | // $Id$ | |
3 | ||
4 | /* | |
5 | +--------------------------------------------------------------------+ | |
6 | | CiviCRM version 4.3 | | |
7 | +--------------------------------------------------------------------+ | |
8 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
9 | +--------------------------------------------------------------------+ | |
10 | | This file is a part of CiviCRM. | | |
11 | | | | |
12 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
13 | | under the terms of the GNU Affero General Public License | | |
14 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
15 | | | | |
16 | | CiviCRM is distributed in the hope that it will be useful, but | | |
17 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
18 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
19 | | See the GNU Affero General Public License for more details. | | |
20 | | | | |
21 | | You should have received a copy of the GNU Affero General Public | | |
22 | | License and the CiviCRM Licensing Exception along | | |
23 | | with this program; if not, contact CiviCRM LLC | | |
24 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
25 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
26 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
27 | +--------------------------------------------------------------------+ | |
28 | */ | |
29 | ||
30 | /** | |
31 | * File for the CiviCRM APIv3 website functions | |
32 | * | |
33 | * @package CiviCRM_APIv3 | |
34 | * @subpackage API_Website | |
35 | * | |
36 | * @copyright CiviCRM LLC (c) 2004-2013 | |
37 | * @version $Id: Website.php 2011-03-16 ErikHommel $ | |
38 | */ | |
39 | ||
40 | require_once 'CRM/Core/BAO/Website.php'; | |
41 | ||
42 | /** | |
43 | * Add an Website for a contact | |
44 | * | |
45 | * Allowed @params array keys are: | |
46 | * {@getfields website_create} | |
47 | * @example WebsiteCreate.php | |
48 | * {@example WebsiteCreate.php} | |
49 | * | |
50 | * @return array of newly created website property values. | |
51 | * @access public | |
52 | * @todo convert to using basic create - BAO function non-std | |
53 | */ | |
54 | function civicrm_api3_website_create($params) { | |
55 | //DO NOT USE THIS FUNCTION AS THE BASIS FOR A NEW API http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
56 | ||
57 | $websiteBAO = CRM_Core_BAO_Website::add($params); | |
58 | $values = array(); | |
59 | _civicrm_api3_object_to_array($websiteBAO, $values[$websiteBAO->id]); | |
60 | return civicrm_api3_create_success($values, $params, 'website', 'get'); | |
11e09c59 | 61 | } |
6a488035 | 62 | |
11e09c59 | 63 | /** |
6a488035 TO |
64 | * Adjust Metadata for Create action |
65 | * | |
66 | * The metadata is used for setting defaults, documentation & validation | |
67 | * @param array $params array or parameters determined by getfields | |
68 | */ | |
69 | function _civicrm_api3_website_create_spec(&$params) { | |
70 | $params['contact_id']['api.required'] = 1; | |
71 | } | |
72 | ||
73 | /** | |
74 | * Deletes an existing Website | |
75 | * | |
76 | * @param array $params | |
77 | * {@getfields website_delete} | |
78 | * @example WebsiteDelete.php Std Delete Example | |
79 | * | |
80 | * @return array API result Array | |
81 | * @access public | |
82 | * @todo convert to using Basic delete - BAO function non standard | |
83 | */ | |
84 | function civicrm_api3_website_delete($params) { | |
85 | //DO NOT USE THIS FUNCTION AS THE BASIS FOR A NEW API http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
86 | $websiteID = CRM_Utils_Array::value('id', $params); | |
87 | ||
88 | $websiteDAO = new CRM_Core_DAO_Website(); | |
89 | $websiteDAO->id = $websiteID; | |
90 | if ($websiteDAO->find()) { | |
91 | while ($websiteDAO->fetch()) { | |
92 | $websiteDAO->delete(); | |
93 | return civicrm_api3_create_success(1, $params, 'website', 'delete'); | |
94 | } | |
95 | } | |
96 | else { | |
97 | return civicrm_api3_create_error('Could not delete website with id ' . $websiteID); | |
98 | } | |
99 | } | |
100 | ||
101 | /** | |
102 | * Retrieve one or more websites | |
103 | * | |
104 | * @param mixed[] (reference ) input parameters | |
105 | * {@getfields website_get} | |
106 | * {@example WebsiteGet.php 0} | |
107 | * @example WebsiteGet.php | |
108 | * @param array $params an associative array of name/value pairs. | |
109 | * | |
110 | * @return array details of found websites | |
111 | * | |
112 | * @access public | |
113 | */ | |
114 | function civicrm_api3_website_get($params) { | |
115 | return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); | |
116 | } | |
117 |