Ignore:
Timestamp:
Nov 20, 2020, 12:08:12 AM (3 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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 = '';
Note: See TracChangeset for help on using the changeset viewer.