コード例 #1
0
   static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {

      if ($item->getID() > 0) {
         $pmContact = new PluginMonitoringContact();
         $pmContact->showForm(0);
      }
      return true;
   }
コード例 #2
0
 function manageContacts($items_id)
 {
     global $LANG;
     $pmContact = new PluginMonitoringContact();
     $user = new User();
     $a_list = $this->find("`plugin_monitoring_hosts_id`='" . $items_id . "'");
     echo "<form name='contacts_form' id='contacts_form'\n             method='post' action=' ";
     echo getItemTypeFormURL(__CLASS__) . "'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th colspan='3'>";
     echo $LANG['plugin_monitoring']['contact'][20];
     echo "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td class='right'>";
     $a_contacts = $pmContact->find();
     $a_elements = array();
     foreach ($a_contacts as $data) {
         $user->getFromDB($data['users_id']);
         $a_elements[$data['id']] = $user->getName();
     }
     asort($a_elements);
     Dropdown::showFromArray('plugin_monitoring_contacts_id', $a_elements);
     echo "</td>";
     echo "<td class='center'>";
     echo "<input type='submit' class='submit' name='parent_add' value='" . $LANG['buttons'][8] . " >>'>";
     echo "<br><br>";
     if ($a_list) {
         echo "<input type='submit' class='submit' name='parent_delete' value='<< " . $LANG['buttons'][6] . "'>";
     }
     echo "</td>";
     echo "<td>";
     if ($a_list) {
         echo "<select name='parent_to_delete[]' multiple size='5'>";
         foreach ($a_list as $data) {
             $pmContact->getFromDB($data['plugin_monitoring_contacts_id']);
             $user->getFromDB($pmContact->fields['users_id']);
             echo "<option value='" . $data['plugin_monitoring_contacts_id'] . "'>" . $user->getName() . "</option>";
         }
         echo "</select>";
     } else {
         echo "&nbsp;";
     }
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "<input type='hidden' name='id' value='" . $items_id . "' />";
     echo "</form>";
 }
コード例 #3
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;
   }
コード例 #4
0
ファイル: hook.php プロジェクト: RubichonL/glpi_monitoring
function plugin_headings_monitoring_contacts($item)
{
    $pmContact = new PluginMonitoringContact();
    $pmContact->showForm(0);
}
コード例 #5
0
   @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("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);
コード例 #6
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 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;
 }