Changeset 5890

Show
Ignore:
Timestamp:
07/24/08 13:46:44 (2 months ago)
Author:
jmathis
Message:

Remove PHP Warning and notive in host configuration when template field is empty

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/centreon/www/include/configuration/configObject/host/DB-Func.php

    r5851 r5890  
    842842                        while ($hst =& $DBRESULT->fetchRow()) 
    843843                                $oldTp[$hst["host_tpl_id"]] = $hst["host_tpl_id"];                       
    844                         for ($i=0;$i <= $_POST['nbOfSelect']; $i++) 
    845                         { 
     844                        for ($i=0;$i <= $_POST['nbOfSelect']; $i++){ 
    846845                                $tpSelect = "tpSelect_" . $i; 
    847                                 $newTp[$_POST[$tpSelect]] = $_POST[$tpSelect]; 
     846                                if (isset($_POST[$tpSelect])) 
     847                                        $newTp[$_POST[$tpSelect]] = $_POST[$tpSelect]; 
    848848                        } 
    849                         foreach ($oldTp as $val) 
    850                         { 
     849                         
     850                        foreach ($oldTp as $val){ 
    851851                                /* 
    852852                                 * if not set, then that means a template was removed 
     
    861861                        if (PEAR::isError($DBRESULT)) 
    862862                                print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 
    863                         for ($i=0, $j = 1;$i <= $_POST['nbOfSelect']; $i++) 
    864                         {                        
     863                        for ($i=0, $j = 1;$i <= $_POST['nbOfSelect']; $i++){ 
    865864                                $tpSelect = "tpSelect_" . $i; 
    866                                 if (!isset($already_stored[$_POST[$tpSelect]]) && $_POST[$tpSelect]) { 
     865                                if (isset($_POST[$tpSelect]) && !isset($already_stored[$_POST[$tpSelect]]) && $_POST[$tpSelect]) { 
    867866                                        $rq = "INSERT INTO host_template_relation (`host_host_id`, `host_tpl_id`, `order`) VALUES (". $host_id .", ". $_POST[$tpSelect] .", ". $j .")"; 
    868867                                        $DBRESULT =& $pearDB->query($rq); 
     
    881880                        $DBRESULT =& $pearDB->query("DELETE FROM `on_demand_macro_host` WHERE `host_host_id`='".$host_id."'"); 
    882881                         
    883                         for ($i=0; $i <= $_POST['nbOfMacro']; $i++) 
    884                         {                        
     882                        for ($i=0; $i <= $_POST['nbOfMacro']; $i++){                     
    885883                                $macInput = "macroInput_" . $i; 
    886884                                $macValue = "macroValue_" . $i;