Changeset 687 for trunk/Modules/IS/IS.php
- Timestamp:
- Sep 7, 2014, 12:28:06 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/IS/IS.php
r684 r687 123 123 } 124 124 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 125 155 function ShowEdit($Table, $Id) 126 156 { … … 139 169 try { 140 170 $Form->Validate(); 171 $this->LogChange($Form, 'Edit', $Id, $Id); 141 172 $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);144 173 $Output .= $this->SystemMessage('Úprava položky', 'Položka upravena'); 145 174 $Output .= $this->ShowView($Table, $Id); … … 190 219 $DbRow = $DbResult->fetch_assoc(); 191 220 try { 221 $Form = new Form($this->System->FormManager); 222 $Form->SetClass($Table); 223 $this->LogChange($Form, 'Delete', 0, $Id); 192 224 $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);195 225 $Output .= $this->SystemMessage('Smazání položky', 'Položka odstraněna'); 196 226 } catch (Exception $E) … … 227 257 $Form->SaveValuesToDatabase(0); 228 258 $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); 231 260 $Output .= $this->SystemMessage('Přidání položky', 'Nová položka vytvořena'); 232 261 $Output .= $this->ShowView($Table, $Id, $_GET['a'] == 'addsub');
Note:
See TracChangeset
for help on using the changeset viewer.