diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index da4e8e70..ec555ac6 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -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" diff --git a/CHANGELOG.md b/CHANGELOG.md index e51f0094..aa2ac1a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +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] +## [1.11.0] - 2026-10-06 + +### Added + +- GLPI 12 compatibility ### Fixed diff --git a/README.md b/README.md index 3726ad76..218130e5 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,9 @@ -# More reporting GLPI plugin +# More Reporting GLPI plugin [![Join the chat at https://gitter.im/TECLIB/mreporting](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/TECLIB/mreporting?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ![Dashboard](https://raw.githubusercontent.com/PluginsGLPI/mreporting/main/screenshots/dashboard.png) -* Download : https://github.com/PluginsGLPI/mreporting/releases -* Translations on Transifex service : https://explore.transifex.com/teclib/glpi-project-plugin-mreporting/ -* WIKI (Develop new reports) : https://github.com/PluginsGLPI/mreporting/wiki - ## Contributing * Open a ticket for each bug/feature so it can be discussed diff --git a/front/config.form.php b/front/config.form.php index 5899a5db..90739edc 100644 --- a/front/config.form.php +++ b/front/config.form.php @@ -30,12 +30,8 @@ Session::checkRight('config', UPDATE); -if (!isset($_GET['id'])) { - $_GET['id'] = 0; -} -if (!isset($_GET['preconfig'])) { - $_GET['preconfig'] = -1; -} +$_GET['id'] ??= 0; +$_GET['preconfig'] ??= -1; $config = new PluginMreportingConfig(); diff --git a/front/preference.form.php b/front/preference.form.php index 933d442d..57cfa48f 100644 --- a/front/preference.form.php +++ b/front/preference.form.php @@ -30,9 +30,7 @@ Session::checkLoginUser(); -if (!isset($_GET['id'])) { - $_GET['id'] = ''; -} +$_GET['id'] ??= ''; $pref = new PluginMreportingPreference(); diff --git a/inc/baseclass.class.php b/inc/baseclass.class.php index 1ef7b64e..5b63b6a1 100644 --- a/inc/baseclass.class.php +++ b/inc/baseclass.class.php @@ -120,9 +120,7 @@ public function __construct($config = []) = $_SESSION['mreporting_values']['status_6'] = 0; } - if (!isset($_SESSION['mreporting_values']['period'])) { - $_SESSION['mreporting_values']['period'] = 'month'; - } + $_SESSION['mreporting_values']['period'] ??= 'month'; if ( isset($_SESSION['mreporting_values']['period']) && !empty($_SESSION['mreporting_values']['period']) diff --git a/inc/common.class.php b/inc/common.class.php index eba36547..b933cc72 100644 --- a/inc/common.class.php +++ b/inc/common.class.php @@ -33,7 +33,7 @@ class PluginMreportingCommon extends CommonDBTM { - public static $rightname = 'statistic'; + public static string $rightname = 'statistic'; public const MNBSP = '                @@ -60,16 +60,8 @@ public static function canCreate(): bool public static function getMenuContent() { - /** @var array $CFG_GLPI */ - global $CFG_GLPI; - - $web_full_dir = $CFG_GLPI['url_base'] . '/plugins/mreporting'; - $img_db = "" . __s("; - $img_ct = "" . __s("; + $icon_db = "" . __s('Dashboard', 'mreporting'); + $icon_ct = "" . __s('Reports list', 'mreporting'); $web_rel_dir = '/plugins/mreporting'; $url_central = "$web_rel_dir/front/central.php"; @@ -82,15 +74,17 @@ public static function getMenuContent() $menu['title'] = self::getTypeName(Session::getPluralNumber()); $menu['options']['dashboard']['page'] = $url_dashboard; + $menu['options']['dashboard']['icon'] = 'ti ti-layout-dashboard'; $menu['options']['dashboard']['title'] = __s('Dashboard', 'mreporting'); - $menu['options']['dashboard']['links'][$img_db] = $url_dashboard; - $menu['options']['dashboard']['links'][$img_ct] = $url_central; + $menu['options']['dashboard']['links'][$icon_db] = $url_dashboard; + $menu['options']['dashboard']['links'][$icon_ct] = $url_central; if (PluginMreportingConfig::canCreate()) { $menu['options']['dashboard']['links']['config'] = PluginMreportingConfig::getSearchURL(false); } $menu['options']['dashboard_list'] = $menu['options']['dashboard']; $menu['options']['dashboard_list']['page'] = $url_central; + $menu['options']['dashboard_list']['icon'] = 'ti ti-list'; $menu['options']['dashboard_list']['title'] = __s('Reports list', 'mreporting'); $menu['options']['config']['title'] = PluginMreportingConfig::getTypeName(2); @@ -645,9 +639,7 @@ public function showGraph($opt, $export = false, $forceFormat = null) $opt['hide_title'] = false; } - if (!isset($opt['width'])) { - $opt['width'] = false; - } + $opt['width'] ??= false; //check the format display charts configured in glpi $opt = $this->initParams($opt, $export); @@ -664,15 +656,11 @@ public function showGraph($opt, $export = false, $forceFormat = null) } //generate default date - if (!isset($_SESSION['mreporting_values']['date1' . $config['randname']])) { - $_SESSION['mreporting_values']['date1' . $config['randname']] = date( - 'Y-m-d', - time() - (intval($config['delay']) * 24 * 60 * 60), - ); - } - if (!isset($_SESSION['mreporting_values']['date2' . $config['randname']])) { - $_SESSION['mreporting_values']['date2' . $config['randname']] = date('Y-m-d'); - } + $_SESSION['mreporting_values']['date1' . $config['randname']] ??= date( + 'Y-m-d', + time() - (intval($config['delay']) * 24 * 60 * 60), + ); + $_SESSION['mreporting_values']['date2' . $config['randname']] ??= date('Y-m-d'); // save/clear selectors if (isset($opt['submit'])) { @@ -1599,12 +1587,8 @@ public static function selectorDateinterval() { $randname = 'PluginMreporting' . $_REQUEST['short_classname'] . $_REQUEST['f_name']; - if (!isset($_SESSION['mreporting_values']['date1' . $randname])) { - $_SESSION['mreporting_values']['date1' . $randname] = date('Y-m-d', time() - (365 * 24 * 60 * 60)); - } - if (!isset($_SESSION['mreporting_values']['date2' . $randname])) { - $_SESSION['mreporting_values']['date2' . $randname] = date('Y-m-d'); - } + $_SESSION['mreporting_values']['date1' . $randname] ??= date('Y-m-d', time() - (365 * 24 * 60 * 60)); + $_SESSION['mreporting_values']['date2' . $randname] ??= date('Y-m-d'); $date1 = $_SESSION['mreporting_values']['date1' . $randname]; echo '' . __s('Start date') . '
'; @@ -1917,9 +1901,7 @@ public static function getSelectorValuesByUser() public static function addToSelector() { foreach ($_REQUEST as $key => $value) { - if (!isset($_SESSION['mreporting_values'][$key])) { - $_SESSION['mreporting_values'][$key] = $value; - } + $_SESSION['mreporting_values'][$key] ??= $value; } } diff --git a/inc/config.class.php b/inc/config.class.php index 52a77636..d4edd0f5 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -64,7 +64,7 @@ class PluginMreportingConfig extends CommonDBTM { - public static $rightname = 'config'; + public static string $rightname = 'config'; public static function getTypeName($nb = 0) { diff --git a/inc/graphpng.class.php b/inc/graphpng.class.php index d8597c0b..a2b5f722 100644 --- a/inc/graphpng.class.php +++ b/inc/graphpng.class.php @@ -68,13 +68,9 @@ public function initGraph($options) if (!$options['export'] && !$options['showHeader']) { $width = $this->width + 100; - if (!isset($_REQUEST['date1' . $randname])) { - $_REQUEST['date1' . $randname] = date('Y-m-d', time() - - ($options['delay'] * 24 * 60 * 60)); - } - if (!isset($_REQUEST['date2' . $randname])) { - $_REQUEST['date2' . $randname] = date('Y-m-d'); - } + $_REQUEST['date1' . $randname] ??= date('Y-m-d', time() + - ($options['delay'] * 24 * 60 * 60)); + $_REQUEST['date2' . $randname] ??= date('Y-m-d'); $backtrace = debug_backtrace(); $prev_function = strtolower(str_replace('show', '', $backtrace[1]['function'])); diff --git a/inc/helpdeskplus.class.php b/inc/helpdeskplus.class.php index 587bf34f..a4839b37 100644 --- a/inc/helpdeskplus.class.php +++ b/inc/helpdeskplus.class.php @@ -460,9 +460,7 @@ public function reportVstackbarLifetime($config = []) 'multiplegroupassign', 'userassign', 'category', ]; - if (!isset($_SESSION['mreporting_values']['date2' . $config['randname']])) { - $_SESSION['mreporting_values']['date2' . $config['randname']] = date('Y-m-d'); - } + $_SESSION['mreporting_values']['date2' . $config['randname']] ??= date('Y-m-d'); //Init delay value $delay = PluginMreportingCommon::getCriteriaDate('glpi_tickets.date', $config['delay'], $config['randname']); @@ -527,9 +525,7 @@ public function reportVstackbarTicketsgroups($config = []) $tab = []; $datas = []; - if (!isset($_SESSION['mreporting_values']['date2' . $config['randname']])) { - $_SESSION['mreporting_values']['date2' . $config['randname']] = date('Y-m-d'); - } + $_SESSION['mreporting_values']['date2' . $config['randname']] ??= date('Y-m-d'); //Init delay value $delay = PluginMreportingCommon::getCriteriaDate('glpi_tickets.date', $config['delay'], $config['randname']); @@ -593,9 +589,7 @@ public function reportVstackbarTicketstech($config = []) $tab = []; $datas = []; - if (!isset($_SESSION['mreporting_values']['date2' . $config['randname']])) { - $_SESSION['mreporting_values']['date2' . $config['randname']] = date('Y-m-d'); - } + $_SESSION['mreporting_values']['date2' . $config['randname']] ??= date('Y-m-d'); foreach ($this->status as $current_status) { if ($_SESSION['mreporting_values']['status_' . $current_status] == '1') { @@ -634,9 +628,7 @@ public function reportVstackbarTicketstech($config = []) foreach ($result as $data) { $data['name'] = empty($data['completename']) ? __s('None') : $data['completename']; - if (!isset($tab[$data['name']][$status_name])) { - $tab[$data['name']][$status_name] = 0; - } + $tab[$data['name']][$status_name] ??= 0; $tab[$data['name']][$status_name] += $data['nb']; } @@ -1325,9 +1317,7 @@ public function reportVstackbarRespectedSlasByGroup($config = []) $datas['labels2'][$group_name] = $group_name; $datas['datas'][$LANG['plugin_mreporting']['Helpdeskplus']['slaobserved']][$group_name] = 0; } - if (!isset($datas['datas'][$LANG['plugin_mreporting']['Helpdeskplus']['slanotobserved']][$group_name])) { - $datas['datas'][$LANG['plugin_mreporting']['Helpdeskplus']['slanotobserved']][$group_name] = 0; - } + $datas['datas'][$LANG['plugin_mreporting']['Helpdeskplus']['slanotobserved']][$group_name] ??= 0; } //Flip array to have observed SLA first diff --git a/inc/inventory.class.php b/inc/inventory.class.php index 15527366..53ef0f1e 100644 --- a/inc/inventory.class.php +++ b/inc/inventory.class.php @@ -717,7 +717,7 @@ public function reportHbarLinuxDistro($config = []) ], ); - if ($number) { + if ($number !== 0) { $data['datas'][$os['name']] = $number; } } @@ -959,9 +959,7 @@ public function reportHbarMonitors($config = []) $data = []; foreach ($DB->request($query) as $result) { $label = $result['cpt'] . ' ' . _sn('Monitor', 'Monitors', $result['cpt']); - if (!isset($data['datas'][$label])) { - $data['datas'][$label] = 0; - } + $data['datas'][$label] ??= 0; $data['datas'][$label] += 1; } diff --git a/inc/notification.class.php b/inc/notification.class.php index e17d86c5..e44ecee5 100644 --- a/inc/notification.class.php +++ b/inc/notification.class.php @@ -33,7 +33,7 @@ class PluginMreportingNotification extends CommonDBTM /** * @var boolean activate the history for the plugin */ - public $dohistory = true; + public bool $dohistory = true; /** * Return the localized name of the current Type (PluginMreporting) diff --git a/inc/preference.class.php b/inc/preference.class.php index 56ad16ea..da52ba8d 100644 --- a/inc/preference.class.php +++ b/inc/preference.class.php @@ -59,7 +59,7 @@ public function addDefaultPreference($users_id) public static function checkPreferenceValue($field, $users_id = 0) { $data = getAllDataFromTable(getTableForItemType(self::class), ['users_id' => $users_id]); - if (!empty($data)) { + if ($data !== []) { $first = array_pop($data); return $first[$field]; diff --git a/inc/profile.class.php b/inc/profile.class.php index f5495aa1..bb57775c 100644 --- a/inc/profile.class.php +++ b/inc/profile.class.php @@ -64,7 +64,7 @@ class PluginMreportingProfile extends CommonDBTM { - public static $rightname = 'profile'; + public static string $rightname = 'profile'; public static function getTypeName($nb = 0) { @@ -143,7 +143,7 @@ public function getFromDBByProfile($profiles_id) } $this->fields = $result->current(); - return (is_array($this->fields) && count($this->fields)); + return count($this->fields) > 0; } /** diff --git a/mreporting.xml b/mreporting.xml index 22f1ba5c..e8aa0ec3 100644 --- a/mreporting.xml +++ b/mreporting.xml @@ -98,6 +98,11 @@ Voir documentation : https://github.com/PluginsGLPI/mreporting/wiki Infotel + + 1.11.0 + ~12.0.0 + https://github.com/pluginsGLPI/mreporting/releases/download/1.11.0/glpi-mreporting-1.11.0.tar.bz2 + 1.10.3 ~11.0.0 diff --git a/setup.php b/setup.php index 07a6c4f9..0be5812b 100644 --- a/setup.php +++ b/setup.php @@ -28,12 +28,12 @@ * ------------------------------------------------------------------------- */ -define('PLUGIN_MREPORTING_VERSION', '1.10.3'); +define('PLUGIN_MREPORTING_VERSION', '1.11.0'); // Minimal GLPI version, inclusive -define('PLUGIN_MREPORTING_MIN_GLPI', '11.0.0'); +define('PLUGIN_MREPORTING_MIN_GLPI', '12.0.0'); // Maximum GLPI version, exclusive -define('PLUGIN_MREPORTING_MAX_GLPI', '11.0.99'); +define('PLUGIN_MREPORTING_MAX_GLPI', '12.0.99'); if (!defined('PLUGIN_MREPORTING_DIR')) { define('PLUGIN_MREPORTING_DIR', __DIR__); @@ -190,7 +190,7 @@ function plugin_init_mreporting() function plugin_version_mreporting() { return [ - 'name' => __s('More Reporting', 'mreporting'), + 'name' => 'More Reporting', 'version' => PLUGIN_MREPORTING_VERSION, 'author' => "Teclib' & Infotel", 'homepage' => 'https://github.com/pluginsGLPI/mreporting',