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
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
name: "Generate CI matrix"
uses: "glpi-project/plugin-ci-workflows/.github/workflows/generate-ci-matrix.yml@v1"
with:
glpi-version: "11.0.x"
glpi-version: "12.0.x"
ci:
name: "GLPI ${{ matrix.glpi-version }} - php:${{ matrix.php-version }} - ${{ matrix.db-image }}"
needs: "generate-ci-matrix"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ vendor/
.gh_token
*.min.*
var/
.phpunit.result.cache
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Added

- GLPI 12 compatibility

### Fixed

- CI: fix Psalm cache directory, drop the stray `glpi-project/tools` composer dependency, declare a unique composer autoloader suffix
Expand Down
5 changes: 3 additions & 2 deletions ajax/agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
*/

use Glpi\Exception\Http\NotFoundHttpException;
use Glpi\Inventory\Conf;

use function Safe\json_encode;

Expand All @@ -38,8 +39,8 @@
Html::header_nocache();

Session::checkLoginUser();
Session::checkRight("inventory", READ);
Session::checkRight("database_inventory", PluginDatabaseinventoryProfile::RUN_DATABSE_INVENTORY);
Session::checkRight(Conf::class, READ);
Session::checkRight(PluginDatabaseinventoryDatabaseParam::class, PluginDatabaseinventoryProfile::RUN_DATABSE_INVENTORY);

if (isset($_POST['action']) && isset($_POST['id'])) {
$agent = new Agent();
Expand Down
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"GlpiPlugin\\DatabaseInventory\\Tests\\": "tests"
}
},
"autoload-dev": {
"psr-4": {
"Glpi\\Tools\\": "../../tools/src/"
Expand Down
10 changes: 3 additions & 7 deletions front/computergroup.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,11 @@

use Glpi\Event;

Session::checkRight('config', READ);
Session::checkRight(Config::$rightname, READ);

if (!isset($_GET['id'])) {
$_GET['id'] = '';
}
$_GET['id'] ??= '';

if (!isset($_GET['withtemplate'])) {
$_GET['withtemplate'] = '';
}
$_GET['withtemplate'] ??= '';

$computergroup = new PluginDatabaseinventoryComputerGroup();
$computergroupstatic = new PluginDatabaseinventoryComputerGroupStatic();
Expand Down
2 changes: 1 addition & 1 deletion front/computergroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* -------------------------------------------------------------------------
*/

Session::checkRight('config', UPDATE);
Session::checkRight(Config::$rightname, UPDATE);

Html::header(
PluginDatabaseinventoryComputerGroup::getTypeName(Session::getPluralNumber()),
Expand Down
10 changes: 3 additions & 7 deletions front/credential.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,11 @@

use Glpi\Event;

Session::checkRight('config', READ);
Session::checkRight(Config::$rightname, READ);

if (!isset($_GET['id'])) {
$_GET['id'] = '';
}
$_GET['id'] ??= '';

if (!isset($_GET['withtemplate'])) {
$_GET['withtemplate'] = '';
}
$_GET['withtemplate'] ??= '';

$credential = new PluginDatabaseinventoryCredential();

Expand Down
2 changes: 1 addition & 1 deletion front/credential.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* -------------------------------------------------------------------------
*/

Session::checkRight('config', UPDATE);
Session::checkRight(Config::$rightname, UPDATE);

Html::header(
PluginDatabaseinventoryCredential::getTypeName(Session::getPluralNumber()),
Expand Down
10 changes: 3 additions & 7 deletions front/databaseparam.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,11 @@

use Glpi\Event;

Session::checkRight('config', READ);
Session::checkRight(Config::$rightname, READ);

if (!isset($_GET['id'])) {
$_GET['id'] = '';
}
$_GET['id'] ??= '';

if (!isset($_GET['withtemplate'])) {
$_GET['withtemplate'] = '';
}
$_GET['withtemplate'] ??= '';

$databaseparam = new PluginDatabaseinventoryDatabaseParam();
$databaseparam_credential = new PluginDatabaseinventoryDatabaseParam_Credential();
Expand Down
2 changes: 1 addition & 1 deletion front/databaseparam.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* -------------------------------------------------------------------------
*/

Session::checkRight('config', UPDATE);
Session::checkRight(Config::$rightname, UPDATE);

Html::header(
PluginDatabaseinventoryDatabaseParam::getTypeName(Session::getPluralNumber()),
Expand Down
8 changes: 4 additions & 4 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ function plugin_databaseinventory_uninstall()
function plugin_databaseinventory_MassiveActions($type)
{
// Must be super-admin
if (!Session::haveRight('database_inventory', UPDATE)) {
if (!Session::haveRight(PluginDatabaseinventoryDatabaseParam::class, UPDATE)) {
return [];
}

switch ($type) {
case 'Computer':
case 'Agent':
$class = PluginDatabaseinventoryInventoryAction::getType();
$class = PluginDatabaseinventoryInventoryAction::class;
$key = PluginDatabaseinventoryInventoryAction::MA_PARTIAL;
$label = __s('Run partial databases inventory', 'databaseinventory');

Expand All @@ -113,15 +113,15 @@ function postItemForm(CommonDBTM $item)

function cleanComputerFromStaticGroup(CommonDBTM $item)
{
if ($item::getType() === Computer::getType()) {
if ($item::class === Computer::class) {
$c_static = new PluginDatabaseinventoryComputerGroupStatic();
$c_static->deleteByCriteria(['computers_id' => $item->fields['id']]);
}
}

function cleanAgentFromContactLog(CommonDBTM $item)
{
if ($item::getType() === Agent::getType()) {
if ($item::class === Agent::class) {
$contactlog = new PluginDatabaseinventoryContactLog();
$contactlog->deleteByCriteria(['agents_id' => $item->fields['id']]);
}
Expand Down
4 changes: 2 additions & 2 deletions inc/computergroup.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@

class PluginDatabaseinventoryComputerGroup extends CommonDBTM
{
public $dohistory = true;
public bool $dohistory = true;

public static $rightname = 'database_inventory';
public static string $rightname = 'database_inventory';

public static function getTypeName($nb = 0)
{
Expand Down
8 changes: 3 additions & 5 deletions inc/computergroupdynamic.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

class PluginDatabaseinventoryComputerGroupDynamic extends CommonDBTM
{
public static $rightname = 'database_inventory';
public static string $rightname = 'database_inventory';

public static function getTypeName($nb = 0)
{
Expand Down Expand Up @@ -192,9 +192,7 @@ public function isDynamicSearchMatchComputer(Computer $computer)
'value' => $computer->fields['id'],
];

if (!isset($_SESSION['glpiname'])) {
$_SESSION['glpiname'] = 'databaseinventory_plugin';
}
$_SESSION['glpiname'] ??= 'databaseinventory_plugin';

$search_params = Search::manageParams('Computer', $search);
$data = Search::prepareDatasForSearch('Computer', $search_params);
Expand Down Expand Up @@ -250,7 +248,7 @@ private static function showForItem(PluginDatabaseinventoryComputerGroup $comput

//hack because submit button is not a submit... See https://github.com/glpi-project/glpi/pull/20731
ob_start();
Search::showGenericSearch(Computer::getType(), $p);
Search::showGenericSearch(Computer::class, $p);
$generic_search = ob_get_clean();
echo preg_replace('/type="button" name="save"/', 'type="submit" name="save"', $generic_search);

Expand Down
16 changes: 8 additions & 8 deletions inc/computergroupstatic.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,21 @@
class PluginDatabaseinventoryComputerGroupStatic extends CommonDBRelation
{
// From CommonDBRelation
public static $itemtype_1 = 'PluginDatabaseinventoryComputerGroup';
public static ?string $itemtype_1 = 'PluginDatabaseinventoryComputerGroup';

public static $items_id_1 = 'plugin_databaseinventory_computergroups_id';
public static ?string $items_id_1 = 'plugin_databaseinventory_computergroups_id';

public static $itemtype_2 = 'Computer';
public static ?string $itemtype_2 = 'Computer';

public static $items_id_2 = 'computers_id';
public static ?string $items_id_2 = 'computers_id';

public static $checkItem_2_Rights = self::DONT_CHECK_ITEM_RIGHTS;
public static int $checkItem_2_Rights = self::DONT_CHECK_ITEM_RIGHTS;

public static $logs_for_item_2 = false;
public static bool $logs_for_item_2 = false;

public $auto_message_on_action = false;
public bool $auto_message_on_action = false;

public static $rightname = 'database_inventory';
public static string $rightname = 'database_inventory';

public static function getTypeName($nb = 0)
{
Expand Down
8 changes: 4 additions & 4 deletions inc/contactlog.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@

class PluginDatabaseinventoryContactLog extends CommonDBTM
{
public $dohistory = true;
public bool $dohistory = true;

public static $rightname = 'database_inventory';
public static string $rightname = 'database_inventory';

public static function canCreate(): bool
{
Expand Down Expand Up @@ -155,7 +155,7 @@ private static function showForDatabaseParams(PluginDatabaseinventoryDatabasePar
TemplateRenderer::getInstance()->display(
'@databaseinventory/contactlog.html.twig',
[
'itemtype' => PluginDatabaseinventoryDatabaseParam::getType(),
'itemtype' => PluginDatabaseinventoryDatabaseParam::class,
'contactlogs' => $listofctlog,
'canread' => $databaseparams->can($ID, READ),
],
Expand Down Expand Up @@ -205,7 +205,7 @@ private static function showForAgent(Agent $agent)
TemplateRenderer::getInstance()->display(
'@databaseinventory/contactlog.html.twig',
[
'itemtype' => Agent::getType(),
'itemtype' => Agent::class,
'contactlogs' => $listofctlog,
'canread' => $agent->can($ID, READ),
],
Expand Down
4 changes: 2 additions & 2 deletions inc/credential.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@

class PluginDatabaseinventoryCredential extends CommonDBTM
{
public $dohistory = true;
public bool $dohistory = true;

public static $rightname = 'database_inventory';
public static string $rightname = 'database_inventory';

public static function canCreate(): bool
{
Expand Down
2 changes: 1 addition & 1 deletion inc/credentialtype.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

class PluginDatabaseinventoryCredentialType extends CommonDropdown
{
public static $rightname = 'dropdown';
public static string $rightname = 'dropdown';

private const MYSQL = 1;

Expand Down
4 changes: 2 additions & 2 deletions inc/databaseparam.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@

class PluginDatabaseinventoryDatabaseParam extends CommonDBTM
{
public $dohistory = true;
public bool $dohistory = true;

public static $rightname = 'database_inventory';
public static string $rightname = 'database_inventory';

public static function getTypeName($nb = 0)
{
Expand Down
16 changes: 8 additions & 8 deletions inc/databaseparam_computergroup.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,21 @@
class PluginDatabaseinventoryDatabaseParam_ComputerGroup extends CommonDBRelation
{
// From CommonDBRelation
public static $itemtype_1 = 'PluginDatabaseinventoryDatabaseParam';
public static ?string $itemtype_1 = 'PluginDatabaseinventoryDatabaseParam';

public static $items_id_1 = 'plugin_databaseinventory_databaseparams_id';
public static ?string $items_id_1 = 'plugin_databaseinventory_databaseparams_id';

public static $itemtype_2 = 'PluginDatabaseinventoryComputerGroup';
public static ?string $itemtype_2 = 'PluginDatabaseinventoryComputerGroup';

public static $items_id_2 = 'plugin_databaseinventory_computergroups_id';
public static ?string $items_id_2 = 'plugin_databaseinventory_computergroups_id';

public static $checkItem_2_Rights = self::DONT_CHECK_ITEM_RIGHTS;
public static int $checkItem_2_Rights = self::DONT_CHECK_ITEM_RIGHTS;

public static $logs_for_item_2 = false;
public static bool $logs_for_item_2 = false;

public $auto_message_on_action = false;
public bool $auto_message_on_action = false;

public static $rightname = 'database_inventory';
public static string $rightname = 'database_inventory';

public static function canCreate(): bool
{
Expand Down
16 changes: 8 additions & 8 deletions inc/databaseparam_credential.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,21 @@
class PluginDatabaseinventoryDatabaseParam_Credential extends CommonDBRelation
{
// From CommonDBRelation
public static $itemtype_1 = 'PluginDatabaseinventoryDatabaseParam';
public static ?string $itemtype_1 = 'PluginDatabaseinventoryDatabaseParam';

public static $items_id_1 = 'plugin_databaseinventory_databaseparams_id';
public static ?string $items_id_1 = 'plugin_databaseinventory_databaseparams_id';

public static $itemtype_2 = 'PluginDatabaseinventoryCredential';
public static ?string $itemtype_2 = 'PluginDatabaseinventoryCredential';

public static $items_id_2 = 'plugin_databaseinventory_credentials_id';
public static ?string $items_id_2 = 'plugin_databaseinventory_credentials_id';

public static $checkItem_2_Rights = self::DONT_CHECK_ITEM_RIGHTS;
public static int $checkItem_2_Rights = self::DONT_CHECK_ITEM_RIGHTS;

public static $logs_for_item_2 = false;
public static bool $logs_for_item_2 = false;

public $auto_message_on_action = false;
public bool $auto_message_on_action = false;

public static $rightname = 'database_inventory';
public static string $rightname = 'database_inventory';

public static function canCreate(): bool
{
Expand Down
Loading
Loading