| 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 | namespace Civi\Api4; |
| 12 | |
| 13 | /** |
| 14 | * (Read-only) Available permissions |
| 15 | * |
| 16 | * NOTE: This is a high-level API intended for introspective use by administrative tools. |
| 17 | * It may be poorly suited to recursive usage (e.g. permissions defined dynamically |
| 18 | * on top of permissions!) or during install/uninstall processes. |
| 19 | * |
| 20 | * @searchable none |
| 21 | * @since 5.34 |
| 22 | * @package Civi\Api4 |
| 23 | */ |
| 24 | class Permission extends Generic\AbstractEntity { |
| 25 | |
| 26 | /** |
| 27 | * @param bool $checkPermissions |
| 28 | * @return Action\Permission\Get |
| 29 | */ |
| 30 | public static function get($checkPermissions = TRUE) { |
| 31 | return (new Action\Permission\Get(__CLASS__, __FUNCTION__)) |
| 32 | ->setCheckPermissions($checkPermissions); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * @param bool $checkPermissions |
| 37 | * @return Generic\BasicGetFieldsAction |
| 38 | */ |
| 39 | public static function getFields($checkPermissions = TRUE) { |
| 40 | return (new Generic\BasicGetFieldsAction(__CLASS__, __FUNCTION__, function() { |
| 41 | return [ |
| 42 | [ |
| 43 | 'name' => 'group', |
| 44 | 'title' => 'Group', |
| 45 | 'data_type' => 'String', |
| 46 | ], |
| 47 | [ |
| 48 | 'name' => 'name', |
| 49 | 'title' => 'Name', |
| 50 | 'data_type' => 'String', |
| 51 | ], |
| 52 | [ |
| 53 | 'name' => 'title', |
| 54 | 'title' => 'Title', |
| 55 | 'data_type' => 'String', |
| 56 | ], |
| 57 | [ |
| 58 | 'name' => 'description', |
| 59 | 'title' => 'Description', |
| 60 | 'data_type' => 'String', |
| 61 | ], |
| 62 | [ |
| 63 | 'name' => 'is_synthetic', |
| 64 | 'title' => 'Is Synthetic', |
| 65 | 'data_type' => 'Boolean', |
| 66 | ], |
| 67 | [ |
| 68 | 'name' => 'is_active', |
| 69 | 'title' => 'Is Active', |
| 70 | 'description' => '', |
| 71 | 'default' => TRUE, |
| 72 | 'data_type' => 'Boolean', |
| 73 | ], |
| 74 | ]; |
| 75 | }))->setCheckPermissions($checkPermissions); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * @return array |
| 80 | */ |
| 81 | public static function permissions() { |
| 82 | return [ |
| 83 | "meta" => ["access CiviCRM"], |
| 84 | "default" => ["access CiviCRM"], |
| 85 | ]; |
| 86 | } |
| 87 | |
| 88 | } |