function _addContactUser($a_contacts, $users_id, $i) { $pmContact = new PluginMonitoringContact(); $pmNotificationcommand = new PluginMonitoringNotificationcommand(); $pmContacttemplate = new PluginMonitoringContacttemplate(); $user = new User(); $calendar = new Calendar(); $user->getFromDB($users_id); // Get contact template $a_pmcontact = current($pmContact->find("`users_id`='".$users_id."'", "", 1)); if (empty($a_pmcontact) OR (isset($a_pmcontact['plugin_monitoring_contacttemplates_id']) AND $a_pmcontact['plugin_monitoring_contacttemplates_id'] == '0')) { // Use default template $a_pmcontact = current($pmContacttemplate->find("`is_default`='1'", "", 1)); } else { // Use contact defined template $a_pmcontact = current($pmContacttemplate->find("`id`='".$a_pmcontact['plugin_monitoring_contacttemplates_id']."'", "", 1)); } $a_contacts[$i]['contact_name'] = $user->fields['name']; $a_contacts[$i]['alias'] = $user->getName(); PluginMonitoringToolbox::logIfExtradebug( 'pm-shinken', "- contact ".$user->fields['name']." - ".$user->getName()."\n" ); // Toolbox::logInFile("pm-contacts", "- contact ".serialize($user->fields)."\n"); if (!isset($a_pmcontact['host_notification_period'])) { $a_calendars = current($calendar->find("", "", 1)); $cal = '24x7'; if (isset($a_calendars['name'])) { $cal = $a_calendars['name']; } $a_pmcontact['host_notifications_enabled'] = '0'; $a_pmcontact['service_notifications_enabled'] = '0'; $a_pmcontact['service_notification_period'] = $cal; $a_pmcontact['host_notification_period'] = $cal; $a_pmcontact['service_notification_options_w'] = '0'; $a_pmcontact['service_notification_options_u'] = '0'; $a_pmcontact['service_notification_options_c'] = '0'; $a_pmcontact['service_notification_options_r'] = '0'; $a_pmcontact['service_notification_options_f'] = '0'; $a_pmcontact['service_notification_options_n'] = '0'; $a_pmcontact['host_notification_options_d'] = '0'; $a_pmcontact['host_notification_options_u'] = '0'; $a_pmcontact['host_notification_options_r'] = '0'; $a_pmcontact['host_notification_options_f'] = '0'; $a_pmcontact['host_notification_options_s'] = '0'; $a_pmcontact['host_notification_options_n'] = '0'; $a_pmcontact['service_notification_commands'] = '2'; $a_pmcontact['host_notification_commands'] = '1'; } $a_contacts[$i]['host_notifications_enabled'] = $a_pmcontact['host_notifications_enabled']; $a_contacts[$i]['service_notifications_enabled'] = $a_pmcontact['service_notifications_enabled']; $calendar->getFromDB($a_pmcontact['service_notification_period']); if (isset($calendar->fields['name'])) { $a_contacts[$i]['service_notification_period'] = $calendar->fields['name']; } else { $a_contacts[$i]['service_notification_period'] = '24x7'; } $calendar->getFromDB($a_pmcontact['host_notification_period']); if (isset($calendar->fields['name'])) { $a_contacts[$i]['host_notification_period'] = $calendar->fields['name']; } else { $a_contacts[$i]['host_notification_period'] = '24x7'; } $a_servicenotif = array(); if ($a_pmcontact['service_notification_options_w'] == '1') $a_servicenotif[] = "w"; if ($a_pmcontact['service_notification_options_u'] == '1') $a_servicenotif[] = "u"; if ($a_pmcontact['service_notification_options_c'] == '1') $a_servicenotif[] = "c"; if ($a_pmcontact['service_notification_options_r'] == '1') $a_servicenotif[] = "r"; if ($a_pmcontact['service_notification_options_f'] == '1') $a_servicenotif[] = "f"; if ($a_pmcontact['service_notification_options_n'] == '1') $a_servicenotif = array("n"); if (count($a_servicenotif) == "0") $a_servicenotif = array("n"); $a_contacts[$i]['service_notification_options'] = implode(",", $a_servicenotif); $a_hostnotif = array(); if ($a_pmcontact['host_notification_options_d'] == '1') $a_hostnotif[] = "d"; if ($a_pmcontact['host_notification_options_u'] == '1') $a_hostnotif[] = "u"; if ($a_pmcontact['host_notification_options_r'] == '1') $a_hostnotif[] = "r"; if ($a_pmcontact['host_notification_options_f'] == '1') $a_hostnotif[] = "f"; if ($a_pmcontact['host_notification_options_s'] == '1') $a_hostnotif[] = "s"; if ($a_pmcontact['host_notification_options_n'] == '1') $a_hostnotif = array("n"); if (count($a_hostnotif) == "0") $a_hostnotif = array("n"); $a_contacts[$i]['host_notification_options'] = implode(",", $a_hostnotif); $pmNotificationcommand->getFromDB($a_pmcontact['service_notification_commands']); if (isset($pmNotificationcommand->fields['command_name'])) { $a_contacts[$i]['service_notification_commands'] = PluginMonitoringCommand::$command_prefix . $pmNotificationcommand->fields['command_name']; } else { $a_contacts[$i]['service_notification_commands'] = ''; } $pmNotificationcommand->getFromDB($a_pmcontact['host_notification_commands']); if (isset($pmNotificationcommand->fields['command_name'])) { $a_contacts[$i]['host_notification_commands'] = PluginMonitoringCommand::$command_prefix . $pmNotificationcommand->fields['command_name']; } else { $a_contacts[$i]['host_notification_commands'] = ''; } // Get first email $a_emails = UserEmail::getAllForUser($users_id); $first = 0; foreach ($a_emails as $email) { if ($first == 0) { $a_contacts[$i]['email'] = $email; } $first++; } if (!isset($a_contacts[$i]['email'])) { $a_contacts[$i]['email'] = ''; } $a_contacts[$i]['pager'] = $user->fields['phone']; if (isset($a_pmcontact['shinken_administrator'])) { $a_contacts[$i]['is_admin'] = $a_pmcontact['shinken_administrator']; } else { $a_contacts[$i]['is_admin'] = self::$shinkenParameters['webui']['contacts']['is_admin']; } if (isset($a_pmcontact['shinken_can_submit_commands'])) { $a_contacts[$i]['can_submit_commands'] = $a_pmcontact['shinken_can_submit_commands']; } else { $a_contacts[$i]['can_submit_commands'] = self::$shinkenParameters['webui']['contacts']['can_submit_commands']; } if (empty($user->fields['password'])) { $a_contacts[$i]['password'] = self::$shinkenParameters['webui']['contacts']['password']; } else { $a_contacts[$i]['password'] = $user->fields['password']; } /* TODO: address1, address2, ..., address6 are available in Shinken */ return $a_contacts; }
@package Plugin Monitoring for GLPI @author David Durieux @co-author @comment @copyright Copyright (c) 2011-2014 Plugin Monitoring for GLPI team @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::checkRight("user", READ); Html::header(__('Monitoring - contact templates', 'monitoring'), $_SERVER["PHP_SELF"], "plugins", "PluginMonitoringDashboard", "contacttemplate"); $pmContacttemplate = new PluginMonitoringContacttemplate(); if (isset($_POST["add"])) { if (!isset($_POST['users_id']) or $_POST['users_id'] != "0") { $pmContacttemplate->add($_POST); } Html::back(); } else { if (isset($_POST["update"])) { $pmContacttemplate->update($_POST); Html::back(); } else { if (isset($_POST["purge"])) { $pmContacttemplate->delete($_POST); Html::back(); } }
@since 2011 ------------------------------------------------------------------------ */ include ("../../../inc/includes.php"); Session::checkRight("plugin_monitoring_service", UPDATE); Html::header(__('Monitoring', 'monitoring'),$_SERVER["PHP_SELF"], "plugins", "monitoring", "host"); $pmContact = new PluginMonitoringContact(); if (isset($_POST["add"])) { if ($_POST['users_id'] != "0") { $pmContacttemplate = new PluginMonitoringContacttemplate(); $a_template = current($pmContacttemplate->find("`is_default`='1'", '', 1)); if (isset($a_template['id'])) { $_POST['plugin_monitoring_contacttemplates_id'] = $a_template['id']; } $pmContact->add($_POST); } Html::back(); } else if (isset ($_POST["update"])) { $pmContact->update($_POST); Html::back(); } else if (isset ($_POST["delete"])) { $pmContact->delete($_POST); Html::back(); }
static function getAdditionalMenuOptions() { global $CFG_GLPI; $main_menu = '<img src="' . $CFG_GLPI["root_doc"] . '/plugins/monitoring/pics/main_menu.png" alt="' . __('Main menu', 'monitoring') . '" title="' . __('Main menu', 'monitoring') . '"\\>'; return array('componentscatalog' => array('title' => PluginMonitoringComponentscatalog::getTypeName(), 'page' => PluginMonitoringComponentscatalog::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/componentscatalog.php', 'add' => '/plugins/monitoring/front/componentscatalog.form.php')), 'command' => array('title' => PluginMonitoringCommand::getTypeName(), 'page' => PluginMonitoringCommand::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/command.php', 'add' => '/plugins/monitoring/front/command.form.php')), 'check' => array('title' => PluginMonitoringCheck::getTypeName(), 'page' => PluginMonitoringCheck::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/check.php', 'add' => '/plugins/monitoring/front/check.form.php')), 'eventhandler' => array('title' => PluginMonitoringEventhandler::getTypeName(), 'page' => PluginMonitoringEventhandler::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/eventhandler.php', 'add' => '/plugins/monitoring/front/eventhandler.form.php')), 'perfdata' => array('title' => PluginMonitoringPerfdata::getTypeName(), 'page' => PluginMonitoringPerfdata::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/perfdata.php', 'add' => '/plugins/monitoring/front/perfdata.form.php')), 'component' => array('title' => PluginMonitoringComponent::getTypeName(), 'page' => PluginMonitoringComponent::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/component.php', 'add' => '/plugins/monitoring/front/component.form.php')), 'contacttemplate' => array('title' => PluginMonitoringContacttemplate::getTypeName(), 'page' => PluginMonitoringContacttemplate::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/contacttemplate.php', 'add' => '/plugins/monitoring/front/contacttemplate.form.php')), 'notificationcommand' => array('title' => PluginMonitoringNotificationcommand::getTypeName(), 'page' => PluginMonitoringNotificationcommand::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/notificationcommand.php', 'add' => '/plugins/monitoring/front/notificationcommand.form.php')), 'realm' => array('title' => PluginMonitoringRealm::getTypeName(), 'page' => PluginMonitoringRealm::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/realm.php', 'add' => '/plugins/monitoring/front/realm.form.php')), 'tag' => array('title' => PluginMonitoringTag::getTypeName(), 'page' => PluginMonitoringTag::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/tag.php')), 'servicescatalog' => array('title' => PluginMonitoringServicescatalog::getTypeName(), 'page' => PluginMonitoringServicescatalog::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/servicescatalog.php', 'add' => '/plugins/monitoring/front/servicescatalog.form.php')), 'weathermap' => array('title' => PluginMonitoringWeathermap::getTypeName(), 'page' => PluginMonitoringWeathermap::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/weathermap.php', 'add' => '/plugins/monitoring/front/weathermap.form.php')), 'displayview' => array('title' => PluginMonitoringDisplayview::getTypeName(), 'page' => PluginMonitoringDisplayview::getSearchURL(false), 'links' => array('search' => '/plugins/monitoring/front/displayview.php', 'add' => '/plugins/monitoring/front/displayview.form.php')), 'slider' => array('title' => PluginMonitoringSlider::getTypeName(), 'page' => PluginMonitoringSlider::getSearchURL(false), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'search' => '/plugins/monitoring/front/slider.php', 'add' => '/plugins/monitoring/front/slider.form.php')), 'downtime' => array('title' => PluginMonitoringDowntime::getTypeName(), 'page' => PluginMonitoringDowntime::getSearchURL(false), 'links' => array('search' => '/plugins/monitoring/front/downtime.php')), 'acknowledge' => array('title' => PluginMonitoringAcknowledge::getTypeName(), 'page' => PluginMonitoringAcknowledge::getSearchURL(false), 'links' => array('search' => '/plugins/monitoring/front/acknowledge.php')), 'menu' => array('title' => PluginMonitoringMenu::getTypeName(), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'config' => '/plugins/monitoring/front/config.form.php')), 'dashboard' => array('title' => PluginMonitoringDisplay::getTypeName(), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php', 'config' => '/plugins/monitoring/front/config.form.php')), 'config' => array('title' => PluginMonitoringConfig::getTypeName(), 'links' => array($main_menu => '/plugins/monitoring/front/menu.php'))); }
@author David Durieux @co-author @comment @copyright Copyright (c) 2011-2012 Plugin Monitoring for GLPI team @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 ------------------------------------------------------------------------ */ define('GLPI_ROOT', '../../..'); include GLPI_ROOT . "/inc/includes.php"; PluginMonitoringProfile::checkRight("config", "w"); commonHeader($LANG['plugin_monitoring']['title'][0], $_SERVER["PHP_SELF"], "plugins", "monitoring", "contacttemplates"); $pmContacttemplate = new PluginMonitoringContacttemplate(); if (isset($_POST["add"])) { if (!isset($_POST['users_id']) or $_POST['users_id'] != "0") { $pmContacttemplate->add($_POST); } glpi_header($_SERVER['HTTP_REFERER']); } else { if (isset($_POST["update"])) { $pmContacttemplate->update($_POST); glpi_header($_SERVER['HTTP_REFERER']); } else { if (isset($_POST["delete"])) { $pmContacttemplate->delete($_POST); glpi_header($_SERVER['HTTP_REFERER']); } }
function _addContactUser($a_contacts, $users_id, $i) { $pmContact = new PluginMonitoringContact(); $pmNotificationcommand = new PluginMonitoringNotificationcommand(); $pmContacttemplate = new PluginMonitoringContacttemplate(); $user = new User(); $calendar = new Calendar(); $user->getFromDB($users_id); // Get template $a_pmcontact = current($pmContact->find("`users_id`='" . $users_id . "'", "", 1)); if (empty($a_pmcontact) or isset($a_pmcontact['plugin_monitoring_contacttemplates_id']) and $a_pmcontact['plugin_monitoring_contacttemplates_id'] == '0') { $a_pmcontact = current($pmContacttemplate->find("`is_default`='1'", "", 1)); } else { $a_pmcontact = current($pmContacttemplate->find("`id`='" . $a_pmcontact['plugin_monitoring_contacttemplates_id'] . "'", "", 1)); } $a_contacts[$i]['contact_name'] = $user->fields['name']; $a_contacts[$i]['alias'] = $user->getName(); $a_contacts[$i]['host_notifications_enabled'] = $a_pmcontact['host_notifications_enabled']; $a_contacts[$i]['service_notifications_enabled'] = $a_pmcontact['service_notifications_enabled']; $calendar->getFromDB($a_pmcontact['service_notification_period']); $a_contacts[$i]['service_notification_period'] = $calendar->fields['name']; $calendar->getFromDB($a_pmcontact['host_notification_period']); $a_contacts[$i]['host_notification_period'] = $calendar->fields['name']; $a_servicenotif = array(); if ($a_pmcontact['service_notification_options_w'] == '1') { $a_servicenotif[] = "w"; } if ($a_pmcontact['service_notification_options_u'] == '1') { $a_servicenotif[] = "u"; } if ($a_pmcontact['service_notification_options_c'] == '1') { $a_servicenotif[] = "c"; } if ($a_pmcontact['service_notification_options_r'] == '1') { $a_servicenotif[] = "r"; } if ($a_pmcontact['service_notification_options_f'] == '1') { $a_servicenotif[] = "f"; } if ($a_pmcontact['service_notification_options_n'] == '1') { $a_servicenotif = array("n"); } if (count($a_servicenotif) == "0") { $a_servicenotif = array("n"); } $a_contacts[$i]['service_notification_options'] = implode(",", $a_servicenotif); $a_hostnotif = array(); if ($a_pmcontact['host_notification_options_d'] == '1') { $a_hostnotif[] = "d"; } if ($a_pmcontact['host_notification_options_u'] == '1') { $a_hostnotif[] = "u"; } if ($a_pmcontact['host_notification_options_r'] == '1') { $a_hostnotif[] = "r"; } if ($a_pmcontact['host_notification_options_f'] == '1') { $a_hostnotif[] = "f"; } if ($a_pmcontact['host_notification_options_s'] == '1') { $a_hostnotif[] = "s"; } if ($a_pmcontact['host_notification_options_n'] == '1') { $a_hostnotif = array("n"); } if (count($a_hostnotif) == "0") { $a_hostnotif = array("n"); } $a_contacts[$i]['host_notification_options'] = implode(",", $a_hostnotif); $pmNotificationcommand->getFromDB($a_pmcontact['service_notification_commands']); $a_contacts[$i]['service_notification_commands'] = $pmNotificationcommand->fields['command_name']; $pmNotificationcommand->getFromDB($a_pmcontact['host_notification_commands']); $a_contacts[$i]['host_notification_commands'] = $pmNotificationcommand->fields['command_name']; $a_contacts[$i]['email'] = $user->fields['email']; $a_contacts[$i]['pager'] = $user->fields['phone']; return $a_contacts; }