Adding this was mostly to make the syntax conformance happy since adding a navigation.reset action:
*/
public static function add(&$params) {
$navigation = new CRM_Core_DAO_Navigation();
-
- $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
- $params['has_separator'] = CRM_Utils_Array::value('has_separator', $params, FALSE);
+ if (empty($params['id'])) {
+ $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
+ $params['has_separator'] = CRM_Utils_Array::value('has_separator', $params, FALSE);
+ }
if (!isset($params['id']) ||
(CRM_Utils_Array::value('parent_id', $params) != CRM_Utils_Array::value('current_parent_id', $params))
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.6 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ * This api exposes CiviCRM Navigation BAO.
+ *
+ * @package CiviCRM_APIv3
+ */
+
+/**
+ * Adjust metadata for navigation reset action.
+ *
+ * @param array $params
+ */
+function _civicrm_api3_navigation_get_spec(&$params) {
+}
+
+/**
+ * Reset navigation.
+ *
+ * @param array $params
+ * Array of name/value pairs.
+ *
+ * @return array
+ * API result array.
+ */
+function civicrm_api3_navigation_get($params) {
+ return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
+
+/**
+ * Adjust metadata for navigation create action.
+ *
+ * @param array $params
+ */
+function _civicrm_api3_navigation_create_spec(&$params) {
+}
+
+/**
+ * Create navigation item.
+ *
+ * @param array $params
+ * Array of name/value pairs.
+ *
+ * @return array
+ * API result array.
+ */
+function civicrm_api3_navigation_create($params) {
+ return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
+
+/**
+ * Adjust metadata for navigation create action.
+ *
+ * @param array $params
+ */
+function _civicrm_api3_navigation_delete_spec(&$params) {
+}
+
+/**
+ * Create navigation item.
+ *
+ * @param array $params
+ * Array of name/value pairs.
+ *
+ * @return array
+ * API result array.
+ */
+function civicrm_api3_navigation_delete($params) {
+ return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
--- /dev/null
+<?php
+/**
+ * +--------------------------------------------------------------------+
+ * | CiviCRM version 4.7 |
+ * +--------------------------------------------------------------------+
+ * | Copyright CiviCRM LLC (c) 2004-2015 |
+ * +--------------------------------------------------------------------+
+ * | This file is a part of CiviCRM. |
+ * | |
+ * | CiviCRM is free software; you can copy, modify, and distribute it |
+ * | under the terms of the GNU Affero General Public License |
+ * | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ * | |
+ * | CiviCRM is distributed in the hope that it will be useful, but |
+ * | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ * | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ * | See the GNU Affero General Public License for more details. |
+ * | |
+ * | You should have received a copy of the GNU Affero General Public |
+ * | License and the CiviCRM Licensing Exception along |
+ * | with this program; if not, contact CiviCRM LLC |
+ * | at info[AT]civicrm[DOT]org. If you have questions about the |
+ * | GNU Affero General Public License or the licensing of CiviCRM, |
+ * | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ * +--------------------------------------------------------------------+
+ */
+
+require_once 'CiviTest/CiviUnitTestCase.php';
+
+/**
+ * Class api_v3_NavigationTest
+ */
+class api_v3_NavigationTest extends CiviUnitTestCase {
+ protected $_apiversion = 3;
+ protected $_params;
+
+ protected $_entity = 'Navigation';
+
+ /**
+ * Test get function.
+ */
+ public function testGet() {
+ $this->callAPISuccess($this->_entity, 'getsingle', array('label' => 'Manage Groups', 'domain_id' => 1));
+ }
+
+ /**
+ * Test create function.
+ */
+ public function testCreate() {
+ $params = array('label' => 'Feed the Goats', 'domain_id' => 1);
+ $result = $this->callAPISuccess($this->_entity, 'create', $params);
+ $this->getAndCheck($params, $result['id'], $this->_entity, TRUE);
+ }
+
+ /**
+ * Test delete function.
+ */
+ public function testDelete() {
+ $getParams = array(
+ 'return' => 'id',
+ 'options' => array('limit' => 1),
+ );
+ $result = $this->callAPISuccess('Navigation', 'getvalue', $getParams);
+ $this->callAPISuccess('Navigation', 'delete', array('id' => $result));
+ $this->callAPIFailure('Navigation', 'getvalue', array('id' => $result));
+ }
+
+}
'is_primary',
),
),
+ 'Navigation' => array(
+ 'cant_update' => array(
+ // Weight is deliberately altered when this is changed - skip.
+ 'parent_id',
+ ),
+ ),
'Pledge' => array(
'cant_update' => array(
'pledge_original_installment_amount',