function sendAcknowledge($services_id)
 {
     global $DB;
     $pmService = new PluginMonitoringService();
     $pmComponent = new PluginMonitoringComponent();
     $pmTag = new PluginMonitoringTag();
     $pmService->getFromDB($services_id);
     $hostname = '';
     $queryh = "SELECT * FROM `glpi_plugin_monitoring_componentscatalogs_hosts` \n         WHERE `id` = '" . $pmService->fields['plugin_monitoring_componentscatalogs_hosts_id'] . "'\n         LIMIT 1";
     $resulth = $DB->query($queryh);
     while ($datah = $DB->fetch_array($resulth)) {
         $itemtype = $datah['itemtype'];
         $item = new $itemtype();
         if ($item->getFromDB($datah['items_id'])) {
             $hostname = $itemtype . "-" . $datah['items_id'] . "-" . preg_replace("/[^A-Za-z0-9]/", "", $item->fields['name']);
         }
     }
     $a_component = current($pmComponent->find("`id`='" . $pmService->fields['plugin_monitoring_components_id'] . "'", "", 1));
     $service_description = preg_replace("/[^A-Za-z0-9]/", "", $a_component['name']) . "-" . $pmService->fields['id'];
     $tag = PluginMonitoringEntity::getTagByEntities($pmService->fields['entities_id']);
     $ip = $pmTag->getIP($tag);
     $auth = $pmTag->getAuth($tag);
     $url = 'http://' . $ip . ':7760/';
     $action = 'acknowledge';
     $a_fields = array('host_name' => urlencode($hostname), 'service_description' => urlencode($service_description), 'author' => urlencode($_SESSION['glpiname']), 'comment' => urlencode(''));
     $this->sendCommand($url, $action, $a_fields, '', $auth);
 }
 function sendDowntime($host_id = -1, $service_id = -1, $author = '', $comment = '', $flexible = '0', $start_time = '0', $end_time = '0', $duration = '3600', $operation = '')
 {
     global $DB;
     if ($host_id == -1 && $service_id == -1) {
         return false;
     }
     $pmTag = new PluginMonitoringTag();
     $pmService = new PluginMonitoringService();
     $pmService->getFromDB($service_id);
     $service_description = $pmService->getName(array('shinken' => '1'));
     $pmHost = new PluginMonitoringHost();
     $pmHost->getFromDB($host_id == -1 ? $pmService->getHostID() : $host_id);
     $hostname = $pmHost->getName(true);
     // Downtime an host ...
     $acknowledgeServiceOnly = true;
     $a_fields = array();
     if ($host_id == -1) {
         $tag = PluginMonitoringEntity::getTagByEntities($pmService->getEntityID());
     } else {
         // ... one service of the host.
         $tag = PluginMonitoringEntity::getTagByEntities($pmHost->getEntityID());
     }
     $ip = $pmTag->getIP($tag);
     $auth = $pmTag->getAuth($tag);
     $port = $pmTag->getPort($tag);
     $url = 'http://' . $ip . ':' . $port . '/';
     $action = 'downtime';
     $a_fields = array('action' => empty($operation) ? 'add' : $operation, 'host_name' => $hostname, 'service_description' => $service_description, 'author' => $author, 'comment' => mb_convert_encoding($comment, "iso-8859-1"), 'flexible' => $flexible, 'start_time' => PluginMonitoringServiceevent::convert_datetime_timestamp($start_time), 'end_time' => PluginMonitoringServiceevent::convert_datetime_timestamp($end_time), 'trigger_id' => '0', 'duration' => $duration);
     // Send downtime command ...
     return $this->sendCommand($url, $action, $a_fields, '', $auth);
 }