Changeset 6693
- Timestamp:
- 10/02/08 12:23:26 (2 months ago)
- Location:
- trunk/centreon/www/include/configuration/configObject
- Files:
-
- 4 modified
-
command/DB-Func.php (modified) (1 diff)
-
contact/DB-Func.php (modified) (12 diffs)
-
hostgroup/DB-Func.php (modified) (10 diffs)
-
timeperiod/DB-Func.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/centreon/www/include/configuration/configObject/command/DB-Func.php
r6665 r6693 77 77 $key2 == "command_name" ? ($command_name = $value2 = $value2."_".$i) : null; 78 78 $val ? $val .= ($value2 != NULL?(", '".$value2."'"):", NULL") : $val .= ($value2 != NULL?("'".$value2."'"):"NULL"); 79 $fields[$key2] = $value2; 79 if ($key2 != "command_id") 80 $fields[$key2] = $value2; 80 81 $fields["command_name"] = $command_name; 81 82 } -
trunk/centreon/www/include/configuration/configObject/contact/DB-Func.php
r6646 r6693 77 77 78 78 function enableContactInDB ($contact_id = null, $contact_arr = array()) { 79 global $pearDB ;79 global $pearDB, $oreon; 80 80 81 81 if (!$contact_id && !count($contact_arr)) … … 87 87 if (PEAR::isError($DBRESULT)) 88 88 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"); 89 94 } 90 95 } … … 92 97 function disableContactInDB ($contact_id = null, $contact_arr = array()) { 93 98 if (!$contact_id && !count($contact_arr)) return; 94 global $pearDB ;99 global $pearDB, $oreon; 95 100 if ($contact_id) 96 101 $contact_arr = array($contact_id=>"1"); … … 100 105 if (PEAR::isError($DBRESULT)) 101 106 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"); 102 112 } 103 113 } … … 105 115 106 116 function deleteContactInDB ($contacts = array()) { 107 global $pearDB ;117 global $pearDB, $oreon; 108 118 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 109 124 $DBRESULT =& $pearDB->query("DELETE FROM contact WHERE contact_id = '".$key."'"); 110 125 if (PEAR::isError($DBRESULT)) 111 126 print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 127 $oreon->CentreonLogAction->insertLog("contact", $key, $row['contact_name'], "d"); 112 128 } 113 129 } 114 130 115 131 function multipleContactInDB ($contacts = array(), $nbrDup = array()) { 116 global $pearDB ;132 global $pearDB, $oreon; 117 133 foreach ($contacts as $key=>$value) { 118 134 $DBRESULT =& $pearDB->query("SELECT * FROM contact WHERE contact_id = '".$key."' LIMIT 1"); … … 127 143 $key2 == "contact_alias" ? ($contact_alias = $value2 = $value2."_".$i) : null; 128 144 $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; 129 149 } 130 150 if (testContactExistence($contact_name) && testAliasExistence($contact_alias)) { … … 138 158 $maxId =& $DBRESULT->fetchRow(); 139 159 if (isset($maxId["MAX(contact_id)"])) { 160 $oreon->CentreonLogAction->insertLog("contact", $maxId["MAX(contact_id)"], $contact_name, "a", $fields); 140 161 $DBRESULT =& $pearDB->query("SELECT DISTINCT command_command_id FROM contact_hostcommands_relation WHERE contact_contact_id = '".$key."'"); 141 162 if (PEAR::isError($DBRESULT)) … … 219 240 220 241 function insertContact($ret = array()) { 221 global $form, $pearDB ;242 global $form, $pearDB, $oreon; 222 243 if (!count($ret)) 223 244 $ret = $form->getSubmitValues(); … … 257 278 print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 258 279 $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 259 301 return ($contact_id["MAX(contact_id)"]); 260 302 } … … 313 355 $oreon->user->set_lang($ret["contact_lang"]); 314 356 } 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); 315 376 } 316 377 317 378 function updateContact_MC($contact_id = null) { 318 global $form, $pearDB ;379 global $form, $pearDB, $oreon; 319 380 if (!$contact_id) 320 381 return; … … 322 383 $ret = $form->getSubmitValues(); 323 384 $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 } 340 449 if (strcmp("UPDATE contact SET ", $rq)) { 341 450 # Delete last ',' in request … … 345 454 if (PEAR::isError($DBRESULT)) 346 455 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); 347 462 } 348 463 } -
trunk/centreon/www/include/configuration/configObject/hostgroup/DB-Func.php
r6646 r6693 41 41 function enableHostGroupInDB ($hg_id = NULL, $hg_arr = array()) { 42 42 if (!$hg_id && !count($hg_arr)) return; 43 global $pearDB ;43 global $pearDB, $oreon; 44 44 if ($hg_id) 45 45 $hg_arr = array($hg_id=>"1"); … … 48 48 if (PEAR::isError($DBRESULT)) 49 49 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"); 50 55 } 51 56 } … … 53 58 function disableHostGroupInDB ($hg_id = NULL, $hg_arr = array()) { 54 59 if (!$hg_id && !count($hg_arr)) return; 55 global $pearDB ;60 global $pearDB, $oreon; 56 61 if ($hg_id) 57 62 $hg_arr = array($hg_id=>"1"); … … 60 65 if (PEAR::isError($DBRESULT)) 61 66 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"); 62 72 } 63 73 } 64 74 65 75 function deleteHostGroupInDB ($hostGroups = array()) { 66 global $pearDB ;76 global $pearDB, $oreon; 67 77 foreach($hostGroups as $key=>$value) { 68 78 $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."'"; … … 74 84 print "DB Error : ".$DBRESULT2->getDebugInfo()."<br />"; 75 85 } 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 76 91 $DBRESULT =& $pearDB->query("DELETE FROM hostgroup WHERE hg_id = '".$key."'"); 77 92 if (PEAR::isError($DBRESULT)) 78 93 print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 94 $oreon->CentreonLogAction->insertLog("hostgroup", $key, $row['hg_name'], "d"); 79 95 } 80 96 } … … 94 110 $key2 == "hg_name" ? ($hg_name = $value2 = $value2."_".$i) : null; 95 111 $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; 96 115 } 97 116 if (testHostGroupExistence($hg_name)) { … … 105 124 $maxId =& $DBRESULT->fetchRow(); 106 125 if (isset($maxId["MAX(hg_id)"])) { 126 $oreon->CentreonLogAction->insertLog("hostgroup", $maxId["MAX(hg_id)"], $hg_name, "a", $fields); 107 127 if (!$is_admin){ 108 128 $group_list = getGroupListofUser($pearDB); … … 179 199 $hg_id = $DBRESULT->fetchRow(); 180 200 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 181 208 if (!$is_admin){ 182 209 $group_list = getGroupListofUser($pearDB); … … 197 224 function updateHostGroup($hg_id) { 198 225 if (!$hg_id) return; 199 global $form, $pearDB ;226 global $form, $pearDB, $oreon; 200 227 $ret = array(); 201 228 $ret = $form->getSubmitValues(); … … 217 244 if (PEAR::isError($DBRESULT)) 218 245 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); 219 253 } 220 254 -
trunk/centreon/www/include/configuration/configObject/timeperiod/DB-Func.php
r6646 r6693 41 41 42 42 function deleteTimeperiodInDB ($timeperiods = array()) { 43 global $pearDB ;43 global $pearDB, $oreon; 44 44 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(); 45 49 $DBRESULT =& $pearDB->query("DELETE FROM timeperiod WHERE tp_id = '".$key."'"); 46 50 if (PEAR::isError($DBRESULT)) 47 51 print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 52 $oreon->CentreonLogAction->insertLog("timeperiod", $key, $row['tp_name'], "d"); 48 53 } 49 54 } 50 55 51 56 function multipleTimeperiodInDB ($timeperiods = array(), $nbrDup = array()) { 57 global $oreon; 58 52 59 foreach($timeperiods as $key=>$value) { 53 60 global $pearDB; … … 62 69 $key2 == "tp_name" ? ($tp_name = $value2 = $value2."_".$i) : null; 63 70 $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; 64 74 } 65 75 if (testTPExistence($tp_name)) { … … 67 77 if (PEAR::isError($DBRESULT)) 68 78 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); 69 87 } 70 88 } … … 80 98 if (!$tp_id) return; 81 99 global $form; 82 global $pearDB ;100 global $pearDB, $oreon; 83 101 $ret = array(); 84 102 $ret = $form->getSubmitValues(); … … 97 115 if (PEAR::isError($DBRESULT)) 98 116 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); 99 128 } 100 129 … … 106 135 function insertTimeperiod($ret = array()) { 107 136 global $form; 108 global $pearDB ;137 global $pearDB, $oreon; 109 138 if (!count($ret)) 110 139 $ret = $form->getSubmitValues(); … … 129 158 print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 130 159 $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 131 172 return ($tp_id["MAX(tp_id)"]); 132 173 }
