Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed

- Fix default entity insertion for a user
- Fixed `SQL` error when creating new injection model

## [2.14.0] - 2024-10-10

Expand Down
42 changes: 21 additions & 21 deletions inc/model.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1340,29 +1340,29 @@ public static function checkRightOnModel($models_id)
/** @var DBmysql $DB */
global $DB;

$model = new self();
$model->getFromDB($models_id);

$continue = true;

$query = "(SELECT `itemtype`
FROM `glpi_plugin_datainjection_models`
WHERE `id` = '" . $models_id . "')
UNION (SELECT DISTINCT `itemtype`
FROM `glpi_plugin_datainjection_mappings`
WHERE `models_id` = '" . $models_id . "')
UNION (SELECT DISTINCT `itemtype`
FROM `glpi_plugin_datainjection_infos`
WHERE `models_id` = '" . $models_id . "')";
foreach ($DB->request($query) as $data) {
if ($data['itemtype'] != PluginDatainjectionInjectionType::NO_VALUE) {
if (class_exists($data['itemtype'])) {
$item = new $data['itemtype']();
$item->fields['itemtype'] = $model->fields['itemtype'];

if (!($item instanceof CommonDBRelation) && !$item->canCreate()) {
$continue = false;
break;
$model = new self();
if ($model->getFromDB($models_id)) {
$query = "(SELECT `itemtype`
FROM `glpi_plugin_datainjection_models`
WHERE `id` = '" . $models_id . "')
UNION (SELECT DISTINCT `itemtype`
FROM `glpi_plugin_datainjection_mappings`
WHERE `models_id` = '" . $models_id . "')
UNION (SELECT DISTINCT `itemtype`
FROM `glpi_plugin_datainjection_infos`
WHERE `models_id` = '" . $models_id . "')";
foreach ($DB->request($query) as $data) {
if ($data['itemtype'] != PluginDatainjectionInjectionType::NO_VALUE) {
if (class_exists($data['itemtype'])) {
$item = new $data['itemtype']();
$item->fields['itemtype'] = $model->fields['itemtype'];

if (!($item instanceof CommonDBRelation) && !$item->canCreate()) {
$continue = false;
break;
}
}
}
}
Expand Down
Loading