Changeset 887 for trunk/Modules/Portal


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.
File:
1 edited

Legend:

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