Skip to content

Commit

Permalink
Add locations_id to items_devicecamera
Browse files Browse the repository at this point in the history
fixes #16561
  • Loading branch information
trasher committed Feb 21, 2024
1 parent 375e81f commit 8ea8781
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions inc/relation.constant.php
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@
'glpi_devicesensors' => 'locations_id',
'glpi_enclosures' => 'locations_id',
'glpi_items_devicebatteries' => 'locations_id',
'glpi_items_devicecameras' => 'locations_id',
'glpi_items_devicecases' => 'locations_id',
'glpi_items_devicecontrols' => 'locations_id',
'glpi_items_devicedrives' => 'locations_id',
Expand Down
43 changes: 43 additions & 0 deletions install/migrations/update_10.0.12_to_10.0.13/location.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/**
* ---------------------------------------------------------------------
*
* GLPI - Gestionnaire Libre de Parc Informatique
*
* http://glpi-project.org
*
* @copyright 2015-2024 Teclib' and contributors.
* @copyright 2003-2014 by the INDEPNET Development Team.
* @licence https://www.gnu.org/licenses/gpl-3.0.html
*
* ---------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GLPI.
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
*
* ---------------------------------------------------------------------
*/

/**
* @var \Migration $migration
*/

$migration->addField('glpi_items_devicecameras', 'locations_id', "fkey", [
'after' => 'is_recursive',
]);
$migration->addKey('glpi_items_devicecameras', 'locations_id');
2 changes: 2 additions & 0 deletions install/mysql/glpi-empty.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1984,13 +1984,15 @@ CREATE TABLE `glpi_items_devicecameras` (
`is_dynamic` tinyint NOT NULL DEFAULT '0',
`entities_id` int unsigned NOT NULL DEFAULT '0',
`is_recursive` tinyint NOT NULL DEFAULT '0',
`locations_id` int unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `items_id` (`items_id`),
KEY `devicecameras_id` (`devicecameras_id`),
KEY `is_deleted` (`is_deleted`),
KEY `is_dynamic` (`is_dynamic`),
KEY `entities_id` (`entities_id`),
KEY `is_recursive` (`is_recursive`),
KEY `locations_id` (`locations_id`),
KEY `item` (`itemtype`,`items_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

Expand Down
2 changes: 2 additions & 0 deletions tests/functional/Glpi/Inventory/Inventory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5527,6 +5527,7 @@ public function testImportPhone()
'is_dynamic' => 1,
'entities_id' => 0,
'is_recursive' => 0,
'locations_id' => 0,
], [
'items_id' => $phones_id,
'itemtype' => 'Phone',
Expand All @@ -5535,6 +5536,7 @@ public function testImportPhone()
'is_dynamic' => 1,
'entities_id' => 0,
'is_recursive' => 0,
'locations_id' => 0,
]
]
];
Expand Down
10 changes: 10 additions & 0 deletions tests/functional/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,4 +316,14 @@ public function testImport(array $input, array $imported): void
$this->integer(countElementsInTable(\Location::getTable(), $location_data))->isEqualTo(1, json_encode($location_data));
}
}

public function testMaybeLocated()
{
global $CFG_GLPI;

foreach ($CFG_GLPI['location_types'] as $type) {
$item = new $type();
$this->boolean($item->maybeLocated())->isTrue($type . ' cannot be located!');
}
}
}

0 comments on commit 8ea8781

Please sign in to comment.