Merge pull request #15622 from eileenmcnaughton/deprecate_bad
[civicrm-core.git] / api / v3 / Dashboard.php
CommitLineData
15d9b3ae 1<?php
15d9b3ae
N
2/*
3 +--------------------------------------------------------------------+
fee14197 4 | CiviCRM version 5 |
15d9b3ae 5 +--------------------------------------------------------------------+
6b83d5bd 6 | Copyright CiviCRM LLC (c) 2004-2019 |
15d9b3ae
N
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/**
c28e1768 29 * This api exposes CiviCRM Dashboard.
15d9b3ae
N
30 *
31 * @package CiviCRM_APIv3
15d9b3ae
N
32 */
33
15d9b3ae
N
34/**
35 * Creates or updates an Dashlet.
36 *
cf470720 37 * @param array $params
15d9b3ae 38 *
a6c01b45 39 * @return array
72b3a70c 40 * Array containing 'is_error' to denote success or failure and details of the created activity
15d9b3ae
N
41 */
42function civicrm_api3_dashboard_create($params) {
cf8f0fff 43 civicrm_api3_verify_one_mandatory($params, NULL, [
7c31ae57
SL
44 'name',
45 'label',
46 'url',
47 'fullscreen_url',
48 ]);
3cfa8e5e 49 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Dashboard');
15d9b3ae
N
50}
51
52/**
22242c87
EM
53 * Specify Meta data for create.
54 *
55 * Note that this data is retrievable via the getfields function
15d9b3ae 56 * and is used for pre-filling defaults and ensuring mandatory requirements are met.
22242c87 57 *
cf470720 58 * @param array $params
22242c87 59 * array of parameters determined by getfields.
15d9b3ae
N
60 */
61function _civicrm_api3_dashboard_create_spec(&$params) {
3f14cb24 62 $params['is_active']['api.default'] = 1;
15d9b3ae
N
63 unset($params['version']);
64}
65
66/**
d1b0d05e 67 * Gets a CiviCRM Dashlets according to parameters.
15d9b3ae 68 *
cf470720 69 * @param array $params
15d9b3ae
N
70 *
71 * @return array
15d9b3ae
N
72 */
73function civicrm_api3_dashboard_get($params) {
a25b46e9 74 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
15d9b3ae
N
75}
76
77/**
78 * Delete a specified Dashlet.
79 *
cf470720 80 * @param array $params
c23f45d3 81 * Array holding 'id' of dashlet to be deleted.
c23f45d3 82 * @return array
8089541a 83 * @throws API_Exception
15d9b3ae
N
84 */
85function civicrm_api3_dashboard_delete($params) {
86 if (CRM_Core_BAO_Dashboard::deleteDashlet($params['id'])) {
244bbdd8 87 return civicrm_api3_create_success(1, $params, 'Dashboard', 'delete');
15d9b3ae
N
88 }
89 else {
a60c0bc8 90 throw new API_Exception('Could not delete dashlet');
15d9b3ae 91 }
a7488080 92}