Changeset 6693

Show
Ignore:
Timestamp:
10/02/08 12:23:26 (2 months ago)
Author:
shotamchay
Message:

development on user action log

Location:
trunk/centreon/www/include/configuration/configObject
Files:
4 modified

Legend:

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

    r6665 r6693  
    7777                                        $key2 == "command_name" ? ($command_name = $value2 = $value2."_".$i) : null; 
    7878                                        $val ? $val .= ($value2 != NULL?(", '".$value2."'"):", NULL") : $val .= ($value2 != NULL?("'".$value2."'"):"NULL"); 
    79                                         $fields[$key2] = $value2; 
     79                                        if ($key2 != "command_id") 
     80                                                $fields[$key2] = $value2; 
    8081                                        $fields["command_name"] = $command_name; 
    8182                                } 
  • trunk/centreon/www/include/configuration/configObject/contact/DB-Func.php

    r6646 r6693  
    7777 
    7878        function enableContactInDB ($contact_id = null, $contact_arr = array()) { 
    79                 global $pearDB; 
     79                global $pearDB, $oreon; 
    8080                 
    8181                if (!$contact_id && !count($contact_arr))  
     
    8787                        if (PEAR::isError($DBRESULT)) 
    8888                                print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 
     89                        $DBRESULT2 =& $pearDB->query("SELECT contact_name FROM `contact` WHERE `contact_id` = '".$key."' LIMIT 1"); 
     90                        if (PEAR::isError($DBRESULT2)) 
     91                                print "DB Error : ".$DBRESULT2->getDebugInfo()."<br />"; 
     92                        $row = $DBRESULT2->fetchRow(); 
     93                        $oreon->CentreonLogAction->insertLog("contact", $key, $row['contact_name'], "enable"); 
    8994                } 
    9095        } 
     
    9297        function disableContactInDB ($contact_id = null, $contact_arr = array())        { 
    9398                if (!$contact_id && !count($contact_arr)) return; 
    94                 global $pearDB; 
     99                global $pearDB, $oreon; 
    95100                if ($contact_id) 
    96101                        $contact_arr = array($contact_id=>"1"); 
     
    100105                                if (PEAR::isError($DBRESULT)) 
    101106                                        print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 
     107                                $DBRESULT2 =& $pearDB->query("SELECT contact_name FROM `contact` WHERE `contact_id` = '".$key."' LIMIT 1"); 
     108                                if (PEAR::isError($DBRESULT2)) 
     109                                        print "DB Error : ".$DBRESULT2->getDebugInfo()."<br />"; 
     110                                $row = $DBRESULT2->fetchRow(); 
     111                                $oreon->CentreonLogAction->insertLog("contact", $key, $row['contact_name'], "disable"); 
    102112                        } 
    103113                } 
     
    105115 
    106116        function deleteContactInDB ($contacts = array())        { 
    107                 global $pearDB; 
     117                global $pearDB, $oreon; 
    108118                foreach($contacts as $key=>$value)      { 
     119                        $DBRESULT2 =& $pearDB->query("SELECT contact_name FROM `contact` WHERE `contact_id` = '".$key."' LIMIT 1"); 
     120                        if (PEAR::isError($DBRESULT2)) 
     121                                print "DB Error : ".$DBRESULT2->getDebugInfo()."<br />"; 
     122                        $row = $DBRESULT2->fetchRow(); 
     123                         
    109124                        $DBRESULT =& $pearDB->query("DELETE FROM contact WHERE contact_id = '".$key."'"); 
    110125                        if (PEAR::isError($DBRESULT)) 
    111126                                print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 
     127                        $oreon->CentreonLogAction->insertLog("contact", $key, $row['contact_name'], "d"); 
    112128                } 
    113129        } 
    114130 
    115131        function multipleContactInDB ($contacts = array(), $nbrDup = array())   { 
    116                 global $pearDB; 
     132                global $pearDB, $oreon; 
    117133                foreach ($contacts as $key=>$value)     { 
    118134                        $DBRESULT =& $pearDB->query("SELECT * FROM contact WHERE contact_id = '".$key."' LIMIT 1"); 
     
    127143                                        $key2 == "contact_alias" ? ($contact_alias = $value2 = $value2."_".$i) : null; 
    128144                                        $val ? $val .= ($value2!=NULL?(", '".$value2."'"):", NULL") : $val .= ($value2 != NULL?("'".$value2."'"):"NULL"); 
     145                                        if ($key2 != "contact_id") 
     146                                                $fields[$key2] = $value2; 
     147                                        $fields["contact_name"] = $contact_name; 
     148                                        $fields["contact_alias"] = $contact_alias; 
    129149                                } 
    130150                                if (testContactExistence($contact_name) && testAliasExistence($contact_alias))  { 
     
    138158                                        $maxId =& $DBRESULT->fetchRow(); 
    139159                                        if (isset($maxId["MAX(contact_id)"]))   { 
     160                                                $oreon->CentreonLogAction->insertLog("contact", $maxId["MAX(contact_id)"], $contact_name, "a", $fields);                                                 
    140161                                                $DBRESULT =& $pearDB->query("SELECT DISTINCT command_command_id FROM contact_hostcommands_relation WHERE contact_contact_id = '".$key."'"); 
    141162                                                if (PEAR::isError($DBRESULT)) 
     
    219240 
    220241        function insertContact($ret = array())  { 
    221                 global $form, $pearDB; 
     242                global $form, $pearDB, $oreon; 
    222243                if (!count($ret)) 
    223244                        $ret = $form->getSubmitValues(); 
     
    257278                        print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 
    258279                $contact_id = $DBRESULT->fetchRow(); 
     280                 
     281                $fields["timeperiod_tp_id"] = $ret["timeperiod_tp_id"]; 
     282                $fields["timeperiod_tp_id2"] = $ret["timeperiod_tp_id2"]; 
     283                $fields["contact_name"] = htmlentities($ret["contact_name"], ENT_QUOTES); 
     284                $fields["contact_alias"] = htmlentities($ret["contact_alias"], ENT_QUOTES); 
     285                $fields["contact_passwd"] = md5($ret["contact_passwd"]); 
     286                $fields["contact_lang"] = htmlentities($ret["contact_lang"], ENT_QUOTES); 
     287                $fields["contact_hostNotifOpts"] = implode(",", array_keys($ret["contact_hostNotifOpts"])); 
     288                $fields["contact_svNotifOpts"] = implode(",", array_keys($ret["contact_svNotifOpts"])); 
     289                $fields["contact_email"] = htmlentities($ret["contact_email"], ENT_QUOTES); 
     290                $fields["contact_pager"] = htmlentities($ret["contact_pager"], ENT_QUOTES); 
     291                $fields["contact_comment"] = htmlentities($ret["contact_comment"], ENT_QUOTES); 
     292                $fields["contact_oreon"] = $ret["contact_oreon"]["contact_oreon"]; 
     293                $fields["contact_admin"] = $ret["contact_admin"]["contact_admin"]; 
     294                $fields["contact_type_msg"] = $ret["contact_type_msg"]; 
     295                $fields["contact_activate"] = $ret["contact_activate"]["contact_activate"]; 
     296                $fields["contact_auth_type"] = $ret["contact_auth_type"]; 
     297                $fields["contact_ldap_dn"] = $ret["contact_ldap_dn"]; 
     298                $fields["contact_location"] = $ret["contact_location"]; 
     299                $oreon->CentreonLogAction->insertLog("contact", $contact_id["MAX(contact_id)"], $ret["contact_name"], "a", $fields); 
     300                 
    259301                return ($contact_id["MAX(contact_id)"]); 
    260302        } 
     
    313355                        $oreon->user->set_lang($ret["contact_lang"]); 
    314356                } 
     357                $fields["timeperiod_tp_id"] = $ret["timeperiod_tp_id"]; 
     358                $fields["timeperiod_tp_id2"] = $ret["timeperiod_tp_id2"]; 
     359                $fields["contact_name"] = htmlentities($ret["contact_name"], ENT_QUOTES); 
     360                $fields["contact_alias"] = htmlentities($ret["contact_alias"], ENT_QUOTES); 
     361                $fields["contact_passwd"] = md5($ret["contact_passwd"]); 
     362                $fields["contact_lang"] = htmlentities($ret["contact_lang"], ENT_QUOTES); 
     363                $fields["contact_hostNotifOpts"] = implode(",", array_keys($ret["contact_hostNotifOpts"])); 
     364                $fields["contact_svNotifOpts"] = implode(",", array_keys($ret["contact_svNotifOpts"])); 
     365                $fields["contact_email"] = htmlentities($ret["contact_email"], ENT_QUOTES); 
     366                $fields["contact_pager"] = htmlentities($ret["contact_pager"], ENT_QUOTES); 
     367                $fields["contact_comment"] = htmlentities($ret["contact_comment"], ENT_QUOTES); 
     368                $fields["contact_oreon"] = $ret["contact_oreon"]["contact_oreon"]; 
     369                $fields["contact_admin"] = $ret["contact_admin"]["contact_admin"]; 
     370                $fields["contact_type_msg"] = $ret["contact_type_msg"]; 
     371                $fields["contact_activate"] = $ret["contact_activate"]["contact_activate"]; 
     372                $fields["contact_auth_type"] = $ret["contact_auth_type"]; 
     373                $fields["contact_ldap_dn"] = $ret["contact_ldap_dn"]; 
     374                $fields["contact_location"] = $ret["contact_location"]; 
     375                $oreon->CentreonLogAction->insertLog("contact", $contact_id, $ret["contact_name"], "c", $fields); 
    315376        } 
    316377 
    317378        function updateContact_MC($contact_id = null)   { 
    318                 global $form, $pearDB; 
     379                global $form, $pearDB, $oreon; 
    319380                if (!$contact_id)  
    320381                        return; 
     
    322383                $ret = $form->getSubmitValues(); 
    323384                $rq = "UPDATE contact SET "; 
    324                 if (isset($ret["timeperiod_tp_id"]) && $ret["timeperiod_tp_id"] != NULL) $rq .= "timeperiod_tp_id = '".$ret["timeperiod_tp_id"]."', "; 
    325                 if (isset($ret["timeperiod_tp_id2"]) && $ret["timeperiod_tp_id2"] != NULL) $rq .= "timeperiod_tp_id2 = '".$ret["timeperiod_tp_id2"]."', "; 
    326                 if (isset($ret["contact_passwd"]) && $ret["contact_passwd"]) $rq .= "contact_passwd = '".md5($ret["contact_passwd"])."', "; 
    327                 if (isset($ret["contact_lang"]) && $ret["contact_lang"] != NULL) $rq .= "contact_lang = '".htmlentities($ret["contact_lang"], ENT_QUOTES)."', "; 
    328                 if (isset($ret["contact_hostNotifOpts"]) && $ret["contact_hostNotifOpts"] != NULL) $rq .= "contact_host_notification_options = '".implode(",", array_keys($ret["contact_hostNotifOpts"]))."', "; 
    329                 if (isset($ret["contact_svNotifOpts"]) && $ret["contact_svNotifOpts"] != NULL) $rq .= "contact_service_notification_options = '".implode(",", array_keys($ret["contact_svNotifOpts"]))."', "; 
    330                 if (isset($ret["contact_email"]) && $ret["contact_email"] != NULL) $rq .= "contact_email = '".htmlentities($ret["contact_email"], ENT_QUOTES)."', "; 
    331                 if (isset($ret["contact_pager"]) && $ret["contact_pager"] != NULL) $rq .= "contact_pager = '".htmlentities($ret["contact_pager"], ENT_QUOTES)."', "; 
    332                 if (isset($ret["contact_comment"]) && $ret["contact_comment"] != NULL) $rq .= "contact_comment = '".htmlentities($ret["contact_comment"], ENT_QUOTES)."', "; 
    333                 if (isset($ret["contact_oreon"]["contact_oreon"]) && $ret["contact_oreon"]["contact_oreon"] != NULL) $rq .= "contact_oreon = '".$ret["contact_oreon"]["contact_oreon"]."', ";  
    334                 if (isset($ret["contact_admin"]["contact_admin"]) && $ret["contact_admin"]["contact_admin"] != NULL) $rq .= "contact_admin = '".$ret["contact_admin"]["contact_admin"]."', "; 
    335                 if (isset($ret["contact_type_msg"]) && $ret["contact_type_msg"] != NULL) $rq .= "contact_type_msg = '".$ret["contact_type_msg"]."', "; 
    336                 if (isset($ret["contact_activate"]["contact_activate"]) && $ret["contact_activate"]["contact_activate"] != NULL) $rq .= "contact_activate = '".$ret["contact_activate"]["contact_activate"]."', "; 
    337                 if (isset($ret["contact_auth_type"]) && $ret["contact_auth_type"] != NULL) $rq .= "contact_auth_type = '".$ret["contact_auth_type"]."', "; 
    338                 if (isset($ret["contact_ldap_dn"]) && $ret["contact_ldap_dn"] != NULL) $rq .= "contact_ldap_dn = '".$ret["contact_ldap_dn"]."', "; 
    339                 if (isset($ret["contact_location"]) && $ret["contact_location"] != NULL) $rq .= "contact_location = '".$ret["contact_location"]."', "; 
     385                if (isset($ret["timeperiod_tp_id"]) && $ret["timeperiod_tp_id"] != NULL) { 
     386                        $rq .= "timeperiod_tp_id = '".$ret["timeperiod_tp_id"]."', "; 
     387                        $fields["timeperiod_tp_id"] = $ret["timeperiod_tp_id"]; 
     388                } 
     389                if (isset($ret["timeperiod_tp_id2"]) && $ret["timeperiod_tp_id2"] != NULL) { 
     390                        $rq .= "timeperiod_tp_id2 = '".$ret["timeperiod_tp_id2"]."', "; 
     391                        $fields["timeperiod_tp_id2"] = $ret["timeperiod_tp_id2"];        
     392                } 
     393                if (isset($ret["contact_passwd"]) && $ret["contact_passwd"]) {  
     394                        $rq .= "contact_passwd = '".md5($ret["contact_passwd"])."', "; 
     395                        $fields["contact_passwd"] = md5($ret["contact_passwd"]); 
     396                } 
     397                if (isset($ret["contact_lang"]) && $ret["contact_lang"] != NULL) { 
     398                        $rq .= "contact_lang = '".htmlentities($ret["contact_lang"], ENT_QUOTES)."', "; 
     399                        $fields["contact_lang"] = htmlentities($ret["contact_lang"], ENT_QUOTES); 
     400                } 
     401                if (isset($ret["contact_hostNotifOpts"]) && $ret["contact_hostNotifOpts"] != NULL) { 
     402                        $rq .= "contact_host_notification_options = '".implode(",", array_keys($ret["contact_hostNotifOpts"]))."', "; 
     403                        $fields["contact_hostNotifOpts"] = implode(",", array_keys($ret["contact_hostNotifOpts"])); 
     404                } 
     405                if (isset($ret["contact_svNotifOpts"]) && $ret["contact_svNotifOpts"] != NULL) { 
     406                        $rq .= "contact_service_notification_options = '".implode(",", array_keys($ret["contact_svNotifOpts"]))."', "; 
     407                        $fields["contact_svNotifOpts"] = implode(",", array_keys($ret["contact_svNotifOpts"])); 
     408                } 
     409                if (isset($ret["contact_email"]) && $ret["contact_email"] != NULL) { 
     410                        $rq .= "contact_email = '".htmlentities($ret["contact_email"], ENT_QUOTES)."', "; 
     411                        $fields["contact_email"] = htmlentities($ret["contact_email"], ENT_QUOTES); 
     412                } 
     413                if (isset($ret["contact_pager"]) && $ret["contact_pager"] != NULL) { 
     414                        $rq .= "contact_pager = '".htmlentities($ret["contact_pager"], ENT_QUOTES)."', "; 
     415                        $fields["contact_pager"] = htmlentities($ret["contact_pager"], ENT_QUOTES); 
     416                } 
     417                if (isset($ret["contact_comment"]) && $ret["contact_comment"] != NULL) { 
     418                        $rq .= "contact_comment = '".htmlentities($ret["contact_comment"], ENT_QUOTES)."', ";    
     419                        $fields["contact_comment"] = htmlentities($ret["contact_comment"], ENT_QUOTES); 
     420                } 
     421                if (isset($ret["contact_oreon"]["contact_oreon"]) && $ret["contact_oreon"]["contact_oreon"] != NULL) { 
     422                        $rq .= "contact_oreon = '".$ret["contact_oreon"]["contact_oreon"]."', "; 
     423                        $fields["contact_oreon"] = $ret["contact_oreon"]["contact_oreon"];       
     424                }  
     425                if (isset($ret["contact_admin"]["contact_admin"]) && $ret["contact_admin"]["contact_admin"] != NULL) { 
     426                        $rq .= "contact_admin = '".$ret["contact_admin"]["contact_admin"]."', "; 
     427                        $fields["contact_admin"] = $ret["contact_admin"]["contact_admin"]; 
     428                } 
     429                if (isset($ret["contact_type_msg"]) && $ret["contact_type_msg"] != NULL) { 
     430                        $rq .= "contact_type_msg = '".$ret["contact_type_msg"]."', "; 
     431                        $fields["contact_type_msg"] = $ret["contact_type_msg"]; 
     432                } 
     433                if (isset($ret["contact_activate"]["contact_activate"]) && $ret["contact_activate"]["contact_activate"] != NULL) { 
     434                        $rq .= "contact_activate = '".$ret["contact_activate"]["contact_activate"]."', "; 
     435                        $fields["contact_activate"] = $ret["contact_activate"]["contact_activate"]; 
     436                } 
     437                if (isset($ret["contact_auth_type"]) && $ret["contact_auth_type"] != NULL) { 
     438                        $rq .= "contact_auth_type = '".$ret["contact_auth_type"]."', "; 
     439                        $fields["contact_auth_type"] = $ret["contact_auth_type"]; 
     440                } 
     441                if (isset($ret["contact_ldap_dn"]) && $ret["contact_ldap_dn"] != NULL) { 
     442                        $rq .= "contact_ldap_dn = '".$ret["contact_ldap_dn"]."', "; 
     443                        $fields["contact_ldap_dn"] = $ret["contact_ldap_dn"]; 
     444                } 
     445                if (isset($ret["contact_location"]) && $ret["contact_location"] != NULL) { 
     446                        $rq .= "contact_location = '".$ret["contact_location"]."', "; 
     447                        $fields["contact_location"] = $ret["contact_location"]; 
     448                } 
    340449                if (strcmp("UPDATE contact SET ", $rq)) { 
    341450                        # Delete last ',' in request 
     
    345454                        if (PEAR::isError($DBRESULT)) 
    346455                                print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 
     456                         
     457                        $DBRESULT2 =& $pearDB->query("SELECT contact_name FROM `contact` WHERE contact_id='".$contact_id."' LIMIT 1"); 
     458                        if (PEAR::isError($DBRESULT2)) 
     459                                print "DB Error : ".$DBRESULT2->getDebugInfo()."<br />"; 
     460                        $row = $DBRESULT2->fetchRow(); 
     461                        $oreon->CentreonLogAction->insertLog("contact", $contact_id, $row["contact_name"], "mc", $fields); 
    347462                } 
    348463        } 
  • trunk/centreon/www/include/configuration/configObject/hostgroup/DB-Func.php

    r6646 r6693  
    4141        function enableHostGroupInDB ($hg_id = NULL, $hg_arr = array()) { 
    4242                if (!$hg_id && !count($hg_arr)) return; 
    43                 global $pearDB; 
     43                global $pearDB, $oreon; 
    4444                if ($hg_id) 
    4545                        $hg_arr = array($hg_id=>"1"); 
     
    4848                        if (PEAR::isError($DBRESULT)) 
    4949                                print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 
     50                        $DBRESULT2 =& $pearDB->query("SELECT hg_name FROM `hostgroup` WHERE `hg_id` = '".$key."' LIMIT 1"); 
     51                        if (PEAR::isError($DBRESULT2)) 
     52                                print "DB Error : ".$DBRESULT2->getDebugInfo()."<br />"; 
     53                        $row = $DBRESULT2->fetchRow(); 
     54                        $oreon->CentreonLogAction->insertLog("hostgroup", $key, $row['hg_name'], "enable"); 
    5055                } 
    5156        } 
     
    5358        function disableHostGroupInDB ($hg_id = NULL, $hg_arr = array())        { 
    5459                if (!$hg_id && !count($hg_arr)) return; 
    55                 global $pearDB; 
     60                global $pearDB, $oreon; 
    5661                if ($hg_id) 
    5762                        $hg_arr = array($hg_id=>"1"); 
     
    6065                        if (PEAR::isError($DBRESULT)) 
    6166                                print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 
     67                        $DBRESULT2 =& $pearDB->query("SELECT hg_name FROM `hostgroup` WHERE `hg_id` = '".$key."' LIMIT 1"); 
     68                        if (PEAR::isError($DBRESULT2)) 
     69                                print "DB Error : ".$DBRESULT2->getDebugInfo()."<br />"; 
     70                        $row = $DBRESULT2->fetchRow(); 
     71                        $oreon->CentreonLogAction->insertLog("hostgroup", $key, $row['hg_name'], "disable"); 
    6272                } 
    6373        } 
    6474         
    6575        function deleteHostGroupInDB ($hostGroups = array())    { 
    66                 global $pearDB; 
     76                global $pearDB, $oreon; 
    6777                foreach($hostGroups as $key=>$value)    { 
    6878                        $rq = "SELECT @nbr := (SELECT COUNT( * ) FROM host_service_relation WHERE service_service_id = hsr.service_service_id GROUP BY service_service_id ) AS nbr, hsr.service_service_id FROM host_service_relation hsr WHERE hsr.hostgroup_hg_id = '".$key."'"; 
     
    7484                                                print "DB Error : ".$DBRESULT2->getDebugInfo()."<br />"; 
    7585                                } 
     86                        $DBRESULT3 =& $pearDB->query("SELECT hg_name FROM `hostgroup` WHERE `hg_id` = '".$key."' LIMIT 1"); 
     87                        if (PEAR::isError($DBRESULT3)) 
     88                                print "DB Error : ".$DBRESULT3->getDebugInfo()."<br />"; 
     89                        $row = $DBRESULT3->fetchRow(); 
     90                         
    7691                        $DBRESULT =& $pearDB->query("DELETE FROM hostgroup WHERE hg_id = '".$key."'"); 
    7792                        if (PEAR::isError($DBRESULT)) 
    7893                                print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 
     94                        $oreon->CentreonLogAction->insertLog("hostgroup", $key, $row['hg_name'], "d"); 
    7995                } 
    8096        } 
     
    94110                                        $key2 == "hg_name" ? ($hg_name = $value2 = $value2."_".$i) : null; 
    95111                                        $val ? $val .= ($value2!=NULL?(", '".$value2."'"):", NULL") : $val .= ($value2!=NULL?("'".$value2."'"):"NULL"); 
     112                                        if ($key2 != "hg_id") 
     113                                                $fields[$key2] = $value2; 
     114                                        $fields["hg_name"] = $hg_name; 
    96115                                } 
    97116                                if (testHostGroupExistence($hg_name))   { 
     
    105124                                        $maxId =& $DBRESULT->fetchRow(); 
    106125                                        if (isset($maxId["MAX(hg_id)"]))        { 
     126                                                $oreon->CentreonLogAction->insertLog("hostgroup", $maxId["MAX(hg_id)"], $hg_name, "a", $fields); 
    107127                                                if (!$is_admin){ 
    108128                                                        $group_list = getGroupListofUser($pearDB); 
     
    179199                $hg_id = $DBRESULT->fetchRow(); 
    180200                 
     201                $fields["hg_name"] = htmlentities($ret["hg_name"], ENT_QUOTES); 
     202                $fields["hg_alias"] = htmlentities($ret["hg_alias"], ENT_QUOTES); 
     203                $fields["hg_snmp_community"] = htmlentities($ret["hg_snmp_community"], ENT_QUOTES); 
     204                $fields["hg_comment"] = htmlentities($ret["hg_comment"], ENT_QUOTES); 
     205                $fields["hg_activate"] = $ret["hg_activate"]["hg_activate"]; 
     206                $oreon->CentreonLogAction->insertLog("hostgroup", $hg_id["MAX(hg_id)"], htmlentities($ret["hg_name"], ENT_QUOTES), "a", $fields); 
     207                 
    181208                if (!$is_admin){ 
    182209                        $group_list = getGroupListofUser($pearDB); 
     
    197224        function updateHostGroup($hg_id)        { 
    198225                if (!$hg_id) return; 
    199                 global $form, $pearDB; 
     226                global $form, $pearDB, $oreon; 
    200227                $ret = array(); 
    201228                $ret = $form->getSubmitValues(); 
     
    217244                if (PEAR::isError($DBRESULT)) 
    218245                        print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 
     246                         
     247                $fields["hg_name"] = htmlentities($ret["hg_name"], ENT_QUOTES); 
     248                $fields["hg_alias"] = htmlentities($ret["hg_alias"], ENT_QUOTES); 
     249                $fields["hg_snmp_community"] = htmlentities($ret["hg_snmp_community"], ENT_QUOTES); 
     250                $fields["hg_comment"] = htmlentities($ret["hg_comment"], ENT_QUOTES); 
     251                $fields["hg_activate"] = $ret["hg_activate"]["hg_activate"]; 
     252                $oreon->CentreonLogAction->insertLog("hostgroup", $hg_id, htmlentities($ret["hg_name"], ENT_QUOTES), "c", $fields); 
    219253        } 
    220254         
  • trunk/centreon/www/include/configuration/configObject/timeperiod/DB-Func.php

    r6646 r6693  
    4141 
    4242        function deleteTimeperiodInDB ($timeperiods = array())  { 
    43                 global $pearDB; 
     43                global $pearDB, $oreon; 
    4444                foreach($timeperiods as $key=>$value)   { 
     45                        $DBRESULT2 =& $pearDB->query("SELECT tp_name FROM `timeperiod` WHERE `tp_id` = '".$key."' LIMIT 1"); 
     46                        if (PEAR::isError($DBRESULT2)) 
     47                                print "DB Error : ".$DBRESULT2->getDebugInfo()."<br />"; 
     48                        $row = $DBRESULT2->fetchRow(); 
    4549                        $DBRESULT =& $pearDB->query("DELETE FROM timeperiod WHERE tp_id = '".$key."'"); 
    4650                        if (PEAR::isError($DBRESULT)) 
    4751                                print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 
     52                        $oreon->CentreonLogAction->insertLog("timeperiod", $key, $row['tp_name'], "d"); 
    4853                } 
    4954        } 
    5055         
    5156        function multipleTimeperiodInDB ($timeperiods = array(), $nbrDup = array())     { 
     57                global $oreon; 
     58                 
    5259                foreach($timeperiods as $key=>$value)   { 
    5360                        global $pearDB; 
     
    6269                                        $key2 == "tp_name" ? ($tp_name = $value2 = $value2."_".$i) : null; 
    6370                                        $val ? $val .= ($value2!=NULL?(", '".$value2."'"):", NULL") : $val .= ($value2!=NULL?("'".$value2."'"):"NULL"); 
     71                                        if ($key2 != "tp_id") 
     72                                                $fields[$key2] = $value2; 
     73                                        $fields["tp_name"] = $tp_name; 
    6474                                } 
    6575                                if (testTPExistence($tp_name))  {        
     
    6777                                        if (PEAR::isError($DBRESULT)) 
    6878                                                print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 
     79                                        /* 
     80                                        * Get Max ID 
     81                                        */ 
     82                                        $DBRESULT =& $pearDB->query("SELECT MAX(tp_id) FROM `timeperiod`"); 
     83                                        if (PEAR::isError($DBRESULT)) 
     84                                                print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 
     85                                        $tp_id = $DBRESULT->fetchRow();  
     86                                        $oreon->CentreonLogAction->insertLog("timeperiod", $tp_id["MAX(tp_id)"], $tp_name, "a", $fields); 
    6987                                } 
    7088                        } 
     
    8098                if (!$tp_id) return; 
    8199                global $form; 
    82                 global $pearDB; 
     100                global $pearDB, $oreon; 
    83101                $ret = array(); 
    84102                $ret = $form->getSubmitValues(); 
     
    97115                if (PEAR::isError($DBRESULT)) 
    98116                        print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 
     117                         
     118                $fields["tp_name"] = htmlentities($ret["tp_name"], ENT_QUOTES); 
     119                $fields["tp_alias"] = htmlentities($ret["tp_alias"], ENT_QUOTES); 
     120                $fields["tp_sunday"] = htmlentities($ret["tp_sunday"], ENT_QUOTES); 
     121                $fields["tp_monday"] = htmlentities($ret["tp_monday"], ENT_QUOTES); 
     122                $fields["tp_tuesday"] = htmlentities($ret["tp_tuesday"], ENT_QUOTES); 
     123                $fields["tp_wednesday"] = htmlentities($ret["tp_wednesday"], ENT_QUOTES); 
     124                $fields["tp_thursday"] = htmlentities($ret["tp_thursday"], ENT_QUOTES); 
     125                $fields["tp_friday"] = htmlentities($ret["tp_friday"], ENT_QUOTES); 
     126                $fields["tp_saturday"] = htmlentities($ret["tp_saturday"], ENT_QUOTES); 
     127                $oreon->CentreonLogAction->insertLog("timeperiod", $tp_id, htmlentities($ret["tp_name"], ENT_QUOTES), "c", $fields); 
    99128        } 
    100129         
     
    106135        function insertTimeperiod($ret = array())       { 
    107136                global $form; 
    108                 global $pearDB; 
     137                global $pearDB, $oreon; 
    109138                if (!count($ret)) 
    110139                        $ret = $form->getSubmitValues(); 
     
    129158                        print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 
    130159                $tp_id = $DBRESULT->fetchRow(); 
     160                 
     161                $fields["tp_name"] = htmlentities($ret["tp_name"], ENT_QUOTES); 
     162                $fields["tp_alias"] = htmlentities($ret["tp_alias"], ENT_QUOTES); 
     163                $fields["tp_sunday"] = htmlentities($ret["tp_sunday"], ENT_QUOTES); 
     164                $fields["tp_monday"] = htmlentities($ret["tp_monday"], ENT_QUOTES); 
     165                $fields["tp_tuesday"] = htmlentities($ret["tp_tuesday"], ENT_QUOTES); 
     166                $fields["tp_wednesday"] = htmlentities($ret["tp_wednesday"], ENT_QUOTES); 
     167                $fields["tp_thursday"] = htmlentities($ret["tp_thursday"], ENT_QUOTES); 
     168                $fields["tp_friday"] = htmlentities($ret["tp_friday"], ENT_QUOTES); 
     169                $fields["tp_saturday"] = htmlentities($ret["tp_saturday"], ENT_QUOTES); 
     170                $oreon->CentreonLogAction->insertLog("timeperiod", $tp_id["MAX(tp_id)"], htmlentities($ret["tp_name"], ENT_QUOTES), "a", $fields); 
     171                 
    131172                return ($tp_id["MAX(tp_id)"]); 
    132173        }