Repository navigation
Fix ticket observer can edit #1278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
77609cb
4d2b1e7
b9cd9f3
5558b6f
09eb9fa
9b45100
e143ff9
5866f58
3a5b8d3
90a42b0
4f25e35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2077,6 +2077,21 @@ public static function preItemUpdate(CommonDBTM $item) | |
| { | ||
| self::preItem($item); | ||
| if (array_key_exists('_plugin_fields_data', $item->input)) { | ||
| // Only save plugin fields if the user can update this specific item. | ||
| // Automated contexts (cron jobs, API without active profile) bypass this check. | ||
| if ( | ||
| isset($_SESSION['glpiactiveprofile']['id']) | ||
| && !$item->canUpdateItem() | ||
| ) { | ||
| unset($item->input['_plugin_fields_data']); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Submitted values are dropped silently and the item update still succeeds, so the user gets no feedback. Acceptable since the UI renders fields read-only, but a |
||
| Session::addMessageAfterRedirect( | ||
| __('You do not have the right to modify the fields of this item', 'fields'), | ||
| false, | ||
| WARNING, | ||
| ); | ||
| return true; | ||
| } | ||
|
|
||
| $data = $item->input['_plugin_fields_data']; | ||
| $data['itemtype'] = $item::class; | ||
| $data['entities_id'] = $item->isEntityAssign() ? $item->getEntityID() : 0; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -891,7 +891,7 @@ public static function showForTabContainer($c_id, $item) | |
| return null; | ||
| } | ||
|
|
||
| $canedit = $right > READ; | ||
| $canedit = $right > READ && ($item->isNewItem() || $item->canUpdateItem()); | ||
|
|
||
| //get fields for this container | ||
| $field_obj = new self(); | ||
|
|
@@ -1213,7 +1213,7 @@ public static function prepareHtmlFields( | |
| return null; | ||
| } | ||
|
|
||
| $canedit = $right > READ; | ||
| $canedit = $right > READ && ($item->isNewItem() || $item->canUpdateItem()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new |
||
|
|
||
| // Fill status overrides if needed | ||
| if (in_array($item->getType(), PluginFieldsStatusOverride::getStatusItemtypes())) { | ||
|
|
@@ -1349,7 +1349,7 @@ public static function prepareHtmlFields( | |
| $value = is_array($decoded) ? $decoded : []; | ||
| } | ||
|
|
||
| if ($field['multiple'] && is_array($value)) { | ||
| if ($field['multiple']) { | ||
| // Flatten any nested arrays caused by corrupted DB data (double-encoded values) | ||
| // so that Dropdown::show() always receives a flat list of scalars. | ||
| $value = array_values(array_filter( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scoping this to
helpdesk+CommonITILObjectreopens the bug for central-interface users without update right (e.g. an observer with onlyREADASSIGN). The patch validated on ticket !46589 used!$item->canUpdateItem()unconditionally, matching thefield.class.phpdisplay-side fix —Ticket::canUpdateItem()already handles both interfaces correctly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take care of it