예제 #1
0
 function menu()
 {
     global $CFG_GLPI;
     $redirect = FALSE;
     $a_url = array();
     echo "<table class='tab_cadre_fixe' width='950'>";
     echo "<tr class='tab_bg_3'>";
     echo "<td>";
     if (PluginMonitoringProfile::haveRight("restartshinken", 'w') || PluginMonitoringProfile::haveRight("servicescatalog", 'r') || PluginMonitoringProfile::haveRight("componentscatalog", 'r') || PluginMonitoringProfile::haveRight("allressources", 'r')) {
         echo "<table class='tab_cadre_fixe' width='950'>";
         echo "<tr class='tab_bg_1'>";
         echo "<th width='19%' colspan='2'>";
         if (PluginMonitoringProfile::haveRight("restartshinken", 'w')) {
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/restartshinken.form.php'>" . __('Restart Shinken', 'monitoring') . "</a>";
         }
         echo "</th>";
         echo "<th width='27%' colspan='2'>";
         if (PluginMonitoringProfile::haveRight("servicescatalog", 'r')) {
             $this->displayPuce('display_servicescatalog');
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display_servicescatalog.php'>";
             echo __('Services catalog', 'monitoring');
             echo "</a>";
             $a_url[] = $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display_servicescatalog.php";
         } else {
             if (basename($_SERVER['PHP_SELF']) == 'display_servicescatalog.php') {
                 $redirect = TRUE;
             }
         }
         echo "</th>";
         echo "<th width='27%' colspan='2'>";
         if (PluginMonitoringProfile::haveRight("componentscatalog", 'r')) {
             $this->displayPuce('display_componentscatalog');
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display_componentscatalog.php'>";
             echo __('Components catalog', 'monitoring');
             echo "</a>";
             $a_url[] = $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display_componentscatalog.php";
         } else {
             if (basename($_SERVER['PHP_SELF']) == 'display_componentscatalog.php') {
                 $redirect = TRUE;
             }
         }
         echo "</th>";
         echo "<th colspan='2'>";
         if (PluginMonitoringProfile::haveRight("allressources", 'r')) {
             $this->displayPuce('service');
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/service.php'>";
             echo __('All resources', 'monitoring');
             echo "</a>";
             $a_url[] = $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/service.php";
         } else {
             if (basename($_SERVER['PHP_SELF']) == 'service.php') {
                 $redirect = TRUE;
             }
         }
         echo "</th>";
         echo "</tr>";
         echo "</table>";
     } else {
         if (basename($_SERVER['PHP_SELF']) == 'display_servicescatalog.php') {
             $redirect = TRUE;
         } else {
             if (basename($_SERVER['PHP_SELF']) == 'display_componentscatalog.php') {
                 $redirect = TRUE;
             } else {
                 if (basename($_SERVER['PHP_SELF']) == 'service.php') {
                     $redirect = TRUE;
                 }
             }
         }
     }
     $i = 1;
     $pmDisplayview = new PluginMonitoringDisplayview();
     $a_views = $pmDisplayview->getViews();
     if (count($a_views) > 0) {
         echo "<table class='tab_cadre_fixe' width='950'>";
         echo "<tr class='tab_bg_1'>";
         foreach ($a_views as $views_id => $name) {
             $pmDisplayview->getFromDB($views_id);
             if ($pmDisplayview->haveVisibilityAccess()) {
                 if ($i == 6) {
                     echo "</tr>";
                     echo "<tr class='tab_bg_1'>";
                     $i = 1;
                 }
                 echo "<th width='20%'>";
                 $this->displayPuce('display_view', $views_id);
                 echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display_view.php?id=" . $views_id . "'>";
                 echo htmlentities($name);
                 echo "</a>";
                 echo "</th>";
                 $i++;
                 $a_url[] = $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display_view.php?id=" . $views_id;
             }
         }
         for ($i; $i < 6; $i++) {
             echo "<td width='20%'>";
             echo "</td>";
         }
         echo "</tr>";
         echo "</table>";
     }
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     if ($redirect) {
         Html::redirect(array_shift($a_url));
     }
 }
 static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
 {
     if ($item->getType() == 'PluginMonitoringDisplayview') {
         switch ($tabnum) {
             case 1:
                 $pmDisplayview_item = new PluginMonitoringDisplayview_item();
                 $pmDisplayview_item->view($item->getID(), 1);
                 break;
             case 2:
                 $item->showVisibility();
                 break;
         }
         if ($tabnum >= 20) {
             $pmDisplayview_rule = new PluginMonitoringDisplayview_rule();
             $pmDisplayview_rule->ShowRulesTabs($item->getID(), $tabnum);
         }
     } else {
         if ($item->getType() == 'Central') {
             if (Session::haveRight("plugin_monitoring_displayview", PluginMonitoringDisplayview::HOMEPAGE)) {
                 $pmDisplayview_item = new PluginMonitoringDisplayview_item();
                 $pmDisplayview = new PluginMonitoringDisplayview();
                 $a_views = $pmDisplayview->getViews(1);
                 foreach ($a_views as $views_id => $name) {
                     $pmDisplayview->getFromDB($views_id);
                     if ($pmDisplayview->haveVisibilityAccess()) {
                         $pmDisplayview_item->view($views_id);
                     }
                 }
             }
         }
     }
     return true;
 }
 function menu($refreshtype = '')
 {
     global $CFG_GLPI;
     $redirect = FALSE;
     $a_url = array();
     /* Moke-up for user's preferences ...
           if (PluginMonitoringProfile::haveRight("preferences", 'r')) {
              echo "<table class='tab_cadre_fixe' style='width: 120px; position: absolute; right: 15px;'>";
              echo "<tr class='tab_bg_1'>";
              echo "<td>";
              echo "<button><a href='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/restartshinken.form.php'>".__('Restart Shinken', 'monitoring')."</a></button>";
              echo "</td>";
              echo "</tr>";
              echo "</table>";
           }
     */
     echo "<table class='tab_cadre_fixe' width='950'>";
     echo "<tr class='tab_bg_3'>";
     echo "<td>";
     $this->restartShinken();
     if (Session::haveRight("plugin_monitoring_systemstatus", PluginMonitoringSystem::DASHBOARD) || Session::haveRight("plugin_monitoring_hoststatus", PluginMonitoringHost::DASHBOARD) || Session::haveRight("plugin_monitoring_servicescatalog", PluginMonitoringService::DASHBOARD) || Session::haveRight("plugin_monitoring_componentscatalog", PluginMonitoringComponentscatalog::DASHBOARD) || Session::haveRight("plugin_monitoring_service", PluginMonitoringService::DASHBOARD)) {
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'>";
         if (Session::haveRight("plugin_monitoring_systemstatus", PluginMonitoringSystem::DASHBOARD)) {
             echo "<th colspan='2'>";
             $this->displayPuce('display_system_status');
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display_system_status.php'>";
             echo __('System status', 'monitoring');
             echo "</a>";
             $pmTag = new PluginMonitoringTag();
             $servers = 'OK';
             if (!$pmTag->get_servers_status()) {
                 $servers = 'CRITICAL';
             }
             echo "<div class='service service" . $servers . "' style='float : left;'></div>";
             $a_url[] = $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display_system_status.php";
             echo "</th>";
         } else {
             if (basename($_SERVER['PHP_SELF']) == 'display_system_status.php') {
                 $redirect = TRUE;
             }
         }
         if (Session::haveRight("plugin_monitoring_hoststatus", PluginMonitoringHost::DASHBOARD)) {
             echo "<th colspan='2'>";
             $this->displayPuce('host');
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/host.php'>";
             echo __('Hosts status', 'monitoring');
             echo "</a>";
             $a_url[] = $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/host.php";
             echo "</th>";
         } else {
             if (basename($_SERVER['PHP_SELF']) == 'host.php') {
                 $redirect = TRUE;
             }
         }
         if (Session::haveRight("plugin_monitoring_servicescatalog", PluginMonitoringService::DASHBOARD)) {
             echo "<th colspan='2'>";
             $this->displayPuce('service');
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/service.php'>";
             echo __('All resources', 'monitoring');
             echo "</a>";
             $a_url[] = $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/service.php";
             echo "</th>";
         } else {
             if (basename($_SERVER['PHP_SELF']) == 'service.php') {
                 $redirect = TRUE;
             }
         }
         if (Session::haveRight("plugin_monitoring_service", PluginMonitoringService::DASHBOARD)) {
             echo "<th colspan='2'>";
             $this->displayPuce('perfdatas');
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/perfdatas.php'>";
             echo __('Performance data', 'monitoring');
             echo "</a>";
             $a_url[] = $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/perfdatas.php";
             echo "</th>";
         } else {
             if (basename($_SERVER['PHP_SELF']) == 'perfdatas.php') {
                 $redirect = TRUE;
             }
         }
         if (Session::haveRight("plugin_monitoring_servicescatalog", PluginMonitoringService::DASHBOARD)) {
             echo "<th colspan='2'>";
             $this->displayPuce('display_servicescatalog');
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display_servicescatalog.php'>";
             echo __('Services catalogs', 'monitoring');
             echo "</a>";
             $a_url[] = $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display_servicescatalog.php";
             echo "</th>";
         } else {
             if (basename($_SERVER['PHP_SELF']) == 'display_servicescatalog.php') {
                 $redirect = TRUE;
             }
         }
         if (Session::haveRight("plugin_monitoring_componentscatalog", PluginMonitoringComponentscatalog::DASHBOARD)) {
             echo "<th colspan='2'>";
             $this->displayPuce('display_componentscatalog');
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display_componentscatalog.php'>";
             echo __('Components catalogs', 'monitoring');
             echo "</a>";
             $a_url[] = $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display_componentscatalog.php";
             echo "</th>";
         } else {
             if (basename($_SERVER['PHP_SELF']) == 'display_componentscatalog.php') {
                 $redirect = TRUE;
             }
         }
         echo "</tr>";
         echo "</table>";
         if (Session::haveRight("plugin_monitoring_acknowledge", READ) || Session::haveRight("plugin_monitoring_downtime", READ)) {
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr class='tab_bg_1'>";
             echo "<th>";
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/downtime.php'>" . __('Downtimes', 'monitoring') . "</a>";
             echo "</th>";
             echo "<th>";
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/acknowledge.php'>" . __('Acknowledges', 'monitoring') . "</a>";
             echo "</th>";
             echo "</tr>";
             echo "</table>";
         }
     } else {
         if (basename($_SERVER['PHP_SELF']) == 'display_servicescatalog.php') {
             $redirect = TRUE;
         } else {
             if (basename($_SERVER['PHP_SELF']) == 'display_componentscatalog.php') {
                 $redirect = TRUE;
             } else {
                 if (basename($_SERVER['PHP_SELF']) == 'service.php') {
                     $redirect = TRUE;
                 } else {
                     if (basename($_SERVER['PHP_SELF']) == 'host.php') {
                         $redirect = TRUE;
                     }
                 }
             }
         }
     }
     if (Session::haveRight("plugin_monitoring_displayview", PluginMonitoringDisplayview::DASHBOARD)) {
         $i = 1;
         $pmDisplayview = new PluginMonitoringDisplayview();
         $a_views = $pmDisplayview->getViews();
         if (count($a_views) > 0) {
             echo "<table class='tab_cadre_fixe' width='950'>";
             echo "<tr class='tab_bg_1'>";
             foreach ($a_views as $views_id => $name) {
                 $pmDisplayview->getFromDB($views_id);
                 if ($pmDisplayview->haveVisibilityAccess()) {
                     if ($i == 6) {
                         echo "</tr>";
                         echo "<tr class='tab_bg_1'>";
                         $i = 1;
                     }
                     echo "<th width='20%'>";
                     $this->displayPuce('display_view', $views_id);
                     echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display_view.php?id=" . $views_id . "'>";
                     echo htmlentities($name);
                     echo "</a>";
                     echo "</th>";
                     $i++;
                     $a_url[] = $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display_view.php?id=" . $views_id;
                 }
             }
             // Fred : what is it for ?
             // It's to finish properly the table
             for ($i; $i < 6; $i++) {
                 echo "<td width='20%'>";
                 echo "</td>";
             }
             echo "</tr>";
             echo "</table>";
         }
     }
     if (Session::haveRight("plugin_monitoring_slider", PluginMonitoringSlider::DASHBOARD)) {
         $i = 1;
         $pmSlider = new PluginMonitoringSlider();
         $a_sliders = $pmSlider->getSliders();
         if (count($a_sliders) > 0) {
             echo "<table class='tab_cadre_fixe' width='950'>";
             echo "<tr class='tab_bg_1'>";
             foreach ($a_sliders as $sliders_id => $name) {
                 $pmSlider->getFromDB($sliders_id);
                 if ($pmSlider->haveVisibilityAccess()) {
                     if ($i == 6) {
                         echo "</tr>";
                         echo "<tr class='tab_bg_1'>";
                         $i = 1;
                     }
                     echo "<th width='20%'>";
                     $this->displayPuce('slider', $sliders_id);
                     echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display_slider.php?id=" . $sliders_id . "'>";
                     echo htmlentities($name);
                     echo "</a>";
                     echo "</th>";
                     $i++;
                     $a_url[] = $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display_slider.php?id=" . $sliders_id;
                 }
             }
             for ($i; $i < 6; $i++) {
                 echo "<td width='20%'>";
                 echo "</td>";
             }
             echo "</tr>";
             echo "</table>";
         }
     }
     if ($refreshtype == 'service') {
         $this->refreshPage();
     }
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     if ($redirect) {
         Html::redirect(array_shift($a_url));
     }
 }
  @license   AGPL License 3.0 or (at your option) any later version
             http://www.gnu.org/licenses/agpl-3.0-standalone.html
  @link      https://forge.indepnet.net/projects/monitoring/
  @since     2011

  ------------------------------------------------------------------------
*/
include "../../../inc/includes.php";
Session::checkCentralAccess();
Html::header(__('Monitoring', 'monitoring'), $_SERVER["PHP_SELF"], "plugins", "PluginMonitoringDashboard", "dashboard");
$pmDisplay = new PluginMonitoringDisplay();
$pmDisplayview = new PluginMonitoringDisplayview();
$pmDisplayview_item = new PluginMonitoringDisplayview_item();
$pmMessage = new PluginMonitoringMessage();
$pmMessage->getMessages();
$pmDisplay->menu();
$pass = 0;
$a_views = $pmDisplayview->getViews();
if (isset($a_views[$_GET['id']])) {
    $pmDisplayview->getFromDB($_GET['id']);
    $pass = $pmDisplayview->haveVisibilityAccess();
}
if ($pass == 0) {
    Session::checkRight("plugin_monitoring_displayview", READ);
}
if (isset($a_views[$_GET['id']])) {
    $pmDisplayview_item->view($_GET['id']);
} else {
    Html::displayRightError();
}
Html::footer();