Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
amma35 committed Sep 28, 2017
2 parents 1f175e2 + 52ea0ba commit da667be
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 82 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Ce plugin vous permet de regrouper 7 plugins dans un seul pour une meilleure vis

> * Plugin "appliances":https://forge.glpi-project.org/projects/show/appliances
> * Plugin "webapplications":https://github.com/InfotelGLPI/webapplications
> * Plugin "certificates":https://github.com/InfotelGLPI/certificates
> * Plugin "accounts":https://github.com/InfotelGLPI/accounts
> * Plugin "domains":https://github.com/InfotelGLPI/domains
> * Plugin "databases":https://github.com/InfotelGLPI/databases
Expand All @@ -23,7 +22,6 @@ This plugin enables you to group 7 plugins to one for more visibility of plugins

> * "appliances":https://forge.glpi-project.org/projects/show/appliances Plugin
> * "webapplications":https://github.com/InfotelGLPI/webapplications Plugin
> * "certificates":https://github.com/InfotelGLPI/certificates Plugin
> * "accounts":https://github.com/InfotelGLPI/accounts Plugin
> * "domains":https://github.com/InfotelGLPI/domains Plugin
> * "databases":https://github.com/InfotelGLPI/databases Plugin
Expand Down
8 changes: 4 additions & 4 deletions environment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<logo>https://raw.githubusercontent.com/InfotelGLPI/environment/master/environment.png</logo>
<description>
<short>
<fr><![CDATA[Meta-plugin environment. Ce plugin vous permet de regrouper dix plugins dans un seul pour une meilleure visibilité du menu des plugins.<br />Peut contenir : <br />- Plugin appliances<br />- Plugin webapplications<br />- Plugin certificates<br />- Plugin accounts<br />- Plugin connections<br />- Plugin domains<br />- Plugin databases<br />- Plugin backups<br />- Plugin badges<br />- Plugin rights]]></fr>
<en><![CDATA[Meta-plugin environment. This plugin enables you to group ten plugins to one for more visibility of plugins menu.<br />Include <br />- Plugin appliances<br />- Plugin webapplications<br />- Plugin certificates<br />- Plugin accounts<br />- Plugin connections<br />- Plugin domains<br />- Plugin databases<br />- Plugin backups<br />- Plugin badges<br />- Plugin rights]]></en>
<fr><![CDATA[Meta-plugin environment. Ce plugin vous permet de regrouper dix plugins dans un seul pour une meilleure visibilité du menu des plugins.<br />Peut contenir : <br />- Plugin appliances<br />- Plugin webapplications<br />- Plugin accounts<br />- Plugin connections<br />- Plugin domains<br />- Plugin databases<br />- Plugin backups<br />- Plugin badges<br />- Plugin rights]]></fr>
<en><![CDATA[Meta-plugin environment. This plugin enables you to group ten plugins to one for more visibility of plugins menu.<br />Include <br />- Plugin appliances<br />- Plugin webapplications<br />- Plugin accounts<br />- Plugin connections<br />- Plugin domains<br />- Plugin databases<br />- Plugin backups<br />- Plugin badges<br />- Plugin rights]]></en>
</short>
<long>
<fr><![CDATA[Ce plugin vous permet de regrouper dix plugins dans un seul pour une meilleure visibilité du menu des plugins.<br />Peut contenir : <br />- Plugin appliances<br />- Plugin webapplications<br />- Plugin certificates<br />- Plugin accounts<br />- Plugin connections<br />- Plugin domains<br />- Plugin databases<br />- Plugin backups<br />- Plugin badges<br />- Plugin rights]]></fr>
<en><![CDATA[This plugin enables you to group ten plugins to one for more visibility of plugins menu.<br />Include <br />- Plugin appliances<br />- Plugin webapplications<br />- Plugin certificates<br />- Plugin accounts<br />- Plugin connections<br />- Plugin domains<br />- Plugin databases<br />- Plugin backups<br />- Plugin badges<br />- Plugin rights]]></en>
<fr><![CDATA[Ce plugin vous permet de regrouper dix plugins dans un seul pour une meilleure visibilité du menu des plugins.<br />Peut contenir : <br />- Plugin appliances<br />- Plugin webapplications<br />- Plugin accounts<br />- Plugin connections<br />- Plugin domains<br />- Plugin databases<br />- Plugin backups<br />- Plugin badges<br />- Plugin rights]]></fr>
<en><![CDATA[This plugin enables you to group ten plugins to one for more visibility of plugins menu.<br />Include <br />- Plugin appliances<br />- Plugin webapplications<br />- Plugin accounts<br />- Plugin connections<br />- Plugin domains<br />- Plugin databases<br />- Plugin backups<br />- Plugin badges<br />- Plugin rights]]></en>
</long>
</description>
<homepage>https://github.com/InfotelGLPI/environment</homepage>
Expand Down
2 changes: 1 addition & 1 deletion hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function plugin_environment_install() {

PluginEnvironmentProfile::initProfile();
PluginEnvironmentProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
$migration = new Migration("2..0");
$migration = new Migration("2.0.0");
$migration->dropTable('glpi_plugin_environment_profiles');

$_SESSION["glpi_plugin_environment_installed"] = 1;
Expand Down
83 changes: 17 additions & 66 deletions inc/display.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class PluginEnvironmentDisplay extends CommonGLPI
{

static $rightname = "plugin_environment";
static $plugins = array('appliances', 'webapplications', 'certificates', 'accounts', 'databases', 'domains', 'badges');
static $plugins = array('appliances', 'webapplications', 'accounts', 'databases', 'domains', 'badges');

/**
* @param int $nb
Expand Down Expand Up @@ -67,8 +67,8 @@ static function getMenuContent()
if ($plugin->isActivated($plug)) {
if (Session::haveRight("plugin_" . $plug, READ)) {
$table = "glpi_plugin_" . $plug . "_" . $plug;

$itemtype = getItemTypeForTable($table);
$dbu = new DbUtils();
$itemtype = $dbu->getItemTypeForTable($table);

if (!class_exists($itemtype)) {
continue;
Expand Down Expand Up @@ -144,8 +144,8 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
$plugin = new Plugin();
if ($plugin->isActivated($plug)) {
$table = "glpi_plugin_" . $plug . "_" . $plug;

$itemtype = getItemTypeForTable($table);
$dbu = new DbUtils();
$itemtype = $dbu->getItemTypeForTable($table);

if (!class_exists($itemtype)) {
continue;
Expand Down Expand Up @@ -201,15 +201,15 @@ static function showappliances()
echo "<a href=\"" . $CFG_GLPI["root_doc"] . "/plugins/appliances/front/appliance.php\">";
echo __('Appliances', 'environment');
echo "</th></tr>";

$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' "
. getEntitiesRestrictRequest(" AND ", "glpi_plugin_appliances_appliances", '', '', true);
. $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`";

Expand Down Expand Up @@ -251,15 +251,15 @@ static function showwebapplications()
echo "<a href=\"" . $CFG_GLPI["root_doc"] . "/plugins/webapplications/front/webapplication.php\">";
echo __('Web applications', 'environment');
echo "</th></tr>";

$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' "
. getEntitiesRestrictRequest(" AND ", "glpi_plugin_webapplications_webapplications", '', '', true);
. $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);
Expand Down Expand Up @@ -289,56 +289,6 @@ static function showwebapplications()
}
}

static function showcertificates()
{
global $CFG_GLPI, $DB;

if (Session::haveRight("plugin_environment_certificates", READ)) {
echo "<table class='tab_cadrehov' width='750px'>";
echo "<tr>";
echo "<th class='center top' colspan='2'>";
echo "<a href=\"" . $CFG_GLPI["root_doc"] . "/plugins/certificates/front/certificate.php\">";
echo __('Certificates', 'environment');
echo "</th></tr>";

$query = "SELECT COUNT(`glpi_plugin_certificates_certificates`.`id`) AS total,
`glpi_plugin_certificates_certificatetypes`.`name` AS TYPE,
`glpi_plugin_certificates_certificates`.`entities_id`
FROM `glpi_plugin_certificates_certificates` ";
$query .= " LEFT JOIN `glpi_plugin_certificates_certificatetypes` ON (`glpi_plugin_certificates_certificates`.`plugin_certificates_certificatetypes_id` = `glpi_plugin_certificates_certificatetypes`.`id`) ";
$query .= " LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `glpi_plugin_certificates_certificates`.`entities_id`) ";
$query .= "WHERE `glpi_plugin_certificates_certificates`.`is_deleted` = '0' "
. getEntitiesRestrictRequest(" AND ", "glpi_plugin_certificates_certificates", '', '', true);
$query .= "GROUP BY `glpi_plugin_certificates_certificates`.`entities_id`,`TYPE`
ORDER BY `glpi_entities`.`completename`, `glpi_plugin_certificates_certificatetypes`.`name` ";

$result = $DB->query($query);
if ($DB->numrows($result)) {
echo "<tr><th colspan='2'>" . __('Certificates', 'environment') . " : </th></tr>";
while ($data = $DB->fetch_array($result)) {
echo "<tr class='tab_bg_1'>";
$link = "";
if (Session::isMultiEntitiesMode()) {
echo "<td class='left top'>" . Dropdown::getDropdownName("glpi_entities", $data["entities_id"]) . "</td>";
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 "<td><a href='" . $CFG_GLPI["root_doc"] . "/plugins/certificates/front/certificate.php?glpisearchcount=2&criteria[0][searchtype]=contains&criteria[0][value]=NULL&criteria[0][field]=2$link&is_deleted=0&itemtype=PluginCertificatesCertificate&start=0'>" . $data["total"] . " " . __('Without type', 'environment') . "</a></td>";
else
echo "<td><a href='" . $CFG_GLPI["root_doc"] . "/plugins/certificates/front/certificate.php?glpisearchcount=2&criteria[0][searchtype]=contains&criteria[0][value]=" . rawurlencode($data["TYPE"]) . "&criteria[0][field]=2$link&is_deleted=0&itemtype=PluginCertificatesCertificate&start=0'>" . $data["total"] . " " . $data["TYPE"] . "</a></td>";
echo "</tr>";
}
} else
echo "<tr><th colspan='2'>" . __('Certificates', 'environment') . " : 0</th></tr>";

echo "</table><br>";
}
}

static function showaccounts()
{
global $CFG_GLPI, $DB;
Expand Down Expand Up @@ -383,8 +333,9 @@ static function showaccounts()
$query .= " $ASSIGN ";
}
}
$dbu = new DbUtils();
$query .= " `glpi_plugin_accounts_accounts`.`is_deleted` = '0' "
. getEntitiesRestrictRequest(" AND ", "glpi_plugin_accounts_accounts", '', '', true);
. $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`";

Expand Down Expand Up @@ -454,15 +405,15 @@ static function showdomains()
echo "<a href=\"" . $CFG_GLPI["root_doc"] . "/plugins/domains/front/domain.php\">";
echo __('Domains', 'environment');
echo "</th></tr>";

$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' "
. getEntitiesRestrictRequest(" AND ", "glpi_plugin_domains_domains", '', '', true);
. $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` ";

Expand Down Expand Up @@ -504,15 +455,15 @@ static function showdatabases()
echo "<a href=\"" . $CFG_GLPI["root_doc"] . "/plugins/databases/front/database.php\">";
echo __('Databases', 'environment');
echo "</th></tr>";

$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' "
. getEntitiesRestrictRequest(" AND ", "glpi_plugin_databases_databases", '', '', true);
. $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`";

Expand Down Expand Up @@ -546,7 +497,7 @@ static function showdatabases()
static function showbadges()
{
global $CFG_GLPI, $DB;

$dbu = new DbUtils();
if (Session::haveRight("plugin_environment_badges", READ)) {
echo "<table class='tab_cadrehov' width='750px'>";
echo "<tr>";
Expand All @@ -562,7 +513,7 @@ static function showbadges()
$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' "
. getEntitiesRestrictRequest(" AND ", "glpi_plugin_badges_badges", '', '', false);
. $dbu->getEntitiesRestrictRequest(" AND ", "glpi_plugin_badges_badges", '', '', false);
$query .= "GROUP BY `glpi_plugin_badges_badges`.`entities_id`,`TYPE`
ORDER BY `glpi_entities`.`completename`, `glpi_plugin_badges_badgetypes`.`name` ";

Expand Down
7 changes: 0 additions & 7 deletions inc/profile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtem
array('plugin_environment' => 0,
'plugin_environment_appliances' => 0,
'plugin_environment_webapplications' => 0,
'plugin_environment_certificates' => 0,
'plugin_environment_accounts' => 0,
'plugin_environment_domains' => 0,
'plugin_environment_databases' => 0,
Expand All @@ -90,7 +89,6 @@ static function createFirstAccess($ID) {
array('plugin_environment' => 1,
'plugin_environment_appliances' => 1,
'plugin_environment_webapplications' => 1,
'plugin_environment_certificates' => 1,
'plugin_environment_accounts' => 1,
'plugin_environment_domains' => 1,
'plugin_environment_databases' => 1,
Expand Down Expand Up @@ -185,10 +183,6 @@ static function getAllRights($all = false) {
'label' => __('Web applications', 'environment'),
'field' => 'plugin_environment_webapplications'
),
array('rights' => array(READ => __('Read')),
'label' => __('Certificates', 'environment'),
'field' => 'plugin_environment_certificates'
),
array('rights' => array(READ => __('Read')),
'label' => __('Accounts', 'environment'),
'field' => 'plugin_environment_accounts'
Expand Down Expand Up @@ -256,7 +250,6 @@ static function migrateOneProfile($profiles_id) {
$matching = array('environment' => 'plugin_environment',
'appliances' => 'plugin_environment_appliances',
'webapplications' => 'plugin_environment_webapplications',
'certificates' => 'plugin_environment_certificates',
'accounts' => 'plugin_environment_accounts',
'domains' => 'plugin_environment_domains',
'databases' => 'plugin_environment_databases',
Expand Down
2 changes: 0 additions & 2 deletions sql/empty-1.4.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ CREATE TABLE `glpi_plugin_environment_profiles` (
COLLATE utf8_unicode_ci DEFAULT NULL,
`webapplications` CHAR(1)
COLLATE utf8_unicode_ci DEFAULT NULL,
`certificates` CHAR(1)
COLLATE utf8_unicode_ci DEFAULT NULL,
`accounts` CHAR(1)
COLLATE utf8_unicode_ci DEFAULT NULL,
`domains` CHAR(1)
Expand Down

0 comments on commit da667be

Please sign in to comment.