Changeset 562


Ignore:
Timestamp:
Aug 13, 2013, 11:45:33 PM (11 years ago)
Author:
chronos
Message:
  • Modified: News admin announcement message system transformed to application module.
Location:
trunk
Files:
2 added
5 edited

Legend:

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

    r561 r562  
    1111    $this->License = 'GNU/GPL';
    1212    $this->Description = 'Main welcome page';
    13     $this->Dependencies = array();
     13    $this->Dependencies = array('News', 'User', 'ShoutBox', 'Translation');
    1414  }
    1515 
     
    8181                        '</td></tr>'.
    8282                        '<tr><td>'.$this->ShowLastTranslated().'</td>'.
    83                         '<td class="news-box">'.$this->ShowNews().'</td>'.
     83                        '<td class="news-box">'.$this->System->ModuleManager->Modules['News']->ShowBox().'</td>'.
    8484                        '<td>'.$this->System->ModuleManager->Modules['ShoutBox']->ShowBox().'</td>'.
    8585                        '</tr></table>';
    8686         return($Output);
    87   }
    88 
    89   function ShowNews()
    90   {
    91         $Output = '<strong>Změny systému:</strong><div class="NewsBox">';
    92         $DbResult = $this->Database->query('SELECT `News`.`Time`, `User`.`Name`, `News`.`Text`,`News`.`Title`'.
    93                         ' FROM `News` JOIN `User` ON `User`.`ID` = `News`.`User` ORDER BY `Time` DESC LIMIT 10');
    94         while($DbRow = $DbResult->fetch_assoc())
    95                 $Output .= '<div><strong>'.$DbRow['Title'].' ('.HumanDate($DbRow['Time']).')</strong> <br />'.$DbRow['Text'].' ('.$DbRow['Name'].')</div>';
    96         $Output .= '<a href="action.php?action=news">Všechny zprávy</a>';
    97         $Output .= '</div>';
    98         return($Output);
    99   }
     87  } 
    10088 
    10189  function ShowLastTranslated()
  • trunk/action.php

    r561 r562  
    184184}
    185185
    186 function ShowNewsHistory()
    187 {
    188   global $System, $User;
    189  
    190   $DbResult = $System->Database->query('SELECT COUNT(*) FROM `News`');
    191   $DbRow = $DbResult->fetch_row();
    192   $PageList = GetPageList($DbRow[0]);   
    193 
    194   $Output = '<h3>Novinky</h3>'.$PageList['Output'];
    195   if($User->Licence(LICENCE_ADMIN)) $Output .= ' <a href="admin/?action=addnew">Vložit</a>';
    196   $Output .= '<div class="shoutbox">';
    197   $DbResult = $System->Database->query('SELECT `News`.`Time`, `News`.`Text`, `News`.`Title`, '.
    198         '`User`.`Name` AS `User` FROM `News` JOIN `User` ON `User`.`Id`=`News`.`User` ORDER BY `News`.`Time` DESC '.$PageList['SQLLimit']);
    199   while($Line = $DbResult->fetch_assoc())
    200     $Output .= '<div><strong>'.$Line['Title'].' ('.HumanDate($Line['Time']).')</strong><br/> '.$Line['Text'].' ('.$Line['User'].')</div>';
    201   $Output .= '</div>'.$PageList['Output'];
    202   return($Output);
    203 }
    204186
    205187if(array_key_exists('group', $_GET)) $GroupId = LoadGroupIdParameter();
     
    209191if(array_key_exists('action', $_GET)) $Action = $_GET['action'];
    210192
    211 if($Action == 'news') $Output = ShowNewsHistory();
    212193else if($Action == 'search') $Output = Search();
    213194else if($Action == 'dbkit') $Output = DatabaseKit();
  • trunk/admin/index.php

    r539 r562  
    2121  '<a href="'.$System->Link('/admin/?action=delerrlog').'">Vymázání chybových záznamů</a><br/>'.
    2222  '<small>Provede vymazání všech chybových záznamů v logu</small><br/><br/>'.   
    23   '<a href="'.$System->Link('/admin/?action=addnew').'">Přidání aktuality</a><br/>'.
     23  '<a href="'.$System->Link('/news/?a=add').'">Přidání aktuality</a><br/>'.
    2424  '<small>Přidá aktulitu na hlavní stranu projektu</small><br/><br/>'.   
    2525  '<a href="'.$System->Link('/admin/?action=testing').'">Testování</a><br/>'.
    2626  '<small>Testovací funkce</small><br/><br/>';   
    27   return($Output);
    28 }
    29 
    30 function ShowNewForm()
    31 {
    32   global $User;
    33  
    34   $Output = '<form action="?action=addnew" method="POST">'.
    35   'Uživatel: '.$User->Name.'('.$User->Id.')<br/> '. 
    36   'Nadpis: <input type="text" name="title" size="40"/><br/>'.
    37   'Obsah: <textarea rows="8" cols="40" onkeydown="ResizeTextArea(this)" class="textedit" id="Text" name="text"></textarea><br/>'.
    38   '<input type="submit" value="Uložit"/><br/>'.
    39   '</form>';
    40   return($Output);
    41 }
    42 
    43 function SaveNew()
    44 {
    45   global $System, $Config, $User;
    46  
    47   if(array_key_exists('text', $_POST) and array_key_exists('title', $_POST))
    48   {
    49     $querty = 'INSERT INTO `News` (`Title`, `Time` ,`User` ,`Text`) VALUES ( "'.$_POST['title'].'", NOW( ) , '.
    50       $User->Id.', "'.$_POST['text'].'")';
    51     $System->Database->query($querty);
    52     $Output = ShowMessage('Aktualita uložena.');
    53     WriteLog('Vložena nová aktualita', LOG_TYPE_ADMINISTRATION);
    54   } else $Output = ShowMessage('Nezadány údaje', MESSAGE_CRITICAL);
    5527  return($Output);
    5628}
     
    11789    else if($_GET['action'] == 'testing') $Output .= Testing();
    11890    else if($_GET['action'] == 'phpinfo') $Output .= ShowPHPInfo();
    119     else if($_GET['action'] == 'addnew')
    120     {
    121       $Output .= SaveNew();
    122       $Output .= ShowNewForm();
    123     } else
    124       $Output .= ShowMenu();
     91    else $Output .= ShowMenu();
    12592  } else $Output .= ShowMenu(); 
    12693} else $Output .= ShowMessage('Nemáte oprávnění.', MESSAGE_CRITICAL);
    12794     
    12895ShowPage($Output);
    129 
    130 ?>
  • trunk/includes/Version.php

    r561 r562  
    11<?php
    22
    3 $Revision = 561; // Subversion revision
     3$Revision = 562; // Subversion revision
    44$DatabaseRevision = 543; // Database structure revision
    55$ReleaseTime = '2013-08-13';
  • trunk/includes/global.php

    r561 r562  
    2525include_once(dirname(__FILE__).'/../Modules/ClientVersion/ClientVersion.php');
    2626include_once(dirname(__FILE__).'/../Modules/ShoutBox/ShoutBox.php');
     27include_once(dirname(__FILE__).'/../Modules/News/News.php');
    2728include_once(dirname(__FILE__).'/../Modules/FrontPage/FrontPage.php');
    2829
     
    8081  $System->ModuleManager->RegisterModule(new ModuleClientVersion($System));
    8182  $System->ModuleManager->RegisterModule(new ModuleShoutBox($System));
     83  $System->ModuleManager->RegisterModule(new ModuleNews($System));
    8284  $System->ModuleManager->RegisterModule(new ModuleFrontPage($System));
    8385  $System->ModuleManager->StartAll();
    8486}
    85 
    86 $System->RegisterRSS(array('Title' => 'Změny systému', 'Channel' => 'news'));
    8787
    8888function GetMicrotime()
Note: See TracChangeset for help on using the changeset viewer.