Merge pull request #16733 from eileenmcnaughton/smarty
[civicrm-core.git] / api / v3 / Dashboard.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 * This api exposes CiviCRM Dashboard.
14 *
15 * @package CiviCRM_APIv3
16 */
17
18 /**
19 * Creates or updates an Dashlet.
20 *
21 * @param array $params
22 *
23 * @return array
24 * Array containing 'is_error' to denote success or failure and details of the created activity
25 */
26 function civicrm_api3_dashboard_create($params) {
27 civicrm_api3_verify_one_mandatory($params, NULL, [
28 'name',
29 'label',
30 'url',
31 'fullscreen_url',
32 ]);
33 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Dashboard');
34 }
35
36 /**
37 * Specify Meta data for create.
38 *
39 * Note that this data is retrievable via the getfields function
40 * and is used for pre-filling defaults and ensuring mandatory requirements are met.
41 *
42 * @param array $params
43 * array of parameters determined by getfields.
44 */
45 function _civicrm_api3_dashboard_create_spec(&$params) {
46 $params['is_active']['api.default'] = 1;
47 unset($params['version']);
48 }
49
50 /**
51 * Gets a CiviCRM Dashlets according to parameters.
52 *
53 * @param array $params
54 *
55 * @return array
56 */
57 function civicrm_api3_dashboard_get($params) {
58 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
59 }
60
61 /**
62 * Delete a specified Dashlet.
63 *
64 * @param array $params
65 * Array holding 'id' of dashlet to be deleted.
66 * @return array
67 * @throws API_Exception
68 * @throws CiviCRM_API3_Exception
69 */
70 function civicrm_api3_dashboard_delete($params) {
71 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
72 }