Changeset 893 for trunk/Modules/News


Ignore:
Timestamp:
Mar 6, 2023, 1:48:45 AM (22 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.
Location:
trunk/Modules/News
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/News/News.php

    r891 r893  
    55class ModuleNews extends Module
    66{
    7   var $RSSChannels;
     7  public array $RSSChannels;
     8  public array $RSSChannelsPos;
    89
    910  function __construct(System $System)
     
    5657  function ShowRSSHeader()
    5758  {
     59    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    5860    $Output = '';
    5961    foreach ($this->RSSChannels as $Channel)
    6062    {
    61       if ($this->System->User->Licence($Channel['Permission']))
     63      if ($User->Licence($Channel['Permission']))
    6264        $Output .= ' <link rel="alternate" title="'.$Channel['Title'].'" href="'.
    63           $this->System->Link('/rss/?channel='.$Channel['Channel']).'" type="application/rss+xml" />';
     65        $this->System->Link('/rss/?channel='.$Channel['Channel']).'" type="application/rss+xml" />';
    6466    }
    6567    return $Output;
     
    8486  function ShowList()
    8587  {
     88    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    8689    $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `News`');
    8790    $DbRow = $DbResult->fetch_row();
     
    8992
    9093    $Output = '<h3>'.T('News').'</h3>';
    91     if ($this->System->User->Licence(LICENCE_ADMIN))
     94    if ($User->Licence(LICENCE_ADMIN))
    9295      $Output .= ' <a href="?a=add">'.T('Add').'</a>';
    9396    $Output .= $PageList['Output'];
     
    122125  function ShowAddForm()
    123126  {
    124     if ($this->System->User->Licence(LICENCE_ADMIN))
     127    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     128    if ($User->Licence(LICENCE_ADMIN))
    125129    {
    126130      $Output = '<form action="?" method="POST">'.
    127131        '<fieldset><legend>'.T('New news').'</legend>'.
    128         T('User').': '.$this->System->User->Name.'('.$this->System->User->Id.')<br/> '.
     132        T('User').': '.$User->Name.'('.$User->Id.')<br/> '.
    129133        T('Title').': <input type="text" name="title" size="40"/><br/>'.
    130134        T('Content').': <textarea rows="8" cols="40" onkeydown="ResizeTextArea(this)" class="textedit" id="Text" name="text"></textarea><br/>'.
     
    139143  function SaveNew()
    140144  {
    141     if ($this->System->User->Licence(LICENCE_ADMIN))
     145    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     146    if ($User->Licence(LICENCE_ADMIN))
    142147    {
    143148      if (array_key_exists('text', $_POST) and array_key_exists('title', $_POST))
    144149      {
    145150        $querty = 'INSERT INTO `News` (`Title`, `Time` ,`User` ,`Text`) VALUES ( "'.$_POST['title'].'", NOW( ) , '.
    146            $this->System->User->Id.', "'.$_POST['text'].'")';
     151           $User->Id.', "'.$_POST['text'].'")';
    147152        $this->System->Database->query($querty);
    148153        $Output = ShowMessage(T('News added'));
     
    162167    while ($DbRow = $DbResult->fetch_assoc())
    163168    {
    164      $Items[] = array
    165      (
    166        'Title' => $DbRow['Title'],
    167        'Link' =>  'https://'.$this->System->Config['Web']['Host'].$this->System->Link('/news/?a=item&amp;i='.$DbRow['Id']),
    168        'Description' => $DbRow['Text'].' ('.$DbRow['Name'].')',
    169        'Time' => $DbRow['UnixTime'],
    170      );
     169      $Items[] = array
     170      (
     171        'Title' => $DbRow['Title'],
     172        'Link' =>  'https://'.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/news/?a=item&amp;i='.$DbRow['Id']),
     173        'Description' => $DbRow['Text'].' ('.$DbRow['Name'].')',
     174        'Time' => $DbRow['UnixTime'],
     175      );
    171176    }
    172177    $Output = GenerateRSS(array
    173178    (
    174       'Title' => $this->System->Config['Web']['Title'].' - '.T('System changes'),
    175       'Link' => 'https://'.$this->System->Config['Web']['Host'].$this->System->Link('/news/'),
    176       'Description' => $this->System->Config['Web']['Description'],
    177       'WebmasterEmail' => $this->System->Config['Web']['AdminEmail'],
     179      'Title' => Core::Cast($this->System)->Config['Web']['Title'].' - '.T('System changes'),
     180      'Link' => 'https://'.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/news/'),
     181      'Description' => Core::Cast($this->System)->Config['Web']['Description'],
     182      'WebmasterEmail' => Core::Cast($this->System)->Config['Web']['AdminEmail'],
    178183      'Items' => $Items,
    179184    ));
  • trunk/Modules/News/RSS.php

    r888 r893  
    3333  function Show(): string
    3434  {
     35    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    3536    $this->RawPage = true;
    3637
     
    4243    {
    4344      $Channel = $this->System->ModuleManager->Modules['News']->RSSChannels[$ChannelName];
    44       if ($this->System->User->Licence($Channel['Permission']) or
    45       $this->System->User->CheckToken($Channel['Permission'], $Token))
     45      if ($User->Licence($Channel['Permission']) or
     46      $User->CheckToken($Channel['Permission'], $Token))
    4647      {
    4748        if (is_string($Channel['Callback'][0]))
Note: See TracChangeset for help on using the changeset viewer.