Ignore:
Timestamp:
Mar 6, 2023, 1:48:45 AM (21 months ago)
Author:
chronos
Message:
  • Fixed: Class types casting for better type checking.
  • Fixed: XML direct export.
  • Modified: User class instance moved from Core class to ModuleUser class.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/User/Options.php

    r892 r893  
    55  function UserOptionsFrom()
    66  {
     7    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    78    $Output = '<form action="'.$this->System->Link('/options/?action=save').'" method="post">
    89    <fieldset><legend>'.T('User settings').'</legend>
    910    <table>
    10     <tr><td>'.T('E-mail').':</td><td><input type="text" name="Email" value="'.$this->System->User->Email.'" /></td></tr>
     11    <tr><td>'.T('E-mail').':</td><td><input type="text" name="Email" value="'.$User->Email.'" /></td></tr>
    1112    <tr><td>'.T('Original password').':</td><td><input type="password" name="OldPass" /></td></tr>
    1213    <tr><td>'.T('New password').':</td><td><input type="password" name="NewPass" /></td></tr>
    1314    <tr><td>'.T('New password confirmation').': </td><td><input type="password" name="NewPass2" /></td></tr>
    14     <tr><td>'.T('I will translate normally to').': </td><td>'.WriteLanguages($this->System->User->Language).'</td></tr>
     15    <tr><td>'.T('I will translate normally to').': </td><td>'.WriteLanguages($User->Language).'</td></tr>
    1516    <tr><td>'.T('After save translation redirect to').': </td><td>';
    1617    $Output .= '<select name="redirecting">'.
    1718      '<option value="0">'.T('Nowhere').'</option>'.
    1819      '<option value="1"';
    19     if ($this->System->User->Redirecting == '1') $Output .= ' selected="selected"';
     20    if ($User->Redirecting == '1') $Output .= ' selected="selected"';
    2021    $Output .= '>'.T('To untranslated').'</option>';
    2122    $Output .= '<option value="2"';
    22     if ($this->System->User->Redirecting == '2') $Output .= ' selected="selected"';
     23    if ($User->Redirecting == '2') $Output .= ' selected="selected"';
    2324    $Output .= '>'.T('To next translation').'</option>';
    2425    $Output .= '<option value="3"';
    25     if ($this->System->User->Redirecting == '3') $Output .= ' selected="selected"';
     26    if ($User->Redirecting == '3') $Output .= ' selected="selected"';
    2627    $Output .= '>'.T('To previous translation').'</option>';
    2728    $Output .= '</select>';
    2829
    2930    $Output .= '</td></tr>'.
    30       '<tr><td>'.T('Preferred client version').': </td><td>'.ClientVersionSelection($this->System->User->PreferredVersion).'</td></tr>'.
     31      '<tr><td>'.T('Preferred client version').': </td><td>'.ClientVersionSelection($User->PreferredVersion).'</td></tr>'.
    3132      '<tr><td>'.T('Public profile text').':</td><td>'.
    32       '<textarea name="info" cols="60" rows="10">'.htmlspecialchars($this->System->User->Info).'</textarea></td></tr>';
     33      '<textarea name="info" cols="60" rows="10">'.htmlspecialchars($User->Info).'</textarea></td></tr>';
    3334
    3435    $Output .= '<tr><td>';
     
    4041      $Query = 'SELECT * FROM `UserTag` '.
    4142      //'LEFT JOIN `UserTagType` ON `UserTagType`.`ID` = `UserTag`.`UserTagType` '.
    42       'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($this->System->User->Id * 1);
     43      'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($User->Id * 1);
    4344      $DbResult2 = $this->Database->query($Query);
    4445      if ($DbResult2->num_rows != 0) $checked = true;
     
    6465    {
    6566      $Output .= '<option value="'.$LineTeam['Id'].'"';
    66       if ($LineTeam['Id'] == $this->System->User->Team) $Output .= ' selected="selected"';
     67      if ($LineTeam['Id'] == $User->Team) $Output .= ' selected="selected"';
    6768      $Output .= '>'.htmlspecialchars($LineTeam['Name']).'</option>';
    6869    }
     
    7778  {
    7879    $Output = '';
     80    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    7981    if (array_key_exists('Email', $_POST))
    8082    {
     
    9496        if ($NewPass == $NewPass2)
    9597        {
    96           $DbResult = $this->System->Database->query('SELECT `Pass`, '.$this->System->User->CryptPasswordSQL('"'.$OldPass.'"', '`Salt`').' AS `Hash` FROM `User` WHERE `ID`= '.$this->System->User->Id);
     98          $DbResult = $this->System->Database->query('SELECT `Pass`, '.$User->CryptPasswordSQL('"'.$OldPass.'"', '`Salt`').' AS `Hash` FROM `User` WHERE `ID`= '.$User->Id);
    9799          $DbRow = $DbResult->fetch_assoc();
    98100          if ($DbRow['Hash'] == $DbRow['Pass'])
    99101          {
    100102            // Update password
    101             $Salt = $this->System->User->GetPasswordSalt();
    102             $this->Database->query('UPDATE `User` SET `Pass` = '.$this->System->User->CryptPasswordSQL('"'.$NewPass.'"', '"'.$Salt.'"').', `Salt`="'.$Salt.'" WHERE `ID` = '.$this->System->User->Id);
     103            $Salt = $User->GetPasswordSalt();
     104            $this->Database->query('UPDATE `User` SET `Pass` = '.$User->CryptPasswordSQL('"'.$NewPass.'"', '"'.$Salt.'"').', `Salt`="'.$Salt.'" WHERE `ID` = '.$User->Id);
    103105            $Output .= ShowMessage('Heslo změněno.');
    104106          } else $Output .= ShowMessage('Staré heslo neodpovídá.', MESSAGE_CRITICAL);
     
    113115        {
    114116          $Query = 'SELECT * FROM `UserTag` '.
    115             'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($this->System->User->Id * 1);
     117            'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($User->Id * 1);
    116118          $DbResult2 = $this->Database->query($Query);
    117119          if ($DbResult2->num_rows == 0)
    118120          {
    119121            $Query = 'INSERT INTO `UserTag` (`ID` ,`UserTagType`,`User` ) '.
    120               'VALUES (NULL, '.$UserTag['ID'].' , '.($this->System->User->Id * 1).')';
     122              'VALUES (NULL, '.$UserTag['ID'].' , '.($User->Id * 1).')';
    121123            $DbResult2 = $this->Database->query($Query);
    122124          }
     
    124126        {
    125127          $Query = 'DELETE FROM `UserTag` '.
    126             'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($this->System->User->Id * 1);
     128            'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($User->Id * 1);
    127129          $DbResult2 = $this->Database->query($Query);
    128130        }
    129131      }
    130132
    131       $this->Database->update('User', '`ID` = '.$this->System->User->Id, array('Email' => $Email,
     133      $this->Database->update('User', '`ID` = '.$User->Id, array('Email' => $Email,
    132134        'Language' => $Language, 'Redirecting' => $Redirecting, 'Info' => $Info,
    133135        'PreferredVersion' => $PreferredVersion));
    134       $Output .= ShowMessage('Úprava nastavení proběhla v pořádku, Email: <b>'.$Email.'</b> Uživatel: <b>'.$this->System->User->Name.'</b>');
     136      $Output .= ShowMessage('Úprava nastavení proběhla v pořádku, Email: <b>'.$Email.'</b> Uživatel: <b>'.$User->Name.'</b>');
    135137      $this->System->ModuleManager->Modules['Log']->WriteLog('Úprava nastavení!', LOG_TYPE_USER);
    136       $this->System->User->Load();
     138      $User->Load();
    137139    } else $Output .= ShowMessage('Nezadány údaje.', MESSAGE_CRITICAL);
    138140    return $Output;
     
    143145    $this->Title = T('User settings');
    144146    $Output = '';
    145     if ($this->System->User->Licence(LICENCE_USER))
     147    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     148    if ($User->Licence(LICENCE_USER))
    146149    {
    147150      if (array_key_exists('action', $_GET) and ($_GET['action'] == 'save'))
Note: See TracChangeset for help on using the changeset viewer.