Changeset 887 for trunk/Modules
- Timestamp:
- Nov 20, 2020, 12:08:12 AM (4 years ago)
- Location:
- trunk/Modules
- Files:
-
- 86 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/API/API.php
r874 r887 17 17 class ModuleAPI extends AppModule 18 18 { 19 function __construct( $System)19 function __construct(System $System) 20 20 { 21 21 parent::__construct($System); … … 28 28 } 29 29 30 function DoStart() 30 function DoStart(): void 31 31 { 32 $this->System->RegisterPage( array('api'), 'PageAPI');32 $this->System->RegisterPage(['api'], 'PageAPI'); 33 33 } 34 34 } … … 36 36 class PageAPI extends Page 37 37 { 38 var$DataFormat;39 40 function __construct( $System)38 public string $DataFormat; 39 40 function __construct(System $System) 41 41 { 42 42 parent::__construct($System); 43 43 $this->ClearPage = true; 44 $this->DataFormat = ''; 44 45 } 45 46 46 function Show() 47 function Show(): string 47 48 { 48 49 // p - token … … 50 51 $Token = $_GET['p']; 51 52 $DbResult = $this->Database->query('SELECT `User` FROM `APIToken` WHERE `Token`="'.$Token.'"'); 52 if ($DbResult->num_rows > 0) 53 if ($DbResult->num_rows > 0) 53 54 { 54 55 $DbRow = $DbResult->fetch_assoc(); … … 75 76 } 76 77 77 function ShowList( $Table, $ItemId)78 function ShowList(string $Table, $ItemId): string 78 79 { 79 80 if (($Table != '') and (array_key_exists($Table, $this->System->FormManager->Classes))) … … 84 85 $SourceTable = '('.$FormClass['SQL'].') AS `TX`'; 85 86 else $SourceTable = '`'.$FormClass['Table'].'` AS `TX`'; 86 87 87 88 $Filter = ''; 88 89 if ($ItemId != 0) … … 112 113 $dom->appendChild($root); 113 114 114 $array2xml = function ($node, $array) use ($dom, &$array2xml) 115 $array2xml = function ($node, $array) use ($dom, &$array2xml) 115 116 { 116 117 foreach ($array as $key => $value) 117 118 { 118 if ( is_array($value) ) 119 if ( is_array($value) ) 119 120 { 120 121 if (is_numeric($key)) $key = 'N'.$key; //die('XML tag name "'.$key.'" can\'t be numeric'); -
trunk/Modules/Chat/Chat.php
r874 r887 3 3 class PageChatHistory extends Page 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 17 17 } 18 18 19 function Show() 19 function Show(): string 20 20 { 21 21 global $MonthNames; 22 22 23 if (! $this->System->User->CheckPermission('Chat', 'Display')) return 'Nemáte oprávnění';23 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Chat', 'Display')) return 'Nemáte oprávnění'; 24 24 25 25 if (array_key_exists('date', $_GET)) $Date = $_GET['date']; … … 87 87 class ModuleChat extends AppModule 88 88 { 89 function __construct( $System)89 function __construct(System $System) 90 90 { 91 91 parent::__construct($System); … … 98 98 } 99 99 100 function DoStart() 100 function DoStart(): void 101 101 { 102 102 $this->System->Pages['chat'] = 'PageChatHistory'; -
trunk/Modules/Chat/irc_bot.php
r873 r887 39 39 } 40 40 41 function Run() 41 function Run(): void 42 42 { 43 43 global $Database; … … 195 195 echo("-Connection lost.\n"); 196 196 } 197 198 197 } 199 198 -
trunk/Modules/Customer/Customer.php
r874 r887 3 3 class ModuleCustomer extends AppModule 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 14 14 } 15 15 16 function DoStart() 16 function DoStart(): void 17 17 { 18 18 $this->System->FormManager->RegisterClass('Member', array( … … 187 187 )); 188 188 189 $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Customer',190 array( 'ModuleCustomer', 'ShowDashboardItem'));189 ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('Customer', 190 array($this, 'ShowDashboardItem')); 191 191 } 192 192 193 function ShowDashboardItem() 193 function ShowDashboardItem(): string 194 194 { 195 195 $DbResult = $this->Database->select('Member', 'COUNT(*)', '1'); -
trunk/Modules/EmailQueue/EmailQueue.php
r882 r887 3 3 class PageEmailQueueProcess extends Page 4 4 { 5 var $FullTitle = 'Odeslání pošty z fronty'; 6 var $ShortTitle = 'Fronta pošty'; 7 var $ParentClass = 'PagePortal'; 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Odeslání pošty z fronty'; 9 $this->ShortTitle = 'Fronta pošty'; 10 $this->ParentClass = 'PagePortal'; 11 } 8 12 9 function Show() 13 function Show(): string 10 14 { 11 $Output = $this->System->ModuleManager->Modules['EmailQueue']->Process();15 $Output = ModuleEmailQueue::Cast($this->System->GetModule('EmailQueue'))->Process(); 12 16 $Output = $this->SystemMessage('Zpracování fronty emailů', 'Nové emaily byly odeslány').$Output; 13 17 return $Output; … … 17 21 class ModuleEmailQueue extends AppModule 18 22 { 19 function __construct( $System)23 function __construct(System $System) 20 24 { 21 25 parent::__construct($System); … … 28 32 } 29 33 30 function DoInstall() 34 function DoInstall(): void 31 35 { 32 36 } 33 37 34 function DoUninstall() 38 function DoUninstall(): void 35 39 { 36 40 } 37 41 38 function DoStart() 42 function DoStart(): void 39 43 { 40 $this->System->RegisterPage( 'fronta-posty', 'PageEmailQueueProcess');44 $this->System->RegisterPage(['fronta-posty'], 'PageEmailQueueProcess'); 41 45 $this->System->FormManager->RegisterClass('Email', array( 42 46 'Title' => 'Nový email', … … 70 74 } 71 75 72 function DoStop() 76 function DoStop(): void 73 77 { 74 78 } … … 83 87 } 84 88 85 function Process() 89 function Process(): string 86 90 { 87 91 $Output = ''; … … 103 107 $Mail->Send(); 104 108 $this->Database->update('EmailQueue', 'Id='.$DbRow['Id'], array('Archive' => 1)); 105 $this->System->ModuleManager->Modules['Log']->NewRecord('System', 'SendEmail', $DbRow['Id']);109 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('System', 'SendEmail', $DbRow['Id']); 106 110 $Output .= 'To: '.$DbRow['To'].' Subject: '.$DbRow['Subject'].'<br />'; 107 111 } 108 112 return $Output; 109 113 } 114 115 static function Cast(AppModule $AppModule): ModuleEmailQueue 116 { 117 if ($AppModule instanceof ModuleEmailQueue) 118 { 119 return $AppModule; 120 } 121 throw new Exception('Expected ModuleEmailQueue type but '.gettype($AppModule)); 122 } 110 123 } 111 -
trunk/Modules/Employee/Employee.php
r738 r887 3 3 class ModuleEmployee extends AppModule 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 14 14 } 15 15 16 function DoStart() 16 function DoStart(): void 17 17 { 18 18 $this->System->FormManager->RegisterClass('Employee', array( -
trunk/Modules/Error/Error.php
r873 r887 3 3 class ModuleError extends AppModule 4 4 { 5 var $Encoding; 6 var $ShowError; 7 var $UserErrors; 8 var $ErrorHandler; 5 public string $Encoding; 6 public ErrorHandler $ErrorHandler; 9 7 10 function __construct( $System)8 function __construct(System $System) 11 9 { 12 10 parent::__construct($System); … … 19 17 20 18 $this->ErrorHandler = new ErrorHandler(); 19 $this->Encoding = 'utf-8'; 21 20 } 22 21 23 function DoInstall() 22 function DoInstall(): void 24 23 { 25 24 } 26 25 27 function DoUnInstall() 26 function DoUnInstall(): void 28 27 { 29 28 } 30 29 31 function DoStart() 30 function DoStart(): void 32 31 { 33 32 $this->ErrorHandler->ShowError = $this->System->Config['Web']['ShowPHPError']; … … 36 35 } 37 36 38 function DoStop() 37 function DoStop(): void 39 38 { 40 39 $this->ErrorHandler->Stop(); 41 40 } 42 41 43 function DoOnError( $Error)42 function DoOnError(string $Error): void 44 43 { 45 $this->System->ModuleManager->Modules['Log']->NewRecord('Error', 'Log', $Error);44 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Error', 'Log', $Error); 46 45 47 46 //if ($Config['Web']['ErrorLogFile'] != '') -
trunk/Modules/File/File.php
r885 r887 5 5 class File extends Model 6 6 { 7 var$FilesDir;8 9 function __construct( $System)7 public string $FilesDir; 8 9 function __construct(System $System) 10 10 { 11 11 parent::__construct($System); … … 13 13 } 14 14 15 function Delete($Id) 15 function Delete($Id): void 16 16 { 17 17 $DbResult = $this->Database->select('File', 'Name', 'Id='.$Id); … … 24 24 } 25 25 26 function CreateFromUpload( $Name)26 function CreateFromUpload(string $Name): string 27 27 { 28 28 // Submited form with file input have to be enctype="multipart/form-data" … … 41 41 } 42 42 43 function DetectMimeType( $FileName)43 function DetectMimeType(string $FileName): string 44 44 { 45 45 $MimeTypes = GetMimeTypes(); … … 49 49 } 50 50 51 function Download( $Id)51 function Download(string $Id): void 52 52 { 53 53 $DbResult = $this->Database->select('File', '*', 'Id='.addslashes($Id)); … … 67 67 } 68 68 69 function GetDir( $Id)69 function GetDir(string $Id): string 70 70 { 71 71 $DbResult = $this->Database->select('FileDirectory', '*', 'Id='.$Id); … … 77 77 } 78 78 79 function GetFullPath( $Id)79 function GetFullPath(string $Id): string 80 80 { 81 81 $DbResult = $this->Database->select('File', '*', 'Id='.addslashes($Id)); … … 93 93 class PageFile extends Page 94 94 { 95 function Show() 95 function Show(): string 96 96 { 97 97 if (array_key_exists('id', $_GET)) $Id = $_GET['id']; … … 99 99 else return $this->SystemMessage('Chyba', 'Nezadáno id souboru'); 100 100 $this->ClearPage = true; 101 $Output = $this->System->Modules['File']->Download($Id);101 $Output = ModuleFile::Cast($this->System->GetModule('File'))->File->Download($Id); 102 102 return $Output; 103 103 } … … 106 106 class PageFileCheck extends Page 107 107 { 108 function __construct( $System)108 function __construct(System $System) 109 109 { 110 110 parent::__construct($System); … … 114 114 } 115 115 116 function GetAbsolutePath( $Path)116 function GetAbsolutePath(string $Path): string 117 117 { 118 118 $Path = trim($Path); … … 137 137 } 138 138 139 function Show() 139 function Show(): string 140 140 { 141 141 $Output = '<strong>Missing files:</strong><br>'; 142 if (! $this->System->User->CheckPermission('File', 'Check'))142 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('File', 'Check')) 143 143 return 'Nemáte oprávnění'; 144 144 $DbResult = $this->Database->select('File', 'Id'); … … 146 146 { 147 147 $Id = $DbRow['Id']; 148 $FileName = $this->GetAbsolutePath( $this->System->Modules['File']->GetFullPath($Id));148 $FileName = $this->GetAbsolutePath(ModuleFile::Cast($this->System->GetModule('File'))->File->GetFullPath($Id)); 149 149 if (!file_exists($FileName)) 150 150 $Output .= '<a href="'.$this->System->Link('/is/?a=view&t=File&i='.$Id).'">'.$FileName.'</a><br>'; … … 156 156 class ModuleFile extends AppModule 157 157 { 158 function __construct($System) 158 public File $File; 159 160 function __construct(System $System) 159 161 { 160 162 parent::__construct($System); … … 164 166 $this->License = 'GNU/GPLv3'; 165 167 $this->Description = 'Base module for file management'; 166 $this->Dependencies = array(); 167 } 168 169 function DoInstall() 170 { 171 } 172 173 function DoUninstall() 174 { 175 } 176 177 function DoStart() 168 $this->Dependencies = array('User'); 169 170 $this->File = new File($this->System); 171 } 172 173 function DoInstall(): void 174 { 175 } 176 177 function DoUninstall(): void 178 { 179 } 180 181 function DoStart(): void 178 182 { 179 183 global $Config; 180 184 181 $this->System->RegisterPage('file', 'PageFile'); 182 $this->System->RegisterPage('file-check', 'PageFileCheck'); 183 $this->System->AddModule(new File($this->System)); 184 $this->System->Modules['File']->FilesDir = dirname(__FILE__).'/../../'.$Config['Web']['UploadFileFolder']; 185 $this->System->RegisterPage(['file'], 'PageFile'); 186 $this->System->RegisterPage(['file-check'], 'PageFileCheck'); 187 $this->File->FilesDir = dirname(__FILE__).'/../../'.$Config['Web']['UploadFileFolder']; 185 188 $this->System->FormManager->RegisterClass('File', array( 186 189 'Title' => 'Soubor', … … 271 274 } 272 275 273 function DoStop() 274 { 275 } 276 } 276 static function Cast(AppModule $AppModule): ModuleFile 277 { 278 if ($AppModule instanceof ModuleFile) 279 { 280 return $AppModule; 281 } 282 throw new Exception('Expected ModuleFile type but got '.gettype($AppModule)); 283 } 284 } -
trunk/Modules/File/MimeTypes.php
r885 r887 1 1 <?php 2 2 3 function GetMimeTypes() 3 function GetMimeTypes(): array 4 4 { 5 5 return array( -
trunk/Modules/Finance/Bill.php
r874 r887 3 3 class Bill extends Model 4 4 { 5 var $SpecificSymbol = 1; // počítačová sít6 var $Checked;5 public int $SpecificSymbol = 1; // computer network number 6 public bool $Checked = false; 7 7 8 8 function GenerateHTML() … … 11 11 } 12 12 13 function SaveToFile($FileName) 14 { 15 global $Database; 16 13 function SaveToFile(string $FileName) 14 { 17 15 $PdfData = $this->HtmlToPdf($this->GenerateHTML()); 18 16 file_put_contents($FileName, $PdfData); 19 17 } 20 18 21 function HtmlToPdf( $HtmlCode)19 function HtmlToPdf(string $HtmlCode): string 22 20 { 23 21 $Encoding = new Encoding(); … … 35 33 class BillInvoice extends Bill 36 34 { 37 var$InvoiceId;38 39 function ShowSubjectInfo( $Subject)35 public string $InvoiceId; 36 37 function ShowSubjectInfo(array $Subject): string 40 38 { 41 39 $BooleanText = array('Ne', 'Ano'); … … 50 48 } 51 49 52 function GenerateHTML() 53 { 54 $Finance = & $this->System->Modules['Finance'];50 function GenerateHTML(): string 51 { 52 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 55 53 $Finance->LoadMonthParameters(0); 56 54 … … 152 150 class BillOperation extends Bill 153 151 { 154 var$OperationId;155 156 function GenerateHTML() 152 public string $OperationId; 153 154 function GenerateHTML(): string 157 155 { 158 156 $DbResult = $this->Database->query('SELECT `FinanceOperation`.*, `FinanceOperationGroup`.`Direction`, `DocumentLineCode`.`Name` AS `BillName` FROM `FinanceOperation` '. -
trunk/Modules/Finance/Finance.php
r877 r887 41 41 var $Rounding; 42 42 43 function LoadMonthParameters( $Period = 1) // 0 - now, 1 - next month43 function LoadMonthParameters(int $Period = 1) // 0 - now, 1 - next month 44 44 { 45 45 $DbResult = $this->Database->query('SELECT * FROM `FinanceBillingPeriod`'); … … 78 78 } 79 79 80 function W2Kc($Spotreba) 80 function W2Kc($Spotreba): string 81 81 { 82 82 return round($Spotreba * 0.72 * $this->kWh); … … 88 88 $EndTime = mktime(0, 0, 0, 12, 31, $Year); 89 89 $this->Database->insert('FinanceYear', array('Year' => $Year, 90 'DateStart' => TimeToMysqlDate($StartTime), 'DateEnd' => TimeToMysqlDate($EndTime), 'Closed' => 0));91 $YearId = $this->Database->insert_id;90 'DateStart' => TimeToMysqlDate($StartTime), 'DateEnd' => TimeToMysqlDate($EndTime), 'Closed' => 0)); 91 $YearId = $this->Database->insert_id; 92 92 93 93 // Create DocumentLineSequence from previous … … 95 95 while ($DbRow = $DbResult->fetch_assoc()) 96 96 { 97 $this->Database->insert('DocumentLineSequence', array('FinanceYear' => $YearId,98 'NextNumber' => 1, 'YearPrefix' => 1, 'DocumentLine' => $DbRow['Id']));99 }100 } 101 102 function GetFinanceYear( $Year)97 $this->Database->insert('DocumentLineSequence', array('FinanceYear' => $YearId, 98 'NextNumber' => 1, 'YearPrefix' => 1, 'DocumentLine' => $DbRow['Id'])); 99 } 100 } 101 102 function GetFinanceYear(int $Year) 103 103 { 104 104 if ($Year == 0) … … 107 107 $DbResult = $this->Database->select('FinanceYear', '*', '1 ORDER BY `Year` DESC LIMIT 1'); 108 108 } else $DbResult = $this->Database->select('FinanceYear', '*', '`Year`='.$Year); 109 if ($DbResult->num_rows == 0) { 110 if ($Year == date('Y')) 111 { 112 $this->CreateFinanceYear($Year); 109 if ($DbResult->num_rows == 0) 110 { 111 if ($Year == date('Y')) 112 { 113 $this->CreateFinanceYear($Year); 113 114 $DbResult = $this->Database->select('FinanceYear', '*', '`Year`='.$Year); 114 } else throw new Exception('Rok '.$Year.' nenalezen');115 }115 } else throw new Exception('Rok '.$Year.' nenalezen'); 116 } 116 117 $FinanceYear = $DbResult->fetch_assoc(); 117 118 if ($FinanceYear['Closed'] == 1) … … 120 121 } 121 122 122 function GetNextDocumentLineNumber( $Id,$FinanceYear = 0)123 { 124 $FinanceYear = $this->GetFinanceYear($FinanceYear);123 function GetNextDocumentLineNumber(string $Id, int $FinanceYear = 0) 124 { 125 $FinanceYear = $this->GetFinanceYear($FinanceYear); 125 126 126 127 $DbResult = $this->Database->query('SELECT `Shortcut`, `Id` FROM `DocumentLine` WHERE `Id`='.$Id); … … 141 142 } 142 143 143 function GetNextDocumentLineNumberId( $Id, $FinanceYear = 0)144 function GetNextDocumentLineNumberId(string $Id, int $FinanceYear = 0): int 144 145 { 145 146 $Code = $this->GetNextDocumentLineNumber($Id, $FinanceYear); … … 148 149 } 149 150 150 function GetFinanceGroupById( $Id, $Table)151 function GetFinanceGroupById(string $Id, string $Table): ?array 151 152 { 152 153 $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE `Id`= '.$Id); … … 154 155 $Group = $DbResult->fetch_assoc(); 155 156 return $Group; 156 } else die('Finance group id '.$Id.' not found in table '.$Table); 157 } 158 159 function RecalculateMemberPayment() 157 } 158 echo('Finance group id '.$Id.' not found in table '.$Table); 159 return null; 160 } 161 162 function RecalculateMemberPayment(): string 160 163 { 161 164 $Output = 'Aktualizuji finance členů...<br />'; … … 199 202 $Consumption = 0; 200 203 $this->Database->insert('MemberPayment', array('Member' => $Member['Id'], 201 202 203 204 'MonthlyInternet' => $MonthlyInet, 205 'MonthlyTotal' => $Monthly, 'MonthlyConsumption' => $this->W2Kc($Consumption), 206 'Cash' => $Cash, 'MonthlyPlus' => $this->W2Kc($ConsumptionPlus))); 204 207 } 205 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'RecalculateMemberPayment');208 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'RecalculateMemberPayment'); 206 209 return $Output; 207 210 } 208 211 209 function GetVATByType( $TypeId)212 function GetVATByType(string $TypeId): string 210 213 { 211 214 $Time = time(); … … 220 223 class ModuleFinance extends AppModule 221 224 { 222 function __construct($System) 225 public Finance $Finance; 226 public Bill $Bill; 227 228 function __construct(System $System) 223 229 { 224 230 parent::__construct($System); … … 229 235 $this->Description = 'Base module for finance management'; 230 236 $this->Dependencies = array('File', 'EmailQueue'); 231 } 232 233 function DoInstall() 234 { 235 } 236 237 function DoUninstall() 238 { 239 } 240 241 function DoStart() 237 238 $this->Bill = new Bill($this->System); 239 $this->Finance = new Finance($this->System); 240 } 241 242 function DoInstall(): void 243 { 244 } 245 246 function DoUninstall(): void 247 { 248 } 249 250 function DoStart(): void 242 251 { 243 252 global $Config; 244 253 245 $this->System->RegisterPage( array('finance', 'sprava'), 'PageFinanceManage');246 $this->System->RegisterPage( array('finance', 'platby'), 'PageFinanceUserState');247 $this->System->RegisterPage( array('finance', 'import'), 'PageFinanceImportPayment');248 $this->System->RegisterPage( array('finance', 'zivnost'), 'PageFinanceTaxFiling');254 $this->System->RegisterPage(['finance', 'sprava'], 'PageFinanceManage'); 255 $this->System->RegisterPage(['finance', 'platby'], 'PageFinanceUserState'); 256 $this->System->RegisterPage(['finance', 'import'], 'PageFinanceImportPayment'); 257 $this->System->RegisterPage(['finance', 'zivnost'], 'PageFinanceTaxFiling'); 249 258 250 259 $this->System->FormManager->RegisterClass('FinanceOperation', array( … … 644 653 )); 645 654 646 647 $this->System->AddModule(new Bill($this->System)); 648 $this->System->AddModule(new Finance($this->System)); 649 $this->System->Modules['Finance']->MainSubject = $Config['Finance']['MainSubjectId']; 650 $this->System->Modules['Finance']->DirectoryId = $Config['Finance']['DirectoryId']; 651 652 $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Finance', 653 array('ModuleFinance', 'ShowDashboardItem')); 654 } 655 656 function ShowDashboardItem() 655 $this->Finance->MainSubject = $Config['Finance']['MainSubjectId']; 656 $this->Finance->DirectoryId = $Config['Finance']['DirectoryId']; 657 658 ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('Finance', array($this, 'ShowDashboardItem')); 659 } 660 661 function ShowDashboardItem(): string 657 662 { 658 663 $DbResult = $this->Database->select('FinanceOperation', 'ROUND(SUM(`Value`))', '1'); … … 662 667 } 663 668 664 function DoStop() 665 { 666 } 667 668 function BeforeInsertFinanceOperation( $Form)669 function DoStop(): void 670 { 671 } 672 673 function BeforeInsertFinanceOperation(Form $Form): array 669 674 { 670 675 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 671 676 else $Year = date("Y", $Form->Values['ValidFrom']); 672 $FinanceGroup = $this-> System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup');673 $Form->Values['BillCode'] = $this-> System->Modules['Finance']->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year);674 return $Form->Values; 675 } 676 677 function AfterInsertFinanceOperation( $Form, $Id)678 { 679 $FinanceGroup = $this-> System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup');677 $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup'); 678 $Form->Values['BillCode'] = $this->Finance->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year); 679 return $Form->Values; 680 } 681 682 function AfterInsertFinanceOperation(Form $Form, string $Id): array 683 { 684 $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup'); 680 685 $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '. 681 686 ($Form->Values['ValueUser'] * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id); … … 683 688 } 684 689 685 function BeforeModifyFinanceOperation( $Form, $Id)686 { 687 $FinanceGroup = $this-> System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup');690 function BeforeModifyFinanceOperation(Form $Form, string $Id): array 691 { 692 $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup'); 688 693 $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '. 689 694 ($Form->Values['ValueUser'] * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id); … … 691 696 } 692 697 693 function BeforeInsertFinanceInvoice( $Form)698 function BeforeInsertFinanceInvoice(Form $Form): array 694 699 { 695 700 // Get new DocumentLineCode by selected invoice Group 696 701 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 697 702 else $Year = date("Y", $Form->Values['ValidFrom']); 698 $Group = $this-> System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup');699 $Form->Values['BillCode'] = $this-> System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);700 return $Form->Values; 701 } 702 703 function AfterInsertFinanceInvoice( $Form, $Id)704 { 705 $FinanceGroup = $this-> System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup');703 $Group = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup'); 704 $Form->Values['BillCode'] = $this->Finance->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 705 return $Form->Values; 706 } 707 708 function AfterInsertFinanceInvoice(Form $Form, string $Id): array 709 { 710 $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup'); 706 711 $DbResult = $this->Database->query(str_replace('#Id', $Id, $Form->Definition['Items']['ValueUser']['SQL'])); 707 712 $DbRow = $DbResult->fetch_row(); … … 713 718 } 714 719 715 function BeforeModifyFinanceInvoice( $Form, $Id)716 { 717 $FinanceGroup = $this-> System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup');720 function BeforeModifyFinanceInvoice(Form $Form, string $Id): array 721 { 722 $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup'); 718 723 $DbResult = $this->Database->query(str_replace('#Id', $Id, $Form->Definition['Items']['ValueUser']['SQL'])); 719 724 $DbRow = $DbResult->fetch_row(); … … 724 729 } 725 730 726 function AfterInsertFinanceInvoiceItem( $Form, $Id)731 function AfterInsertFinanceInvoiceItem(Form $Form, string $Id): array 727 732 { 728 733 $ParentForm = new Form($this->System->FormManager); … … 733 738 } 734 739 735 function AfterModifyFinanceInvoiceItem( $Form, $Id)740 function AfterModifyFinanceInvoiceItem(Form $Form, string $Id): array 736 741 { 737 742 $ParentForm = new Form($this->System->FormManager); … … 742 747 } 743 748 744 function BeforeInsertContract( $Form)749 function BeforeInsertContract(Form $Form): array 745 750 { 746 751 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 747 752 else $Year = date("Y", $Form->Values['ValidFrom']); 748 $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Form->Values['DocumentLine'], $Year); 749 return $Form->Values; 753 $Form->Values['BillCode'] = $this->Finance->GetNextDocumentLineNumberId($Form->Values['DocumentLine'], $Year); 754 return $Form->Values; 755 } 756 757 static function Cast(AppModule $AppModule): ModuleFinance 758 { 759 if ($AppModule instanceof ModuleFinance) 760 { 761 return $AppModule; 762 } 763 throw new Exception('Expected ModuleFinance type but '.gettype($AppModule)); 750 764 } 751 765 } -
trunk/Modules/Finance/Import.php
r874 r887 3 3 class PageFinanceImportPayment extends Page 4 4 { 5 var $FullTitle = 'Import plateb'; 6 var $ShortTitle = 'Import plateb'; 7 var $ParentClass = 'PageFinance'; 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Import plateb'; 9 $this->ShortTitle = 'Import plateb'; 10 $this->ParentClass = 'PageFinance'; 11 } 8 12 9 function Show() 13 function Show(): string 10 14 { 11 if (! $this->System->User->CheckPermission('Finance', 'SubjectList')) return 'Nemáte oprávnění';15 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'SubjectList')) return 'Nemáte oprávnění'; 12 16 if (array_key_exists('Operation', $_GET)) 13 17 { … … 26 30 } 27 31 28 function Prepare() 32 function Prepare(): string 29 33 { 30 $Finance = $this->System->Modules['Finance'];34 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 31 35 $Finance->LoadMonthParameters(0); 32 36 $Data = explode("\n", $_POST['Source']); … … 124 128 } 125 129 126 function InsertMoney( $Subject, $Value, $Cash, $Taxable, $Time, $Text,$Group)130 function InsertMoney(string $Subject, string $Value, string $Cash, string $Taxable, string $Time, string $Text, array $Group) 127 131 { 128 132 $Year = date('Y', $Time); 129 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);133 $BillCode = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 130 134 // TODO: Fixed BankAccount=1, allow to select bank account for import 131 135 $this->Database->insert('FinanceOperation', array('Text' => $Text, … … 136 140 } 137 141 138 function Insert() 142 function Insert(): string 139 143 { 140 $Finance = $this->System->Modules['Finance'];144 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 141 145 $Finance->LoadMonthParameters(0); 142 146 $Output = ''; … … 144 148 for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--) 145 149 { 146 if ($_POST['Money'.$I] < 0) { 147 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 148 } else { 149 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 150 if ($_POST['Money'.$I] < 0) 151 { 152 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 153 } else 154 { 155 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 150 156 } 151 157 $Date = explode('-', $_POST['Date'.$I]); … … 154 160 0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $FinanceGroup); 155 161 $Output .= $I.', '; 156 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted');162 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'NewPaymentInserted'); 157 163 } 158 164 return $Output; -
trunk/Modules/Finance/Manage.php
r886 r887 3 3 class PageFinanceManage extends Page 4 4 { 5 var $FullTitle = 'Správa financí'; 6 var $ShortTitle = 'Správa financí'; 7 var $ParentClass = 'PageFinance'; 8 9 function Show() 10 { 11 $Output = ''; 12 if (!$this->System->User->CheckPermission('Finance', 'Manage')) 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Správa financí'; 9 $this->ShortTitle = 'Správa financí'; 10 $this->ParentClass = 'PageFinance'; 11 } 12 13 function Show(): string 14 { 15 $Output = ''; 16 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'Manage')) 13 17 return 'Nemáte oprávnění'; 14 18 … … 18 22 { 19 23 case 'Recalculate': 20 $Output .= $this->System->Modules['Finance']->RecalculateMemberPayment();24 $Output .= ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->RecalculateMemberPayment(); 21 25 break; 22 26 case 'ShowMonthlyPayment': … … 51 55 $Year = date('Y', $Time); 52 56 53 $MonthCount = $this->System->Modules['Finance']->BillingPeriods[$Period]['MonthCount'];57 $MonthCount = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->BillingPeriods[$Period]['MonthCount']; 54 58 if ($MonthCount <= 0) return array('From' => NULL, 'To' => NULL, 'MonthCount' => 0); 55 59 $MonthCurrent = date('n', $Time); … … 72 76 function ShowMonthlyPayment() 73 77 { 74 if (! $this->System->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění';78 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění'; 75 79 $SQL = 'SELECT `Member`.*, `MemberPayment`.`MonthlyTotal` AS `Monthly`, '. 76 80 '`MemberPayment`.`Cash` AS `Cash`, '. … … 128 132 global $LastInsertTime; 129 133 134 $Finance = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 135 130 136 $Year = date('Y', $TimeCreation); 131 $BillCode = $ this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);137 $BillCode = $Finance->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 132 138 $SumValue = 0; 133 139 foreach ($Items as $Item) { 134 140 $SumValue = $SumValue + $Item['Price'] * $Item['Quantity']; 135 141 } 136 $Finance = &$this->System->Modules['Finance'];137 142 $SumValue = round($SumValue, $Finance->Rounding); 138 143 $this->Database->insert('FinanceInvoice', array( … … 181 186 { 182 187 $InvoiceItems[] = array('Description' => $Service['Name'], 'Price' => $Service['Price'], 183 'Quantity' => $Period['MonthCount'], 'VAT' => $this->System->Modules['Finance']->GetVATByType($Service['VAT']));188 'Quantity' => $Period['MonthCount'], 'VAT' => ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetVATByType($Service['VAT'])); 184 189 $MonthlyTotal += $Service['Price']; 185 190 } … … 196 201 197 202 // Load invoice group 198 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($InvoiceGroupId, 'FinanceInvoiceGroup');203 $FinanceGroup = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetFinanceGroupById($InvoiceGroupId, 'FinanceInvoiceGroup'); 199 204 foreach ($InvoiceItems as $Index => $Item) 200 205 { … … 275 280 function ProcessMonthlyPayment() 276 281 { 277 if (! $this->System->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění';282 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění'; 278 283 $Output = ''; 279 284 280 285 $Output .= $this->ProcessTableUpdates(); 281 286 282 $Finance = & $this->System->Modules['Finance'];287 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 283 288 $Finance->LoadMonthParameters(0); 284 289 … … 334 339 //flush(); 335 340 //$this->GenerateBills(); 336 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'ProcessMonthlyPayment', $Output);341 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'ProcessMonthlyPayment', $Output); 337 342 } 338 343 $Output = str_replace("\n", '<br/>', $Output); … … 379 384 $Service = $DbResult->fetch_assoc(); 380 385 $Content .= '<strong>'.$Service['Name'].'</strong><br />'."\n". 381 'Vaše platební období: <strong>'. $this->System->Modules['Finance']->BillingPeriods[$Member['BillingPeriod']]['Name'].'</strong><br />'."\n".386 'Vaše platební období: <strong>'.ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->BillingPeriods[$Member['BillingPeriod']]['Name'].'</strong><br />'."\n". 382 387 'Pravidelná platba za období: <strong>'.($MemberPayment['MonthlyTotal'] * $Period['MonthCount']).' Kč</strong><br />'."\n". 383 388 'Bankovní účet: <strong>'.$MainSubjectAccount['NumberFull'].'</strong><br/>'."\n". … … 407 412 408 413 $Content .= '<br />Tento email je generován automaticky. V případě zjištění nesrovnalostí napište zpět.'; 409 $this->System->ModuleManager->Modules['EmailQueue']->AddItem($User['Name'].' <'.$User['Email'].'>', $Title, $Content,414 ModuleEmailQueue::Cast($this->System->GetModule('EmailQueue'))->AddItem($User['Name'].' <'.$User['Email'].'>', $Title, $Content, 410 415 $Config['Web']['Admin'].' <'.$Config['Web']['AdminEmail'].'>'); 411 416 $Output = ''; … … 416 421 function GenerateInvoice($Where) 417 422 { 423 $DirectoryId = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->DirectoryId; 418 424 $Output = ''; 419 425 $DbResult = $this->Database->query('SELECT * FROM `FinanceInvoice` WHERE (`BillCode` <> "") '. … … 423 429 if ($Row['File'] == null) 424 430 { 425 $DbResult2 = $this->Database->insert('File', array('Name' => '', 'Size' => 0, 426 'Directory' => $this->System->Modules['Finance']->DirectoryId, 'Time' => 'NOW()')); 431 $this->Database->insert('File', array('Name' => '', 'Size' => 0, 'Directory' => $DirectoryId, 'Time' => 'NOW()')); 427 432 $FileId = $this->Database->insert_id; 428 433 } else $FileId = $Row['File']; … … 432 437 $Bill->System = &$this->System; 433 438 $Bill->InvoiceId = $Row['Id']; 434 $FullFileName = $this->System->Modules['File']->GetDir($this->System->Modules['Finance']->DirectoryId).$FileName;439 $FullFileName = ModuleFile::Cast($this->System->GetModule('File'))->File->GetDir($DirectoryId).$FileName; 435 440 $Bill->SaveToFile($FullFileName); 436 441 if (file_exists($FullFileName)) … … 446 451 function GenerateOperation($Where) 447 452 { 453 $DirectoryId = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->DirectoryId; 448 454 $Output = ''; 449 455 $DbResult = $this->Database->query('SELECT * FROM `FinanceOperation` WHERE (`BillCode` <> "") '. … … 454 460 { 455 461 $DbResult2 = $this->Database->insert('File', array('Name' => '', 'Size' => 0, 456 'Directory' => $ this->System->Modules['Finance']->DirectoryId, 'Time' => 'NOW()'));462 'Directory' => $DirectoryId, 'Time' => 'NOW()')); 457 463 $FileId = $this->Database->insert_id; 458 464 } else $FileId = $Row['File']; … … 462 468 $Bill->System = &$this->System; 463 469 $Bill->OperationId = $Row['Id']; 464 $FullFileName = $this->System->Modules['File']->GetDir($this->System->Modules['Finance']->DirectoryId).$FileName;470 $FullFileName = ModuleFile::Cast($this->System->GetModule('File'))->File->GetDir($DirectoryId).$FileName; 465 471 $Bill->SaveToFile($FullFileName); 466 472 if (file_exists($FullFileName)) -
trunk/Modules/Finance/Trade.php
r874 r887 3 3 class PageFinanceTaxFiling extends Page 4 4 { 5 var $FullTitle = 'Daňová evidence';6 var $ShortTitle = 'Daňová evidence';7 var $ParentClass = 'PageFinance';8 5 var $StartEvidence = 0; 6 7 function __construct(System $System) 8 { 9 parent::__construct($System); 10 $this->FullTitle = 'Daňová evidence'; 11 $this->ShortTitle = 'Daňová evidence'; 12 $this->ParentClass = 'PageFinance'; 13 } 9 14 10 15 function GetTimePeriodBalance($StartTime, $EndTime) … … 340 345 function ShowSubjectAccount() 341 346 { 347 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 348 342 349 $Output = '<table style="width: 100%"><tr><td style="vertical-align: top;">'; 343 350 $Output .= '<strong>Výpis příjmů/výdajů</strong>'; … … 424 431 } 425 432 426 function Show() 427 { 428 if (! $this->System->User->CheckPermission('Finance', 'TradingStatus'))433 function Show(): string 434 { 435 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'TradingStatus')) 429 436 return 'Nemáte oprávnění'; 430 431 $Finance = &$this->System->Modules['Finance'];432 437 433 438 $Output = ''; -
trunk/Modules/Finance/UserState.php
r874 r887 3 3 class PageFinanceUserState extends Page 4 4 { 5 var $FullTitle = 'Stav financí účastníka'; 6 var $ShortTitle = 'Stav financí'; 7 var $ParentClass = 'PageUser'; 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Stav financí účastníka'; 9 $this->ShortTitle = 'Stav financí'; 10 $this->ParentClass = 'PageUser'; 11 } 8 12 9 13 function ShowFinanceOperation($Subject) … … 69 73 } 70 74 71 function Show() 75 function Show(): string 72 76 { 73 $Finance = & $this->System->Modules['Finance'];77 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 74 78 $Finance->LoadMonthParameters(0); 75 79 … … 77 81 if (array_key_exists('i', $_GET)) 78 82 { 79 if (! $this->System->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění';83 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění'; 80 84 $CustomerId = $_GET['i']; 81 85 } else 82 86 { 83 if (! $this->System->User->CheckPermission('Finance', 'DisplaySubjectState')) return 'Nemáte oprávnění';84 $UserId = $this->System->User->User['Id'];87 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'DisplaySubjectState')) return 'Nemáte oprávnění'; 88 $UserId = ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id']; 85 89 $DbResult = $this->Database->query('SELECT `Customer` FROM `UserCustomerRel` WHERE `User`='.$UserId.' LIMIT 1'); 86 90 if ($DbResult->num_rows > 0) -
trunk/Modules/FinanceBankAPI/FileImport.php
r884 r887 5 5 class BankImport 6 6 { 7 var$System;8 var$Database;9 var$BankAccount;10 11 function __construct( $System)7 public System $System; 8 public Database $Database; 9 public int $BankAccount; 10 11 function __construct(System $System) 12 12 { 13 13 $this->Database = &$System->Database; … … 15 15 } 16 16 17 function Import() 18 { 17 function Import(): string 18 { 19 return ''; 19 20 } 20 21 … … 23 24 } 24 25 25 function PairOperations() 26 { 26 function PairOperations(): void 27 { 28 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 27 29 $DbResult = $this->Database->select('FinanceBankImport', '*', 'FinanceOperation IS NULL'); 28 30 while ($DbRow = $DbResult->fetch_assoc()) … … 34 36 { 35 37 $DbRow2 = $DbResult2->fetch_assoc(); 36 if ($DbRow['Value'] >= 0) { 37 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 'FinanceOperationGroup'); 38 } else { 39 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 38 if ($DbRow['Value'] >= 0) 39 { 40 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 'FinanceOperationGroup'); 41 } else 42 { 43 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 40 44 } 41 45 $Year = date('Y', MysqlDateToTime($DbRow['Time'])); 42 $BillCode = $ this->System->Modules['Finance']->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year);43 $ DbResult3 = $this->Database->insert('FinanceOperation', array('Subject' => $DbRow2['Id'], 'Cash' => 0,46 $BillCode = $Finance->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year); 47 $this->Database->insert('FinanceOperation', array('Subject' => $DbRow2['Id'], 'Cash' => 0, 44 48 'ValueUser' => Abs($DbRow['Value']), 'Value' => 0, 'Taxable' => 1, 'BankAccount' => $DbRow['BankAccount'], 'Network' => 1, 45 49 'Time' => $DbRow['Time'], 'Text' => $DbRow['Description'], 'BillCode' => $BillCode, 'Group' => $FinanceGroup['Id'])); … … 65 69 class PageImportAPI extends Page 66 70 { 67 var $FullTitle = 'Import plateb přes API'; 68 var $ShortTitle = 'Import plateb přes API'; 69 var $ParentClass = 'PageFinance'; 70 71 function Import($Id) 71 function __construct(System $System) 72 { 73 parent::__construct($System); 74 $this->FullTitle = 'Import plateb přes API'; 75 $this->ShortTitle = 'Import plateb přes API'; 76 $this->ParentClass = 'PageFinance'; 77 } 78 79 function Import(int $Id): string 72 80 { 73 81 $Output = ''; … … 92 100 } 93 101 94 function Show() 95 { 96 if (! $this->System->User->CheckPermission('Finance', 'SubjectList'))102 function Show(): string 103 { 104 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'SubjectList')) 97 105 return 'Nemáte oprávnění'; 98 106 … … 104 112 class PageImportFile extends Page 105 113 { 106 var $FullTitle = 'Import plateb ze souboru'; 107 var $ShortTitle = 'Import plateb ze souboru'; 108 var $ParentClass = 'PageFinance'; 109 110 function Show() 114 function __construct(System $System) 115 { 116 parent::__construct($System); 117 $this->FullTitle = 'Import plateb ze souboru'; 118 $this->ShortTitle = 'Import plateb ze souboru'; 119 $this->ParentClass = 'PageFinance'; 120 } 121 122 function Show(): string 111 123 { 112 124 $Output = ''; 113 if (! $this->System->User->CheckPermission('Finance', 'SubjectList')) return 'Nemáte oprávnění';125 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'SubjectList')) return 'Nemáte oprávnění'; 114 126 if (array_key_exists('Operation', $_GET)) 115 127 { … … 121 133 } 122 134 123 function ShowForm() 135 function ShowForm(): string 124 136 { 125 137 $Form = new Form($this->System->FormManager); … … 156 168 } 157 169 158 function InsertMoney($Subject, $Value, $Cash, $Taxable, $Time, $Text, $Group) 170 function InsertMoney($Subject, $Value, $Cash, $Taxable, $Time, $Text, $Group): void 159 171 { 160 172 $Year = date('Y', $Time); 161 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId(173 $BillCode = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetNextDocumentLineNumberId( 162 174 $Group['DocumentLine'], $Year); 163 175 $this->Database->insert('FinanceOperation', array('Text' => $Text, … … 166 178 } 167 179 168 function Insert() 169 { 170 $Finance = $ this->System->Modules['Finance'];180 function Insert(): string 181 { 182 $Finance = $ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 171 183 $Output = ''; 172 184 173 185 for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--) 174 186 { 175 if ($_POST['Money'.$I] >= 0) { 187 if ($_POST['Money'.$I] >= 0) 188 { 176 189 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 177 190 'FinanceOperationGroup'); 178 } else { 191 } else 192 { 179 193 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 180 194 'FinanceOperationGroup'); … … 185 199 0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $FinanceGroup); 186 200 $Output .= $I.', '; 187 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted');201 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'NewPaymentInserted'); 188 202 } 189 203 return $Output; -
trunk/Modules/FinanceBankAPI/FinanceBankAPI.php
r874 r887 8 8 class ModuleFinanceBankAPI extends AppModule 9 9 { 10 function __construct( $System)10 function __construct(System $System) 11 11 { 12 12 parent::__construct($System); … … 16 16 $this->License = 'GNU/GPLv3'; 17 17 $this->Description = 'Communication through API to various banks, manual file import'; 18 $this->Dependencies = array('Finance', 'Scheduler' );18 $this->Dependencies = array('Finance', 'Scheduler', 'IS'); 19 19 } 20 20 21 function DoInstall() 21 function DoInstall(): void 22 22 { 23 23 } 24 24 25 function DoUninstall() 25 function DoUninstall(): void 26 26 { 27 27 } 28 28 29 function DoStart() 29 function DoStart(): void 30 30 { 31 31 $this->System->FormManager->RegisterClass('ImportBankFile', array( … … 60 60 )); 61 61 62 $this->System->RegisterPage( array('finance', 'import-api'), 'PageImportAPI');63 $this->System->RegisterPage( array('finance', 'import-soubor'), 'PageImportFile');62 $this->System->RegisterPage(['finance', 'import-api'], 'PageImportAPI'); 63 $this->System->RegisterPage(['finance', 'import-soubor'], 'PageImportFile'); 64 64 65 $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('FinanceBankAPI',66 array( 'ModuleFinanceBankAPI', 'ShowDashboardItem'));65 ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('FinanceBankAPI', 66 array($this, 'ShowDashboardItem')); 67 67 } 68 68 69 function DoStop() 69 function DoStop(): void 70 70 { 71 71 } 72 72 73 function ShowDashboardItem() 73 function ShowDashboardItem(): string 74 74 { 75 75 $DbResult = $this->Database->select('FinanceBankImport', 'COUNT(*)', '`FinanceOperation` IS NULL'); … … 79 79 } 80 80 81 function PresetItem( $Item)81 function PresetItem(array $Item): array 82 82 { 83 83 $Preset = array(); 84 84 if ($Item['Value'] < 0) $OperationGroupId = OPERATION_GROUP_ACCOUNT_OUT; 85 85 else $OperationGroupId = OPERATION_GROUP_ACCOUNT_IN; 86 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($OperationGroupId, 'FinanceOperationGroup');86 $FinanceGroup = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetFinanceGroupById($OperationGroupId, 'FinanceOperationGroup'); 87 87 88 88 $Preset = array( … … 100 100 class ScheduleBankImport extends SchedulerTask 101 101 { 102 function Execute() 102 function Execute(): string 103 103 { 104 104 $Output = ''; -
trunk/Modules/FinanceBankAPI/Fio.php
r874 r887 5 5 class Fio 6 6 { 7 var$UserName;8 var$Password;9 var$Account;7 public string $UserName; 8 public string $Password; 9 public int $Account; 10 10 11 function Import( $TimeFrom, $TimeTo)11 function Import(int $TimeFrom, int $TimeTo): array 12 12 { 13 13 if ($this->UserName == '') throw new Exception('Missing value for UserName property.'); … … 59 59 } 60 60 61 function NoValidDataError( $Response)61 function NoValidDataError(array $Response): void 62 62 { 63 63 // Try to get error message 64 // If something go wrong fio show HTML login page and display error message65 $Response = implode('', $Response);64 // If something go wrong fio shows HTML login page and display error message 65 $Response = implode('', $Response); 66 66 $ErrorMessageStart = '<div id="oldform_warning">'; 67 67 if (strpos($Response, $ErrorMessageStart) !== false) 68 {69 $Response = substr($Response, strpos($Response, $ErrorMessageStart) + strlen($ErrorMessageStart));70 $ErrorMessage = trim(substr($Response, 0, strpos($Response, '</div>')));71 } else $ErrorMessage = '';72 throw new Exception('No valid GPC data: '.$ErrorMessage);68 { 69 $Response = substr($Response, strpos($Response, $ErrorMessageStart) + strlen($ErrorMessageStart)); 70 $ErrorMessage = trim(substr($Response, 0, strpos($Response, '</div>'))); 71 } else $ErrorMessage = ''; 72 throw new Exception('No valid GPC data: '.$ErrorMessage); 73 73 } 74 74 } -
trunk/Modules/FinanceBankAPI/FioAPI.php
r874 r887 23 23 } 24 24 25 function Import( $TimeFrom, $TimeTo)25 function Import(int $TimeFrom, int $TimeTo): array 26 26 { 27 27 if ($this->Token == '') throw new Exception('Missing value for Token property.'); … … 101 101 } 102 102 103 function NoValidDataError( $Response)103 function NoValidDataError(array $Response): void 104 104 { 105 105 // Try to get error message -
trunk/Modules/FinanceBankAPI/GPC.php
r874 r887 6 6 class GPC 7 7 { 8 function ParseLine( $Line)8 function ParseLine(string $Line): array 9 9 { 10 10 $Line = ' '.$Line; -
trunk/Modules/FinanceBankAPI/ImportFio.php
r884 r887 5 5 class ImportFio extends BankImport 6 6 { 7 function Import() 7 function Import(): string 8 8 { 9 9 $Fio = new FioAPI(); -
trunk/Modules/FinanceBankAPI/ImportPS.php
r873 r887 11 11 function ImportTxt($Content) 12 12 { 13 $Finance = &$this->System->Modules['Finance'];14 $Data = explode("\n", $Content);15 13 } 16 14 17 15 function ImportCVS($Content) 18 16 { 19 $Finance = &$this->System->Modules['Finance'];20 21 17 $Data = explode("\n", $Content); 22 18 foreach ($Data as $Key => $Value) -
trunk/Modules/IS/IS.php
r873 r887 5 5 class PageIS extends Page 6 6 { 7 var $FullTitle = 'Správa dat'; 8 var $ShortTitle = 'Správa dat'; 9 var $ParentClass = 'PagePortal'; 10 var $MenuItems; 11 var $HideMenu; 12 var $ShowActionName; 7 public array $MenuItems; 8 public bool $HideMenu; 9 public bool $ShowActionName; 13 10 14 11 function __construct($System) 15 12 { 16 13 parent::__construct($System); 14 $this->FullTitle = 'Správa dat'; 15 $this->ShortTitle = 'Správa dat'; 16 $this->ParentClass = 'PagePortal'; 17 17 18 $this->MenuItems = array(); 18 19 $this->HideMenu = false; … … 20 21 } 21 22 22 function Show() 23 { 24 if (! $this->System->User->CheckPermission('IS', 'Manage'))23 function Show(): string 24 { 25 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('IS', 'Manage')) 25 26 return 'Nemáte oprávnění'; 26 27 $this->System->FormManager->ShowRelation = true; … … 78 79 } 79 80 80 function Dashboard() 81 function Dashboard(): string 81 82 { 82 83 $Output = '<strong>Nástěnka:</strong><br/>'; 83 foreach ( $this->System->ModuleManager->Modules['IS']->DashboardItems as $Item)84 foreach (ModuleIS::Cast($this->System->GetModule('IS'))->DashboardItems as $Item) 84 85 { 85 86 if (is_string($Item['Callback'][0])) … … 93 94 } 94 95 95 function ShowFavoriteAdd( $Table, $ItemId)96 { 97 $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['i'] * 1).') AND (`User`='.$this-> System->User->User['Id'].')');96 function ShowFavoriteAdd(string $Table, string $ItemId): string 97 { 98 $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['i'] * 1).') AND (`User`='.$this->ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'].')'); 98 99 if ($DbResult->num_rows > 0) 99 100 { … … 101 102 } else 102 103 { 103 $this->Database->insert('MenuItemFavorite', array('MenuItem' => ($_GET['i'] * 1), 'User' => $this->System->User->User['Id']));104 $this->Database->insert('MenuItemFavorite', array('MenuItem' => ($_GET['i'] * 1), 'User' => ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'])); 104 105 $Output = $this->SystemMessage('Oblíbené', 'Přidáno do oblíbených'); 105 106 } … … 108 109 } 109 110 110 function ShowFavoriteDel( $Table, $ItemId)111 { 112 $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['i'] * 1).') AND (`User`='. $this->System->User->User['Id'].')');111 function ShowFavoriteDel(string $Table, string $ItemId): string 112 { 113 $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['i'] * 1).') AND (`User`='.ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'].')'); 113 114 if ($DbResult->num_rows > 0) 114 115 { … … 124 125 } 125 126 126 function LogChange( $Form, $Action, $NewId, $OldId)127 function LogChange(Form $Form, string $Action, string $NewId, string $OldId): void 127 128 { 128 129 $Values = $Form->Definition['Table'].' (Id: '.$OldId.' => '.$NewId.'):'."\n"; … … 152 153 } 153 154 } 154 $this->System->ModuleManager->Modules['Log']->NewRecord('IS', $Action, $Values);155 } 156 157 function ShowEdit( $Table, $Id)155 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('IS', $Action, $Values); 156 } 157 158 function ShowEdit(string $Table, string $Id): string 158 159 { 159 160 $Output = ''; 160 161 if (!array_key_exists($Table, $this->System->FormManager->Classes)) 161 162 return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena'); 162 if (defined('NEW_PERMISSION') and ! $this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))163 if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write')) 163 164 return $this->SystemMessage('Oprávnění', 'Nemáte oprávnění'); 164 165 if (array_key_exists('o', $_GET)) … … 226 227 } 227 228 228 function ShowDelete( $Table, $Id)229 function ShowDelete(string $Table, string $Id): string 229 230 { 230 231 $Output = ''; … … 232 233 return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena'); 233 234 $FormClass = $this->System->FormManager->Classes[$Table]; 234 if (defined('NEW_PERMISSION') and ! $this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))235 if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write')) 235 236 return 'Nemáte oprávnění'; 236 237 $DbResult = $this->Database->select($Table, '*', '`Id`='.$Id); … … 266 267 } 267 268 268 function ShowAdd( $Table, $Actions = array())269 function ShowAdd(string $Table, array $Actions = array()): string 269 270 { 270 271 $Output = ''; 271 272 if (!array_key_exists($Table, $this->System->FormManager->Classes)) 272 273 return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena'); 273 if (defined('NEW_PERMISSION') and ! $this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))274 if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write')) 274 275 return 'Nemáte oprávnění'; 275 276 if (array_key_exists('o', $_GET)) … … 315 316 316 317 //$this->Database->update($Table, 'Id='.$Id, 317 // array('UserCreate' => $this->System->User->User['Id'],318 // array('UserCreate' => ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'], 318 319 // 'TimeCreate' => 'NOW()')); 319 320 } catch (Exception $E) … … 357 358 } 358 359 359 function ShowAddSub( $Table, $Filter = '', $Title = '')360 { 361 if (defined('NEW_PERMISSION') and ! $this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))360 function ShowAddSub(string $Table, string $Filter = '', string $Title = ''): string 361 { 362 if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write')) 362 363 return 'Nemáte oprávnění'; 363 364 $this->BasicHTML = true; … … 367 368 } 368 369 369 function ShowTabs( $Tabs, $QueryParamName, $TabContent)370 function ShowTabs(array $Tabs, string $QueryParamName, string $TabContent): string 370 371 { 371 372 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); … … 388 389 } 389 390 390 function ShowView( $Table, $Id, $WithoutActions = false)391 function ShowView(string $Table, string $Id, bool $WithoutActions = false): string 391 392 { 392 393 if (!array_key_exists($Table, $this->System->FormManager->Classes)) 393 394 return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena'); 394 395 $FormClass = $this->System->FormManager->Classes[$Table]; 395 if (defined('NEW_PERMISSION') and ! $this->System->User->CheckPermission($this->TableToModule($Table), 'Read'))396 if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Read')) 396 397 return 'Nemáte oprávnění'; 397 398 … … 473 474 } 474 475 475 function ShowTable( $Table, $Filter = '', $Title = '', $RowActions = array(), $ExcludeColumn = '')476 function ShowTable(string $Table, string $Filter = '', string $Title = '', string $RowActions = '', string $ExcludeColumn = ''): string 476 477 { 477 478 if (!array_key_exists($Table, $this->System->FormManager->Classes)) … … 673 674 } 674 675 675 function ShowSelect( $Table, $Filter = '', $Title = '')676 { 677 if (defined('NEW_PERMISSION') and ! $this->System->User->CheckPermission($this->TableToModule($Table), 'Read'))676 function ShowSelect(string $Table, string $Filter = '', string $Title = ''): string 677 { 678 if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Read')) 678 679 return 'Nemáte oprávnění'; 679 680 $this->BasicHTML = true; … … 686 687 } 687 688 688 function ShowMapSelect( $Table, $Filter = '', $Title = '')689 { 690 if (defined('NEW_PERMISSION') and ! $this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))689 function ShowMapSelect(string $Table, string $Filter = '', string $Title = ''): string 690 { 691 if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write')) 691 692 return 'Nemáte oprávnění'; 692 693 $Map = new MapOpenStreetMaps($this->System); … … 701 702 } 702 703 703 function ShowList( $Table, $Filter = '', $Title = '', $ExcludeColumn = '', $ExcludeValue = '')704 function ShowList(string $Table, string $Filter = '', string $Title = '', string $ExcludeColumn = '', string $ExcludeValue = ''): string 704 705 { 705 706 $Output = ''; 706 if (defined('NEW_PERMISSION') and ! $this->System->User->CheckPermission($this->TableToModule($Table), 'Read'))707 if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Read')) 707 708 return 'Nemáte oprávnění'; 708 709 if (!array_key_exists($Table, $this->System->FormManager->Classes)) … … 738 739 if (array_key_exists('mi', $_GET)) 739 740 { 740 $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['mi'] * 1).') AND (`User`='. $this->System->User->User['Id'].')');741 $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['mi'] * 1).') AND (`User`='.ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'].')'); 741 742 if ($DbResult->num_rows > 0) 742 743 { … … 761 762 } 762 763 763 function ShowFavorites() 764 function ShowFavorites(): string 764 765 { 765 766 $this->MenuItems = array(); … … 768 769 'LEFT JOIN `Action` ON `Action`.`Id` = `MenuItem`.`Action` '. 769 770 'LEFT JOIN `ActionIcon` ON `ActionIcon`.`Id` = `Action`.`Icon` '. 770 'WHERE `MenuItemFavorite`.`User`='. $this->System->User->User['Id'].' '.771 'WHERE `MenuItemFavorite`.`User`='.ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'].' '. 771 772 'ORDER BY `MenuItem`.`Parent`,`MenuItem`.`Name`'); 772 773 while ($DbRow = $DbResult->fetch_assoc()) … … 778 779 } 779 780 780 function ShowMenu() 781 function ShowMenu(): string 781 782 { 782 783 $this->MenuItems = array(); … … 794 795 } 795 796 796 function ShowMenuItem( $Parent, $All = false)797 function ShowMenuItem(string $Parent, bool $All = false): string 797 798 { 798 799 $Output = '<ul style="list-style: none; margin-left:1em; padding-left:0em;">'; … … 810 811 if ($MenuItem['IconName'] != '') $Image = '<img src="'.$this->System->Link('/images/favicons/'.$MenuItem['IconName']).'"/> '; 811 812 else $Image = '<img src="'.$this->System->Link('/images/favicons/'.$Icon).'"/> '; 812 //if ( $this->System->User->CheckPermission($this->TableToModule($Table), 'Write') or !defined('NEW_PERMISSION'))813 //if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write') or !defined('NEW_PERMISSION')) 813 814 $Output .= '<li>'.$Image.$LinkTitle.'</li>'; 814 815 if ($All == false) $Output .= $this->ShowMenuItem($MenuItem['Id']); … … 819 820 } 820 821 821 function TableToModule( $Table)822 function TableToModule(string $Table): string 822 823 { 823 824 $DbResult = $this->Database->query('SELECT (SELECT `Name` FROM `Module` '. … … 830 831 } 831 832 832 function ShowAction( $Name, $Target, $Icon, $Confirm = '')833 function ShowAction(string $Name, string $Target, string $Icon, string $Confirm = ''): string 833 834 { 834 835 $Output = '<img alt="'.$Name.'" title="'.$Name.'" src="'. … … 846 847 var $DashboardItems; 847 848 848 function __construct( $System)849 function __construct(System $System) 849 850 { 850 851 parent::__construct($System); … … 855 856 $this->License = 'GNU/GPLv3'; 856 857 $this->Description = 'User interface for generic information system'; 857 $this->Dependencies = array( );858 $this->Dependencies = array('User'); 858 859 859 860 $this->DashboardItems = array(); 860 861 } 861 862 862 function DoInstall() 863 { 864 } 865 866 function DoUninstall() 867 { 868 } 869 870 function DoStart() 871 { 872 $this->System->RegisterPage( 'is', 'PageIS');863 function DoInstall(): void 864 { 865 } 866 867 function DoUninstall(): void 868 { 869 } 870 871 function DoStart(): void 872 { 873 $this->System->RegisterPage(['is'], 'PageIS'); 873 874 $this->System->FormManager->RegisterClass('MenuItem', array( 874 875 'Title' => 'Položky nabídky', … … 914 915 } 915 916 916 function DoStop() 917 { 918 } 919 920 function RegisterDashboardItem( $Name, $Callback)917 function DoStop(): void 918 { 919 } 920 921 function RegisterDashboardItem(string $Name, callable $Callback): void 921 922 { 922 923 $this->DashboardItems[$Name] = array('Callback' => $Callback); 923 924 } 924 925 925 function UnregisterDashboardItem( $Name)926 function UnregisterDashboardItem(string $Name): void 926 927 { 927 928 unset($this->DashboardItems[$Name]); 928 929 } 930 931 static function Cast(AppModule $AppModule): ModuleIS 932 { 933 if ($AppModule instanceof ModuleIS) 934 { 935 return $AppModule; 936 } 937 throw new Exception('Expected ModuleIS type but '.gettype($AppModule)); 938 } 929 939 } -
trunk/Modules/Log/Log.php
r874 r887 3 3 class ModuleLog extends AppModule 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 14 14 } 15 15 16 function DoInstall() 16 function DoInstall(): void 17 17 { 18 18 } 19 19 20 function DoUnInstall() 20 function DoUnInstall(): void 21 21 { 22 22 } 23 23 24 function DoStart() 24 function DoStart(): void 25 25 { 26 26 $this->System->FormManager->RegisterClass('Log', array( … … 38 38 ), 39 39 )); 40 $this->System->ModuleManager->Modules['RSS']->RegisterRSS(array('Title' => 'Logs',41 'Channel' => 'log', 'Callback' => array( 'ModuleLog', 'ShowRSS'),40 ModuleRSS::Cast($this->System->GetModule('RSS'))->RegisterRSS(array('Title' => 'Logs', 41 'Channel' => 'log', 'Callback' => array($this, 'ShowRSS'), 42 42 'Permission' => array('Module' => 'Log', 'Operation' => 'RSS'))); 43 43 } 44 44 45 function DoStop() 45 function DoStop(): void 46 46 { 47 47 } 48 48 49 function NewRecord( $Module, $Operation, $Value = '')49 function NewRecord(string $Module, string $Operation, string $Value = ''): void 50 50 { 51 if ( array_key_exists('User', $this->System->ModuleManager->Modules) and52 array_key_exists('Id', $this->System->User->User))53 $UserId = $this->System->User->User['Id'];51 if ($this->System->ModuleManager->ModulePresent('User') and 52 array_key_exists('Id', ModuleUser::Cast($this->System->GetModule('User'))->User->User)) 53 $UserId = ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id']; 54 54 else $UserId = NULL; 55 55 if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IPAddress = $_SERVER['REMOTE_ADDR']; … … 60 60 } 61 61 62 function ShowRSS() 62 function ShowRSS(): string 63 63 { 64 64 $this->ClearPage = true; … … 98 98 return $RSS->Generate(); 99 99 } 100 101 static function Cast(AppModule $AppModule): ModuleLog 102 { 103 if ($AppModule instanceof ModuleLog) 104 { 105 return $AppModule; 106 } 107 throw new Exception('Expected ModuleLog type but got '.gettype($AppModule)); 108 } 100 109 } -
trunk/Modules/Map/Map.php
r874 r887 5 5 class PageNetworkMap extends Page 6 6 { 7 var $FullTitle = 'Mapa sítě'; 8 var $ShortTitle = 'Mapa sítě'; 9 var $ParentClass = 'PagePortal'; 7 function __construct(System $System) 8 { 9 parent::__construct($System); 10 $this->FullTitle = 'Mapa sítě'; 11 $this->ShortTitle = 'Mapa sítě'; 12 $this->ParentClass = 'PagePortal'; 13 } 10 14 //var $Load = 'initialize()'; 11 15 //var $Unload = 'GUnload()'; 12 16 13 function Show() 14 { 15 if (! $this->System->User->CheckPermission('Map', 'Show'))17 function Show(): string 18 { 19 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Map', 'Show')) 16 20 return 'Nemáte oprávnění'; 17 21 … … 23 27 } 24 28 25 function ShowPosition() 29 function ShowPosition(): string 26 30 { 27 31 $DbResult = $this->Database->select('MapPosition', '*', '`Id`='.$_GET['i']); … … 44 48 } 45 49 46 function ShowMain() 50 function ShowMain(): string 47 51 { 48 52 $Map = new MapOpenStreetMaps($this->System); … … 242 246 class TypeMapPosition extends TypeString 243 247 { 244 function OnEdit( $Item)248 function OnEdit(array $Item): string 245 249 { 246 250 $Output = parent::OnEdit($Item); … … 255 259 class ModuleMap extends AppModule 256 260 { 257 function __construct( $System)261 function __construct(System $System) 258 262 { 259 263 parent::__construct($System); … … 263 267 $this->License = 'GNU/GPL'; 264 268 $this->Description = 'Show objects on Google maps'; 265 $this->Dependencies = array('Network' );269 $this->Dependencies = array('Network', 'User'); 266 270 $this->SupportedModels = array(); 267 271 } 268 272 269 function DoStart() 273 function DoStart(): void 270 274 { 271 275 $this->System->Pages['map'] = 'PageNetworkMap'; … … 310 314 } 311 315 312 function DoInstall() 316 function DoInstall(): void 313 317 { 314 318 $this->System->Database->query("CREATE TABLE IF NOT EXISTS `MapPosition` ( … … 320 324 } 321 325 322 function DoUninstall() 326 function DoUninstall(): void 323 327 { 324 328 $this->Database->query('DROP TABLE `MapPosition`'); -
trunk/Modules/Map/MapAPI.php
r874 r887 3 3 class MapMarker 4 4 { 5 var$Position;6 var$Text;5 public array $Position; 6 public string $Text; 7 7 } 8 8 9 9 class MapPolyLine 10 10 { 11 var$Points = array();12 var$Color = 'black';11 public array $Points = array(); 12 public string $Color = 'black'; 13 13 } 14 14 15 15 class Map extends Model 16 16 { 17 var$Position;18 var$Zoom;19 var$Key;17 public array $Position; 18 public int $Zoom; 19 public string $Key; 20 20 var $OnClickObject; 21 var$MarkerText;22 var$Markers;23 var$PolyLines;21 public string $MarkerText; 22 public array $Markers; 23 public array $PolyLines; 24 24 25 function __construct( $System)25 function __construct(System $System) 26 26 { 27 27 parent::__construct($System); … … 35 35 } 36 36 37 function Show() 37 function Show(): string 38 38 { 39 39 return ''; … … 43 43 class MapGoogle extends Map 44 44 { 45 function ShowPage( $Page)45 function ShowPage(Page $Page): string 46 46 { 47 47 $Page->Load = 'initialize()'; … … 113 113 class MapOpenStreetMaps extends Map 114 114 { 115 function GetPageHeader() 115 function GetPageHeader(): string 116 116 { 117 117 $Output = '<link rel="stylesheet" href="https://unpkg.com/leaflet@1.5.1/dist/leaflet.css" … … 124 124 } 125 125 126 function ShowPage( $Page)126 function ShowPage(Page $Page): string 127 127 { 128 128 $this->System->PageHeaders[] = array($this, 'GetPageHeader'); -
trunk/Modules/Meals/Meals.php
r874 r887 3 3 class PageEatingPlace extends Page 4 4 { 5 var $FullTitle = 'Jídleníček jídelny Na kopečku';6 var $ShortTitle = 'Jídelníček';7 var $ParentClass = 'PagePortal';8 5 var $DayNames = array('Neděle', 'Pondělí', 'Úterý', 'Středa', 'Čtvrtek', 'Pátek', 'Sobota'); 9 6 var $DayNamesShort = array('NE', 'PO', 'ÚT', 'ST', 'ČT', 'PÁ', 'SO'); … … 11 8 var $DayCount = 20; // počet dopředu zobrazených dnů 12 9 13 function Show() 10 function __construct(System $System) 11 { 12 parent::__construct($System); 13 $this->FullTitle = 'Jídleníček jídelny Na kopečku'; 14 $this->ShortTitle = 'Jídelníček'; 15 $this->ParentClass = 'PagePortal'; 16 } 17 18 function Show(): string 14 19 { 15 20 if (count($this->System->PathItems) > 1) … … 21 26 } 22 27 23 function ShowMenu() 28 function ShowMenu(): string 24 29 { 25 30 //echo('Dnes je '.HumanDate(date('Y-m-d')).'<br>'); … … 43 48 } 44 49 45 function ShowPrint() 50 function ShowPrint(): string 46 51 { 47 52 $this->ClearPage = true; … … 94 99 } 95 100 96 function PrintTableRow( $Row)101 function PrintTableRow(array $Row): string 97 102 { 98 103 global $LastWeekOfYear; … … 120 125 } 121 126 122 function ShowEdit() 127 function ShowEdit(): string 123 128 { 124 129 Header('Cache-Control: no-cache'); … … 136 141 } 137 142 $Output .= '<div style="color: red; font-size: larger;">Menu uloženo!</div>'; 138 $this->System->ModuleManager->Modules['Log']->NewRecord('EatingPlace', 'MenuSave');143 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('EatingPlace', 'MenuSave'); 139 144 } 140 145 if ($_GET['action'] == 'saveinfo') … … 143 148 $this->Database->insert('MealsInfo', array('Info' => $_POST['info'], 'Price' => $_POST['price'])); 144 149 $Output .= '<div style="color: red; font-size: larger;">Informační údaje uloženy!</div>'; 145 $this->System->ModuleManager->Modules['Log']->NewRecord('EatingPlace', 'InfoSave');150 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('EatingPlace', 'InfoSave'); 146 151 } 147 152 } … … 179 184 class ModuleMeals extends AppModule 180 185 { 181 function __construct( $System)186 function __construct(System $System) 182 187 { 183 188 parent::__construct($System); … … 191 196 } 192 197 193 function DoInstall() 194 { 195 } 196 197 function DoUnInstall() 198 { 199 } 200 201 function DoStart() 202 { 203 $this->System->RegisterPage( 'jidelna', 'PageEatingPlace');198 function DoInstall(): void 199 { 200 } 201 202 function DoUnInstall(): void 203 { 204 } 205 206 function DoStart(): void 207 { 208 $this->System->RegisterPage(['jidelna'], 'PageEatingPlace'); 204 209 } 205 210 } -
trunk/Modules/Meteostation/Meteostation.php
r874 r887 3 3 class PageMeteo extends Page 4 4 { 5 var $FullTitle = 'Stav meteostanice'; 6 var $ShortTitle = 'Meteostanice'; 7 var $ParentClass = 'PagePortal'; 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Stav meteostanice'; 9 $this->ShortTitle = 'Meteostanice'; 10 $this->ParentClass = 'PagePortal'; 11 } 8 12 9 function Show() 13 function Show(): string 10 14 { 11 15 $Output = 'Stav meteostanice:<br/>'; … … 22 26 var $URL; 23 27 24 function DownloadData() 28 function DownloadData(): void 25 29 { 26 30 $XmlData = simplexml_load_file($this->URL); … … 50 54 } 51 55 52 function CreateImage($FileName) 56 function CreateImage($FileName): void 53 57 { 54 58 $Image = new Image(); … … 63 67 } 64 68 65 function LoadFromDb() 69 function LoadFromDb(): void 66 70 { 67 71 $DbResult = $this->Database->select('Meteostation', '*', 'Id = '.$this->Id); … … 77 81 var $Data; 78 82 79 function __construct( $System)83 function __construct(System $System) 80 84 { 81 85 parent::__construct($System); … … 88 92 } 89 93 90 function DownloadAll() 94 function DownloadAll(): void 91 95 { 92 96 $DbResult = $this->Database->select('MeteoStation', '*'); 93 97 while ($DbRow = $DbResult->fetch_assoc()) 94 98 { 95 $MeteoStation = new MeteoStation( );99 $MeteoStation = new MeteoStation($this->System); 96 100 $MeteoStation->Id = $DbRow['Id']; 97 101 $MeteoStation->LoadFromDb(); … … 102 106 103 107 104 function DoInstall() 108 function DoInstall(): void 105 109 { 106 110 } 107 111 108 function DoUninstall() 112 function DoUninstall(): void 109 113 { 110 114 } 111 115 112 function DoStart() 116 function DoStart(): void 113 117 { 114 $this->System->RegisterPage( 'meteo', 'PageMeteo');118 $this->System->RegisterPage(['meteo'], 'PageMeteo'); 115 119 } 116 120 117 function DoStop() 121 function DoStop(): void 118 122 { 119 123 } -
trunk/Modules/Network/HostList.php
r874 r887 5 5 class PageHostList extends Page 6 6 { 7 var $FullTitle = 'Seznam registrovaných počítačů'; 8 var $ShortTitle = 'Seznam počítačů'; 9 var $ParentClass = 'PageNetwork'; 7 function __construct(System $System) 8 { 9 parent::__construct($System); 10 $this->FullTitle = 'Seznam registrovaných počítačů'; 11 $this->ShortTitle = 'Seznam počítačů'; 12 $this->ParentClass = 'PageNetwork'; 13 } 10 14 11 function Show() 15 function Show(): string 12 16 { 13 if (! $this->System->User->CheckPermission('Network', 'ShowHostList'))17 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Network', 'ShowHostList')) 14 18 return 'Nemáte oprávnění'; 15 19 -
trunk/Modules/Network/Hosting.php
r874 r887 3 3 class PageHosting extends Page 4 4 { 5 var $FullTitle = 'Hostované projekty'; 6 var $ShortTitle = 'Hostované projekty'; 7 var $ParentClass = 'PageNetwork'; 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Hostované projekty'; 9 $this->ShortTitle = 'Hostované projekty'; 10 $this->ParentClass = 'PageNetwork'; 11 } 8 12 9 function Show() 13 function Show(): string 10 14 { 11 15 $Output = '<br /><table class="WideTable"><tr><th>Název projektu</th><th>Založeno</th><th>Umístění na serveru</th><th>Zodpovědná osoba</th></tr>'; -
trunk/Modules/Network/Network.php
r879 r887 8 8 class PageFrequencyPlan extends Page 9 9 { 10 var $FullTitle = 'Výpis obsazení frekvenčních kanálů'; 11 var $ShortTitle = 'Frekvenční plán'; 12 var $ParentClass = 'PageNetwork'; 13 14 function Show() 10 function __construct(System $System) 11 { 12 parent::__construct($System); 13 $this->FullTitle = 'Výpis obsazení frekvenčních kanálů'; 14 $this->ShortTitle = 'Frekvenční plán'; 15 $this->ParentClass = 'PageNetwork'; 16 } 17 18 function Show(): string 15 19 { 16 20 // http://en.wikipedia.org/wiki/List_of_WLAN_channels … … 75 79 class PageNetwork extends Page 76 80 { 77 var $FullTitle = 'Technické informace o síti'; 78 var $ShortTitle = 'Síť'; 79 var $ParentClass = 'PagePortal'; 80 81 function Show() 82 { 83 if (count($this->System->PathItems) > 1) 84 { 85 $Output = $this->PageNotFound(); 86 } else $Output = $this->ShowInformation(); 87 return $Output; 88 } 89 90 function ShowInformation() 91 { 92 if (!$this->System->User->CheckPermission('Network', 'ShowInfo')) 81 function __construct(System $System) 82 { 83 parent::__construct($System); 84 $this->FullTitle = 'Technické informace o síti'; 85 $this->ShortTitle = 'Síť'; 86 $this->ParentClass = 'PagePortal'; 87 } 88 89 function Show(): string 90 { 91 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Network', 'ShowInfo')) 93 92 return 'Nemáte oprávnění'; 94 93 … … 102 101 class ModuleNetwork extends AppModule 103 102 { 104 var$MinNotifyTime;105 106 function __construct( $System)103 public int $MinNotifyTime; 104 105 function __construct(System $System) 107 106 { 108 107 parent::__construct($System); … … 112 111 $this->License = 'GNU/GPLv3'; 113 112 $this->Description = 'Networking related tools'; 114 $this->Dependencies = array('Notify' );113 $this->Dependencies = array('Notify', 'IS'); 115 114 116 115 // TODO: Make notify time configurable … … 118 117 } 119 118 120 function DoInstall() 121 { 122 } 123 124 function DoUninstall() 125 { 126 } 127 128 function DoStart() 129 { 130 $this->System->ModuleManager->Modules['Notify']->RegisterCheck('NetworkReachability',119 function DoInstall(): void 120 { 121 } 122 123 function DoUninstall(): void 124 { 125 } 126 127 function DoStart(): void 128 { 129 ModuleNotify::Cast($this->System->GetModule('Notify'))->RegisterCheck('NetworkReachability', 131 130 array($this, 'ReachabilityCheck')); 132 $this->System->ModuleManager->Modules['Notify']->RegisterCheck('NetworkPort',131 ModuleNotify::Cast($this->System->GetModule('Notify'))->RegisterCheck('NetworkPort', 133 132 array($this, 'PortCheck')); 134 133 135 $this->System->RegisterPage( 'network', 'PageNetwork');136 $this->System->RegisterPage( array('network', 'administration'), 'PageNetworkAdministration');137 $this->System->RegisterPage( array('network', 'subnet'), 'PageSubnet');138 $this->System->RegisterPage( array('network', 'user-hosts'), 'PageNetworkHostList');139 $this->System->RegisterPage( array('network', 'hosting'),'PageHosting');140 $this->System->RegisterPage( array('network', 'hosts'), 'PageHostList');141 $this->System->RegisterPage( array('network', 'frequency-plan'), 'PageFrequencyPlan');142 143 $this->System->RegisterCommandLine('networklog_import', array($this, 'ImportNetworkLog'));134 $this->System->RegisterPage(['network'], 'PageNetwork'); 135 $this->System->RegisterPage(['network', 'administration'], 'PageNetworkAdministration'); 136 $this->System->RegisterPage(['network', 'subnet'], 'PageSubnet'); 137 $this->System->RegisterPage(['network', 'user-hosts'], 'PageNetworkHostList'); 138 $this->System->RegisterPage(['network', 'hosting'],'PageHosting'); 139 $this->System->RegisterPage(['network', 'hosts'], 'PageHostList'); 140 $this->System->RegisterPage(['network', 'frequency-plan'], 'PageFrequencyPlan'); 141 142 $this->System->RegisterCommandLine('networklog_import', 'Imports network logs from remote server', array($this, 'ImportNetworkLog')); 144 143 145 144 $this->System->FormManager->RegisterClass('NetworkDomainAlias', array( … … 750 749 )); 751 750 752 $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Network',753 array( 'ModuleNetwork', 'ShowDashboardItem'));751 ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('Network', 752 array($this, 'ShowDashboardItem')); 754 753 755 754 $this->System->RegisterModel('NetworkDevice', array( … … 761 760 } 762 761 763 function AfterInsertNetworkDevice( $Form)762 function AfterInsertNetworkDevice(Form $Form): void 764 763 { 765 764 $this->System->Models['NetworkDevice']->DoOnChange(); 766 765 } 767 766 768 function AfterModifyNetworkDevice( $Form, $Id)767 function AfterModifyNetworkDevice(Form $Form, string $Id): void 769 768 { 770 769 $this->System->Models['NetworkDevice']->DoOnChange(); 771 770 } 772 771 773 function AfterInsertNetworkInterface( $Form)772 function AfterInsertNetworkInterface(Form $Form): void 774 773 { 775 774 $this->System->Models['NetworkInterface']->DoOnChange(); 776 775 } 777 776 778 function AfterModifyNetworkInterface( $Form, $Id)777 function AfterModifyNetworkInterface(Form $Form, string $Id): void 779 778 { 780 779 $this->System->Models['NetworkInterface']->DoOnChange(); 781 780 } 782 781 783 function BeforeDeleteNetworkInterface( $Form, $Id)782 function BeforeDeleteNetworkInterface(Form $Form, string $Id): void 784 783 { 785 784 $this->Database->query('DELETE FROM `NetworkInterfaceUpDown` WHERE `Interface`='.$Id); … … 791 790 } 792 791 793 function ImportNetworkLog( $Parameters)792 function ImportNetworkLog(array $Parameters): void 794 793 { 795 794 global $Config; … … 813 812 { 814 813 $DbRow2 = $DbResult2->fetch_assoc(); 815 $DeviceI D= $DbRow2['Device'];814 $DeviceId = $DbRow2['Device']; 816 815 $this->System->Database->insert('NetworkDeviceLog', array('Time' => $DbRow['ReceivedAt'], 817 816 'Device' => $DeviceId, 'Message' => $DbRow['Message'], 'Tags' => $DbRow['SysLogTag'])); … … 820 819 } 821 820 822 function ShowDashboardItem() 821 function ShowDashboardItem(): string 823 822 { 824 823 $Output = ''; … … 841 840 } 842 841 843 function DoStop() 844 { 845 } 846 847 function OnlineList( $Title, $OnlineNow, $OnlinePrevious, $MinDuration)842 function DoStop(): void 843 { 844 } 845 846 function OnlineList(string $Title, string $OnlineNow, string $OnlinePrevious, int $MinDuration): array 848 847 { 849 848 $Time = time(); … … 886 885 } 887 886 888 function ReachabilityCheck() 887 function ReachabilityCheck(): array 889 888 { 890 889 $NewOnline = $this->OnlineList('Nově online', 1, 0, 0); … … 898 897 } 899 898 900 function PortCheckList( $Title, $OnlineNow, $OnlinePrevious, $MinDuration)899 function PortCheckList(string $Title, string $OnlineNow, string $OnlinePrevious, int $MinDuration): array 901 900 { 902 901 $Time = time(); … … 937 936 } 938 937 939 function PortCheck() 938 function PortCheck(): array 940 939 { 941 940 $Output = ''; -
trunk/Modules/Network/Subnet.php
r874 r887 3 3 class PageSubnet extends Page 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 11 11 } 12 12 13 function Show() 13 function Show(): string 14 14 { 15 15 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `NetworkSubnet`'); -
trunk/Modules/Network/UserHosts.php
r874 r887 3 3 class PageNetworkHostList extends Page 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 11 11 } 12 12 13 function Show() 13 function Show(): string 14 14 { 15 15 global $Config; 16 16 17 if ( $this->System->User->User['Id'] == '') return $this->SystemMessage('Nepovolený přístup', 'Nemáte oprávnění pro tuto operaci');17 if (ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'] == '') return $this->SystemMessage('Nepovolený přístup', 'Nemáte oprávnění pro tuto operaci'); 18 18 $Output = '<div align="center" style="font-size: small;"><table class="WideTable">'; 19 19 $Output .= '<tr><th>Jméno počítače</th><th>Místní adresa</th><th>Veřejná adresa</th><th>Fyzická adresa</th><th>Typ</th><th>Naposledy online</th></tr>'; 20 20 $DbResult = $this->Database->query('SELECT NetworkDevice.*, NetworkDeviceType.Name AS HostType FROM NetworkDevice '. 21 21 'LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type '. 22 'WHERE NetworkDevice.Used = 1 AND NetworkDevice.Member = (SELECT Customer FROM UserCustomerRel WHERE User='. $this->System->User->User['Id'].') ORDER BY NetworkDevice.Name');22 'WHERE NetworkDevice.Used = 1 AND NetworkDevice.Member = (SELECT Customer FROM UserCustomerRel WHERE User='.ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'].') ORDER BY NetworkDevice.Name'); 23 23 while ($Device = $DbResult->fetch_assoc()) 24 24 { -
trunk/Modules/NetworkConfig/Generate.php
r873 r887 2 2 3 3 if (isset($_SERVER['REMOTE_ADDR'])) die(); 4 include_once(dirname(__FILE__).'/../../Application/ System.php');4 include_once(dirname(__FILE__).'/../../Application/Core.php'); 5 5 $System = new Core(); 6 6 $System->ShowPage = false; -
trunk/Modules/NetworkConfig/NetworkConfig.php
r874 r887 5 5 var $ConfigItems; 6 6 7 function __construct( $System)7 function __construct(System $System) 8 8 { 9 9 parent::__construct($System); … … 17 17 } 18 18 19 function DoInstall() 19 function DoInstall(): void 20 20 { 21 21 } 22 22 23 function DoUnInstall() 23 function DoUnInstall(): void 24 24 { 25 25 } 26 26 27 function DoStart() 27 function DoStart(): void 28 28 { 29 29 $this->System->FormManager->RegisterClass('NetworkConfiguration', array( … … 55 55 'States' => array('Neplánováno', 'V plánu', 'Provádí se'), 56 56 )); 57 58 $this->System->RegisterCommandLine('config', array($this, 'Config'));57 58 $this->System->RegisterCommandLine('config', 'Configures network services.', array($this, 'Config')); 59 59 $this->System->Models['NetworkDevice']->RegisterOnChange('NetworkConfig', array($this, 'DoNetworkChange')); 60 60 $this->System->Models['NetworkInterface']->RegisterOnChange('NetworkConfig', array($this, 'DoNetworkChange')); 61 61 } 62 63 function DoNetworkChange() 62 63 function DoNetworkChange(): void 64 64 { 65 65 $this->Database->query('UPDATE `NetworkConfiguration` SET `Changed`=1 WHERE '. … … 67 67 } 68 68 69 function RegisterConfigItem( $Name, $ClassName)69 function RegisterConfigItem(string $Name, string $ClassName): void 70 70 { 71 71 $this->ConfigItems[$Name] = $ClassName; 72 72 } 73 73 74 function UnregisterConfigItem( $Name)74 function UnregisterConfigItem(string $Name): void 75 75 { 76 76 unset($this->ConfigItems[$Name]); 77 77 } 78 78 79 function Config( $Parameters)79 function Config(array $Parameters): void 80 80 { 81 81 $Output = ''; … … 90 90 } else $Output = 'Config item '.$ConfigItemName.' not found'; 91 91 } else $Output = 'Not enough parameters'; 92 return $Output; 92 echo($Output); 93 } 94 95 static function Cast(AppModule $AppModule): ModuleNetworkConfig 96 { 97 if ($AppModule instanceof ModuleNetworkConfig) 98 { 99 return $AppModule; 100 } 101 throw new Exception('Expected ModuleNetworkConfig type but got '.gettype($AppModule)); 93 102 } 94 103 } … … 96 105 class NetworkConfigItem extends Model 97 106 { 98 function Run() 107 function Run(): void 99 108 { 100 101 109 } 102 110 } -
trunk/Modules/NetworkConfigAirOS/Generators/Signal.php
r873 r887 5 5 class ConfigAirOSSignal extends NetworkConfigItem 6 6 { 7 function ReadWirelessRegistration() 7 function ReadWirelessRegistration(): void 8 8 { 9 9 $Time = time(); … … 19 19 //$SSHClient->Debug = true; 20 20 $Result = $SSHClient->Execute('wstalist'); 21 if (count($Result) > 0) 22 { 21 if (count($Result) > 0) 22 { 23 23 //print_r($Result); 24 24 $Array = json_decode(implode("\n", $Result), true); … … 44 44 echo("\n"); 45 45 } else echo("Empty response\n"); 46 47 46 } 48 47 } 49 48 50 function Run() 49 function Run(): void 51 50 { 52 51 RepeatFunction(60 * 60, array($this, 'ReadWirelessRegistration')); -
trunk/Modules/NetworkConfigAirOS/NetworkConfigAirOS.php
r781 r887 5 5 class ModuleNetworkConfigAirOS extends AppModule 6 6 { 7 function __construct( $System)7 function __construct(System $System) 8 8 { 9 9 parent::__construct($System); … … 16 16 } 17 17 18 function DoInstall() 18 function DoInstall(): void 19 19 { 20 20 } 21 21 22 function DoUnInstall() 22 function DoUnInstall(): void 23 23 { 24 24 } 25 25 26 function DoStart() 26 function DoStart(): void 27 27 { 28 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('airos-signal', 'ConfigAirOSSignal');28 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('airos-signal', 'ConfigAirOSSignal'); 29 29 } 30 30 } -
trunk/Modules/NetworkConfigLinux/Generators/CheckPorts.php
r874 r887 3 3 class ConfigCheckPorts extends NetworkConfigItem 4 4 { 5 function CheckPortStatus($IP, $Port, $Protocol = 'tcp') 5 function CheckPortStatus($IP, $Port, $Protocol = 'tcp'): int 6 6 { 7 7 $Timeout = 1; … … 17 17 return $State; 18 18 } 19 20 function CheckPorts() 19 20 function CheckPorts(): void 21 21 { 22 22 $StartTime = time(); … … 77 77 } 78 78 79 function Run() 79 function Run(): void 80 80 { 81 81 RepeatFunction(60, array($this, 'CheckPorts')); -
trunk/Modules/NetworkConfigLinux/Generators/DNS.php
r873 r887 7 7 class ConfigDNS extends NetworkConfigItem 8 8 { 9 function GenerateDNS( $DNS)9 function GenerateDNS(array $DNS): void 10 10 { 11 11 $Output = '$ORIGIN '.$DNS['Domain'].'.'."\n". … … 147 147 } 148 148 149 function Run() 149 function Run(): void 150 150 { 151 151 $BaseDomain = 'zdechov.net'; -
trunk/Modules/NetworkConfigLinux/Generators/Latency.php
r873 r887 3 3 class ConfigLatency extends NetworkConfigItem 4 4 { 5 function PingHosts() 5 function PingHosts(): void 6 6 { 7 7 $Timeout = 2000; // ms … … 23 23 24 24 $Queries = array(); 25 foreach ($Output as $Index => $Line) 25 foreach ($Output as $Index => $Line) 26 26 { 27 27 $IP = substr($Line, 0, strPos($Line, ' ')); … … 35 35 } 36 36 37 function Run() 37 function Run(): void 38 38 { 39 39 RepeatFunction(10 * 60, array($this, 'PingHosts')); -
trunk/Modules/NetworkConfigLinux/NetworkConfigLinux.php
r824 r887 7 7 class ModuleNetworkConfigLinux extends AppModule 8 8 { 9 function __construct( $System)9 function __construct(System $System) 10 10 { 11 11 parent::__construct($System); … … 18 18 } 19 19 20 function DoInstall() 20 function DoInstall(): void 21 21 { 22 22 } 23 23 24 function DoUnInstall() 24 function DoUnInstall(): void 25 25 { 26 26 } 27 27 28 function DoStart() 28 function DoStart(): void 29 29 { 30 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('linux-dns', 'ConfigDNS');31 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('linux-checkports', 'ConfigCheckPorts');32 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('linux-latency', 'ConfigLatency');30 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('linux-dns', 'ConfigDNS'); 31 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('linux-checkports', 'ConfigCheckPorts'); 32 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('linux-latency', 'ConfigLatency'); 33 33 } 34 34 } -
trunk/Modules/NetworkConfigRouterOS/Generators/DHCP.php
r873 r887 4 4 class ConfigRouterOSDHCP extends NetworkConfigItem 5 5 { 6 function Run() 6 function Run(): void 7 7 { 8 8 $Path = array('ip', 'dhcp-server', 'lease'); -
trunk/Modules/NetworkConfigRouterOS/Generators/DNS.php
r873 r887 3 3 class ConfigRouterOSDNS extends NetworkConfigItem 4 4 { 5 function Run() 5 function Run(): void 6 6 { 7 7 $Path = array('ip', 'dns', 'static'); -
trunk/Modules/NetworkConfigRouterOS/Generators/FirewallFilter.php
r873 r887 3 3 class ConfigRouterOSFirewallFilter extends NetworkConfigItem 4 4 { 5 function Run() 5 function Run(): void 6 6 { 7 7 $Path = array('ip', 'firewall', 'filter'); -
trunk/Modules/NetworkConfigRouterOS/Generators/FirewallMangle.php
r873 r887 3 3 class ConfigRouterOSFirewallMangle extends NetworkConfigItem 4 4 { 5 function ProcessNode($Node) 5 function ProcessNode($Node): void 6 6 { 7 7 global $InetInterface, $ItemsFirewall; 8 8 9 foreach ($Node['Items'] as $I ndex => $Item)9 foreach ($Node['Items'] as $Item) 10 10 { 11 11 if (count($Item['Items']) == 0) … … 47 47 } 48 48 49 function Run() 49 function Run(): void 50 50 { 51 51 $this->RunIPv4(); … … 53 53 } 54 54 55 function RunIPv4() 55 function RunIPv4(): void 56 56 { 57 57 global $ItemsFirewall; … … 149 149 } 150 150 151 function RunIPv6() 151 function RunIPv6(): void 152 152 { 153 153 global $ItemsFirewall; -
trunk/Modules/NetworkConfigRouterOS/Generators/FirewallNAT.php
r873 r887 3 3 class ConfigRouterOSFirewallNAT extends NetworkConfigItem 4 4 { 5 function Run() 5 function Run(): void 6 6 { 7 7 $Path = array('ip', 'firewall', 'nat'); -
trunk/Modules/NetworkConfigRouterOS/Generators/Netwatch.php
r873 r887 3 3 class ConfigRouterOSNetwatch extends NetworkConfigItem 4 4 { 5 function Run() 5 function Run(): void 6 6 { 7 7 $Path = array('tool', 'netwatch'); -
trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php
r873 r887 3 3 class ConfigRouterOSNetwatchImport extends NetworkConfigItem 4 4 { 5 function NetwatchImport() 5 function NetwatchImport(): void 6 6 { 7 7 $StartTime = time(); … … 44 44 $Queries = array(); 45 45 $QueriesInsert = array(); 46 foreach ($Interfaces as $In dex => $Interface)46 foreach ($Interfaces as $Interface) 47 47 { 48 48 // Update last online time if still online … … 103 103 } 104 104 105 function Run() 105 function Run(): void 106 106 { 107 107 RepeatFunction(10, array($this, 'NetwatchImport')); -
trunk/Modules/NetworkConfigRouterOS/Generators/Queue.php
r873 r887 14 14 } 15 15 16 function Print() 16 function Print(): string 17 17 { 18 18 $Output = '(Min: '.$this->Min.' Max: '.$this->Max; … … 46 46 } 47 47 48 function CheckName($Name, &$UsedNames) 48 function CheckName($Name, &$UsedNames): void 49 49 { 50 50 if (in_array($Name, $UsedNames)) die("\n".'Duplicate name: '.$Name); … … 52 52 } 53 53 54 function GetCommands(&$UsedNames = null) 54 function GetCommands(&$UsedNames = null): array 55 55 { 56 56 if ($UsedNames == null) $UsedNames = array(); … … 72 72 } 73 73 74 function GetParentName(string $Suffix) 74 function GetParentName(string $Suffix): string 75 75 { 76 76 if ($this->Parent != null) return $this->Parent->Name.$Suffix; … … 78 78 } 79 79 80 function UpdateMinSpeeds() 80 function UpdateMinSpeeds(): void 81 81 { 82 82 if (($this->LimitIn->Min == 0) or ($this->LimitOut->Min == 0)) … … 100 100 class SpeedLimitItems extends GenericList 101 101 { 102 function AddNew(string $Name, SpeedLimitItem $Parent = null) 102 function AddNew(string $Name, SpeedLimitItem $Parent = null): SpeedLimitItem 103 103 { 104 104 $Item = new SpeedLimitItem($Name, $Parent); 105 $Item->LimitIn = new SpeedLimit( );106 $Item->LimitOut = new SpeedLimit( );105 $Item->LimitIn = new SpeedLimit(0, 0); 106 $Item->LimitOut = new SpeedLimit(0, 0); 107 107 $this->Items[] = $Item; 108 108 return $Item; … … 119 119 } 120 120 121 function GetCommands(&$UsedNames) 121 function GetCommands(&$UsedNames): array 122 122 { 123 123 $Output = array(); … … 137 137 var $SpeedLimits; 138 138 139 function Run() 139 function Run(): void 140 140 { 141 141 $PathQueue = array('queue', 'tree'); … … 149 149 $this->UsedNames = array(); 150 150 151 $Finance = & $this->System->Modules['Finance'];151 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 152 152 $Finance->LoadMonthParameters(0); 153 153 … … 280 280 } 281 281 282 function BuildSpeedLimit(&$SpeedLimit, $TopSpeedLimitItem) 282 function BuildSpeedLimit(&$SpeedLimit, $TopSpeedLimitItem): void 283 283 { 284 284 $SpeedLimitName = $SpeedLimit['Name'].'-grp'; … … 297 297 } 298 298 299 function LoadSpeedLimits($SpeedLimitItem) 299 function LoadSpeedLimits($SpeedLimitItem): void 300 300 { 301 301 echo('Limit groups: '); … … 326 326 } 327 327 328 function UpdateMinSpeed($DeviceId) 328 function UpdateMinSpeed($DeviceId): void 329 329 { 330 330 $MinSpeed = 0; … … 340 340 341 341 // Calculate maximum real speed available for each network device Start with main router and continue with adjecement nodes. 342 function BuildTree($RootDeviceId, $BaseSpeed) 342 function BuildTree($RootDeviceId, $BaseSpeed): void 343 343 { 344 344 // Load network devices … … 438 438 } 439 439 440 function BuildQueueItems($DeviceId, $SpeedLimitParent) 440 function BuildQueueItems($DeviceId, $SpeedLimitParent): void 441 441 { 442 442 $Device = $this->Devices[$DeviceId]; … … 475 475 } 476 476 477 function RunTopology() 477 function RunTopology(): void 478 478 { 479 479 $PathQueue = array('queue', 'tree'); … … 487 487 $this->UsedNames = array(); 488 488 489 $Finance = & $this->System->Modules['Finance'];489 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 490 490 $Finance->LoadMonthParameters(0); 491 491 -
trunk/Modules/NetworkConfigRouterOS/Generators/Signal.php
r874 r887 3 3 class ConfigRouterOSSignal extends NetworkConfigItem 4 4 { 5 function ReadWirelessRegistration() 5 function ReadWirelessRegistration(): void 6 6 { 7 7 $Time = time(); … … 66 66 $this->Database->Transaction($Queries); 67 67 } 68 69 function StripUnits($Value) 68 69 function StripUnits($Value): string 70 70 { 71 71 if (strpos($Value, '-') !== false) $Value = substr($Value, 0, strpos($Value, '-') - 1); // without channel info 72 72 if (substr($Value, -3, 3) == "MHz") $Value = substr($Value, 0, -3); // without MHz unit 73 if (substr($Value, -4, 4) == "Mbps") $Value = substr($Value, 0, -4); // without Mbps unit 74 if (substr($Value, -3, 3) == "Mbp") $Value = substr($Value, 0, -3); // without Mbp unit 73 if (substr($Value, -4, 4) == "Mbps") $Value = substr($Value, 0, -4); // without Mbps unit 74 if (substr($Value, -3, 3) == "Mbp") $Value = substr($Value, 0, -3); // without Mbp unit 75 75 if (substr($Value, -1, 1) == "M") $Value = substr($Value, 0, -1); // without M unit 76 76 return $Value; 77 77 } 78 78 79 function Run() 79 function Run(): void 80 80 { 81 81 RepeatFunction(60 * 60, array($this, 'ReadWirelessRegistration')); -
trunk/Modules/NetworkConfigRouterOS/NetworkConfigRouterOS.php
r874 r887 18 18 class ModuleNetworkConfigRouterOS extends AppModule 19 19 { 20 function __construct( $System)20 function __construct(System $System) 21 21 { 22 22 parent::__construct($System); … … 29 29 } 30 30 31 function DoInstall() 31 function DoInstall(): void 32 32 { 33 33 } 34 34 35 function DoUnInstall() 35 function DoUnInstall(): void 36 36 { 37 37 } 38 38 39 function DoStart() 39 function DoStart(): void 40 40 { 41 41 $this->System->Pages['zdarma'] = 'PageFreeAccess'; 42 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-dns', 'ConfigRouterOSDNS');43 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-dhcp', 'ConfigRouterOSDHCP');44 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-signal', 'ConfigRouterOSSignal');45 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-netwatch', 'ConfigRouterOSNetwatch');46 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-netwatch-import', 'ConfigRouterOSNetwatchImport');47 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-firewall-filter', 'ConfigRouterOSFirewallFilter');48 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-firewall-nat', 'ConfigRouterOSFirewallNAT');49 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-firewall-mangle', 'ConfigRouterOSFirewallMangle');50 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-queue', 'ConfigRouterOSQueue');42 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-dns', 'ConfigRouterOSDNS'); 43 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-dhcp', 'ConfigRouterOSDHCP'); 44 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-signal', 'ConfigRouterOSSignal'); 45 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-netwatch', 'ConfigRouterOSNetwatch'); 46 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-netwatch-import', 'ConfigRouterOSNetwatchImport'); 47 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-firewall-filter', 'ConfigRouterOSFirewallFilter'); 48 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-firewall-nat', 'ConfigRouterOSFirewallNAT'); 49 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-firewall-mangle', 'ConfigRouterOSFirewallMangle'); 50 ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-queue', 'ConfigRouterOSQueue'); 51 51 } 52 52 } … … 54 54 class PageFreeAccess extends Page 55 55 { 56 var $FullTitle = 'Přístup zdarma k Internetu'; 57 var $ShortTitle = 'Internet zdarma'; 58 var $ParentClass = 'PagePortal'; 59 var $AddressList = 'free-access'; 60 var $Timeout; 56 public string $AddressList = 'free-access'; 57 public int $Timeout; 61 58 62 function __construct( $System)59 function __construct(System $System) 63 60 { 64 61 parent::__construct($System); 62 $this->FullTitle = 'Přístup zdarma k Internetu'; 63 $this->ShortTitle = 'Internet zdarma'; 64 $this->ParentClass = 'PagePortal'; 65 65 66 $this->Timeout = 24 * 60 * 60; 66 67 } 67 68 68 function Show() 69 function Show(): string 69 70 { 70 71 $IPAddress = GetRemoteAddress(); 71 72 $Output = 'Vaše IP adresa je: '.$IPAddress.'<br/>'; 72 if (IsInternetAddr($IPAddress)) { 73 if (IsInternetAddr($IPAddress)) 74 { 73 75 $Output .= '<p>Internet zdarma je dostupný pouze z vnitřní sítě.</p>'; 74 76 return $Output; … … 117 119 class ScheduleConfigureFreeAccess extends SchedulerTask 118 120 { 119 function Execute() 121 function Execute(): string 120 122 { 121 123 $Output = ''; -
trunk/Modules/NetworkConfigRouterOS/Routerboard.php
r874 r887 19 19 } 20 20 21 function Execute( $Commands)21 function Execute(array $Commands): array 22 22 { 23 23 $Output = array(); … … 44 44 } 45 45 46 function ExecuteBatch( $Commands)46 function ExecuteBatch(string $Commands): string 47 47 { 48 48 $Commands = trim($Commands); … … 65 65 } 66 66 67 function ItemGet( $Path)67 function ItemGet(array $Path): array 68 68 { 69 69 $Result = $this->Execute(implode(' ', $Path).' print'); … … 82 82 } 83 83 84 function ListGet( $Path, $Properties, $Conditions = array())84 function ListGet(array $Path, array $Properties, array $Conditions = array()): array 85 85 { 86 86 $PropertyList = '"'; … … 116 116 } 117 117 118 function ListGetPrint($Path, $Properties, $Conditions = array()) 118 function ListGetPrint($Path, $Properties, $Conditions = array()): array 119 119 { 120 120 $ConditionList = ''; … … 151 151 } 152 152 153 function ListEraseAll( $Path)153 function ListEraseAll(array $Path): void 154 154 { 155 155 $this->Execute(implode(' ', $Path).' { remove [find] }'); 156 156 } 157 157 158 function ListUpdate( $Path, $Properties, $Values, $Condition = array(), $UsePrint = false)158 function ListUpdate(array $Path, array $Properties, array $Values, array $Condition = array(), bool $UsePrint = false): array 159 159 { 160 160 // Get current list from routerboard -
trunk/Modules/NetworkConfigRouterOS/Routerboard2.php
r874 r887 11 11 ); 12 12 13 function Execute($Commands) 13 function Execute($Commands): array 14 14 { 15 15 if (is_array($Commands)) $Commands = implode(';', $Commands); … … 17 17 } 18 18 19 function GetItem($Command) 19 function GetItem($Command): array 20 20 { 21 21 $Result = $this->Execute($Command); … … 25 25 { 26 26 $ResultLineParts = explode(' ', trim($ResultLine)); 27 if ($ResultLineParts[1] {0}== '"') $ResultLineParts[1] = substr($ResultLineParts[1], 1, -1); // Remove quotes27 if ($ResultLineParts[1][0] == '"') $ResultLineParts[1] = substr($ResultLineParts[1], 1, -1); // Remove quotes 28 28 $List[substr($ResultLineParts[0], 0, -1)] = $ResultLineParts[1]; 29 29 } … … 31 31 } 32 32 33 function GetList($Command, $Properties) 33 function GetList($Command, $Properties): array 34 34 { 35 35 $PropertyList = '"'; … … 55 55 } 56 56 57 function GetSystemResource() 57 function GetSystemResource(): array 58 58 { 59 59 return $this->GetItem('/system resource print'); 60 60 } 61 61 62 function GetFirewallFilterList() 62 function GetFirewallFilterList(): array 63 63 { 64 64 return $this->GetList('/ip firewall nat', array('src-address', 'dst-address', 'bytes')); 65 65 } 66 66 67 function GetDHCPServerLeasesList() 67 function GetDHCPServerLeasesList(): array 68 68 { 69 69 return $this->GetList('/ip dhcp-server lease', array('address', 'active-address', 'comment', 'lease-time', 'status', 'host-name')); -
trunk/Modules/NetworkConfigRouterOS/RouterboardAPI.php
r874 r887 25 25 } 26 26 27 function EncodeLength($Length) 28 { 29 if ($Length < 0x80) { 27 function EncodeLength(int $Length): int 28 { 29 if ($Length < 0x80) 30 { 30 31 $Length = chr($Length); 31 } else if ($Length < 0x4000) { 32 } else if ($Length < 0x4000) 33 { 32 34 $Length |= 0x8000; 33 35 $Length = chr(($Length >> 8) & 0xFF).chr($Length & 0xFF); 34 } else if ($Length < 0x200000) { 36 } else if ($Length < 0x200000) 37 { 35 38 $Length |= 0xC00000; 36 39 $Length = chr(($Length >> 16) & 0xFF).chr(($Length >> 8) & 0xFF).chr($Length & 0xFF); 37 } else if ($Length < 0x10000000) { 40 } else if ($Length < 0x10000000) 41 { 38 42 $Length |= 0xE0000000; 39 43 $Length = chr(($Length >> 24) & 0xFF).chr(($Length >> 16) & 0xFF).chr(($Length >> 8) & 0xFF).chr($Length & 0xFF); … … 43 47 } 44 48 45 function ConnectOnce( $IP, $Login, $Password)49 function ConnectOnce(string $IP, string $Login, string $Password): void 46 50 { 47 51 if ($this->Connected) $this->Disconnect(); … … 63 67 } 64 68 65 function Connect( $IP, $Login, $Password)69 function Connect(string $IP, string $Login, string $Password): bool 66 70 { 67 71 for ($Attempt = 1; $Attempt <= $this->Attempts; $Attempt++) … … 74 78 } 75 79 76 function Disconnect() 80 function Disconnect(): void 77 81 { 78 82 if ($this->Connected) … … 83 87 } 84 88 85 function ParseResponse($Response) 86 { 87 if (is_array($Response)) { 89 function ParseResponse(array $Response): array 90 { 91 if (is_array($Response)) 92 { 88 93 $Parsed = array(); 89 94 $Current = null; 90 95 $SingleValue = null; 91 96 $count = 0; 92 foreach ($Response as $x) { 97 foreach ($Response as $x) 98 { 93 99 if (in_array($x, array( 94 100 '!fatal', 95 101 '!re', 96 102 '!trap' 97 ))) { 98 if ($x == '!re') { 103 ))) 104 { 105 if ($x == '!re') 106 { 99 107 $Current =& $Parsed[]; 100 108 } else 101 109 $Current =& $Parsed[$x][]; 102 } else if ($x != '!done') { 103 if (preg_match_all('/[^=]+/i', $x, $Matches)) { 110 } else if ($x != '!done') 111 { 112 if (preg_match_all('/[^=]+/i', $x, $Matches)) 113 { 104 114 if ($Matches[0][0] == 'ret') { 105 115 $SingleValue = $Matches[0][1]; … … 109 119 } 110 120 } 111 if (empty($Parsed) && !is_null($SingleValue)) { 121 if (empty($Parsed) && !is_null($SingleValue)) 122 { 112 123 $Parsed = $SingleValue; 113 124 } … … 117 128 } 118 129 119 function ArrayChangeKeyName(&$array) 120 { 121 if (is_array($array)) { 122 foreach ($array as $k => $v) { 130 function ArrayChangeKeyName(array &$array): array 131 { 132 if (is_array($array)) 133 { 134 foreach ($array as $k => $v) 135 { 123 136 $tmp = str_replace("-", "_", $k); 124 137 $tmp = str_replace("/", "_", $tmp); 125 if ($tmp) { 138 if ($tmp) 139 { 126 140 $array_new[$tmp] = $v; 127 } else { 141 } else 142 { 128 143 $array_new[$k] = $v; 129 144 } 130 145 } 131 146 return $array_new; 132 } else { 147 } else 148 { 133 149 return $array; 134 150 } 135 151 } 136 152 137 function Read( $Parse = true)153 function Read(bool $Parse = true): array 138 154 { 139 155 $Line = ''; 140 156 $Response = array(); 141 while (true) { 157 while (true) 158 { 142 159 // Read the first byte of input which gives us some or all of the length 143 160 // of the remaining reply. … … 149 166 // If the fourth bit is set, we need to remove anything left in the first byte 150 167 // and then read in yet another byte. 151 if ($Byte & 0x80) { 152 if (($Byte & 0xc0) == 0x80) { 168 if ($Byte & 0x80) 169 { 170 if (($Byte & 0xc0) == 0x80) 171 { 153 172 $Length = (($Byte & 63) << 8) + ord(fread($this->Socket, 1)); 154 } else { 155 if (($Byte & 0xe0) == 0xc0) { 173 } else 174 { 175 if (($Byte & 0xe0) == 0xc0) 176 { 156 177 $Length = (($Byte & 31) << 8) + ord(fread($this->Socket, 1)); 157 178 $Length = ($Length << 8) + ord(fread($this->Socket, 1)); 158 } else { 159 if (($Byte & 0xf0) == 0xe0) { 179 } else 180 { 181 if (($Byte & 0xf0) == 0xe0) 182 { 160 183 $Length = (($Byte & 15) << 8) + ord(fread($this->Socket, 1)); 161 184 $Length = ($Length << 8) + ord(fread($this->Socket, 1)); 162 185 $Length = ($Length << 8) + ord(fread($this->Socket, 1)); 163 } else { 186 } else 187 { 164 188 $Length = ord(fread($this->Socket, 1)); 165 189 $Length = ($Length << 8) + ord(fread($this->Socket, 1)); … … 169 193 } 170 194 } 171 } else { 195 } else 196 { 172 197 $Length = $Byte; 173 198 } 174 199 // If we have got more characters to read, read them in. 175 if ($Length > 0) { 200 if ($Length > 0) 201 { 176 202 $Line = ''; 177 203 $RetLen = 0; 178 while ($RetLen < $Length) { 204 while ($RetLen < $Length) 205 { 179 206 $ToRead = $Length - $RetLen; 180 207 $Line .= fread($this->Socket, $ToRead); … … 196 223 } 197 224 198 function Write( $Command, $Param2 = true)225 function Write(string $Command, bool $Param2 = true): bool 199 226 { 200 227 if ($Command) 201 228 { 202 229 $Data = explode("\n", $Command); 203 foreach ($Data as $Com) { 230 foreach ($Data as $Com) 231 { 204 232 $Com = trim($Com); 205 233 fwrite($this->Socket, $this->EncodeLength(strlen($Com)).$Com); 206 234 } 207 if (gettype($Param2) == 'integer') { 235 if (gettype($Param2) == 'integer') 236 { 208 237 fwrite($this->Socket, $this->EncodeLength(strlen('.tag='.$Param2)).'.tag='.$Param2.chr(0)); 209 238 } else if (gettype($Param2) == 'boolean') … … 214 243 } 215 244 216 function Comm( $Com, $Arr = array())245 function Comm(string $Com, array $Arr = array()): array 217 246 { 218 247 $Count = count($Arr); 219 248 $this->write($Com, !$Arr); 220 249 $i = 0; 221 foreach ($Arr as $k => $v) { 222 switch ($k[0]) { 250 foreach ($Arr as $k => $v) 251 { 252 switch ($k[0]) 253 { 223 254 case "?": 224 255 $el = "$k=$v"; -
trunk/Modules/NetworkShare/NetworkShare.php
r738 r887 7 7 class ModuleNetworkShare extends AppModule 8 8 { 9 function __construct( $System)9 function __construct(System $System) 10 10 { 11 11 parent::__construct($System); … … 18 18 } 19 19 20 function DoInstall() 20 function DoInstall(): void 21 21 { 22 22 } 23 23 24 function DoUnInstall() 24 function DoUnInstall(): void 25 25 { 26 26 } 27 27 28 function DoStart() 28 function DoStart(): void 29 29 { 30 $this->System->RegisterPage( 'share', 'SharePage');30 $this->System->RegisterPage(['share'], 'SharePage'); 31 31 } 32 32 } -
trunk/Modules/NetworkShare/SharePage.php
r874 r887 3 3 class SharePage extends Page 4 4 { 5 var $FullTitle = 'Prohledávání sdílených souborů';6 var $ShortTitle = 'Sdílené soubory';7 var $ParentClass = 'PagePortal';8 5 var $Dependencies = array('Log'); 9 6 var $MaxNesting = 20; // Maximální vnoření … … 20 17 ); 21 18 19 function __construct(System $System) 20 { 21 parent::__construct($System); 22 $this->FullTitle = 'Prohledávání sdílených souborů'; 23 $this->ShortTitle = 'Sdílené soubory'; 24 $this->ParentClass = 'PagePortal'; 25 } 26 22 27 function ShowTime() 23 28 { … … 66 71 } 67 72 68 function Show() 69 { 70 if (! $this->System->User->CheckPermission('NetworkShare', 'Display')) return 'Nemáte oprávnění';73 function Show(): string 74 { 75 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('NetworkShare', 'Display')) return 'Nemáte oprávnění'; 71 76 72 77 // If not only online checkbox checked … … 102 107 // Log search 103 108 if (array_key_exists('keyword', $_POST) or array_key_exists('keyword', $_GET)) 104 $this->System->ModuleManager->Modules['Log']->NewRecord('Share', 'Hledaný výraz', $_SESSION['keyword']);109 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Share', 'Hledaný výraz', $_SESSION['keyword']); 105 110 106 111 // Zobrazení formuláře -
trunk/Modules/NetworkTopology/NetworkTopology.php
r874 r887 3 3 class PageNetworkTopology extends Page 4 4 { 5 var $FullTitle = 'Grafické zobrazení topologie sítě';6 var $ShortTitle = 'Topologie sítě';7 var $ParentClass = 'PagePortal';8 5 var $TopHostName = 'NIX-ROUTER'; 9 6 10 function Show() 7 function __construct(System $System) 8 { 9 parent::__construct($System); 10 $this->FullTitle = 'Grafické zobrazení topologie sítě'; 11 $this->ShortTitle = 'Topologie sítě'; 12 $this->ParentClass = 'PagePortal'; 13 } 14 15 function Show(): string 11 16 { 12 17 if (count($this->System->PathItems) > 1) … … 132 137 class ModuleNetworkTopology extends AppModule 133 138 { 134 function __construct( $System)139 function __construct(System $System) 135 140 { 136 141 parent::__construct($System); … … 143 148 } 144 149 145 function DoInstall() 150 function DoInstall(): void 146 151 { 147 152 } 148 153 149 function DoUnInstall() 154 function DoUnInstall(): void 150 155 { 151 156 } 152 157 153 function DoStart() 158 function DoStart(): void 154 159 { 155 $this->System->RegisterPage( 'topologie', 'PageNetworkTopology');160 $this->System->RegisterPage(['topologie'], 'PageNetworkTopology'); 156 161 } 157 162 } -
trunk/Modules/News/Import/Vismo.php
r878 r887 3 3 class NewsSourceVismo extends NewsSource 4 4 { 5 function Import() 5 function Import(): string 6 6 { 7 7 $Output = parent::Import(); -
trunk/Modules/News/ImportKinoVatra.php
r873 r887 1 1 <?php 2 2 3 include_once(dirname(__FILE__).'/../../Application/ System.php');4 $System = new System();3 include_once(dirname(__FILE__).'/../../Application/Core.php'); 4 $System = new Core(); 5 5 $System->ShowPage = false; 6 6 $System->Run(); -
trunk/Modules/News/ImportTvBeskyd.php
r873 r887 1 1 <?php 2 2 3 include_once(dirname(__FILE__).'/../../Application/ System.php');3 include_once(dirname(__FILE__).'/../../Application/Core.php'); 4 4 $System = new Core(); 5 5 $System->ShowPage = false; -
trunk/Modules/News/News.php
r878 r887 13 13 class ModuleNews extends AppModule 14 14 { 15 var$NewsCountPerCategory = 3;16 var$UploadedFilesFolder = 'files/news/';17 18 function __construct( $System)15 public int $NewsCountPerCategory = 3; 16 public string $UploadedFilesFolder = 'files/news/'; 17 18 function __construct(System $System) 19 19 { 20 20 parent::__construct($System); … … 28 28 } 29 29 30 function DoInstall() 31 { 32 } 33 34 function DoUnInstall() 35 { 36 } 37 38 function DoStart() 39 { 40 $this->System->RegisterPage('aktuality', 'PageNews'); 41 $this->System->RegisterPage(array('aktuality', 'aktualizace'), 'PageNewsUpdate'); 30 function DoInstall(): void 31 { 32 } 33 34 function DoUnInstall(): void 35 { 36 } 37 38 function DoStart(): void 39 { 40 $this->System->RegisterPage(['aktuality'], 'PageNews'); 41 $this->System->RegisterPage(['aktuality', 'subscription'], 'PageNewsSubscription'); 42 $this->System->RegisterPage(['aktuality', 'rss'], 'PageNewsRss'); 43 $this->System->RegisterPage(['aktuality', 'aktualizace'], 'PageNewsUpdate'); 42 44 $this->System->FormManager->RegisterClass('News', array( 43 45 'Title' => 'Aktualita', … … 86 88 if ($this->System->ModuleManager->ModulePresent('Search')) 87 89 { 88 $this->System->ModuleManager->Modules['Search']->RegisterSearch('Novinky', 'News', array('Title', 'Content'));89 } 90 } 91 92 function ShowNews( $Category, $ItemCount, $DaysAgo)90 ModuleSearch::Cast($this->System->GetModule('Search'))->RegisterSearch('Novinky', 'News', array('Title', 'Content')); 91 } 92 } 93 94 function ShowNews(string $Category, int $ItemCount, int $DaysAgo): string 93 95 { 94 96 $ItemCount = abs($ItemCount); … … 98 100 $Output = '<div class="NewsPanel"><div class="Title">'.$Row['Caption']; 99 101 $Output .= '<div class="Action"><a href="aktuality/?category='.$Category.'">Zobrazit</a>'; 100 if ( $this->System->User->CheckPermission('News', 'Insert', 'Group', $Category))102 if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('News', 'Insert', 'Group', $Category)) 101 103 $Output .= ' <a href="aktuality/?action=add&category='.$Category.'">Přidat</a>'; 102 104 $Output .= '</div></div><div class="Content">'; … … 139 141 } 140 142 141 function LoadSettingsFromCookies() 143 function LoadSettingsFromCookies(): void 142 144 { 143 145 // Initialize default news setting … … 163 165 } 164 166 165 function Show() 167 function Show(): string 166 168 { 167 169 $Output = ''; … … 197 199 } 198 200 199 function ShowCustomizeMenu() 201 function ShowCustomizeMenu(): string 200 202 { 201 203 $Output = '<form action="?Action=CustomizeNewsSave" method="post">'; … … 220 222 } 221 223 222 function CustomizeSave() 224 function CustomizeSave(): void 223 225 { 224 226 $Checkbox = array('' => 0, 'on' => 1); … … 245 247 } 246 248 247 function ModifyContent( $Content)249 function ModifyContent(string $Content): string 248 250 { 249 251 $Result = ''; … … 254 256 { 255 257 $I = strpos($Content, 'http://'); 256 if (($I > 0) and ($Content {$I - 1}!= '"'))258 if (($I > 0) and ($Content[$I - 1] != '"')) 257 259 { 258 260 $Result .= substr($Content, 0, $I); … … 272 274 return $Result; 273 275 } 276 277 static function Cast(AppModule $AppModule): ModuleNews 278 { 279 if ($AppModule instanceof ModuleNews) 280 { 281 return $AppModule; 282 } 283 throw new Exception('Expected ModuleNews type but got '.gettype($AppModule)); 284 } 274 285 } -
trunk/Modules/News/NewsPage.php
r878 r887 3 3 class PageNews extends Page 4 4 { 5 var $FullTitle = 'Aktualní informace'; 6 var $ShortTitle = 'Aktuality'; 7 var $ParentClass = 'PagePortal'; 8 var $UploadedFilesFolder; 9 10 function Show() 11 { 12 $this->UploadedFilesFolder = $this->System->ModuleManager->Modules['News']->UploadedFilesFolder; 13 if (count($this->System->PathItems) > 1) 14 { 15 if ($this->System->PathItems[1] == 'subscription') return $this->ShowSubscription(); 16 else if ($this->System->PathItems[1] == 'rss') return $this->ShowRSS(); 17 else return PAGE_NOT_FOUND; 18 } else return $this->ShowMain(); 19 } 20 21 function ShowView() 22 { 23 $Output = ''; 24 if (!$this->System->User->CheckPermission('News', 'Display', 'Item')) $Output .= 'Nemáte oprávnění'; 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Aktualní informace'; 9 $this->ShortTitle = 'Aktuality'; 10 $this->ParentClass = 'PagePortal'; 11 } 12 13 function ShowView(): string 14 { 15 $Output = ''; 16 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('News', 'Display', 'Item')) $Output .= 'Nemáte oprávnění'; 25 17 else 26 18 { … … 35 27 else $Author = $Row['Name']; 36 28 $Output .= '<div class="Panel"><div class="Title">'.$Row['Title'].' ('.HumanDate($Row['Date']).', '.$Author.')'; 37 if (($this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))) 29 if ((ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'] == $Row['User']) and 30 (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))) 38 31 { 39 32 $Output .= '<div class="Action">'; … … 42 35 $Output .= '</div>'; 43 36 } 44 $Output .= '</div><div class="Content">'. $this->System->ModuleManager->Modules['News']->ModifyContent($Row['Content']).'<br />';37 $Output .= '</div><div class="Content">'.ModuleNews::Cast($this->System->GetModule('News'))->ModifyContent($Row['Content']).'<br />'; 45 38 if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>'; 46 39 if ($Row['Enclosure'] != '') … … 50 43 foreach ($Enclosures as $Enclosure) 51 44 { 52 if (file_exists( $this->UploadedFilesFolder.$Enclosure))53 $Output .= ' <a href="'.$this->System->Link('/'. $this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';45 if (file_exists(ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.$Enclosure)) 46 $Output .= ' <a href="'.$this->System->Link('/'.ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>'; 54 47 } 55 48 } … … 60 53 } 61 54 62 function ShowAdd() 63 { 64 $Output = ''; 65 $Category = $this->GetCategory(); 66 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 55 function ShowAdd(): string 56 { 57 $User = &ModuleUser::Cast($this->System->GetModule('User'))->User; 58 $Output = ''; 59 $Category = $this->GetCategory(); 60 if ($User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 67 61 { 68 62 $this->System->PageHeaders[] = array($this, 'GetPageHeader'); … … 75 69 while ($DbRow = $DbResult->fetch_array()) 76 70 { 77 if ($ this->System->User->CheckPermission('News', 'Insert', 'Group', $DbRow['Id']))71 if ($User->CheckPermission('News', 'Insert', 'Group', $DbRow['Id'])) 78 72 { 79 73 if ($DbRow['Id'] == $Category['Id']) $Selected = ' selected="1"'; … … 96 90 } 97 91 98 function ShowAdd2() 99 { 92 function ShowAdd2(): string 93 { 94 $User = &ModuleUser::Cast($this->System->GetModule('User'))->User; 100 95 $Output = ''; 101 96 $RemoteAddr = GetRemoteAddress(); 102 97 $Category = $this->GetCategory(); 103 if ($ this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))98 if ($User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 104 99 { 105 100 // Process uploaded file … … 110 105 if (array_key_exists($EnclosureName, $_FILES) and ($_FILES[$EnclosureName]['name'] != '')) 111 106 { 112 $UploadedFilePath = $this->UploadedFilesFolder.basename($_FILES[$EnclosureName]['name']);107 $UploadedFilePath = ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.basename($_FILES[$EnclosureName]['name']); 113 108 if (move_uploaded_file($_FILES[$EnclosureName]['tmp_name'], $UploadedFilePath)) 114 109 { … … 124 119 $this->Database->insert('News', array('Category' => $Category['Id'], 'Title' => $_POST['title'], 125 120 'Content' => $_POST['content'], 'Date' => 'NOW()', 'IP' => $RemoteAddr, 126 'Enclosure' => $Enclosures, 'Author' => $ this->System->User->User['Name'],127 'User' => $ this->System->User->User['Id'], 'Link' => $_POST['link']));121 'Enclosure' => $Enclosures, 'Author' => $User->User['Name'], 122 'User' => $User->User['Id'], 'Link' => $_POST['link'])); 128 123 $Output .= 'Aktualita přidána!<br />Pokud budete chtít vaši aktualitu smazat, klikněte na odkaz Smazat v seznamu všech aktualit v kategorii.<br /><br />'; 129 124 $Output .= '<a href="?category='.$_POST['category'].'">Zpět na seznam aktualit</a>'; 130 $this->System->ModuleManager->Modules['Log']->NewRecord('News', 'Aktualita přidána', $this->Database->insert_id);125 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('News', 'Aktualita přidána', $this->Database->insert_id); 131 126 } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!'; 132 127 return $Output; 133 128 } 134 129 135 function GetPageHeader() 130 function GetPageHeader(): string 136 131 { 137 132 return '<script src="'.$this->System->Link('/Packages/TinyMCE/tinymce.min.js').'"></script>'. … … 152 147 } 153 148 154 function ShowEdit() 155 { 156 $Output = ''; 157 $Category = $this->GetCategory(); 158 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 149 function ShowEdit(): string 150 { 151 $User = &ModuleUser::Cast($this->System->GetModule('User'))->User; 152 $Output = ''; 153 $Category = $this->GetCategory(); 154 if ($User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 159 155 { 160 156 $DbResult = $this->Database->query('SELECT * FROM `News` WHERE `Id`='.$_GET['id']); 161 157 $Row = $DbResult->fetch_array(); 162 if (($ this->System->User->User['Id'] == $Row['User']))158 if (($User->User['Id'] == $Row['User'])) 163 159 { 164 160 $this->System->PageHeaders[] = array($this, 'GetPageHeader'); … … 177 173 } 178 174 179 function ShowUpdate() 180 { 175 function ShowUpdate(): string 176 { 177 $User = &ModuleUser::Cast($this->System->GetModule('User'))->User; 181 178 $Output = ''; 182 179 $RemoteAddr = GetRemoteAddress(); 183 180 $Category = $this->GetCategory(); 184 if ($ this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))181 if ($User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 185 182 { 186 183 $_POST['id'] = $_POST['id'] * 1; … … 189 186 { 190 187 $Row = $DbResult->fetch_array(); 191 if ($ this->System->User->User['Id'] == $Row['User'])188 if ($User->User['Id'] == $Row['User']) 192 189 { 193 190 $this->Database->update('News', 'Id='.$_POST['id'], array('Title' => $_POST['title'], … … 201 198 } 202 199 203 function ShowDelete() 204 { 205 $Output = ''; 206 $Category = $this->GetCategory(); 207 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 200 function ShowDelete(): string 201 { 202 $User = &ModuleUser::Cast($this->System->GetModule('User'))->User; 203 $Output = ''; 204 $Category = $this->GetCategory(); 205 if ($User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 208 206 { 209 207 $DbResult = $this->Database->query('SELECT * FROM `News` WHERE `Id`='.$_GET['id']); 210 208 $Row = $DbResult->fetch_array(); 211 if ($ this->System->User->User['Id'] == $Row['User'])209 if ($User->User['Id'] == $Row['User']) 212 210 { 213 211 // TODO: Make upload using general File class … … 218 216 foreach ($Enclosures as $Enclosure) 219 217 { 220 if (file_exists( $this->UploadedFilesFolder.$Enclosure)) unlink($this->UploadedFilesFolder.$Enclosure);218 if (file_exists(ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.$Enclosure)) unlink(ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.$Enclosure); 221 219 } 222 220 } … … 228 226 } 229 227 230 function ShowList() 231 { 232 $Output = ''; 233 $Category = $this->GetCategory(); 234 if ($this->System->User->CheckPermission('News', 'Display', 'Group', $Category['Id'])) 228 function ShowList(): string 229 { 230 $User = &ModuleUser::Cast($this->System->GetModule('User'))->User; 231 $Output = ''; 232 $Category = $this->GetCategory(); 233 if ($User->CheckPermission('News', 'Display', 'Group', $Category['Id'])) 235 234 { 236 235 $PerPage = 20; … … 250 249 else $Author = $Row['Name']; 251 250 $Output .= '<div class="Panel"><div class="Title"><a href="?action=view&id='.$Row['Id'].'">'.$Row['Title'].'</a> ('.HumanDate($Row['Date']).', '.$Author.')'; 252 if (($ this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])))251 if (($User->User['Id'] == $Row['User']) and ($User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))) 253 252 { 254 253 $Output .= '<div class="Action">'; … … 257 256 $Output .= '</div>'; 258 257 } 259 $Output .= '</div><div class="Content">'. $this->System->ModuleManager->Modules['News']->ModifyContent($Row['Content']).'<br />';258 $Output .= '</div><div class="Content">'.ModuleNews::Cast($this->System->GetModule('News'))->ModifyContent($Row['Content']).'<br />'; 260 259 if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>'; 261 260 if ($Row['Enclosure'] != '') … … 265 264 foreach ($Enclosures as $Enclosure) 266 265 { 267 if (file_exists( $this->UploadedFilesFolder.$Enclosure))268 $Output .= ' <a href="'.$this->System->Link('/'. $this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';266 if (file_exists(ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.$Enclosure)) 267 $Output .= ' <a href="'.$this->System->Link('/'.ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>'; 269 268 } 270 269 } … … 277 276 } 278 277 279 function GetCategory() 278 function GetCategory(): array 280 279 { 281 280 $Category = array('Id' => 1); // Default category … … 292 291 } 293 292 294 function Show Main()293 function Show(): string 295 294 { 296 295 $Output = ''; … … 306 305 return $Output; 307 306 } 308 309 function ShowSubscription() 307 } 308 309 class PageNewsUpdate extends Page 310 { 311 function __construct(System $System) 312 { 313 parent::__construct($System); 314 $this->FullTitle = 'Aktualizace aktualit'; 315 $this->ShortTitle = 'Aktualizace aktualit'; 316 $this->ParentClass = 'PageNews'; 317 } 318 319 function Show(): string 320 { 321 $NewsSources = new NewsSources(); 322 $NewsSources->Database = $this->Database; 323 if (array_key_exists('i', $_GET)) $Output = $NewsSources->Parse($_GET['i']); 324 else $Output = $NewsSources->Parse(); 325 return $Output; 326 } 327 } 328 329 class PageNewsSubscription extends Page 330 { 331 function __construct(System $System) 332 { 333 parent::__construct($System); 334 $this->FullTitle = 'Odběry aktualit'; 335 $this->ShortTitle = 'Odběry aktualit'; 336 $this->ParentClass = 'PageNews'; 337 } 338 339 function Show(): string 310 340 { 311 341 if (array_key_exists('build', $_GET)) … … 333 363 return $Output; 334 364 } 335 336 function ShowRSS() 365 } 366 367 class PageNewsRss extends Page 368 { 369 function __construct(System $System) 370 { 371 parent::__construct($System); 372 $this->FullTitle = 'RSS kanál aktualit'; 373 $this->ShortTitle = 'Aktuality RSS'; 374 $this->ParentClass = 'PageNews'; 375 } 376 377 function Show(): string 337 378 { 338 379 $this->ClearPage = true; … … 409 450 foreach ($Enclosures as $Enclosure) 410 451 { 411 if (file_exists( $this->UploadedFilesFolder.$Enclosure))412 $EnclosuresText .= ' <a href="'.$this->System->Link('/aktuality/'. $this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';452 if (file_exists(ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.$Enclosure)) 453 $EnclosuresText .= ' <a href="'.$this->System->Link('/aktuality/'.ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>'; 413 454 } 414 455 } … … 432 473 } 433 474 } 434 435 class PageNewsUpdate extends Page436 {437 function __construct($System)438 {439 parent::__construct($System);440 $this->FullTitle = 'Aktualizace aktualit';441 $this->ShortTitle = 'Aktualizace aktualit';442 $this->ParentClass = 'PageNews';443 }444 445 function Show()446 {447 $NewsSources = new NewsSources();448 $NewsSources->Database = $this->Database;449 if (array_key_exists('i', $_GET)) $Output = $NewsSources->Parse($_GET['i']);450 else $Output = $NewsSources->Parse();451 return $Output;452 }453 }454 -
trunk/Modules/News/NewsSource.php
r878 r887 1 1 <?php 2 2 3 function GetTextBetween( &$Text, $Start, $End)3 function GetTextBetween(string &$Text, string $Start, string $End): string 4 4 { 5 5 $Result = ''; … … 34 34 } 35 35 36 function HumanDateTimeToTime( $DateTime)36 function HumanDateTimeToTime(string $DateTime): int 37 37 { 38 38 if ($DateTime == '') return NULL; … … 49 49 } 50 50 51 function HumanDateToTime( $Date)51 function HumanDateToTime(string $Date): int 52 52 { 53 53 if ($Date == '') return NULL; … … 55 55 } 56 56 57 function GetUrlBase( $Url)57 function GetUrlBase(string $Url): string 58 58 { 59 59 $Result = parse_url($Url); … … 63 63 class NewsSources 64 64 { 65 public $Database;65 public Database $Database; 66 66 67 67 function Parse($Id = null) … … 94 94 class NewsSource 95 95 { 96 public $Name;97 public $URL;96 public string $Name; 97 public string $URL; 98 98 public $Method; 99 public $Id;100 public $Database;101 public $NewsItems;102 public $AddedCount;99 public int $Id; 100 public Database $Database; 101 public array $NewsItems; 102 public int $AddedCount; 103 103 public $Category; 104 104 … … 109 109 } 110 110 111 function Import() 111 function Import(): string 112 112 { 113 113 return ''; 114 114 } 115 115 116 function DoImport() 116 function DoImport(): string 117 117 { 118 118 $this->NewsItems = array(); … … 133 133 class NewsItem 134 134 { 135 var$Database;136 var$Title = '';137 var$Content = '';138 var $Date = '';139 var$Link = '';140 var$Category = '';141 var$Author = '';142 var$IP = '';143 var$Enclosure = '';135 public Database $Database; 136 public string $Title = ''; 137 public string $Content = ''; 138 public int $Date = 0; 139 public string $Link = ''; 140 public string $Category = ''; 141 public string $Author = ''; 142 public string $IP = ''; 143 public string $Enclosure = ''; 144 144 145 function AddIfNotExist() 145 function AddIfNotExist(): int 146 146 { 147 147 $Where = '(`Title` = "'.$this->Database->real_escape_string($this->Title).'") AND '. -
trunk/Modules/Notify/Notify.php
r874 r887 5 5 class ModuleNotify extends AppModule 6 6 { 7 var$Checks;8 9 function __construct( $System)7 public array $Checks; 8 9 function __construct(System $System) 10 10 { 11 11 parent::__construct($System); … … 19 19 } 20 20 21 function DoStart() 21 function DoStart(): void 22 22 { 23 23 $this->System->FormManager->RegisterClass('NotifyUser', array( … … 38 38 ), 39 39 )); 40 $this->System->RegisterCommandLine('notify', array($this, 'RunCheck'));41 $this->System->ModuleManager->Modules['RSS']->RegisterRSS(array('Title' => 'Notify log',42 'Channel' => 'notifylog', 'Callback' => array( 'ModuleNotify', 'ShowLogRSS'),40 $this->System->RegisterCommandLine('notify', 'Perform notifications processing.', array($this, 'RunCheck')); 41 ModuleRSS::Cast($this->System->GetModule('RSS'))->RegisterRSS(array('Title' => 'Notify log', 42 'Channel' => 'notifylog', 'Callback' => array($this, 'ShowLogRSS'), 43 43 'Permission' => array('Module' => 'Notify', 'Operation' => 'RSS'))); 44 44 } 45 45 46 function RegisterCheck( $Name, $Callback)46 function RegisterCheck(string $Name, callable $Callback): void 47 47 { 48 48 if (array_key_exists($Name, $this->Checks)) … … 51 51 } 52 52 53 function UnregisterCheck( $Name)53 function UnregisterCheck(string $Name): void 54 54 { 55 55 if (!array_key_exists($Name, $this->Checks)) … … 58 58 } 59 59 60 function Check() 60 function Check(): string 61 61 { 62 62 $Output = ''; … … 123 123 } 124 124 125 function RunCheck( $Parameters)125 function RunCheck(array $Parameters): void 126 126 { 127 127 RepeatFunction(30, array($this, 'Check')); 128 128 } 129 129 130 function DoInstall() 130 function DoInstall(): void 131 131 { 132 132 $this->Database->query('CREATE TABLE IF NOT EXISTS `NotifyCategory` ( … … 160 160 } 161 161 162 function DoUninstall() 162 function DoUninstall(): void 163 163 { 164 164 $this->Database->query('DROP TABLE `NotifyUser`'); … … 166 166 } 167 167 168 function ShowLogRSS() 168 function ShowLogRSS(): string 169 169 { 170 170 $this->ClearPage = true; … … 197 197 return $RSS->Generate(); 198 198 } 199 200 static function Cast(AppModule $AppModule): ModuleNotify 201 { 202 if ($AppModule instanceof ModuleNotify) 203 { 204 return $AppModule; 205 } 206 throw new Exception('Expected ModuleNotify type but got '.gettype($AppModule)); 207 } 199 208 } -
trunk/Modules/OpeningHours/OpeningHours.php
r874 r887 5 5 class PageSubjectOpenTime extends Page 6 6 { 7 var $FullTitle = 'Otvírací doby místních subjektů'; 8 var $ShortTitle = 'Otvírací doby'; 9 var $DaysOfWeek = array('Pondělí', 'Úterý', 'Středa', 'Čtvrtek', 'Pátek', 'Sobota', 'Neděle'); 10 var $EventType = array('Žádný', 'Otevřeno', 'Zavřeno'); 11 var $ParentClass = 'PagePortal'; 12 13 function ToHumanTime($Time) 7 public array $DaysOfWeek = array('Pondělí', 'Úterý', 'Středa', 'Čtvrtek', 'Pátek', 'Sobota', 'Neděle'); 8 public array $EventType = array('Žádný', 'Otevřeno', 'Zavřeno'); 9 10 function __construct(System $System) 11 { 12 parent::__construct($System); 13 $this->FullTitle = 'Otvírací doby místních subjektů'; 14 $this->ShortTitle = 'Otvírací doby'; 15 $this->ParentClass = 'PagePortal'; 16 } 17 18 function ToHumanTime(float $Time): string 14 19 { 15 20 $Hours = floor($Time / 60); … … 20 25 } 21 26 22 function ToHumanTime2( $Time)27 function ToHumanTime2(float $Time): string 23 28 { 24 29 $Days = floor($Time / 24 / 60); … … 34 39 } 35 40 36 function EditSubject( $Id)37 { 38 if ( $this->System->User->CheckPermission('OpeningHours', 'Edit'))41 function EditSubject(int $Id): string 42 { 43 if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('OpeningHours', 'Edit')) 39 44 { 40 45 $Output = '<div class="Centred">'; … … 73 78 } 74 79 75 function SaveSubject($Id) 76 { 77 global $Config; 78 80 function SaveSubject(int $Id): string 81 { 79 82 $Output = ''; 80 if ( $this->System->User->CheckPermission('OpeningHours', 'Edit'))83 if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('OpeningHours', 'Edit')) 81 84 { 82 85 $this->Database->delete('SubjectOpenTimeDay', 'Subject='.$Id); … … 100 103 $Output .= 'Uloženo'; 101 104 102 $File = new File($this-> Database);105 $File = new File($this->System); 103 106 104 107 // Delete old file … … 114 117 } 115 118 116 function ShowAll() 119 function ShowAll(): string 117 120 { 118 121 $Output = '<div class="Centred">'; … … 138 141 } 139 142 } 140 //print_r($Events);141 143 142 144 // Calculate time to next event … … 190 192 if ($Subject['Photo'] != 0) $Output .= '<a href="file?id='.$Subject['Photo'].'">Fotka</a> '; 191 193 192 if ( $this->System->User->CheckPermission('SubjectOpenTime', 'Edit'))194 if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('SubjectOpenTime', 'Edit')) 193 195 $Output .= '<a href="edit?Subject='.$Subject['Id'].'">Editovat</a><br />'; 194 196 $Output .= '<br />'; … … 198 200 } 199 201 200 function Show() 202 function Show(): string 201 203 { 202 204 if (count($this->System->PathItems) > 1) … … 215 217 class ModuleOpeningHours extends AppModule 216 218 { 217 function __construct( $System)219 function __construct(System $System) 218 220 { 219 221 parent::__construct($System); … … 226 228 } 227 229 228 function DoStart() 229 { 230 $this->System->Pages['otviraci-doby'] = 'PageSubjectOpenTime'; 231 } 232 233 function DoInstall() 234 { 235 } 236 237 function DoUnInstall() 230 function DoStart(): void 231 { 232 $this->System->RegisterPage(['otviraci-doby'], 'PageSubjectOpenTime'); 233 } 234 235 function DoStop(): void 236 { 237 $this->System->UnregisterPage(['otviraci-doby']); 238 } 239 240 function DoInstall(): void 241 { 242 } 243 244 function DoUnInstall(): void 238 245 { 239 246 } -
trunk/Modules/Portal/Portal.php
r874 r887 5 5 class ModulePortal extends AppModule 6 6 { 7 function __construct( $System)7 function __construct(System $System) 8 8 { 9 9 parent::__construct($System); … … 16 16 } 17 17 18 function DoInstall() 19 { 20 } 21 22 function DoUninstall() 23 { 24 } 25 26 function DoStart() 27 { 28 $this->System->RegisterPage( '', 'PagePortal');18 function DoInstall(): void 19 { 20 } 21 22 function DoUninstall(): void 23 { 24 } 25 26 function DoStart(): void 27 { 28 $this->System->RegisterPage([''], 'PagePortal'); 29 29 $this->System->FormManager->RegisterClass('MemberOptions', array( 30 30 'Title' => 'Nastavení zákazníka', … … 42 42 ), 43 43 )); 44 $this->System->ModuleManager->Modules['User']->UserPanel[] = array('PagePortal', 'UserPanel');45 } 46 47 function DoStop() 44 ModuleUser::Cast($this->System->GetModule('User'))->UserPanel[] = array('PagePortal', 'UserPanel'); 45 } 46 47 function DoStop(): void 48 48 { 49 49 } … … 52 52 class PagePortal extends Page 53 53 { 54 var $FullTitle = 'Zděchovský rozcestník'; 55 var $ShortTitle = 'Rozcestník'; 56 57 function ShowActions($ActionGroup) 54 function __construct(System $System) 55 { 56 parent::__construct($System); 57 $this->FullTitle = 'Zděchovský rozcestník'; 58 $this->ShortTitle = 'Rozcestník'; 59 } 60 61 function ShowActions(array $ActionGroup): string 58 62 { 59 63 $Output = ''; … … 67 71 } 68 72 69 function InfoBar() 73 function InfoBar(): string 70 74 { 71 75 $Output2 = ''; … … 98 102 //$Output .= 'Server běží: '.$this->GetServerUptime().' '; 99 103 100 if ( $this->System->User->CheckPermission('Finance', 'DisplaySubjectState'))101 { 102 $DbResult = $this->Database->select('MemberPayment', 'Cash', 'Member=(SELECT Customer FROM UserCustomerRel WHERE Id='. $this->System->User->User['Id'].')');104 if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'DisplaySubjectState')) 105 { 106 $DbResult = $this->Database->select('MemberPayment', 'Cash', 'Member=(SELECT Customer FROM UserCustomerRel WHERE Id='.ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'].')'); 103 107 if ($DbResult->num_rows > 0) 104 108 { … … 112 116 } 113 117 114 function UserPanel() 115 { 118 function UserPanel(): string 119 { 120 $User = &ModuleUser::Cast($this->System->GetModule('User'))->User; 116 121 $Output = '<a href="'.$this->System->Link('/user/?Action=UserOptions').'">Profil</a><br />'; 117 if ($ this->System->User->CheckPermission('Finance', 'MemberOptions'))122 if ($User->CheckPermission('Finance', 'MemberOptions')) 118 123 $Output .= '<a href="'.$this->System->Link('/?Action=MemberOptions').'">Fakturační adresa</a><br />'; 119 if ($ this->System->User->CheckPermission('Finance', 'DisplaySubjectState'))124 if ($User->CheckPermission('Finance', 'DisplaySubjectState')) 120 125 $Output .= '<a href="'.$this->System->Link('/finance/platby/').'">Finance</a><br />'; 121 if ($ this->System->User->CheckPermission('Network', 'RegistredHostList'))126 if ($User->CheckPermission('Network', 'RegistredHostList')) 122 127 $Output .= '<a href="'.$this->System->Link('/network/user-hosts/').'">Počítače</a><br />'; 123 if ($ this->System->User->CheckPermission('News', 'Insert'))128 if ($User->CheckPermission('News', 'Insert')) 124 129 $Output .= '<a href="'.$this->System->Link('/aktuality/?action=add').'">Vložení aktuality</a><br />'; 125 if ($ this->System->User->CheckPermission('EatingPlace', 'Edit'))130 if ($User->CheckPermission('EatingPlace', 'Edit')) 126 131 $Output .= '<a href="'.$this->System->Link('/jidelna/menuedit.php').'">Úprava jídelníčků</a><br />'; 127 if ($ this->System->User->CheckPermission('Finance', 'Manage'))132 if ($User->CheckPermission('Finance', 'Manage')) 128 133 $Output .= '<a href="'.$this->System->Link('/finance/sprava/').'">Správa financí</a><br />'; 129 if ($ this->System->User->CheckPermission('IS', 'Manage'))134 if ($User->CheckPermission('IS', 'Manage')) 130 135 $Output .= '<a href="'.$this->System->Link('/is/').'">Správa dat</a><br />'; 131 136 return $Output; 132 137 } 133 138 134 function WebcamPanel() 135 { 136 $Output = $this->System->ModuleManager->Modules['WebCam']->ShowImage();137 return $Output; 138 } 139 140 function MeteoPanel() 139 function WebcamPanel(): string 140 { 141 $Output = ModuleWebCam::Cast($this->System->GetModule('WebCam'))->ShowImage(); 142 return $Output; 143 } 144 145 function MeteoPanel(): string 141 146 { 142 147 $Output = '<a href="https://stat.zdechov.net/meteo/?Measure=28" title="Klikněte pro detailní informace a předpověď"><img src="https://www.zdechov.net/meteo/koliba.png" border="0" alt="Počasí - Meteostanice Zděchov" width="150" height="150" /></a>'; … … 144 149 } 145 150 146 function OnlineHostList() 151 function OnlineHostList(): string 147 152 { 148 153 $Output = '<span style="font-size: smaller;">'; … … 158 163 } 159 164 160 function ShowBadPayerList() 161 { 162 $Output .= '<div class="PanelTitle">Dlužníci:</div><span style="font-size: smaller;">';163 $DbResult = $ Database->select('Subject', 'Name', 'Money < 0 ORDER BY Money');165 function ShowBadPayerList(): string 166 { 167 $Output = '<div class="PanelTitle">Dlužníci:</div><span style="font-size: smaller;">'; 168 $DbResult = $this->Database->select('Subject', 'Name', 'Money < 0 ORDER BY Money'); 164 169 while ($Row = $DbResult->fetch_array()) 165 170 { … … 170 175 } 171 176 172 function Panel( $Title, $Content, $Menu = array())177 function Panel(string $Title, string $Content, array $Menu = array()): string 173 178 { 174 179 if (count($Menu) > 0) 180 { 175 181 foreach ($Menu as $Item) 182 { 176 183 $Title .= '<div class="Action">'.$Item.'</div>'; 184 } 185 } 177 186 return '<div class="Panel"><div class="Title">'.$Title.'</div><div class="Content">'.$Content.'</div></div>'; 178 187 } 179 188 180 function Show() 189 function Show(): string 181 190 { 182 191 $Output = ''; … … 186 195 if ($Action == 'CustomizeNewsSave') 187 196 { 188 $Output .= $this->System->ModuleManager->Modules['News']->CustomizeSave();197 $Output .= ModuleNews::Cast($this->System->GetModule('News'))->CustomizeSave(); 189 198 } else 190 199 if ($Action == 'MemberOptions') 191 200 { 192 201 $DbResult = $this->Database->query('SELECT `Customer` FROM `UserCustomerRel` '. 193 'WHERE `User`='. $this->System->User->User['Id']);202 'WHERE `User`='.ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id']); 194 203 while ($CustomerUserRel = $DbResult->fetch_assoc()) 195 204 { … … 218 227 $Form->Values['FamilyMemberCount'] = 0; 219 228 220 $DbResult = $this->Database->update('Member', 'Id='.$this->System->User->User['Member'], 229 $User = &ModuleUser::Cast($this->System->GetModule('User'))->User; 230 $DbResult = $this->Database->update('Member', 'Id='.$User->User['Member'], 221 231 array('FamilyMemberCount' => $Form->Values['FamilyMemberCount'])); 222 $DbResult = $this->Database->query('SELECT Subject FROM Member WHERE Id='.$ this->System->User->User['Member']);232 $DbResult = $this->Database->query('SELECT Subject FROM Member WHERE Id='.$User->User['Member']); 223 233 $Member = $DbResult->fetch_assoc(); 224 234 $DbResult = $this->Database->update('Subject', 'Id='.$Member['Subject'], … … 228 238 'DIC' => $Form->Values['DIC'])); 229 239 $Output .= $this->SystemMessage('Nastavení', 'Nastavení zákazníka uloženo.'); 230 $this->System->ModuleManager->Modules['Log']->NewRecord('Member+Subject', 'Nastavení zákazníka/subjektu změněno',240 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Member+Subject', 'Nastavení zákazníka/subjektu změněno', 231 241 $Form->Values['Name']); 232 242 $DbResult = $this->Database->query('SELECT Member.Id, Member.FamilyMemberCount, '. 233 243 'Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, '. 234 244 'Subject.AddressCountry, Subject.IC, Subject.DIC FROM Member JOIN Subject '. 235 'ON Subject.Id = Member.Subject WHERE Member.Id='.$ this->System->User->User['Member']);245 'ON Subject.Id = Member.Subject WHERE Member.Id='.$User->User['Member']); 236 246 $DbRow = $DbResult->fetch_array(); 237 247 foreach ($Form->Definition['Items'] as $Index => $Item) … … 246 256 } 247 257 248 function ShowMain() 258 function ShowMain(): string 249 259 { 250 260 $Output = ''; … … 270 280 else if ($Panel['Module'] == 'UserOptions') 271 281 { 272 //if ( $this->System->User->User['Id'] != null) $Output .= $this->Panel('Přihlášený uživatel', $this->UserPanel());282 //if (ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'] != null) $Output .= $this->Panel('Přihlášený uživatel', $this->UserPanel()); 273 283 } else 274 284 if ($Panel['Module'] == 'Webcam') $Output .= $this->Panel('Kamery', $this->WebcamPanel()); 275 285 if ($Panel['Module'] == 'Meteo') $Output .= $this->Panel('Meteostanice', $this->MeteoPanel()); 276 286 else if ($Panel['Module'] == 'NewsGroupList') 277 $Output .= $this->Panel('Aktuality', $this->System->ModuleManager->Modules['News']->Show(), array('<a href="?Action=CustomizeNews">Upravit</a>'));287 $Output .= $this->Panel('Aktuality', ModuleNews::Cast($this->System->GetModule('News'))->Show(), array('<a href="?Action=CustomizeNews">Upravit</a>')); 278 288 } 279 289 $Output .= '</td>'; -
trunk/Modules/RSS/RSS.php
r874 r887 3 3 class ModuleRSS extends AppModule 4 4 { 5 var$RSSChannels;5 public array $RSSChannels; 6 6 7 function __construct( $System)7 function __construct(System $System) 8 8 { 9 9 parent::__construct($System); … … 17 17 } 18 18 19 function Start()19 function DoStart(): void 20 20 { 21 $this->System->RegisterPage( 'rss', 'PageRSS');21 $this->System->RegisterPage(['rss'], 'PageRSS'); 22 22 $this->System->RegisterPageHeader('RSS', array($this, 'ShowRSSHeader')); 23 23 } 24 24 25 function RegisterRSS( $Channel, $Pos = NULL, $Callback = NULL)25 function RegisterRSS(array $Channel, $Pos = NULL, $Callback = NULL): void 26 26 { 27 27 $this->RSSChannels[$Channel['Channel']] = $Channel; 28 28 29 29 if (is_null($Pos)) $this->RSSChannelsPos[] = $Channel['Channel']; 30 else { 30 else 31 { 31 32 array_splice($this->RSSChannelsPos, $Pos, 0, $Channel['Channel']); 32 33 } 33 34 } 34 35 35 function UnregisterRSS($ChannelName) 36 function UnregisterRSS($ChannelName): void 36 37 { 37 38 unset($this->RSSChannels[$ChannelName]); … … 39 40 } 40 41 41 function ShowRSSHeader() 42 function ShowRSSHeader(): string 42 43 { 43 44 $Output = ''; 44 45 foreach ($this->RSSChannels as $Channel) 45 46 { 46 //if ( $this->System->User->Licence($Channel['Permission']))47 //if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence($Channel['Permission'])) 47 48 $Output .= ' <link rel="alternate" title="'.$Channel['Title'].'" href="'. 48 49 $this->System->Link('/rss/?channel='.$Channel['Channel']).'" type="application/rss+xml" />'; … … 50 51 return $Output; 51 52 } 53 54 static function Cast(AppModule $AppModule): ModuleRSS 55 { 56 if ($AppModule instanceof ModuleRSS) 57 { 58 return $AppModule; 59 } 60 throw new Exception('Expected ModuleRSS type but got '.gettype($AppModule)); 61 } 52 62 } 53 63 54 64 class PageRSS extends Page 55 65 { 56 function Show() 66 function Show(): string 57 67 { 58 68 $this->ClearPage = true; … … 62 72 if (array_key_exists('token', $_GET)) $Token = $_GET['token']; 63 73 else $Token = ''; 64 if (array_key_exists($ChannelName, $this->System->ModuleManager->Modules['RSS']->RSSChannels))74 if (array_key_exists($ChannelName, ModuleRSS::Cast($this->System->GetModule('RSS'))->RSSChannels)) 65 75 { 66 $Channel = $this->System->ModuleManager->Modules['RSS']->RSSChannels[$ChannelName];67 if ( $this->System->User->CheckPermission($Channel['Permission']['Module'], $Channel['Permission']['Operation']) or68 $this->System->User->CheckToken($Channel['Permission']['Module'], $Channel['Permission']['Operation'], $Token))76 $Channel = ModuleRSS::Cast($this->System->GetModule('RSS'))->RSSChannels[$ChannelName]; 77 if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($Channel['Permission']['Module'], $Channel['Permission']['Operation']) or 78 ModuleUser::Cast($this->System->GetModule('User'))->User->CheckToken($Channel['Permission']['Module'], $Channel['Permission']['Operation'], $Token)) 69 79 { 70 80 if (is_string($Channel['Callback'][0])) -
trunk/Modules/Scheduler/Scheduler.php
r874 r887 3 3 class ModuleScheduler extends AppModule 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 14 14 } 15 15 16 function DoStart() 16 function DoStart(): void 17 17 { 18 18 $this->System->FormManager->RegisterClass('Scheduler', array( … … 48 48 'Filter' => '1', 49 49 )); 50 $this->System->RegisterCommandLine('run-scheduler', array($this->System->ModuleManager->Modules['Scheduler'], 'Run')); 50 $this->System->RegisterCommandLine('run-scheduler', 'Runs scheduled tasks', 51 array(ModuleScheduler::Cast($this->System->GetModule('Scheduler')), 'Run')); 51 52 } 52 53 53 function DoInstall() 54 function DoInstall(): void 54 55 { 55 56 } 56 57 57 function DoUnInstall() 58 function DoUnInstall(): void 58 59 { 59 60 } 60 61 61 function Run( $Parameters)62 function Run(array $Parameters): void 62 63 { 63 64 while (true) … … 100 101 } 101 102 } 103 104 static function Cast(AppModule $AppModule): ModuleScheduler 105 { 106 if ($AppModule instanceof ModuleScheduler) 107 { 108 return $AppModule; 109 } 110 throw new Exception('Expected ModuleScheduler type but got '.gettype($AppModule)); 111 } 102 112 } 103 113 104 114 class SchedulerTask extends Model 105 115 { 106 function Execute() 116 function Execute(): string 107 117 { 118 return ''; 108 119 } 109 120 } 110 121 111 112 122 class ScheduleTaskTest extends SchedulerTask 113 123 { 114 function Execute() 124 function Execute(): string 115 125 { 116 126 $Output = '#'; -
trunk/Modules/Search/Search.php
r874 r887 3 3 class PageSearch extends Page 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 11 11 } 12 12 13 function Show() 13 function Show(): string 14 14 { 15 15 $Output = ''; … … 21 21 '</form>'; 22 22 if ($Text != '') 23 foreach ( $this->System->ModuleManager->Modules['Search']->Items as $Item)23 foreach (ModuleSearch::Cast($this->System->GetModule('Search'))->Items as $Item) 24 24 { 25 25 $Columns = ''; … … 33 33 $Condition = substr($Condition, 3); 34 34 $DbResult = $this->Database->Select($Item['Table'], $Columns, $Condition.' LIMIT '. 35 $this->System->ModuleManager->Modules['Search']->MaxItemCount);35 ModuleSearch::Cast($this->System->GetModule('Search'))->MaxItemCount); 36 36 if ($DbResult->num_rows > 0) $Output .= '<strong>'.$Item['Name'].'</strong><br/>'; 37 37 while ($Row = $DbResult->fetch_assoc()) … … 49 49 class ModuleSearch extends AppModule 50 50 { 51 var$Items;52 var$MaxItemCount;51 public array $Items; 52 public int $MaxItemCount; 53 53 54 function __construct( $System)54 function __construct(System $System) 55 55 { 56 56 parent::__construct($System); … … 65 65 } 66 66 67 function DoStart() 67 function DoStart(): void 68 68 { 69 69 $this->System->Pages['search'] = 'PageSearch'; 70 70 } 71 71 72 function DoInstall() 72 function DoInstall(): void 73 73 { 74 74 } 75 75 76 function DoUnInstall() 76 function DoUnInstall(): void 77 77 { 78 78 } 79 79 80 function RegisterSearch( $Title, $TableName, $Columns)80 function RegisterSearch(string $Title, string $TableName, array $Columns): void 81 81 { 82 82 $this->Items[] = array('Name' => $Title, 'Table' => $TableName, 'Columns' => $Columns); 83 83 } 84 85 static function Cast(AppModule $AppModule): ModuleSearch 86 { 87 if ($AppModule instanceof ModuleSearch) 88 { 89 return $AppModule; 90 } 91 throw new Exception('Expected ModuleSearch type but got '.gettype($AppModule)); 92 } 84 93 } -
trunk/Modules/SpeedTest/SpeedTest.php
r874 r887 14 14 class ModuleSpeedTest extends AppModule 15 15 { 16 function __construct( $System)16 function __construct(System $System) 17 17 { 18 18 parent::__construct($System); … … 25 25 } 26 26 27 function DoStart() 27 function DoStart(): void 28 28 { 29 29 $this->System->Pages['speedtest'] = 'PageSpeedTest'; … … 33 33 class PageSpeedTest extends Page 34 34 { 35 var $FullTitle = 'Test rychlosti připojení'; 36 var $ShortTitle = 'Test rychlosti'; 37 var $ParentClass = 'PagePortal'; 35 function __construct(System $System) 36 { 37 parent::__construct($System); 38 $this->FullTitle = 'Test rychlosti připojení'; 39 $this->ShortTitle = 'Test rychlosti'; 40 $this->ParentClass = 'PagePortal'; 41 } 38 42 39 function Show() 43 function Show(): string 40 44 { 41 45 if (count($this->System->PathItems) > 1) … … 47 51 } 48 52 49 function ShowDownload() 53 function ShowDownload(): void 50 54 { 51 55 global $config; … … 54 58 } 55 59 56 function ShowMain() 60 function ShowMain(): string 57 61 { 58 62 global $config; -
trunk/Modules/Stock/Stock.php
r874 r887 3 3 class ModuleStock extends AppModule 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 14 14 } 15 15 16 function DoStart() 16 function DoStart(): void 17 17 { 18 18 global $Config; … … 246 246 } 247 247 248 function BeforeInsertStockMove( $Form)248 function BeforeInsertStockMove(Form $Form): array 249 249 { 250 $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance; 250 251 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 251 252 else $Year = date("Y", $Form->Values['ValidFrom']); 252 $Group = $ this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'StockMoveGroup');253 $Form->Values['BillCode'] = $ this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);253 $Group = $Finance->GetFinanceGroupById($Form->Values['Group'], 'StockMoveGroup'); 254 $Form->Values['BillCode'] = $Finance->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 254 255 return $Form->Values; 255 256 } -
trunk/Modules/Subject/Subject.php
r886 r887 3 3 class ModuleSubject extends AppModule 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 14 14 } 15 15 16 function DoStart() 16 function DoStart(): void 17 17 { 18 18 $this->System->FormManager->RegisterClass('Subject', array( … … 127 127 'Filter' => '1', 128 128 )); 129 $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Subject',130 array( 'ModuleSubject', 'ShowDashboardItem'));129 ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('Subject', 130 array($this, 'ShowDashboardItem')); 131 131 } 132 132 133 function DoInstall() 133 function DoInstall(): void 134 134 { 135 135 $this->Database->query("CREATE TABLE IF NOT EXISTS `Subject` ( … … 173 173 } 174 174 175 function DoUninstall() 175 function DoUninstall(): void 176 176 { 177 177 $this->Database->query('DROP TABLE `Contact`'); … … 180 180 } 181 181 182 function ShowDashboardItem() 182 function ShowDashboardItem(): string 183 183 { 184 184 $DbResult = $this->Database->select('Subject', 'COUNT(*)', '1'); -
trunk/Modules/System/System.php
r874 r887 3 3 class PageModules extends Page 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 11 11 } 12 12 13 function ShowList() 13 function ShowList(): string 14 14 { 15 15 $Output = ''; … … 62 62 } 63 63 64 function Show() 64 function Show(): string 65 65 { 66 66 $Output = ''; … … 69 69 if ($_GET['A'] == 'SaveToDb') 70 70 { 71 $Output .= $this->System->ModuleManager->Modules['System']->SaveToDatabase();71 $Output .= ModuleSystem::Cast($this->System->GetModule('System'))->SaveToDatabase(); 72 72 $Output .= $this->SystemMessage('Načtení modulů', 'Seznam modulů v databázi zaktualizován'); 73 73 } else … … 78 78 if ($ModuleName != '') 79 79 { 80 $this->System->Modules[$ModuleName]->Install(); 81 $this->System->ModuleManager->Init(); 80 $this->System->ModuleManager->GetModule($ModuleName)->Install(); 82 81 } else $Output .= 'Modul id '.$_GET['Id'].' nenalezen'; 83 82 … … 88 87 if ($ModuleName != '') 89 88 { 90 $this->System->ModuleManager->Modules[$ModuleName]->UnInstall(); 91 $this->System->ModuleManager->Init(); 89 $this->System->ModuleManager->GetModule($ModuleName)->UnInstall(); 92 90 } else $Output .= 'Modul id '.$_GET['Id'].' nenalezen'; 93 91 } else $Output .= 'Neplatná akce'; … … 100 98 class ModuleSystem extends AppModule 101 99 { 102 var$InstalledChecked;103 104 function __construct( $System)100 public bool $InstalledChecked; 101 102 function __construct(System $System) 105 103 { 106 104 parent::__construct($System); … … 113 111 } 114 112 115 function DoInstall() 113 function DoInstall(): void 116 114 { 117 115 $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemVersion` ( … … 164 162 } 165 163 166 function DoUnInstall() 164 function DoUnInstall(): void 167 165 { 168 166 // Delete tables with reverse order … … 178 176 } 179 177 180 function DoStart() 181 { 182 $this->System->RegisterPage( 'module', 'PageModules');178 function DoStart(): void 179 { 180 $this->System->RegisterPage(['module'], 'PageModules'); 183 181 $this->System->FormManager->RegisterClass('Action', array( 184 182 'Title' => 'Akce', … … 402 400 } 403 401 404 function DoStop() 405 { 406 } 407 408 function IsInstalled() 402 function DoStop(): void 403 { 404 } 405 406 function IsInstalled(): bool 409 407 { 410 408 if ($this->InstalledChecked == false) … … 419 417 } 420 418 421 function ModuleChange($Module) 419 function ModuleChange($Module): void 422 420 { 423 421 //if ($this->IsInstalled()) … … 430 428 } 431 429 432 function LoadFromDatabase() 430 function LoadFromDatabase(): void 433 431 { 434 432 //DebugLog('Loading modules...'); … … 448 446 } 449 447 450 function SaveToDatabase() 448 function SaveToDatabase(): string 451 449 { 452 450 $Output = ''; … … 457 455 $Modules[$DbRow['Name']] = $DbRow; 458 456 if ($this->System->ModuleManager->ModulePresent($DbRow['Name'])) 459 $this->System->ModuleManager-> Modules[$DbRow['Name']]->Id = $DbRow['Id'];457 $this->System->ModuleManager->GetModule($DbRow['Name'])->Id = $DbRow['Id']; 460 458 } 461 459 … … 470 468 'Description' => $Module->Description, 'License' => $Module->License, 471 469 'Installed' => $Module->Installed)); 472 $this->System->ModuleManager-> Modules[$Module->Name]->Id = $this->Database->insert_id;470 $this->System->ModuleManager->GetModule($Module->Name)->Id = $this->Database->insert_id; 473 471 } 474 472 else $this->Database->update('Module', 'Name = "'.$Module->Name.'"', array( … … 512 510 { 513 511 if (!array_key_exists($Module->Id, $DbDependency) or 514 !in_array($this->System->ModuleManager-> Modules[$Dependency]->Id, $DbDependency[$Module->Id]))512 !in_array($this->System->ModuleManager->GetModule($Dependency)->Id, $DbDependency[$Module->Id])) 515 513 { 516 if ( array_key_exists($Dependency, $this->System->ModuleManager->Modules))517 $DependencyId = $this->System->ModuleManager-> Modules[$Dependency]->Id;514 if ($this->System->ModuleManager->ModulePresent($Dependency)) 515 $DependencyId = $this->System->ModuleManager->GetModule($Dependency)->Id; 518 516 else throw new Exception('Dependent module '.$Dependency.' not found'); 519 517 $this->Database->insert('ModuleLink', array('Module' => $Module->Id, … … 534 532 return $Output; 535 533 } 534 535 static function Cast(AppModule $AppModule): ModuleSystem 536 { 537 if ($AppModule instanceof ModuleSystem) 538 { 539 return $AppModule; 540 } 541 throw new Exception('Expected ModuleSystem type but got '.gettype($AppModule)); 542 } 536 543 } -
trunk/Modules/TV/TV.php
r874 r887 5 5 class PageIPTV extends Page 6 6 { 7 var $FullTitle = 'Síťová televize'; 8 var $ShortTitle = 'IPTV'; 9 var $ParentClass = 'PagePortal'; 10 11 function Show() 7 function __construct(System $System) 12 8 { 13 if (count($this->System->PathItems) > 1) 14 { 15 if ($this->System->PathItems[1] == 'playlist.m3u') return $this->ShowPlayList(); 16 else return PAGE_NOT_FOUND; 17 } else return $this->ShowChannelList(); 9 parent::__construct($System); 10 $this->FullTitle = 'Síťová televize'; 11 $this->ShortTitle = 'IPTV'; 12 $this->ParentClass = 'PagePortal'; 18 13 } 19 14 20 function Show ChannelList()15 function Show(): string 21 16 { 22 global $Channels; 23 24 $Output = 'Stažení přehrávače: <a href="http://www.videolan.org/vlc/">VLC Media Player</a><br/>'. 17 $Output = 'Stažení přehrávače: <a href="https://www.videolan.org/vlc/">VLC Media Player</a><br/>'. 25 18 'Seznam všech kanálů do přehrávače: <a href="playlist.m3u">Playlist</a><br/>'. 26 19 'Zobrazení playlistu ve VLC lze provést pomocí menu <strong>View - Playlist</strong> nebo klávesové zkratky CTRL+L<br/>'. … … 28 21 '<div align="center"><strong>Výpis kanálů:</strong><br>'; 29 22 30 $Where =31 23 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `TV` LEFT JOIN `TVGroup` ON `TVGroup`.`Id` = `TV`.`Category` '. 32 24 ' LEFT JOIN `Language` ON `Language`.`Id` = `TV`.`Language` WHERE (`TV`.`Stream` <> "") OR (`TV`.`StreamWeb` <> "")'); … … 69 61 $Output .= '</div><br/>'; 70 62 71 $Output .= 'Další online TV na webu: <a href="http://spustit.cz">Spustit.cz</a><br/>'; 72 $Output .= 'Další online TV na webu: <a href="http://www.tvinfo.cz/live/televize/evropa/cz">TV info</a><br/>'; 63 $Output .= 'Další online TV na webu: <a href="https://spustit.cz/">Spustit.cz</a><br/>'; 73 64 74 65 return $Output; 75 66 } 67 } 76 68 77 function ShowPlayList() 69 class PagePlaylist extends Page 70 { 71 function Show(): string 78 72 { 79 73 $this->ClearPage = true; … … 82 76 Header("Content-Disposition: attachment; filename=playlist.m3u"); 83 77 84 echo('#EXTM3U'."\n");78 $Output = '#EXTM3U'."\n"; 85 79 if (array_key_exists('id', $_GET)) 86 80 { … … 89 83 { 90 84 $Channel = $DbResult->fetch_array(); 91 echo('#EXTINF:0,'.$Channel['Name']."\n");92 echo($Channel['Stream']."\n");85 $Output .= '#EXTINF:0,'.$Channel['Name']."\n"; 86 $Output .= $Channel['Stream']."\n"; 93 87 } 94 88 } else … … 97 91 while ($Channel = $DbResult->fetch_array()) 98 92 { 99 echo('#EXTINF:0,'.$Channel['Name']."\n");100 echo($Channel['Stream']."\n");93 $Output .= '#EXTINF:0,'.$Channel['Name']."\n"; 94 $Output .= $Channel['Stream']."\n"; 101 95 } 102 96 } 97 return $Output; 103 98 } 104 99 } … … 106 101 class ModuleTV extends AppModule 107 102 { 108 function __construct( $System)103 function __construct(System $System) 109 104 { 110 105 parent::__construct($System); … … 117 112 } 118 113 119 function DoInstall() 114 function DoInstall(): void 120 115 { 121 116 } 122 117 123 function DoUninstall() 118 function DoUninstall(): void 124 119 { 125 120 } 126 121 127 function DoStart() 122 function DoStart(): void 128 123 { 129 $this->System->RegisterPage('tv', 'PageIPTV'); 124 $this->System->RegisterPage(['tv'], 'PageIPTV'); 125 $this->System->RegisterPage(['tv', 'playlist.m3u'], 'PagePlaylist'); 130 126 $this->System->FormManager->RegisterClass('TV', array( 131 127 'Title' => 'TV kanály', … … 170 166 } 171 167 172 function DoStop() 168 function DoStop(): void 173 169 { 174 170 } -
trunk/Modules/TV/tkr.php
r874 r887 3 3 class CableTVChennelListPage extends Page 4 4 { 5 var $FullTitle = 'Seznam televizních kanálů místní kabelové televize'; 6 var $ShortTitle = 'Kanály kabelové televize'; 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Seznam televizních kanálů místní kabelové televize'; 9 $this->ShortTitle = 'Kanály kabelové televize'; 10 } 7 11 8 function Show() 12 function Show(): string 9 13 { 10 14 $Output = '<div align="center"><strong>Výpis kanálů:</strong><br>'. … … 21 25 } 22 26 23 $ System->AddModule(new CableTVChennelListPage($System));24 $ System->Modules['CableTVChennelListPage']->GetOutput();27 $Page = new CableTVChennelListPage($System); 28 $Page->GetOutput(); -
trunk/Modules/Task/Task.php
r760 r887 3 3 class ModuleTask extends AppModule 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 14 14 } 15 15 16 function DoStart() 16 function DoStart(): void 17 17 { 18 18 $this->System->FormManager->RegisterClass('Task', array( … … 89 89 )); 90 90 91 $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Task',92 array( 'ModuleTask', 'ShowDashboardItem'));91 ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('Task', 92 array($this, 'ShowDashboardItem')); 93 93 } 94 94 95 function DoInstall() 95 function DoInstall(): void 96 96 { 97 98 97 } 99 98 100 function ShowDashboardItem() 99 function ShowDashboardItem(): string 101 100 { 102 101 $DbResult = $this->Database->select('Task', 'COUNT(*)', '`Progress` < 100'); -
trunk/Modules/TimeMeasure/Graph.php
r874 r887 9 9 var $DefaultHeight; 10 10 11 function __construct( $System)11 function __construct(System $System) 12 12 { 13 13 parent::__construct($System); … … 17 17 } 18 18 19 function Show() 19 function Show(): string 20 20 { 21 21 $this->ClearPage = true; 22 return $this->Render(); 22 $this->Render(); 23 return ''; 23 24 } 24 25 25 function Render() 26 function Render(): void 26 27 { 27 28 $PrefixMultiplier = new PrefixMultiplier(); -
trunk/Modules/TimeMeasure/Main.php
r874 r887 3 3 class PageMeasure extends Page 4 4 { 5 var$GraphTimeRanges;6 var$DefaultVariables;7 var$ImageHeight;8 var$ImageWidth;9 10 function __construct( $System)5 public array $GraphTimeRanges; 6 public array $DefaultVariables; 7 public int $ImageHeight; 8 public int $ImageWidth; 9 10 function __construct(System $System) 11 11 { 12 12 parent::__construct($System); … … 23 23 ); 24 24 $this->GraphTimeRanges = array 25 (26 'hour' => array(27 'caption' => 'Hodina',28 'period' => 3600,29 ),30 'day' => array(31 'caption' => 'Den',32 'period' => 86400, // 3600 * 24,33 ),34 'week' => array(35 'caption' => 'Týden',36 'period' => 604800, // 3600 * 24 * 7,37 ),38 'month' => array(39 'caption' => 'Měsíc',40 'period' => 2592000, // 3600 * 24 * 30,41 ),42 'year' => array(43 'caption' => 'Rok',44 'period' => 31536000, // 3600 * 24 * 365,45 ),46 'years' => array(47 'caption' => 'Desetiletí',48 'period' => 315360000, // 3600 * 24 * 365 * 10,49 ),50 );25 ( 26 'hour' => array( 27 'caption' => 'Hodina', 28 'period' => 3600, 29 ), 30 'day' => array( 31 'caption' => 'Den', 32 'period' => 86400, // 3600 * 24, 33 ), 34 'week' => array( 35 'caption' => 'Týden', 36 'period' => 604800, // 3600 * 24 * 7, 37 ), 38 'month' => array( 39 'caption' => 'Měsíc', 40 'period' => 2592000, // 3600 * 24 * 30, 41 ), 42 'year' => array( 43 'caption' => 'Rok', 44 'period' => 31536000, // 3600 * 24 * 365, 45 ), 46 'years' => array( 47 'caption' => 'Desetiletí', 48 'period' => 315360000, // 3600 * 24 * 365 * 10, 49 ), 50 ); 51 51 } 52 52 … … 114 114 } 115 115 116 function Show() 116 function Show(): string 117 117 { 118 118 $Debug = 0; … … 182 182 } 183 183 184 function Graph() 184 function Graph(): string 185 185 { 186 186 $Output = '<strong>Graf:</strong><br/>'; … … 194 194 } 195 195 196 function MeasureTable() 196 function MeasureTable(): string 197 197 { 198 198 $PrefixMultiplier = new PrefixMultiplier(); … … 266 266 class PageMeasureAddValue extends Page 267 267 { 268 function Show() 268 function Show(): string 269 269 { 270 270 $this->ClearPage = true; -
trunk/Modules/TimeMeasure/TimeMeasure.php
r738 r887 7 7 class ModuleTimeMeasure extends AppModule 8 8 { 9 function __construct( $System)9 function __construct(System $System) 10 10 { 11 11 parent::__construct($System); … … 18 18 } 19 19 20 function DoInstall() 20 function DoInstall(): void 21 21 { 22 22 } 23 23 24 function DoUnInstall() 24 function DoUnInstall(): void 25 25 { 26 26 } 27 27 28 function DoStart() 28 function DoStart(): void 29 29 { 30 $this->System->RegisterPage( 'grafy', 'PageMeasure');31 $this->System->RegisterPage( array('grafy', 'graf.png'), 'PageGraph');32 $this->System->RegisterPage( array('grafy', 'add.php'), 'PageMeasureAddValue');30 $this->System->RegisterPage(['grafy'], 'PageMeasure'); 31 $this->System->RegisterPage(['grafy', 'graf.png'], 'PageGraph'); 32 $this->System->RegisterPage(['grafy', 'add.php'], 'PageMeasureAddValue'); 33 33 $this->System->FormManager->RegisterClass('Measure', array( 34 34 'Title' => 'Měření', … … 50 50 } 51 51 52 function DoStop() 52 function DoStop(): void 53 53 { 54 54 } -
trunk/Modules/User/User.php
r874 r887 7 7 class ModuleUser extends AppModule 8 8 { 9 var $UserPanel; 10 11 function __construct($System) 9 public array $UserPanel; 10 public User $User; 11 12 function __construct(System $System) 12 13 { 13 14 parent::__construct($System); … … 19 20 $this->Dependencies = array(); 20 21 $this->UserPanel = array(); 21 } 22 23 function DoInstall() 22 $this->User = new User($System); 23 } 24 25 function DoInstall(): void 24 26 { 25 27 $this->Database->query("CREATE TABLE IF NOT EXISTS `User` ( … … 108 110 } 109 111 110 function DoUninstall() 112 function DoUninstall(): void 111 113 { 112 114 $this->Database->query('DROP TABLE `PermissionUserAssignment`'); … … 118 120 } 119 121 120 function DoUpgrade() 122 function DoUpgrade(): void 121 123 { 122 124 /* … … 129 131 } 130 132 131 function DoStart() 132 { 133 $this->System->User = new User($this->System); 134 if (isset($_SERVER['REMOTE_ADDR'])) $this->System->User->Check(); 135 $this->System->RegisterPage('userlist', 'PageUserList'); 136 $this->System->RegisterPage('user', 'PageUser'); 133 function DoStart(): void 134 { 135 if (isset($_SERVER['REMOTE_ADDR'])) $this->User->Check(); 136 $this->System->RegisterPage(['userlist'], 'PageUserList'); 137 $this->System->RegisterPage(['user'], 'PageUser'); 137 138 $this->System->RegisterPageBarItem('Top', 'User', array($this, 'TopBarCallback')); 138 139 $this->System->FormManager->RegisterClass('UserLogin', array( … … 272 273 'Filter' => '1', 273 274 )); 274 $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('User',275 array('ModuleUser', 'ShowDashboardItem'));276 } 277 278 function ShowDashboardItem() 275 ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('User', 276 array($this, 'ShowDashboardItem')); 277 } 278 279 function ShowDashboardItem(): string 279 280 { 280 281 $DbResult = $this->Database->select('User', 'COUNT(*)', '1'); … … 284 285 } 285 286 286 function DoStop() 287 { 288 } 289 290 function TopBarCallback() 291 { 292 if ($this-> System->User->User['Id'] == null)287 function DoStop(): void 288 { 289 } 290 291 function TopBarCallback(): string 292 { 293 if ($this->User->User['Id'] == null) 293 294 { 294 295 $Output = '<a href="'.$this->System->Link('/user/?Action=LoginForm').'">Přihlášení</a> '. … … 296 297 } else 297 298 { 298 $Output = $this-> System->User->User['Name'].299 $Output = $this->User->User['Name']. 299 300 ' <a href="'.$this->System->Link('/user/?Action=UserMenu').'">Nabídka</a>'. 300 301 ' <a href="'.$this->System->Link('/user/?Action=Logout').'">Odhlásit</a>'; … … 303 304 return $Output; 304 305 } 306 307 static function Cast(AppModule $AppModule): ModuleUser 308 { 309 if ($AppModule instanceof ModuleUser) 310 { 311 return $AppModule; 312 } 313 throw new Exception('Expected ModuleUser type but got '.gettype($AppModule)); 314 } 305 315 } -
trunk/Modules/User/UserList.php
r874 r887 3 3 class PageUserList extends Page 4 4 { 5 var $FullTitle = 'Seznam registrovaných uživatelů'; 6 var $ShortTitle = 'Seznam uživatelů'; 7 var $ParentClass = 'PagePortal'; 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Seznam registrovaných uživatelů'; 9 $this->ShortTitle = 'Seznam uživatelů'; 10 $this->ParentClass = 'PagePortal'; 11 } 8 12 9 function Show() 13 function Show(): string 10 14 { 11 if (! $this->System->User->CheckPermission('User', 'ShowList'))15 if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('User', 'ShowList')) 12 16 return 'Nemáte oprávnění'; 13 17 -
trunk/Modules/User/UserModel.php
r878 r887 28 28 class PasswordHash 29 29 { 30 function Hash( $Password, $Salt)30 function Hash(string $Password, string $Salt): string 31 31 { 32 32 return sha1(sha1($Password).$Salt); 33 33 } 34 34 35 function Verify( $Password, $Salt, $StoredHash)35 function Verify(string $Password, string $Salt, string $StoredHash): bool 36 36 { 37 37 return $this->Hash($Password, $Salt) == $StoredHash; 38 38 } 39 39 40 function GetSalt() 40 function GetSalt(): string 41 41 { 42 42 mt_srand(microtime(true) * 100000 + memory_get_usage(true)); … … 49 49 class User extends Model 50 50 { 51 var $Roles = array(); 52 var $User = array(); 53 var $OnlineStateTimeout; 54 var $PermissionCache = array(); 55 var $PermissionGroupCache = array(); 56 var $PermissionGroupCacheOp = array(); 57 /** @var Password */ 58 var $PasswordHash; 59 60 function __construct($System) 51 public array $Roles = array(); 52 public array $User = array(); 53 public int $OnlineStateTimeout; 54 public array $PermissionCache = array(); 55 public array $PermissionGroupCache = array(); 56 public array $PermissionGroupCacheOp = array(); 57 public PasswordHash $PasswordHash; 58 59 function __construct(System $System) 61 60 { 62 61 parent::__construct($System); … … 66 65 } 67 66 68 function Check() 67 function Check(): void 69 68 { 70 69 $SID = session_id(); … … 117 116 { 118 117 $this->Database->delete('UserOnline', 'Id='.$DbRow['Id']); 119 if ($DbRow['User'] != null) $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Logout');118 if ($DbRow['User'] != null) ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'Logout'); 120 119 } 121 120 //$this->LoadPermission($this->User['Role']); … … 125 124 } 126 125 127 function Register( $Login, $Password, $Password2, $Email, $Name)126 function Register(string $Login, string $Password, string $Password2, string $Email, string $Name): string 128 127 { 129 128 if (($Email == '') || ($Login == '') || ($Password == '') || ($Password2 == '') || ($Name == '')) $Result = DATA_MISSING; … … 172 171 173 172 $Result = USER_REGISTRATED; 174 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'NewRegistration', $Login);173 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'NewRegistration', $Login); 175 174 } 176 175 } … … 180 179 } 181 180 182 function RegisterConfirm( $Id, $Hash)181 function RegisterConfirm(string $Id, string $Hash): string 183 182 { 184 183 $DbResult = $this->Database->select('User', 'Id, Login, Password', 'Id = '.$Id); … … 191 190 $this->Database->update('User', 'Id='.$Row['Id'], array('Locked' => 0)); 192 191 $Output = USER_REGISTRATION_CONFIRMED; 193 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'RegisterConfirm', 'Login='.192 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'RegisterConfirm', 'Login='. 194 193 $Row['Login'].', Id='.$Row['Id']); 195 194 } else $Output = PASSWORDS_UNMATCHED; … … 198 197 } 199 198 200 function Login( $Login, $Password, $StayLogged = false)199 function Login(string $Login, string $Password, bool $StayLogged = false): string 201 200 { 202 201 if ($StayLogged) $StayLogged = 1; else $StayLogged = 0; … … 228 227 $Result = USER_LOGGED_IN; 229 228 $this->Check(); 230 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Login', 'Login='.$Login.',Host='.gethostbyaddr(GetRemoteAddress()));229 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'Login', 'Login='.$Login.',Host='.gethostbyaddr(GetRemoteAddress())); 231 230 } 232 231 } else $Result = USER_NOT_REGISTRED; … … 234 233 } 235 234 236 function Logout() 235 function Logout(): string 237 236 { 238 237 $SID = session_id(); 239 238 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => null)); 240 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Logout', $this->User['Login']);239 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'Logout', $this->User['Login']); 241 240 $this->Check(); 242 241 return USER_LOGGED_OUT; … … 248 247 $DbResult = $this->Database->select('UserRole', '*'); 249 248 while ($DbRow = $DbResult->fetch_array()) 249 { 250 250 $this->Roles[] = $DbRow; 251 } 251 252 } 252 253 … … 257 258 if ($DbResult->num_rows > 0) 258 259 while ($DbRow = $DbResult->fetch_array()) 260 { 259 261 $this->User['Permission'][$DbRow['Operation']] = $DbRow; 260 } 261 262 function PermissionMatrix() 262 } 263 } 264 265 function PermissionMatrix(): array 263 266 { 264 267 $Result = array(); … … 274 277 } 275 278 276 function CheckGroupPermission( $GroupId, $OperationId)279 function CheckGroupPermission(string $GroupId, string $OperationId): bool 277 280 { 278 281 $PermissionExists = false; … … 322 325 } 323 326 324 function CheckPermission( $Module, $Operation, $ItemType = '', $ItemIndex = 0)327 function CheckPermission(string $Module, string $Operation, string $ItemType = '', int $ItemIndex = 0): bool 325 328 { 326 329 // Get module id … … 373 376 } 374 377 375 function PasswordRecoveryRequest( $Login, $Email)378 function PasswordRecoveryRequest(string $Login, string $Email): string 376 379 { 377 380 $DbResult = $this->Database->select('User', 'Login, Name, Id, Email, Password', '`Login`="'.$Login.'" AND `Email`="'.$Email.'"'); … … 395 398 396 399 $Output = USER_PASSWORD_RECOVERY_SUCCESS; 397 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'PasswordRecoveryRequest', 'Login='.$Login.',Email='.$Email);400 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'PasswordRecoveryRequest', 'Login='.$Login.',Email='.$Email); 398 401 } else $Output = USER_PASSWORD_RECOVERY_FAIL; 399 402 return $Output; 400 403 } 401 404 402 function PasswordRecoveryConfirm( $Id, $Hash, $NewPassword)405 function PasswordRecoveryConfirm(string $Id, string $Hash, string $NewPassword): string 403 406 { 404 407 $DbResult = $this->Database->select('User', 'Id, Login, Password', 'Id = '.$Id); … … 414 417 'Salt' => $Salt, 'Locked' => 0)); 415 418 $Output = USER_PASSWORD_RECOVERY_CONFIRMED; 416 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'PasswordRecoveryConfirm', 'Login='.$Row['Login']);419 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'PasswordRecoveryConfirm', 'Login='.$Row['Login']); 417 420 } else $Output = PASSWORDS_UNMATCHED; 418 421 } else $Output = USER_NOT_FOUND; … … 420 423 } 421 424 422 function CheckToken( $Module, $Operation, $Token)425 function CheckToken(string $Module, string $Operation, string $Token): bool 423 426 { 424 427 $DbResult = $this->Database->select('APIToken', 'User', '`Token`="'.$Token.'"'); -
trunk/Modules/User/UserPage.php
r874 r887 3 3 class PageUser extends Page 4 4 { 5 var $FullTitle = 'Uživatel'; 6 var $ShortTitle = 'Uživatel'; 7 var $ParentClass = 'PagePortal'; 8 9 function Panel($Title, $Content, $Menu = array()) 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Uživatel'; 9 $this->ShortTitle = 'Uživatel'; 10 $this->ParentClass = 'PagePortal'; 11 } 12 13 function Panel(string $Title, string $Content, array $Menu = array()): string 10 14 { 11 15 if (count($Menu) > 0) … … 15 19 } 16 20 17 function ShowContacts() 21 function ShowContacts(): string 18 22 { 19 23 $Query = 'SELECT `Contact`.`Value`, `Contact`.`Description`, (SELECT `Name` FROM `ContactCategory` WHERE `ContactCategory`.`Id` = `Contact`.`Category`) AS `Category` '. 20 24 'FROM `Contact` WHERE `User` = '. 21 $this->System->User->User['Id'];25 ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id']; 22 26 $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS T'); 23 27 $DbRow = $DbResult->fetch_row(); … … 53 57 } 54 58 55 function ShowUserPanel() 56 { 59 function ShowUserPanel(): string 60 { 61 $User = &ModuleUser::Cast($this->System->GetModule('User'))->User; 57 62 $Output = ''; 58 if ($ this->System->User->User['Id'] != null)63 if ($User->User['Id'] != null) 59 64 { 60 65 $Actions = ''; 61 foreach ( $this->System->ModuleManager->Modules['User']->UserPanel as $Action)66 foreach (ModuleUser::Cast($this->System->GetModule('User'))->UserPanel as $Action) 62 67 { 63 68 if (is_string($Action[0])) … … 71 76 $Output .= $this->Panel('Nabídka uživatele', $Actions); 72 77 $Output .= '</td><td style="vertical-align:top;">'; 73 if ($ this->System->User->User['Id'] != null)78 if ($User->User['Id'] != null) 74 79 { 75 80 $Form = new Form($this->System->FormManager); 76 81 $Form->SetClass('UserOptions'); 77 $Form->LoadValuesFromDatabase($ this->System->User->User['Id']);82 $Form->LoadValuesFromDatabase($User->User['Id']); 78 83 $Form->OnSubmit = '?Action=UserOptionsSave'; 79 84 $Output .= $Form->ShowViewForm(); … … 88 93 } 89 94 90 function Show() 91 { 95 function Show(): string 96 { 97 $User = &ModuleUser::Cast($this->System->GetModule('User'))->User; 92 98 $Output = ''; 93 99 if (array_key_exists('Action', $_GET)) … … 112 118 if (array_key_exists('StayLogged', $_POST) and ($_POST['StayLogged'] == 'on')) $StayLogged = true; 113 119 else $StayLogged = false; 114 $Result = $ this->System->User->Login($_POST['Username'], $_POST['Password'], $StayLogged);120 $Result = $User->Login($_POST['Username'], $_POST['Password'], $StayLogged); 115 121 $Output .= $this->SystemMessage('Přihlášení', $Result); 116 122 if ($Result <> USER_LOGGED_IN) … … 130 136 if ($Action == 'Logout') 131 137 { 132 if ($ this->System->User->User['Id'] != null)133 { 134 $Output .= $this->SystemMessage('Odhlášení', $ this->System->User->Logout());138 if ($User->User['Id'] != null) 139 { 140 $Output .= $this->SystemMessage('Odhlášení', $User->Logout()); 135 141 } else $Output .= $this->SystemMessage('Nastavení uživatele', 'Nejste přihlášen'); 136 142 } else 137 143 if ($Action == 'UserOptions') 138 144 { 139 if ($ this->System->User->User['Id'] != null)145 if ($User->User['Id'] != null) 140 146 { 141 147 $Form = new Form($this->System->FormManager); 142 148 $Form->SetClass('UserOptions'); 143 $Form->LoadValuesFromDatabase($ this->System->User->User['Id']);149 $Form->LoadValuesFromDatabase($User->User['Id']); 144 150 $Form->OnSubmit = '?Action=UserOptionsSave'; 145 151 $Output .= $Form->ShowEditForm(); … … 151 157 $Form->SetClass('UserOptions'); 152 158 $Form->LoadValuesFromForm(); 153 $Form->SaveValuesToDatabase($ this->System->User->User['Id']);159 $Form->SaveValuesToDatabase($User->User['Id']); 154 160 $Output .= $this->SystemMessage('Nastavení', 'Nastavení uloženo.'); 155 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Nastavení uživatele změněno', $Form->Values['Name']);156 $Form->LoadValuesFromDatabase($ this->System->User->User['Id']);161 ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'Nastavení uživatele změněno', $Form->Values['Name']); 162 $Form->LoadValuesFromDatabase($User->User['Id']); 157 163 $Form->OnSubmit = '?Action=UserOptionsSave'; 158 164 $Output .= $Form->ShowEditForm(); … … 169 175 { 170 176 $Output .= $this->SystemMessage('Potvrzení registrace', 171 $ this->System->User->RegisterConfirm($_GET['User'], $_GET['H']));177 $User->RegisterConfirm($_GET['User'], $_GET['H'])); 172 178 } else 173 179 if ($Action == 'PasswordRecovery') … … 183 189 $Form->SetClass('PasswordRecovery'); 184 190 $Form->LoadValuesFromForm(); 185 $Result = $ this->System->User->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']);191 $Result = $User->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']); 186 192 $Output .= $this->SystemMessage('Obnova hesla', $Result); 187 193 if ($Result <> USER_PASSWORD_RECOVERY_SUCCESS) … … 192 198 if ($Action == 'PasswordRecoveryConfirm') 193 199 { 194 $Output .= $this->SystemMessage('Obnova hesla', $ this->System->User->PasswordRecoveryConfirm($_GET['User'], $_GET['H'], $_GET['P']));200 $Output .= $this->SystemMessage('Obnova hesla', $User->PasswordRecoveryConfirm($_GET['User'], $_GET['H'], $_GET['P'])); 195 201 } else 196 202 if ($Action == 'UserRegisterSave') … … 199 205 $Form->SetClass('UserRegister'); 200 206 $Form->LoadValuesFromForm(); 201 $Result = $ this->System->User->Register($Form->Values['Login'], $Form->Values['Password'],207 $Result = $User->Register($Form->Values['Login'], $Form->Values['Password'], 202 208 $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['Name']); 203 209 $Output .= $this->SystemMessage('Registrace nového účtu', $Result); … … 216 222 } 217 223 218 function ShowMain() 224 function ShowMain(): string 219 225 { 220 226 $Output = 'Nebyla vybrána akce'; -
trunk/Modules/VPS/VPS.php
r770 r887 3 3 class ModuleVPS extends AppModule 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 16 16 } 17 17 18 function DoStart() 18 function DoStart(): void 19 19 { 20 20 21 21 } 22 22 23 function DoInstall() 23 function DoInstall(): void 24 24 { 25 25 -
trunk/Modules/WebCam/WebCam.php
r874 r887 3 3 class PageWebcam extends Page 4 4 { 5 var $FullTitle = 'Webová kamera'; 6 var $ShortTitle = 'Kamera'; 7 var $ParentClass = 'PagePortal'; 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Webová kamera'; 9 $this->ShortTitle = 'Kamera'; 10 $this->ParentClass = 'PagePortal'; 11 } 8 12 9 function Show() 13 function Show(): string 10 14 { 11 if (file_exists( $this->System->ModuleManager->Modules['WebCam']->ImageFileName))15 if (file_exists(ModuleWebCam::Cast($this->System->GetModule('WebCam'))->ImageFileName)) 12 16 { 13 17 $Output = '<script language="JavaScript"> 14 var ImageURL = "'.$this->System->Config['Web']['RootFolder'].'/webcam/'. $this->System->Modules['Webcam']->ImageFileName.'";18 var ImageURL = "'.$this->System->Config['Web']['RootFolder'].'/webcam/'.ModuleWebCam::Cast($this->System->GetModule('WebCam'))->ImageFileName.'"; 15 19 16 20 // Force an immediate image load … … 32 36 </script>'; 33 37 34 $Output .= '<br /><div align="center"><img name="theImage" src="" idth="640" height="480" alt="Webcam image"><br>Poslední aktualizace: '.date('j.n.Y G:i', filemtime($this->System->Modules['Webcam']->ImageFileName)).'<br>Obnovování po '.$this->System->Config['Web']['WebcamRefresh'].' sekundách</div><br />'; 38 $Output .= '<br /><div align="center"><img name="theImage" src="" idth="640" height="480" alt="Webcam image"><br>Poslední aktualizace: '. 39 date('j.n.Y G:i', filemtime(ModuleWebCam::Cast($this->System->GetModule('WebCam'))->ImageFileName)). 40 '<br>Obnovování po '.$this->System->Config['Web']['WebcamRefresh'].' sekundách</div><br />'; 35 41 } else $Output = '<br />Obrázek nenalezen.<br /><br />'; 36 42 … … 44 50 class ModuleWebCam extends AppModule 45 51 { 46 var$ImageFileName = 'webcam.jpg';52 public string $ImageFileName = 'webcam.jpg'; 47 53 48 function __construct( $System)54 function __construct(System $System) 49 55 { 50 56 parent::__construct($System); … … 58 64 } 59 65 60 function DoStart() 66 function DoStart(): void 61 67 { 62 68 $this->System->Pages['webcam'] = 'PageWebcam'; 63 69 } 64 70 65 function ShowImage() 71 function ShowImage(): string 66 72 { 67 73 global $Config; … … 74 80 return $Output; 75 81 } 82 83 static function Cast(AppModule $AppModule): ModuleWebCam 84 { 85 if ($AppModule instanceof ModuleWebCam) 86 { 87 return $AppModule; 88 } 89 throw new Exception('Expected ModuleWebCam type but got '.gettype($AppModule)); 90 } 76 91 } -
trunk/Modules/Wiki/Wiki.php
r874 r887 3 3 class ModuleWiki extends AppModule 4 4 { 5 function __construct( $System)5 function __construct(System $System) 6 6 { 7 7 parent::__construct($System); … … 15 15 } 16 16 17 function DoInstall() 17 function DoInstall(): void 18 18 { 19 19 parent::Install(); … … 42 42 } 43 43 44 function DoUnInstall() 44 function DoUnInstall(): void 45 45 { 46 46 $this->Database->query('DELETE TABLE `WikiPageContent`'); … … 48 48 } 49 49 50 function DoStart() 50 function DoStart(): void 51 51 { 52 52 $this->LoadPages(); 53 53 } 54 54 55 function DoStop() 56 { 57 } 58 59 function LoadPages() 55 function DoStop(): void 56 { 57 } 58 59 function LoadPages(): void 60 60 { 61 61 $DbResult = $this->Database->select('WikiPage', '*', 'VisibleInMenu=1'); 62 62 while ($DbRow = $DbResult->fetch_assoc()) 63 63 { 64 $this->System->RegisterPage( $DbRow['NormalizedName'], 'PageWiki');64 $this->System->RegisterPage([$DbRow['NormalizedName']], 'PageWiki'); 65 65 $this->System->RegisterMenuItem(array( 66 66 'Title' => $DbRow['Name'], … … 76 76 class PageWiki extends Page 77 77 { 78 var $FullTitle = 'Wiki stránky'; 79 var $ShortTitle = 'Wiki'; 80 var $ParentClass = 'PagePortal'; 81 82 function Show() 78 function __construct(System $System) 79 { 80 parent::__construct($System); 81 $this->FullTitle = 'Wiki stránky'; 82 $this->ShortTitle = 'Wiki'; 83 $this->ParentClass = 'PagePortal'; 84 } 85 86 function Show(): string 83 87 { 84 88 if (array_key_exists('Action', $_GET)) … … 92 96 } 93 97 94 function ShowContent() 98 function ShowContent(): string 95 99 { 96 100 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; … … 107 111 $Output = '<h3>Archív stránky '.$DbRow['Name'].' ('.HumanDateTime($DbRow2['Time']).')</h3>'; 108 112 $Output .= $DbRow2['Content']; 109 if ( $this->System->User->Licence(LICENCE_MODERATOR))113 if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence(LICENCE_MODERATOR)) 110 114 $Output .= '<div><a href="?Action=Edit">Upravit nejnovější</a> <a href="?Action=History">Historie</a></div>'; 111 } else $Output = Show Message('Wiki stránka nenalezena', MESSAGE_CRITICAL);115 } else $Output = ShowmMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 112 116 } else 113 117 { … … 118 122 $Output = '<h3>'.$DbRow['Name'].'</h3>'; 119 123 $Output .= $DbRow2['Content']; 120 if ( $this->System->User->Licence(LICENCE_MODERATOR))124 if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence(LICENCE_MODERATOR)) 121 125 $Output .= '<div><a href="?Action=Edit">Upravit</a> <a href="?Action=History">Historie</a></div>'; 122 126 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); … … 126 130 } 127 131 128 function EditContent() 129 { 130 if ( $this->System->User->Licence(LICENCE_MODERATOR))132 function EditContent(): string 133 { 134 if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence(LICENCE_MODERATOR)) 131 135 { 132 136 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; … … 151 155 } 152 156 153 function SaveContent() 154 { 155 if ( $this->System->User->Licence(LICENCE_MODERATOR))157 function SaveContent(): string 158 { 159 if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence(LICENCE_MODERATOR)) 156 160 { 157 161 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; … … 162 166 if (array_key_exists('content', $_POST) and array_key_exists('save', $_POST)) 163 167 { 164 $ DbResult2 = $this->Database->insert('WikiPageContent', array('Content' => stripslashes($_POST['content']),165 'User' => $this->System->User->Id, 'Time' => 'NOW()', 'Page' => $DbRow['Id']));168 $this->Database->insert('WikiPageContent', array('Content' => stripslashes($_POST['content']), 169 'User' => ModuleUser::Cast($this->System->GetModule('User'))->User->Id, 'Time' => 'NOW()', 'Page' => $DbRow['Id'])); 166 170 $Output = ShowMessage('Wiki stránka uložena', MESSAGE_INFORMATION); 167 171 } else $Output = ShowMessage('Nezadána platná data', MESSAGE_CRITICAL); … … 172 176 } 173 177 174 function ShowHistory() 175 { 176 if ( $this->System->User->Licence(LICENCE_MODERATOR))178 function ShowHistory(): string 179 { 180 if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence(LICENCE_MODERATOR)) 177 181 { 178 182 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; … … 218 222 } 219 223 220 function ToHtml( $text)224 function ToHtml(string $text): string 221 225 { 222 226 $text = preg_replace('/<source lang="(.*?)">(.*?)<\/source>/', '<pre lang="$1">$2</pre>', $text);
Note:
See TracChangeset
for help on using the changeset viewer.