Commit 6f94427
committed
Add Orderable capacity and per-user permission filtering for GLPI 11 custom assets
Following review feedback on #574, replace the unconditional
auto-registration of all active custom asset definitions with an explicit,
admin-controlled opt-in via a new Orderable capacity:
- Introduce PluginOrderOrderableCapacity (extends \Glpi\Asset\Capacity\AbstractCapacity).
Admins enable/disable it per asset definition under
Setup -> Asset definitions -> {asset} -> Capacities. Provides label, icon,
description, and a usage count based on existing PluginOrderReference rows.
- In plugin_init_order(), register the capacity with AssetDefinitionManager,
then iterate active definitions and append the generated asset class to
$ORDER_TYPES only when:
1. the Orderable capacity is enabled on that definition, AND
2. the current user passes $class::canView()
(which delegates to the asset's AssignableItem READ check + is_active).
- The class_exists() guard preserves backward compatibility on GLPI <= 10.x.
End-to-end tested on GLPI 11.0.6, PHP 8.3, Order plugin 2.12.6:
- Capacity appears in the Capacities tab with proper label/icon/description.
- With capacity disabled: custom asset is absent from the Item type dropdown.
- With capacity enabled: custom asset appears, references can be created,
Generate item massive action renders and submits, items reach Taken
delivery state, and generated assets appear in the Assets section.
- Native itemtypes remain unaffected.
Addresses review comments from @stonebuzz on #574.1 parent 43f4e95 commit 6f94427
3 files changed
Lines changed: 71 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
128 | 151 | | |
129 | 152 | | |
130 | 153 | | |
| |||
0 commit comments