Changeset 953 for trunk


Ignore:
Timestamp:
Aug 11, 2023, 11:17:28 AM (17 months ago)
Author:
chronos
Message:
  • Added: News can be set as intranet only.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/UpdateTrace.php

    r948 r953  
    22322232{
    22332233  $Manager->Execute('ALTER TABLE `News` CHANGE `IP` `IP` VARCHAR(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL;');
     2234}
     2235
     2236function UpdateTo953(UpdateManager $Manager): void
     2237{
     2238  $Manager->Execute('ALTER TABLE `News` ADD `Intranet` INT NOT NULL DEFAULT "0" AFTER `Link`;');
    22342239}
    22352240
     
    23432348      911 => array('Revision' => 921, 'Function' => 'UpdateTo921'),
    23442349      921 => array('Revision' => 933, 'Function' => 'UpdateTo933'),
    2345       933 => array('Revision' => 939, 'Function' => 'UpdateTo939'),
     2350      933 => array('Revision' => 939, 'Function' => 'UpdateTo939'),     
    23462351      939 => array('Revision' => 948, 'Function' => 'UpdateTo948'),
     2352      948 => array('Revision' => 953, 'Function' => 'UpdateTo953'),
    23472353    );
    23482354  }
  • trunk/Application/Version.php

    r948 r953  
    11<?php
    22
    3 $Revision = 948; // Subversion revision
    4 $DatabaseRevision = 948; // SQL structure revision
    5 $ReleaseTime = strtotime('2022-12-06');
     3$Revision = 953; // Subversion revision
     4$DatabaseRevision = 953; // SQL structure revision
     5$ReleaseTime = strtotime('2023-08-11');
  • trunk/Common/Global.php

    r942 r953  
    275275  $Result = true;
    276276  $RemoteAddr = GetRemoteAddress();
    277   foreach (array_merge($Config['Web']['IntranetSubnets']) as $Subnet)
     277  foreach ($Config['Web']['IntranetSubnets'] as $Subnet)
    278278  {
    279279    if (substr($RemoteAddr, 0, strlen($Subnet)) == $Subnet)
  • trunk/Modules/News/News.php

    r938 r953  
    1616  public int $NewsCountPerCategory = 3;
    1717  public string $UploadedFilesFolder = 'files/news/';
     18  public array $NewsSetting;
    1819
    1920  function __construct(System $System)
     
    8687  }
    8788
     89  function GetIntranetCondition(): string
     90  {
     91    if (IsInternetAddr()) return ' AND (`Intranet`=0)';
     92      else return '';
     93  }
     94
    8895  function ShowNews(string $Category, int $ItemCount, int $DaysAgo): string
    8996  {
     
    97104      $Output .= ' <a href="aktuality/?action=add&amp;category='.$Category.'">Přidat</a>';
    98105    $Output .= '</div></div><div class="Content">';
    99     $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE (`News`.`Category`='.$Category.') AND (DATE_SUB(NOW(), INTERVAL '.$DaysAgo.' DAY) < `News`.`Date`) ORDER BY `News`.`Date` DESC LIMIT 0,'.$ItemCount);
     106    $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` LEFT JOIN `User` ON `User`.`Id`=`News`.`User`'.
     107      ' WHERE (`News`.`Category`='.$Category.') AND (DATE_SUB(NOW(), INTERVAL '.$DaysAgo.' DAY) < `News`.`Date`)'.$this->GetIntranetCondition().
     108      ' ORDER BY `News`.`Date` DESC LIMIT 0,'.$ItemCount);
    100109
    101110    $Index = 0;
     
    162171  {
    163172    $Output = '';
    164 
     173   
    165174    $this->LoadSettingsFromCookies();
    166175
  • trunk/Modules/News/NewsPage.php

    r929 r953  
    1111  }
    1212
     13  function GetIntranetCondition(): string
     14  {
     15    if (IsInternetAddr()) return ' AND (`Intranet`=0)';
     16      else return '';
     17  }
     18
    1319  function ShowView(): string
    1420  {
     
    2026      if (array_key_exists('id', $_GET)) $Id = $_GET['id'] * 1;
    2127      $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` '.
    22         'LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `News`.`Id`='.$Id);
     28        'LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE (`News`.`Id`='.$Id.')'.$this->GetIntranetCondition());
    2329      if ($DbResult->num_rows > 0)
    2430      {
     
    8086        'Obsah:<br /><textarea name="content" rows="20" cols="40"></textarea><br />'.
    8187        'Odkaz:<br /><input type="text" size="54" name="link"><br />'.
     88        'Viditelné jen z vnitřní sítě: <input type="checkbox" name="intranet"/><br />'.
    8289        'Přílohy (Max. velikost souboru 1 MB):<br /><input type="hidden" name="MAX_FILE_SIZE" value="1000000">'.
    8390        '<input name="enclosure1" size="38" type="file"><br />'.
     
    116123        }
    117124        $Enclosures = substr($Enclosures, 1);
     125        if (array_key_exists('intranet', $_POST)) $Intranet = 1;
     126          else $Intranet = 0;
    118127
    119128        $this->Database->insert('News', array('Category' => $Category['Id'], 'Title' => $_POST['title'],
    120129          'Content' => $_POST['content'], 'Date' => 'NOW()', 'IP' => $RemoteAddr,
    121130          'Enclosure' => $Enclosures, 'Author' => $User->User['Name'],
    122           'User' => $User->User['Id'], 'Link' => $_POST['link']));
     131          'User' => $User->User['Id'], 'Link' => $_POST['link'], 'Intranet' => $Intranet));
    123132        $Output .= 'Aktualita přidána!<br />Pokud budete chtít vaši aktualitu smazat, klikněte na odkaz Smazat v seznamu všech aktualit v kategorii.<br /><br />';
    124133        $Output .= '<a href="?category='.$_POST['category'].'">Zpět na seznam aktualit</a>';
     
    154163    if ($User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
    155164    {
    156       $DbResult = $this->Database->query('SELECT * FROM `News` WHERE `Id`='.$_GET['id']);
     165      $DbResult = $this->Database->query('SELECT * FROM `News` WHERE (`Id`='.$_GET['id'].')'.$this->GetIntranetCondition());
    157166      $Row = $DbResult->fetch_assoc();
    158167      if (($User->User['Id'] == $Row['User']))
    159168      {
     169        if ($Row['Intranet'] == 1) $IntranetChecked = ' checked="1"';
     170          else $IntranetChecked = 0;
    160171        $this->System->PageHeaders[] = array($this, 'GetPageHeader');
    161172        $Output .= '<strong>Editace aktuality v kategorii '.$Category['Caption'].':</strong><br />';
     
    165176        'Obsah:<br /><textarea name="content" rows="20" cols="40" style="width: 50%">'.$Row['Content'].'</textarea><br />'.
    166177        'Odkaz:<br /><input type="text" size="54" name="link" value="'.$Row['Link'].'"><br />'.
     178        'Viditelné jen z vnitřní sítě: <input type="checkbox" name="intranet" '.$IntranetChecked.'/><br />'.
    167179        '<input type="hidden" name="category" value="'.$Category['Id'].'"><br />'.
    168180        '<input type="submit" value="Uložit">'.
     
    182194    {
    183195      $_POST['id'] = $_POST['id'] * 1;
    184       $DbResult = $this->Database->select('News', '*', '`Id`='.$_POST['id']);
     196      $DbResult = $this->Database->select('News', '*', '(`Id`='.$_POST['id'].')'.$this->GetIntranetCondition());
    185197      if ($DbResult->num_rows > 0)
    186198      {
     
    188200        if ($User->User['Id'] == $Row['User'])
    189201        {
     202          if (array_key_exists('intranet', $_POST)) $Intranet = 1;
     203            else $Intranet = 0;
     204         
    190205          $this->Database->update('News', 'Id='.$_POST['id'], array('Title' => $_POST['title'],
    191             'Content' => $_POST['content'], 'Link' => $_POST['link']));
     206            'Content' => $_POST['content'], 'Link' => $_POST['link'], 'Intranet' => $Intranet));
    192207          $Output .= 'Aktualita uložena!<br />';
    193208          $Output .= '<a href="?category='.$Category['Id'].'">Zpět na seznam aktualit</a>';
     
    205220    if ($User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
    206221    {
    207       $DbResult = $this->Database->query('SELECT * FROM `News` WHERE `Id`='.$_GET['id']);
     222      $DbResult = $this->Database->query('SELECT * FROM `News` WHERE (`Id`='.$_GET['id'].')'.$this->GetIntranetCondition());
    208223      $Row = $DbResult->fetch_assoc();
    209224      if ($User->User['Id'] == $Row['User'])
     
    234249    {
    235250      $PerPage = 20;
    236       $DbResult = $this->Database->select('News', 'COUNT(*)', ' `Category`='.$Category['Id']);
     251      $DbResult = $this->Database->select('News', 'COUNT(*)', '(`Category`='.$Category['Id'].')'.$this->GetIntranetCondition());
    237252      $RowTotal = $DbResult->fetch_array();
    238253      $PageMax = $RowTotal[0];
     
    243258
    244259      $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` '.
    245         'LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `Category`='.$Category['Id'].' ORDER BY `News`.`Id` DESC LIMIT '.($Page * $PerPage).','.$PerPage);
     260        'LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE (`Category`='.$Category['Id'].')'.$this->GetIntranetCondition().
     261        ' ORDER BY `News`.`Id` DESC LIMIT '.($Page * $PerPage).','.$PerPage);
    246262      while ($Row = $DbResult->fetch_assoc())
    247263      {
  • trunk/Modules/News/NewsSource.php

    r938 r953  
    6464{
    6565  public Database $Database;
     66  public array $Items;
    6667
    6768  function Parse($Id = null)
Note: See TracChangeset for help on using the changeset viewer.