diff --git a/hook.php b/hook.php index e265b88..dfb4bb3 100644 --- a/hook.php +++ b/hook.php @@ -58,7 +58,7 @@ function plugin_environment_install() { $result_ = $DB->query($query_); if ($DB->numrows($result_) > 0) { - while ($data = $DB->fetch_array($result_)) { + while ($data = $DB->fetchArray($result_)) { $query = "UPDATE `glpi_plugin_environment_profiles` SET `profiles_id` = '" . $data["id"] . "' WHERE `id` = '" . $data["id"] . "';"; diff --git a/inc/display.class.php b/inc/display.class.php index ba0c6a5..20d1c38 100644 --- a/inc/display.class.php +++ b/inc/display.class.php @@ -37,7 +37,7 @@ class PluginEnvironmentDisplay extends CommonGLPI { static $rightname = "plugin_environment"; - static $plugins = ['appliances', 'webapplications', 'accounts', 'databases', 'domains', 'badges']; + static $plugins = ['webapplications', 'accounts', 'databases', 'badges']; /** * @param int $nb @@ -100,9 +100,15 @@ static function getMenuContent() { } } + $menu['icon'] = self::getIcon(); + return $menu; } + static function getIcon() { + return "fas fa-globe"; + } + static function removeRightsFromSession() { if (isset($_SESSION['glpimenu']['assets']['types']['PluginEnvironmentDisplay'])) { unset($_SESSION['glpimenu']['assets']['types']['PluginEnvironmentDisplay']); @@ -185,368 +191,4 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtem } return true; } - - - static function showappliances() { - global $CFG_GLPI, $DB; - - if (Session::haveRight("plugin_environment_appliances", READ)) { - echo ""; - echo ""; - echo ""; - $dbu = new DbUtils(); - $query = "SELECT COUNT(`glpi_plugin_appliances_appliances`.`id`) AS total, - `glpi_plugin_appliances_appliancetypes`.`name` AS TYPE, - `glpi_plugin_appliances_appliances`.`entities_id` - FROM `glpi_plugin_appliances_appliances` "; - $query .= " LEFT JOIN `glpi_plugin_appliances_appliancetypes` ON (`glpi_plugin_appliances_appliances`.`plugin_appliances_appliancetypes_id` = `glpi_plugin_appliances_appliancetypes`.`id`) "; - $query .= " LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `glpi_plugin_appliances_appliances`.`entities_id`) "; - $query .= "WHERE `glpi_plugin_appliances_appliances`.`is_deleted` = '0' " - . $dbu->getEntitiesRestrictRequest(" AND ", "glpi_plugin_appliances_appliances", '', '', true); - $query .= "GROUP BY `glpi_plugin_appliances_appliances`.`entities_id`,`TYPE` - ORDER BY `glpi_entities`.`completename`, `glpi_plugin_appliances_appliancetypes`.`name`"; - - $result = $DB->query($query); - if ($DB->numrows($result)) { - echo ""; - while ($data = $DB->fetch_array($result)) { - echo ""; - $link = ""; - if (Session::isMultiEntitiesMode()) { - echo ""; - if ($data["entities_id"] == 0) { - $link = "&criteria[1][link]=AND&criteria[1][searchtype]=contains&criteria[1][value]=-1&criteria[1][field]=81"; - } else { - $link = "&criteria[1][link]=AND&criteria[1][searchtype]=equals&criteria[1][value]=" . $data["entities_id"] . "&criteria[1][field]=80"; - } - } - if (empty($data["TYPE"])) { - echo ""; - } else { - echo ""; - } - echo ""; - } - } else { - echo ""; - } - - echo "
"; - echo ""; - echo __('Appliances', 'environment'); - echo "
" . __('Appliances', 'environment') . " :
" . Dropdown::getDropdownName("glpi_entities", $data["entities_id"]) . "" . $data["total"] . " " . __('Without type', 'environment') . "" . $data["total"] . " " . $data["TYPE"] . "
" . __('Appliances', 'environment') . " : 0

"; - } - } - - static function showwebapplications() { - global $CFG_GLPI, $DB; - - if (Session::haveRight("plugin_environment_webapplications", READ)) { - echo ""; - echo ""; - echo ""; - $dbu = new DbUtils(); - $query = "SELECT COUNT(`glpi_plugin_webapplications_webapplications`.`id`) AS total, - `glpi_plugin_webapplications_webapplicationtypes`.`name` AS TYPE, - `glpi_plugin_webapplications_webapplications`.`entities_id` - FROM `glpi_plugin_webapplications_webapplications` "; - $query .= " LEFT JOIN `glpi_plugin_webapplications_webapplicationtypes` ON (`glpi_plugin_webapplications_webapplications`.`plugin_webapplications_webapplicationtypes_id` = `glpi_plugin_webapplications_webapplicationtypes`.`id`) "; - $query .= " LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id`=`glpi_plugin_webapplications_webapplications`.`entities_id`) "; - $query .= "WHERE `glpi_plugin_webapplications_webapplications`.`is_deleted` = '0' " - . $dbu->getEntitiesRestrictRequest(" AND ", "glpi_plugin_webapplications_webapplications", '', '', true); - $query .= "GROUP BY `glpi_plugin_webapplications_webapplications`.`entities_id`,`TYPE` - ORDER BY `glpi_entities`.`completename`, `glpi_plugin_webapplications_webapplicationtypes`.`name` "; - $result = $DB->query($query); - if ($DB->numrows($result)) { - echo ""; - while ($data = $DB->fetch_array($result)) { - echo ""; - $link = ""; - if (Session::isMultiEntitiesMode()) { - echo ""; - if ($data["entities_id"] == 0) { - $link = "&criteria[1][link]=AND&criteria[1][searchtype]=contains&criteria[1][value]=-1&criteria[1][field]=81"; - } else { - $link = "&criteria[1][link]=AND&criteria[1][searchtype]=equals&criteria[1][value]=" . $data["entities_id"] . "&criteria[1][field]=80"; - } - } - if (empty($data["TYPE"])) { - echo ""; - } else { - echo ""; - } - echo ""; - } - } else { - echo ""; - } - - echo "
"; - echo ""; - echo __('Web applications', 'environment'); - echo "
" . __('Web applications', 'environment') . " :
" . Dropdown::getDropdownName("glpi_entities", $data["entities_id"]) . "" . $data["total"] . " " . __('Without type', 'environment') . "" . $data["total"] . " " . $data["TYPE"] . "
" . __('Web applications', 'environment') . " : 0

"; - } - } - - static function showaccounts() { - global $CFG_GLPI, $DB; - - if (Session::haveRight("plugin_environment_accounts", READ)) { - echo ""; - echo ""; - echo ""; - - $who = Session::getLoginUserID(); - - if (count($_SESSION["glpigroups"])) { - $first_groups = true; - $groups = ""; - foreach ($_SESSION['glpigroups'] as $val) { - if (!$first_groups) { - $groups .= ","; - } else { - $first_groups = false; - } - $groups .= $val; - } - $ASSIGN = " (`glpi_plugin_accounts_accounts`.`groups_id` IN (SELECT DISTINCT `groups_id` - FROM `glpi_groups_users` - WHERE `groups_id` IN ($groups)) OR"; - $ASSIGN .= " `glpi_plugin_accounts_accounts`.`users_id` = '$who') AND "; - } else { // Only personal ones - $ASSIGN = " `glpi_plugin_accounts_accounts`.`users_id` = '$who' AND "; - } - - $query = "SELECT COUNT(`glpi_plugin_accounts_accounts`.`id`) AS total, - `glpi_plugin_accounts_accounttypes`.`name` AS TYPE, - `glpi_plugin_accounts_accounts`.`entities_id` - FROM `glpi_plugin_accounts_accounts` "; - $query .= " LEFT JOIN `glpi_plugin_accounts_accounttypes` ON (`glpi_plugin_accounts_accounts`.`plugin_accounts_accounttypes_id` = `glpi_plugin_accounts_accounttypes`.`id`) "; - $query .= " LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `glpi_plugin_accounts_accounts`.`entities_id`) "; - $query .= "WHERE "; - if (!Session::haveRight("plugin_accounts_see_all_users", 1)) { - if (!Session::haveRight("plugin_accounts_my_groups", 1)) { - $query .= " `glpi_plugin_accounts_accounts`.`users_id` = " . $who . " AND "; - } else { - $query .= " $ASSIGN "; - } - } - $dbu = new DbUtils(); - $query .= " `glpi_plugin_accounts_accounts`.`is_deleted` = '0' " - . $dbu->getEntitiesRestrictRequest(" AND ", "glpi_plugin_accounts_accounts", '', '', true); - $query .= "GROUP BY `glpi_plugin_accounts_accounts`.`entities_id`,`TYPE` - ORDER BY `glpi_entities`.`completename`, `glpi_plugin_accounts_accounttypes`.`name`"; - - $result = $DB->query($query); - if ($DB->numrows($result)) { - echo ""; - while ($data = $DB->fetch_array($result)) { - echo ""; - $link = ""; - if (Session::isMultiEntitiesMode()) { - echo ""; - if ($data["entities_id"] == 0) { - $link = "&criteria[1][link]=AND&criteria[1][searchtype]=contains&criteria[1][value]=-1&criteria[1][field]=81"; - } else { - $link = "&criteria[1][link]=AND&criteria[1][searchtype]=equals&criteria[1][value]=" . $data["entities_id"] . "&criteria[1][field]=80"; - } - } - - if (empty($data["TYPE"])) { - if (!Session::haveRight("plugin_accounts_see_all_users", 1)) { - if (Session::haveRight("plugin_accounts_my_groups", 1)) { - if ($data["entities_id"] == 0) { - $linkgroup = "&criteria[1][link]=AND&criteria[1][field]=81&criteria[1][searchtype]=equals&criteria[1][value]=-1"; - } else { - $linkgroup = "&criteria[1][link]=AND&criteria[1][field]=80&criteria[1][searchtype]=equals&criteria[1][value]=" . $data["entities_id"]; - } - echo ""; - } else { - echo ""; - } - } else { - echo ""; - } - } else { - - if (!Session::haveRight("plugin_accounts_see_all_users", 1)) { - if (Session::haveRight("plugin_accounts_my_groups", 1)) { - if ($data["entities_id"] == 0) { - $linkgroup = "&criteria[1][link]=AND&criteria[1][field]=81&criteria[1][searchtype]=equals&criteria[1][value]=-1";//"mygroups - } else { - $linkgroup = "&criteria[1][link]=AND&criteria[1][field]=80&criteria[1][searchtype]=equals&criteria[1][value]=" . $data["entities_id"]; - } - echo ""; - } else { - echo ""; - } - } else { - echo ""; - } - } - } - } else { - echo ""; - } - - echo "
"; - echo ""; - echo __('Accounts', 'environment'); - echo "
" . __('Accounts', 'environment') . " :
" . Dropdown::getDropdownName("glpi_entities", $data["entities_id"]) . "" . $data["total"] . " " . __('Without type', 'environment') . "" . $data["total"] . " " . __('Without type', 'environment') . "" . $data["total"] . " " . __('Without type', 'environment') . "" . $data["total"] . " " . $data["TYPE"] . "" . $data["total"] . " " . $data["TYPE"] . "" . $data["total"] . " " . $data["TYPE"] . "
" . __('Accounts', 'environment') . " : 0

"; - } - } - - static function showdomains() { - global $CFG_GLPI, $DB; - - if (Session::haveRight("plugin_environment_domains", READ)) { - echo ""; - echo ""; - echo ""; - $dbu = new DbUtils(); - $query = "SELECT COUNT(`glpi_plugin_domains_domains`.`id`) AS total, - `glpi_plugin_domains_domaintypes`.`name` AS TYPE, - `glpi_plugin_domains_domains`.`entities_id` - FROM `glpi_plugin_domains_domains` "; - $query .= " LEFT JOIN `glpi_plugin_domains_domaintypes` ON (`glpi_plugin_domains_domains`.`plugin_domains_domaintypes_id` = `glpi_plugin_domains_domaintypes`.`id`) "; - $query .= " LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `glpi_plugin_domains_domains`.`entities_id`) "; - $query .= "WHERE `glpi_plugin_domains_domains`.`is_deleted` = '0' " - . $dbu->getEntitiesRestrictRequest(" AND ", "glpi_plugin_domains_domains", '', '', true); - $query .= "GROUP BY `glpi_plugin_domains_domains`.`entities_id`,`TYPE` - ORDER BY `glpi_entities`.`completename`, `glpi_plugin_domains_domaintypes`.`name` "; - - $result = $DB->query($query); - if ($DB->numrows($result)) { - echo ""; - while ($data = $DB->fetch_array($result)) { - echo ""; - $link = ""; - if (Session::isMultiEntitiesMode()) { - echo ""; - if ($data["entities_id"] == 0) { - $link = "&criteria[1][link]=AND&criteria[1][searchtype]=contains&criteria[1][value]=-1&criteria[1][field]=81"; - } else { - $link = "&criteria[1][link]=AND&criteria[1][searchtype]=equals&criteria[1][value]=" . $data["entities_id"] . "&criteria[1][field]=80"; - } - } - if (empty($data["TYPE"])) { - echo ""; - } else { - echo ""; - } - echo ""; - } - } else { - echo ""; - } - - echo "
"; - echo ""; - echo __('Domains', 'environment'); - echo "
" . __('Domains', 'environment') . " :
" . Dropdown::getDropdownName("glpi_entities", $data["entities_id"]) . "" . $data["total"] . " " . __('Without type', 'environment') . "" . $data["total"] . " " . $data["TYPE"] . "
" . __('Domains', 'environment') . " : 0

"; - } - } - - static function showdatabases() { - global $CFG_GLPI, $DB; - - if (Session::haveRight("plugin_environment_databases", READ)) { - echo ""; - echo ""; - echo ""; - $dbu = new DbUtils(); - $query = "SELECT COUNT(`glpi_plugin_databases_databases`.`id`) AS total, - `glpi_plugin_databases_databasetypes`.`name` AS TYPE, - `glpi_plugin_databases_databases`.`entities_id` - FROM `glpi_plugin_databases_databases` "; - $query .= " LEFT JOIN `glpi_plugin_databases_databasetypes` ON (`glpi_plugin_databases_databases`.`plugin_databases_databasetypes_id` = `glpi_plugin_databases_databasetypes`.`id`) "; - $query .= " LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `glpi_plugin_databases_databases`.`entities_id`) "; - $query .= "WHERE `glpi_plugin_databases_databases`.`is_deleted` = '0' " - . $dbu->getEntitiesRestrictRequest(" AND ", "glpi_plugin_databases_databases", '', '', true); - $query .= "GROUP BY `glpi_plugin_databases_databases`.`entities_id`,`TYPE` - ORDER BY `glpi_entities`.`completename`, `glpi_plugin_databases_databasetypes`.`name`"; - - $result = $DB->query($query); - if ($DB->numrows($result)) { - echo ""; - while ($data = $DB->fetch_array($result)) { - echo ""; - $link = ""; - if (Session::isMultiEntitiesMode()) { - echo ""; - if ($data["entities_id"] == 0) { - $link = "&criteria[1][link]=AND&criteria[1][searchtype]=contains&criteria[1][value]=-1&criteria[1][field]=81"; - } else { - $link = "&criteria[1][link]=AND&criteria[1][searchtype]=equals&criteria[1][value]=" . $data["entities_id"] . "&criteria[1][field]=80"; - } - } - if (empty($data["TYPE"])) { - echo ""; - } else { - echo ""; - } - echo ""; - } - } else { - echo ""; - } - - echo "
"; - echo ""; - echo __('Databases', 'environment'); - echo "
" . __('Databases', 'environment') . " :
" . Dropdown::getDropdownName("glpi_entities", $data["entities_id"]) . "" . $data["total"] . " " . __('Without type', 'environment') . "" . $data["total"] . " " . $data["TYPE"] . "
" . __('Databases', 'environment') . " : 0

"; - } - } - - static function showbadges() { - global $CFG_GLPI, $DB; - $dbu = new DbUtils(); - if (Session::haveRight("plugin_environment_badges", READ)) { - echo ""; - echo ""; - echo ""; - - $query = "SELECT COUNT(`glpi_plugin_badges_badges`.`id`) AS total, - `glpi_plugin_badges_badgetypes`.`name` AS TYPE, - `glpi_plugin_badges_badges`.`entities_id` , - `glpi_plugin_badges_badges`.`is_recursive` - FROM `glpi_plugin_badges_badges` "; - $query .= " LEFT JOIN `glpi_plugin_badges_badgetypes` ON (`glpi_plugin_badges_badges`.`plugin_badges_badgetypes_id` = `glpi_plugin_badges_badgetypes`.`id`) "; - $query .= " LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `glpi_plugin_badges_badges`.`entities_id`) "; - $query .= "WHERE `glpi_plugin_badges_badges`.`is_deleted` = '0' " - . $dbu->getEntitiesRestrictRequest(" AND ", "glpi_plugin_badges_badges", '', '', true); - $query .= "GROUP BY `glpi_plugin_badges_badges`.`entities_id`,`TYPE` - ORDER BY `glpi_entities`.`completename`, `glpi_plugin_badges_badgetypes`.`name` "; - - $result = $DB->query($query); - if ($DB->numrows($result)) { - echo ""; - while ($data = $DB->fetch_array($result)) { - echo ""; - $link = ""; - if (Session::isMultiEntitiesMode()) { - echo ""; - if ($data["entities_id"] == 0) { - $link = "&criteria[1][link]=AND&criteria[1][searchtype]=contains&criteria[1][value]=-1&criteria[1][field]=81"; - } else { - $link = "&criteria[1][link]=AND&criteria[1][searchtype]=equals&criteria[1][value]=" . $data["entities_id"] . "&criteria[1][field]=80"; - } - } - if (empty($data["TYPE"])) { - echo ""; - } else { - echo ""; - } - echo ""; - } - } else { - echo ""; - } - - echo "
"; - echo ""; - echo __('Badges', 'environment'); - echo "
" . __('Badges', 'environment') . " :
" . Dropdown::getDropdownName("glpi_entities", $data["entities_id"]) . "" . $data["total"] . " " . __('Without type', 'environment') . "" . $data["total"] . " " . $data["TYPE"] . "
" . __('Badges', 'environment') . " : 0

"; - } - } } diff --git a/inc/profile.class.php b/inc/profile.class.php index 8bccc20..81dbe2a 100644 --- a/inc/profile.class.php +++ b/inc/profile.class.php @@ -69,10 +69,8 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtem self::addDefaultProfileInfos($ID, ['plugin_environment' => 0, - 'plugin_environment_appliances' => 0, 'plugin_environment_webapplications' => 0, 'plugin_environment_accounts' => 0, - 'plugin_environment_domains' => 0, 'plugin_environment_databases' => 0, 'plugin_environment_badges' => 0]); $prof->showForm($ID); @@ -87,10 +85,8 @@ static function createFirstAccess($ID) { //85 self::addDefaultProfileInfos($ID, ['plugin_environment' => 1, - 'plugin_environment_appliances' => 1, 'plugin_environment_webapplications' => 1, 'plugin_environment_accounts' => 1, - 'plugin_environment_domains' => 1, 'plugin_environment_databases' => 1, 'plugin_environment_badges' => 1], true); } @@ -175,10 +171,6 @@ static function getAllRights($all = false) { 'label' => __('Environment', 'environment'), 'field' => 'plugin_environment' ], - ['rights' => [READ => __('Read')], - 'label' => __('Appliances', 'environment'), - 'field' => 'plugin_environment_appliances' - ], ['rights' => [READ => __('Read')], 'label' => __('Web applications', 'environment'), 'field' => 'plugin_environment_webapplications' @@ -187,10 +179,6 @@ static function getAllRights($all = false) { 'label' => __('Accounts', 'environment'), 'field' => 'plugin_environment_accounts' ], - ['rights' => [READ => __('Read')], - 'label' => __('Domains', 'environment'), - 'field' => 'plugin_environment_domains' - ], ['rights' => [READ => __('Read')], 'label' => __('Databases', 'environment'), 'field' => 'plugin_environment_databases' @@ -248,10 +236,8 @@ static function migrateOneProfile($profiles_id) { "`profiles_id`='$profiles_id'") as $profile_data) { $matching = ['environment' => 'plugin_environment', - 'appliances' => 'plugin_environment_appliances', 'webapplications' => 'plugin_environment_webapplications', 'accounts' => 'plugin_environment_accounts', - 'domains' => 'plugin_environment_domains', 'databases' => 'plugin_environment_databases', 'badges' => 'plugin_environment_badges']; $current_rights = ProfileRight::getProfileRights($profiles_id, array_values($matching)); diff --git a/setup.php b/setup.php index 711023f..5f8afb7 100644 --- a/setup.php +++ b/setup.php @@ -27,7 +27,7 @@ -------------------------------------------------------------------------- */ -define('PLUGIN_ENVIRONNEMENT_VERSION', '2.3.0'); +define('PLUGIN_ENVIRONNEMENT_VERSION', '2.4.0'); // Init the hooks of the plugins -Needed function plugin_init_environment() { @@ -64,7 +64,7 @@ function plugin_version_environment() { 'homepage' => 'https://github.com/InfotelGLPI/environment', 'requirements' => [ 'glpi' => [ - 'min' => '9.4', + 'min' => '9.5', 'dev' => false ] ] @@ -77,10 +77,10 @@ function plugin_version_environment() { * @return bool */ function plugin_environment_check_prerequisites() { - if (version_compare(GLPI_VERSION, '9.4', 'lt') - || version_compare(GLPI_VERSION, '9.5', 'ge')) { + if (version_compare(GLPI_VERSION, '9.5', 'lt') + || version_compare(GLPI_VERSION, '9.6', 'ge')) { if (method_exists('Plugin', 'messageIncompatible')) { - echo Plugin::messageIncompatible('core', '9.4'); + echo Plugin::messageIncompatible('core', '9.5'); } return false; }