static function loadPreferences($components_id)
 {
     $pmComponent = new PluginMonitoringComponent();
     $pmComponent->getFromDB($components_id);
     $_SESSION['glpi_plugin_monitoring']['perfname'][$components_id] = array();
     // $a_perfname = importArrayFromDB($pmComponent->fields['perfname']);
     if ($pmComponent->fields['perfname'] == '') {
         $a_perfname = FALSE;
     } else {
         $a_perfname = @unserialize($pmComponent->fields['perfname']);
     }
     if ($a_perfname === FALSE) {
         // Val not serialized
         $input = array('id' => $pmComponent->fields['id'], 'perfname' => '');
         $pmComponent->update($input);
         $a_perfname = array();
         if (isset($_SESSION['glpi_plugin_monitoring']['perfname'][$components_id])) {
             unset($_SESSION['glpi_plugin_monitoring']['perfname'][$components_id]);
         }
     }
     // No perfdata for this service ...
     if (!is_array($a_perfname)) {
         return false;
     }
     foreach ($a_perfname as $perfname => $active) {
         $_SESSION['glpi_plugin_monitoring']['perfname'][$components_id][$perfname] = 'checked';
     }
     $_SESSION['glpi_plugin_monitoring']['perfnameinvert'][$components_id] = array();
     // $a_perfnameinvert = importArrayFromDB($pmComponent->fields['perfnameinvert']);
     if ($pmComponent->fields['perfnameinvert'] == '' || $pmComponent->fields['perfnameinvert'] == '[]') {
         $a_perfnameinvert = FALSE;
     } else {
         ob_start();
         $a_perfnameinvert = @unserialize($pmComponent->fields['perfnameinvert']);
         ob_clean();
     }
     if ($a_perfnameinvert !== false) {
         foreach ($a_perfnameinvert as $perfname => $active) {
             $_SESSION['glpi_plugin_monitoring']['perfnameinvert'][$components_id][$perfname] = 'checked';
         }
         $_SESSION['glpi_plugin_monitoring']['perfnamecolor'][$components_id] = array();
         // $a_perfnamecolor = importArrayFromDB($pmComponent->fields['perfnamecolor']);
         $a_perfnamecolor = unserialize($pmComponent->fields['perfnamecolor']);
         foreach ($a_perfnamecolor as $perfname => $color) {
             $_SESSION['glpi_plugin_monitoring']['perfnamecolor'][$components_id][$perfname] = $color;
         }
     }
     return true;
 }
Example #2
0
         Html::back();
     }
     if ($_POST['graph_template'] != '') {
         if (!isset($_POST['perfname']) and !isset($_POST['perfnameinvert']) and !isset($_POST['perfnamecolor'])) {
             $pMonitoringComponent->getFromDB($_POST['id']);
             if (empty($pMonitoringComponent->fields['perfname']) and empty($pMonitoringComponent->fields['perfnameinvert']) and empty($pMonitoringComponent->fields['perfnamecolor'])) {
                 $a_perfnames = array();
                 $a_perfnames = PluginMonitoringServicegraph::getperfdataNames($_POST['graph_template']);
                 foreach ($a_perfnames as $name) {
                     $a_perfnames[$name] = 1;
                 }
                 $_POST['perfname'] = exportArrayToDB($a_perfnames);
             }
         }
     }
     $pMonitoringComponent->update($_POST);
     Html::back();
 } else {
     if (isset($_POST["delete"])) {
         $pMonitoringComponent->delete($_POST);
         $pMonitoringComponent->redirectToList();
     } else {
         if (isset($_POST['updateperfdata'])) {
             $a_perfname = array();
             if (isset($_POST['perfname'])) {
                 foreach ($_POST['perfname'] as $perfname) {
                     $a_perfname[$perfname] = '1';
                 }
             }
             $a_perfnameinvert = array();
             if (isset($_POST['perfnameinvert'])) {
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'], "updatePerfname.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();
$pmComponent = new PluginMonitoringComponent();
$sPerfname = explode(',', $_GET['perfname']);
$dbPerfname = array();
$_SESSION['glpi_plugin_monitoring']['perfname'][$_GET['components_id']] = array();
foreach ($sPerfname as $value) {
    $dbPerfname[$value] = 1;
    $_SESSION['glpi_plugin_monitoring']['perfname'][$_GET['components_id']][$value] = "checked";
}
if ($_GET['db']) {
    $input = array('id' => $_GET['components_id'], 'perfname' => serialize($dbPerfname));
    $pmComponent->update($input);
}
Html::ajaxFooter();