Esempio n. 1
0
function pluginMonitoringInstall($version)
{
    global $DB, $LANG, $CFG_GLPI;
    // ** Insert in DB
    $DB_file = GLPI_ROOT . "/plugins/monitoring/install/mysql/plugin_monitoring-" . $version . "-empty.sql";
    $DBf_handle = fopen($DB_file, "rt");
    $sql_query = fread($DBf_handle, filesize($DB_file));
    fclose($DBf_handle);
    foreach (explode(";\n", "{$sql_query}") as $sql_line) {
        if (get_magic_quotes_runtime()) {
            $sql_line = stripslashes_deep($sql_line);
        }
        if (!empty($sql_line)) {
            $DB->query($sql_line);
        }
    }
    include GLPI_ROOT . "/plugins/monitoring/inc/profile.class.php";
    $pmProfile = new PluginMonitoringProfile();
    $pmProfile->initProfile();
    include GLPI_ROOT . "/plugins/monitoring/inc/command.class.php";
    $pmCommand = new PluginMonitoringCommand();
    $pmCommand->initCommands();
    include GLPI_ROOT . "/plugins/monitoring/inc/notificationcommand.class.php";
    $pmNotificationcommand = new PluginMonitoringNotificationcommand();
    $pmNotificationcommand->initCommands();
    include GLPI_ROOT . "/plugins/monitoring/inc/check.class.php";
    $pmCheck = new PluginMonitoringCheck();
    $pmCheck->initChecks();
    include GLPI_ROOT . "/plugins/monitoring/inc/hostconfig.class.php";
    $pmHostconfig = new PluginMonitoringHostconfig();
    $pmHostconfig->initConfig();
    include GLPI_ROOT . "/plugins/monitoring/inc/config.class.php";
    $pmConfig = new PluginMonitoringConfig();
    $pmConfig->initConfig();
    $query = "UPDATE `glpi_plugin_monitoring_configs`\n      SET `version`='" . PLUGIN_MONITORING_VERSION . "'\n         WHERE `id`='1'";
    $DB->query($query);
    if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring')) {
        mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring");
    }
    if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring/templates')) {
        mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring/templates");
    }
    if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring/weathermapbg')) {
        mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring/weathermapbg");
    }
    CronTask::Register('PluginMonitoringServiceevent', 'updaterrd', '300', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30));
    CronTask::Register('PluginMonitoringLog', 'cleanlogs', '96400', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30));
    CronTask::Register('PluginMonitoringUnavaibility', 'unavaibility', '300', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30));
}
Esempio n. 2
0
   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     2013

  ------------------------------------------------------------------------
*/
include "../../../inc/includes.php";
Session::checkRight("plugin_monitoring_command", READ);
Html::header(__('Monitoring', 'monitoring'), $_SERVER["PHP_SELF"], "plugins", "PluginMonitoringDashboard", "notificationcommand");
$pmNotificationcommand = new PluginMonitoringNotificationcommand();
if (isset($_POST["copy"])) {
    $pmNotificationcommand->showForm("", array(), $_POST);
    Html::footer();
    exit;
} else {
    if (isset($_POST["add"])) {
        $pmNotificationcommand->add($_POST);
        Html::back();
    } else {
        if (isset($_POST["update"])) {
            $pmNotificationcommand->update($_POST);
            Html::back();
        } else {
            if (isset($_POST["purge"])) {
                $pmNotificationcommand->delete($_POST);
 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')));
 }
  @package   Plugin Monitoring for GLPI
  @author    David Durieux
  @co-author 
  @comment   
  @copyright Copyright (c) 2011-2013 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     2013

  ------------------------------------------------------------------------
*/
include "../../../inc/includes.php";
PluginMonitoringProfile::checkRight("config", "w");
Html::header(__('Monitoring', 'monitoring'), $_SERVER["PHP_SELF"], "plugins", "monitoring", "notificationcommand");
$pmNotificationcommand = new PluginMonitoringNotificationcommand();
if (isset($_POST["copy"])) {
    $pmNotificationcommand->showForm("", array(), $_POST);
    Html::footer();
    exit;
} else {
    if (isset($_POST["add"])) {
        $_POST = $pmNotificationcommand->convertPostdata($_POST);
        $pmNotificationcommand->add($_POST);
        Html::back();
    } else {
        if (isset($_POST["update"])) {
            $_POST = $pmNotificationcommand->convertPostdata($_POST);
            $pmNotificationcommand->update($_POST);
            Html::back();
        } else {
Esempio n. 6
0
function pluginMonitoringInstall($version)
{
    global $DB, $CFG_GLPI;
    // ** Insert in DB
    $DB_file = GLPI_ROOT . "/plugins/monitoring/install/mysql/plugin_monitoring-" . $version . "-empty.sql";
    $DBf_handle = fopen($DB_file, "rt");
    $sql_query = fread($DBf_handle, filesize($DB_file));
    fclose($DBf_handle);
    foreach (explode(";\n", "{$sql_query}") as $sql_line) {
        if (get_magic_quotes_runtime()) {
            $sql_line = Toolbox::stripslashes_deep($sql_line);
        }
        if (!empty($sql_line)) {
            $DB->query($sql_line);
        }
    }
    include GLPI_ROOT . "/plugins/monitoring/inc/profile.class.php";
    $pmProfile = new PluginMonitoringProfile();
    $pmProfile->initProfile();
    include GLPI_ROOT . "/plugins/monitoring/inc/command.class.php";
    $pmCommand = new PluginMonitoringCommand();
    $pmCommand->initCommands();
    include GLPI_ROOT . "/plugins/monitoring/inc/notificationcommand.class.php";
    $pmNotificationcommand = new PluginMonitoringNotificationcommand();
    $pmNotificationcommand->initCommands();
    include GLPI_ROOT . "/plugins/monitoring/inc/check.class.php";
    $pmCheck = new PluginMonitoringCheck();
    $pmCheck->initChecks();
    include GLPI_ROOT . "/plugins/monitoring/inc/hostconfig.class.php";
    $pmHostconfig = new PluginMonitoringHostconfig();
    $pmHostconfig->initConfig();
    include GLPI_ROOT . "/plugins/monitoring/inc/config.class.php";
    $pmConfig = new PluginMonitoringConfig();
    $pmConfig->initConfig();
    $query = "UPDATE `glpi_plugin_monitoring_configs`\n      SET `version`='" . PLUGIN_MONITORING_VERSION . "'\n         WHERE `id`='1'";
    $DB->query($query);
    $query = "SELECT * FROM `glpi_calendars`\n      WHERE `name`='24x7'\n      LIMIT 1";
    $result = $DB->query($query);
    if ($DB->numrows($result) == 0) {
        $calendar = new Calendar();
        $input = array();
        $input['name'] = '24x7';
        $input['is_recursive'] = 1;
        $calendars_id = $calendar->add($input);
        $calendarSegment = new CalendarSegment();
        $input = array();
        $input['calendars_id'] = $calendars_id;
        $input['is_recursive'] = 1;
        $input['begin'] = '00:00:00';
        $input['end'] = '24:00:00';
        $input['day'] = '0';
        $calendarSegment->add($input);
        $input['day'] = '1';
        $calendarSegment->add($input);
        $input['day'] = '2';
        $calendarSegment->add($input);
        $input['day'] = '3';
        $calendarSegment->add($input);
        $input['day'] = '4';
        $calendarSegment->add($input);
        $input['day'] = '5';
        $calendarSegment->add($input);
        $input['day'] = '6';
        $calendarSegment->add($input);
    }
    if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring')) {
        mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring");
    }
    if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring/templates')) {
        mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring/templates");
    }
    if (!is_dir(GLPI_PLUGIN_DOC_DIR . '/monitoring/weathermapbg')) {
        mkdir(GLPI_PLUGIN_DOC_DIR . "/monitoring/weathermapbg");
    }
    CronTask::Register('PluginMonitoringServiceevent', 'updaterrd', '300', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30));
    CronTask::Register('PluginMonitoringLog', 'cleanlogs', '96400', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30));
    CronTask::Register('PluginMonitoringUnavaibility', 'unavaibility', '300', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30));
    CronTask::Register('PluginMonitoringDisplayview_rule', 'replayallviewrules', '1200', array('mode' => 2, 'allowmode' => 3, 'logs_lifetime' => 30));
}
 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;
 }