Changeset 6743

Show
Ignore:
Timestamp:
10/06/08 17:45:50 (2 months ago)
Author:
shotamchay
Message:

no more "dbfunc" file for config log; processing is made within the class

Location:
trunk/centreon/www
Files:
1 removed
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/centreon/www/class/centreonLogAction.class.php

    r6665 r6743  
    1818class CentreonLogAction { 
    1919        var $logUser; 
    20          
     20 
    2121        /* 
    2222         * Initializes variables 
     
    6060         
    6161        /* 
    62          *  Returns logs  
    63          */ 
    64         function displayLog() { 
    65  
    66         } 
     62         * returns the contact name 
     63         */ 
     64        function getContactname($id) { 
     65                global $pearDB; 
     66         
     67                $DBRESULT =& $pearDB->query("SELECT contact_name FROM `contact` WHERE contact_id = '$id' LIMIT 1"); 
     68                if (PEAR::isError($DBRESULT)) { 
     69                        print "DB Error : ".$DBRESULT->postDebugInfo()."<br />";                 
     70                } 
     71                 
     72                while ($data =& $DBRESULT->fetchRow()) { 
     73                        $name = $data["contact_name"]; 
     74                } 
     75                         
     76        return $name; 
     77        } 
     78         
     79        /* 
     80         * returns the list of actions ("create","delete","change","massive change", "enable", "disable") 
     81         */ 
     82        function listAction($id) {  
     83                global $pearDBO; 
     84                $list_actions = array(); 
     85                $i = 0; 
     86                 
     87                $DBRESULT =& $pearDBO->query("SELECT * FROM log_action WHERE object_id ='".$id."' ORDER BY action_log_date DESC"); 
     88                if (PEAR::isError($DBRESULT)) { 
     89                        print "DB Error : ".$DBRESULT->postDebugInfo()."<br />";                 
     90                } 
     91                 
     92                while ($data =& $DBRESULT->fetchRow()) { 
     93                        $list_actions[$i]["action_log_id"] = $data["action_log_id"]; 
     94                        $list_actions[$i]["action_log_date"] = date("d/m/Y H:i",$data["action_log_date"]); 
     95                        $list_actions[$i]["object_type"] = $data["object_type"]; 
     96                        $list_actions[$i]["object_id"] = $data["object_id"]; 
     97                        $list_actions[$i]["object_name"] = $data["object_name"]; 
     98                        $list_actions[$i]["action_type"] = $this->replaceActiontype($data["action_type"]); 
     99                        $list_actions[$i]["log_contact_id"] = $this->getContactname($data["log_contact_id"]); 
     100                        $i++; 
     101                } 
     102 
     103                return $list_actions; 
     104        } 
     105         
     106        /* 
     107         *  returns list of modifications 
     108         */ 
     109        function listModification($id) { 
     110                global $pearDBO; 
     111                $list_modifications = array(); 
     112                $ref = array(); 
     113                $i = 0; 
     114                $j = 0; 
     115                $first_ref_flag = 0; 
     116                 
     117                $DBRESULT =& $pearDBO->query("SELECT action_log_id, action_log_date, action_type FROM log_action WHERE object_id ='".$id."' ORDER  BY action_log_date ASC"); 
     118                if (PEAR::isError($DBRESULT)) { 
     119                        print "DB Error : ".$DBRESULT->postDebugInfo()."<br />";                 
     120                } 
     121                while ($row =& $DBRESULT->fetchRow()) { 
     122                        $DBRESULT2 =& $pearDBO->query("SELECT action_log_id,field_name,field_value FROM `log_action_modification` WHERE action_log_id='".$row['action_log_id']."'"); 
     123                        if (PEAR::isError($DBRESULT2)) { 
     124                                print "DB Error : ".$DBRESULT2->postDebugInfo()."<br />";                
     125                        } 
     126                        while ($field =& $DBRESULT2->fetchRow()) { 
     127                                if (($row["action_type"] == "mc" || $row["action_type"] == "a" || $row["action_type"] == "c") && (!$first_ref_flag || $first_ref_flag == $field["action_log_id"])) { 
     128                                        $ref[$field["field_name"]] = $field["field_value"]; 
     129                                        $first_ref_flag = $field["action_log_id"]; 
     130                                         
     131                                        $list_modifications[$i]["action_log_id"] = $field["action_log_id"]; 
     132                                        $list_modifications[$i]["field_name"] = $field["field_name"]; 
     133                                        $list_modifications[$i]["field_value_before"] = $field["field_value"]; 
     134                                        $list_modifications[$i]["field_value_after"] = $field["field_value"]; 
     135                                        $j++; 
     136                                } 
     137                                else { 
     138                                        foreach ($ref as $key => $value) { 
     139                                                if (!isset($ref[$field["field_name"]])) { 
     140                                                        $list_modifications[$i]["field_value_before"] = ""; 
     141                                                        $list_modifications[$i]["action_log_id"] = $field["action_log_id"]; 
     142                                                        $list_modifications[$i]["field_name"] = $field["field_name"]; 
     143                                                        $list_modifications[$i]["field_value_after"] = $field["field_value"]; 
     144                                                        $ref[$field["field_name"]] = $field["field_value"]; 
     145                                                } 
     146                                                else if (($field["field_name"] == $key) && ($field["field_value"] != $value)) { 
     147                                                        $list_modifications[$i]["field_value_before"] = $value; 
     148                                                        $list_modifications[$i]["action_log_id"] = $field["action_log_id"]; 
     149                                                        $list_modifications[$i]["field_name"] = $field["field_name"]; 
     150                                                        $list_modifications[$i]["field_value_after"] = $field["field_value"]; 
     151                                                        $ref[$key] = $field["field_value"]; 
     152                                                } 
     153                                        } 
     154                                } 
     155                                $i++; 
     156                        } 
     157                } 
     158                return $list_modifications; 
     159        } 
     160          
     161        /* 
     162         *  Display clear action labels 
     163         */ 
     164        function replaceActiontype($action) { 
     165                 
     166                $actionList = array(); 
     167                $actionList["d"] = "Delete"; 
     168                $actionList["c"] = "Change"; 
     169                $actionList["a"] = "Create"; 
     170                $actionList["disable"] = "Disable"; 
     171                $actionList["enable"] = "Enable"; 
     172                $actionList["mc"] = "Massive change";    
     173                 
     174                foreach($actionList as $key => $value) { 
     175                        if ($action == $key) { 
     176                                $action = $value; 
     177                        } 
     178                } 
     179                 
     180                return $action; 
     181        } 
     182         
     183        /* 
     184         *  list object types 
     185         */ 
     186        function listObjecttype() { 
     187                $object_type_tab = array(); 
     188 
     189                $object_type_tab[0] = _("Please select an object"); 
     190                $object_type_tab[1] = "command"; 
     191                $object_type_tab[2] = "timeperiod"; 
     192                $object_type_tab[3] = "contact"; 
     193                $object_type_tab[4] = "contactgroup"; 
     194                $object_type_tab[5] = "host"; 
     195                $object_type_tab[6] = "hostgroup"; 
     196                $object_type_tab[7] = "service"; 
     197                $object_type_tab[8] = "servicegroup"; 
     198                $object_type_tab[9] = "snmp traps"; 
     199                $object_type_tab[10] = "escalation"; 
     200                $object_type_tab[11] = "host dependency"; 
     201                $object_type_tab[12] = "hostgroup dependency"; 
     202                $object_type_tab[13] = "service dependency"; 
     203                $object_type_tab[14] = "servicegroup dependency";        
     204                 
     205                return $object_type_tab; 
     206        } 
    67207} 
    68208?> 
  • trunk/centreon/www/include/configuration/configObject/host/DB-Func.php

    r6731 r6743  
    347347                                                                if (PEAR::isError($DBRESULT4)) 
    348348                                                                        print "DB Error : ".$DBRESULT4->getDebugInfo()."<br />"; 
    349                                                                 $fields["_".$macName."_"] = $hst['host_macro_value']; 
     349                                                                $fields["_".strtoupper($macName)."_"] = $hst['host_macro_value']; 
    350350                                                        } 
    351351                                                 } 
     
    613613                                        if (PEAR::isError($DBRESULT)) 
    614614                                                print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 
    615                                         $fields["_".$_POST[$macInput]."_"] = $_POST[$macValue];  
     615                                        $fields["_".strtoupper($_POST[$macInput])."_"] = $_POST[$macValue];      
    616616                                        $already_stored[$_POST[$macInput]] = 1; 
    617617                                }                        
     
    10401040                                        if (PEAR::isError($DBRESULT)) 
    10411041                                                print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 
    1042                                         $fields["_".$_POST[$macInput]."_"] = $_POST[$macValue];  
     1042                                        $fields["_".strtoupper($_POST[$macInput])."_"] = $_POST[$macValue];      
    10431043                                        $already_stored[$_POST[$macInput]] = 1; 
    10441044                                }                        
     
    13791379                                        $already_stored[$_POST[$macInput]] = 1; 
    13801380                                } 
    1381                                 $fields["_".$$_POST[$macInput]."_"] = $_POST[$macValue]; 
     1381                                $fields["_".strtoupper($_POST[$macInput])."_"] = $_POST[$macValue]; 
    13821382                        } 
    13831383                } 
  • trunk/centreon/www/include/configuration/configObject/service/DB-Func.php

    r6731 r6743  
    364364                                                                if (PEAR::isError($DBRESULT4)) 
    365365                                                                        print "DB Error : ".$DBRESULT4->getDebugInfo()."<br />"; 
    366                                                                 $fields["_".$macName."_"] = $sv['svc_macro_value']; 
     366                                                                $fields["_".strtoupper($macName)."_"] = $sv['svc_macro_value']; 
    367367                                                        } 
    368368                                                } 
     
    560560                                        if (PEAR::isError($DBRESULT)) 
    561561                                                print "DB Error : ".$DBRESULT->getDebugInfo()."<br />";          
    562                                         $fields["_".$_POST[$macInput]."_"] = $_POST[$macValue];          
     562                                        $fields["_".strtoupper($_POST[$macInput])."_"] = $_POST[$macValue];              
    563563                                        $already_stored[$_POST[$macInput]] = 1; 
    564564                                }                        
     
    790790                                        if (PEAR::isError($DBRESULT)) 
    791791                                                print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 
    792                                         $fields["_".$_POST[$macInput]."_"] = $_POST[$macValue];  
     792                                        $fields["_".strtoupper($_POST[$macInput])."_"] = $_POST[$macValue];      
    793793                                        $already_stored[$_POST[$macInput]] = 1; 
    794794                                }                        
     
    10981098                                        $already_stored[$_POST[$macInput]] = 1; 
    10991099                                } 
    1100                                 $fields["_".$_POST[$macInput]."_"] = $_POST[$macValue]; 
     1100                                $fields["_".strtoupper($_POST[$macInput])."_"] = $_POST[$macValue]; 
    11011101                        } 
    11021102                } 
  • trunk/centreon/www/include/options/configurationChangelog/viewLogs.ihtml

    r6731 r6743  
    4747                                                                        {/if} 
    4848                                                                </td> 
    49                                                                 <td class="ListColCenter" width="100"> 
     49                                                                <td class="ListColCenter" width="200"> 
    5050                                                                        {if $modif.action_log_id == $list.action_log_id} 
    5151                                                                                {$modif.field_value_before} 
    5252                                                                        {/if} 
    5353                                                                </td> 
    54                                                                 <td class="ListColCenter" width="100"> 
     54                                                                <td class="ListColCenter" width="200"> 
    5555                                                                        {if $modif.action_log_id == $list.action_log_id} 
    5656                                                                                {$modif.field_value_after} 
     
    6666                                                        </tr> 
    6767                                                {/if} 
    68                                 </table> 
    69                         {/if}                            
     68                                </table>                                 
     69                        {/if}            
    7070                        </td> 
    7171                </tr> 
  • trunk/centreon/www/include/options/configurationChangelog/viewLogs.php

    r6733 r6743  
    3131         
    3232        #PHP functions  
    33         require_once $path."DB-Func.php"; 
    3433        require_once "./include/common/common-Func.php"; 
    3534        require_once("./DBOdsConnect.php"); 
     
    3736        if ($cmd2) { 
    3837                $listAction = array(); 
    39                 $listAction = listAction($cmd2); 
     38                $listAction = $oreon->CentreonLogAction->listAction($cmd2); 
    4039                $listModification = array(); 
    41                 $listModification = listmodification($cmd2); 
     40                $listModification = $oreon->CentreonLogAction->listmodification($cmd2); 
    4241        } 
    4342         
     
    6766        $tpl->assign("display_flag", $display_flag); 
    6867 
    69         $objects_list = array(); 
    70         $objects_List = listObjecttype(); 
    71  
    72         $object_type_tab[0] = _("Please select an object"); 
    73         $object_type_tab[1] = "command"; 
    74         $object_type_tab[2] = "timeperiod"; 
    75         $object_type_tab[3] = "contact"; 
    76         $object_type_tab[4] = "contactgroup"; 
    77         $object_type_tab[5] = "host"; 
    78         $object_type_tab[6] = "hostgroup"; 
    79         $object_type_tab[7] = "service"; 
    80         $object_type_tab[8] = "servicegroup"; 
    81         $object_type_tab[9] = "snmp traps"; 
    82         $object_type_tab[10] = "escalation"; 
    83         $object_type_tab[11] = "host dependency"; 
    84         $object_type_tab[12] = "hostgroup dependency"; 
    85         $object_type_tab[13] = "service dependency"; 
    86         $object_type_tab[14] = "servicegroup dependency"; 
    87  
    88         //$objects_list[] = _("Hosts : Disable Check"); 
     68        $objects_type_tab = array(); 
     69        $objects_type_tab = $oreon->CentreonLogAction->listObjecttype(); 
    8970         
    9071        ?> 
     
    9879        function setO2(_i) { 
    9980                document.forms['form'].elements['cmd2'].value = _i; 
    100                 //document.forms['form'].elements['o2'].selectedIndex = _i; 
    10181        } 
    10282         
     
    10585         
    10686        if ($cmd) { 
    107                 $DBRESULT = $pearDBO->query("SELECT DISTINCT object_name, object_id FROM log_action WHERE object_type='".$object_type_tab[$cmd]."' ORDER BY object_id"); 
     87                $DBRESULT = $pearDBO->query("SELECT DISTINCT object_name, object_id FROM log_action WHERE object_type='".$objects_type_tab[$cmd]."' ORDER BY object_id"); 
    10888                if (PEAR::isError($DBRESULT)) 
    10989                        print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 
     
    122102         
    123103        $attrs = array( 'onchange'=>"javascript: setO1(this.form.elements['o1'].value); submit();"); 
    124     $form->addElement('select', 'o1', NULL, $object_type_tab, $attrs); 
     104    $form->addElement('select', 'o1', NULL, $objects_type_tab, $attrs); 
    125105        $form->setDefaults(array('o1' => NULL)); 
    126106        $o1 =& $form->getElement('o1'); 
    127107        $o1->setValue(NULL); 
    128108 
    129         $objects = array(); 
    130         $objects = listObjectname(NULL); 
    131109        $attrs = array( 'onchange'=>"javascript: setO2(this.form.elements['o2'].value); submit();"); 
    132110    $form->addElement('select', 'o2', NULL, $objNameTab, $attrs);