source: trunk/Modules/Log/Log.php@ 661

Last change on this file since 661 was 661, checked in by chronos, 11 years ago
  • Upraveno: Definice třídy Subject přesunuta do samostatného modulu Subject.
  • Přidáno: K Subjektům přidána definice Kontaktů a druhů kontaktů.
File size: 1.9 KB
Line 
1<?php
2
3class ModuleLog extends AppModule
4{
5 function __construct($System)
6 {
7 parent::__construct($System);
8 $this->Name = 'Log';
9 $this->Version = '1.0';
10 $this->Creator = 'Chronos';
11 $this->License = 'GNU/GPLv3';
12 $this->Description = 'Logging user actions';
13 $this->Dependencies = array('User');
14 }
15
16 function DoInstall()
17 {
18 }
19
20 function DoUnInstall()
21 {
22 }
23
24 function DoStart()
25 {
26 $this->System->FormManager->RegisterClass('Log', array(
27 'Title' => 'Záznamy',
28 'Table' => 'Log',
29 'DefaultSortColumn' => 'Time',
30 'DefaultSortOrder' => 1,
31 'Items' => array(
32 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => '', 'ReadOnly' => true),
33 'User' => array('Type' => 'TUser', 'Caption' => 'Uživatel', 'Default' => '', 'Null' => true, 'ReadOnly' => true),
34 'Module' => array('Type' => 'String', 'Caption' => 'Modul', 'Default' => '', 'ReadOnly' => true),
35 'Operation' => array('Type' => 'String', 'Caption' => 'Operace', 'Default' => '', 'ReadOnly' => true),
36 'Value' => array('Type' => 'Text', 'Caption' => 'Hodnota', 'Default' => '', 'ReadOnly' => true),
37 'IPAddress' => array('Type' => 'IPv4Address', 'Caption' => 'Adresa IP', 'Default' => '', 'ReadOnly' => true),
38 ),
39 ));
40
41 }
42
43 function DoStop()
44 {
45 }
46
47 function NewRecord($Module, $Operation, $Value = '')
48 {
49 if(array_key_exists('User', $this->System->ModuleManager->Modules) and
50 array_key_exists('Id', $this->System->User->User))
51 $UserId = $this->System->User->User['Id'];
52 else $UserId = NULL;
53 if(array_key_exists('REMOTE_ADDR', $_SERVER)) $IPAddress = $_SERVER['REMOTE_ADDR'];
54 else $IPAddress = '';
55 $this->Database->insert('Log', array('Time' => 'NOW()',
56 'User' => $UserId, 'Module' => $Module,
57 'Operation' => $Operation, 'Value' => $Value, 'IPAddress' => $IPAddress));
58 }
59}
Note: See TracBrowser for help on using the repository browser.