Changeset 353 for trunk/Modules/Log/Log.php
- Timestamp:
- Jan 18, 2012, 8:48:26 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Log/Log.php
r348 r353 1 1 <?php 2 3 include_once('Common/rss_generator.php'); 4 5 class LogShow extends Page 6 { 7 var $FullTitle = 'Zobrazení záznamu operací'; 8 var $ShortTitle = 'Záznam operací'; 9 var $RowPerPage = 20; 10 11 function Show() 12 { 13 if(count($this->System->PathItems) > 1) 14 { 15 if($this->System->PathItems[1] == 'rss') return($this->ShowRSS()); 16 else return(PAGE_NOT_FOUND); 17 } else return($this->ShowList()); 18 } 19 20 function ShowRSS() 21 { 22 $this->SimplePage = true; 23 $this->FormatHTML = false; 24 25 if(!$this->System->Models['User']->CheckPermission('Log', 'Show')) return('Nemáte oprávnění'); 26 $DbResult = $this->Database->query('SELECT UNIX_TIMESTAMP(Time), Log.*, `User`.`Name` as UserName FROM `Log` LEFT JOIN `User` ON `User`.`Id` = `Log`.`User` ORDER BY Time DESC LIMIT 0, 50'); 27 while($Row = $DbResult->fetch_assoc()) 28 { 29 $Info = $Row['UserName'].': '.$Row['Module'].' '.$Row['Operation'].' '.$Row['Value']; 30 $Items[] = array 31 ( 32 'Title' => $Info, 33 'Link' => 'http://'.$this->System->Config['Web']['Host'].'/', 34 'Description' => $Info, 35 'Time' => $Row['UNIX_TIMESTAMP(Time)'], 36 ); 37 } 38 return(GenerateRSS(array( 39 'Title' => $this->System->Config['Web']['Title'].' - Záznamy operací', 40 'Link' => 'http://'.$this->System->Config['Web']['Host'].'/', 41 'Description' => 'Záznamy operací', 42 'WebmasterEmail' => $this->System->Config['Web']['AdminEmail'], 43 'Items' => $Items))); 44 } 45 46 function ShowList() 47 { 48 if(!$this->System->Models['User']->CheckPermission('Log', 'Show')) return('Nemáte oprávnění'); 49 $DbResult = $this->Database->select('Log', 'COUNT(*)'); 50 $RowTotal = $DbResult->fetch_array(); 51 $PageMax = $RowTotal[0]; 52 if(array_key_exists('Page', $_GET)) $Page = $_GET['Page']; else $Page = 0; 53 54 $Output = '<div align="center"><table class="WideTable" style="font-size: small;">'; 55 $Output .= '<tr><th>Čas</th><th>Uživatel</th><th>Modul</th><th>Operace</th><th>Hodnota</th></tr>'; 56 $DbResult = $this->Database->query('SELECT Log.*, `User`.`Name` as UserName FROM `Log` LEFT JOIN `User` ON `User`.`Id` = `Log`.`User` ORDER BY Time DESC LIMIT '.$Page * $this->RowPerPage.','.$this->RowPerPage); 57 while($DbRow = $DbResult->fetch_assoc()) 58 { 59 $Output .= '<tr><td>'.$DbRow['Time'].'</td><td>'.$DbRow['UserName'].'</td><td>'.$DbRow['Module'].'</td><td>'.$DbRow['Operation'].'</td><td>'.$DbRow['Value'].'</td></tr>'; 60 } 61 $Output .= '</table>'; 62 $Output .= PagesList('?Page=', $Page, $PageMax, $this->RowPerPage); 63 $Output .= '</div>'; 64 return($Output); 65 } 66 } 67 68 class Log extends Model 69 { 70 function __construct($Database, $System) 71 { 72 parent::__construct($Database, $System); 73 $this->Name = 'Log'; 74 $this->AddPropertyDateTime('Time'); 75 $this->AddPropertyOneToMany('User', 'User'); 76 $this->AddPropertyString('Module'); 77 $this->AddPropertyString('Operation'); 78 $this->AddPropertyString('Value'); 79 } 80 } 2 81 3 82 class ModuleLog extends Module … … 12 91 $this->Description = 'Logging of user operations'; 13 92 $this->Dependencies = array('User'); 14 $this->Models = array(); 93 $this->Models = array('Log'); 94 } 95 96 function Init() 97 { 98 $this->System->Pages['log'] = 'LogShow'; 15 99 } 16 100
Note:
See TracChangeset
for help on using the changeset viewer.