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

Legend:

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