Changeset 892 for trunk


Ignore:
Timestamp:
Mar 3, 2023, 11:36:26 PM (21 months ago)
Author:
chronos
Message:
  • Fixed: User profile and options in case of incorrectly set null user info.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/UpdateTrace.php

    r890 r892  
    29732973}
    29742974
     2975function UpdateTo892($Manager)
     2976{
     2977  $Manager->Execute('ALTER TABLE `User` CHANGE `Info` `Info` TEXT CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT '';');
     2978}
     2979
    29752980class Updates
    29762981{
     
    30133018      872 => array('Revision' => 873, 'Function' => 'UpdateTo873'),
    30143019      873 => array('Revision' => 887, 'Function' => 'UpdateTo887'),
     3020      887 => array('Revision' => 892, 'Function' => 'UpdateTo892'),
    30153021    );
    30163022  }
  • trunk/Application/Version.php

    r891 r892  
    77
    88$Version = '1.0';
    9 $Revision = 891; // Subversion revision
    10 $DatabaseRevision = 887; // Database structure revision
    11 $ReleaseDate = strtotime('2023-01-13');
     9$Revision = 892; // Subversion revision
     10$DatabaseRevision = 891; // Database structure revision
     11$ReleaseDate = strtotime('2023-03-03');
  • trunk/Modules/User/Options.php

    r888 r892  
    1515    <tr><td>'.T('After save translation redirect to').': </td><td>';
    1616    $Output .= '<select name="redirecting">'.
    17         '<option value="0">'.T('Nowhere').'</option>'.
    18         '<option value="1"';
     17      '<option value="0">'.T('Nowhere').'</option>'.
     18      '<option value="1"';
    1919    if ($this->System->User->Redirecting == '1') $Output .= ' selected="selected"';
    2020    $Output .= '>'.T('To untranslated').'</option>';
     
    3636    $DbResult = $this->Database->query($Query);
    3737    $Output .= T('User obey selected rules').':</td><td>';
    38     while ($UserTag = $DbResult->fetch_array()) {
    39      $Query = 'SELECT * FROM `UserTag` '.
    40      //'LEFT JOIN `UserTagType` ON `UserTagType`.`ID` = `UserTag`.`UserTagType` '.
    41      'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($this->System->User->Id * 1);
     38    while ($UserTag = $DbResult->fetch_array())
     39    {
     40      $Query = 'SELECT * FROM `UserTag` '.
     41      //'LEFT JOIN `UserTagType` ON `UserTagType`.`ID` = `UserTag`.`UserTagType` '.
     42      'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($this->System->User->Id * 1);
    4243      $DbResult2 = $this->Database->query($Query);
    4344      if ($DbResult2->num_rows != 0) $checked = true;
    44       else $checked = false;
     45        else $checked = false;
    4546
    4647      $Output .= CheckBox('Tag'.$UserTag['ID'], $checked, 'CheckBox');
     
    5051
    5152    $Output .= '<tr><td colspan="2"><input type="submit" value="'.T('Save').'" /></td></tr>'.
    52         '</table></fieldset>'.
    53         '</form>';
     53      '</table></fieldset>'.
     54      '</form>';
    5455
    5556    $Output .= '<fieldset><legend>'.T('Translation team').'</legend>';
    5657    $DbResult = $this->Database->query('SELECT `Id`, `Name` FROM `Team`');
    5758    $Output .= '<a href="'.$this->System->Link('/team/?action=create').'">'.T('Create team').'</a><br />'.
    58         '<a href="'.$this->System->Link('/team/?action=leave').'">'.T('Leave team').'</a><br />'.
    59         '<br /><form action="'.$this->System->Link('/team/').'" method="get">'.
    60         '<input type="hidden" name="action" value="gointeam"/>'.
    61         '<select name="id">';
     59      '<a href="'.$this->System->Link('/team/?action=leave').'">'.T('Leave team').'</a><br />'.
     60      '<br /><form action="'.$this->System->Link('/team/').'" method="get">'.
     61      '<input type="hidden" name="action" value="gointeam"/>'.
     62      '<select name="id">';
    6263    while ($LineTeam = $DbResult->fetch_assoc())
    6364    {
     
    107108      $Query = 'SELECT * FROM UserTagType';
    108109      $DbResult = $this->Database->query($Query);
    109       while ($UserTag = $DbResult->fetch_array()) {
    110        if (array_key_exists('Tag'.$UserTag['ID'], $_POST)) {
    111          $Query = 'SELECT * FROM `UserTag` '.
    112          'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($this->System->User->Id * 1);
    113          $DbResult2 = $this->Database->query($Query);
    114          if ($DbResult2->num_rows == 0) {
    115            $Query = 'INSERT INTO `UserTag` (`ID` ,`UserTagType`,`User` ) '.
    116            'VALUES (NULL, '.$UserTag['ID'].' , '.($this->System->User->Id * 1).')';
    117            $DbResult2 = $this->Database->query($Query);
    118          }
    119        } else {
    120          $Query = 'DELETE FROM `UserTag` '.
    121          'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($this->System->User->Id * 1);
    122          $DbResult2 = $this->Database->query($Query);
    123        }
     110      while ($UserTag = $DbResult->fetch_array())
     111      {
     112        if (array_key_exists('Tag'.$UserTag['ID'], $_POST))
     113        {
     114          $Query = 'SELECT * FROM `UserTag` '.
     115            'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($this->System->User->Id * 1);
     116          $DbResult2 = $this->Database->query($Query);
     117          if ($DbResult2->num_rows == 0)
     118          {
     119            $Query = 'INSERT INTO `UserTag` (`ID` ,`UserTagType`,`User` ) '.
     120              'VALUES (NULL, '.$UserTag['ID'].' , '.($this->System->User->Id * 1).')';
     121            $DbResult2 = $this->Database->query($Query);
     122          }
     123        } else
     124        {
     125          $Query = 'DELETE FROM `UserTag` '.
     126            'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($this->System->User->Id * 1);
     127          $DbResult2 = $this->Database->query($Query);
     128        }
    124129      }
    125130
  • trunk/Modules/User/Profile.php

    r891 r892  
    170170        'WHERE `User` = '.($_GET['user'] * 1);
    171171      $DbResult = $this->Database->query($Query);
    172       if ($DbResult->num_rows != 0) {
     172      if ($DbResult->num_rows != 0)
     173      {
    173174        $Output .= T('Translator is using this rules:').'<br />';
    174175        $Output .= '<ul>';
     
    179180      }
    180181
    181     $Output .= '<br /><fieldset><legend>'.T('Profile text').'</legend>'.htmlspecialchars(str_replace("\n", '<br/>', $UserLine['Info'])).'</fieldset><br/>';
    182 
    183     $Output .= '<table class="Home"><tr>'.
    184       '<td>'.$this->ShowLastTranslated().'</td>'.
    185       '<td>'.$this->ExportList().'</td>'.
    186       '</tr></table>';
    187     $Output .= '<br />'.$this->ShowLastForum().'<br />';
    188     if ($this->System->User->Licence(LICENCE_MODERATOR))
    189     {
    190       $Output .= '<fieldset><legend>Moderování</legend>';
    191 
    192       $Output .= '<form action="?user='.($_GET['user'] * 1).'" method="post">Přidání tagu uživateli:<br />';
    193       $Query = 'SELECT * FROM `UserTagType`';
    194       $DbResult = $this->Database->query($Query);
    195       while ($UserTag = $DbResult->fetch_array()) {
    196         //save:
    197        if (array_key_exists('save', $_POST)) {
    198         if (array_key_exists('Tag'.$UserTag['ID'], $_POST)) {
     182      $UserInfo = $UserLine['Info'];
     183      if ($UserInfo == null) $UserInfo = '';
     184      $UserInfo = htmlspecialchars(str_replace("\n", '<br/>', $UserInfo));
     185      $Output .= '<br /><fieldset><legend>'.T('Profile text').'</legend>'.$UserInfo.'</fieldset><br/>';
     186
     187      $Output .= '<table class="Home"><tr>'.
     188        '<td>'.$this->ShowLastTranslated().'</td>'.
     189        '<td>'.$this->ExportList().'</td>'.
     190        '</tr></table>';
     191      $Output .= '<br />'.$this->ShowLastForum().'<br />';
     192      if ($this->System->User->Licence(LICENCE_MODERATOR))
     193      {
     194        $Output .= '<fieldset><legend>Moderování</legend>';
     195
     196        $Output .= '<form action="?user='.($_GET['user'] * 1).'" method="post">Přidání tagu uživateli:<br />';
     197        $Query = 'SELECT * FROM `UserTagType`';
     198        $DbResult = $this->Database->query($Query);
     199        while ($UserTag = $DbResult->fetch_array())
     200        {
     201          //save:
     202          if (array_key_exists('save', $_POST))
     203          {
     204            if (array_key_exists('Tag'.$UserTag['ID'], $_POST))
     205            {
     206              $Query = 'SELECT * FROM `UserTag` '.
     207                'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($_GET['user']*1);
     208              $DbResult2 = $this->Database->query($Query);
     209              if ($DbResult2->num_rows == 0)
     210              {
     211                $Query = 'INSERT INTO `UserTag` (`ID` ,`UserTagType`,`User` ) '.
     212                  'VALUES (NULL, '.$UserTag['ID'].' , '.($_GET['user']*1).')';
     213                $DbResult2 = $this->Database->query($Query);
     214              }
     215            } else
     216            {
     217              $Query = 'DELETE FROM `UserTag` '.
     218                'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($_GET['user'] * 1);
     219              $DbResult2 = $this->Database->query($Query);
     220            }
     221          }
     222
    199223          $Query = 'SELECT * FROM `UserTag` '.
    200           'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($_GET['user']*1);
     224            'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($_GET['user'] * 1);
    201225          $DbResult2 = $this->Database->query($Query);
    202           if ($DbResult2->num_rows == 0) {
    203             $Query = 'INSERT INTO `UserTag` (`ID` ,`UserTagType`,`User` ) '.
    204             'VALUES (NULL, '.$UserTag['ID'].' , '.($_GET['user']*1).')';
    205             $DbResult2 = $this->Database->query($Query);
    206           }
    207         } else {
    208            $Query = 'DELETE FROM `UserTag` '.
    209            'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($_GET['user'] * 1);
    210            $DbResult2 = $this->Database->query($Query);
     226          if ($DbResult2->num_rows != 0) $checked = true;
     227            else $checked = false;
     228
     229          $Output .= CheckBox('Tag'.$UserTag['ID'], $checked, 'CheckBox');
     230          $Output .= ''.$UserTag['Text'].'<br />';
    211231        }
    212        }
    213 
    214         $Query = 'SELECT * FROM `UserTag` '.
    215         'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($_GET['user'] * 1);
    216         $DbResult2 = $this->Database->query($Query);
    217         if ($DbResult2->num_rows != 0) $checked = true;
    218         else  $checked = false;
    219 
    220         $Output .= CheckBox('Tag'.$UserTag['ID'], $checked, 'CheckBox');
    221         $Output .= ''.$UserTag['Text'].'<br />';
    222       }
    223       $Output .= '<input name="save" type="submit" value="Uložit" /></form>';
    224 
    225       $Output .= ' PosledníIP: <strong>'.$UserLine['LastIP'].'</strong><br />'.
     232        $Output .= '<input name="save" type="submit" value="Uložit" /></form>';
     233
     234        $Output .= ' PosledníIP: <strong>'.$UserLine['LastIP'].'</strong><br />'.
    226235          'Prohlížeč: <strong>'.$UserLine['UserAgent'].'</strong><br />'.
    227236          'Email: <strong>'.$UserLine['Email'].'</strong><br />';
    228       $Output .= '<br/><form action="'.$this->System->Link('/user/').'" method="post"><div>'.
    229         'Napsat E-mail:'.
    230         '<input type="text" name="email" value="'.$UserLine['Email'].'" /><br/>'.
    231         'Předmět:'.
    232         '<input type="text" name="subject" value="'.$this->System->Config['Web']['Title'].'" />'.
    233         '<br />'.
    234         '<textarea name="text" rows="20" cols="62">'.
    235         ''."\n".
    236         'S pozdravem '.$this->System->User->Name."\n".
    237         '--------------------------------------------------------'."\n".
    238         $this->System->Config['Web']['Title'].' '.$this->System->Config['Web']['Host'].$this->System->Link('/')."\n".
    239         '</textarea><br/>'.
    240         '<input type="submit" value="Odeslat" />'.
    241         '</div></form></fieldset>';
     237        $Output .= '<br/><form action="'.$this->System->Link('/user/').'" method="post"><div>'.
     238          'Napsat E-mail:'.
     239          '<input type="text" name="email" value="'.$UserLine['Email'].'" /><br/>'.
     240          'Předmět:'.
     241          '<input type="text" name="subject" value="'.$this->System->Config['Web']['Title'].'" />'.
     242          '<br />'.
     243          '<textarea name="text" rows="20" cols="62">'.
     244          ''."\n".
     245          'S pozdravem '.$this->System->User->Name."\n".
     246          '--------------------------------------------------------'."\n".
     247          $this->System->Config['Web']['Title'].' '.$this->System->Config['Web']['Host'].$this->System->Link('/')."\n".
     248          '</textarea><br/>'.
     249          '<input type="submit" value="Odeslat" />'.
     250          '</div></form></fieldset>';
    242251      }
    243252    } else $Output .= ShowMessage('Uživatel nenalezen', MESSAGE_CRITICAL);
  • trunk/Modules/User/User.php

    r888 r892  
    204204      $this->Email = $User['Email'];
    205205      $this->Info = $User['Info'];
     206      if ($this->Info == null) $this->Info = '';
    206207      $this->PreferredVersion = $User['PreferredVersion'];
    207208      $this->PreferredVersionGame = $User['PreferredVersionGame'];
Note: See TracChangeset for help on using the changeset viewer.