Changeset 887 for trunk/Modules


Ignore:
Timestamp:
Nov 20, 2020, 12:08:12 AM (4 years ago)
Author:
chronos
Message:
  • Added: Static types added to almost all classes, methods and function. Supported by PHP 7.4.
  • Fixed: Various found code issues.
Location:
trunk/Modules
Files:
86 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/API/API.php

    r874 r887  
    1717class ModuleAPI extends AppModule
    1818{
    19   function __construct($System)
     19  function __construct(System $System)
    2020  {
    2121    parent::__construct($System);
     
    2828  }
    2929
    30   function DoStart()
     30  function DoStart(): void
    3131  {
    32     $this->System->RegisterPage(array('api'), 'PageAPI');
     32    $this->System->RegisterPage(['api'], 'PageAPI');
    3333  }
    3434}
     
    3636class PageAPI extends Page
    3737{
    38   var $DataFormat;
    39  
    40   function __construct($System)
     38  public string $DataFormat;
     39
     40  function __construct(System $System)
    4141  {
    4242    parent::__construct($System);
    4343    $this->ClearPage = true;
     44    $this->DataFormat = '';
    4445  }
    4546
    46   function Show()
     47  function Show(): string
    4748  {
    4849    // p - token
     
    5051      $Token = $_GET['p'];
    5152      $DbResult = $this->Database->query('SELECT `User` FROM `APIToken` WHERE `Token`="'.$Token.'"');
    52       if ($DbResult->num_rows > 0) 
     53      if ($DbResult->num_rows > 0)
    5354      {
    5455        $DbRow = $DbResult->fetch_assoc();
     
    7576  }
    7677
    77   function ShowList($Table, $ItemId)
     78  function ShowList(string $Table, $ItemId): string
    7879  {
    7980    if (($Table != '') and (array_key_exists($Table, $this->System->FormManager->Classes)))
     
    8485      $SourceTable = '('.$FormClass['SQL'].') AS `TX`';
    8586      else $SourceTable = '`'.$FormClass['Table'].'` AS `TX`';
    86      
     87
    8788    $Filter = '';
    8889    if ($ItemId != 0)
     
    112113    $dom->appendChild($root);
    113114
    114     $array2xml = function ($node, $array) use ($dom, &$array2xml) 
     115    $array2xml = function ($node, $array) use ($dom, &$array2xml)
    115116    {
    116117      foreach ($array as $key => $value)
    117118      {
    118         if ( is_array($value) ) 
     119        if ( is_array($value) )
    119120        {
    120121          if (is_numeric($key)) $key = 'N'.$key; //die('XML tag name "'.$key.'" can\'t be numeric');
  • trunk/Modules/Chat/Chat.php

    r874 r887  
    33class PageChatHistory extends Page
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1717  }
    1818
    19   function Show()
     19  function Show(): string
    2020  {
    2121    global $MonthNames;
    2222
    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í';
    2424
    2525    if (array_key_exists('date', $_GET)) $Date = $_GET['date'];
     
    8787class ModuleChat extends AppModule
    8888{
    89   function __construct($System)
     89  function __construct(System $System)
    9090  {
    9191    parent::__construct($System);
     
    9898  }
    9999
    100   function DoStart()
     100  function DoStart(): void
    101101  {
    102102    $this->System->Pages['chat'] = 'PageChatHistory';
  • trunk/Modules/Chat/irc_bot.php

    r873 r887  
    3939  }
    4040
    41   function Run()
     41  function Run(): void
    4242  {
    4343    global $Database;
     
    195195    echo("-Connection lost.\n");
    196196  }
    197 
    198197}
    199198
  • trunk/Modules/Customer/Customer.php

    r874 r887  
    33class ModuleCustomer extends AppModule
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1414  }
    1515
    16   function DoStart()
     16  function DoStart(): void
    1717  {
    1818    $this->System->FormManager->RegisterClass('Member', array(
     
    187187    ));
    188188
    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'));
    191191  }
    192192
    193   function ShowDashboardItem()
     193  function ShowDashboardItem(): string
    194194  {
    195195    $DbResult = $this->Database->select('Member', 'COUNT(*)', '1');
  • trunk/Modules/EmailQueue/EmailQueue.php

    r882 r887  
    33class PageEmailQueueProcess extends Page
    44{
    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  }
    812
    9   function Show()
     13  function Show(): string
    1014  {
    11     $Output = $this->System->ModuleManager->Modules['EmailQueue']->Process();
     15    $Output = ModuleEmailQueue::Cast($this->System->GetModule('EmailQueue'))->Process();
    1216    $Output = $this->SystemMessage('Zpracování fronty emailů', 'Nové emaily byly odeslány').$Output;
    1317    return $Output;
     
    1721class ModuleEmailQueue extends AppModule
    1822{
    19   function __construct($System)
     23  function __construct(System $System)
    2024  {
    2125    parent::__construct($System);
     
    2832  }
    2933
    30   function DoInstall()
     34  function DoInstall(): void
    3135  {
    3236  }
    3337
    34   function DoUninstall()
     38  function DoUninstall(): void
    3539  {
    3640  }
    3741
    38   function DoStart()
     42  function DoStart(): void
    3943  {
    40     $this->System->RegisterPage('fronta-posty', 'PageEmailQueueProcess');
     44    $this->System->RegisterPage(['fronta-posty'], 'PageEmailQueueProcess');
    4145    $this->System->FormManager->RegisterClass('Email', array(
    4246        'Title' => 'Nový email',
     
    7074  }
    7175
    72   function DoStop()
     76  function DoStop(): void
    7377  {
    7478  }
     
    8387  }
    8488
    85   function Process()
     89  function Process(): string
    8690  {
    8791    $Output = '';
     
    103107      $Mail->Send();
    104108      $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']);
    106110      $Output .= 'To: '.$DbRow['To'].'  Subject: '.$DbRow['Subject'].'<br />';
    107111    }
    108112    return $Output;
    109113  }
     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  }
    110123}
    111 
  • trunk/Modules/Employee/Employee.php

    r738 r887  
    33class ModuleEmployee extends AppModule
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1414  }
    1515
    16   function DoStart()
     16  function DoStart(): void
    1717  {
    1818    $this->System->FormManager->RegisterClass('Employee', array(
  • trunk/Modules/Error/Error.php

    r873 r887  
    33class ModuleError extends AppModule
    44{
    5   var $Encoding;
    6   var $ShowError;
    7   var $UserErrors;
    8   var $ErrorHandler;
     5  public string $Encoding;
     6  public ErrorHandler $ErrorHandler;
    97
    10   function __construct($System)
     8  function __construct(System $System)
    119  {
    1210    parent::__construct($System);
     
    1917
    2018    $this->ErrorHandler = new ErrorHandler();
     19    $this->Encoding = 'utf-8';
    2120  }
    2221
    23   function DoInstall()
     22  function DoInstall(): void
    2423  {
    2524  }
    2625
    27   function DoUnInstall()
     26  function DoUnInstall(): void
    2827  {
    2928  }
    3029
    31   function DoStart()
     30  function DoStart(): void
    3231  {
    3332    $this->ErrorHandler->ShowError = $this->System->Config['Web']['ShowPHPError'];
     
    3635  }
    3736
    38   function DoStop()
     37  function DoStop(): void
    3938  {
    4039    $this->ErrorHandler->Stop();
    4140  }
    4241
    43   function DoOnError($Error)
     42  function DoOnError(string $Error): void
    4443  {
    45     $this->System->ModuleManager->Modules['Log']->NewRecord('Error', 'Log', $Error);
     44    ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Error', 'Log', $Error);
    4645
    4746    //if ($Config['Web']['ErrorLogFile'] != '')
  • trunk/Modules/File/File.php

    r885 r887  
    55class File extends Model
    66{
    7   var $FilesDir;
    8 
    9   function __construct($System)
     7  public string $FilesDir;
     8
     9  function __construct(System $System)
    1010  {
    1111    parent::__construct($System);
     
    1313  }
    1414
    15   function Delete($Id)
     15  function Delete($Id): void
    1616  {
    1717    $DbResult = $this->Database->select('File', 'Name', 'Id='.$Id);
     
    2424  }
    2525
    26   function CreateFromUpload($Name)
     26  function CreateFromUpload(string $Name): string
    2727  {
    2828    // Submited form with file input have to be enctype="multipart/form-data"
     
    4141  }
    4242
    43   function DetectMimeType($FileName)
     43  function DetectMimeType(string $FileName): string
    4444  {
    4545    $MimeTypes = GetMimeTypes();
     
    4949  }
    5050
    51   function Download($Id)
     51  function Download(string $Id): void
    5252  {
    5353    $DbResult = $this->Database->select('File', '*', 'Id='.addslashes($Id));
     
    6767  }
    6868
    69   function GetDir($Id)
     69  function GetDir(string $Id): string
    7070  {
    7171    $DbResult = $this->Database->select('FileDirectory', '*', 'Id='.$Id);
     
    7777  }
    7878
    79   function GetFullPath($Id)
     79  function GetFullPath(string $Id): string
    8080  {
    8181    $DbResult = $this->Database->select('File', '*', 'Id='.addslashes($Id));
     
    9393class PageFile extends Page
    9494{
    95   function Show()
     95  function Show(): string
    9696  {
    9797    if (array_key_exists('id', $_GET)) $Id = $_GET['id'];
     
    9999    else return $this->SystemMessage('Chyba', 'Nezadáno id souboru');
    100100    $this->ClearPage = true;
    101     $Output = $this->System->Modules['File']->Download($Id);
     101    $Output = ModuleFile::Cast($this->System->GetModule('File'))->File->Download($Id);
    102102    return $Output;
    103103  }
     
    106106class PageFileCheck extends Page
    107107{
    108   function __construct($System)
     108  function __construct(System $System)
    109109  {
    110110    parent::__construct($System);
     
    114114  }
    115115
    116   function GetAbsolutePath($Path)
     116  function GetAbsolutePath(string $Path): string
    117117  {
    118118    $Path = trim($Path);
     
    137137  }
    138138
    139   function Show()
     139  function Show(): string
    140140  {
    141141    $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'))
    143143      return 'Nemáte oprávnění';
    144144    $DbResult = $this->Database->select('File', 'Id');
     
    146146    {
    147147      $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));
    149149      if (!file_exists($FileName))
    150150        $Output .= '<a href="'.$this->System->Link('/is/?a=view&amp;t=File&amp;i='.$Id).'">'.$FileName.'</a><br>';
     
    156156class ModuleFile extends AppModule
    157157{
    158   function __construct($System)
     158  public File $File;
     159
     160  function __construct(System $System)
    159161  {
    160162    parent::__construct($System);
     
    164166    $this->License = 'GNU/GPLv3';
    165167    $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
    178182  {
    179183    global $Config;
    180184
    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'];
    185188    $this->System->FormManager->RegisterClass('File', array(
    186189      'Title' => 'Soubor',
     
    271274  }
    272275
    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  
    11<?php
    22
    3 function GetMimeTypes()
     3function GetMimeTypes(): array
    44{
    55  return array(
  • trunk/Modules/Finance/Bill.php

    r874 r887  
    33class Bill extends Model
    44{
    5   var $SpecificSymbol = 1; // počítačová sít
    6   var $Checked;
     5  public int $SpecificSymbol = 1; // computer network number
     6  public bool $Checked = false;
    77
    88  function GenerateHTML()
     
    1111  }
    1212
    13   function SaveToFile($FileName)
    14   {
    15     global $Database;
    16 
     13  function SaveToFile(string $FileName)
     14  {
    1715    $PdfData = $this->HtmlToPdf($this->GenerateHTML());
    1816    file_put_contents($FileName, $PdfData);
    1917  }
    2018
    21   function HtmlToPdf($HtmlCode)
     19  function HtmlToPdf(string $HtmlCode): string
    2220  {
    2321    $Encoding = new Encoding();
     
    3533class BillInvoice extends Bill
    3634{
    37   var $InvoiceId;
    38 
    39   function ShowSubjectInfo($Subject)
     35  public string $InvoiceId;
     36
     37  function ShowSubjectInfo(array $Subject): string
    4038  {
    4139    $BooleanText = array('Ne', 'Ano');
     
    5048  }
    5149
    52   function GenerateHTML()
    53   {
    54     $Finance = &$this->System->Modules['Finance'];
     50  function GenerateHTML(): string
     51  {
     52    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    5553    $Finance->LoadMonthParameters(0);
    5654
     
    152150class BillOperation extends Bill
    153151{
    154   var $OperationId;
    155 
    156   function GenerateHTML()
     152  public string $OperationId;
     153
     154  function GenerateHTML(): string
    157155  {
    158156    $DbResult = $this->Database->query('SELECT `FinanceOperation`.*, `FinanceOperationGroup`.`Direction`, `DocumentLineCode`.`Name` AS `BillName` FROM `FinanceOperation` '.
  • trunk/Modules/Finance/Finance.php

    r877 r887  
    4141  var $Rounding;
    4242
    43   function LoadMonthParameters($Period = 1) // 0 - now, 1 - next month
     43  function LoadMonthParameters(int $Period = 1) // 0 - now, 1 - next month
    4444  {
    4545    $DbResult = $this->Database->query('SELECT * FROM `FinanceBillingPeriod`');
     
    7878  }
    7979
    80   function W2Kc($Spotreba)
     80  function W2Kc($Spotreba): string
    8181  {
    8282    return round($Spotreba * 0.72 * $this->kWh);
     
    8888    $EndTime = mktime(0, 0, 0, 12, 31, $Year);
    8989    $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;
    9292
    9393    // Create DocumentLineSequence from previous
     
    9595    while ($DbRow = $DbResult->fetch_assoc())
    9696    {
    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)
    103103  {
    104104    if ($Year == 0)
     
    107107      $DbResult = $this->Database->select('FinanceYear', '*', '1 ORDER BY `Year` DESC LIMIT 1');
    108108    } 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);
    113114        $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          }
    116117    $FinanceYear = $DbResult->fetch_assoc();
    117118    if ($FinanceYear['Closed'] == 1)
     
    120121  }
    121122
    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);
    125126
    126127    $DbResult = $this->Database->query('SELECT `Shortcut`, `Id` FROM `DocumentLine` WHERE `Id`='.$Id);
     
    141142  }
    142143
    143   function GetNextDocumentLineNumberId($Id, $FinanceYear = 0)
     144  function GetNextDocumentLineNumberId(string $Id, int $FinanceYear = 0): int
    144145  {
    145146    $Code = $this->GetNextDocumentLineNumber($Id, $FinanceYear);
     
    148149  }
    149150
    150   function GetFinanceGroupById($Id, $Table)
     151  function GetFinanceGroupById(string $Id, string $Table): ?array
    151152  {
    152153    $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE `Id`= '.$Id);
     
    154155      $Group = $DbResult->fetch_assoc();
    155156      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
    160163  {
    161164    $Output = 'Aktualizuji finance členů...<br />';
     
    199202      $Consumption = 0;
    200203      $this->Database->insert('MemberPayment', array('Member' => $Member['Id'],
    201           'MonthlyInternet' => $MonthlyInet,
    202           'MonthlyTotal' => $Monthly, 'MonthlyConsumption' => $this->W2Kc($Consumption),
    203           'Cash' => $Cash, 'MonthlyPlus' => $this->W2Kc($ConsumptionPlus)));
     204        'MonthlyInternet' => $MonthlyInet,
     205        'MonthlyTotal' => $Monthly, 'MonthlyConsumption' => $this->W2Kc($Consumption),
     206        'Cash' => $Cash, 'MonthlyPlus' => $this->W2Kc($ConsumptionPlus)));
    204207    }
    205     $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'RecalculateMemberPayment');
     208    ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'RecalculateMemberPayment');
    206209    return $Output;
    207210  }
    208211
    209   function GetVATByType($TypeId)
     212  function GetVATByType(string $TypeId): string
    210213  {
    211214    $Time = time();
     
    220223class ModuleFinance extends AppModule
    221224{
    222   function __construct($System)
     225  public Finance $Finance;
     226  public Bill $Bill;
     227
     228  function __construct(System $System)
    223229  {
    224230    parent::__construct($System);
     
    229235    $this->Description = 'Base module for finance management';
    230236    $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
    242251  {
    243252    global $Config;
    244253
    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');
    249258
    250259    $this->System->FormManager->RegisterClass('FinanceOperation', array(
     
    644653    ));
    645654
    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
    657662  {
    658663    $DbResult = $this->Database->select('FinanceOperation', 'ROUND(SUM(`Value`))', '1');
     
    662667  }
    663668
    664   function DoStop()
    665   {
    666   }
    667 
    668   function BeforeInsertFinanceOperation($Form)
     669  function DoStop(): void
     670  {
     671  }
     672
     673  function BeforeInsertFinanceOperation(Form $Form): array
    669674  {
    670675    if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
    671676      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');
    680685    $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '.
    681686      ($Form->Values['ValueUser'] * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id);
     
    683688  }
    684689
    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');
    688693    $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '.
    689694      ($Form->Values['ValueUser'] * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id);
     
    691696  }
    692697
    693   function BeforeInsertFinanceInvoice($Form)
     698  function BeforeInsertFinanceInvoice(Form $Form): array
    694699  {
    695700    // Get new DocumentLineCode by selected invoice Group
    696701    if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
    697702      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');
    706711    $DbResult = $this->Database->query(str_replace('#Id', $Id, $Form->Definition['Items']['ValueUser']['SQL']));
    707712    $DbRow = $DbResult->fetch_row();
     
    713718  }
    714719
    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');
    718723    $DbResult = $this->Database->query(str_replace('#Id', $Id, $Form->Definition['Items']['ValueUser']['SQL']));
    719724    $DbRow = $DbResult->fetch_row();
     
    724729  }
    725730
    726   function AfterInsertFinanceInvoiceItem($Form, $Id)
     731  function AfterInsertFinanceInvoiceItem(Form $Form, string $Id): array
    727732  {
    728733    $ParentForm = new Form($this->System->FormManager);
     
    733738  }
    734739
    735   function AfterModifyFinanceInvoiceItem($Form, $Id)
     740  function AfterModifyFinanceInvoiceItem(Form $Form, string $Id): array
    736741  {
    737742    $ParentForm = new Form($this->System->FormManager);
     
    742747  }
    743748
    744   function BeforeInsertContract($Form)
     749  function BeforeInsertContract(Form $Form): array
    745750  {
    746751    if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
    747752      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));
    750764  }
    751765}
  • trunk/Modules/Finance/Import.php

    r874 r887  
    33class PageFinanceImportPayment extends Page
    44{
    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  }
    812
    9   function Show()
     13  function Show(): string
    1014  {
    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í';
    1216    if (array_key_exists('Operation', $_GET))
    1317    {
     
    2630  }
    2731
    28   function Prepare()
     32  function Prepare(): string
    2933  {
    30     $Finance = $this->System->Modules['Finance'];
     34    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    3135    $Finance->LoadMonthParameters(0);
    3236    $Data = explode("\n", $_POST['Source']);
     
    124128  }
    125129
    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)
    127131  {
    128132    $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);
    130134    // TODO: Fixed BankAccount=1, allow to select bank account for import
    131135    $this->Database->insert('FinanceOperation', array('Text' => $Text,
     
    136140  }
    137141
    138   function Insert()
     142  function Insert(): string
    139143  {
    140     $Finance = $this->System->Modules['Finance'];
     144    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    141145    $Finance->LoadMonthParameters(0);
    142146    $Output = '';
     
    144148    for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--)
    145149    {
    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');
    150156      }
    151157      $Date = explode('-', $_POST['Date'.$I]);
     
    154160        0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $FinanceGroup);
    155161      $Output .= $I.', ';
    156       $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted');
     162      ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'NewPaymentInserted');
    157163    }
    158164    return $Output;
  • trunk/Modules/Finance/Manage.php

    r886 r887  
    33class PageFinanceManage extends Page
    44{
    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'))
    1317      return 'Nemáte oprávnění';
    1418
     
    1822    {
    1923      case 'Recalculate':
    20         $Output .= $this->System->Modules['Finance']->RecalculateMemberPayment();
     24        $Output .= ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->RecalculateMemberPayment();
    2125        break;
    2226      case 'ShowMonthlyPayment':
     
    5155    $Year = date('Y', $Time);
    5256
    53     $MonthCount = $this->System->Modules['Finance']->BillingPeriods[$Period]['MonthCount'];
     57    $MonthCount = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->BillingPeriods[$Period]['MonthCount'];
    5458    if ($MonthCount <= 0) return array('From' => NULL, 'To' => NULL, 'MonthCount' => 0);
    5559    $MonthCurrent = date('n', $Time);
     
    7276  function ShowMonthlyPayment()
    7377  {
    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í';
    7579    $SQL = 'SELECT `Member`.*, `MemberPayment`.`MonthlyTotal` AS `Monthly`, '.
    7680      '`MemberPayment`.`Cash` AS `Cash`, '.
     
    128132    global $LastInsertTime;
    129133
     134    $Finance = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
     135
    130136    $Year = date('Y', $TimeCreation);
    131     $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);
     137    $BillCode = $Finance->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);
    132138    $SumValue = 0;
    133139    foreach ($Items as $Item) {
    134140      $SumValue = $SumValue + $Item['Price'] * $Item['Quantity'];
    135141    }
    136     $Finance = &$this->System->Modules['Finance'];
    137142    $SumValue = round($SumValue, $Finance->Rounding);
    138143    $this->Database->insert('FinanceInvoice', array(
     
    181186        {
    182187          $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']));
    184189          $MonthlyTotal += $Service['Price'];
    185190        }
     
    196201
    197202        // Load invoice group
    198         $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($InvoiceGroupId, 'FinanceInvoiceGroup');
     203        $FinanceGroup = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetFinanceGroupById($InvoiceGroupId, 'FinanceInvoiceGroup');
    199204        foreach ($InvoiceItems as $Index => $Item)
    200205        {
     
    275280  function ProcessMonthlyPayment()
    276281  {
    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í';
    278283    $Output = '';
    279284
    280285    $Output .= $this->ProcessTableUpdates();
    281286
    282     $Finance = &$this->System->Modules['Finance'];
     287    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    283288    $Finance->LoadMonthParameters(0);
    284289
     
    334339      //flush();
    335340      //$this->GenerateBills();
    336       $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'ProcessMonthlyPayment', $Output);
     341      ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'ProcessMonthlyPayment', $Output);
    337342    }
    338343    $Output = str_replace("\n", '<br/>', $Output);
     
    379384      $Service = $DbResult->fetch_assoc();
    380385      $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".
    382387        'Pravidelná platba za období: <strong>'.($MemberPayment['MonthlyTotal'] * $Period['MonthCount']).' Kč</strong><br />'."\n".
    383388        'Bankovní účet: <strong>'.$MainSubjectAccount['NumberFull'].'</strong><br/>'."\n".
     
    407412
    408413      $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,
    410415         $Config['Web']['Admin'].' <'.$Config['Web']['AdminEmail'].'>');
    411416      $Output = '';
     
    416421  function GenerateInvoice($Where)
    417422  {
     423    $DirectoryId = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->DirectoryId;
    418424    $Output = '';
    419425    $DbResult = $this->Database->query('SELECT * FROM `FinanceInvoice` WHERE (`BillCode` <> "") '.
     
    423429      if ($Row['File'] == null)
    424430      {
    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()'));
    427432        $FileId = $this->Database->insert_id;
    428433      } else $FileId = $Row['File'];
     
    432437      $Bill->System = &$this->System;
    433438      $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;
    435440      $Bill->SaveToFile($FullFileName);
    436441      if (file_exists($FullFileName))
     
    446451  function GenerateOperation($Where)
    447452  {
     453    $DirectoryId = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->DirectoryId;
    448454    $Output = '';
    449455    $DbResult = $this->Database->query('SELECT * FROM `FinanceOperation` WHERE (`BillCode` <> "") '.
     
    454460      {
    455461        $DbResult2 = $this->Database->insert('File', array('Name' => '', 'Size' => 0,
    456           'Directory' => $this->System->Modules['Finance']->DirectoryId, 'Time' => 'NOW()'));
     462          'Directory' => $DirectoryId, 'Time' => 'NOW()'));
    457463        $FileId = $this->Database->insert_id;
    458464      } else $FileId = $Row['File'];
     
    462468      $Bill->System = &$this->System;
    463469      $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;
    465471      $Bill->SaveToFile($FullFileName);
    466472      if (file_exists($FullFileName))
  • trunk/Modules/Finance/Trade.php

    r874 r887  
    33class PageFinanceTaxFiling extends Page
    44{
    5   var $FullTitle = 'Daňová evidence';
    6   var $ShortTitle = 'Daňová evidence';
    7   var $ParentClass = 'PageFinance';
    85  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  }
    914
    1015  function GetTimePeriodBalance($StartTime, $EndTime)
     
    340345  function ShowSubjectAccount()
    341346  {
     347    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
     348
    342349    $Output = '<table style="width: 100%"><tr><td style="vertical-align: top;">';
    343350    $Output .= '<strong>Výpis příjmů/výdajů</strong>';
     
    424431  }
    425432
    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'))
    429436      return 'Nemáte oprávnění';
    430 
    431     $Finance = &$this->System->Modules['Finance'];
    432437
    433438    $Output = '';
  • trunk/Modules/Finance/UserState.php

    r874 r887  
    33class PageFinanceUserState extends Page
    44{
    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  }
    812
    913  function ShowFinanceOperation($Subject)
     
    6973  }
    7074
    71   function Show()
     75  function Show(): string
    7276  {
    73     $Finance = &$this->System->Modules['Finance'];
     77    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    7478    $Finance->LoadMonthParameters(0);
    7579
     
    7781    if (array_key_exists('i', $_GET))
    7882    {
    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í';
    8084      $CustomerId = $_GET['i'];
    8185    } else
    8286    {
    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'];
    8589      $DbResult = $this->Database->query('SELECT `Customer` FROM `UserCustomerRel` WHERE `User`='.$UserId.' LIMIT 1');
    8690      if ($DbResult->num_rows > 0)
  • trunk/Modules/FinanceBankAPI/FileImport.php

    r884 r887  
    55class BankImport
    66{
    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)
    1212  {
    1313    $this->Database = &$System->Database;
     
    1515  }
    1616
    17   function Import()
    18   {
     17  function Import(): string
     18  {
     19    return '';
    1920  }
    2021
     
    2324  }
    2425
    25   function PairOperations()
    26   {
     26  function PairOperations(): void
     27  {
     28    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    2729    $DbResult = $this->Database->select('FinanceBankImport', '*', 'FinanceOperation IS NULL');
    2830    while ($DbRow = $DbResult->fetch_assoc())
     
    3436        {
    3537          $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');
    4044          }
    4145          $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,
    4448            'ValueUser' => Abs($DbRow['Value']), 'Value' => 0, 'Taxable' => 1, 'BankAccount' => $DbRow['BankAccount'], 'Network' => 1,
    4549            'Time' => $DbRow['Time'], 'Text' => $DbRow['Description'], 'BillCode' => $BillCode, 'Group' => $FinanceGroup['Id']));
     
    6569class PageImportAPI extends Page
    6670{
    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
    7280  {
    7381    $Output = '';
     
    92100  }
    93101
    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'))
    97105      return 'Nemáte oprávnění';
    98106
     
    104112class PageImportFile extends Page
    105113{
    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
    111123  {
    112124    $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í';
    114126    if (array_key_exists('Operation', $_GET))
    115127    {
     
    121133  }
    122134
    123   function ShowForm()
     135  function ShowForm(): string
    124136  {
    125137    $Form = new Form($this->System->FormManager);
     
    156168  }
    157169
    158   function InsertMoney($Subject, $Value, $Cash, $Taxable, $Time, $Text, $Group)
     170  function InsertMoney($Subject, $Value, $Cash, $Taxable, $Time, $Text, $Group): void
    159171  {
    160172    $Year = date('Y', $Time);
    161     $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId(
     173    $BillCode = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetNextDocumentLineNumberId(
    162174      $Group['DocumentLine'], $Year);
    163175    $this->Database->insert('FinanceOperation', array('Text' => $Text,
     
    166178  }
    167179
    168   function Insert()
    169   {
    170     $Finance = $this->System->Modules['Finance'];
     180  function Insert(): string
     181  {
     182    $Finance = $ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    171183    $Output = '';
    172184
    173185    for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--)
    174186    {
    175       if ($_POST['Money'.$I] >= 0) {
     187      if ($_POST['Money'.$I] >= 0)
     188      {
    176189        $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN,
    177190          'FinanceOperationGroup');
    178       } else {
     191      } else
     192      {
    179193        $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT,
    180194          'FinanceOperationGroup');
     
    185199        0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $FinanceGroup);
    186200      $Output .= $I.', ';
    187       $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted');
     201      ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'NewPaymentInserted');
    188202    }
    189203    return $Output;
  • trunk/Modules/FinanceBankAPI/FinanceBankAPI.php

    r874 r887  
    88class ModuleFinanceBankAPI extends AppModule
    99{
    10   function __construct($System)
     10  function __construct(System $System)
    1111  {
    1212    parent::__construct($System);
     
    1616    $this->License = 'GNU/GPLv3';
    1717    $this->Description = 'Communication through API to various banks, manual file import';
    18     $this->Dependencies = array('Finance', 'Scheduler');
     18    $this->Dependencies = array('Finance', 'Scheduler', 'IS');
    1919  }
    2020
    21   function DoInstall()
     21  function DoInstall(): void
    2222  {
    2323  }
    2424
    25   function DoUninstall()
     25  function DoUninstall(): void
    2626  {
    2727  }
    2828
    29   function DoStart()
     29  function DoStart(): void
    3030  {
    3131    $this->System->FormManager->RegisterClass('ImportBankFile', array(
     
    6060    ));
    6161
    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');
    6464
    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'));
    6767  }
    6868
    69   function DoStop()
     69  function DoStop(): void
    7070  {
    7171  }
    7272
    73   function ShowDashboardItem()
     73  function ShowDashboardItem(): string
    7474  {
    7575    $DbResult = $this->Database->select('FinanceBankImport', 'COUNT(*)', '`FinanceOperation` IS NULL');
     
    7979  }
    8080
    81   function PresetItem($Item)
     81  function PresetItem(array $Item): array
    8282  {
    8383    $Preset = array();
    8484    if ($Item['Value'] < 0) $OperationGroupId = OPERATION_GROUP_ACCOUNT_OUT;
    8585       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');
    8787
    8888    $Preset = array(
     
    100100class ScheduleBankImport extends SchedulerTask
    101101{
    102   function Execute()
     102  function Execute(): string
    103103  {
    104104    $Output = '';
  • trunk/Modules/FinanceBankAPI/Fio.php

    r874 r887  
    55class Fio
    66{
    7   var $UserName;
    8   var $Password;
    9   var $Account;
     7  public string $UserName;
     8  public string $Password;
     9  public int $Account;
    1010
    11   function Import($TimeFrom, $TimeTo)
     11  function Import(int $TimeFrom, int $TimeTo): array
    1212  {
    1313    if ($this->UserName == '') throw new Exception('Missing value for UserName property.');
     
    5959  }
    6060
    61   function NoValidDataError($Response)
     61  function NoValidDataError(array $Response): void
    6262  {
    6363    // Try to get error message
    64     // If something go wrong fio show HTML login page and display error message
    65   $Response = implode('', $Response);
     64    // If something go wrong fio shows HTML login page and display error message
     65    $Response = implode('', $Response);
    6666    $ErrorMessageStart = '<div id="oldform_warning">';
    6767    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);
    7373  }
    7474}
  • trunk/Modules/FinanceBankAPI/FioAPI.php

    r874 r887  
    2323  }
    2424
    25   function Import($TimeFrom, $TimeTo)
     25  function Import(int $TimeFrom, int $TimeTo): array
    2626  {
    2727    if ($this->Token == '') throw new Exception('Missing value for Token property.');
     
    101101  }
    102102
    103   function NoValidDataError($Response)
     103  function NoValidDataError(array $Response): void
    104104  {
    105105    // Try to get error message
  • trunk/Modules/FinanceBankAPI/GPC.php

    r874 r887  
    66class GPC
    77{
    8   function ParseLine($Line)
     8  function ParseLine(string $Line): array
    99  {
    1010    $Line = ' '.$Line;
  • trunk/Modules/FinanceBankAPI/ImportFio.php

    r884 r887  
    55class ImportFio extends BankImport
    66{
    7   function Import()
     7  function Import(): string
    88  {
    99    $Fio = new FioAPI();
  • trunk/Modules/FinanceBankAPI/ImportPS.php

    r873 r887  
    1111  function ImportTxt($Content)
    1212  {
    13     $Finance = &$this->System->Modules['Finance'];
    14     $Data = explode("\n", $Content);
    1513  }
    1614
    1715  function ImportCVS($Content)
    1816  {
    19     $Finance = &$this->System->Modules['Finance'];
    20 
    2117    $Data = explode("\n", $Content);
    2218    foreach ($Data as $Key => $Value)
  • trunk/Modules/IS/IS.php

    r873 r887  
    55class PageIS extends Page
    66{
    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;
    1310
    1411  function __construct($System)
    1512  {
    1613    parent::__construct($System);
     14    $this->FullTitle = 'Správa dat';
     15    $this->ShortTitle = 'Správa dat';
     16    $this->ParentClass = 'PagePortal';
     17
    1718    $this->MenuItems = array();
    1819    $this->HideMenu = false;
     
    2021  }
    2122
    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'))
    2526      return 'Nemáte oprávnění';
    2627    $this->System->FormManager->ShowRelation = true;
     
    7879  }
    7980
    80   function Dashboard()
     81  function Dashboard(): string
    8182  {
    8283    $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)
    8485    {
    8586      if (is_string($Item['Callback'][0]))
     
    9394  }
    9495
    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'].')');
    9899    if ($DbResult->num_rows > 0)
    99100    {
     
    101102    } else
    102103    {
    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']));
    104105      $Output = $this->SystemMessage('Oblíbené', 'Přidáno do oblíbených');
    105106    }
     
    108109  }
    109110
    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'].')');
    113114    if ($DbResult->num_rows > 0)
    114115    {
     
    124125  }
    125126
    126   function LogChange($Form, $Action, $NewId, $OldId)
     127  function LogChange(Form $Form, string $Action, string $NewId, string $OldId): void
    127128  {
    128129    $Values = $Form->Definition['Table'].' (Id: '.$OldId.' => '.$NewId.'):'."\n";
     
    152153      }
    153154    }
    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
    158159  {
    159160    $Output = '';
    160161    if (!array_key_exists($Table, $this->System->FormManager->Classes))
    161162      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'))
    163164      return $this->SystemMessage('Oprávnění', 'Nemáte oprávnění');
    164165    if (array_key_exists('o', $_GET))
     
    226227  }
    227228
    228   function ShowDelete($Table, $Id)
     229  function ShowDelete(string $Table, string $Id): string
    229230  {
    230231    $Output = '';
     
    232233      return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena');
    233234    $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'))
    235236      return 'Nemáte oprávnění';
    236237    $DbResult = $this->Database->select($Table, '*', '`Id`='.$Id);
     
    266267  }
    267268
    268   function ShowAdd($Table, $Actions = array())
     269  function ShowAdd(string $Table, array $Actions = array()): string
    269270  {
    270271    $Output = '';
    271272    if (!array_key_exists($Table, $this->System->FormManager->Classes))
    272273      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'))
    274275      return 'Nemáte oprávnění';
    275276    if (array_key_exists('o', $_GET))
     
    315316
    316317        //$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'],
    318319        //  'TimeCreate' => 'NOW()'));
    319320        } catch (Exception $E)
     
    357358  }
    358359
    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'))
    362363      return 'Nemáte oprávnění';
    363364    $this->BasicHTML = true;
     
    367368  }
    368369
    369   function ShowTabs($Tabs, $QueryParamName, $TabContent)
     370  function ShowTabs(array $Tabs, string $QueryParamName, string $TabContent): string
    370371  {
    371372    $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
     
    388389  }
    389390
    390   function ShowView($Table, $Id, $WithoutActions = false)
     391  function ShowView(string $Table, string $Id, bool $WithoutActions = false): string
    391392  {
    392393    if (!array_key_exists($Table, $this->System->FormManager->Classes))
    393394      return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena');
    394395    $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'))
    396397      return 'Nemáte oprávnění';
    397398
     
    473474  }
    474475
    475   function ShowTable($Table, $Filter = '', $Title = '', $RowActions = array(), $ExcludeColumn = '')
     476  function ShowTable(string $Table, string $Filter = '', string $Title = '', string $RowActions = '', string $ExcludeColumn = ''): string
    476477  {
    477478    if (!array_key_exists($Table, $this->System->FormManager->Classes))
     
    673674  }
    674675
    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'))
    678679      return 'Nemáte oprávnění';
    679680    $this->BasicHTML = true;
     
    686687  }
    687688
    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'))
    691692      return 'Nemáte oprávnění';
    692693    $Map = new MapOpenStreetMaps($this->System);
     
    701702  }
    702703
    703   function ShowList($Table, $Filter = '', $Title = '', $ExcludeColumn = '', $ExcludeValue = '')
     704  function ShowList(string $Table, string $Filter = '', string $Title = '', string $ExcludeColumn = '', string $ExcludeValue = ''): string
    704705  {
    705706    $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'))
    707708      return 'Nemáte oprávnění';
    708709    if (!array_key_exists($Table, $this->System->FormManager->Classes))
     
    738739    if (array_key_exists('mi', $_GET))
    739740    {
    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'].')');
    741742      if ($DbResult->num_rows > 0)
    742743      {
     
    761762  }
    762763
    763   function ShowFavorites()
     764  function ShowFavorites(): string
    764765  {
    765766    $this->MenuItems = array();
     
    768769      'LEFT JOIN `Action` ON `Action`.`Id` = `MenuItem`.`Action` '.
    769770      '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'].' '.
    771772      'ORDER BY `MenuItem`.`Parent`,`MenuItem`.`Name`');
    772773    while ($DbRow = $DbResult->fetch_assoc())
     
    778779  }
    779780
    780   function ShowMenu()
     781  function ShowMenu(): string
    781782  {
    782783    $this->MenuItems = array();
     
    794795  }
    795796
    796   function ShowMenuItem($Parent, $All = false)
     797  function ShowMenuItem(string $Parent, bool $All = false): string
    797798  {
    798799    $Output = '<ul style="list-style: none; margin-left:1em; padding-left:0em;">';
     
    810811        if ($MenuItem['IconName'] != '') $Image = '<img src="'.$this->System->Link('/images/favicons/'.$MenuItem['IconName']).'"/>&nbsp;';
    811812          else $Image = '<img src="'.$this->System->Link('/images/favicons/'.$Icon).'"/>&nbsp;';
    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'))
    813814          $Output .= '<li>'.$Image.$LinkTitle.'</li>';
    814815        if ($All == false) $Output .= $this->ShowMenuItem($MenuItem['Id']);
     
    819820  }
    820821
    821   function TableToModule($Table)
     822  function TableToModule(string $Table): string
    822823  {
    823824    $DbResult = $this->Database->query('SELECT (SELECT `Name` FROM `Module` '.
     
    830831  }
    831832
    832   function ShowAction($Name, $Target, $Icon, $Confirm = '')
     833  function ShowAction(string $Name, string $Target, string $Icon, string $Confirm = ''): string
    833834  {
    834835    $Output = '<img alt="'.$Name.'" title="'.$Name.'" src="'.
     
    846847  var $DashboardItems;
    847848
    848   function __construct($System)
     849  function __construct(System $System)
    849850  {
    850851    parent::__construct($System);
     
    855856    $this->License = 'GNU/GPLv3';
    856857    $this->Description = 'User interface for generic information system';
    857     $this->Dependencies = array();
     858    $this->Dependencies = array('User');
    858859
    859860    $this->DashboardItems = array();
    860861  }
    861862
    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');
    873874    $this->System->FormManager->RegisterClass('MenuItem', array(
    874875      'Title' => 'Položky nabídky',
     
    914915  }
    915916
    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
    921922  {
    922923    $this->DashboardItems[$Name] = array('Callback' => $Callback);
    923924  }
    924925
    925   function UnregisterDashboardItem($Name)
     926  function UnregisterDashboardItem(string $Name): void
    926927  {
    927928    unset($this->DashboardItems[$Name]);
    928929  }
     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  }
    929939}
  • trunk/Modules/Log/Log.php

    r874 r887  
    33class ModuleLog extends AppModule
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1414  }
    1515
    16   function DoInstall()
     16  function DoInstall(): void
    1717  {
    1818  }
    1919
    20   function DoUnInstall()
     20  function DoUnInstall(): void
    2121  {
    2222  }
    2323
    24   function DoStart()
     24  function DoStart(): void
    2525  {
    2626    $this->System->FormManager->RegisterClass('Log', array(
     
    3838      ),
    3939    ));
    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'),
    4242      'Permission' => array('Module' => 'Log', 'Operation' => 'RSS')));
    4343  }
    4444
    45   function DoStop()
     45  function DoStop(): void
    4646  {
    4747  }
    4848
    49   function NewRecord($Module, $Operation, $Value = '')
     49  function NewRecord(string $Module, string $Operation, string $Value = ''): void
    5050  {
    51     if (array_key_exists('User', $this->System->ModuleManager->Modules) and
    52       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'];
    5454      else $UserId = NULL;
    5555    if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IPAddress = $_SERVER['REMOTE_ADDR'];
     
    6060  }
    6161
    62   function ShowRSS()
     62  function ShowRSS(): string
    6363  {
    6464    $this->ClearPage = true;
     
    9898    return $RSS->Generate();
    9999  }
     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  }
    100109}
  • trunk/Modules/Map/Map.php

    r874 r887  
    55class PageNetworkMap extends Page
    66{
    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  }
    1014  //var $Load = 'initialize()';
    1115  //var $Unload = 'GUnload()';
    1216
    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'))
    1620      return 'Nemáte oprávnění';
    1721
     
    2327  }
    2428
    25   function ShowPosition()
     29  function ShowPosition(): string
    2630  {
    2731    $DbResult = $this->Database->select('MapPosition', '*', '`Id`='.$_GET['i']);
     
    4448  }
    4549
    46   function ShowMain()
     50  function ShowMain(): string
    4751  {
    4852    $Map = new MapOpenStreetMaps($this->System);
     
    242246class TypeMapPosition extends TypeString
    243247{
    244   function OnEdit($Item)
     248  function OnEdit(array $Item): string
    245249  {
    246250    $Output = parent::OnEdit($Item);
     
    255259class ModuleMap extends AppModule
    256260{
    257   function __construct($System)
     261  function __construct(System $System)
    258262  {
    259263    parent::__construct($System);
     
    263267    $this->License = 'GNU/GPL';
    264268    $this->Description = 'Show objects on Google maps';
    265     $this->Dependencies = array('Network');
     269    $this->Dependencies = array('Network', 'User');
    266270    $this->SupportedModels = array();
    267271  }
    268272
    269   function DoStart()
     273  function DoStart(): void
    270274  {
    271275    $this->System->Pages['map'] = 'PageNetworkMap';
     
    310314  }
    311315
    312   function DoInstall()
     316  function DoInstall(): void
    313317  {
    314318    $this->System->Database->query("CREATE TABLE IF NOT EXISTS `MapPosition` (
     
    320324  }
    321325
    322   function DoUninstall()
     326  function DoUninstall(): void
    323327  {
    324328    $this->Database->query('DROP TABLE `MapPosition`');
  • trunk/Modules/Map/MapAPI.php

    r874 r887  
    33class MapMarker
    44{
    5   var $Position;
    6   var $Text;
     5  public array $Position;
     6  public string $Text;
    77}
    88
    99class MapPolyLine
    1010{
    11   var $Points = array();
    12   var $Color = 'black';
     11  public array $Points = array();
     12  public string $Color = 'black';
    1313}
    1414
    1515class Map extends Model
    1616{
    17   var $Position;
    18   var $Zoom;
    19   var $Key;
     17  public array $Position;
     18  public int $Zoom;
     19  public string $Key;
    2020  var $OnClickObject;
    21   var $MarkerText;
    22   var $Markers;
    23   var $PolyLines;
     21  public string $MarkerText;
     22  public array $Markers;
     23  public array $PolyLines;
    2424
    25   function __construct($System)
     25  function __construct(System $System)
    2626  {
    2727    parent::__construct($System);
     
    3535  }
    3636
    37   function Show()
     37  function Show(): string
    3838  {
    3939    return '';
     
    4343class MapGoogle extends Map
    4444{
    45   function ShowPage($Page)
     45  function ShowPage(Page $Page): string
    4646  {
    4747    $Page->Load = 'initialize()';
     
    113113class MapOpenStreetMaps extends Map
    114114{
    115   function GetPageHeader()
     115  function GetPageHeader(): string
    116116  {
    117117    $Output = '<link rel="stylesheet" href="https://unpkg.com/leaflet@1.5.1/dist/leaflet.css"
     
    124124  }
    125125
    126   function ShowPage($Page)
     126  function ShowPage(Page $Page): string
    127127  {
    128128    $this->System->PageHeaders[] = array($this, 'GetPageHeader');
  • trunk/Modules/Meals/Meals.php

    r874 r887  
    33class PageEatingPlace extends Page
    44{
    5   var $FullTitle = 'Jídleníček jídelny Na kopečku';
    6   var $ShortTitle = 'Jídelníček';
    7   var $ParentClass = 'PagePortal';
    85  var $DayNames = array('Neděle', 'Pondělí', 'Úterý', 'Středa', 'Čtvrtek', 'Pátek', 'Sobota');
    96  var $DayNamesShort = array('NE', 'PO', 'ÚT', 'ST', 'ČT', 'PÁ', 'SO');
     
    118  var $DayCount = 20;    // počet dopředu zobrazených dnů
    129
    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
    1419  {
    1520    if (count($this->System->PathItems) > 1)
     
    2126  }
    2227
    23   function ShowMenu()
     28  function ShowMenu(): string
    2429  {
    2530    //echo('Dnes je '.HumanDate(date('Y-m-d')).'<br>');
     
    4348  }
    4449
    45   function ShowPrint()
     50  function ShowPrint(): string
    4651  {
    4752    $this->ClearPage = true;
     
    9499  }
    95100
    96   function PrintTableRow($Row)
     101  function PrintTableRow(array $Row): string
    97102  {
    98103    global $LastWeekOfYear;
     
    120125  }
    121126
    122   function ShowEdit()
     127  function ShowEdit(): string
    123128  {
    124129    Header('Cache-Control: no-cache');
     
    136141        }
    137142        $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');
    139144      }
    140145      if ($_GET['action'] == 'saveinfo')
     
    143148        $this->Database->insert('MealsInfo', array('Info' => $_POST['info'], 'Price' => $_POST['price']));
    144149        $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');
    146151      }
    147152    }
     
    179184class ModuleMeals extends AppModule
    180185{
    181   function __construct($System)
     186  function __construct(System $System)
    182187  {
    183188    parent::__construct($System);
     
    191196  }
    192197
    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');
    204209  }
    205210}
  • trunk/Modules/Meteostation/Meteostation.php

    r874 r887  
    33class PageMeteo extends Page
    44{
    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  }
    812
    9   function Show()
     13  function Show(): string
    1014  {
    1115    $Output = 'Stav meteostanice:<br/>';
     
    2226  var $URL;
    2327
    24   function DownloadData()
     28  function DownloadData(): void
    2529  {
    2630    $XmlData = simplexml_load_file($this->URL);
     
    5054  }
    5155
    52   function CreateImage($FileName)
     56  function CreateImage($FileName): void
    5357  {
    5458    $Image = new Image();
     
    6367  }
    6468
    65   function LoadFromDb()
     69  function LoadFromDb(): void
    6670  {
    6771    $DbResult = $this->Database->select('Meteostation', '*', 'Id = '.$this->Id);
     
    7781  var $Data;
    7882
    79   function __construct($System)
     83  function __construct(System $System)
    8084  {
    8185    parent::__construct($System);
     
    8892  }
    8993
    90   function DownloadAll()
     94  function DownloadAll(): void
    9195  {
    9296    $DbResult = $this->Database->select('MeteoStation', '*');
    9397    while ($DbRow = $DbResult->fetch_assoc())
    9498    {
    95       $MeteoStation = new MeteoStation();
     99      $MeteoStation = new MeteoStation($this->System);
    96100      $MeteoStation->Id = $DbRow['Id'];
    97101      $MeteoStation->LoadFromDb();
     
    102106
    103107
    104   function DoInstall()
     108  function DoInstall(): void
    105109  {
    106110  }
    107111
    108   function DoUninstall()
     112  function DoUninstall(): void
    109113  {
    110114  }
    111115
    112   function DoStart()
     116  function DoStart(): void
    113117  {
    114     $this->System->RegisterPage('meteo', 'PageMeteo');
     118    $this->System->RegisterPage(['meteo'], 'PageMeteo');
    115119  }
    116120
    117   function DoStop()
     121  function DoStop(): void
    118122  {
    119123  }
  • trunk/Modules/Network/HostList.php

    r874 r887  
    55class PageHostList extends Page
    66{
    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  }
    1014
    11   function Show()
     15  function Show(): string
    1216  {
    13     if (!$this->System->User->CheckPermission('Network', 'ShowHostList'))
     17    if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Network', 'ShowHostList'))
    1418      return 'Nemáte oprávnění';
    1519
  • trunk/Modules/Network/Hosting.php

    r874 r887  
    33class PageHosting extends Page
    44{
    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  }
    812
    9   function Show()
     13  function Show(): string
    1014  {
    1115    $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  
    88class PageFrequencyPlan extends Page
    99{
    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
    1519  {
    1620    // http://en.wikipedia.org/wiki/List_of_WLAN_channels
     
    7579class PageNetwork extends Page
    7680{
    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'))
    9392      return 'Nemáte oprávnění';
    9493
     
    102101class ModuleNetwork extends AppModule
    103102{
    104   var $MinNotifyTime;
    105 
    106   function __construct($System)
     103  public int $MinNotifyTime;
     104
     105  function __construct(System $System)
    107106  {
    108107    parent::__construct($System);
     
    112111    $this->License = 'GNU/GPLv3';
    113112    $this->Description = 'Networking related tools';
    114     $this->Dependencies = array('Notify');
     113    $this->Dependencies = array('Notify', 'IS');
    115114
    116115    // TODO: Make notify time configurable
     
    118117  }
    119118
    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',
    131130      array($this, 'ReachabilityCheck'));
    132     $this->System->ModuleManager->Modules['Notify']->RegisterCheck('NetworkPort',
     131    ModuleNotify::Cast($this->System->GetModule('Notify'))->RegisterCheck('NetworkPort',
    133132      array($this, 'PortCheck'));
    134133
    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'));
    144143
    145144    $this->System->FormManager->RegisterClass('NetworkDomainAlias', array(
     
    750749    ));
    751750
    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'));
    754753
    755754    $this->System->RegisterModel('NetworkDevice', array(
     
    761760  }
    762761
    763   function AfterInsertNetworkDevice($Form)
     762  function AfterInsertNetworkDevice(Form $Form): void
    764763  {
    765764    $this->System->Models['NetworkDevice']->DoOnChange();
    766765  }
    767766
    768   function AfterModifyNetworkDevice($Form, $Id)
     767  function AfterModifyNetworkDevice(Form $Form, string $Id): void
    769768  {
    770769    $this->System->Models['NetworkDevice']->DoOnChange();
    771770  }
    772771
    773   function AfterInsertNetworkInterface($Form)
     772  function AfterInsertNetworkInterface(Form $Form): void
    774773  {
    775774    $this->System->Models['NetworkInterface']->DoOnChange();
    776775  }
    777776
    778   function AfterModifyNetworkInterface($Form, $Id)
     777  function AfterModifyNetworkInterface(Form $Form, string $Id): void
    779778  {
    780779    $this->System->Models['NetworkInterface']->DoOnChange();
    781780  }
    782781
    783   function BeforeDeleteNetworkInterface($Form, $Id)
     782  function BeforeDeleteNetworkInterface(Form $Form, string $Id): void
    784783  {
    785784    $this->Database->query('DELETE FROM `NetworkInterfaceUpDown` WHERE `Interface`='.$Id);
     
    791790  }
    792791
    793   function ImportNetworkLog($Parameters)
     792  function ImportNetworkLog(array $Parameters): void
    794793  {
    795794    global $Config;
     
    813812      {
    814813        $DbRow2 = $DbResult2->fetch_assoc();
    815         $DeviceID = $DbRow2['Device'];
     814        $DeviceId = $DbRow2['Device'];
    816815        $this->System->Database->insert('NetworkDeviceLog', array('Time' => $DbRow['ReceivedAt'],
    817816          'Device' => $DeviceId, 'Message' => $DbRow['Message'], 'Tags' => $DbRow['SysLogTag']));
     
    820819  }
    821820
    822   function ShowDashboardItem()
     821  function ShowDashboardItem(): string
    823822  {
    824823    $Output = '';
     
    841840  }
    842841
    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
    848847  {
    849848    $Time = time();
     
    886885  }
    887886
    888   function ReachabilityCheck()
     887  function ReachabilityCheck(): array
    889888  {
    890889    $NewOnline = $this->OnlineList('Nově online', 1, 0, 0);
     
    898897  }
    899898
    900   function PortCheckList($Title, $OnlineNow, $OnlinePrevious, $MinDuration)
     899  function PortCheckList(string $Title, string $OnlineNow, string $OnlinePrevious, int $MinDuration): array
    901900  {
    902901    $Time = time();
     
    937936  }
    938937
    939   function PortCheck()
     938  function PortCheck(): array
    940939  {
    941940    $Output = '';
  • trunk/Modules/Network/Subnet.php

    r874 r887  
    33class PageSubnet extends Page
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1111  }
    1212
    13   function Show()
     13  function Show(): string
    1414  {
    1515    $DbResult = $this->Database->query('SELECT COUNT(*) FROM `NetworkSubnet`');
  • trunk/Modules/Network/UserHosts.php

    r874 r887  
    33class PageNetworkHostList extends Page
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1111  }
    1212
    13   function Show()
     13  function Show(): string
    1414  {
    1515    global $Config;
    1616
    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');
    1818    $Output = '<div align="center" style="font-size: small;"><table class="WideTable">';
    1919    $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>';
    2020    $DbResult = $this->Database->query('SELECT NetworkDevice.*, NetworkDeviceType.Name AS HostType FROM NetworkDevice '.
    2121      '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');
    2323    while ($Device = $DbResult->fetch_assoc())
    2424    {
  • trunk/Modules/NetworkConfig/Generate.php

    r873 r887  
    22
    33if (isset($_SERVER['REMOTE_ADDR'])) die();
    4 include_once(dirname(__FILE__).'/../../Application/System.php');
     4include_once(dirname(__FILE__).'/../../Application/Core.php');
    55$System = new Core();
    66$System->ShowPage = false;
  • trunk/Modules/NetworkConfig/NetworkConfig.php

    r874 r887  
    55  var $ConfigItems;
    66
    7   function __construct($System)
     7  function __construct(System $System)
    88  {
    99    parent::__construct($System);
     
    1717  }
    1818
    19   function DoInstall()
     19  function DoInstall(): void
    2020  {
    2121  }
    2222
    23   function DoUnInstall()
     23  function DoUnInstall(): void
    2424  {
    2525  }
    2626
    27   function DoStart()
     27  function DoStart(): void
    2828  {
    2929    $this->System->FormManager->RegisterClass('NetworkConfiguration', array(
     
    5555      'States' => array('Neplánováno', 'V plánu', 'Provádí se'),
    5656    ));
    57    
    58     $this->System->RegisterCommandLine('config', array($this, 'Config'));
     57
     58    $this->System->RegisterCommandLine('config', 'Configures network services.', array($this, 'Config'));
    5959    $this->System->Models['NetworkDevice']->RegisterOnChange('NetworkConfig', array($this, 'DoNetworkChange'));
    6060    $this->System->Models['NetworkInterface']->RegisterOnChange('NetworkConfig', array($this, 'DoNetworkChange'));
    6161  }
    62  
    63   function DoNetworkChange()
     62
     63  function DoNetworkChange(): void
    6464  {
    6565    $this->Database->query('UPDATE `NetworkConfiguration` SET `Changed`=1 WHERE '.
     
    6767  }
    6868
    69   function RegisterConfigItem($Name, $ClassName)
     69  function RegisterConfigItem(string $Name, string $ClassName): void
    7070  {
    7171    $this->ConfigItems[$Name] = $ClassName;
    7272  }
    7373
    74   function UnregisterConfigItem($Name)
     74  function UnregisterConfigItem(string $Name): void
    7575  {
    7676    unset($this->ConfigItems[$Name]);
    7777  }
    7878
    79   function Config($Parameters)
     79  function Config(array $Parameters): void
    8080  {
    8181    $Output = '';
     
    9090      } else $Output = 'Config item '.$ConfigItemName.' not found';
    9191    } 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));
    93102  }
    94103}
     
    96105class NetworkConfigItem extends Model
    97106{
    98   function Run()
     107  function Run(): void
    99108  {
    100 
    101109  }
    102110}
  • trunk/Modules/NetworkConfigAirOS/Generators/Signal.php

    r873 r887  
    55class ConfigAirOSSignal extends NetworkConfigItem
    66{
    7   function ReadWirelessRegistration()
     7  function ReadWirelessRegistration(): void
    88  {
    99    $Time = time();
     
    1919      //$SSHClient->Debug = true;
    2020      $Result = $SSHClient->Execute('wstalist');
    21       if (count($Result) > 0) 
    22       {     
     21      if (count($Result) > 0)
     22      {
    2323      //print_r($Result);
    2424      $Array = json_decode(implode("\n", $Result), true);
     
    4444      echo("\n");
    4545      } else echo("Empty response\n");
    46      
    4746    }
    4847  }
    4948
    50   function Run()
     49  function Run(): void
    5150  {
    5251    RepeatFunction(60 * 60, array($this, 'ReadWirelessRegistration'));
  • trunk/Modules/NetworkConfigAirOS/NetworkConfigAirOS.php

    r781 r887  
    55class ModuleNetworkConfigAirOS extends AppModule
    66{
    7   function __construct($System)
     7  function __construct(System $System)
    88  {
    99    parent::__construct($System);
     
    1616  }
    1717
    18   function DoInstall()
     18  function DoInstall(): void
    1919  {
    2020  }
    2121
    22   function DoUnInstall()
     22  function DoUnInstall(): void
    2323  {
    2424  }
    2525
    26   function DoStart()
     26  function DoStart(): void
    2727  {
    28     $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('airos-signal', 'ConfigAirOSSignal');
     28    ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('airos-signal', 'ConfigAirOSSignal');
    2929  }
    3030}
  • trunk/Modules/NetworkConfigLinux/Generators/CheckPorts.php

    r874 r887  
    33class ConfigCheckPorts extends NetworkConfigItem
    44{
    5   function CheckPortStatus($IP, $Port, $Protocol = 'tcp')
     5  function CheckPortStatus($IP, $Port, $Protocol = 'tcp'): int
    66  {
    77    $Timeout = 1;
     
    1717    return $State;
    1818  }
    19  
    20   function CheckPorts()
     19
     20  function CheckPorts(): void
    2121  {
    2222    $StartTime = time();
     
    7777  }
    7878
    79   function Run()
     79  function Run(): void
    8080  {
    8181    RepeatFunction(60, array($this, 'CheckPorts'));
  • trunk/Modules/NetworkConfigLinux/Generators/DNS.php

    r873 r887  
    77class ConfigDNS extends NetworkConfigItem
    88{
    9   function GenerateDNS($DNS)
     9  function GenerateDNS(array $DNS): void
    1010  {
    1111    $Output = '$ORIGIN '.$DNS['Domain'].'.'."\n".
     
    147147  }
    148148
    149   function Run()
     149  function Run(): void
    150150  {
    151151    $BaseDomain = 'zdechov.net';
  • trunk/Modules/NetworkConfigLinux/Generators/Latency.php

    r873 r887  
    33class ConfigLatency extends NetworkConfigItem
    44{
    5   function PingHosts()
     5  function PingHosts(): void
    66  {
    77    $Timeout = 2000; // ms
     
    2323
    2424    $Queries = array();
    25     foreach ($Output as $Index => $Line) 
     25    foreach ($Output as $Index => $Line)
    2626    {
    2727      $IP = substr($Line, 0, strPos($Line, ' '));
     
    3535  }
    3636
    37   function Run()
     37  function Run(): void
    3838  {
    3939    RepeatFunction(10 * 60, array($this, 'PingHosts'));
  • trunk/Modules/NetworkConfigLinux/NetworkConfigLinux.php

    r824 r887  
    77class ModuleNetworkConfigLinux extends AppModule
    88{
    9   function __construct($System)
     9  function __construct(System $System)
    1010  {
    1111    parent::__construct($System);
     
    1818  }
    1919
    20   function DoInstall()
     20  function DoInstall(): void
    2121  {
    2222  }
    2323
    24   function DoUnInstall()
     24  function DoUnInstall(): void
    2525  {
    2626  }
    2727
    28   function DoStart()
     28  function DoStart(): void
    2929  {
    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');
    3333  }
    3434}
  • trunk/Modules/NetworkConfigRouterOS/Generators/DHCP.php

    r873 r887  
    44class ConfigRouterOSDHCP extends NetworkConfigItem
    55{
    6   function Run()
     6  function Run(): void
    77  {
    88    $Path = array('ip', 'dhcp-server', 'lease');
  • trunk/Modules/NetworkConfigRouterOS/Generators/DNS.php

    r873 r887  
    33class ConfigRouterOSDNS extends NetworkConfigItem
    44{
    5   function Run()
     5  function Run(): void
    66  {
    77    $Path = array('ip', 'dns', 'static');
  • trunk/Modules/NetworkConfigRouterOS/Generators/FirewallFilter.php

    r873 r887  
    33class ConfigRouterOSFirewallFilter extends NetworkConfigItem
    44{
    5   function Run()
     5  function Run(): void
    66  {
    77    $Path = array('ip', 'firewall', 'filter');
  • trunk/Modules/NetworkConfigRouterOS/Generators/FirewallMangle.php

    r873 r887  
    33class ConfigRouterOSFirewallMangle extends NetworkConfigItem
    44{
    5   function ProcessNode($Node)
     5  function ProcessNode($Node): void
    66  {
    77    global $InetInterface, $ItemsFirewall;
    88
    9     foreach ($Node['Items'] as $Index => $Item)
     9    foreach ($Node['Items'] as $Item)
    1010    {
    1111      if (count($Item['Items']) == 0)
     
    4747  }
    4848
    49   function Run()
     49  function Run(): void
    5050  {
    5151    $this->RunIPv4();
     
    5353  }
    5454
    55   function RunIPv4()
     55  function RunIPv4(): void
    5656  {
    5757    global $ItemsFirewall;
     
    149149  }
    150150
    151   function RunIPv6()
     151  function RunIPv6(): void
    152152  {
    153153    global $ItemsFirewall;
  • trunk/Modules/NetworkConfigRouterOS/Generators/FirewallNAT.php

    r873 r887  
    33class ConfigRouterOSFirewallNAT extends NetworkConfigItem
    44{
    5   function Run()
     5  function Run(): void
    66  {
    77    $Path = array('ip', 'firewall', 'nat');
  • trunk/Modules/NetworkConfigRouterOS/Generators/Netwatch.php

    r873 r887  
    33class ConfigRouterOSNetwatch extends NetworkConfigItem
    44{
    5   function Run()
     5  function Run(): void
    66  {
    77    $Path = array('tool', 'netwatch');
  • trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php

    r873 r887  
    33class ConfigRouterOSNetwatchImport extends NetworkConfigItem
    44{
    5   function NetwatchImport()
     5  function NetwatchImport(): void
    66  {
    77    $StartTime = time();
     
    4444    $Queries = array();
    4545    $QueriesInsert = array();
    46     foreach ($Interfaces as $Index => $Interface)
     46    foreach ($Interfaces as $Interface)
    4747    {
    4848      // Update last online time if still online
     
    103103  }
    104104
    105   function Run()
     105  function Run(): void
    106106  {
    107107    RepeatFunction(10, array($this, 'NetwatchImport'));
  • trunk/Modules/NetworkConfigRouterOS/Generators/Queue.php

    r873 r887  
    1414  }
    1515
    16   function Print()
     16  function Print(): string
    1717  {
    1818    $Output = '(Min: '.$this->Min.' Max: '.$this->Max;
     
    4646  }
    4747
    48   function CheckName($Name, &$UsedNames)
     48  function CheckName($Name, &$UsedNames): void
    4949  {
    5050    if (in_array($Name, $UsedNames)) die("\n".'Duplicate name: '.$Name);
     
    5252  }
    5353
    54   function GetCommands(&$UsedNames = null)
     54  function GetCommands(&$UsedNames = null): array
    5555  {
    5656    if ($UsedNames == null) $UsedNames = array();
     
    7272  }
    7373
    74   function GetParentName(string $Suffix)
     74  function GetParentName(string $Suffix): string
    7575  {
    7676    if ($this->Parent != null) return $this->Parent->Name.$Suffix;
     
    7878  }
    7979
    80   function UpdateMinSpeeds()
     80  function UpdateMinSpeeds(): void
    8181  {
    8282    if (($this->LimitIn->Min == 0) or ($this->LimitOut->Min == 0))
     
    100100class SpeedLimitItems extends GenericList
    101101{
    102   function AddNew(string $Name, SpeedLimitItem $Parent = null)
     102  function AddNew(string $Name, SpeedLimitItem $Parent = null): SpeedLimitItem
    103103  {
    104104    $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);
    107107    $this->Items[] = $Item;
    108108    return $Item;
     
    119119  }
    120120
    121   function GetCommands(&$UsedNames)
     121  function GetCommands(&$UsedNames): array
    122122  {
    123123    $Output = array();
     
    137137  var $SpeedLimits;
    138138
    139   function Run()
     139  function Run(): void
    140140  {
    141141    $PathQueue = array('queue', 'tree');
     
    149149    $this->UsedNames = array();
    150150
    151     $Finance = &$this->System->Modules['Finance'];
     151    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    152152    $Finance->LoadMonthParameters(0);
    153153
     
    280280  }
    281281
    282   function BuildSpeedLimit(&$SpeedLimit, $TopSpeedLimitItem)
     282  function BuildSpeedLimit(&$SpeedLimit, $TopSpeedLimitItem): void
    283283  {
    284284    $SpeedLimitName = $SpeedLimit['Name'].'-grp';
     
    297297  }
    298298
    299   function LoadSpeedLimits($SpeedLimitItem)
     299  function LoadSpeedLimits($SpeedLimitItem): void
    300300  {
    301301    echo('Limit groups: ');
     
    326326  }
    327327
    328   function UpdateMinSpeed($DeviceId)
     328  function UpdateMinSpeed($DeviceId): void
    329329  {
    330330    $MinSpeed = 0;
     
    340340
    341341  // 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
    343343  {
    344344    // Load network devices
     
    438438  }
    439439
    440   function BuildQueueItems($DeviceId, $SpeedLimitParent)
     440  function BuildQueueItems($DeviceId, $SpeedLimitParent): void
    441441  {
    442442    $Device = $this->Devices[$DeviceId];
     
    475475  }
    476476
    477   function RunTopology()
     477  function RunTopology(): void
    478478  {
    479479    $PathQueue = array('queue', 'tree');
     
    487487    $this->UsedNames = array();
    488488
    489     $Finance = &$this->System->Modules['Finance'];
     489    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    490490    $Finance->LoadMonthParameters(0);
    491491
  • trunk/Modules/NetworkConfigRouterOS/Generators/Signal.php

    r874 r887  
    33class ConfigRouterOSSignal extends NetworkConfigItem
    44{
    5   function ReadWirelessRegistration()
     5  function ReadWirelessRegistration(): void
    66  {
    77    $Time = time();
     
    6666    $this->Database->Transaction($Queries);
    6767  }
    68  
    69   function StripUnits($Value)
     68
     69  function StripUnits($Value): string
    7070  {
    7171    if (strpos($Value, '-') !== false) $Value = substr($Value, 0, strpos($Value, '-') - 1); // without channel info
    7272    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
    7575    if (substr($Value, -1, 1) == "M") $Value = substr($Value, 0, -1); // without M unit
    7676    return $Value;
    7777  }
    7878
    79   function Run()
     79  function Run(): void
    8080  {
    8181    RepeatFunction(60 * 60, array($this, 'ReadWirelessRegistration'));
  • trunk/Modules/NetworkConfigRouterOS/NetworkConfigRouterOS.php

    r874 r887  
    1818class ModuleNetworkConfigRouterOS extends AppModule
    1919{
    20   function __construct($System)
     20  function __construct(System $System)
    2121  {
    2222    parent::__construct($System);
     
    2929  }
    3030
    31   function DoInstall()
     31  function DoInstall(): void
    3232  {
    3333  }
    3434
    35   function DoUnInstall()
     35  function DoUnInstall(): void
    3636  {
    3737  }
    3838
    39   function DoStart()
     39  function DoStart(): void
    4040  {
    4141    $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');
    5151  }
    5252}
     
    5454class PageFreeAccess extends Page
    5555{
    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;
    6158
    62   function __construct($System)
     59  function __construct(System $System)
    6360  {
    6461    parent::__construct($System);
     62    $this->FullTitle = 'Přístup zdarma k Internetu';
     63    $this->ShortTitle = 'Internet zdarma';
     64    $this->ParentClass = 'PagePortal';
     65
    6566    $this->Timeout = 24 * 60 * 60;
    6667  }
    6768
    68   function Show()
     69  function Show(): string
    6970  {
    7071    $IPAddress = GetRemoteAddress();
    7172    $Output = 'Vaše IP adresa je: '.$IPAddress.'<br/>';
    72     if (IsInternetAddr($IPAddress)) {
     73    if (IsInternetAddr($IPAddress))
     74    {
    7375      $Output .= '<p>Internet zdarma je dostupný pouze z vnitřní sítě.</p>';
    7476      return $Output;
     
    117119class ScheduleConfigureFreeAccess extends SchedulerTask
    118120{
    119   function Execute()
     121  function Execute(): string
    120122  {
    121123    $Output = '';
  • trunk/Modules/NetworkConfigRouterOS/Routerboard.php

    r874 r887  
    1919  }
    2020
    21   function Execute($Commands)
     21  function Execute(array $Commands): array
    2222  {
    2323    $Output = array();
     
    4444  }
    4545
    46   function ExecuteBatch($Commands)
     46  function ExecuteBatch(string $Commands): string
    4747  {
    4848    $Commands = trim($Commands);
     
    6565  }
    6666
    67   function ItemGet($Path)
     67  function ItemGet(array $Path): array
    6868  {
    6969    $Result = $this->Execute(implode(' ', $Path).' print');
     
    8282  }
    8383
    84   function ListGet($Path, $Properties, $Conditions = array())
     84  function ListGet(array $Path, array $Properties, array $Conditions = array()): array
    8585  {
    8686    $PropertyList = '"';
     
    116116  }
    117117
    118   function ListGetPrint($Path, $Properties, $Conditions = array())
     118  function ListGetPrint($Path, $Properties, $Conditions = array()): array
    119119  {
    120120    $ConditionList = '';
     
    151151  }
    152152
    153   function ListEraseAll($Path)
     153  function ListEraseAll(array $Path): void
    154154  {
    155155    $this->Execute(implode(' ', $Path).' { remove [find] }');
    156156  }
    157157
    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
    159159  {
    160160    // Get current list from routerboard
  • trunk/Modules/NetworkConfigRouterOS/Routerboard2.php

    r874 r887  
    1111  );
    1212
    13   function Execute($Commands)
     13  function Execute($Commands): array
    1414  {
    1515    if (is_array($Commands)) $Commands = implode(';', $Commands);
     
    1717  }
    1818
    19   function GetItem($Command)
     19  function GetItem($Command): array
    2020  {
    2121    $Result = $this->Execute($Command);
     
    2525    {
    2626      $ResultLineParts = explode(' ', trim($ResultLine));
    27       if ($ResultLineParts[1]{0} == '"') $ResultLineParts[1] = substr($ResultLineParts[1], 1, -1); // Remove quotes
     27      if ($ResultLineParts[1][0] == '"') $ResultLineParts[1] = substr($ResultLineParts[1], 1, -1); // Remove quotes
    2828      $List[substr($ResultLineParts[0], 0, -1)] = $ResultLineParts[1];
    2929    }
     
    3131  }
    3232
    33   function GetList($Command, $Properties)
     33  function GetList($Command, $Properties): array
    3434  {
    3535    $PropertyList = '"';
     
    5555  }
    5656
    57   function GetSystemResource()
     57  function GetSystemResource(): array
    5858  {
    5959    return $this->GetItem('/system resource print');
    6060  }
    6161
    62   function GetFirewallFilterList()
     62  function GetFirewallFilterList(): array
    6363  {
    6464    return $this->GetList('/ip firewall nat', array('src-address', 'dst-address', 'bytes'));
    6565  }
    6666
    67   function GetDHCPServerLeasesList()
     67  function GetDHCPServerLeasesList(): array
    6868  {
    6969    return $this->GetList('/ip dhcp-server lease', array('address', 'active-address', 'comment', 'lease-time', 'status', 'host-name'));
  • trunk/Modules/NetworkConfigRouterOS/RouterboardAPI.php

    r874 r887  
    2525  }
    2626
    27   function EncodeLength($Length)
    28   {
    29     if ($Length < 0x80) {
     27  function EncodeLength(int $Length): int
     28  {
     29    if ($Length < 0x80)
     30    {
    3031      $Length = chr($Length);
    31     } else if ($Length < 0x4000) {
     32    } else if ($Length < 0x4000)
     33    {
    3234      $Length |= 0x8000;
    3335      $Length = chr(($Length >> 8) & 0xFF).chr($Length & 0xFF);
    34     } else if ($Length < 0x200000) {
     36    } else if ($Length < 0x200000)
     37    {
    3538      $Length |= 0xC00000;
    3639      $Length = chr(($Length >> 16) & 0xFF).chr(($Length >> 8) & 0xFF).chr($Length & 0xFF);
    37     } else if ($Length < 0x10000000) {
     40    } else if ($Length < 0x10000000)
     41    {
    3842      $Length |= 0xE0000000;
    3943      $Length = chr(($Length >> 24) & 0xFF).chr(($Length >> 16) & 0xFF).chr(($Length >> 8) & 0xFF).chr($Length & 0xFF);
     
    4347  }
    4448
    45   function ConnectOnce($IP, $Login, $Password)
     49  function ConnectOnce(string $IP, string $Login, string $Password): void
    4650  {
    4751    if ($this->Connected) $this->Disconnect();
     
    6367  }
    6468
    65   function Connect($IP, $Login, $Password)
     69  function Connect(string $IP, string $Login, string $Password): bool
    6670  {
    6771    for ($Attempt = 1; $Attempt <= $this->Attempts; $Attempt++)
     
    7478  }
    7579
    76   function Disconnect()
     80  function Disconnect(): void
    7781  {
    7882    if ($this->Connected)
     
    8387  }
    8488
    85   function ParseResponse($Response)
    86   {
    87     if (is_array($Response)) {
     89  function ParseResponse(array $Response): array
     90  {
     91    if (is_array($Response))
     92    {
    8893      $Parsed      = array();
    8994      $Current     = null;
    9095      $SingleValue = null;
    9196      $count       = 0;
    92       foreach ($Response as $x) {
     97      foreach ($Response as $x)
     98      {
    9399        if (in_array($x, array(
    94100            '!fatal',
    95101            '!re',
    96102            '!trap'
    97         ))) {
    98           if ($x == '!re') {
     103        )))
     104        {
     105          if ($x == '!re')
     106          {
    99107            $Current =& $Parsed[];
    100108          } else
    101109            $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          {
    104114            if ($Matches[0][0] == 'ret') {
    105115              $SingleValue = $Matches[0][1];
     
    109119        }
    110120      }
    111       if (empty($Parsed) && !is_null($SingleValue)) {
     121      if (empty($Parsed) && !is_null($SingleValue))
     122      {
    112123        $Parsed = $SingleValue;
    113124      }
     
    117128  }
    118129
    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      {
    123136        $tmp = str_replace("-", "_", $k);
    124137        $tmp = str_replace("/", "_", $tmp);
    125         if ($tmp) {
     138        if ($tmp)
     139        {
    126140          $array_new[$tmp] = $v;
    127         } else {
     141        } else
     142        {
    128143          $array_new[$k] = $v;
    129144        }
    130145      }
    131146      return $array_new;
    132     } else {
     147    } else
     148    {
    133149      return $array;
    134150    }
    135151  }
    136152
    137   function Read($Parse = true)
     153  function Read(bool $Parse = true): array
    138154  {
    139155    $Line = '';
    140156    $Response = array();
    141     while (true) {
     157    while (true)
     158    {
    142159      // Read the first byte of input which gives us some or all of the length
    143160      // of the remaining reply.
     
    149166      // If the fourth bit is set, we need to remove anything left in the first byte
    150167      // 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        {
    153172          $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          {
    156177            $Length = (($Byte & 31) << 8) + ord(fread($this->Socket, 1));
    157178            $Length = ($Length << 8) + ord(fread($this->Socket, 1));
    158           } else {
    159             if (($Byte & 0xf0) == 0xe0) {
     179          } else
     180          {
     181            if (($Byte & 0xf0) == 0xe0)
     182            {
    160183              $Length = (($Byte & 15) << 8) + ord(fread($this->Socket, 1));
    161184              $Length = ($Length << 8) + ord(fread($this->Socket, 1));
    162185              $Length = ($Length << 8) + ord(fread($this->Socket, 1));
    163             } else {
     186            } else
     187            {
    164188              $Length = ord(fread($this->Socket, 1));
    165189              $Length = ($Length << 8) + ord(fread($this->Socket, 1));
     
    169193          }
    170194        }
    171       } else {
     195      } else
     196      {
    172197        $Length = $Byte;
    173198      }
    174199      // If we have got more characters to read, read them in.
    175       if ($Length > 0) {
     200      if ($Length > 0)
     201      {
    176202        $Line = '';
    177203        $RetLen = 0;
    178         while ($RetLen < $Length) {
     204        while ($RetLen < $Length)
     205        {
    179206          $ToRead = $Length - $RetLen;
    180207          $Line .= fread($this->Socket, $ToRead);
     
    196223  }
    197224
    198   function Write($Command, $Param2 = true)
     225  function Write(string $Command, bool $Param2 = true): bool
    199226  {
    200227    if ($Command)
    201228    {
    202229      $Data = explode("\n", $Command);
    203       foreach ($Data as $Com) {
     230      foreach ($Data as $Com)
     231      {
    204232        $Com = trim($Com);
    205233        fwrite($this->Socket, $this->EncodeLength(strlen($Com)).$Com);
    206234      }
    207       if (gettype($Param2) == 'integer') {
     235      if (gettype($Param2) == 'integer')
     236      {
    208237        fwrite($this->Socket, $this->EncodeLength(strlen('.tag='.$Param2)).'.tag='.$Param2.chr(0));
    209238      } else if (gettype($Param2) == 'boolean')
     
    214243  }
    215244
    216   function Comm($Com, $Arr = array())
     245  function Comm(string $Com, array $Arr = array()): array
    217246  {
    218247    $Count = count($Arr);
    219248    $this->write($Com, !$Arr);
    220249    $i = 0;
    221     foreach ($Arr as $k => $v) {
    222       switch ($k[0]) {
     250    foreach ($Arr as $k => $v)
     251    {
     252      switch ($k[0])
     253      {
    223254        case "?":
    224255          $el = "$k=$v";
  • trunk/Modules/NetworkShare/NetworkShare.php

    r738 r887  
    77class ModuleNetworkShare extends AppModule
    88{
    9   function __construct($System)
     9  function __construct(System $System)
    1010  {
    1111    parent::__construct($System);
     
    1818  }
    1919
    20   function DoInstall()
     20  function DoInstall(): void
    2121  {
    2222  }
    2323
    24   function DoUnInstall()
     24  function DoUnInstall(): void
    2525  {
    2626  }
    2727
    28   function DoStart()
     28  function DoStart(): void
    2929  {
    30     $this->System->RegisterPage('share', 'SharePage');
     30    $this->System->RegisterPage(['share'], 'SharePage');
    3131  }
    3232}
  • trunk/Modules/NetworkShare/SharePage.php

    r874 r887  
    33class SharePage extends Page
    44{
    5   var $FullTitle = 'Prohledávání sdílených souborů';
    6   var $ShortTitle = 'Sdílené soubory';
    7   var $ParentClass = 'PagePortal';
    85  var $Dependencies = array('Log');
    96  var $MaxNesting = 20; // Maximální vnoření
     
    2017  );
    2118
     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
    2227  function ShowTime()
    2328  {
     
    6671  }
    6772
    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í';
    7176
    7277    // If not only online checkbox checked
     
    102107    // Log search
    103108    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']);
    105110
    106111    // Zobrazení formuláře
  • trunk/Modules/NetworkTopology/NetworkTopology.php

    r874 r887  
    33class PageNetworkTopology extends Page
    44{
    5   var $FullTitle = 'Grafické zobrazení topologie sítě';
    6   var $ShortTitle = 'Topologie sítě';
    7   var $ParentClass = 'PagePortal';
    85  var $TopHostName = 'NIX-ROUTER';
    96
    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
    1116  {
    1217    if (count($this->System->PathItems) > 1)
     
    132137class ModuleNetworkTopology extends AppModule
    133138{
    134   function __construct($System)
     139  function __construct(System $System)
    135140  {
    136141    parent::__construct($System);
     
    143148  }
    144149
    145   function DoInstall()
     150  function DoInstall(): void
    146151  {
    147152  }
    148153
    149   function DoUnInstall()
     154  function DoUnInstall(): void
    150155  {
    151156  }
    152157
    153   function DoStart()
     158  function DoStart(): void
    154159  {
    155     $this->System->RegisterPage('topologie', 'PageNetworkTopology');
     160    $this->System->RegisterPage(['topologie'], 'PageNetworkTopology');
    156161  }
    157162}
  • trunk/Modules/News/Import/Vismo.php

    r878 r887  
    33class NewsSourceVismo extends NewsSource
    44{
    5   function Import()
     5  function Import(): string
    66  {
    77    $Output = parent::Import();
  • trunk/Modules/News/ImportKinoVatra.php

    r873 r887  
    11<?php
    22
    3 include_once(dirname(__FILE__).'/../../Application/System.php');
    4 $System = new System();
     3include_once(dirname(__FILE__).'/../../Application/Core.php');
     4$System = new Core();
    55$System->ShowPage = false;
    66$System->Run();
  • trunk/Modules/News/ImportTvBeskyd.php

    r873 r887  
    11<?php
    22
    3 include_once(dirname(__FILE__).'/../../Application/System.php');
     3include_once(dirname(__FILE__).'/../../Application/Core.php');
    44$System = new Core();
    55$System->ShowPage = false;
  • trunk/Modules/News/News.php

    r878 r887  
    1313class ModuleNews extends AppModule
    1414{
    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)
    1919  {
    2020    parent::__construct($System);
     
    2828  }
    2929
    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');
    4244    $this->System->FormManager->RegisterClass('News', array(
    4345      'Title' => 'Aktualita',
     
    8688    if ($this->System->ModuleManager->ModulePresent('Search'))
    8789    {
    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
    9395  {
    9496    $ItemCount = abs($ItemCount);
     
    98100    $Output = '<div class="NewsPanel"><div class="Title">'.$Row['Caption'];
    99101    $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))
    101103      $Output .= ' <a href="aktuality/?action=add&amp;category='.$Category.'">Přidat</a>';
    102104    $Output .= '</div></div><div class="Content">';
     
    139141  }
    140142
    141   function LoadSettingsFromCookies()
     143  function LoadSettingsFromCookies(): void
    142144  {
    143145    // Initialize default news setting
     
    163165  }
    164166
    165   function Show()
     167  function Show(): string
    166168  {
    167169    $Output = '';
     
    197199  }
    198200
    199   function ShowCustomizeMenu()
     201  function ShowCustomizeMenu(): string
    200202  {
    201203    $Output = '<form action="?Action=CustomizeNewsSave" method="post">';
     
    220222  }
    221223
    222   function CustomizeSave()
     224  function CustomizeSave(): void
    223225  {
    224226    $Checkbox = array('' => 0, 'on' => 1);
     
    245247  }
    246248
    247   function ModifyContent($Content)
     249  function ModifyContent(string $Content): string
    248250  {
    249251    $Result = '';
     
    254256    {
    255257      $I = strpos($Content, 'http://');
    256       if (($I > 0) and ($Content{$I - 1} != '"'))
     258      if (($I > 0) and ($Content[$I - 1] != '"'))
    257259      {
    258260        $Result .= substr($Content, 0, $I);
     
    272274    return $Result;
    273275  }
     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  }
    274285}
  • trunk/Modules/News/NewsPage.php

    r878 r887  
    33class PageNews extends Page
    44{
    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í';
    2517    else
    2618    {
     
    3527          else $Author = $Row['Name'];
    3628        $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'])))
    3831        {
    3932          $Output .= '<div class="Action">';
     
    4235          $Output .= '</div>';
    4336        }
    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 />';
    4538        if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';
    4639        if ($Row['Enclosure'] != '')
     
    5043          foreach ($Enclosures as $Enclosure)
    5144          {
    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>';
    5447          }
    5548        }
     
    6053  }
    6154
    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']))
    6761    {
    6862      $this->System->PageHeaders[] = array($this, 'GetPageHeader');
     
    7569      while ($DbRow = $DbResult->fetch_array())
    7670      {
    77         if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $DbRow['Id']))
     71        if ($User->CheckPermission('News', 'Insert', 'Group', $DbRow['Id']))
    7872        {
    7973          if ($DbRow['Id'] == $Category['Id']) $Selected = ' selected="1"';
     
    9690  }
    9791
    98   function ShowAdd2()
    99   {
     92  function ShowAdd2(): string
     93  {
     94    $User = &ModuleUser::Cast($this->System->GetModule('User'))->User;
    10095    $Output = '';
    10196    $RemoteAddr = GetRemoteAddress();
    10297    $Category = $this->GetCategory();
    103     if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
     98    if ($User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
    10499    {
    105100      // Process uploaded file
     
    110105        if (array_key_exists($EnclosureName, $_FILES) and ($_FILES[$EnclosureName]['name'] != ''))
    111106        {
    112           $UploadedFilePath = $this->UploadedFilesFolder.basename($_FILES[$EnclosureName]['name']);
     107          $UploadedFilePath = ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.basename($_FILES[$EnclosureName]['name']);
    113108          if (move_uploaded_file($_FILES[$EnclosureName]['tmp_name'], $UploadedFilePath))
    114109          {
     
    124119        $this->Database->insert('News', array('Category' => $Category['Id'], 'Title' => $_POST['title'],
    125120          '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']));
    128123        $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 />';
    129124        $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);
    131126    } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!';
    132127    return $Output;
    133128  }
    134129
    135   function GetPageHeader()
     130  function GetPageHeader(): string
    136131  {
    137132    return '<script src="'.$this->System->Link('/Packages/TinyMCE/tinymce.min.js').'"></script>'.
     
    152147  }
    153148
    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']))
    159155    {
    160156      $DbResult = $this->Database->query('SELECT * FROM `News` WHERE `Id`='.$_GET['id']);
    161157      $Row = $DbResult->fetch_array();
    162       if (($this->System->User->User['Id'] == $Row['User']))
     158      if (($User->User['Id'] == $Row['User']))
    163159      {
    164160        $this->System->PageHeaders[] = array($this, 'GetPageHeader');
     
    177173  }
    178174
    179   function ShowUpdate()
    180   {
     175  function ShowUpdate(): string
     176  {
     177    $User = &ModuleUser::Cast($this->System->GetModule('User'))->User;
    181178    $Output = '';
    182179    $RemoteAddr = GetRemoteAddress();
    183180    $Category = $this->GetCategory();
    184     if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
     181    if ($User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
    185182    {
    186183      $_POST['id'] = $_POST['id'] * 1;
     
    189186      {
    190187        $Row = $DbResult->fetch_array();
    191         if ($this->System->User->User['Id'] == $Row['User'])
     188        if ($User->User['Id'] == $Row['User'])
    192189        {
    193190          $this->Database->update('News', 'Id='.$_POST['id'], array('Title' => $_POST['title'],
     
    201198  }
    202199
    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']))
    208206    {
    209207      $DbResult = $this->Database->query('SELECT * FROM `News` WHERE `Id`='.$_GET['id']);
    210208      $Row = $DbResult->fetch_array();
    211       if ($this->System->User->User['Id'] == $Row['User'])
     209      if ($User->User['Id'] == $Row['User'])
    212210      {
    213211        // TODO: Make upload using general File class
     
    218216          foreach ($Enclosures as $Enclosure)
    219217          {
    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);
    221219          }
    222220        }
     
    228226  }
    229227
    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']))
    235234    {
    236235      $PerPage = 20;
     
    250249          else $Author = $Row['Name'];
    251250        $Output .= '<div class="Panel"><div class="Title"><a href="?action=view&amp;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'])))
    253252        {
    254253          $Output .= '<div class="Action">';
     
    257256          $Output .= '</div>';
    258257        }
    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 />';
    260259        if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';
    261260        if ($Row['Enclosure'] != '')
     
    265264          foreach ($Enclosures as $Enclosure)
    266265          {
    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>';
    269268          }
    270269        }
     
    277276  }
    278277
    279   function GetCategory()
     278  function GetCategory(): array
    280279  {
    281280    $Category = array('Id' => 1); // Default category
     
    292291  }
    293292
    294   function ShowMain()
     293  function Show(): string
    295294  {
    296295    $Output = '';
     
    306305    return $Output;
    307306  }
    308 
    309   function ShowSubscription()
     307}
     308
     309class 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
     329class 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
    310340  {
    311341    if (array_key_exists('build', $_GET))
     
    333363    return $Output;
    334364  }
    335 
    336   function ShowRSS()
     365}
     366
     367class 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
    337378  {
    338379    $this->ClearPage = true;
     
    409450        foreach ($Enclosures as $Enclosure)
    410451        {
    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>';
    413454        }
    414455      }
     
    432473  }
    433474}
    434 
    435 class PageNewsUpdate extends Page
    436 {
    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  
    11<?php
    22
    3 function GetTextBetween(&$Text, $Start, $End)
     3function GetTextBetween(string &$Text, string $Start, string $End): string
    44{
    55  $Result = '';
     
    3434}
    3535
    36 function HumanDateTimeToTime($DateTime)
     36function HumanDateTimeToTime(string $DateTime): int
    3737{
    3838  if ($DateTime == '') return NULL;
     
    4949}
    5050
    51 function HumanDateToTime($Date)
     51function HumanDateToTime(string $Date): int
    5252{
    5353  if ($Date == '') return NULL;
     
    5555}
    5656
    57 function GetUrlBase($Url)
     57function GetUrlBase(string $Url): string
    5858{
    5959  $Result = parse_url($Url);
     
    6363class NewsSources
    6464{
    65   public $Database;
     65  public Database $Database;
    6666
    6767  function Parse($Id = null)
     
    9494class NewsSource
    9595{
    96   public $Name;
    97   public $URL;
     96  public string $Name;
     97  public string $URL;
    9898  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;
    103103  public $Category;
    104104
     
    109109  }
    110110
    111   function Import()
     111  function Import(): string
    112112  {
    113113    return '';
    114114  }
    115115
    116   function DoImport()
     116  function DoImport(): string
    117117  {
    118118    $this->NewsItems = array();
     
    133133class NewsItem
    134134{
    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 = '';
    144144
    145   function AddIfNotExist()
     145  function AddIfNotExist(): int
    146146  {
    147147    $Where = '(`Title` = "'.$this->Database->real_escape_string($this->Title).'") AND '.
  • trunk/Modules/Notify/Notify.php

    r874 r887  
    55class ModuleNotify extends AppModule
    66{
    7   var $Checks;
    8 
    9   function __construct($System)
     7  public array $Checks;
     8
     9  function __construct(System $System)
    1010  {
    1111    parent::__construct($System);
     
    1919  }
    2020
    21   function DoStart()
     21  function DoStart(): void
    2222  {
    2323    $this->System->FormManager->RegisterClass('NotifyUser', array(
     
    3838      ),
    3939    ));
    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'),
    4343    'Permission' => array('Module' => 'Notify', 'Operation' => 'RSS')));
    4444  }
    4545
    46   function RegisterCheck($Name, $Callback)
     46  function RegisterCheck(string $Name, callable $Callback): void
    4747  {
    4848    if (array_key_exists($Name, $this->Checks))
     
    5151  }
    5252
    53   function UnregisterCheck($Name)
     53  function UnregisterCheck(string $Name): void
    5454  {
    5555    if (!array_key_exists($Name, $this->Checks))
     
    5858  }
    5959
    60   function Check()
     60  function Check(): string
    6161  {
    6262    $Output = '';
     
    123123  }
    124124
    125   function RunCheck($Parameters)
     125  function RunCheck(array $Parameters): void
    126126  {
    127127    RepeatFunction(30, array($this, 'Check'));
    128128  }
    129129
    130   function DoInstall()
     130  function DoInstall(): void
    131131  {
    132132    $this->Database->query('CREATE TABLE IF NOT EXISTS `NotifyCategory` (
     
    160160  }
    161161
    162   function DoUninstall()
     162  function DoUninstall(): void
    163163  {
    164164    $this->Database->query('DROP TABLE `NotifyUser`');
     
    166166  }
    167167
    168   function ShowLogRSS()
     168  function ShowLogRSS(): string
    169169  {
    170170    $this->ClearPage = true;
     
    197197    return $RSS->Generate();
    198198  }
     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  }
    199208}
  • trunk/Modules/OpeningHours/OpeningHours.php

    r874 r887  
    55class PageSubjectOpenTime extends Page
    66{
    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
    1419  {
    1520    $Hours = floor($Time / 60);
     
    2025  }
    2126
    22   function ToHumanTime2($Time)
     27  function ToHumanTime2(float $Time): string
    2328  {
    2429    $Days = floor($Time / 24 / 60);
     
    3439  }
    3540
    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'))
    3944    {
    4045      $Output = '<div class="Centred">';
     
    7378  }
    7479
    75   function SaveSubject($Id)
    76   {
    77     global $Config;
    78 
     80  function SaveSubject(int $Id): string
     81  {
    7982    $Output = '';
    80     if ($this->System->User->CheckPermission('OpeningHours', 'Edit'))
     83    if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('OpeningHours', 'Edit'))
    8184    {
    8285      $this->Database->delete('SubjectOpenTimeDay', 'Subject='.$Id);
     
    100103      $Output .= 'Uloženo';
    101104
    102       $File = new File($this->Database);
     105      $File = new File($this->System);
    103106
    104107      // Delete old file
     
    114117  }
    115118
    116   function ShowAll()
     119  function ShowAll(): string
    117120  {
    118121    $Output = '<div class="Centred">';
     
    138141        }
    139142      }
    140       //print_r($Events);
    141143
    142144      // Calculate time to next event
     
    190192      if ($Subject['Photo'] != 0) $Output .= '<a href="file?id='.$Subject['Photo'].'">Fotka</a> ';
    191193
    192       if ($this->System->User->CheckPermission('SubjectOpenTime', 'Edit'))
     194      if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('SubjectOpenTime', 'Edit'))
    193195        $Output .= '<a href="edit?Subject='.$Subject['Id'].'">Editovat</a><br />';
    194196      $Output .= '<br />';
     
    198200  }
    199201
    200   function Show()
     202  function Show(): string
    201203  {
    202204    if (count($this->System->PathItems) > 1)
     
    215217class ModuleOpeningHours extends AppModule
    216218{
    217   function __construct($System)
     219  function __construct(System $System)
    218220  {
    219221    parent::__construct($System);
     
    226228  }
    227229
    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
    238245  {
    239246  }
  • trunk/Modules/Portal/Portal.php

    r874 r887  
    55class ModulePortal extends AppModule
    66{
    7   function __construct($System)
     7  function __construct(System $System)
    88  {
    99    parent::__construct($System);
     
    1616  }
    1717
    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');
    2929    $this->System->FormManager->RegisterClass('MemberOptions', array(
    3030      'Title' => 'Nastavení zákazníka',
     
    4242      ),
    4343    ));
    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
    4848  {
    4949  }
     
    5252class PagePortal extends Page
    5353{
    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
    5862  {
    5963    $Output = '';
     
    6771  }
    6872
    69   function InfoBar()
     73  function InfoBar(): string
    7074  {
    7175    $Output2 = '';
     
    98102    //$Output .= 'Server běží: '.$this->GetServerUptime().' &nbsp;  &nbsp; ';
    99103
    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'].')');
    103107      if ($DbResult->num_rows > 0)
    104108      {
     
    112116  }
    113117
    114   function UserPanel()
    115   {
     118  function UserPanel(): string
     119  {
     120    $User = &ModuleUser::Cast($this->System->GetModule('User'))->User;
    116121    $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'))
    118123      $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'))
    120125      $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'))
    122127      $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'))
    124129      $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'))
    126131      $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'))
    128133      $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'))
    130135      $Output .= '<a href="'.$this->System->Link('/is/').'">Správa dat</a><br />';
    131136    return $Output;
    132137  }
    133138
    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
    141146  {
    142147    $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>';
     
    144149  }
    145150
    146   function OnlineHostList()
     151  function OnlineHostList(): string
    147152  {
    148153    $Output = '<span style="font-size: smaller;">';
     
    158163  }
    159164
    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');
    164169    while ($Row = $DbResult->fetch_array())
    165170    {
     
    170175  }
    171176
    172   function Panel($Title, $Content, $Menu = array())
     177  function Panel(string $Title, string $Content, array $Menu = array()): string
    173178  {
    174179    if (count($Menu) > 0)
     180    {
    175181      foreach ($Menu as $Item)
     182      {
    176183        $Title .= '<div class="Action">'.$Item.'</div>';
     184      }
     185    }
    177186    return '<div class="Panel"><div class="Title">'.$Title.'</div><div class="Content">'.$Content.'</div></div>';
    178187  }
    179188
    180   function Show()
     189  function Show(): string
    181190  {
    182191    $Output = '';
     
    186195      if ($Action == 'CustomizeNewsSave')
    187196      {
    188         $Output .= $this->System->ModuleManager->Modules['News']->CustomizeSave();
     197        $Output .= ModuleNews::Cast($this->System->GetModule('News'))->CustomizeSave();
    189198      } else
    190199      if ($Action == 'MemberOptions')
    191200      {
    192201        $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']);
    194203        while ($CustomerUserRel = $DbResult->fetch_assoc())
    195204        {
     
    218227          $Form->Values['FamilyMemberCount'] = 0;
    219228
    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'],
    221231           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']);
    223233        $Member = $DbResult->fetch_assoc();
    224234        $DbResult = $this->Database->update('Subject', 'Id='.$Member['Subject'],
     
    228238          'DIC' => $Form->Values['DIC']));
    229239        $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',
    231241          $Form->Values['Name']);
    232242        $DbResult = $this->Database->query('SELECT Member.Id, Member.FamilyMemberCount, '.
    233243          'Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, '.
    234244          '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']);
    236246        $DbRow = $DbResult->fetch_array();
    237247        foreach ($Form->Definition['Items'] as $Index => $Item)
     
    246256  }
    247257
    248   function ShowMain()
     258  function ShowMain(): string
    249259  {
    250260    $Output = '';
     
    270280        else if ($Panel['Module'] == 'UserOptions')
    271281        {
    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());
    273283        } else
    274284        if ($Panel['Module'] == 'Webcam') $Output .= $this->Panel('Kamery', $this->WebcamPanel());
    275285        if ($Panel['Module'] == 'Meteo') $Output .= $this->Panel('Meteostanice', $this->MeteoPanel());
    276286        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>'));
    278288      }
    279289      $Output .= '</td>';
  • trunk/Modules/RSS/RSS.php

    r874 r887  
    33class ModuleRSS extends AppModule
    44{
    5   var $RSSChannels;
     5  public array $RSSChannels;
    66
    7   function __construct($System)
     7  function __construct(System $System)
    88  {
    99    parent::__construct($System);
     
    1717  }
    1818
    19   function Start()
     19  function DoStart(): void
    2020  {
    21     $this->System->RegisterPage('rss', 'PageRSS');
     21    $this->System->RegisterPage(['rss'], 'PageRSS');
    2222    $this->System->RegisterPageHeader('RSS', array($this, 'ShowRSSHeader'));
    2323  }
    2424
    25   function RegisterRSS($Channel, $Pos = NULL, $Callback = NULL)
     25  function RegisterRSS(array $Channel, $Pos = NULL, $Callback = NULL): void
    2626  {
    2727    $this->RSSChannels[$Channel['Channel']] = $Channel;
    2828
    2929    if (is_null($Pos)) $this->RSSChannelsPos[] = $Channel['Channel'];
    30     else {
     30    else
     31    {
    3132      array_splice($this->RSSChannelsPos, $Pos, 0, $Channel['Channel']);
    3233    }
    3334  }
    3435
    35   function UnregisterRSS($ChannelName)
     36  function UnregisterRSS($ChannelName): void
    3637  {
    3738    unset($this->RSSChannels[$ChannelName]);
     
    3940  }
    4041
    41   function ShowRSSHeader()
     42  function ShowRSSHeader(): string
    4243  {
    4344    $Output = '';
    4445    foreach ($this->RSSChannels as $Channel)
    4546    {
    46       //if ($this->System->User->Licence($Channel['Permission']))
     47      //if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence($Channel['Permission']))
    4748        $Output .= ' <link rel="alternate" title="'.$Channel['Title'].'" href="'.
    4849          $this->System->Link('/rss/?channel='.$Channel['Channel']).'" type="application/rss+xml" />';
     
    5051    return $Output;
    5152  }
     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  }
    5262}
    5363
    5464class PageRSS extends Page
    5565{
    56   function Show()
     66  function Show(): string
    5767  {
    5868    $this->ClearPage = true;
     
    6272    if (array_key_exists('token', $_GET)) $Token = $_GET['token'];
    6373      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))
    6575    {
    66       $Channel = $this->System->ModuleManager->Modules['RSS']->RSSChannels[$ChannelName];
    67       if ($this->System->User->CheckPermission($Channel['Permission']['Module'], $Channel['Permission']['Operation']) or
    68       $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))
    6979      {
    7080        if (is_string($Channel['Callback'][0]))
  • trunk/Modules/Scheduler/Scheduler.php

    r874 r887  
    33class ModuleScheduler extends AppModule
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1414  }
    1515
    16   function DoStart()
     16  function DoStart(): void
    1717  {
    1818    $this->System->FormManager->RegisterClass('Scheduler', array(
     
    4848      'Filter' => '1',
    4949    ));
    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'));
    5152  }
    5253
    53   function DoInstall()
     54  function DoInstall(): void
    5455  {
    5556  }
    5657
    57   function DoUnInstall()
     58  function DoUnInstall(): void
    5859  {
    5960  }
    6061
    61   function Run($Parameters)
     62  function Run(array $Parameters): void
    6263  {
    6364    while (true)
     
    100101    }
    101102  }
     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  }
    102112}
    103113
    104114class SchedulerTask extends Model
    105115{
    106   function Execute()
     116  function Execute(): string
    107117  {
     118    return '';
    108119  }
    109120}
    110121
    111 
    112122class ScheduleTaskTest extends SchedulerTask
    113123{
    114   function Execute()
     124  function Execute(): string
    115125  {
    116126    $Output = '#';
  • trunk/Modules/Search/Search.php

    r874 r887  
    33class PageSearch extends Page
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1111  }
    1212
    13   function Show()
     13  function Show(): string
    1414  {
    1515    $Output = '';
     
    2121    '</form>';
    2222    if ($Text != '')
    23     foreach ($this->System->ModuleManager->Modules['Search']->Items as $Item)
     23    foreach (ModuleSearch::Cast($this->System->GetModule('Search'))->Items as $Item)
    2424    {
    2525      $Columns = '';
     
    3333      $Condition = substr($Condition, 3);
    3434      $DbResult = $this->Database->Select($Item['Table'], $Columns, $Condition.' LIMIT '.
    35         $this->System->ModuleManager->Modules['Search']->MaxItemCount);
     35        ModuleSearch::Cast($this->System->GetModule('Search'))->MaxItemCount);
    3636      if ($DbResult->num_rows > 0) $Output .= '<strong>'.$Item['Name'].'</strong><br/>';
    3737      while ($Row = $DbResult->fetch_assoc())
     
    4949class ModuleSearch extends AppModule
    5050{
    51   var $Items;
    52   var $MaxItemCount;
     51  public array $Items;
     52  public int $MaxItemCount;
    5353
    54   function __construct($System)
     54  function __construct(System $System)
    5555  {
    5656    parent::__construct($System);
     
    6565  }
    6666
    67   function DoStart()
     67  function DoStart(): void
    6868  {
    6969    $this->System->Pages['search'] = 'PageSearch';
    7070  }
    7171
    72   function DoInstall()
     72  function DoInstall(): void
    7373  {
    7474  }
    7575
    76   function DoUnInstall()
     76  function DoUnInstall(): void
    7777  {
    7878  }
    7979
    80   function RegisterSearch($Title, $TableName, $Columns)
     80  function RegisterSearch(string $Title, string $TableName, array $Columns): void
    8181  {
    8282    $this->Items[] = array('Name' => $Title, 'Table' => $TableName, 'Columns' => $Columns);
    8383  }
     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  }
    8493}
  • trunk/Modules/SpeedTest/SpeedTest.php

    r874 r887  
    1414class ModuleSpeedTest extends AppModule
    1515{
    16   function __construct($System)
     16  function __construct(System $System)
    1717  {
    1818    parent::__construct($System);
     
    2525  }
    2626
    27   function DoStart()
     27  function DoStart(): void
    2828  {
    2929    $this->System->Pages['speedtest'] = 'PageSpeedTest';
     
    3333class PageSpeedTest extends Page
    3434{
    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  }
    3842
    39   function Show()
     43  function Show(): string
    4044  {
    4145    if (count($this->System->PathItems) > 1)
     
    4751  }
    4852
    49   function ShowDownload()
     53  function ShowDownload(): void
    5054  {
    5155    global $config;
     
    5458  }
    5559
    56   function ShowMain()
     60  function ShowMain(): string
    5761  {
    5862    global $config;
  • trunk/Modules/Stock/Stock.php

    r874 r887  
    33class ModuleStock extends AppModule
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1414  }
    1515
    16   function DoStart()
     16  function DoStart(): void
    1717  {
    1818    global $Config;
     
    246246  }
    247247
    248   function BeforeInsertStockMove($Form)
     248  function BeforeInsertStockMove(Form $Form): array
    249249  {
     250    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    250251    if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
    251252      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);
    254255    return $Form->Values;
    255256  }
  • trunk/Modules/Subject/Subject.php

    r886 r887  
    33class ModuleSubject extends AppModule
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1414  }
    1515
    16   function DoStart()
     16  function DoStart(): void
    1717  {
    1818    $this->System->FormManager->RegisterClass('Subject', array(
     
    127127      'Filter' => '1',
    128128    ));
    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'));
    131131  }
    132132
    133   function DoInstall()
     133  function DoInstall(): void
    134134  {
    135135    $this->Database->query("CREATE TABLE IF NOT EXISTS `Subject` (
     
    173173  }
    174174
    175   function DoUninstall()
     175  function DoUninstall(): void
    176176  {
    177177    $this->Database->query('DROP TABLE `Contact`');
     
    180180  }
    181181
    182   function ShowDashboardItem()
     182  function ShowDashboardItem(): string
    183183  {
    184184    $DbResult = $this->Database->select('Subject', 'COUNT(*)', '1');
  • trunk/Modules/System/System.php

    r874 r887  
    33class PageModules extends Page
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1111  }
    1212
    13   function ShowList()
     13  function ShowList(): string
    1414  {
    1515    $Output = '';
     
    6262  }
    6363
    64   function Show()
     64  function Show(): string
    6565  {
    6666    $Output = '';
     
    6969      if ($_GET['A'] == 'SaveToDb')
    7070      {
    71         $Output .= $this->System->ModuleManager->Modules['System']->SaveToDatabase();
     71        $Output .= ModuleSystem::Cast($this->System->GetModule('System'))->SaveToDatabase();
    7272        $Output .= $this->SystemMessage('Načtení modulů', 'Seznam modulů v databázi zaktualizován');
    7373      } else
     
    7878        if ($ModuleName != '')
    7979        {
    80           $this->System->Modules[$ModuleName]->Install();
    81           $this->System->ModuleManager->Init();
     80          $this->System->ModuleManager->GetModule($ModuleName)->Install();
    8281        } else $Output .= 'Modul id '.$_GET['Id'].' nenalezen';
    8382
     
    8887        if ($ModuleName != '')
    8988        {
    90           $this->System->ModuleManager->Modules[$ModuleName]->UnInstall();
    91           $this->System->ModuleManager->Init();
     89          $this->System->ModuleManager->GetModule($ModuleName)->UnInstall();
    9290        } else $Output .= 'Modul id '.$_GET['Id'].' nenalezen';
    9391      } else $Output .= 'Neplatná akce';
     
    10098class ModuleSystem extends AppModule
    10199{
    102   var $InstalledChecked;
    103 
    104   function __construct($System)
     100  public bool $InstalledChecked;
     101
     102  function __construct(System $System)
    105103  {
    106104    parent::__construct($System);
     
    113111  }
    114112
    115   function DoInstall()
     113  function DoInstall(): void
    116114  {
    117115    $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemVersion` (
     
    164162  }
    165163
    166   function DoUnInstall()
     164  function DoUnInstall(): void
    167165  {
    168166    // Delete tables with reverse order
     
    178176  }
    179177
    180   function DoStart()
    181   {
    182     $this->System->RegisterPage('module', 'PageModules');
     178  function DoStart(): void
     179  {
     180    $this->System->RegisterPage(['module'], 'PageModules');
    183181    $this->System->FormManager->RegisterClass('Action', array(
    184182      'Title' => 'Akce',
     
    402400  }
    403401
    404   function DoStop()
    405   {
    406   }
    407 
    408   function IsInstalled()
     402  function DoStop(): void
     403  {
     404  }
     405
     406  function IsInstalled(): bool
    409407  {
    410408    if ($this->InstalledChecked == false)
     
    419417  }
    420418
    421   function ModuleChange($Module)
     419  function ModuleChange($Module): void
    422420  {
    423421    //if ($this->IsInstalled())
     
    430428  }
    431429
    432   function LoadFromDatabase()
     430  function LoadFromDatabase(): void
    433431  {
    434432    //DebugLog('Loading modules...');
     
    448446  }
    449447
    450   function SaveToDatabase()
     448  function SaveToDatabase(): string
    451449  {
    452450    $Output = '';
     
    457455      $Modules[$DbRow['Name']] = $DbRow;
    458456      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'];
    460458    }
    461459
     
    470468          'Description' => $Module->Description, 'License' => $Module->License,
    471469          '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;
    473471      }
    474472      else $this->Database->update('Module', 'Name = "'.$Module->Name.'"', array(
     
    512510      {
    513511        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]))
    515513        {
    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;
    518516            else throw new Exception('Dependent module '.$Dependency.' not found');
    519517          $this->Database->insert('ModuleLink', array('Module' => $Module->Id,
     
    534532    return $Output;
    535533  }
     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  }
    536543}
  • trunk/Modules/TV/TV.php

    r874 r887  
    55class PageIPTV extends Page
    66{
    7   var $FullTitle = 'Síťová televize';
    8   var $ShortTitle = 'IPTV';
    9   var $ParentClass = 'PagePortal';
    10 
    11   function Show()
     7  function __construct(System $System)
    128  {
    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';
    1813  }
    1914
    20   function ShowChannelList()
     15  function Show(): string
    2116  {
    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/>'.
    2518    'Seznam všech kanálů do přehrávače: <a href="playlist.m3u">Playlist</a><br/>'.
    2619    'Zobrazení playlistu ve VLC lze provést pomocí menu <strong>View - Playlist</strong> nebo klávesové zkratky CTRL+L<br/>'.
     
    2821    '<div align="center"><strong>Výpis kanálů:</strong><br>';
    2922
    30     $Where =
    3123    $DbResult = $this->Database->query('SELECT COUNT(*) FROM `TV` LEFT JOIN `TVGroup` ON `TVGroup`.`Id` = `TV`.`Category` '.
    3224      ' LEFT JOIN `Language` ON `Language`.`Id` = `TV`.`Language` WHERE (`TV`.`Stream` <> "") OR (`TV`.`StreamWeb` <> "")');
     
    6961    $Output .= '</div><br/>';
    7062
    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/>';
    7364
    7465    return $Output;
    7566  }
     67}
    7668
    77   function ShowPlayList()
     69class PagePlaylist extends Page
     70{
     71  function Show(): string
    7872  {
    7973    $this->ClearPage = true;
     
    8276    Header("Content-Disposition: attachment; filename=playlist.m3u");
    8377
    84     echo('#EXTM3U'."\n");
     78    $Output = '#EXTM3U'."\n";
    8579    if (array_key_exists('id', $_GET))
    8680    {
     
    8983      {
    9084        $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";
    9387      }
    9488    } else
     
    9791      while ($Channel = $DbResult->fetch_array())
    9892      {
    99         echo('#EXTINF:0,'.$Channel['Name']."\n");
    100         echo($Channel['Stream']."\n");
     93        $Output .= '#EXTINF:0,'.$Channel['Name']."\n";
     94        $Output .= $Channel['Stream']."\n";
    10195      }
    10296    }
     97    return $Output;
    10398  }
    10499}
     
    106101class ModuleTV extends AppModule
    107102{
    108   function __construct($System)
     103  function __construct(System $System)
    109104  {
    110105    parent::__construct($System);
     
    117112  }
    118113
    119   function DoInstall()
     114  function DoInstall(): void
    120115  {
    121116  }
    122117
    123   function DoUninstall()
     118  function DoUninstall(): void
    124119  {
    125120  }
    126121
    127   function DoStart()
     122  function DoStart(): void
    128123  {
    129     $this->System->RegisterPage('tv', 'PageIPTV');
     124    $this->System->RegisterPage(['tv'], 'PageIPTV');
     125    $this->System->RegisterPage(['tv', 'playlist.m3u'], 'PagePlaylist');
    130126    $this->System->FormManager->RegisterClass('TV', array(
    131127      'Title' => 'TV kanály',
     
    170166  }
    171167
    172   function DoStop()
     168  function DoStop(): void
    173169  {
    174170  }
  • trunk/Modules/TV/tkr.php

    r874 r887  
    33class CableTVChennelListPage extends Page
    44{
    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  }
    711
    8   function Show()
     12  function Show(): string
    913  {
    1014    $Output = '<div align="center"><strong>Výpis kanálů:</strong><br>'.
     
    2125}
    2226
    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  
    33class ModuleTask extends AppModule
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1414  }
    1515
    16   function DoStart()
     16  function DoStart(): void
    1717  {
    1818    $this->System->FormManager->RegisterClass('Task', array(
     
    8989    ));
    9090
    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'));
    9393  }
    9494
    95   function DoInstall()
     95  function DoInstall(): void
    9696  {
    97 
    9897  }
    9998
    100   function ShowDashboardItem()
     99  function ShowDashboardItem(): string
    101100  {
    102101    $DbResult = $this->Database->select('Task', 'COUNT(*)', '`Progress` < 100');
  • trunk/Modules/TimeMeasure/Graph.php

    r874 r887  
    99  var $DefaultHeight;
    1010
    11   function __construct($System)
     11  function __construct(System $System)
    1212  {
    1313    parent::__construct($System);
     
    1717  }
    1818
    19   function Show()
     19  function Show(): string
    2020  {
    2121    $this->ClearPage = true;
    22     return $this->Render();
     22    $this->Render();
     23    return '';
    2324  }
    2425
    25   function Render()
     26  function Render(): void
    2627  {
    2728    $PrefixMultiplier = new PrefixMultiplier();
  • trunk/Modules/TimeMeasure/Main.php

    r874 r887  
    33class PageMeasure extends Page
    44{
    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)
    1111  {
    1212    parent::__construct($System);
     
    2323    );
    2424    $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    );
    5151  }
    5252
     
    114114  }
    115115
    116   function Show()
     116  function Show(): string
    117117  {
    118118    $Debug = 0;
     
    182182  }
    183183
    184   function Graph()
     184  function Graph(): string
    185185  {
    186186    $Output = '<strong>Graf:</strong><br/>';
     
    194194  }
    195195
    196   function MeasureTable()
     196  function MeasureTable(): string
    197197  {
    198198    $PrefixMultiplier = new PrefixMultiplier();
     
    266266class PageMeasureAddValue extends Page
    267267{
    268   function Show()
     268  function Show(): string
    269269  {
    270270    $this->ClearPage = true;
  • trunk/Modules/TimeMeasure/TimeMeasure.php

    r738 r887  
    77class ModuleTimeMeasure extends AppModule
    88{
    9   function __construct($System)
     9  function __construct(System $System)
    1010  {
    1111    parent::__construct($System);
     
    1818  }
    1919
    20   function DoInstall()
     20  function DoInstall(): void
    2121  {
    2222  }
    2323
    24   function DoUnInstall()
     24  function DoUnInstall(): void
    2525  {
    2626  }
    2727
    28   function DoStart()
     28  function DoStart(): void
    2929  {
    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');
    3333    $this->System->FormManager->RegisterClass('Measure', array(
    3434      'Title' => 'Měření',
     
    5050  }
    5151
    52   function DoStop()
     52  function DoStop(): void
    5353  {
    5454  }
  • trunk/Modules/User/User.php

    r874 r887  
    77class ModuleUser extends AppModule
    88{
    9   var $UserPanel;
    10 
    11   function __construct($System)
     9  public array $UserPanel;
     10  public User $User;
     11
     12  function __construct(System $System)
    1213  {
    1314    parent::__construct($System);
     
    1920    $this->Dependencies = array();
    2021    $this->UserPanel = array();
    21   }
    22 
    23   function DoInstall()
     22    $this->User = new User($System);
     23  }
     24
     25  function DoInstall(): void
    2426  {
    2527    $this->Database->query("CREATE TABLE IF NOT EXISTS `User` (
     
    108110  }
    109111
    110   function DoUninstall()
     112  function DoUninstall(): void
    111113  {
    112114    $this->Database->query('DROP TABLE `PermissionUserAssignment`');
     
    118120  }
    119121
    120   function DoUpgrade()
     122  function DoUpgrade(): void
    121123  {
    122124    /*
     
    129131  }
    130132
    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');
    137138    $this->System->RegisterPageBarItem('Top', 'User', array($this, 'TopBarCallback'));
    138139    $this->System->FormManager->RegisterClass('UserLogin', array(
     
    272273      'Filter' => '1',
    273274    ));
    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
    279280  {
    280281    $DbResult = $this->Database->select('User', 'COUNT(*)', '1');
     
    284285  }
    285286
    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)
    293294    {
    294295      $Output = '<a href="'.$this->System->Link('/user/?Action=LoginForm').'">Přihlášení</a> '.
     
    296297    } else
    297298    {
    298       $Output = $this->System->User->User['Name'].
     299      $Output = $this->User->User['Name'].
    299300        ' <a href="'.$this->System->Link('/user/?Action=UserMenu').'">Nabídka</a>'.
    300301        ' <a href="'.$this->System->Link('/user/?Action=Logout').'">Odhlásit</a>';
     
    303304    return $Output;
    304305  }
     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  }
    305315}
  • trunk/Modules/User/UserList.php

    r874 r887  
    33class PageUserList extends Page
    44{
    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  }
    812
    9   function Show()
     13  function Show(): string
    1014  {
    11     if (!$this->System->User->CheckPermission('User', 'ShowList'))
     15    if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('User', 'ShowList'))
    1216      return 'Nemáte oprávnění';
    1317
  • trunk/Modules/User/UserModel.php

    r878 r887  
    2828class PasswordHash
    2929{
    30   function Hash($Password, $Salt)
     30  function Hash(string $Password, string $Salt): string
    3131  {
    3232    return sha1(sha1($Password).$Salt);
    3333  }
    3434
    35   function Verify($Password, $Salt, $StoredHash)
     35  function Verify(string $Password, string $Salt, string $StoredHash): bool
    3636  {
    3737    return $this->Hash($Password, $Salt) == $StoredHash;
    3838  }
    3939
    40   function GetSalt()
     40  function GetSalt(): string
    4141  {
    4242    mt_srand(microtime(true) * 100000 + memory_get_usage(true));
     
    4949class User extends Model
    5050{
    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)
    6160  {
    6261    parent::__construct($System);
     
    6665  }
    6766
    68   function Check()
     67  function Check(): void
    6968  {
    7069    $SID = session_id();
     
    117116    {
    118117      $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');
    120119    }
    121120    //$this->LoadPermission($this->User['Role']);
     
    125124  }
    126125
    127   function Register($Login, $Password, $Password2, $Email, $Name)
     126  function Register(string $Login, string $Password, string $Password2, string $Email, string $Name): string
    128127  {
    129128    if (($Email == '') || ($Login == '') || ($Password == '') || ($Password2 == '')  || ($Name == '')) $Result = DATA_MISSING;
     
    172171
    173172            $Result = USER_REGISTRATED;
    174             $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'NewRegistration', $Login);
     173            ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'NewRegistration', $Login);
    175174          }
    176175        }
     
    180179  }
    181180
    182   function RegisterConfirm($Id, $Hash)
     181  function RegisterConfirm(string $Id, string $Hash): string
    183182  {
    184183    $DbResult = $this->Database->select('User', 'Id, Login, Password', 'Id = '.$Id);
     
    191190        $this->Database->update('User', 'Id='.$Row['Id'], array('Locked' => 0));
    192191        $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='.
    194193          $Row['Login'].', Id='.$Row['Id']);
    195194      } else $Output = PASSWORDS_UNMATCHED;
     
    198197  }
    199198
    200   function Login($Login, $Password, $StayLogged = false)
     199  function Login(string $Login, string $Password, bool $StayLogged = false): string
    201200  {
    202201    if ($StayLogged) $StayLogged = 1; else $StayLogged = 0;
     
    228227        $Result = USER_LOGGED_IN;
    229228        $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()));
    231230      }
    232231    } else $Result = USER_NOT_REGISTRED;
     
    234233  }
    235234
    236   function Logout()
     235  function Logout(): string
    237236  {
    238237    $SID = session_id();
    239238    $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']);
    241240    $this->Check();
    242241    return USER_LOGGED_OUT;
     
    248247    $DbResult = $this->Database->select('UserRole', '*');
    249248    while ($DbRow = $DbResult->fetch_array())
     249    {
    250250      $this->Roles[] = $DbRow;
     251    }
    251252  }
    252253
     
    257258    if ($DbResult->num_rows > 0)
    258259    while ($DbRow = $DbResult->fetch_array())
     260    {
    259261      $this->User['Permission'][$DbRow['Operation']] = $DbRow;
    260   }
    261 
    262   function PermissionMatrix()
     262    }
     263  }
     264
     265  function PermissionMatrix(): array
    263266  {
    264267    $Result = array();
     
    274277  }
    275278
    276   function CheckGroupPermission($GroupId, $OperationId)
     279  function CheckGroupPermission(string $GroupId, string $OperationId): bool
    277280  {
    278281    $PermissionExists = false;
     
    322325  }
    323326
    324   function CheckPermission($Module, $Operation, $ItemType = '', $ItemIndex = 0)
     327  function CheckPermission(string $Module, string $Operation, string $ItemType = '', int $ItemIndex = 0): bool
    325328  {
    326329    // Get module id
     
    373376  }
    374377
    375   function PasswordRecoveryRequest($Login, $Email)
     378  function PasswordRecoveryRequest(string $Login, string $Email): string
    376379  {
    377380    $DbResult = $this->Database->select('User', 'Login, Name, Id, Email, Password', '`Login`="'.$Login.'" AND `Email`="'.$Email.'"');
     
    395398
    396399      $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);
    398401    } else $Output = USER_PASSWORD_RECOVERY_FAIL;
    399402    return $Output;
    400403  }
    401404
    402   function PasswordRecoveryConfirm($Id, $Hash, $NewPassword)
     405  function PasswordRecoveryConfirm(string $Id, string $Hash, string $NewPassword): string
    403406  {
    404407    $DbResult = $this->Database->select('User', 'Id, Login, Password', 'Id = '.$Id);
     
    414417          'Salt' => $Salt, 'Locked' => 0));
    415418        $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']);
    417420      } else $Output = PASSWORDS_UNMATCHED;
    418421    } else $Output = USER_NOT_FOUND;
     
    420423  }
    421424
    422   function CheckToken($Module, $Operation, $Token)
     425  function CheckToken(string $Module, string $Operation, string $Token): bool
    423426  {
    424427    $DbResult = $this->Database->select('APIToken', 'User', '`Token`="'.$Token.'"');
  • trunk/Modules/User/UserPage.php

    r874 r887  
    33class PageUser extends Page
    44{
    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
    1014  {
    1115    if (count($Menu) > 0)
     
    1519  }
    1620
    17   function ShowContacts()
     21  function ShowContacts(): string
    1822  {
    1923    $Query = 'SELECT `Contact`.`Value`, `Contact`.`Description`, (SELECT `Name` FROM `ContactCategory` WHERE `ContactCategory`.`Id` = `Contact`.`Category`) AS `Category` '.
    2024      'FROM `Contact` WHERE `User` = '.
    21       $this->System->User->User['Id'];
     25      ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'];
    2226    $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS T');
    2327    $DbRow = $DbResult->fetch_row();
     
    5357  }
    5458
    55   function ShowUserPanel()
    56   {
     59  function ShowUserPanel(): string
     60  {
     61    $User = &ModuleUser::Cast($this->System->GetModule('User'))->User;
    5762    $Output = '';
    58     if ($this->System->User->User['Id'] != null)
     63    if ($User->User['Id'] != null)
    5964    {
    6065      $Actions = '';
    61       foreach ($this->System->ModuleManager->Modules['User']->UserPanel as $Action)
     66      foreach (ModuleUser::Cast($this->System->GetModule('User'))->UserPanel as $Action)
    6267      {
    6368        if (is_string($Action[0]))
     
    7176      $Output .= $this->Panel('Nabídka uživatele', $Actions);
    7277      $Output .= '</td><td style="vertical-align:top;">';
    73       if ($this->System->User->User['Id'] != null)
     78      if ($User->User['Id'] != null)
    7479        {
    7580          $Form = new Form($this->System->FormManager);
    7681          $Form->SetClass('UserOptions');
    77           $Form->LoadValuesFromDatabase($this->System->User->User['Id']);
     82          $Form->LoadValuesFromDatabase($User->User['Id']);
    7883          $Form->OnSubmit = '?Action=UserOptionsSave';
    7984          $Output .= $Form->ShowViewForm();
     
    8893  }
    8994
    90   function Show()
    91   {
     95  function Show(): string
     96  {
     97    $User = &ModuleUser::Cast($this->System->GetModule('User'))->User;
    9298    $Output = '';
    9399    if (array_key_exists('Action', $_GET))
     
    112118          if (array_key_exists('StayLogged', $_POST) and ($_POST['StayLogged'] == 'on')) $StayLogged = true;
    113119            else $StayLogged = false;
    114           $Result = $this->System->User->Login($_POST['Username'], $_POST['Password'], $StayLogged);
     120          $Result = $User->Login($_POST['Username'], $_POST['Password'], $StayLogged);
    115121          $Output .= $this->SystemMessage('Přihlášení', $Result);
    116122          if ($Result <> USER_LOGGED_IN)
     
    130136      if ($Action == 'Logout')
    131137      {
    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());
    135141        } else $Output .= $this->SystemMessage('Nastavení uživatele', 'Nejste přihlášen');
    136142      } else
    137143      if ($Action == 'UserOptions')
    138144      {
    139         if ($this->System->User->User['Id'] != null)
     145        if ($User->User['Id'] != null)
    140146        {
    141147          $Form = new Form($this->System->FormManager);
    142148          $Form->SetClass('UserOptions');
    143           $Form->LoadValuesFromDatabase($this->System->User->User['Id']);
     149          $Form->LoadValuesFromDatabase($User->User['Id']);
    144150          $Form->OnSubmit = '?Action=UserOptionsSave';
    145151          $Output .= $Form->ShowEditForm();
     
    151157        $Form->SetClass('UserOptions');
    152158        $Form->LoadValuesFromForm();
    153         $Form->SaveValuesToDatabase($this->System->User->User['Id']);
     159        $Form->SaveValuesToDatabase($User->User['Id']);
    154160        $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']);
    157163        $Form->OnSubmit = '?Action=UserOptionsSave';
    158164        $Output .= $Form->ShowEditForm();
     
    169175      {
    170176        $Output .= $this->SystemMessage('Potvrzení registrace',
    171           $this->System->User->RegisterConfirm($_GET['User'], $_GET['H']));
     177          $User->RegisterConfirm($_GET['User'], $_GET['H']));
    172178      } else
    173179      if ($Action == 'PasswordRecovery')
     
    183189        $Form->SetClass('PasswordRecovery');
    184190        $Form->LoadValuesFromForm();
    185         $Result = $this->System->User->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']);
     191        $Result = $User->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']);
    186192        $Output .= $this->SystemMessage('Obnova hesla', $Result);
    187193        if ($Result <> USER_PASSWORD_RECOVERY_SUCCESS)
     
    192198      if ($Action == 'PasswordRecoveryConfirm')
    193199      {
    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']));
    195201      } else
    196202      if ($Action == 'UserRegisterSave')
     
    199205        $Form->SetClass('UserRegister');
    200206        $Form->LoadValuesFromForm();
    201         $Result = $this->System->User->Register($Form->Values['Login'], $Form->Values['Password'],
     207        $Result = $User->Register($Form->Values['Login'], $Form->Values['Password'],
    202208          $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['Name']);
    203209        $Output .= $this->SystemMessage('Registrace nového účtu', $Result);
     
    216222  }
    217223
    218   function ShowMain()
     224  function ShowMain(): string
    219225  {
    220226    $Output = 'Nebyla vybrána akce';
  • trunk/Modules/VPS/VPS.php

    r770 r887  
    33class ModuleVPS extends AppModule
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1616  }
    1717
    18   function DoStart()
     18  function DoStart(): void
    1919  {
    2020
    2121  }
    2222
    23   function DoInstall()
     23  function DoInstall(): void
    2424  {
    2525
  • trunk/Modules/WebCam/WebCam.php

    r874 r887  
    33class PageWebcam extends Page
    44{
    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  }
    812
    9   function Show()
     13  function Show(): string
    1014  {
    11     if (file_exists($this->System->ModuleManager->Modules['WebCam']->ImageFileName))
     15    if (file_exists(ModuleWebCam::Cast($this->System->GetModule('WebCam'))->ImageFileName))
    1216    {
    1317      $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.'";
    1519
    1620      // Force an immediate image load
     
    3236      </script>';
    3337
    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 />';
    3541    } else $Output = '<br />Obrázek nenalezen.<br /><br />';
    3642
     
    4450class ModuleWebCam extends AppModule
    4551{
    46   var $ImageFileName = 'webcam.jpg';
     52  public string $ImageFileName = 'webcam.jpg';
    4753
    48   function __construct($System)
     54  function __construct(System $System)
    4955  {
    5056    parent::__construct($System);
     
    5864  }
    5965
    60   function DoStart()
     66  function DoStart(): void
    6167  {
    6268    $this->System->Pages['webcam'] = 'PageWebcam';
    6369  }
    6470
    65  function ShowImage()
     71 function ShowImage(): string
    6672  {
    6773    global $Config;
     
    7480    return $Output;
    7581  }
     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  }
    7691}
  • trunk/Modules/Wiki/Wiki.php

    r874 r887  
    33class ModuleWiki extends AppModule
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1515  }
    1616
    17   function DoInstall()
     17  function DoInstall(): void
    1818  {
    1919    parent::Install();
     
    4242  }
    4343
    44   function DoUnInstall()
     44  function DoUnInstall(): void
    4545  {
    4646    $this->Database->query('DELETE TABLE `WikiPageContent`');
     
    4848  }
    4949
    50   function DoStart()
     50  function DoStart(): void
    5151  {
    5252    $this->LoadPages();
    5353  }
    5454
    55   function DoStop()
    56   {
    57   }
    58 
    59   function LoadPages()
     55  function DoStop(): void
     56  {
     57  }
     58
     59  function LoadPages(): void
    6060  {
    6161    $DbResult = $this->Database->select('WikiPage', '*', 'VisibleInMenu=1');
    6262    while ($DbRow = $DbResult->fetch_assoc())
    6363    {
    64       $this->System->RegisterPage($DbRow['NormalizedName'], 'PageWiki');
     64      $this->System->RegisterPage([$DbRow['NormalizedName']], 'PageWiki');
    6565      $this->System->RegisterMenuItem(array(
    6666        'Title' => $DbRow['Name'],
     
    7676class PageWiki extends Page
    7777{
    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
    8387  {
    8488    if (array_key_exists('Action', $_GET))
     
    9296  }
    9397
    94   function ShowContent()
     98  function ShowContent(): string
    9599  {
    96100    $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
     
    107111          $Output = '<h3>Archív stránky '.$DbRow['Name'].' ('.HumanDateTime($DbRow2['Time']).')</h3>';
    108112          $Output .= $DbRow2['Content'];
    109           if ($this->System->User->Licence(LICENCE_MODERATOR))
     113          if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence(LICENCE_MODERATOR))
    110114            $Output .= '<div><a href="?Action=Edit">Upravit nejnovější</a> <a href="?Action=History">Historie</a></div>';
    111         } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
     115        } else $Output = ShowmMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
    112116      } else
    113117      {
     
    118122          $Output = '<h3>'.$DbRow['Name'].'</h3>';
    119123          $Output .= $DbRow2['Content'];
    120           if ($this->System->User->Licence(LICENCE_MODERATOR))
     124          if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence(LICENCE_MODERATOR))
    121125            $Output .= '<div><a href="?Action=Edit">Upravit</a> <a href="?Action=History">Historie</a></div>';
    122126        } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
     
    126130  }
    127131
    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))
    131135    {
    132136    $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
     
    151155  }
    152156
    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))
    156160    {
    157161    $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
     
    162166      if (array_key_exists('content', $_POST) and array_key_exists('save', $_POST))
    163167      {
    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']));
    166170        $Output = ShowMessage('Wiki stránka uložena', MESSAGE_INFORMATION);
    167171      } else $Output = ShowMessage('Nezadána platná data', MESSAGE_CRITICAL);
     
    172176  }
    173177
    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))
    177181    {
    178182      $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
     
    218222  }
    219223
    220   function ToHtml($text)
     224  function ToHtml(string $text): string
    221225  {
    222226    $text = preg_replace('/&lt;source lang=&quot;(.*?)&quot;&gt;(.*?)&lt;\/source&gt;/', '<pre lang="$1">$2</pre>', $text);
Note: See TracChangeset for help on using the changeset viewer.