This gives consistency in how the fields are handled in the Navigation and Dashboard entities
*
* Generated from xml/schema/CRM/Core/Dashboard.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:0404bd5bf3e04c20da16ec1950db8ac0)
+ * (GenCodeChecksum:9603ee2a3a27196ef1ec671bf758a783)
*/
/**
'entity' => 'Dashboard',
'bao' => 'CRM_Core_BAO_Dashboard',
'localizable' => 0,
+ 'pseudoconstant' => [
+ 'callback' => 'CRM_Core_SelectValues::andOr',
+ ],
'add' => '3.1',
],
'fullscreen_url' => [
*
* Generated from xml/schema/CRM/Core/Navigation.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:2b9fb139d42e95f23ebc1fe7b055c546)
+ * (GenCodeChecksum:6400fef9c925231f0d6245030ec46e68)
*/
/**
public $icon;
/**
- * Permission for menu item
+ * Permission(s) needed to access menu item
*
* @var string
*/
public $permission;
/**
- * Permission Operator
+ * Operator to use if item has more than one permission
*
* @var string
*/
'name' => 'permission',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Required Permission'),
- 'description' => ts('Permission for menu item'),
+ 'description' => ts('Permission(s) needed to access menu item'),
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
'where' => 'civicrm_navigation.permission',
'entity' => 'Navigation',
'bao' => 'CRM_Core_BAO_Navigation',
'localizable' => 0,
+ 'serialize' => self::SERIALIZE_COMMA,
'add' => '3.0',
],
'permission_operator' => [
'name' => 'permission_operator',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Permission Operator'),
- 'description' => ts('Permission Operator'),
+ 'description' => ts('Operator to use if item has more than one permission'),
'maxlength' => 3,
'size' => CRM_Utils_Type::FOUR,
'where' => 'civicrm_navigation.permission_operator',
'entity' => 'Navigation',
'bao' => 'CRM_Core_BAO_Navigation',
'localizable' => 0,
+ 'pseudoconstant' => [
+ 'callback' => 'CRM_Core_SelectValues::andOr',
+ ],
'add' => '3.0',
],
'parent_id' => [
];
}
+ /**
+ * @return array
+ */
+ public static function andOr() {
+ return [
+ 'AND' => ts('And'),
+ 'OR' => ts('Or'),
+ ];
+ }
+
}
->addValue('icon', 'crm-i fa-search-plus')
->addValue('has_separator', 2)
->addValue('weight', 99)
- ->addValue('permission', 'administer CiviCRM data')
+ ->addValue('permission', ['administer CiviCRM data'])
->execute();
}
--- /dev/null
+<?php
+
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved. |
+ | |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC https://civicrm.org/licensing
+ */
+
+namespace api\v4\Entity;
+
+use api\v4\UnitTestCase;
+use Civi\Api4\Navigation;
+use Civi\Test\TransactionalInterface;
+
+/**
+ * @group headless
+ */
+class NavigationTest extends UnitTestCase implements TransactionalInterface {
+
+ public function testCreate() {
+ $created = Navigation::create(FALSE)
+ ->addValue('permission', ['administer CiviCRM', 'access CiviCRM'])
+ ->addValue('name', 'Test menu item')
+ ->execute()->single();
+
+ $fetched = Navigation::get(FALSE)
+ ->addWhere('id', '=', $created['id'])
+ ->execute()->single();
+
+ $this->assertEquals(['administer CiviCRM', 'access CiviCRM'], $created['permission']);
+ $this->assertEquals(\CRM_Core_Config::domainID(), $fetched['domain_id']);
+ $this->assertGreaterThan(0, $fetched['weight']);
+ }
+
+}
<type>varchar</type>
<title>Dashlet Permission Operator</title>
<length>3</length>
+ <pseudoconstant>
+ <callback>CRM_Core_SelectValues::andOr</callback>
+ </pseudoconstant>
<comment>Permission Operator</comment>
<add>3.1</add>
</field>
<title>Required Permission</title>
<type>varchar</type>
<length>255</length>
- <comment>Permission for menu item</comment>
+ <comment>Permission(s) needed to access menu item</comment>
+ <serialize>COMMA</serialize>
<add>3.0</add>
</field>
<field>
<title>Permission Operator</title>
<type>varchar</type>
<length>3</length>
- <comment>Permission Operator</comment>
+ <pseudoconstant>
+ <callback>CRM_Core_SelectValues::andOr</callback>
+ </pseudoconstant>
+ <comment>Operator to use if item has more than one permission</comment>
<add>3.0</add>
</field>
<field>