Merge pull request #19307 from eileenmcnaughton/534
[civicrm-core.git] / api / v3 / Navigation.php
CommitLineData
3523b615 1<?php
2/*
3 +--------------------------------------------------------------------+
a30c801b 4 | Copyright CiviCRM LLC. All rights reserved. |
3523b615 5 | |
a30c801b
TO
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 |
3523b615 9 +--------------------------------------------------------------------+
10 */
11
12/**
13 * This api exposes CiviCRM Navigation BAO.
14 *
15 * @package CiviCRM_APIv3
16 */
17
18/**
19 * Adjust metadata for navigation reset action.
20 *
21 * @param array $params
22 */
31cb1898
AN
23function _civicrm_api3_navigation_reset_spec(&$params) {
24 $params['for']['api.required'] = TRUE;
25 $params['for']['title'] = "Is this reset for all navigation or reports";
26 $params['for']['type'] = CRM_Utils_Type::T_STRING;
cf8f0fff 27 $params['for']['options'] = [
31cb1898
AN
28 'all' => 'General Navigation rebuild from xml',
29 'report' => 'Reset report menu to default structure',
cf8f0fff 30 ];
31cb1898
AN
31 $params['domain_id']['api.default'] = CRM_Core_Config::domainID();
32 $params['domain_id']['type'] = CRM_Utils_Type::T_INT;
33 $params['domain_id']['title'] = 'Domain ID';
34}
35
36/**
37 * Reset navigation.
38 *
39 * @param array $params
40 * Array of name/value pairs.
41 *
42 * @return array
43 * API result array.
44 */
45function civicrm_api3_navigation_reset($params) {
46 if ($params['for'] == 'report') {
533ccb95 47 CRM_Core_BAO_Navigation::rebuildReportsNavigation($params['domain_id']);
31cb1898 48 }
533ccb95 49 CRM_Core_BAO_Navigation::resetNavigation();
31cb1898
AN
50 return civicrm_api3_create_success(1, $params, 'navigation', 'reset');
51}
52
53/**
54 * Adjust metadata for navigation get action.
55 *
56 * @param array $params
57 */
3523b615 58function _civicrm_api3_navigation_get_spec(&$params) {
59}
60
61/**
62 * Reset navigation.
63 *
64 * @param array $params
65 * Array of name/value pairs.
66 *
67 * @return array
68 * API result array.
69 */
70function civicrm_api3_navigation_get($params) {
71 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
72}
73
3523b615 74/**
75 * Create navigation item.
76 *
77 * @param array $params
78 * Array of name/value pairs.
79 *
80 * @return array
81 * API result array.
82 */
83function civicrm_api3_navigation_create($params) {
cf8f0fff 84 civicrm_api3_verify_one_mandatory($params, NULL, ['name', 'label']);
a25b46e9 85 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Navigation');
3523b615 86}
87
88/**
89 * Adjust metadata for navigation create action.
90 *
91 * @param array $params
92 */
93function _civicrm_api3_navigation_delete_spec(&$params) {
94}
95
96/**
31cb1898 97 * Delete navigation item.
3523b615 98 *
99 * @param array $params
100 * Array of name/value pairs.
101 *
102 * @return array
103 * API result array.
104 */
105function civicrm_api3_navigation_delete($params) {
106 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
107}