@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_acknowledge", READ);
Html::header(__('Monitoring - acknowledges', 'monitoring'), '', "plugins", "PluginMonitoringDashboard", "acknowledge");
$pmAcknowledge = new PluginMonitoringAcknowledge();
if (isset($_POST["add"])) {
    $pmAcknowledge->add($_POST);
    $pmAcknowledge->redirectToList();
} else {
    if (isset($_POST["update"])) {
        $pmAcknowledge->update($_POST);
        $pmAcknowledge->redirectToList();
    } else {
        if (isset($_POST["purge"])) {
            $pmAcknowledge->delete($_POST);
            $pmAcknowledge->redirectToList();
        }
    }
}
// Read or edit acknowledge ...
示例#2
0
   function getAcknowledge() {
      if ($this->getID() == -1) return false;

      $pmAcknowledge = new PluginMonitoringAcknowledge();
      if ($pmAcknowledge->getFromHost($this->getID(), 'Service') != -1) {
         return ($pmAcknowledge->getComments());
      }

      return '';
   }
 /**
  *
  *
  * @param $items_id integer ID
  *
  * @param $host_id integer associated host ID
  * @param $options array
  *
  *@return bool true if form is ok
  *
  **/
 function showForm($id = -1, $itemtype = 'Host', $items_id = -1, $options = array())
 {
     global $DB, $CFG_GLPI;
     // Toolbox::logInFile("pm-ack", "acknowledge, showForm, id : $id, item type : $itemtype / $items_id\n");
     $createAcknowledge = false;
     if ($id == -1) {
         // if ($itemtype == 'N/A') $itemtype = 'Computer';
         // if ($itemtype == '') $itemtype = 'Computer';
         $itemtype = 'PluginMonitoring' . $itemtype;
         $item = new $itemtype();
         $item->getFromDB($items_id);
         if ($item->isCurrentlyAcknowledged()) {
             // If host currently acknowledged, show current acknowledge ...
             $pmAcknowledge = new PluginMonitoringAcknowledge();
             $this->getFromDB($pmAcknowledge->getFromHost($this->getID()));
         } else {
             // .. else create new acknowledge
             $createAcknowledge = true;
             $this->getEmpty();
             $this->setDefaultContent($itemtype, $items_id);
         }
     } else {
         $this->getFromDB($id);
         $createAcknowledge = true;
     }
     // Now ...
     $nowDate = date('Y-m-d');
     $nowTime = date('H:i:s');
     $this->showFormHeader($options);
     $this->isExpired();
     $itemtype = $this->getField('itemtype');
     if ($itemtype == 'N/A') {
         $itemtype = 'Computer';
     }
     if ($itemtype == '') {
         $itemtype = 'Computer';
     }
     $item = new $itemtype();
     $item->getFromDB($this->getField("items_id"));
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $item->getTypeName() . "</td>";
     echo "<td>";
     echo "<input type='hidden' name='itemtype' value='" . $this->fields['itemtype'] . "' />";
     echo "<input type='hidden' name='items_id' value='" . $this->fields['items_id'] . "' />";
     echo $item->getLink() . "&nbsp;" . $item->getComments();
     echo "</td>";
     echo "<td>" . __('Sticky ?', 'monitoring') . "</td>";
     echo "<td>";
     if ($createAcknowledge) {
         Dropdown::showYesNo('sticky', $this->fields['sticky']);
     } else {
         echo Dropdown::getYesNo($this->fields['sticky']);
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Start time', 'monitoring') . "</td>";
     echo "<td>";
     $date = $this->fields["start_time"];
     Html::showDateTimeField("start_time", array('value' => $date, 'timestep' => 10, 'maybeempty' => false, 'canedit' => $createAcknowledge, 'mindate' => $nowDate, 'mintime' => $nowTime));
     echo "</td>";
     echo "<td>" . __('Persistent ?', 'monitoring') . "</td>";
     echo "<td>";
     if ($createAcknowledge) {
         Dropdown::showYesNo('persistent', $this->fields['persistent']);
     } else {
         echo Dropdown::getYesNo($this->fields['persistent']);
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('End time', 'monitoring') . "</td>";
     echo "<td>";
     $date = $this->fields["end_time"];
     Html::showDateTimeField("end_time", array('value' => $date, 'timestep' => 10, 'maybeempty' => false, 'canedit' => $createAcknowledge, 'mindate' => $nowDate, 'mintime' => $nowTime));
     echo "</td>";
     echo "<td>" . __('Notify ?', 'monitoring') . "</td>";
     echo "<td>";
     if ($createAcknowledge) {
         Dropdown::showYesNo('notify', $this->fields['notify']);
     } else {
         echo Dropdown::getYesNo($this->fields['notify']);
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Comment', 'monitoring') . "</td>";
     echo "<td >";
     if ($createAcknowledge) {
         echo "<textarea cols='80' rows='4' name='comment' >" . $this->fields['comment'] . "</textarea>";
     } else {
         echo "<textarea cols='80' rows='4' name='comment' readonly='1' disabled='1' >" . $this->fields['comment'] . "</textarea>";
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('User', 'monitoring') . "</td>";
     echo "<td>";
     echo "<input type='hidden' name='users_id' value='" . $this->fields['users_id'] . "' />";
     echo $this->getUsername();
     echo "</td>";
     echo "<td>" . __('Expired ?', 'monitoring') . "</td>";
     echo "<td>";
     echo Dropdown::getYesNo($this->fields['expired']);
     echo "</td>";
     echo "</tr>";
     $this->showFormButtons();
     return true;
 }
 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')));
 }