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/Forum/Forum.php

    r891 r893  
    6868  function Show(): string
    6969  {
     70    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    7071    $Output = '';
    7172    $this->Title = T('Forum');
     
    8485      $Output .= '<h3>'.T('Forum - Thread').'</h3>';
    8586      if ($Action == 'add2') $Output .= $this->AddFinish();
    86       if ($this->System->User->Licence(LICENCE_USER)) $Output .= $this->ShowAddForm();
     87      if ($User->Licence(LICENCE_USER)) $Output .= $this->ShowAddForm();
    8788      $Output .= $this->ShowList();
    8889    } else {
    8990      $Output .= '<h3>'.T('Forum - List of Thread').'</h3>';
    9091      if ($Action == 'add2') $Output .= $this->AddFinish('ForumThread');
    91       if ($this->System->User->Licence(LICENCE_USER)) $Output .= $this->ShowAddFormThread();
     92      if ($User->Licence(LICENCE_USER)) $Output .= $this->ShowAddFormThread();
    9293      $Output .= $this->ShowListThread();
    9394    }
     
    9798  function Edit()
    9899  {
    99     $Output = '';
    100     $this->System->Database->query('UPDATE `ForumText` SET `Text`="'.$_POST['text'].'" WHERE `User` = '.$this->System->User->Id.' AND `ID` = '.$_GET['Edit']);
     100    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     101    $Output = '';
     102    $this->System->Database->query('UPDATE `ForumText` SET `Text`="'.$_POST['text'].'" WHERE `User` = '.$User->Id.' AND `ID` = '.$_GET['Edit']);
    101103    $Output .= ShowMessage(T('Text edited.'));
    102104    return $Output;
     
    105107  function ShowEditForm()
    106108  {
    107     $Output = '';
    108     if ($this->System->User->Licence(LICENCE_USER))
    109     {
    110       $DbResult = $this->System->Database->query('SELECT * FROM `ForumText`  WHERE `User` = '.$this->System->User->Id.' AND `ID` = '.$_GET['Edit']);
     109    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     110    $Output = '';
     111    if ($User->Licence(LICENCE_USER))
     112    {
     113      $DbResult = $this->System->Database->query('SELECT * FROM `ForumText`  WHERE `User` = '.$User->Id.' AND `ID` = '.$_GET['Edit']);
    111114      if ( $DbResult->num_rows > 0) {
    112115        $DbRow = $DbResult->fetch_assoc();
     
    114117            '<fieldset><legend>'.T('Edit message').'</legend>'.
    115118            T('User').': ';
    116         if ($this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />';
     119        if ($User->Licence(LICENCE_USER)) $Output .= '<b>'.$User->Name.'</b><br />';
    117120          else $Output .= '<input type="text" name="user" /><br />';
    118121        $Output .= T('Message text').': ('.T('You can use').' <a href="http://www.bbcode.org/reference.php">'.T('BB code').'</a>)<br/>'.
     
    173176  function ShowList()
    174177  {
     178    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    175179    $Output = '';
    176180
     
    200204    while ($Line = $DbResult->fetch_assoc())
    201205    {
    202       if ($this->System->User->Id == $Line['User'])
     206      if ($User->Id == $Line['User'])
    203207      {
    204208        $edit = '<a href="?Edit='.$Line['ID'].'">'.T('edit').'</a>';
     
    215219  function ShowAddForm()
    216220  {
    217     $Output = '';
    218     if ($this->System->User->Licence(LICENCE_USER))
     221    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     222    $Output = '';
     223    if ($User->Licence(LICENCE_USER))
    219224    {
    220225      $Output .= '<form action="?Thread='.$_GET['Thread'].'" method="post">'.
    221226        '<fieldset><legend>'.T('New Forum Message').'</legend>'.
    222227        T('User').': ';
    223       if ($this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />';
     228      if ($User->Licence(LICENCE_USER)) $Output .= '<b>'.$User->Name.'</b><br />';
    224229        else $Output .= '<input type="text" name="user" /><br />';
    225230      $Output .= T('Message text').': ('.T('You can use').' <a href="http://www.bbcode.org/reference.php">'.T('BB code').'</a>)<br/>'.
     
    234239  function ShowAddFormThread()
    235240  {
    236     $Output = '';
    237     if ($this->System->User->Licence(LICENCE_USER))
     241    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     242    $Output = '';
     243    if ($User->Licence(LICENCE_USER))
    238244    {
    239245      $Output .= '<form action="?" method="post">'.
    240246        '<fieldset><legend>'.T('New thread').'</legend>'.T('User').': ';
    241       if ($this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />';
     247      if ($User->Licence(LICENCE_USER)) $Output .= '<b>'.$User->Name.'</b><br />';
    242248        else $Output .= '<input type="text" name="user" /><br />';
    243249      $Output .= T('Name of thread').': <br />'.
     
    252258  function AddFinish($Table = 'ForumText')
    253259  {
    254     $Output = '';
    255     if ($this->System->User->Licence(LICENCE_USER))
     260    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     261    $Output = '';
     262    if ($User->Licence(LICENCE_USER))
    256263    {
    257264      if (array_key_exists('text', $_POST))
     
    265272          if ($Table == 'ForumText') $Thread = 'AND `Thread` = '.$_GET['Thread'];
    266273          $DbResult = $this->System->Database->query('SELECT `Text` FROM `'.$Table.'` WHERE 1 '.$Thread.' AND (`User` = "'.
    267               $this->System->User->Id.'") ORDER BY `Date` DESC LIMIT 1');
     274              $User->Id.'") ORDER BY `Date` DESC LIMIT 1');
    268275          if ($DbResult->num_rows > 0)
    269276          {
     
    280287              {
    281288                $this->System->Database->query('INSERT INTO `'.$Table.'` ( `User`, `UserName` , `Text` , `Date` , `IP` , `Thread` ) '.
    282                 ' VALUES ('.$this->System->User->Id.', "'.$this->System->User->Name.
     289                ' VALUES ('.$User->Id.', "'.$User->Name.
    283290                '", "'.$Text.'", NOW(), "'.GetRemoteAddress().'","'.$_GET['Thread'].'")');
    284291              } else $Output .= ShowMessage(T('Item not found'), MESSAGE_CRITICAL);
    285292             } else
    286293            $this->System->Database->query('INSERT INTO `'.$Table.'` ( `User`, `UserName` , `Text` , `Date` , `IP`) '.
    287                 ' VALUES ('.$this->System->User->Id.', "'.$this->System->User->Name.
     294                ' VALUES ('.$User->Id.', "'.$User->Name.
    288295                '", "'.$Text.'", NOW(), "'.GetRemoteAddress().'")');
    289296            $Output .= ShowMessage(T('Added.'));
     
    311318      (
    312319        'Title' => htmlspecialchars($DbRow['ThreadText']).' - '.$DbRow['UserName'].': ',
    313         'Link' => 'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/forum/?Thread='.$DbRow['Thread']),
     320        'Link' => 'https://'.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/forum/?Thread='.$DbRow['Thread']),
    314321        'Description' => ShowBBcodes(htmlspecialchars($DbRow['Text'])),
    315322        'Time' => $DbRow['UnixDate'],
     
    318325    $Output = GenerateRSS(array
    319326    (
    320       'Title' => $this->System->Config['Web']['Title'].' - '.T('Forum'),
    321       'Link' => 'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/forum/'),
    322       'Description' => $this->System->Config['Web']['Description'],
    323       'WebmasterEmail' => $this->System->Config['Web']['AdminEmail'],
     327      'Title' => Core::Cast($this->System)->Config['Web']['Title'].' - '.T('Forum'),
     328      'Link' => 'https://'.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/forum/'),
     329      'Description' => Core::Cast($this->System)->Config['Web']['Description'],
     330      'WebmasterEmail' => Core::Cast($this->System)->Config['Web']['AdminEmail'],
    324331      'Items' => $Items,
    325332    ));
Note: See TracChangeset for help on using the changeset viewer.