Changeset 687 for trunk/Modules


Ignore:
Timestamp:
Sep 7, 2014, 12:28:06 PM (11 years ago)
Author:
chronos
Message:
  • Upraveno: Vylepšení čitelnosti záznamu změn v IS do tabulky Log.
Location:
trunk/Modules
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/IS/IS.php

    r684 r687  
    123123  }
    124124
     125  function LogChange($Form, $Action, $NewId, $OldId)
     126  {
     127        $Values = $Form->Definition['Table'].' (Id: '.$OldId.' => '.$NewId.'):'."\n";
     128        // Compare old values loaded from database with new values in Form variable
     129        $NewValues = $Form->Values;
     130        if($OldId != 0)
     131        {
     132          $FormOld = new Form($this->System->FormManager);
     133          $FormOld->SetClass($Form->Definition['Table']);
     134          $FormOld->LoadValuesFromDatabase($OldId);
     135                $OldValues = $FormOld->Values;
     136                // Keep only changes values
     137          foreach($NewValues as $Index => $Value)
     138          {
     139                if($OldValues[$Index] != $NewValues[$Index])
     140                {
     141                $Values .= $Index.': '.$FormOld->GetValue($Index);
     142                if($NewId != 0) $Values .= ' => '.$Form->GetValue($Index);
     143                $Values .= "\n";
     144                }
     145        }
     146        } else {
     147                foreach($NewValues as $Index => $Value)
     148                {
     149                        $Values .= $Index.': '.$Form->GetValue($Index)."\n";
     150                }
     151        }
     152        $this->System->ModuleManager->Modules['Log']->NewRecord('IS', $Action, $Values);
     153  }
     154
    125155  function ShowEdit($Table, $Id)
    126156  {
     
    139169        try {
    140170          $Form->Validate();
     171          $this->LogChange($Form, 'Edit', $Id, $Id);
    141172          $Form->SaveValuesToDatabase($Id);
    142           $Values = $Table.': '.str_replace('=>', '=', str_replace('array', '', var_export($Form->Values, true)));
    143           $this->System->ModuleManager->Modules['Log']->NewRecord('IS', 'Edit', $Values);
    144173          $Output .= $this->SystemMessage('Úprava položky', 'Položka upravena');
    145174          $Output .= $this->ShowView($Table, $Id);
     
    190219        $DbRow = $DbResult->fetch_assoc();
    191220        try {
     221        $Form = new Form($this->System->FormManager);
     222        $Form->SetClass($Table);
     223        $this->LogChange($Form, 'Delete', 0, $Id);
    192224        $this->Database->delete($Table, '`Id`='.$Id);
    193         $Values = $Table.': '.str_replace('=>', '=', str_replace('array', '', var_export($DbRow, true)));
    194         $this->System->ModuleManager->Modules['Log']->NewRecord('IS', 'Delete', $Values);
    195225        $Output .= $this->SystemMessage('Smazání položky', 'Položka odstraněna');
    196226      } catch (Exception $E)
     
    227257          $Form->SaveValuesToDatabase(0);
    228258          $Id = $this->Database->insert_id;
    229           $Values = $Table.': '.str_replace('=>', '=', str_replace('array', '', var_export($Form->Values, true)));
    230           $this->System->ModuleManager->Modules['Log']->NewRecord('IS', 'Add', $Values);
     259          $this->LogChange($Form, 'Add', $Id, 0);
    231260          $Output .= $this->SystemMessage('Přidání položky', 'Nová položka vytvořena');
    232261          $Output .= $this->ShowView($Table, $Id, $_GET['a'] == 'addsub');
  • trunk/Modules/Network/Availability.php

    r548 r687  
    88  var $PeriodCount = 24;
    99  var $Period = array(
    10     array('Column' => 'Hour', 'Title' => 'Hodina', 'Period' => 1, 'MinPercent' => 100), 
    11     array('Column' => 'Day', 'Title' => 'Den', 'Period' => 24, 'MinPercent' => 98), 
    12     array('Column' => 'Week', 'Title' => 'Týden', 'Period' => 168, 'MinPercent' => 96), // 24 * 7 
     10    array('Column' => 'Hour', 'Title' => 'Hodina', 'Period' => 1, 'MinPercent' => 100),
     11    array('Column' => 'Day', 'Title' => 'Den', 'Period' => 24, 'MinPercent' => 98),
     12    array('Column' => 'Week', 'Title' => 'Týden', 'Period' => 168, 'MinPercent' => 96), // 24 * 7
    1313    array('Column' => 'Month', 'Title' => 'Měsíc', 'Period' => 720, 'MinPercent' => 93), // 24 * 30
    1414    array('Column' => 'Year', 'Title' => 'Rok', 'Period' => 8760, 'MinPercent' => 92), // 365 * 24
     
    1919  {
    2020    $Output = '<div style="font-size: small;">Dostupnost zařízení se kontroluje jednou za minutu. '.
    21     'Hodnoty u delších intervalů nemusí odpovídat skutečnosti, protože záznam byl spuštěn až v průběhu těchto intervalu.'. 
     21    'Hodnoty u delších intervalů nemusí odpovídat skutečnosti, protože záznam byl spuštěn až v průběhu těchto intervalu.'.
    2222    'Všechny prvky sítě jsou kontrolovány ze směrovačů, tj. pokud vypadne některé blízké zařízení, všechny další zařízení propojené přes něj jsou také nedostupné.</div>';
    2323    $Output .= '<div align="center">';
     
    3636    while($DbRow = $DbResult->fetch_assoc())
    3737      $HostTypeList[$DbRow['Id']] = $DbRow;
    38    
    39    
     38
    4039    $DbResult = $this->Database->query('SELECT COUNT(*) FROM `NetworkInterface` '.
    4140      'JOIN `NetworkDevice` ON `NetworkInterface`.`Device` = `NetworkDevice`.`Id` WHERE `NetworkDevice`.`Used` = 1 AND `NetworkDevice`.`PermanentOnline`=1');
    4241    $DbRow = $DbResult->fetch_row();
    43     $PageList = GetPageList($DbRow[0]);   
     42    $PageList = GetPageList($DbRow[0]);
    4443
    4544    $Output .= '<br />';
     
    4746    $Output .= $PageList['Output'];
    4847    $Output .= '<table class="WideTable" style="font-size: small;">';
    49    
     48
    5049    $TableColumns = array(
    51       array('Name' => 'Name', 'Title' => 'Jméno'),
    52     );   
    53    
    54    
     50      array('Name' => 'Name', 'Title' => 'Jméno'),
     51    );
     52
    5553    $Join = '';
    5654    $Columns = '';
     
    6664        $Columns .= ', `Period'.$Period['Column'].'`.`Percent` AS `'.$Period['Column'].'`';
    6765      }
    68     } else 
     66    } else
    6967    {
    7068      if(array_key_exists($_GET['Period'], $this->Period))
     
    8583    $Order = GetOrderTableHeader($TableColumns, 'Name', 0);
    8684    $Output .= $Order['Output'];
    87      
     85
    8886    $DbResult2 = $this->Database->query('SELECT `NetworkInterface`.`Name` AS `InterfaceName`'.$Columns.', '.
    8987      'CONCAT(`NetworkDevice`.`Name`, "-", `NetworkInterface`.`Name`) AS `Name`, `NetworkDevice`.`Name` AS `DeviceName` FROM `NetworkInterface` '.
     
    103101          $Output .= '<td style="text-align: right;'.$Color.'">'.sprintf('%01.2f', $Interface[$Period['Column']]).'</td>';
    104102        }
    105       } else 
     103      } else
    106104      {
    107105        if(array_key_exists($_GET['Period'], $this->Period))
Note: See TracChangeset for help on using the changeset viewer.