Changeset 893 for trunk/Modules/Log
- Timestamp:
- Mar 6, 2023, 1:48:45 AM (22 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Log/Log.php
r891 r893 33 33 function WriteLog($Text, $Type) 34 34 { 35 if (isset($this->System->User) and !is_null($this->System->User->Id)) 36 $UserId = $this->System->User->Id; 35 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 36 if (isset($User) and !is_null($User->Id)) 37 $UserId = $User->Id; 37 38 else $UserId = 'NULL'; 38 39 $Query = 'INSERT INTO `Log` ( `User` , `Type` , `Text` , `Date` , `IP`, `URL` ) '. … … 40 41 GetRemoteAddress().'", "'.GetRequestURI().'")'; 41 42 $this->System->Database->query($Query); 43 } 44 45 static function Cast(Module $Module): ModuleLog 46 { 47 if ($Module instanceof ModuleLog) 48 { 49 return $Module; 50 } 51 throw new Exception('Expected '.ModuleLog::GetClassName().' type but got '.gettype($Module)); 42 52 } 43 53 } … … 91 101 ( 92 102 'Title' => $LogType['Name'].' ('.$Line['UserName'].', '.$Line['IP'].')', 93 'Link' => 'https://'. $this->System->Config['Web']['Host'].$this->System->Link('/log/'),103 'Link' => 'https://'.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/log/'), 94 104 'Description' => $LogType['Name'].': '.$Line['Text'].' ('.$Line['UserName']. 95 105 ', '.$Line['IP'].', '.HumanDate($Line['Date']).')', … … 100 110 $Output .= GenerateRSS(array 101 111 ( 102 'Title' => $this->System->Config['Web']['Title'].' - '.T('Logs'),103 'Link' => 'https://'. $this->System->Config['Web']['Host'].$this->System->Link('/'),104 'Description' => $this->System->Config['Web']['Description'],105 'WebmasterEmail' => $this->System->Config['Web']['AdminEmail'],112 'Title' => Core::Cast($this->System)->Config['Web']['Title'].' - '.T('Logs'), 113 'Link' => 'https://'.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/'), 114 'Description' => Core::Cast($this->System)->Config['Web']['Description'], 115 'WebmasterEmail' => Core::Cast($this->System)->Config['Web']['AdminEmail'], 106 116 'Items' => $Items, 107 117 )); … … 121 131 function ShowList() 122 132 { 133 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 123 134 $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree(); 124 135 … … 141 152 142 153 // Show category filter 143 if ($ this->System->User->Licence(LICENCE_MODERATOR))154 if ($User->Licence(LICENCE_MODERATOR)) 144 155 { 145 156 $Output = '<strong>'.T('Filter').':</strong>'; … … 203 214 $Output .= '</table>'. 204 215 $PageList['Output']; 205 if ($ this->System->User->Licence(LICENCE_ADMIN))216 if ($User->Licence(LICENCE_ADMIN)) 206 217 { 207 218 $Output .= '<div>'.T('Remove').': <a href="'.$this->System->Link('/log/?a=delerrlog&type='.LOG_TYPE_ERROR).'">'.T('Error logs').'</a> '. … … 215 226 function DeleteErrorLog() 216 227 { 217 if ($this->System->User->Licence(LICENCE_ADMIN) and 228 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 229 if ($User->Licence(LICENCE_ADMIN) and 218 230 (($_GET['type'] == LOG_TYPE_ERROR) or ($_GET['type'] == LOG_TYPE_PAGE_NOT_FOUND))) 219 231 {
Note:
See TracChangeset
for help on using the changeset viewer.