function plugin_init_environment() { global $PLUGIN_HOOKS, $CFG_GLPI; $PLUGIN_HOOKS['csrf_compliant']['environment'] = true; $PLUGIN_HOOKS['change_profile']['environment'] = array('PluginEnvironmentProfile', 'changeProfile'); $key = array_search("environment", $_SESSION['glpi_plugins']); if ($key == false) { $_SESSION["glpi_plugin_environment_installed"] = 0; $_SESSION["glpi_plugin_environment_appliances"] = 0; $_SESSION["glpi_plugin_environment_webapplications"] = 0; $_SESSION["glpi_plugin_environment_certificates"] = 0; $_SESSION["glpi_plugin_environment_accounts"] = 0; $_SESSION["glpi_plugin_environment_domains"] = 0; $_SESSION["glpi_plugin_environment_databases"] = 0; $_SESSION["glpi_plugin_environment_badges"] = 0; } if (Session::getLoginUserID()) { Plugin::registerClass('PluginEnvironmentProfile', array('addtabon' => 'Profile')); if (plugin_environment_haveRight("environment", "r") && isset($_SESSION["glpi_plugin_environment_installed"]) && $_SESSION["glpi_plugin_environment_installed"] == 1) { $PLUGIN_HOOKS['menu_entry']['environment'] = 'front/environment.php'; } if (class_exists('PluginEnvironmentProfile')) { // only if plugin activated //Clean Plugin on Profile delete $PLUGIN_HOOKS['pre_item_purge']['environment'] = array('Profile' => array('PluginEnvironmentProfile', 'purgeProfiles')); } } }
function showBadges($badges) { global $CFG_GLPI, $DB; if (plugin_environment_haveRight("badges", "r") && $badges != 0) { echo "<table class='tab_cadrehov' width='750px'>"; echo "<tr>"; echo "<th class='center top' colspan='2'>"; echo "<a href=\"" . $CFG_GLPI["root_doc"] . "/plugins/badges/front/badge.php\">"; _e('Badges', 'environment'); echo "</th></tr>"; $query = "SELECT COUNT(`glpi_plugin_badges_badges`.`id`) AS total,\n `glpi_plugin_badges_badgetypes`.`name` AS TYPE,\n `glpi_plugin_badges_badges`.`entities_id` \n 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' " . getEntitiesRestrictRequest(" AND ", "glpi_plugin_badges_badges", '', '', false); $query .= "GROUP BY `glpi_plugin_badges_badges`.`entities_id`,`TYPE`\n ORDER BY `glpi_entities`.`completename`, `glpi_plugin_badges_badgetypes`.`name` "; $result = $DB->query($query); if ($DB->numrows($result)) { echo "<tr><th colspan='2'>" . __('Badges', '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 = "&link[1]=AND&searchtype[1]=contains&contains[1]=NULL&field[1]=80"; } else { $link = "&link[1]=AND&searchtype[1]=contains&contains[1]=" . Dropdown::getDropdownName("glpi_entities", $data["entities_id"]) . "&field[1]=80"; } } if (empty($data["TYPE"])) { echo "<td><a href='" . $CFG_GLPI["root_doc"] . "/plugins/badges/front/badge.php?glpisearchcount=2&searchtype[0]=contains&contains[0]=NULL&field[0]=2{$link}&is_deleted=0&itemtype=PluginBadgesBadge&start=0'>" . $data["total"] . " " . __('Without type', 'environment') . "</a></td>"; } else { echo "<td><a href='" . $CFG_GLPI["root_doc"] . "/plugins/badges/front/badge.php?glpisearchcount=2&searchtype[0]=contains&contains[0]=" . rawurlencode($data["TYPE"]) . "&field[0]=2{$link}&is_deleted=0&itemtype=PluginBadgesBadge&start=0'>" . $data["total"] . " " . $data["TYPE"] . "</a></td>"; } echo "</tr>"; } } else { echo "<tr><th colspan='2'>" . __('Badges', 'environment') . " : 0</th></tr>"; } echo "</table><br>"; } }
$tabs['appliances'] = array('title' => __('Appliances', 'environment'), 'url' => $CFG_GLPI['root_doc'] . "/plugins/environment/ajax/environment.tabs.php", 'params' => "target=" . $_SERVER['PHP_SELF'] . "&appliances={$appliances}&plugin_environment_tab=appliances"); } if ($webapplications != 0 && plugin_environment_haveRight("webapplications", "r")) { $tabs['webapplications'] = array('title' => __('Web applications', 'environment'), 'url' => $CFG_GLPI['root_doc'] . "/plugins/environment/ajax/environment.tabs.php", 'params' => "target=" . $_SERVER['PHP_SELF'] . "&webapplications={$webapplications}&plugin_environment_tab=webapplications"); } if ($certificates != 0 && plugin_environment_haveRight("certificates", "r")) { $tabs['certificates'] = array('title' => __('Certificates', 'environment'), 'url' => $CFG_GLPI['root_doc'] . "/plugins/environment/ajax/environment.tabs.php", 'params' => "target=" . $_SERVER['PHP_SELF'] . "&certificates={$certificates}&plugin_environment_tab=certificates"); } if ($accounts != 0 && plugin_environment_haveRight("accounts", "r")) { $tabs['accounts'] = array('title' => __('Accounts', 'environment'), 'url' => $CFG_GLPI['root_doc'] . "/plugins/environment/ajax/environment.tabs.php", 'params' => "target=" . $_SERVER['PHP_SELF'] . "&accounts={$accounts}&plugin_environment_tab=accounts"); } if ($domains != 0 && plugin_environment_haveRight("domains", "r")) { $tabs['domains'] = array('title' => __('Domains', 'environment'), 'url' => $CFG_GLPI['root_doc'] . "/plugins/environment/ajax/environment.tabs.php", 'params' => "target=" . $_SERVER['PHP_SELF'] . "&domains={$domains}&plugin_environment_tab=domains"); } if ($databases != 0 && plugin_environment_haveRight("databases", "r")) { $tabs['databases'] = array('title' => __('Databases', 'environment'), 'url' => $CFG_GLPI['root_doc'] . "/plugins/environment/ajax/environment.tabs.php", 'params' => "target=" . $_SERVER['PHP_SELF'] . "&databases={$databases}&plugin_environment_tab=databases"); } if ($badges != 0 && plugin_environment_haveRight("badges", "r")) { $tabs['badges'] = array('title' => __('Badges', 'environment'), 'url' => $CFG_GLPI['root_doc'] . "/plugins/environment/ajax/environment.tabs.php", 'params' => "target=" . $_SERVER['PHP_SELF'] . "&badges={$badges}&plugin_environment_tab=badges"); } $tabs['all'] = array('title' => __('All'), 'url' => $CFG_GLPI['root_doc'] . "/plugins/environment/ajax/environment.tabs.php", 'params' => "target=" . $_SERVER['PHP_SELF'] . "&appliances={$appliances}&webapplications={$webapplications}&certificates={$certificates}&accounts={$accounts}&domains={$domains}&databases={$databases}&badges={$badges}&plugin_environment_tab=all"); echo "<div id='tabspanel' class='center-h'></div>"; Ajax::createTabs('tabspanel', 'tabcontent', $tabs, 'PluginEnvironmentDisplay'); $env->addDivForTabs(); } else { Html::displayRightError(); } } else { Html::displayRightError(); } Html::footer();