static function getMessages() { global $CFG_GLPI; $pmMessage = new self(); // Display if shinken is in restart or if restarted less than 5 minutes echo "<div id='shikenrestart'></div>"; echo "<script type=\"text/javascript\">\n (function worker() {\n \$.get('" . $CFG_GLPI["root_doc"] . "/plugins/monitoring/ajax/updateshinkenrestartmessage.php" . "?glpiID=" . $_SESSION['glpiID'] . "', function(data) {\n \$('#shikenrestart').html(data);\n setTimeout(worker, 30000);\n });\n })();\n </script>"; $servicecatalog = ''; $confchanges = ''; if (session::haveRight("plugin_monitoring_servicescatalog", READ)) { $servicecatalog = $pmMessage->servicescatalogMessage(); } $confchanges = $pmMessage->configurationchangesMessage(); $runningshinken = $pmMessage->ShinkennotrunMessage(); $i = 0; if ($servicecatalog != '' or $confchanges != '') { echo "<div class='msgboxmonit msgboxmonit-orange'>"; if ($confchanges != '') { echo $confchanges; $i++; } if ($servicecatalog != '') { if ($i > 0) { echo "</div>"; echo "<div class='msgboxmonit msgboxmonit-orange'>"; } echo $servicecatalog; $i++; } if ($runningshinken != '') { if ($i > 0) { echo "</div>"; echo "<div class='msgboxmonit msgboxmonit-red'>"; } echo $runningshinken . "!"; $i++; } echo "</div>"; } }
/** * @see CommonGLPI::getTabNameForItem() **/ function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { if (self::canView()) { $nb = 0; switch ($item->getType()) { case 'RSSFeed': $showtab = array(1 => __('Content')); if (session::haveRight('rssfeed_public', UPDATE)) { if ($_SESSION['glpishow_count_on_tabs']) { $nb = $item->countVisibilities(); } $showtab[2] = self::createTabEntry(_n('Target', 'Targets', Session::getPluralNumber()), $nb); } return $showtab; } } return ''; }
static function getMessages() { global $CFG_GLPI; $pmMessage = new self(); $sess_id = session_id(); // PluginMonitoringSecurity::updateSession(); // Display if shinken is in restart or if restarted less than 5 minutes echo "<div id='shikenrestart'></div>"; // echo "<script type=\"text/javascript\"> // var elshikenrestart = Ext.get(\"shikenrestart\"); // var mgrshikenrestart = elshikenrestart.getUpdateManager(); // mgrshikenrestart.loadScripts=true; // mgrshikenrestart.showLoadIndicator=false; // mgrshikenrestart.startAutoRefresh(30, \"".$CFG_GLPI["root_doc"]. // "/plugins/monitoring/ajax/updateshinkenrestartmessage.php\"," // . " \"sess_id=".$sess_id. // "&glpiID=".$_SESSION['glpiID']. // "&plugin_monitoring_securekey=".$_SESSION['plugin_monitoring_securekey']. // "\", \"\", true);"; // echo "</script>"; echo "<script type=\"text/javascript\"> (function worker() { $.get('".$CFG_GLPI["root_doc"]."/plugins/monitoring/ajax/updateshinkenrestartmessage.php" ."?sess_id=".$sess_id."&glpiID=".$_SESSION['glpiID']."', function(data) { $('#shikenrestart').html(data); setTimeout(worker, 30000); }); })(); </script>"; $servicecatalog = ''; $confchanges = ''; if (session::haveRight("plugin_monitoring_servicescatalog", READ)) { $servicecatalog = $pmMessage->servicescatalogMessage(); } $confchanges = $pmMessage->configurationchangesMessage(); $runningshinken = $pmMessage->ShinkennotrunMessage(); $i = 0; if ($servicecatalog != '' OR $confchanges != '') { echo "<div class='msgboxmonit msgboxmonit-orange'>"; if ($confchanges != '') { echo $confchanges; $i++; } if ($servicecatalog != '') { if($i > 0) { echo "</div>"; echo "<div class='msgboxmonit msgboxmonit-orange'>"; } echo $servicecatalog; $i++; } if ($runningshinken != '') { if($i > 0) { echo "</div>"; echo "<div class='msgboxmonit msgboxmonit-red'>"; } echo $runningshinken."!"; $i++; } echo "</div>"; } }
/** * Get name of the user with ID=$ID (optional with link to user.form.php) * *@param $ID integer ID of the user. *@param $link integer 1 = Show link to user.form.php 2 = return array with comments and link * (default =0) * *@return string : username string (realname if not empty and name if realname is empty). **/ function getUserName($ID, $link = 0) { global $DB, $CFG_GLPI; $user = ""; if ($link == 2) { $user = array("name" => "", "link" => "", "comment" => ""); } if ($ID) { $query = "SELECT *\n FROM `glpi_users`\n WHERE `id` = '{$ID}'"; $result = $DB->query($query); if ($link == 2) { $user = array("name" => "", "comment" => "", "link" => ""); } if ($DB->numrows($result) == 1) { $data = $DB->fetch_assoc($result); $username = formatUserName($data["id"], $data["name"], $data["realname"], $data["firstname"], $link); if ($link == 2) { $user["name"] = $username; $user["link"] = $CFG_GLPI["root_doc"] . "/front/user.form.php?id=" . $ID; $user['comment'] = ''; $comments = array(); $comments[] = array('name' => __('Name'), 'value' => $username); // Ident only if you have right to read user if (session::haveRight('user', READ)) { $comments[] = array('name' => __('Login'), 'value' => $data["name"]); } $email = UserEmail::getDefaultForUser($ID); if (!empty($email)) { $comments[] = array('name' => __('Email'), 'value' => $email); } if (!empty($data["phone"])) { $comments[] = array('name' => __('Phone'), 'value' => $data["phone"]); } if (!empty($data["mobile"])) { $comments[] = array('name' => __('Mobile phone'), 'value' => $data["mobile"]); } if ($data["locations_id"] > 0) { $comments[] = array('name' => __('Location'), 'value' => Dropdown::getDropdownName("glpi_locations", $data["locations_id"])); } if ($data["usertitles_id"] > 0) { $comments[] = array('name' => _x('person', 'Title'), 'value' => Dropdown::getDropdownName("glpi_usertitles", $data["usertitles_id"])); } if ($data["usercategories_id"] > 0) { $comments[] = array('name' => __('Category'), 'value' => Dropdown::getDropdownName("glpi_usercategories", $data["usercategories_id"])); } if (count($comments)) { $user['comment'] = $user['comment']; foreach ($comments as $datas) { // Do not use SPAN here $user['comment'] .= sprintf(__('%1$s: %2$s') . "<br>", "<strong>" . $datas['name'] . "</strong>", $datas['value']); } } if (!empty($data['picture'])) { $user['comment'] = "<div class='tooltip_picture_border'>" . "<img class='tooltip_picture' src='" . User::getThumbnailURLForPicture($data['picture']) . "' /></div>" . "<div class='tooltip_text'>" . $user['comment'] . "</div>"; } } else { $user = $username; } } } return $user; }