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/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';
Note: See TracChangeset for help on using the changeset viewer.