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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [UNRELEASED]
## [unreleased] -

### Fixed

- Fix `name` and `locations_id` when updating the `completename`
- Fix user field updates and email import

## [2.15.2] - 2025-11-25
Expand Down
2 changes: 1 addition & 1 deletion inc/commoninjectionlib.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1648,7 +1648,7 @@ private function effectiveAddOrUpdate($injectionClass, $item, $values, $add = tr

if (!empty($option) && self::isFieldADropdown($option['displaytype']) && $value == self::EMPTY_VALUE) {
//If field is a dropdown and value is '', then replace it by 0
continue;
$toinject[$key] = 0;
} else {
// Skip empty values for fields that cannot accept empty strings during updates
// Check if the field is nullable using the injection class method
Expand Down
43 changes: 42 additions & 1 deletion inc/locationinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,36 @@



/**
* -------------------------------------------------------------------------
* DataInjection plugin for GLPI
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of DataInjection.
*
* DataInjection is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* DataInjection is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DataInjection. If not, see <http://www.gnu.org/licenses/>.
* -------------------------------------------------------------------------
* @copyright Copyright (C) 2007-2023 by DataInjection plugin team.
* @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
* @link https://github.com/pluginsGLPI/datainjection
* -------------------------------------------------------------------------
*/



class PluginDatainjectionLocationInjection extends Location implements PluginDatainjectionInjectionInterface
{
public static function getTable($classname = null)
Expand Down Expand Up @@ -83,9 +113,20 @@ public function getOptions($primary_type = '')
**/
public function addOrUpdateObject($values = [], $options = [])
{

$values = $this->fixLocationTreeStructure($values);
$lib = new PluginDatainjectionCommonInjectionLib($this, $values, $options);
$lib->processAddOrUpdate();
return $lib->getInjectionResults();
}

public function fixLocationTreeStructure($values)
{
if (isset($values['Location']['completename']) && !isset($values['Location']['name']) && !str_contains($values['Location']['completename'], '>')) {
$values['Location']['name'] = trim($values['Location']['completename']);
$values['Location']['locations_id'] = '0';
$values['Location']['ancestors_cache'] = '[]';
}

return $values;
}
}