Changeset 956 for trunk


Ignore:
Timestamp:
Sep 4, 2023, 11:30:03 PM (16 months ago)
Author:
chronos
Message:
  • Added: Show notify item page on web.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Version.php

    r954 r956  
    11<?php
    22
    3 $Revision = 954; // Subversion revision
     3$Revision = 956; // Subversion revision
    44$DatabaseRevision = 953; // SQL structure revision
    5 $ReleaseTime = strtotime('2023-08-11');
     5$ReleaseTime = strtotime('2023-09-04');
  • trunk/Modules/Notify/Notify.php

    r925 r956  
    4040      ),
    4141    ));
     42    $this->System->RegisterPage(['notify'], 'PageNotify');
    4243    $this->System->RegisterCommandLine('notify', 'Perform notifications processing.', array($this, 'RunCheck'));
    4344    ModuleRSS::Cast($this->System->GetModule('RSS'))->RegisterRSS(array('Title' => 'Notify log',
    44     'Channel' => 'notifylog', 'Callback' => array($this, 'ShowLogRSS'),
    45     'Permission' => array('Module' => 'Notify', 'Operation' => 'RSS')));
     45      'Channel' => 'notifylog', 'Callback' => array($this, 'ShowLogRSS'),
     46      'Permission' => array('Module' => 'Notify', 'Operation' => 'RSS')));
    4647  }
    4748
     
    124125
    125126    return $Output;
    126   }
     127  } 
    127128
    128129  function RunCheck(array $Parameters): void
     
    147148    $this->FormatHTML = false;
    148149    Header('Content-Type: text/xml');
    149     $Count = 100;
    150 
    151     $Output = '';
     150    $Count = 20;
     151
    152152    $Items = array();
    153     $sql = 'SELECT Title,Content, UNIX_TIMESTAMP(`Time`) AS `Time` FROM `NotifyLog`'.
     153    $sql = 'SELECT `Id`,`Title`,`Content`, UNIX_TIMESTAMP(`Time`) AS `Time` FROM `NotifyLog`'.
    154154      ' ORDER BY `Time` DESC LIMIT '.$Count;
    155155    $DbResult = $this->System->Database->query($sql);
     
    159159      (
    160160        'Title' => $Line['Title'],
    161         'Link' => 'https://'.$this->System->Config['Web']['Host'].$this->System->Link('/Notify.php'),
     161        'Link' => 'https://'.$this->System->Config['Web']['Host'].$this->System->Link('/notify/?i='.$Line['Id']),
    162162        'Description' => $Line['Content'],
    163163        'Time' => $Line['Time'],
     
    184184}
    185185
     186class PageNotify extends Page
     187{
     188  function __construct(System $System)
     189  {
     190    parent::__construct($System);
     191    $this->Title = 'Upozornění';
     192    $this->Description = 'Upozornění';
     193    $this->ParentClass = 'PagePortal';
     194  }
     195
     196  function Show(): string
     197  {
     198    if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Notify', 'Show'))
     199      return 'Nemáte oprávnění';
     200
     201    $Output = '<style>
     202    table { border-collapse: collapse; }
     203    table, th, td { border: 1px solid gray; }
     204    td { padding: 5px; }
     205    </style>';
     206    if (!array_key_exists('i', $_GET)) return 'Položka nenalezena';   
     207    $Id = $_GET['i'] * 1;
     208    $DbResult = $this->Database->select('NotifyLog', 'Title,Content, UNIX_TIMESTAMP(`Time`) AS `Time`', 'Id='.$Id);
     209    if ($DbResult->num_rows > 0)
     210    {
     211      $DbRow = $DbResult->fetch_assoc();
     212      $Output .= '<h3>'.$DbRow['Title'].'</h3>'.
     213        '<div>Čas: '.TimeToMysqlDateTime($DbRow['Time']).'</div>'.
     214        '<p>'.$DbRow['Content'].'</p>';
     215    } else $Output = 'Položka nenalezena';
     216    return $Output;
     217  }
     218}
     219
    186220class NotifyCategory extends Model
    187221{
Note: See TracChangeset for help on using the changeset viewer.