Skip to content

Commit

Permalink
Merge branch 'main' into twigupdatev2
Browse files Browse the repository at this point in the history
  • Loading branch information
Lainow authored Nov 20, 2023
2 parents 526d4a2 + 47fc06f commit 30a343f
Show file tree
Hide file tree
Showing 19 changed files with 188 additions and 79 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "Continuous integration"

on:
push:
branches:
- "main"
tags:
- "*"
pull_request:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
ci:
name: "GLPI ${{ matrix.glpi-version }} - php:${{ matrix.php-version }} - ${{ matrix.db-image }}"
strategy:
fail-fast: false
matrix:
include:
- {glpi-version: "10.0.x", php-version: "7.4", db-image: "mysql:5.7"}
- {glpi-version: "10.0.x", php-version: "8.0", db-image: "mysql:8.0"}
- {glpi-version: "10.0.x", php-version: "8.1", db-image: "mariadb:10.2"}
- {glpi-version: "10.0.x", php-version: "8.2", db-image: "mariadb:11.0"}
- {glpi-version: "10.0.x", php-version: "8.3-rc", db-image: "mysql:8.0"}
uses: "glpi-project/plugin-ci-workflows/.github/workflows/continuous-integration.yml@v1"
with:
plugin-key: "databaseinventory"
glpi-version: "${{ matrix.glpi-version }}"
php-version: "${{ matrix.php-version }}"
db-image: "${{ matrix.db-image }}"
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: "actions/checkout@v4"
- name: "Build package"
id: "build-package"
uses: "glpi-project/tools/github-actions/build-package@0.6.4"
uses: "glpi-project/tools/github-actions/build-package@0.7.1"
with:
plugin-version: ${{ env.tag_name }}
- name: "Create release"
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"php": ">=7.4"
},
"require-dev": {
"glpi-project/tools": "^0.6",
"glpi-project/tools": "^0.7.1",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpstan/phpstan": "^1.10",
"squizlabs/php_codesniffer": "^3.7"
},
"config": {
Expand Down
80 changes: 73 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions front/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@

include("../../../inc/includes.php");

/** @var array $CFG_GLPI */
global $CFG_GLPI;

Html::header(
__('Database Inventory', 'databaseinventory'),
$_SERVER['PHP_SELF'],
Expand All @@ -42,12 +45,10 @@
echo "<table class='tab_cadre'>";
echo "<tr><th colspan='2'>" . __('Database Inventory', 'databaseinventory') . "</th></tr>";

if (PluginDatabaseinventoryDatabaseParam::canView()) {
echo "<tr class='tab_bg_1 center'>";
echo "<td><i class='fas fa-cog'></i></td>";
echo "<td><a href='" . Toolbox::getItemTypeSearchURL('PluginDatabaseinventoryDatabaseParam') . "'>"
. PluginDatabaseinventoryDatabaseParam::getTypeName(2) . "</a></td></tr>";
}
echo "<tr class='tab_bg_1 center'>";
echo "<td><i class='fas fa-cog'></i></td>";
echo "<td><a href='" . Toolbox::getItemTypeSearchURL('PluginDatabaseinventoryDatabaseParam') . "'>"
. PluginDatabaseinventoryDatabaseParam::getTypeName(2) . "</a></td></tr>";

if (PluginDatabaseinventoryCredential::canView()) {
echo "<tr class='tab_bg_1 center'>";
Expand Down
5 changes: 4 additions & 1 deletion inc/computergroup.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public function showForm($ID, array $options = [])

public function countDynamicItem()
{
/** @var DBmysql $DB */
global $DB;
$count = 0;

Expand All @@ -178,8 +179,8 @@ public function countDynamicItem()

public function countStaticItem()
{
/** @var DBmysql $DB */
global $DB;
$count = 0;

$params = [
'SELECT' => '*',
Expand All @@ -195,6 +196,7 @@ public function countStaticItem()

public static function install(Migration $migration)
{
/** @var DBmysql $DB */
global $DB;

$default_charset = DBConnection::getDefaultCharset();
Expand Down Expand Up @@ -234,6 +236,7 @@ public static function install(Migration $migration)

public static function uninstall(Migration $migration)
{
/** @var DBmysql $DB */
global $DB;
$table = self::getTable();
if ($DB->tableExists($table)) {
Expand Down
12 changes: 5 additions & 7 deletions inc/computergroupdynamic.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static function canPurge()

public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
{
if (get_class($item) == PluginDatabaseinventoryComputerGroup::getType()) {
if ($item instanceof PluginDatabaseinventoryComputerGroup) {
$count = 0;
$computergroup_dynamic = new self();
if (
Expand All @@ -59,9 +59,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
) {
$count = $computergroup_dynamic->countDynamicItems();
}
$ong = [];
$ong[1] = self::createTabEntry(self::getTypeName(Session::getPluralNumber()), $count);
return $ong;
return self::createTabEntry(self::getTypeName(Session::getPluralNumber()), $count);
}
return '';
}
Expand All @@ -84,6 +82,7 @@ public static function getSpecificValueToDisplay($field, $values, array $options
return ($count) ? $count : ' 0 ';

case '_virtual_dynamic_list':
/** @var array $CFG_GLPI */
global $CFG_GLPI;
$value = " ";
$out = " ";
Expand Down Expand Up @@ -151,7 +150,6 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $

private function countDynamicItems()
{
$count = 0;
$search_params = Search::manageParams('Computer', unserialize($this->fields['search']));
$data = Search::prepareDatasForSearch('Computer', $search_params);
Search::constructSQL($data);
Expand All @@ -162,8 +160,6 @@ private function countDynamicItems()

public function isDynamicSearchMatchComputer(Computer $computer)
{
$count = 0;

// add new criteria to force computer ID
$search = unserialize($this->fields['search']);
$search['criteria'][] = [
Expand Down Expand Up @@ -248,6 +244,7 @@ function() {

public static function install(Migration $migration)
{
/** @var DBmysql $DB */
global $DB;

$default_charset = DBConnection::getDefaultCharset();
Expand All @@ -272,6 +269,7 @@ public static function install(Migration $migration)

public static function uninstall(Migration $migration)
{
/** @var DBmysql $DB */
global $DB;
$table = self::getTable();
if ($DB->tableExists($table)) {
Expand Down
10 changes: 5 additions & 5 deletions inc/computergroupstatic.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,9 @@ public static function canPurge()

public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
{
if (get_class($item) == PluginDatabaseinventoryComputerGroup::getType()) {
$count = 0;
if ($item instanceof PluginDatabaseinventoryComputerGroup) {
$count = countElementsInTable(self::getTable(), ['plugin_databaseinventory_computergroups_id' => $item->getID()]);
$ong = [];
$ong[1] = self::createTabEntry(self::getTypeName(Session::getPluralNumber()), $count);
return $ong;
return self::createTabEntry(self::getTypeName(Session::getPluralNumber()), $count);
}
return '';
}
Expand All @@ -87,6 +84,7 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $

private static function showForItem(PluginDatabaseinventoryComputerGroup $computergroup)
{
/** @var DBmysql $DB */
global $DB;

$ID = $computergroup->getField('id');
Expand Down Expand Up @@ -132,6 +130,7 @@ private static function showForItem(PluginDatabaseinventoryComputerGroup $comput

public static function install(Migration $migration)
{
/** @var DBmysql $DB */
global $DB;

$default_charset = DBConnection::getDefaultCharset();
Expand All @@ -157,6 +156,7 @@ public static function install(Migration $migration)

public static function uninstall(Migration $migration)
{
/** @var DBmysql $DB */
global $DB;
$table = self::getTable();
if ($DB->tableExists($table)) {
Expand Down
19 changes: 7 additions & 12 deletions inc/contactlog.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,13 @@ public static function getTypeName($nb = 0)

public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
{
switch ($item->getType()) {
case PluginDatabaseinventoryDatabaseParam::getType():
$count = 0;
switch (get_class($item)) {
case PluginDatabaseinventoryDatabaseParam::class:
$count = countElementsInTable(self::getTable(), ['plugin_databaseinventory_databaseparams_id' => $item->getID()]);
$ong = [];
$ong[1] = self::createTabEntry(self::getTypeName(Session::getPluralNumber()), $count);
return $ong;
break;
case Agent::getType():
$count = 0;
return self::createTabEntry(self::getTypeName(Session::getPluralNumber()), $count);
case Agent::class:
$count = countElementsInTable(self::getTable(), ['agents_id' => $item->getID()]);
$ong = [];
$ong[2] = self::createTabEntry(self::getTypeName(Session::getPluralNumber()), $count);
return $ong;
return self::createTabEntry(self::getTypeName(Session::getPluralNumber()), $count);
}
return '';
}
Expand Down Expand Up @@ -181,6 +174,7 @@ private static function showForAgent(Agent $agent)

public static function install(Migration $migration)
{
/** @var DBmysql $DB */
global $DB;

$default_charset = DBConnection::getDefaultCharset();
Expand Down Expand Up @@ -210,6 +204,7 @@ public static function install(Migration $migration)

public static function uninstall(Migration $migration)
{
/** @var DBmysql $DB */
global $DB;
$table = self::getTable();
if ($DB->tableExists($table)) {
Expand Down
2 changes: 2 additions & 0 deletions inc/credential.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public function prepareInputForUpdate($input)

public static function install(Migration $migration)
{
/** @var DBmysql $DB */
global $DB;

$default_charset = DBConnection::getDefaultCharset();
Expand Down Expand Up @@ -204,6 +205,7 @@ public static function install(Migration $migration)

public static function uninstall(Migration $migration)
{
/** @var DBmysql $DB */
global $DB;
$table = self::getTable();
if ($DB->tableExists($table)) {
Expand Down
Loading

0 comments on commit 30a343f

Please sign in to comment.