예제 #1
0
   function slideSlider($id) {
      global $CFG_GLPI, $DB;

      echo "<script type='text/javascript'>
         function fittext(itemid) {
            document.getElementById(itemid).style.fontSize = '50px';
            var fontsize = 50;
            while(document.getElementById(itemid).offsetWidth > 120) {
               fontsize--;
               if (fontsize > 20) {
                  fontsize--;
               }
               document.getElementById(itemid).style.fontSize = fontsize + 'px';
            }
            while(document.getElementById(itemid).offsetHeight > 67) {
               fontsize--;
               document.getElementById(itemid).style.fontSize = fontsize + 'px';
            }
            if (fontsize > 30) {
               document.getElementById(itemid).style.fontSize = '30px';
            }
            if (fontsize < 7) {
               document.getElementById(itemid).style.fontSize = '7px';
            }
         }
      </script>";
      PluginMonitoringToolbox::loadLib();

      $this->getFromDB($id);
      echo '<div id="custom_date" style="display:none"></div>';
      echo '<div id="custom_time" style="display:none"></div>';

      echo '<script src="'.$CFG_GLPI["root_doc"].'/plugins/monitoring/lib/slider.js-14/js/jssor.slider.mini.js"></script>
<script>
    jQuery(document).ready(function ($) {
        //Define an array of slideshow transition code
        var _SlideshowTransitions = [
        {$Duration:0001,$Opacity:2}
        ];
        var options = {
            $AutoPlay: true,
            $AutoPlayInterval: '.$this->fields['duration'].'000,
            $SlideshowOptions: {
                    $Class: $JssorSlideshowRunner$,
                    $Transitions: _SlideshowTransitions,
                    $TransitionsOrder: 1,
                    $ShowLink: true
        }
        };
        var jssor_slider1 = new $JssorSlider$(\'slider1_container\', options);
    });
</script>';
      echo "<table class='tab_cadre'>";

      echo "<tr>";
      echo "<td>";

      $query = "SELECT * FROM `glpi_plugin_monitoring_sliders_items`
              WHERE `plugin_monitoring_sliders_id`='".$id."'";

      $result = $DB->query($query);
      $maxWidth = 0;
      $maxHeight = 0;
      $is_minemap = 0;
      while ($data=$DB->fetch_array($result)) {
         if ($data['itemtype'] == 'PluginMonitoringServicescatalog'
                 || $data['itemtype'] == 'PluginMonitoringComponentscatalog'
                 || $data['itemtype'] == 'PluginMonitoringCustomitem_Gauge'
                 || $data['itemtype'] == 'PluginMonitoringCustomitem_Counter') {
            if ($maxWidth < 180) {
               $maxWidth = 180;
            }
            if ($maxHeight < 180) {
               $maxHeight = 180;
            }
            if ($data['is_minemap'] == 1) {
               $is_minemap = 1;
            }
         } else if ($data['itemtype'] == 'PluginMonitoringService') {
            if ($maxWidth < 475) {
               $maxWidth = 475;
            }
            if ($maxHeight < 330) {
               $maxHeight = 330;
            }
         } else if ($data['itemtype'] == "PluginMapsMap") {
            if ($maxWidth < 950) {
               $maxWidth = 950;
            }
            if ($maxHeight < 800) {
               $maxHeight = 800;
            }
         } else {
            $itemtype = $data['itemtype'];
            $item = new $itemtype();
            $item->getFromDB($data['items_id']);
            if ($maxWidth < $item->fields['width']) {
               $maxWidth = $item->fields['width'];
            }
            if (isset($item->fields['height'])) {
               if ($maxHeight < $item->fields['width']) {
                  $maxHeight = $item->fields['height'];
               }
            }
         }
      }
      if ($is_minemap) {
         $maxHeight = '1500';
      }

      $pm = new PluginMonitoringComponentscatalog();
      echo '<div id="slider1_container" style="position: relative;
top: 0px; left: 0px; width: '.$maxWidth.'px; height: '.$maxHeight.'px;">
    <!-- Slides Container -->
    <div u="slides" style="cursor: move; position: absolute; overflow: hidden;
    left: 0px; top: 0px; width: '.$maxWidth.'px; height: '.$maxHeight.'px;">';

      $result = $DB->query($query);
      while ($data=$DB->fetch_array($result)) {
         $itemtype = $data['itemtype'];
         $item = new $itemtype();
         if ($itemtype == "PluginMonitoringService") {
            echo '<div>';
            echo $item->showWidget($data['items_id'], $data['extra_infos']);
            echo '</div>';
         } else if ($itemtype == "PluginMonitoringWeathermap") {
            echo '<div>';
            echo '<div id="weathermap-'.$data['items_id'].'"></div>';
            echo '</div>';
         } else if ($itemtype == 'PluginMonitoringDisplayview') {
            echo '<div>';
            $pmDisplayview_item = new PluginMonitoringDisplayview_item();
            echo $pmDisplayview_item->view($data['items_id']);
            echo '</div>';
         } else if ($itemtype == "PluginMapsMap") {
            echo '<div>';
            echo '<div id="pluginmap"></div>';
            echo '</div>';
         } else {
            echo '<div>';
            echo $item->showWidget($data['items_id']);
            echo '</div>';
         }

      }
echo '    </div>
</div>';
      $result = $DB->query($query);
      while ($data=$DB->fetch_array($result)) {
         $itemtype = $data['itemtype'];
         $item = new $itemtype();
         // Ajax
         if ($itemtype == "PluginMonitoringService") {
            $pmComponent = new PluginMonitoringComponent();
            $item = new $itemtype();

            $item->getFromDB($data['items_id']);
            $pmComponent->getFromDB($item->fields['plugin_monitoring_components_id']);
            $pmServicegraph = new PluginMonitoringServicegraph();
            $pmServicegraph->displayGraph($pmComponent->fields['graph_template'],
                                          "PluginMonitoringService",
                                          $data['items_id'],
                                          "0",
                                          $data['extra_infos'],
                                          "js");
         } else if($itemtype == "PluginMonitoringComponentscatalog") {
            $pmComponentscatalog = new PluginMonitoringComponentscatalog();
            $pmComponentscatalog->ajaxLoad($data['items_id'], $data['is_minemap']);
         } else if($itemtype == "PluginMonitoringServicescatalog") {
            $pmServicescatalog = new PluginMonitoringServicescatalog();
            $pmServicescatalog->ajaxLoad($data['items_id']);
         } else if($itemtype == "PluginMonitoringDisplayview") {

         } else if($itemtype == "PluginMonitoringCustomitem_Gauge") {
            $pmCustomitem_Gauge = new PluginMonitoringCustomitem_Gauge();
            $pmCustomitem_Gauge->ajaxLoad($data['items_id']);
         } else if($itemtype == "PluginMonitoringCustomitem_Counter") {
            $pmCustomitem_Counter = new PluginMonitoringCustomitem_Counter();
            $pmCustomitem_Counter->ajaxLoad($data['items_id']);
         }
         if ($itemtype == "PluginMonitoringWeathermap") {
            $sess_id = session_id();
            PluginMonitoringSecurity::updateSession();

            echo "<script type='text/javascript'>
            var mgr = new Ext.UpdateManager('weathermap-".$data['items_id']."');
            mgr.startAutoRefresh(50, \"".$CFG_GLPI["root_doc"].
                    "/plugins/monitoring/ajax/widgetWeathermap.php\","
                    . " \"id=".$data['items_id']."&extra_infos=".
                    $data['extra_infos']."&sess_id=".$sess_id.
                    "&glpiID=".$_SESSION['glpiID'].
                    "&plugin_monitoring_securekey=".$_SESSION['plugin_monitoring_securekey'].
                    "\", \"\", true);
            </script>";
         }
         if ($itemtype == "PluginMapsMap") {
            $sess_id = session_id();
            PluginMonitoringSecurity::updateSession();

            echo "<script type='text/javascript'>
            var mgr = new Ext.UpdateManager('pluginmap');
            mgr.startAutoRefresh(50, \"".$CFG_GLPI["root_doc"].
                    "/plugins/monitoring/ajax/widgetPluginmap.php\","
                    . " \"extra_infos=".
                    $data['extra_infos']."&sess_id=".$sess_id.
                    "&glpiID=".$_SESSION['glpiID'].
                    "&plugin_monitoring_securekey=".$_SESSION['plugin_monitoring_securekey'].
                    "\", \"\", true);
            </script>";
         }
      }
      echo "</td>";
      echo "</tr>";
      echo "</table>";
   }
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--------------------------------------------------------------------------
*/
// ----------------------------------------------------------------------
// Original Author of file: David DURIEUX
// Purpose of file:
// ----------------------------------------------------------------------
// Direct access to file
if (strpos($_SERVER['PHP_SELF'], "updateWidgetCustomitem_counter.php")) {
    include "../../../inc/includes.php";
    header("Content-Type: text/html; charset=UTF-8");
    Html::header_nocache();
}
session_write_close();
if (!defined('GLPI_ROOT')) {
    die("Can not acces directly to this file");
}
Session::checkLoginUser();
$pmCustomitem_Counter = new PluginMonitoringCustomitem_Counter();
$pmCustomitem_Counter->showWidgetFrame($_POST['id']);
  @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("plugin_monitoring_displayview", READ);
Html::header(__('Monitoring - counter', 'monitoring'), $_SERVER["PHP_SELF"], "plugins", "monitoring", "customitem_counter");
$pmCustomitem_Counter = new PluginMonitoringCustomitem_Counter();
if (isset($_POST['add_item'])) {
    if (isset($_POST['item'])) {
        $pmCustomitem_Counter->getFromDB($_POST['id']);
        $input = array();
        $input['id'] = $_POST['id'];
        if ($pmCustomitem_Counter->fields['aggregate_items'] == '') {
            $aggregate_items = array();
        } else {
            $aggregate_items = importArrayFromDB($pmCustomitem_Counter->fields['aggregate_items']);
        }
        if (isset($_POST['plugin_monitoring_componentscatalogs_id'])) {
            $aggregate_items_add = array();
            $a = 'PluginMonitoringComponentscatalog';
            $b = $_POST['plugin_monitoring_componentscatalogs_id'];
            $c = 'PluginMonitoringComponent';
 function addItem($sliders_id)
 {
     global $DB, $CFG_GLPI;
     $this->getEmpty();
     $pmSlider = new PluginMonitoringSlider();
     $pmSlider->getFromDB($sliders_id);
     // Manage entity_sons
     $a_entities = array();
     if (!($pmSlider->fields['entities_id'] < 0)) {
         if ($pmSlider->fields['is_recursive'] == '0') {
             $a_entities[$pmSlider->fields['entities_id']] = $pmSlider->fields['entities_id'];
         } else {
             $a_entities = getSonsOf('glpi_entities', $pmSlider->fields['entities_id']);
         }
     }
     $options = array();
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     echo "<input type='hidden' name='plugin_monitoring_sliders_id' value='" . $sliders_id . "' />";
     echo __('Element to display', 'monitoring') . " :</td>";
     echo "<td>";
     $elements = array();
     $elements['NULL'] = Dropdown::EMPTY_VALUE;
     $elements['PluginMonitoringDisplayview'] = __('Views', 'monitoring');
     $elements['PluginMonitoringServicescatalog'] = PluginMonitoringServicescatalog::getTypeName();
     $elements['PluginMonitoringService'] = __('Resources (graph)', 'monitoring');
     $elements['PluginMonitoringComponentscatalog'] = __('Components catalog', 'monitoring');
     $elements['PluginMonitoringWeathermap'] = __('Weathermap', 'monitoring');
     $elements['PluginMonitoringCustomitem_Gauge'] = PluginMonitoringCustomitem_Gauge::getTypeName();
     $elements['PluginMonitoringCustomitem_Counter'] = PluginMonitoringCustomitem_Counter::getTypeName();
     if (in_array('maps', $_SESSION['glpi_plugins'])) {
         $elements['PluginMapsMap'] = 'Maps';
     }
     $rand = Dropdown::showFromArray('itemtype', $elements, array('value' => $this->fields['itemtype']));
     $params = array('itemtype' => '__VALUE__', 'sliders_id' => $sliders_id, 'myname' => "items_id", 'a_entities' => $a_entities);
     Ajax::updateItemOnSelectEvent("dropdown_itemtype" . $rand, "items_id", $CFG_GLPI["root_doc"] . "/plugins/monitoring/ajax/dropdownDisplayviewItemtype.php", $params);
     echo "<span id='items_id'></span>";
     echo "<input type='hidden' name='x' value='1' />";
     echo "<input type='hidden' name='y' value='1' />";
     echo "</td>";
     echo "<td colspan='2'></td>";
     echo "</tr>";
     $this->showFormButtons($options);
     // Show items
     $query = "SELECT * FROM `glpi_plugin_monitoring_sliders_items`\n              WHERE `plugin_monitoring_sliders_id`='" . $sliders_id . "'";
     $result = $DB->query($query);
     echo "<table class='tab_cadre' width='600'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th colspan='3'>";
     echo _n('Associated item', 'Associated items', 2);
     echo "</th>";
     echo "</tr>";
     while ($data = $DB->fetch_array($result)) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>";
         $itemtype = $data['itemtype'];
         $item = new $itemtype();
         echo $item->getTypeName();
         echo "</td>";
         echo "<td>";
         $item->getFromDB($data['items_id']);
         echo $item->getLink();
         echo "</td>";
         echo "<td>";
         echo "<form name='form' method='post' action='" . $this->getFormURL() . "' >";
         echo "<input type='hidden' name='id' value='" . $data['id'] . "'>";
         echo "<input type='submit' name='delete' value=\"" . _sx('button', 'Delete permanently') . "\"\n                class='submit' " . Html::addConfirmationOnAction(__('Confirm the final deletion?')) . ">";
         Html::closeForm();
         echo "</td>";
         echo "</tr>";
     }
     echo "</table>";
     return true;
 }
 function addItem($displayviews_id)
 {
     global $DB, $CFG_GLPI;
     $this->getEmpty();
     $pmDisplayview = new PluginMonitoringDisplayview();
     $pmDisplayview->getFromDB($displayviews_id);
     // Manage entity_sons
     $a_entities = array();
     if (!($pmDisplayview->fields['entities_id'] < 0)) {
         if ($pmDisplayview->fields['is_recursive'] == '0') {
             $a_entities[$pmDisplayview->fields['entities_id']] = $pmDisplayview->fields['entities_id'];
         } else {
             $a_entities = getSonsOf('glpi_entities', $pmDisplayview->fields['entities_id']);
         }
     }
     $options = array();
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     echo "<input type='hidden' name='plugin_monitoring_displayviews_id' value='" . $displayviews_id . "' />";
     echo __('Element to display', 'monitoring') . " :</td>";
     echo "<td>";
     $elements = array();
     $elements['NULL'] = Dropdown::EMPTY_VALUE;
     $elements['PluginMonitoringDisplayview'] = __('Views', 'monitoring');
     $elements['PluginMonitoringServicescatalog'] = PluginMonitoringServicescatalog::getTypeName();
     //      $elements['service']                             = __('Resources (info)', 'monitoring');
     $elements['host'] = __('Host (info)', 'monitoring');
     $elements['PluginMonitoringService'] = __('Resources (graph)', 'monitoring');
     $elements['PluginMonitoringComponentscatalog'] = __('Components catalog', 'monitoring');
     $elements['PluginMonitoringWeathermap'] = __('Weathermap', 'monitoring');
     $elements['PluginMonitoringCustomitem_Gauge'] = PluginMonitoringCustomitem_Gauge::getTypeName();
     $elements['PluginMonitoringCustomitem_Counter'] = PluginMonitoringCustomitem_Counter::getTypeName();
     $rand = Dropdown::showFromArray('itemtype', $elements, array('value' => $this->fields['itemtype']));
     $params = array('itemtype' => '__VALUE__', 'displayviews_id' => $displayviews_id, 'myname' => "items_id", 'a_entities' => $a_entities);
     Ajax::updateItemOnSelectEvent("dropdown_itemtype" . $rand, "items_id", $CFG_GLPI["root_doc"] . "/plugins/monitoring/ajax/dropdownDisplayviewItemtype.php", $params);
     echo "<span id='items_id'></span>";
     echo "<input type='hidden' name='x' value='1' />";
     echo "<input type='hidden' name='y' value='1' />";
     echo "</td>";
     echo "<td colspan='2'></td>";
     echo "</tr>";
     $this->showFormButtons($options);
     return true;
 }
  You should have received a copy of the GNU Affero General Public License
  along with Monitoring. If not, see <http://www.gnu.org/licenses/>.

  ------------------------------------------------------------------------

  @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     2014

  ------------------------------------------------------------------------
*/
// Direct access to file
if (strpos($_SERVER['PHP_SELF'], "counterData.php")) {
    include "../../../inc/includes.php";
    header("Content-Type: text/html; charset=UTF-8");
    Html::header_nocache();
}
if (!defined('GLPI_ROOT')) {
    die("Can not acces directly to this file");
}
Session::checkLoginUser();
if (isset($_POST['id'])) {
    $pmCustomitem_Counter = new PluginMonitoringCustomitem_Counter();
    $pmCustomitem_Counter->showDefineDataOfCounter($_POST['id']);
}