Changeset 893 for trunk


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.
Location:
trunk
Files:
4 added
1 deleted
37 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Core.php

    r888 r893  
    1212  public array $PageHeaders;
    1313  public string $BaseURL;
     14  public array $RSSChannels;
     15  public BaseView $BaseView;
     16  public array $LinkLocaleExceptions;
    1417
    1518  function __construct()
  • trunk/Application/UpdateTrace.php

    r892 r893  
    29752975function UpdateTo892($Manager)
    29762976{
    2977   $Manager->Execute('ALTER TABLE `User` CHANGE `Info` `Info` TEXT CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT '';');
     2977  $Manager->Execute('ALTER TABLE `User` CHANGE `Info` `Info` TEXT CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT "";');
    29782978}
    29792979
  • trunk/Application/Version.php

    r892 r893  
    77
    88$Version = '1.0';
    9 $Revision = 892; // Subversion revision
     9$Revision = 893; // Subversion revision
    1010$DatabaseRevision = 891; // Database structure revision
    11 $ReleaseDate = strtotime('2023-03-03');
     11$ReleaseDate = strtotime('2023-03-06');
  • trunk/Application/View.php

    r888 r893  
    33class BaseView extends View
    44{
    5   var $Title;
     5  public string $Title;
    66
    77  function ShowLocaleSelector()
     
    99    //$Output .= ' <form action="?setlocale" method="get">';
    1010    $Output = ' <select onchange="window.location=this.value">';
    11     foreach ($this->System->LocaleManager->Available as $Locale)
     11    foreach (Core::Cast($this->System)->LocaleManager->Available as $Locale)
    1212    {
    13       $Remaining = substr($_SERVER["REQUEST_URI"], strlen($this->System->BaseURL));
    14       if (substr($Remaining, 1, strlen($Locale['Code'].'/')) == $this->System->LocaleManager->LangCode.'/')
     13      $Remaining = substr($_SERVER["REQUEST_URI"], strlen(Core::Cast($this->System)->BaseURL));
     14      if (substr($Remaining, 1, strlen($Locale['Code'].'/')) == Core::Cast($this->System)->LocaleManager->LangCode.'/')
    1515        $Remaining = substr($Remaining, strlen('/'.$Locale['Code']));
    16       if ($Locale['Code'] == $this->System->LocaleManager->CurrentLocale->Texts->Code) $Selected = ' selected="selected"';
     16      if ($Locale['Code'] == Core::Cast($this->System)->LocaleManager->CurrentLocale->Texts->Code) $Selected = ' selected="selected"';
    1717        else $Selected = '';
    18       $Remaining = Core::Cast($this->System)->TranslateReverseURL($Remaining, $this->System->LocaleManager->LangCode);
     18      $Remaining = Core::Cast($this->System)->TranslateReverseURL($Remaining, Core::Cast($this->System)->LocaleManager->LangCode);
    1919
    2020      $URL = Core::Cast($this->System)->LinkLocale($Remaining, $Locale['Code']);
     
    2828  function ShowTopBar()
    2929  {
     30    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    3031    $Output = '<div class="Menu">';
    31     if (isset($this->System->User))
     32    if (isset($User))
    3233    {
    33       if (!$this->System->User->Licence(LICENCE_USER))
    34         $Output .= '<div class="advert">'.$this->System->Config['Web']['Advertisement'].'</div>';
     34      if (!$User->Licence(LICENCE_USER))
     35        $Output .= '<div class="advert">'.Core::Cast($this->System)->Config['Web']['Advertisement'].'</div>';
    3536    }
    3637    $Output .= '<span class="MenuItem"></span><span class="MenuItem2">';
     
    3839    // Show bars items
    3940    $Bar = '';
    40     foreach ($this->System->Bars['Top'] as $BarItem)
     41    foreach (Core::Cast($this->System)->Bars['Top'] as $BarItem)
    4142      $Bar .= call_user_func($BarItem);
    4243    if (trim($Bar) != '') $Output .= $Bar;
     
    5152  function ShowMainMenu()
    5253  {
     54    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    5355    $Output = '<strong>'.T('Menu').':</strong>'.
    5456      '<div class="verticalmenu"><ul>';
    55     foreach ($this->System->Menu as $MenuItem)
     57    foreach (Core::Cast($this->System)->Menu as $MenuItem)
    5658    {
    57       if (!isset($this->System->User) or $this->System->User->Licence($MenuItem['Permission']))
     59      if (!isset($User) or $User->Licence($MenuItem['Permission']))
    5860      {
    5961        if (isset($MenuItem['Click'])) $OnClick = ' onclick="'.$MenuItem['Click'].'"';
     
    7577    '<html>'.
    7678    '<head>'.
    77     '<meta http-equiv="content-type" content="text/html; charset='.$this->System->Config['Web']['Charset'].'" />'.
    78     '<meta name="keywords" content="'.$this->System->Config['Web']['Keywords'].'" />'.
    79     '<meta name="description" content="'.$this->System->Config['Web']['Description'].'" />'.
     79    '<meta http-equiv="content-type" content="text/html; charset='.Core::Cast($this->System)->Config['Web']['Charset'].'" />'.
     80    '<meta name="keywords" content="'.Core::Cast($this->System)->Config['Web']['Keywords'].'" />'.
     81    '<meta name="description" content="'.Core::Cast($this->System)->Config['Web']['Description'].'" />'.
    8082    '<meta name="robots" content="all" />'.
    8183    '<meta name="viewport" content="width=device-width, initial-scale=1">'.
     
    8688    // Show page headers
    8789    $Bar = '';
    88     foreach ($this->System->PageHeaders as $Item)
     90    foreach (Core::Cast($this->System)->PageHeaders as $Item)
     91    {
    8992      $Output .= call_user_func($Item);
     93    }
    9094
    91     $Title = $this->System->Config['Web']['Title'];
     95    $Title = Core::Cast($this->System)->Config['Web']['Title'];
    9296    if ($this->Title != '') $Title = $this->Title.' - '.$Title;
    9397    $Output .= '<title>'.$Title.'</title>'.
     
    101105    // Show bars items
    102106    $Bar = '';
    103     foreach ($this->System->Bars['Left'] as $BarItem)
     107    foreach (Core::Cast($this->System)->Bars['Left'] as $BarItem)
    104108      $Bar .= call_user_func($BarItem);
    105109    if (trim($Bar) != '') $Output .= $Bar;
     
    120124    // Show bars items
    121125    $Bar = '';
    122     foreach ($this->System->Bars['Right'] as $BarItem)
     126    foreach (Core::Cast($this->System)->Bars['Right'] as $BarItem)
    123127      $Bar .= call_user_func($BarItem);
    124128    if (trim($Bar) != '') $Output .= $Bar;
     
    129133      ' &nbsp; <a href="https://app.zdechov.net/wowpreklad/browser/trunk">'.T('Source code').'</a> &nbsp; '.
    130134      '<a href="https://app.zdechov.net/wowpreklad/log/trunk?verbose=on">'.T('Changelog').'</a> &nbsp; '.
    131       $this->System->Config['Web']['WebCounter'];
     135      Core::Cast($this->System)->Config['Web']['WebCounter'];
    132136
    133137    $Output .= '</td></tr>';
    134     if ($this->System->Config['Web']['ShowRuntimeInfo'] == true)
     138    if (Core::Cast($this->System)->Config['Web']['ShowRuntimeInfo'] == true)
    135139      $Output .= '<tr><td colspan="3" style="text-align: center;">'.T('Generating duration').': '.
    136140    $ScriptGenerateDuration.' s / '.ini_get('max_execution_time').' s &nbsp;&nbsp; '.T('Used memory').': '.
     
    146150  {
    147151    $Output = $this->ShowHeader().$Content.$this->ShowFooter();
    148     if ($this->System->Config['Web']['FormatOutput'])
     152    if (Core::Cast($this->System)->Config['Web']['FormatOutput'])
    149153      $Output = $this->FormatOutput($Output);
    150154    return $Output;
  • trunk/Modules/Admin/Admin.php

    r888 r893  
    3434
    3535    $Output .= '<br />'.
    36       '<a href="https://'.$this->System->Config['Web']['Host'].'/phpmyadmin/">'.T('Database management').'</a><br/>'.
     36      '<a href="https://'.Core::Cast($this->System)->Config['Web']['Host'].'/phpmyadmin/">'.T('Database management').'</a><br/>'.
    3737      '<small>Rozhraní phpMyAdmin pro přímou správu databáze</small><br/><br/>'.
    3838      '<a href="'.$this->System->Link('/import/').'">'.T('Text import').'</a><br/>'.
     
    114114  function RepairVersionEnd()
    115115  {
    116     $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
     116    $TranslationTree = ModuleTranslation::Cast($this->System->ModuleManager->GetModule('Translation'))->GetTranslationTree();
    117117
    118118    $Output = '';
     
    149149  function MergeSameText()
    150150  {
    151     $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
     151    $TranslationTree = ModuleTranslation::Cast($this->System->ModuleManager->GetModule('Translation'))->GetTranslationTree();
    152152
    153153    $Output = '';
     
    205205  function DbcStructure()
    206206  {
    207     $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
     207    $TranslationTree = ModuleTranslation::Cast($this->System->ModuleManager->GetModule('Translation'))->GetTranslationTree();
    208208
    209209    $Output = '';
     
    213213    }
    214214    if (!array_key_exists('GameVersion', $_SESSION))
    215       $_SESSION['GameVersion'] = $this->System->Config['Web']['GameVersion'];
     215      $_SESSION['GameVersion'] = Core::Cast($this->System)->Config['Web']['GameVersion'];
    216216
    217217      $Output .= '<br />Nastavená verze: '.$_SESSION['GameVersion'].'<br />';
     
    295295  function ShowLocale()
    296296  {
    297     $this->System->LocaleManager->UpdateAll(dirname(dirname(__FILE__)));
     297    Core::Cast($this->System)->LocaleManager->UpdateAll(dirname(dirname(__FILE__)));
    298298    $Output = 'Překlad rozhraní přegenerován';
    299299    $Output .= '<table class="BaseTable"><tr><th>Originál</th><th>Překlad</th></tr>';
    300     foreach ($this->System->LocaleManager->CurrentLocale->Texts->Data as $Index => $Item)
     300    foreach (Core::Cast($this->System)->LocaleManager->CurrentLocale->Texts->Data as $Index => $Item)
    301301      $Output .= '<tr><td>'.$Index.'</td><td>'.$Item.'</td></tr>';
    302302    $Output .= '</table>';
     
    307307  function Show(): string
    308308  {
     309    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    309310    $this->Title = T('Administration');
    310311    $Output = '';
    311     if ($this->System->User->Licence(LICENCE_ADMIN))
     312    if ($User->Licence(LICENCE_ADMIN))
    312313    {
    313314      if (array_key_exists('action', $_GET))
  • trunk/Modules/Dictionary/Dictionary.php

    r888 r893  
    2828      $this->System->ModuleManager->Modules['Search']->RegisterSearch('dictionary',
    2929      T('Dictionary'), array('Text', 'Description'),
    30      '(SELECT * FROM `Dictionary` WHERE `Language` = '.$this->System->Config['OriginalLanguage'].') AS `T`',
     30     '(SELECT * FROM `Dictionary` WHERE `Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') AS `T`',
    3131        $this->System->Link('/dictionary/?search='));
    3232  }
     
    8888  function DictionaryInsert()
    8989  {
     90    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    9091    $Output = '';
    91     if ($this->System->User->Licence(LICENCE_USER))
     92    if ($User->Licence(LICENCE_USER))
    9293    {
    9394      $Output .= '<form action="?action=save" method="post">'.
     
    108109  function DictionarySave()
    109110  {
    110     if ($this->System->User->Licence(LICENCE_USER))
     111    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     112    if ($User->Licence(LICENCE_USER))
    111113    {
    112114      if (array_key_exists('Original', $_POST) and array_key_exists('Translated', $_POST) and array_key_exists('Description', $_POST))
     
    114116        // Check if original text exists and determine entry id
    115117        $DbResult = $this->Database->query('SELECT * FROM `Dictionary` WHERE '.
    116           '`Text` = "'.$_POST['Original'].'" AND `Language`= '.$this->System->Config['OriginalLanguage']);
     118          '`Text` = "'.$_POST['Original'].'" AND `Language`= '.Core::Cast($this->System)->Config['OriginalLanguage']);
    117119        if ($DbResult->num_rows > 0)
    118120        {
     
    125127          $Entry = $DbRow[0] + 1;
    126128          $this->Database->query('INSERT INTO `Dictionary` ( `Text` , `Entry` , `Description` , '.
    127             '`User`, `Language` ) VALUES ("'.$_POST['Original'].'", "'.$Entry.'", "", NULL, '.$this->System->Config['OriginalLanguage'].');');
     129            '`User`, `Language` ) VALUES ("'.$_POST['Original'].'", "'.$Entry.'", "", NULL, '.Core::Cast($this->System)->Config['OriginalLanguage'].');');
    128130        }
    129131
    130132        $DbResult = $this->Database->query('SELECT `Id` FROM `Dictionary` WHERE '.
    131           '`Entry` = '.$Entry.' AND `Language`='.$_POST['Language'].' AND `User`='.$this->System->User->Id);
     133          '`Entry` = '.$Entry.' AND `Language`='.$_POST['Language'].' AND `User`='.$User->Id);
    132134        if ($DbResult->num_rows > 0)
    133135        {
     
    138140          $this->Database->query('INSERT INTO `Dictionary` ( `Text` , `Entry` , `Description` , '.
    139141            '`User`, `Language` ) VALUES ("'.$_POST['Translated'].'", "'.$Entry.'", "'.
    140             $_POST['Description'].'", '.$this->System->User->Id.', '.$_POST['Language'].')');
     142            $_POST['Description'].'", '.$User->Id.', '.$_POST['Language'].')');
    141143        $Output = ShowMessage('Záznam byl uložen!');
    142144      } else $Output = ShowMessage(T('You have to fill all column of form.'), MESSAGE_CRITICAL);
     
    147149  function DictionaryRemove()
    148150  {
    149     if ($this->System->User->Licence(LICENCE_USER))
    150     {
    151       $this->Database->query('DELETE FROM `Dictionary` WHERE (`User`='.$this->System->User->Id.') AND (`Id`='.($_GET['id'] * 1).')');
     151    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     152    if ($User->Licence(LICENCE_USER))
     153    {
     154      $this->Database->query('DELETE FROM `Dictionary` WHERE (`User`='.$User->Id.') AND (`Id`='.($_GET['id'] * 1).')');
    152155      $Output = ShowMessage(T('Record removed'));
    153156    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
     
    157160  function DictionaryModify()
    158161  {
    159     if ($this->System->User->Licence(LICENCE_USER))
     162    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     163    if ($User->Licence(LICENCE_USER))
    160164    {
    161165      $DbResult = $this->Database->query('SELECT * FROM `Dictionary` WHERE `Id`='.($_GET['id'] * 1));
     
    164168        $DbRow = $DbResult->fetch_assoc();
    165169        $DbResult = $this->Database->query('SELECT * FROM `Dictionary` WHERE (`User` IS NULL) '.
    166           'AND (`Entry`='.$DbRow['Entry'].') AND (`Language`= '.$this->System->Config['OriginalLanguage'].')');
     170          'AND (`Entry`='.$DbRow['Entry'].') AND (`Language`= '.Core::Cast($this->System)->Config['OriginalLanguage'].')');
    167171        $DbRow2 = $DbResult->fetch_assoc();
    168172        $Output = '<form action="?action=save" method="post">'.
     
    216220  function DictionaryShow()
    217221  {
     222    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    218223    global $LanguageList;
    219224
     
    227232      <input type="text" value="'.$Search.'" name="search" size="30" />
    228233      <input type="submit" value="'.T('Search').'" />';
    229     if ($this->System->User->Licence(LICENCE_USER))
     234    if ($User->Licence(LICENCE_USER))
    230235      $Output .= ' <a href="?action=insert">'.T('Add word').'</a>';
    231236
     
    258263      '`T1`.`Entry`, `T2`.`Text` AS `Original`, `T1`.`Text` AS `Translated`, `T1`.`Description` '.
    259264      'FROM `Dictionary` AS `T1` JOIN `Dictionary` AS `T2` '.
    260       'ON (`T2`.`Entry` = `T1`.`Entry`) AND (`T2`.`Language` = '.$this->System->Config['OriginalLanguage'].') '.
     265      'ON (`T2`.`Entry` = `T1`.`Entry`) AND (`T2`.`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') '.
    261266      'JOIN `Language` ON `Language`.`Id` = `T1`.`Language` '.
    262267      'JOIN `User` ON `User`.`ID` = `T1`.`User` '.
     
    279284    $TableColumns[] = array('Name' => 'Description', 'Title' => T('Description'));
    280285    $TableColumns[] = array('Name' => 'UserName', 'Title' => T('Translator'));
    281     if ($this->System->User->Licence(LICENCE_USER)) $TableColumns[] = array('Name' => '', 'Title' => T('Action'));
     286    if ($User->Licence(LICENCE_USER)) $TableColumns[] = array('Name' => '', 'Title' => T('Action'));
    282287    $Order = GetOrderTableHeader($TableColumns, 'Original');
    283288    $Output .= '<table class="BaseTable">'.$Order['Output'];
     
    294299        '<td><a href="'.$this->System->Link('/user/?user='.$Line['UserId']).'">'.
    295300        $Line['UserName'].'</a></td>';
    296       if ($this->System->User->Licence(LICENCE_USER))
    297       {
    298         if ($Line['UserId'] == $this->System->User->Id)
     301      if ($User->Licence(LICENCE_USER))
     302      {
     303        if ($Line['UserId'] == $User->Id)
    299304          $Output .= '<td><a href="?action=remove&amp;id='.$Line['Id'].
    300305            '" onclick="return confirmAction(\''.T('Do you really want to delete item?').'\');">'.T('Delete').'</a>'.
     
    315320    global $LanguageList;
    316321
     322    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    317323    $this->Title = T('Dictionary');
    318324
     
    321327    if (!isset($_SESSION['language']))
    322328    {
    323       if ($this->System->User->Licence(LICENCE_USER))
    324       {
    325         $_SESSION['language'] = $this->System->User->Language;
     329      if ($User->Licence(LICENCE_USER))
     330      {
     331        $_SESSION['language'] = $User->Language;
    326332      } else $_SESSION['language'] = '';
    327333    }
  • trunk/Modules/Download/Download.php

    r888 r893  
    112112
    113113        if ($DbExport['OutputType'] == 10)
    114           $filename = $this->System->Config['Web']['TempFolder'].'Export/'.$ExportId.'/'.'Instalace_CzechWoW_'.$DbExport['Version'].'.exe';
     114          $filename = Core::Cast($this->System)->Config['Web']['TempFolder'].'Export/'.$ExportId.'/'.'Instalace_CzechWoW_'.$DbExport['Version'].'.exe';
    115115        if ($DbExport['OutputType'] == 7)
    116           $filename = $this->System->Config['Web']['TempFolder'].'Export/'.$ExportId.'/'.'CzWoW_Addon-'.$DbExport['Version'].'.zip';
     116          $filename = Core::Cast($this->System)->Config['Web']['TempFolder'].'Export/'.$ExportId.'/'.'CzWoW_Addon-'.$DbExport['Version'].'.zip';
    117117
    118118        if ($DbExport['OutputType'] == 10)
  • trunk/Modules/Error/Error.php

    r888 r893  
    2323  function DoStart(): void
    2424  {
    25     if (isset($this->System->Config['Web']['ShowPHPError']))
    26       $this->ErrorHandler->ShowError = $this->System->Config['Web']['ShowPHPError'];
     25    if (isset(Core::Cast($this->System)->Config['Web']['ShowPHPError']))
     26      $this->ErrorHandler->ShowError = Core::Cast($this->System)->Config['Web']['ShowPHPError'];
    2727      else $this->ErrorHandler->ShowError = true;
    2828    $this->ErrorHandler->Start();
  • trunk/Modules/Export/CreateAddon.php

    r888 r893  
    55class ExportAddon extends Export
    66{
    7 
    87  // Replace special codes by lua functions
    98  function ReplaceVarInText($string, $strlower = 'strlower')
    109  {
    11 
    1210    $string = str_replace('$N', '"..'.$strlower.'(UnitName("player")).."', $string);
    1311    $string = str_replace('$n', '"..'.$strlower.'(UnitName("player")).."', $string);
     
    149147        $ID = $this->Database->query('SELECT `BuildNumber` FROM `ClientVersion` WHERE '.
    150148        ' `Imported` = 1 AND `BuildNumber` < '.$BuildNumber.' ORDER BY  `BuildNumber` DESC LIMIT 1');
    151         if ($ID->num_rows > 0) {
     149        if ($ID->num_rows > 0)
     150        {
    152151          $ExportVersionOld = $ID->fetch_assoc();
    153152          $ExportVersionOld = $ExportVersionOld['BuildNumber'];
     
    164163          }
    165164        }
    166                 //last version
     165        //last version
    167166
    168167        $DbResult2 = $this->Database->query($this->BuildQuery($Group,$ExportVersion));
     
    177176        }
    178177
    179         foreach ($TableTexts as $key => $value) {
    180             $Buffer .= "\n".'["'.$key.'"]="'.$value.'",';
    181             $i++;
     178        foreach ($TableTexts as $key => $value)
     179        {
     180          $Buffer .= "\n".'["'.$key.'"]="'.$value.'",';
     181          $i++;
    182182        }
    183 
    184183
    185184        $Buffer = $Buffer."\n};if not CZWOW_".$Column['AddonFileName']." then CZWOW_".$Column['AddonFileName']."=0; end; CZWOW_".$Column['AddonFileName']."=CZWOW_".$Column['AddonFileName']."+".$i.";\n";
     
    189188      }
    190189    }
    191 
    192190
    193191    // Generete list file of translated
     
    195193    $Buffer = '';
    196194    foreach ($CreatedFileList as $CreatedFile)
     195    {
    197196      $Buffer .= 'CZWOW_'.str_replace('_','_count=',$CreatedFile).';'."\n";
     197    }
    198198    foreach ($TranslationTree as $Group)
     199    {
    199200      foreach ($TranslationTree[$Group['Id']]['Items'] as $Column)
    200       if (($Column['AddonFileName'] != '') and (!in_array($Column['AddonFileName'].'_1', $CreatedFileList)))
    201201      {
    202         $Buffer .= 'CZWOW_'.$Column['AddonFileName'].'_count=0;'."\n";
     202        if (($Column['AddonFileName'] != '') and (!in_array($Column['AddonFileName'].'_1', $CreatedFileList)))
     203        {
     204          $Buffer .= 'CZWOW_'.$Column['AddonFileName'].'_count=0;'."\n";
     205        }
     206      }
    203207    }
    204208
    205209    file_put_contents($this->TempDir.'CzWoW/'.$CountFiles, $Buffer);
    206 
    207210
    208211    // Generate file Translates.xml
     
    210213    $Buffer .= '<script file="'.$CountFiles.'"/>'."\n";
    211214    foreach ($CreatedFileList as $CreatedFile)
     215    {
    212216      $Buffer .= '<script file="'.$CreatedFile.'.lua"/>'."\n";
     217    }
    213218    $Buffer .= '</Ui>';
    214219    file_put_contents($this->TempDir.'CzWoW/Translates.xml', $Buffer);
    215220    return $Output;
    216221  }
    217 
    218222
    219223  function MakeClientStrings()
     
    282286
    283287    ';
    284     $DbResult = $System->Database->query('SELECT * FROM `CzWoWPackageVersion` ORDER BY `Date` DESC');
     288    $DbResult = $this->Database->query('SELECT * FROM `CzWoWPackageVersion` ORDER BY `Date` DESC');
    285289    while ($Line = $DbResult->fetch_assoc())
    286290    {
  • trunk/Modules/Export/Export.php

    r891 r893  
    11<?php
    22
    3 class ModuleExport extends Module
    4 {
    5   function __construct(System $System)
    6   {
    7     parent::__construct($System);
    8     $this->Name = 'Export';
    9     $this->Version = '1.0';
    10     $this->Creator = 'Chronos';
    11     $this->License = 'GNU/GPL';
    12     $this->Description = 'Allow parametric export of translated texts to various supported output formats';
    13     $this->Dependencies = array('Translation');
    14   }
    15 
    16   function DoStart(): void
    17   {
    18     $this->System->RegisterPage(['export'], 'PageExport');
    19     $this->System->RegisterPage(['export', 'progress'], 'PageExportProgress');
    20     Core::Cast($this->System)->RegisterMenuItem(array(
    21       'Title' => 'Exporty',
    22       'Hint' => 'Zde si můžete stáhnout přeložené texty',
    23       'Link' => $this->System->Link('/export/'),
    24       'Permission' => LICENCE_ANONYMOUS,
    25       'Icon' => '',
    26     ), 2);
    27   }
    28 
    29   function GetTaskProgress($TaskId)
    30   {
    31     $Output = '';
    32     $DbResult = $this->Database->query('SELECT * FROM `ExportTask` '.
    33       'LEFT JOIN `Export` ON `Export`.`Id` = `ExportTask`.`Export` WHERE '.
    34       '((`Export`.`OutputType` = 9) OR (`Export`.`OutputType` = 10)) AND '.
    35       '(`TimeFinish` IS NULL) OR (`Export` ='.$TaskId.') ORDER BY `TimeQueued`'); // `Export`='.$Export->Id
    36     while ($Task = $DbResult->fetch_assoc())
    37     {
    38       $Export = '<a href="'.$this->System->Link('/export/?Action=View&amp;ExportId='.$Task['Export']).'">'.$Task['Export'].'</a>';
    39       if ($TaskId == $Task['Export'])
    40         $Export = ''.$Export.' (tento)';
    41 
    42       // Show progress bar
    43       $Output .= ' <strong>Export '.$Export.':</strong> <div id="progress'.$Task['Export'].'">'.
    44         '<strong>'.ProgressBar(300, $Task['Progress']).'</strong> ';
    45 
    46       // Show estimated time to complete
    47       $PrefixMultiplier = new PrefixMultiplier();
    48       if ($Task['Progress'] > 0) {
    49         $ElapsedTime = time() - MysqlDateTimeToTime($Task['TimeStart']);
    50         $Output .= T('Elapsed time').': <strong>'.$PrefixMultiplier->Add($ElapsedTime, '', 4, 'Time').'</strong> / ';
    51         $EstimatedTime = (time() - MysqlDateTimeToTime($Task['TimeStart'])) / $Task['Progress'] * (100 - $Task['Progress']);
    52         $Output .= T('Estimated remaining time').': <strong>'.$PrefixMultiplier->Add($EstimatedTime, '', 4, 'Time').'</strong><br/>';
    53       }
    54       $Output .= '</div>';
    55 
    56       if ($Task['Progress'] > 99)
    57         $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'.
    58         'setTimeout("parent.location.href=\''.$this->System->Link('/export/?Action=View&Tab=7&ExportId='.$TaskId).'\'", 500)'.
    59         '</script>';
    60     }
    61     return $Output;
    62   }
    63 }
     3include_once(dirname(__FILE__).'/ModuleExport.php');
     4include_once(dirname(__FILE__).'/Page.php');
     5include_once(dirname(__FILE__).'/ExportOutput.php');
    646
    657class Export extends Model
    668{
    67   var $Id;
    68   var $AnoNe = array('Ne', 'Ano');
     9  public int $Id;
     10  public array $AnoNe = array('Ne', 'Ano');
    6911  var $WhereLang;
    7012  var $WhereUsers;
     
    7315  var $ClientVersion;
    7416  var $OrderByUserList;
    75   var $TempDir;
    76   var $SourceDir;
     17  public string $TempDir;
     18  public string $TempDirRelative;
     19  public string $SourceDir;
     20  public string $SourceDirRelative;
     21  public array $Export;
    7722
    7823  function Init()
    7924  {
    80     $this->TempDir = dirname(__FILE__).'/../../'.$this->System->Config['Web']['TempFolder'].'Export/'.$this->Id.'/';
     25    $this->TempDir = dirname(__FILE__).'/../../'.Core::Cast($this->System)->Config['Web']['TempFolder'].'Export/'.$this->Id.'/';
    8126    if (!file_exists($this->TempDir)) mkdir($this->TempDir, 0777, true);
    82     $this->TempDirRelative = $this->System->Config['Web']['TempFolder'].'Export/'.$this->Id.'/';
    83     $this->SourceDir = dirname(__FILE__).'/../../'.$this->System->Config['Web']['SourceFolder'];
    84     $this->SourceDirRelative = $this->System->Config['Web']['SourceFolder'];
     27    $this->TempDirRelative = Core::Cast($this->System)->Config['Web']['TempFolder'].'Export/'.$this->Id.'/';
     28    $this->SourceDir = dirname(__FILE__).'/../../'.Core::Cast($this->System)->Config['Web']['SourceFolder'];
     29    $this->SourceDirRelative = Core::Cast($this->System)->Config['Web']['SourceFolder'];
    8530    if (!file_exists($this->SourceDir)) mkdir($this->SourceDir, 0777, true);
    8631  }
     
    158103  //  $Columns = substr($Columns, 0, -2);
    159104
    160     $Query = 'SELECT * FROM (SELECT ANY_VALUE(`TT`.`ID`) AS `TTID` FROM (SELECT '.$Columns.' T.`ID`,T.`Language`,T.`User`,T.`Entry`,T.`VersionEnd`,T.`VersionStart`, `User`.`Name` AS `UserName` FROM `'.$Group['TablePrefix'].'` AS `T`'.
     105    $Query = 'SELECT * FROM (SELECT MIN(`TT`.`ID`) AS `TTID` FROM
     106    (SELECT '.$Columns.' T.`ID`,T.`Language`,T.`User`,T.`Entry`,T.`VersionEnd`,T.`VersionStart`, `User`.`Name` AS `UserName` FROM `'.$Group['TablePrefix'].'` AS `T`'.
    161107    ' JOIN `ExportUser` ON (`ExportUser`.`User`=`T`.`User`) AND (`ExportUser`.`Export`='.$this->Id.') '.
    162108    ' JOIN `User` ON `User`.`ID`=`T`.`User`'.
     
    179125    $Query = 'SELECT `T4`.*, '.$OriginalColumns.' FROM ('.$Query.') AS `T4` '.
    180126    ' LEFT JOIN `'.$Group['TablePrefix'].'` AS `T3` ON (`T3`.`Entry` = `T4`.`Entry`) '.
    181     'AND (`T3`.`Language` = '.$this->System->Config['OriginalLanguage'].') AND '.
     127    'AND (`T3`.`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') AND '.
    182128    '(`T3`.`VersionStart` = `T4`.`VersionStart`) AND (`T3`.`VersionEnd` = `T4`.`VersionEnd`)';
    183129
     
    219165  function ExportToMangosSQL()
    220166  {
     167    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    221168    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    222169
     
    227174      "-- ===========================================\n".
    228175      "--\n".
    229       "-- Web projektu: ".$this->System->Config['Web']['Host'].$this->System->Link('/')."\n".
     176      "-- Web projektu: ".Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/')."\n".
    230177      "-- Datum exportu: ".date("j.n.Y  H:i:s")."\n".
    231       "-- Znaková sada: ".$this->System->Config['Database']['Charset']." / ".$this->System->Config['Web']['Charset']."\n".
     178      "-- Znaková sada: ".Core::Cast($this->System)->Config['Database']['Charset']." / ".Core::Cast($this->System)->Config['Web']['Charset']."\n".
    232179      "-- Diakritika: ".$this->AnoNe[$this->Export['WithDiacritic']]."\n".
    233       "-- Vygeneroval uživatel: ".$this->System->User->Name."\n".
     180      "-- Vygeneroval uživatel: ".$User->Name."\n".
    234181      "-- Vzato od uživatelů: ".$this->UserNames."\n".
    235182      "-- Generované tabulky: ";
     
    370317  }
    371318
    372   function AddProgress($add = 1)
    373   {
    374     $DbResult = $this->System->Database->query('SELECT Progress FROM `ExportTask` WHERE `Export`='.$this->Id);
    375     $Task = $DbResult->fetch_assoc();
    376     $per = $Task['Progress']+$add;
    377     $this->System->Database->query('UPDATE `ExportTask` SET `Progress`='.$per.' WHERE `Export`='.$this->Id);
     319  function AddProgress($Add = 1)
     320  {
     321    $DbResult = $this->System->Database->query('SELECT `Progress` FROM `ExportTask` WHERE `Export`='.$this->Id);   
     322    if ($DbResult->num_rows > 0)
     323    {
     324      $Task = $DbResult->fetch_assoc();
     325      $Progress = $Task['Progress'] + $Add;
     326      $this->System->Database->query('UPDATE `ExportTask` SET `Progress`='.$Progress.' WHERE `Export`='.$this->Id);
     327    }
    378328  }
    379329
     
    723673  function ExportToXML()
    724674  {
     675    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    725676    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    726677
     
    730681    "<document>\n".
    731682    "  <meta>\n".
    732     "    <projecturl>".$this->System->Config['Web']['Host'].$this->System->Link('/')."</projecturl>\n".
     683    "    <projecturl>".Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/')."</projecturl>\n".
    733684    "    <time>".date('r')."</time>\n".
    734685    "    <diacritics mode=".'"'.$this->Export['WithDiacritic'].'"'." />\n".
    735     "    <author>".$this->System->User->Name."</author>\n".
     686    "    <author>".$User->Name."</author>\n".
    736687    "    <contributors>\n";
    737688    foreach (explode(',', $this->UserNames) as $UserName)
    738       $Buffer .= "      <user>".$UserName."</user>\n";
     689    {
     690      $Buffer .= "      <user>".trim($UserName)."</user>\n";
     691    }
    739692    $Buffer .=
    740693    "    </contributors>\n".
     
    755708      while ($Line = $DbResult2->fetch_assoc())
    756709      {
    757         $Buffer .= '      <item id="'.$Line['Entry'].'" user="'.$Line['UserName'].'">'."\n";
    758         $Values = '';
     710        $Buffer .= '      <item id="'.$Line['Entry'].'" user="'.$Line['User'].'">'."\n";
    759711        foreach ($TranslationTree[$Group['Id']]['Items'] as $GroupItem)
    760712        {
     
    774726  }
    775727}
    776 
    777 include_once(dirname(__FILE__).'/Page.php');
    778 include_once(dirname(__FILE__).'/ExportOutput.php');
    779 
  • trunk/Modules/Export/ExportOutput.php

    r880 r893  
    2222function OutputAoWoWToFile($ExportId)
    2323{
    24   global $System, $Config;
     24  global $System;
    2525
    2626  $Output = '';
     
    5050function OutputAoWoWToHTML($ExportId)
    5151{
    52   global $System, $Config;
     52  global $System;
    5353
    5454  $Export = new Export($System);
     
    6363function OutputMangosSQLToFile($ExportId)
    6464{
    65   global $System, $Config;
     65  global $System;
    6666
    6767  $Output = '';
     
    140140function OutputXMLToFile($ExportId)
    141141{
    142   global $Config, $System;
     142  global $System;
    143143
    144144  $Output = '';
     
    318318function OutputLua($ExportId)
    319319{
    320   global $System, $Config;
     320  global $System;
    321321
    322322  $Export = new Export($System);
  • trunk/Modules/Export/Page.php

    r888 r893  
    1616  function ExportList()
    1717  {
     18    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    1819    $Output = '<a href="?Action=ViewList">'.T('All').'</a>';
    19     if ($this->System->User->Licence(LICENCE_USER))
     20    if ($User->Licence(LICENCE_USER))
    2021    {
    2122      $Output .= ' <a href="?Action=ViewList&amp;Filter=Others">'.T('Others').'</a>'.
     
    2324    }
    2425
    25     if ($this->System->User->Licence(LICENCE_USER))
     26    if ($User->Licence(LICENCE_USER))
    2627      $Output .= '<br/><div style="text-align: center;"><a href="?Action=Create">'.T('Create new export').'</a></div><br/>';
    2728
     
    2930    if (array_key_exists('Filter', $_GET))
    3031    {
    31       if ($_GET['Filter'] == 'My') $Filter = ' WHERE `Export`.`User` = '.$this->System->User->Id;
    32       if ($_GET['Filter'] == 'Others') $Filter = ' WHERE `Export`.`User` != '.$this->System->User->Id;
     32      if ($_GET['Filter'] == 'My') $Filter = ' WHERE `Export`.`User` = '.$User->Id;
     33      if ($_GET['Filter'] == 'Others') $Filter = ' WHERE `Export`.`User` != '.$User->Id;
    3334    }
    3435
     
    6667      $Action = '<a href="?Action=View&amp;ExportId='.$Export['Id'].'&amp;Tab=0">'.T('View').'</a> '.
    6768        '<a href="?Action=View&amp;ExportId='.$Export['Id'].'&amp;Tab=7">'.T('Make export').'</a>';
    68       if ($Export['User'] == $this->System->User->Id) $Action .= ' <a href="?Action=Delete&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy delete item?').'\');">'.T('Delete').'</a>';
    69       if ($this->System->User->Id != null) $Action .= ' <a href="?Action=Clone&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy clone item?').'\');">'.T('Clone').'</a>';
     69      if ($Export['User'] == $User->Id) $Action .= ' <a href="?Action=Delete&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy delete item?').'\');">'.T('Delete').'</a>';
     70      if ($User->Id != null) $Action .= ' <a href="?Action=Clone&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy clone item?').'\');">'.T('Clone').'</a>';
    7071      $Output .= '<tr><td>'.HumanDate($Export['TimeCreate']).'</td>'.
    7172          '<td><a href="'.$this->System->Link('/user/?user='.$Export['User']).'">'.$Export['UserName'].'</a></td>'.
     
    8485  function ExportCreate()
    8586  {
    86     if ($this->System->User->Licence(LICENCE_USER))
    87     {
    88       $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$this->System->User->Id);
     87    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     88    if ($User->Licence(LICENCE_USER))
     89    {
     90      $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$User->Id);
    8991      $DbRow = $DbResult->fetch_row();
    90       if ($DbRow[0] < $this->System->Config['MaxExportPerUser'])
     92      if ($DbRow[0] < Core::Cast($this->System)->Config['MaxExportPerUser'])
    9193      {
    9294        $Output = '<form action="?Action=CreateFinish" method="post">'.
     
    9698            '<tr><td colspan="2"><input type="submit" value="'.T('Create').'" /></td></tr>'.
    9799            '</table></fieldset></form>';
    98       } else $Output = ShowMessage(sprintf(T('You can\'t create another export. Max for one user is %d.'), $this->System->Config['MaxExportPerUser']), MESSAGE_CRITICAL);
     100      } else $Output = ShowMessage(sprintf(T('You can\'t create another export. Max for one user is %d.'), Core::Cast($this->System)->Config['MaxExportPerUser']), MESSAGE_CRITICAL);
    99101    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    100102    return $Output;
     
    103105  function ExportCreateFinish()
    104106  {
    105     if ($this->System->User->Licence(LICENCE_USER))
     107    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     108    if ($User->Licence(LICENCE_USER))
    106109    {
    107110      if (array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST))
    108111      {
    109         $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$this->System->User->Id);
     112        $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$User->Id);
    110113        $DbRow = $DbResult->fetch_row();
    111         if ($DbRow[0] < $this->System->Config['MaxExportPerUser'])
     114        if ($DbRow[0] < Core::Cast($this->System)->Config['MaxExportPerUser'])
    112115        {
    113           $this->System->Database->query('INSERT INTO `Export` (`Title`, `User`, `TimeCreate`, `WithDiacritic`, `Description`) VALUES ("'.$_POST['Title'].'", '.$this->System->User->Id.', NOW(), 1, "'.$_POST['Description'].'")');
     116          $this->System->Database->query('INSERT INTO `Export` (`Title`, `User`, `TimeCreate`, `WithDiacritic`, `Description`) VALUES ("'.$_POST['Title'].'", '.$User->Id.', NOW(), 1, "'.$_POST['Description'].'")');
    114117          $ExportId = $this->System->Database->insert_id;
    115118          $Output = ShowMessage(T('New export created.<br />Direct link to export').': <a href="?Action=View&amp;ExportId='.$ExportId.'">'.T('here').'</a>');
     
    117120          $_GET['Filter'] = 'my';
    118121          $this->ExportList();
    119         } else $Output = ShowMessage(sprintf(T('You can\'t create another export. Max for one user is %d.'),$this->System->Config['MaxExportPerUser']), MESSAGE_CRITICAL);
     122        } else $Output = ShowMessage(sprintf(T('You can\'t create another export. Max for one user is %d.'), Core::Cast($this->System)->Config['MaxExportPerUser']), MESSAGE_CRITICAL);
    120123      } else $Output = ShowMessage(T('Missing data in form.'), MESSAGE_CRITICAL);
    121124    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
     
    125128  function ExportDelete()
    126129  {
    127     if ($this->System->User->Licence(LICENCE_USER))
    128     {
    129       $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE (`Id`='.($_GET['ExportId'] * 1).') AND (`User`='.$this->System->User->Id.')');
     130    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     131    if ($User->Licence(LICENCE_USER))
     132    {
     133      $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE (`Id`='.($_GET['ExportId'] * 1).') AND (`User`='.$User->Id.')');
    130134      if ($DbResult->num_rows > 0)
    131135      {
     
    157161  function ExportViewTranslators()
    158162  {
     163    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    159164    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    160165
     
    163168    $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    164169    $Export = $DbResult->fetch_assoc();
    165     if ($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
     170    if ($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    166171    else $Editable = false;
    167172
     
    273278  function ExportViewGeneral()
    274279  {
     280    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    275281    $DisabledInput = array(false => ' disabled="disabled"', true => '');
    276282    $DisabledTextArea = array(false => ' readonly="yes"', true => '');
     
    278284    $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    279285    $Export = $DbRows->fetch_assoc();
    280     if ($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
     286    if ($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    281287    else $Editable = false;
    282288
     
    300306      $Output .= '<form action="?Action=View&amp;Tab=0&amp;ExportId='.$Export['Id'].'" method="post">'.
    301307          '<table>';
    302       if ($this->System->User->Id != null)
     308      if ($User->Id != null)
    303309      {
    304310        $Output .= '<input type="hidden" name="Operation" value="Save"/>'.
     
    306312        if ($Editable) $Output .= ' <input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>';
    307313        $Output .= ' <a href="?Action=Clone&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy clone item?').'\');">'.T('Clone').'</a> ';
    308         if ($this->System->User->Licence(LICENCE_ADMIN))
     314        if ($User->Licence(LICENCE_ADMIN))
    309315          $Output .= CheckBox('Featured', $Export['Featured'], '', 'CheckBox', !$Editable). ' '.T('Recommended').' ';
    310316        $Output .= '</td></tr>';
     
    319325  function ExportViewLanguages()
    320326  {
     327    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    321328    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    322329
     
    325332    $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    326333    $Export = $DbRows->fetch_assoc();
    327     if ($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
     334    if ($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    328335    else $Editable = false;
    329336
     
    410417  function ExportViewGroups()
    411418  {
     419    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    412420    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    413421
     
    416424    $DbRows = $this->System->Database->query('SELECT * FROM Export WHERE Id='.$_GET['ExportId']);
    417425    $Export = $DbRows->fetch_assoc();
    418     if ($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
     426    if ($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    419427    else $Editable = false;
    420428
     
    538546  function ExportViewOutputFormat()
    539547  {
     548    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    540549    $Output = '';
    541550    $DisabledInput = array(false => ' disabled="disabled"', true => '');
     
    546555      {
    547556        $Export = $DbRows->fetch_assoc();
    548         if ($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
     557        if ($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    549558        else $Editable = false;
    550559
     
    583592  function ExportViewVersion()
    584593  {
     594    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    585595    $Output = '';
    586596    $DisabledInput = array(false => ' disabled="disabled"', true => '');
    587597    $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
    588598    $Export = $DbRows->fetch_assoc();
    589     if ($this->System->User->Licence(LICENCE_USER) and ($this->System->User->Id == $Export['User'])) $Editable = true;
     599    if ($User->Licence(LICENCE_USER) and ($User->Id == $Export['User'])) $Editable = true;
    590600    else $Editable = false;
    591601
     
    697707            '(SELECT COUNT(DISTINCT(`Entry`)) FROM ('.
    698708            ' SELECT `T`.* FROM `'.$DbRow['TablePrefix'].'` AS `T`'.
    699             ' WHERE (`Language` = '.$this->System->Config['OriginalLanguage'].') AND (`VersionStart` <= '.$Export->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$Export->ClientVersion['BuildNumber'].')'.
     709            ' WHERE (`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') AND (`VersionStart` <= '.$Export->ClientVersion['BuildNumber'].') AND (`VersionEnd` >= '.$Export->ClientVersion['BuildNumber'].')'.
    700710            ') AS `C2`) AS `Total`, "'.$DbRow['Name'].'" AS `Name`';
    701711      }
     
    777787  function ExportClone()
    778788  {
    779     if ($this->System->User->Licence(LICENCE_USER))
     789    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     790    if ($User->Licence(LICENCE_USER))
    780791    {
    781792      if (array_key_exists('ExportId', $_GET) and is_numeric($_GET['ExportId']))
    782793      {
    783         $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$this->System->User->Id);
     794        $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` WHERE `User`='.$User->Id);
    784795        $DbRow = $DbResult->fetch_row();
    785         if ($DbRow[0] < $this->System->Config['MaxExportPerUser'])
     796        if ($DbRow[0] < Core::Cast($this->System)->Config['MaxExportPerUser'])
    786797        {
    787798          $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']);
     
    791802            unset($DbRow['Id']);
    792803            $DbRow['UsedCount'] = '0';
    793             $DbRow['User'] = $this->System->User->Id;
     804            $DbRow['User'] = $User->Id;
    794805            $DbRow['TimeCreate'] = 'NOW()';
    795806            $DbRow['Title'] .= ' - '.T('clone');
     
    807818          } else $Output = ShowMessage('Zdrojový export nenalezen', MESSAGE_CRITICAL);
    808819        } else $Output = ShowMessage(sprintf(T('You can\'t create another export. Max for one user is %d.'),
    809           $this->System->Config['MaxExportPerUser']), MESSAGE_CRITICAL);
     820        Core::Cast($this->System)->Config['MaxExportPerUser']), MESSAGE_CRITICAL);
    810821      } else $Output = ShowMessage(T('Export not found.'), MESSAGE_CRITICAL);
    811822    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
  • 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    ));
  • trunk/Modules/FrontPage/FrontPage.php

    r888 r893  
    2929  function HandleLoginForm()
    3030  {
     31    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    3132    global $Message, $MessageType;
    3233
     
    3940          if (array_key_exists('StayLogged', $_POST)) $StayLogged = true;
    4041            else $StayLogged = false;
    41           $this->System->User->Login($_POST['LoginUser'], $_POST['LoginPass'], $StayLogged);
    42           if ($this->System->User->Role == LICENCE_ANONYMOUS)
     42          $User->Login($_POST['LoginUser'], $_POST['LoginPass'], $StayLogged);
     43          if ($User->Role == LICENCE_ANONYMOUS)
    4344          {
    4445            $Message = T('Incorrect name or password');
     
    4647          } else
    4748          {
    48             $Message = sprintf(T('Login successful. Welcome <strong>%s</strong>!'), $this->System->User->Name);
     49            $Message = sprintf(T('Login successful. Welcome <strong>%s</strong>!'), $User->Name);
    4950            $MessageType = MESSAGE_INFORMATION;
    5051          }
     
    5556        }
    5657      } else
    57         if ($_GET['action'] == 'logout')
     58      if ($_GET['action'] == 'logout')
     59      {
     60        if ($User->Role != LICENCE_ANONYMOUS)
    5861        {
    59           if ($this->System->User->Role != LICENCE_ANONYMOUS)
    60           {
    61             $this->System->ModuleManager->Modules['Log']->WriteLog('Odhlášení', LOG_TYPE_USER);
    62             $this->System->User->Logout();
    63             $Message = T('You were logged out');
    64             $MessageType = MESSAGE_INFORMATION;
    65           }
     62          ModuleLog::Cast($this->System->GetModule('Log'))->WriteLog('Odhlášení', LOG_TYPE_USER);
     63          $User->Logout();
     64          $Message = T('You were logged out');
     65          $MessageType = MESSAGE_INFORMATION;
    6666        }
     67      }
    6768    }
    6869  }
     
    123124    // Echo text even if it is hidden because of caching by external searching engines
    124125    return '<div style="'.$HideWelcome.'">'.
    125       '<div id="bannertitle">'.$this->System->Config['Web']['Title'].'</div>'.
     126      '<div id="bannertitle">'.Core::Cast($this->System)->Config['Web']['Title'].'</div>'.
    126127      T('Open web system for translation texts from game World of Warcraft (WoW).<br/>'.
    127128      '<ul>'.
  • trunk/Modules/Import/Manage.php

    r888 r893  
    4747      '<a href="?action=instructions">Instrukce pro přípravu zdrojových souborů</a><br/>'.
    4848      '<a href="?action=update_translated">Zaktualizovat verze přeložených</a><br/><br/>'.
    49       'Verze klienta použitá pro import: <strong>'.$this->System->Config['Web']['GameVersion'].'</strong><br/>';
     49      'Verze klienta použitá pro import: <strong>'.Core::Cast($this->System)->Config['Web']['GameVersion'].'</strong><br/>';
    5050    $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Group`');
    5151    $DbRow = $DbResult->fetch_row();
     
    9898  function Show(): string
    9999  {
     100    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    100101    $this->Title = T('Import');
    101102    $Output = '';
    102     if ($this->System->User->Licence(LICENCE_ADMIN))
     103    if ($User->Licence(LICENCE_ADMIN))
    103104    {
    104105    if (array_key_exists('action', $_GET))
  • trunk/Modules/Info/Info.php

    r888 r893  
    9393'Addon jako takový je běžný doplněk do hry a je možné jej bez problémů používat i na oficiálních serverech.<br/>'.
    9494'<iframe width="420" height="315" src="https://www.youtube.com/embed/6EhBFv59syk" frameborder="0" allowfullscreen></iframe><br/>'.
    95 '<img src="'.$this->System->Link('/images/promotion.bmp').'" width="800" alt="addon-obr">';
     95'<img src="'.$this->System->Link('/images/promotion.png').'" width="800" alt="addon-obr">';
    9696    return $Output;
    9797  }
  • trunk/Modules/Log/Log.php

    r891 r893  
    3333  function WriteLog($Text, $Type)
    3434  {
    35     if (isset($this->System->User) and !is_null($this->System->User->Id))
    36       $UserId = $this->System->User->Id;
     35    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     36    if (isset($User) and !is_null($User->Id))
     37      $UserId = $User->Id;
    3738      else $UserId = 'NULL';
    3839    $Query = 'INSERT INTO `Log` ( `User` , `Type` , `Text` , `Date` , `IP`, `URL` ) '.
     
    4041      GetRemoteAddress().'", "'.GetRequestURI().'")';
    4142    $this->System->Database->query($Query);
     43  }
     44
     45  static function Cast(Module $Module): ModuleLog
     46  {
     47    if ($Module instanceof ModuleLog)
     48    {
     49      return $Module;
     50    }
     51    throw new Exception('Expected '.ModuleLog::GetClassName().' type but got '.gettype($Module));
    4252  }
    4353}
     
    91101      (
    92102        'Title' => $LogType['Name'].' ('.$Line['UserName'].', '.$Line['IP'].')',
    93         'Link' => 'https://'.$this->System->Config['Web']['Host'].$this->System->Link('/log/'),
     103        'Link' => 'https://'.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/log/'),
    94104        'Description' => $LogType['Name'].': '.$Line['Text'].' ('.$Line['UserName'].
    95105          ', '.$Line['IP'].', '.HumanDate($Line['Date']).')',
     
    100110    $Output .= GenerateRSS(array
    101111    (
    102       'Title' => $this->System->Config['Web']['Title'].' - '.T('Logs'),
    103       'Link' => 'https://'.$this->System->Config['Web']['Host'].$this->System->Link('/'),
    104       'Description' => $this->System->Config['Web']['Description'],
    105       'WebmasterEmail' => $this->System->Config['Web']['AdminEmail'],
     112      'Title' => Core::Cast($this->System)->Config['Web']['Title'].' - '.T('Logs'),
     113      'Link' => 'https://'.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/'),
     114      'Description' => Core::Cast($this->System)->Config['Web']['Description'],
     115      'WebmasterEmail' => Core::Cast($this->System)->Config['Web']['AdminEmail'],
    106116      'Items' => $Items,
    107117    ));
     
    121131  function ShowList()
    122132  {
     133    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    123134    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    124135
     
    141152
    142153    // Show category filter
    143     if ($this->System->User->Licence(LICENCE_MODERATOR))
     154    if ($User->Licence(LICENCE_MODERATOR))
    144155    {
    145156      $Output = '<strong>'.T('Filter').':</strong>';
     
    203214    $Output .= '</table>'.
    204215      $PageList['Output'];
    205       if ($this->System->User->Licence(LICENCE_ADMIN))
     216      if ($User->Licence(LICENCE_ADMIN))
    206217      {
    207218        $Output .= '<div>'.T('Remove').': <a href="'.$this->System->Link('/log/?a=delerrlog&amp;type='.LOG_TYPE_ERROR).'">'.T('Error logs').'</a> '.
     
    215226  function DeleteErrorLog()
    216227  {
    217     if ($this->System->User->Licence(LICENCE_ADMIN) and
     228    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     229    if ($User->Licence(LICENCE_ADMIN) and
    218230    (($_GET['type'] == LOG_TYPE_ERROR) or ($_GET['type'] == LOG_TYPE_PAGE_NOT_FOUND)))
    219231    {
  • 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]))
  • trunk/Modules/Redirection/Redirection.php

    r888 r893  
    33class ModuleRedirection extends Module
    44{
     5  public array $Excludes;
     6
    57  function __construct(System $System)
    68  {
     
    1214    $this->Description = 'Redirects erlier obsolete addresses to new ones.';
    1315    $this->Dependencies = array();
     16
    1417    $this->Excludes = array();
    1518  }
     
    1720  function DoStart(): void
    1821  {
    19     $this->System->OnPageNotFound = array($this, 'ShowRedirect');
     22    Core::Cast($this->System)->OnPageNotFound = array($this, 'ShowRedirect');
    2023  }
    2124
     
    3033  {
    3134    $Output = '';
    32     if (count($this->System->PathItems) > 0)
     35    if (count(Core::Cast($this->System)->PathItems) > 0)
    3336    {
    34       if ($this->System->PathItems[0] == 'user.php') $Output = $this->Redirect($this->System->Link('/user/'));
    35       if ($this->System->PathItems[0] == 'team.php') $Output = $this->Redirect($this->System->Link('/team/'));
    36       if ($this->System->PathItems[0] == 'version.php') $Output = $this->Redirect($this->System->Link('/client-version/'));
    37       if ($this->System->PathItems[0] == 'phpBB3') $Output = $this->Redirect($this->System->Link('/forum/'));
    38       if ($this->System->PathItems[0] == 'phpbb3') $Output = $this->Redirect($this->System->Link('/forum/'));
    39       if ($this->System->PathItems[0] == 'statistic.php') $Output = $this->Redirect($this->System->Link('/progress/'));
    40       if ($this->System->PathItems[0] == 'register.php') $Output = $this->Redirect($this->System->Link('/registration/'));
    41       if ($this->System->PathItems[0] == 'registrace.php') $Output = $this->Redirect($this->System->Link('/registration/'));
    42       if ($this->System->PathItems[0] == 'dictionary.php') $Output = $this->Redirect($this->System->Link('/dictionary/'));
    43       if ($this->System->PathItems[0] == 'download-addon.php') $Output = $this->Redirect($this->System->Link('/download/'));
    44       if ($this->System->PathItems[0] == 'banners.php') $Output = $this->Redirect($this->System->Link('/referrer/'));
    45       if ($this->System->PathItems[0] == 'download.php') $Output = $this->Redirect($this->System->Link('/download/'));
    46       if ($this->System->PathItems[0] == 'serverlist.php') $Output = $this->Redirect($this->System->Link('/server/'));
    47       if ($this->System->PathItems[0] == 'info.php') $Output = $this->Redirect($this->System->Link('/info/'));
    48       if ($this->System->PathItems[0] == 'userlist.php') $Output = $this->Redirect($this->System->Link('/users/'));
    49       if ($this->System->PathItems[0] == 'promotion.php') $Output = $this->Redirect($this->System->Link('/promotion/'));
    50       if ($this->System->PathItems[0] == 'log.php') $Output = $this->Redirect($this->System->Link('/log/'));
    51       if (count($this->System->PathItems) > 1)
     37      if (Core::Cast($this->System)->PathItems[0] == 'user.php') $Output = $this->Redirect($this->System->Link('/user/'));
     38      if (Core::Cast($this->System)->PathItems[0] == 'team.php') $Output = $this->Redirect($this->System->Link('/team/'));
     39      if (Core::Cast($this->System)->PathItems[0] == 'version.php') $Output = $this->Redirect($this->System->Link('/client-version/'));
     40      if (Core::Cast($this->System)->PathItems[0] == 'phpBB3') $Output = $this->Redirect($this->System->Link('/forum/'));
     41      if (Core::Cast($this->System)->PathItems[0] == 'phpbb3') $Output = $this->Redirect($this->System->Link('/forum/'));
     42      if (Core::Cast($this->System)->PathItems[0] == 'statistic.php') $Output = $this->Redirect($this->System->Link('/progress/'));
     43      if (Core::Cast($this->System)->PathItems[0] == 'register.php') $Output = $this->Redirect($this->System->Link('/registration/'));
     44      if (Core::Cast($this->System)->PathItems[0] == 'registrace.php') $Output = $this->Redirect($this->System->Link('/registration/'));
     45      if (Core::Cast($this->System)->PathItems[0] == 'dictionary.php') $Output = $this->Redirect($this->System->Link('/dictionary/'));
     46      if (Core::Cast($this->System)->PathItems[0] == 'download-addon.php') $Output = $this->Redirect($this->System->Link('/download/'));
     47      if (Core::Cast($this->System)->PathItems[0] == 'banners.php') $Output = $this->Redirect($this->System->Link('/referrer/'));
     48      if (Core::Cast($this->System)->PathItems[0] == 'download.php') $Output = $this->Redirect($this->System->Link('/download/'));
     49      if (Core::Cast($this->System)->PathItems[0] == 'serverlist.php') $Output = $this->Redirect($this->System->Link('/server/'));
     50      if (Core::Cast($this->System)->PathItems[0] == 'info.php') $Output = $this->Redirect($this->System->Link('/info/'));
     51      if (Core::Cast($this->System)->PathItems[0] == 'userlist.php') $Output = $this->Redirect($this->System->Link('/users/'));
     52      if (Core::Cast($this->System)->PathItems[0] == 'promotion.php') $Output = $this->Redirect($this->System->Link('/promotion/'));
     53      if (Core::Cast($this->System)->PathItems[0] == 'log.php') $Output = $this->Redirect($this->System->Link('/log/'));
     54      if (count(Core::Cast($this->System)->PathItems) > 1)
    5255      {
    53         if (($this->System->PathItems[0] == 'team') and ($this->System->PathItems[1] == 'userlist.php'))
     56        if ((Core::Cast($this->System)->PathItems[0] == 'team') and (Core::Cast($this->System)->PathItems[1] == 'userlist.php'))
    5457          $Output = $this->Redirect($this->System->Link('/userlist/'));
    55         if (($this->System->PathItems[0] == 'dictionary') and ($this->System->PathItems[1] == 'user.php'))
     58        if ((Core::Cast($this->System)->PathItems[0] == 'dictionary') and (Core::Cast($this->System)->PathItems[1] == 'user.php'))
    5659          $Output = $this->Redirect($this->System->Link('/user/'));
    57         if (($this->System->PathItems[0] == 'forum') and ($this->System->PathItems[1] == 'index.php'))
     60        if ((Core::Cast($this->System)->PathItems[0] == 'forum') and (Core::Cast($this->System)->PathItems[1] == 'index.php'))
    5861          $Output = $this->Redirect($this->System->Link('/forum/'));
    59         if (($this->System->PathItems[0] == 'phpbb3') and ($this->System->PathItems[1] == 'index.php'))
     62        if ((Core::Cast($this->System)->PathItems[0] == 'phpbb3') and (Core::Cast($this->System)->PathItems[1] == 'index.php'))
    6063          $Output = $this->Redirect($this->System->Link('/forum/'));
    61         if (($this->System->PathItems[0] == 'phpBB3') and ($this->System->PathItems[1] == 'index.php'))
     64        if ((Core::Cast($this->System)->PathItems[0] == 'phpBB3') and (Core::Cast($this->System)->PathItems[1] == 'index.php'))
    6265          $Output = $this->Redirect($this->System->Link('/forum/'));
    63         if (($this->System->PathItems[0] == 'download') and ($this->System->PathItems[1] == 'ceske_fonty_do_wow.zip'))
     66        if ((Core::Cast($this->System)->PathItems[0] == 'download') and (Core::Cast($this->System)->PathItems[1] == 'ceske_fonty_do_wow.zip'))
    6467          $Output = $this->Redirect($this->System->Link('/files/ceske_fonty_do_wow.zip'));
    6568      }
  • trunk/Modules/Referrer/Referrer.php

    r891 r893  
    2020  function DoStart(): void
    2121  {
    22     $this->Excludes[] = $this->System->Config['Web']['Host'];
     22    $this->Excludes[] = Core::Cast($this->System)->Config['Web']['Host'];
    2323    $this->Log();
    2424    $this->System->RegisterPage(['referrer'], 'PageReferrer');
     
    7777  function ShowList()
    7878  {
    79     $Banner = '<a href="https://'.$this->System->Config['Web']['Host'].$this->System->Link('/').'">'.
    80       '<img src="https://'.$this->System->Config['Web']['Host'].$this->System->Link('/banners/wowpreklad_big.jpg').'" '.
     79    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     80    $Banner = '<a href="https://'.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/').'">'.
     81      '<img src="https://'.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/banners/wowpreklad_big.jpg').'" '.
    8182      'alt="wowpreklad" title="Otevřený projekt překládání celé hry World of Warcraft" '.
    8283      'class="banner" height="60" width="468" /></a>';
    8384
    84     $BannerSmall = '<a href="https://'.$this->System->Config['Web']['Host'].$this->System->Link('/').'">'.
    85       '<img src="https://'.$this->System->Config['Web']['Host'].$this->System->Link('/banners/wowpreklad_small.jpg').'" '.
     85    $BannerSmall = '<a href="https://'.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/').'">'.
     86      '<img src="https://'.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/banners/wowpreklad_small.jpg').'" '.
    8687      'alt="wowpreklad" title="Otevřený projekt překládání celé hry World of Warcraft" '.
    8788      'class="banner" height="31" width="88" /></a>';
     
    9293    $Output .= $BannerSmall.' &nbsp;&nbsp;<textarea rows="2" cols="30">'.htmlspecialchars($BannerSmall).'</textarea><br />';
    9394
    94     if ($this->System->User->Licence(LICENCE_ADMIN)) {
     95    if ($User->Licence(LICENCE_ADMIN)) {
    9596
    9697    $MonthAge = 3;
     
    99100    <div style="font-size: 10px;">Seznam je automaticky aktualizován a zobrazeny jsou servery, ze kterých přišli uživatelé během posledních třech měsíců řazený sestupně dle nejnovějších.</div><br />';
    100101
    101     if (!$this->System->User->Licence(LICENCE_ADMIN)) $Where = ' WHERE (`Visible`=1) AND (`Parent` IS NULL)';
     102    if (!$User->Licence(LICENCE_ADMIN)) $Where = ' WHERE (`Visible`=1) AND (`Parent` IS NULL)';
    102103    else $Where = '';
    103104    $Query = 'SELECT *, (SELECT Web FROM `Referrer` AS T4 WHERE T4.Id = T3.Parent) AS ParentName '.
     
    123124        array('Name' => 'TotalHits', 'Title' => T('Hits')),
    124125    );
    125     if ($this->System->User->Licence(LICENCE_ADMIN))
     126    if ($User->Licence(LICENCE_ADMIN))
    126127    {
    127128      $TableColumns[] = array('Name' => 'Visible', 'Title' => T('Visible'));
     
    142143          '<td>'.HumanDate($Line['MaxDateLast']).'</td>'.
    143144          '<td>'.$Line['TotalHits'].'</td>';
    144       if ($this->System->User->Licence(LICENCE_ADMIN))
     145      if ($User->Licence(LICENCE_ADMIN))
    145146      {
    146147        $Output .=
     
    183184  function Spam()
    184185  {
    185     if ($this->System->User->Licence(LICENCE_ADMIN))
     186    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     187    if ($User->Licence(LICENCE_ADMIN))
    186188    {
    187189      if (array_key_exists('id', $_GET))
     
    207209  function Edit()
    208210  {
    209     if ($this->System->User->Licence(LICENCE_ADMIN))
     211    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     212    if ($User->Licence(LICENCE_ADMIN))
    210213    {
    211214      if (array_key_exists('id', $_GET))
     
    232235  function EditSave()
    233236  {
    234     if ($this->System->User->Licence(LICENCE_ADMIN))
     237    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     238    if ($User->Licence(LICENCE_ADMIN))
    235239    {
    236240      if ($_POST['Parent'] == '') $_POST['Parent'] = null;
  • trunk/Modules/ShoutBox/ShoutBox.php

    r891 r893  
    2727  function ShowBox()
    2828  {
     29    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    2930    $Output = '<strong><a href="'.$this->System->Link('/shoutbox/').'">'.T('Shoutbox').':</a></strong>';
    3031
    31     if ($this->System->User->Licence(LICENCE_USER))
     32    if ($User->Licence(LICENCE_USER))
    3233      $Output .= ' <a href="'.$this->System->Link('/shoutbox/?a=add').'">'.T('Add').'</a>';
    3334    $Output .= '<div class="box"><div class="shoutbox"><table>';
     
    5657  function ShowList()
    5758  {
     59    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    5860    $Output = '';
    5961    if (array_key_exists('search', $_GET)) $_SESSION['search'] = $_GET['search'];
     
    7173
    7274    $Output .= '<h3>'.T('Shoutbox').'</h3>';
    73     if ($this->System->User->Licence(LICENCE_USER))
     75    if ($User->Licence(LICENCE_USER))
    7476      $Output .= ' <a href="'.$this->System->Link('/shoutbox/?a=add').'">'.T('Add').'</a>';
    7577    $Output .= $PageList['Output'];
     
    8486  function ShowAddForm()
    8587  {
     88    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    8689    $Output = '';
    87     if ($this->System->User->Licence(LICENCE_USER))
     90    if ($User->Licence(LICENCE_USER))
    8891    {
    8992        $Output .= '<form action="?" method="post">'.
    9093            '<fieldset><legend>'.T('New message').'</legend>'.
    9194            'Uživatel: ';
    92         if ($this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />';
     95        if ($User->Licence(LICENCE_USER)) $Output .= '<b>'.$User->Name.'</b><br />';
    9396        else $Output .= '<input type="text" name="user" /><br />';
    9497      $Output .= 'Text zprávy: <br/>'.
     
    104107  function AddFinish()
    105108  {
     109    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    106110    $Output = '';
    107     if ($this->System->User->Licence(LICENCE_USER))
     111    if ($User->Licence(LICENCE_USER))
    108112    {
    109113      if (array_key_exists('text', $_POST))
     
    115119          // Protection against mutiple post of same message
    116120          $DbResult = $this->System->Database->query('SELECT `Text` FROM `ShoutBox` WHERE (`User` = "'.
    117               $this->System->User->Id.'") ORDER BY `Date` DESC LIMIT 1');
     121              $User->Id.'") ORDER BY `Date` DESC LIMIT 1');
    118122          if ($DbResult->num_rows > 0)
    119123          {
     
    125129          {
    126130            $this->System->Database->query('INSERT INTO `ShoutBox` ( `User`, `UserName` , `Text` , `Date` , `IP` ) '.
    127                 ' VALUES ('.$this->System->User->Id.', "'.$this->System->User->Name.
     131                ' VALUES ('.$User->Id.', "'.$User->Name.
    128132                '", "'.$Text.'", NOW(), "'.GetRemoteAddress().'")');
    129133            $Output .= ShowMessage('Zpráva vložena.');
     
    139143  function ShowRSS()
    140144  {
     145    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    141146    $Items = array();
    142147    $TitleLength = 50;
     
    150155      (
    151156          'Title' => $DbRow['UserName'].': '.$Title,
    152           'Link' =>  'https://'.$this->System->Config['Web']['Host'].$this->System->Link('/shoutbox/'),
     157          'Link' =>  'https://'.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/shoutbox/'),
    153158          'Description' => $DbRow['Text'],
    154159          'Time' => $DbRow['UnixDate'],
     
    157162    $Output = GenerateRSS(array
    158163    (
    159       'Title' => $this->System->Config['Web']['Title'].' - '.T('Shoutbox'),
    160       'Link' => 'https://'.$this->System->Config['Web']['Host'].$this->System->Link('/shoutbox/'),
    161       'Description' => $this->System->Config['Web']['Description'],
    162       'WebmasterEmail' => $this->System->Config['Web']['AdminEmail'],
     164      'Title' => Core::Cast($this->System)->Config['Web']['Title'].' - '.T('Shoutbox'),
     165      'Link' => 'https://'.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/shoutbox/'),
     166      'Description' => Core::Cast($this->System)->Config['Web']['Description'],
     167      'WebmasterEmail' => Core::Cast($this->System)->Config['Web']['AdminEmail'],
    163168      'Items' => $Items,
    164169    ));
  • trunk/Modules/Team/Team.php

    r888 r893  
    3434  function ShowTeamList()
    3535  {
     36    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    3637    $this->Title = T('Teams');
    3738    $Output = '<h3>'.T('List of translating teams').'</h3>';
     
    4243    if (array_key_exists('search', $_GET) and ($_GET['search'] == '')) $_SESSION['search'] = '';
    4344
    44     if ($this->System->User->Licence(LICENCE_USER))
     45    if ($User->Licence(LICENCE_USER))
    4546      $Output .= '<br /><div style="text-align: center;"><a href="?action=create">'.T('Create translating team').'</a></div><br/>';
    4647    if ($_SESSION['search'] != '')
     
    6465      array('Name' => 'TimeCreate', 'Title' => T('Founding date')),
    6566    );
    66     if ($this->System->User->Licence(LICENCE_USER)) $TableColumns[] = array('Name' => '', 'Title' => T('User actions'));
     67    if ($User->Licence(LICENCE_USER)) $TableColumns[] = array('Name' => '', 'Title' => T('User actions'));
    6768
    6869    $Order = GetOrderTableHeader($TableColumns, 'NumberUser', 1);
     
    8081        '<td><a href="'.$this->System->Link('/users/?team='.$Team['Id']).'" title="Zobrazit členy týmu">'.$Team['NumberUser'].'</a></td>'.
    8182        '<td>'.HumanDate($Team['TimeCreate']).'</td>';
    82       if ($this->System->User->Licence(LICENCE_USER))
    83       {
    84         if ($Team['Leader'] == $this->System->User->Id) $Action = ' <a href="?action=modify&amp;id='.$Team['Id'].'">'.T('Edit').'</a>';
     83      if ($User->Licence(LICENCE_USER))
     84      {
     85        if ($Team['Leader'] == $User->Id) $Action = ' <a href="?action=modify&amp;id='.$Team['Id'].'">'.T('Edit').'</a>';
    8586        else $Action = '';
    86         if ($Team['Id'] == $this->System->User->Team) $Action = ' <a href="?action=leave">'.T('Leave').'</a>';
     87        if ($Team['Id'] == $User->Team) $Action = ' <a href="?action=leave">'.T('Leave').'</a>';
    8788        $Output .= '<td><a href="?action=gointeam&amp;id='.$Team['Id'].'">'.T('Enter').'</a>'.$Action.'</td>';
    8889      }
     
    9798  function TeamJoin()
    9899  {
    99     if ($this->System->User->Licence(LICENCE_USER))
     100    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     101    if ($User->Licence(LICENCE_USER))
    100102    {
    101103      if (array_key_exists('id', $_GET))
    102104      {
    103         $this->Database->query('UPDATE `User` SET `Team` = '.$_GET['id'].' WHERE `ID` = '.$this->System->User->Id);
     105        $this->Database->query('UPDATE `User` SET `Team` = '.$_GET['id'].' WHERE `ID` = '.$User->Id);
    104106        $Output = ShowMessage(T('You joined new team'));
    105107        $this->System->ModuleManager->Modules['Log']->WriteLog('Uživatel vstoupil do týmu '.$_GET['id'], LOG_TYPE_USER);
     
    119121  function TeamCreateFinish()
    120122  {
     123    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    121124    $Output = '';
    122     if ($this->System->User->Licence(LICENCE_USER))
     125    if ($User->Licence(LICENCE_USER))
    123126    {
    124127      if (array_key_exists('Name', $_POST) and array_key_exists('Description', $_POST))
     
    131134          $this->Database->query('INSERT INTO `Team` (`Name` ,`Description`, `URL`, `TimeCreate`, `Leader`)'.
    132135            ' VALUES ("'.trim($_POST['Name']).'", "'.trim($_POST['Description']).'", "'.
    133             $_POST['URL'].'", NOW(), '.$this->System->User->Id.')');
    134           $this->Database->query('UPDATE `User` SET `Team` = '.$this->Database->insert_id.' WHERE `ID` = '.$this->System->User->Id);
     136            $_POST['URL'].'", NOW(), '.$User->Id.')');
     137          $this->Database->query('UPDATE `User` SET `Team` = '.$this->Database->insert_id.' WHERE `ID` = '.$User->Id);
    135138          $Output .= ShowMessage('Překladatelský tým vytvořen.');
    136139          $this->System->ModuleManager->Modules['Log']->WriteLog('Překladatelský tým vytvořen '.$_POST['Name'], LOG_TYPE_USER);
     
    147150  function TeamModify()
    148151  {
    149     if ($this->System->User->Licence(LICENCE_USER))
     152    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     153    if ($User->Licence(LICENCE_USER))
    150154    {
    151155      if (array_key_exists('id', $_GET))
    152156      {
    153         $DbResult = $this->Database->query('SELECT * FROM `Team` WHERE `Id`='.$_GET['id'].' AND `Leader`='.$this->System->User->Id);
     157        $DbResult = $this->Database->query('SELECT * FROM `Team` WHERE `Id`='.$_GET['id'].' AND `Leader`='.$User->Id);
    154158        if ($DbResult->num_rows > 0)
    155159        {
     
    170174  function TeamModifyFinish()
    171175  {
     176    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    172177    $Output = '';
    173     if ($this->System->User->Licence(LICENCE_USER))
     178    if ($User->Licence(LICENCE_USER))
    174179    {
    175180      if (array_key_exists('id', $_GET) and array_key_exists('Name', $_POST) and array_key_exists('Description', $_POST) and array_key_exists('URL', $_POST))
    176181      {
    177         $DbResult = $this->Database->query('SELECT * FROM `Team` WHERE `Id`='.$_GET['id'].' AND `Leader`='.$this->System->User->Id);
     182        $DbResult = $this->Database->query('SELECT * FROM `Team` WHERE `Id`='.$_GET['id'].' AND `Leader`='.$User->Id);
    178183        if ($DbResult->num_rows > 0)
    179184        {
     
    197202  function TeamCreate()
    198203  {
    199     if ($this->System->User->Licence(LICENCE_USER))
     204    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     205    if ($User->Licence(LICENCE_USER))
    200206    {
    201207      $Output ='<form action="?action=finish_create" method="post">'.
     
    212218  function TeamShow()
    213219  {
     220    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    214221    $Output = '';
    215222    if (array_key_exists('id', $_GET) and is_numeric($_GET['id']))
     
    237244        $Output .= '<br />';
    238245        //$Output .= '<a href="export/?team='.$Team['Id'].'">Exportovat překlad týmu</a> ';
    239         if ($this->System->User->Licence(LICENCE_USER))
     246        if ($User->Licence(LICENCE_USER))
    240247          $Output .='<a href="?action=gointeam&amp;id='.$Team['Id'].'">'.T('Enter to team').'</a><br /><br />';
    241248        $XP = GetLevelMinMax($Team['AverageXP']);
     
    245252          T('Average level of team members').': <strong>'.$XP['Level'].'</strong> '.T('experience').': '.ProgressBar(150, round($XP['XP'] / $XP['MaxXP'] * 100, 2), $XP['XP'].' / '.$XP['MaxXP']).'<br />'.
    246253          '<br />'.
    247           '<strong>'.T('Team completion state for version').' '.$this->System->Config['Web']['GameVersion'].'</strong><br />';
    248 
    249         $BuildNumber = GetBuildNumber($this->System->Config['Web']['GameVersion']);
     254          '<strong>'.T('Team completion state for version').' '.Core::Cast($this->System)->Config['Web']['GameVersion'].'</strong><br />';
     255
     256        $BuildNumber = GetBuildNumber(Core::Cast($this->System)->Config['Web']['GameVersion']);
    250257
    251258        $GroupListQuery = 'SELECT `Group`.* FROM `Group`';
     
    259266              'SELECT `T`.`Entry` FROM `'.$DbRow['TablePrefix'].'` AS `T` '.
    260267              'WHERE (`User` IN (SELECT `ID` FROM `User` WHERE `Team` = '.$Team['Id'].')) '.
    261               'AND (`Complete` = 1) AND (`T`.`Language`!='.$this->System->Config['OriginalLanguage'].') '.
     268              'AND (`Complete` = 1) AND (`T`.`Language`!='.Core::Cast($this->System)->Config['OriginalLanguage'].') '.
    262269              'AND (`VersionStart` <= '.$BuildNumber.') AND (`VersionEnd` >= '.$BuildNumber.')'.
    263270              ') AS `C1`) AS `Translated`, '.
    264271              '(SELECT COUNT(DISTINCT(`Entry`)) FROM ('.
    265272              'SELECT `T`.`Entry` FROM `'.$DbRow['TablePrefix'].'` AS `T` '.
    266               'WHERE (`Language` = '.$this->System->Config['OriginalLanguage'].') '.
     273              'WHERE (`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') '.
    267274              'AND (`VersionStart` <= '.$BuildNumber.') AND (`VersionEnd` >= '.$BuildNumber.')'.
    268275              ') AS `C2`) AS `Total`, "'.$DbRow['Name'].'" AS `Name` UNION ';
     
    311318  function TeamLeave()
    312319  {
    313     if ($this->System->User->Licence(LICENCE_USER))
    314     {
    315       $this->Database->query('UPDATE `User` SET `Team` = NULL WHERE `ID` = '.$this->System->User->Id);
     320    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     321    if ($User->Licence(LICENCE_USER))
     322    {
     323      $this->Database->query('UPDATE `User` SET `Team` = NULL WHERE `ID` = '.$User->Id);
    316324      $Output = ShowMessage(T('You are now not member of any team'));
    317325      $this->System->ModuleManager->Modules['Log']->WriteLog('Uživatel vystoupil z týmu', LOG_TYPE_USER);
  • trunk/Modules/Translation/Comparison.php

    r888 r893  
    4040  function Show(): string
    4141  {
     42    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    4243    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    4344
    4445    $Output = '';
    4546
    46     if ($this->System->User->Licence(LICENCE_USER))
     47    if ($User->Licence(LICENCE_USER))
    4748    {
    4849    $Output = 'Text je porovnáván vždy ku předešlému (vlevo). Změny jsou zvýrazněny <span class="edit">barvou.</span><br /><br />';
  • trunk/Modules/Translation/Form.php

    r888 r893  
    1919  function ShowForm(): string
    2020  {
     21    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    2122    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    2223
     
    4142      } else
    4243      {
    43         if ($this->System->Config['OriginalLanguage'] == $Line['Language']){
     44        if (Core::Cast($this->System)->Config['OriginalLanguage'] == $Line['Language']){
    4445          $LineAJ = $Line;
    4546
    46           if ($this->System->User->Language <> '') $Language = '`Language` = '.$this->System->User->Language;
    47           else $Language = '`Language` != '.$this->System->Config['OriginalLanguage'];
     47          if ($User->Language <> '') $Language = '`Language` = '.$User->Language;
     48          else $Language = '`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'];
    4849          $Columns = '';
    4950          foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)
     
    5556          $where = ' WHERE '.'( `Tran`.'.$Language.' ) AND '.'(`Tran`.`Entry` = '.$Line['Entry'].') ORDER BY `Tran`.`ModifyTime` DESC';
    5657          $DbResult = $this->Database->query($sql.$join.$where);
    57           while ($LineSearch = $DbResult->fetch_assoc()) {
     58          while ($LineSearch = $DbResult->fetch_assoc())
     59          {
    5860            foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)
     61            {
    5962              if ($TextItem['Visible'] == 1)
     63              {
    6064                if (($LineAJ[$TextItem['Column']] <> '') and
    6165                    ($LineSearch[$TextItem['Column']] <> '') and
    6266                    ($LineSearch['Orig_'.$TextItem['Column']] <> $LineSearch[$TextItem['Column']]) and
    6367                    ($LineAJ[$TextItem['Column']] == $Line[$TextItem['Column']])
    64                    )
    65                  {
    66                    $Line[$TextItem['Column']] = $LineSearch[$TextItem['Column']];
    67                  }
    68           }
    69 
    70         } else {
     68                  )
     69                {
     70                  $Line[$TextItem['Column']] = $LineSearch[$TextItem['Column']];
     71                }
     72              }
     73            }
     74          }
     75        } else
     76        {
    7177          $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE '.
    72           '(`Language` = '.$this->System->Config['OriginalLanguage'].') AND '.
     78          '(`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') AND '.
    7379          '(`Entry` = '.$Line['Entry'].') AND (`VersionEnd` = '.$Line['VersionEnd'].') LIMIT 1');
    7480          $LineAJ = $DbResult->fetch_assoc();
     
    7985        } else
    8086        {
    81 
    8287          if ($Line['User'] != '')
    8388          {
     
    128133            <input type="hidden" name="ID2" value="'.$TextID.'" />';
    129134
    130             if ($this->System->User->Licence(LICENCE_USER)) { // allow to compare only to user
     135            if ($User->Licence(LICENCE_USER)) { // allow to compare only to user
    131136              $Output .= '<select onchange="this.form.submit();" name="ID1">
    132137              <option value="-1">'.T('Select text for comparison').'</option>
     
    155160
    156161          // Special characters: $B - New line, $N - Name, $C - profession
    157           if ($this->System->User->Licence(LICENCE_USER))
     162          if ($User->Licence(LICENCE_USER))
    158163          {
    159164            $Output .= '<form action="'.$this->System->Link('/save.php?group='.$GroupId).'" method="post"><div>';
     
    175180
    176181          $Output .= '<input type="hidden" name="entry" value="'.$LineAJ['Entry'].'" />
    177           <input type="hidden" name="user" value="'.$this->System->User->Id.'" />
     182          <input type="hidden" name="user" value="'.$User->Id.'" />
    178183          <input type="hidden" name="ID" value="'.$TextID.'" />
    179184          <table class="BaseTable">
     
    188193          <td>';
    189194          if ($Line['Language'] <> 0) $Language = $Line['Language'];
    190           else if ($this->System->User->Id != 0)
    191           {
    192             $Language = $this->System->User->Language;
     195          else if ($User->Id != 0)
     196          {
     197            $Language = $User->Language;
    193198          } else $Language = 0;
    194           if ($this->System->User->Licence(LICENCE_USER)) $Output .= WriteLanguages($Language);
    195             else {
     199          if ($User->Licence(LICENCE_USER))
     200          {
     201            $Output .= WriteLanguages($Language);
     202          }
     203          else
     204          {
    196205            $DbResult3 = $this->Database->select('Language', '`Id`, `Name`', '(`Enabled` = 1) AND (`Id`='.$Language.')');
    197206            if ($DbResult3->num_rows > 0)
     
    200209              $Output .= T($Language['Name']);
    201210            }
    202             }
     211          }
    203212
    204213          $Output .= '</td></tr>';
     
    210219          $Output .=    '$(document).ready(function() {';
    211220          foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)
     221          {
    212222            $Output .=   '$("#'.$TextItem['Column'].'").load("'.$this->System->Link('/LoadNames.php?ID='.$LineAJ['ID'].'&Column='.$TextItem['Column'].'&GroupId='.$GroupId).'");';
     223          }
    213224
    214225          $Output .= '});'.
    215226            '</script>';
    216227
    217           foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)
     228          foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)         
     229          {
    218230            if ($TextItem['Visible'] == 1)
    219231            {
     
    225237                $Output .= '<td id="'.$TextItem['Column'].'">'.str_replace("\n", '<br/>', htmlspecialchars($LineAJ[$TextItem['Column']])).'</td>
    226238                <td>';
    227                 if ($this->System->User->Licence(LICENCE_USER))
     239                if ($User->Licence(LICENCE_USER))
    228240                  $Output .= '<textarea rows="8" cols="40" onkeydown="ResizeTextArea(this)" class="textedit" id="'.$TextItem['Column'].'" name="'.$TextItem['Column'].'">';
    229241                $Output .=  htmlspecialchars($Line[$TextItem['Column']]);
    230                 if ($this->System->User->Licence(LICENCE_USER)) $Output .= '</textarea></td></tr>';
     242                if ($User->Licence(LICENCE_USER)) $Output .= '</textarea></td></tr>';
    231243              }
    232244            } else
     
    234246              $Output .= '<input id="'.$TextItem['Column'].'" name="'.$TextItem['Column'].'" type="hidden" value="'.htmlspecialchars($Line[$TextItem['Column']]).'" />';
    235247            }
    236             $Output .= '</table></div>';
    237             if ($this->System->User->Licence(LICENCE_USER)) {
    238               $Output .= '</form>';
    239 
    240               if (isset($this->System->Config['Web']['EnableGoogleTranslate']) and
    241                 $this->System->Config['Web']['EnableGoogleTranslate'])
    242               {
     248          }
     249
     250          $Output .= '</table></div>';
     251          if ($User->Licence(LICENCE_USER))
     252          {
     253            $Output .= '</form>';
     254
     255            if (isset(Core::Cast($this->System)->Config['Web']['EnableGoogleTranslate']) and
     256              Core::Cast($this->System)->Config['Web']['EnableGoogleTranslate'])
     257            {
    243258              $Output .= '<br/><table class="BaseTable">'.
    244259              '<tr><th>'.T('Google translator').':</th><th>'.T('Not translated').'</th><th>'.T('Translated').'</th>';
    245260              foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)
     261              {
    246262                if ($TextItem['Visible'] == 1)
     263                {
    247264                  if ($LineAJ[$TextItem['Column']] <> '')
     265                  {
    248266                    $Output .= '<tr><td>'.$TextItem['Column'].'</td>'.
    249267                      '<td>'.$LineAJ[$TextItem['Column']].'</td>'.
    250                       '<td>'.GetTranslateGoogle($LineAJ[$TextItem['Column']]).'</td></tr>';
    251 
     268                      '<td>'.GetTranslateGoogle($this->System, $LineAJ[$TextItem['Column']]).'</td></tr>';
     269                  }
     270                }
     271              }
    252272              $Output .= '</table>';
    253               }
    254             }
     273            }
     274          }
    255275        }
    256276      }
     
    261281  function Delete()
    262282  {
     283    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    263284    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    264285
    265     if ($this->System->User->Licence(LICENCE_MODERATOR))
     286    if ($User->Licence(LICENCE_MODERATOR))
    266287    {
    267288      $GroupId = LoadGroupIdParameter();
     
    269290      $Table = $TranslationTree[$GroupId]['TablePrefix'];
    270291      $TextID = $_GET['ID'];
    271       $this->Database->query('DELETE FROM `'.$Table.'` WHERE `ID` = '.$TextID.' AND `Language` <> '.$this->System->Config['OriginalLanguage']);
     292      $this->Database->query('DELETE FROM `'.$Table.'` WHERE `ID` = '.$TextID.' AND `Language` <> '.Core::Cast($this->System)->Config['OriginalLanguage']);
    272293      $Output = ShowMessage('Překlad byl smazán.');
    273294      $this->System->ModuleManager->Modules['Log']->WriteLog('Překlad byl smazán! <a href="'.$this->System->Link('/form.php?group='.$this->GroupId.'&amp;ID='.$TextID).'">'.$TextID.'</a>', LOG_TYPE_MODERATOR);
  • trunk/Modules/Translation/LoadNames.php

    r888 r893  
    2020    return $Text;
    2121  }
     22
    2223  function ReplaceNotTranslated($orig,$tran,$Text,$ID,$Group)
    2324  {
     
    4445    $Text = str_replace('$r','<span Title="Znamená rasu hráče, překladu zachovej na stejné pozici." class="edit">$R</span>',$Text);
    4546    $Text = str_replace('$g','<span Title="Vybere oslovení podle pohlaví hráče, překladu zachovej na stejné pozici." class="edit">$G</span>',$Text);
    46     foreach ($names as $Line) {
    47      if (($_GET['ID'] <> $Line[0]) or ($Line[1] <> $_GET['GroupId']))
    48       if ($Line[3] <> '')  {
    49         $Text = $this->ReplaceTranslated($Line[2],$Line[3],$Text,$Line[0],$Line[1]);
    50 
    51       } else {
    52         $Text = $this->ReplaceNotTranslated($Line[2],$Line[3],$Text,$Line[0],$Line[1]);
     47    foreach ($names as $Line)
     48    {
     49      if (($_GET['ID'] <> $Line[0]) or ($Line[1] <> $_GET['GroupId']))
     50      {
     51        if ($Line[3] <> '') 
     52        {
     53          $Text = $this->ReplaceTranslated($Line[2],$Line[3],$Text,$Line[0],$Line[1]);     
     54        } else
     55        {
     56          $Text = $this->ReplaceNotTranslated($Line[2],$Line[3],$Text,$Line[0],$Line[1]);
     57        }
    5358      }
    5459    }
     
    5863  function LoadNames()
    5964  {
     65    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    6066    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    6167
     
    7278          $Text = $LineAJ[$Column];
    7379          $names = array();
    74           if ($this->System->User->Licence(LICENCE_USER))
     80          if ($User->Licence(LICENCE_USER))
    7581          if (($GroupId < 4) or ($GroupId == 10) or ($GroupId == 11))
    7682          {
    7783            //<span class="edit">barvou.</span>
    7884            $names = GetTranslatNames($Text, 0, GetTranslatNamesArray());
    79           } else {
    80             if (($GroupId == 13)) {
     85          } else
     86          {
     87            if (($GroupId == 13))
     88            {
    8189              $names = GetTranslatNames($Text, 0, array('Dictionary' => 'Text',
    8290                'TextGlobalString' => 'Text', 'TextArea' => 'Name',
    8391                'TextItemSubClass' => 'Name', 'TextCharacterRace' => 'Name1',), false);
    84             } else {
     92            } else
     93            {
    8594              $names = GetTranslatNames($Text, 0, GetTranslatNamesArray());
    8695            }
    8796          }
    88                                    //$LineAJ[$Column]
     97          //$LineAJ[$Column]
    8998          return $this->ColorNames(htmlspecialchars($Text),$names);
    9099    }
  • trunk/Modules/Translation/Progress.php

    r888 r893  
    99    $BuildNumber = GetBuildNumber($_SESSION['StatVersion']);
    1010    if (is_numeric($_SESSION['language'])) $LanguageFilter = 'AND (`Language`='.$_SESSION['language'].')';
    11     else $LanguageFilter = ' AND (`Language`!='.$this->System->Config['OriginalLanguage'].')';
     11    else $LanguageFilter = ' AND (`Language`!='.Core::Cast($this->System)->Config['OriginalLanguage'].')';
    1212
    1313    $GroupListQuery = 'SELECT `Id`, `TablePrefix`, `Name` FROM `Group`';
     
    2525          '(SELECT COUNT(DISTINCT(`Entry`)) FROM ('.
    2626          'SELECT `T`.`Entry` FROM `'.$DbRow['TablePrefix'].'` AS `T` '.
    27           'WHERE (`Language` = '.$this->System->Config['OriginalLanguage'].') '.
     27          'WHERE (`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') '.
    2828          'AND (`VersionStart` <= '.$BuildNumber.') AND (`VersionEnd` >= '.$BuildNumber.')'.
    2929          ') AS `C2`) AS `Total`, "'.$DbRow['Name'].'" AS `Name` UNION ';
     
    5959      else $TotalCount = 0;
    6060      $Output .= '<tr><td><strong>'.T('Total').'</strong></td><td><strong>'.$Translated.'</strong></td><td><strong>'.$Total.'</strong></td><td><strong>'.ProgressBar(150, $TotalCount).'</strong></td></tr>'.
    61           '</table>';
     61        '</table>';
    6262    }
    6363    return $Output;
     
    6666  function Show(): string
    6767  {
     68    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    6869    $this->Title = T('Progress');
    6970    $LanguageList = GetLanguageList();
     
    7273    if (!array_key_exists('StatVersion', $_SESSION))
    7374    {
    74       if ($this->System->User->Licence(LICENCE_USER) and ($this->System->User->PreferredVersionGame != ''))
     75      if ($User->Licence(LICENCE_USER) and ($User->PreferredVersionGame != ''))
    7576      {
    76         $_SESSION['StatVersion'] = $this->System->User->PreferredVersionGame;
    77       } else {
    78         $_SESSION['StatVersion'] = $this->System->Config['Web']['GameVersion'];
     77        $_SESSION['StatVersion'] = $User->PreferredVersionGame;
     78      } else
     79      {
     80        $_SESSION['StatVersion'] = Core::Cast($this->System)->Config['Web']['GameVersion'];
    7981      }
    8082    }
     
    8284    if (!isset($_SESSION['language']))
    8385    {
    84       if ($this->System->User->Licence(LICENCE_USER))
     86      if ($User->Licence(LICENCE_USER))
    8587      {
    86         $_SESSION['language'] = $this->System->User->Language;
    87       } else {
     88        $_SESSION['language'] = $User->Language;
     89      } else
     90      {
    8891        $_SESSION['language'] = '';
    8992      }
     
    9396      if ($_GET['language'] == '') {
    9497        $_SESSION['language'] = '';
    95       } else {
     98      } else
     99      {
    96100        $_SESSION['language'] = $_GET['language'] * 1;
    97101      }
     
    103107    $DbResult = $this->Database->query('SELECT `Version`, `Title` FROM `ClientVersion` WHERE `Imported`=1 ORDER BY `Version`');
    104108    while ($DbRow = $DbResult->fetch_assoc())
     109    {
    105110      $Output .= '<a href="?Version='.$DbRow['Version'].'" title="'.$DbRow['Title'].'">'.$DbRow['Version'].'</a> ';
     111    }
    106112    $Output .= '<br/>';
    107113
  • trunk/Modules/Translation/Save.php

    r888 r893  
    55  function Translate($Group, $TextID, $Complete, $Language)
    66  {
     7    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    78    $Output = '';
    89    $Table = $Group['TablePrefix'];
     
    1718      // Get data for english original
    1819      $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE (`Entry`='.$SourceText['Entry'].') '.
    19           'AND (`Language` = '.$this->System->Config['OriginalLanguage'].') AND (`VersionStart` = '.$SourceText['VersionStart'].') '.
     20          'AND (`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') AND (`VersionStart` = '.$SourceText['VersionStart'].') '.
    2021          'AND (`VersionEnd` = '.$SourceText['VersionEnd'].')');
    2122      if ($DbResult->num_rows > 0)
     
    3334          else $Filter = ' AND 0';
    3435
    35           $Query = 'SELECT * FROM `'.$Table.'` WHERE (`Language` = '.$this->System->Config['OriginalLanguage'].')'.$Filter;
     36          $Query = 'SELECT * FROM `'.$Table.'` WHERE (`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].')'.$Filter;
    3637          $DbResult = $this->Database->query($Query);
    3738          while ($EnglishFound = $DbResult->fetch_assoc())
    3839          {
    3940            // Get user translation paired to found english item entry
    40             $DbResult2 = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE (`User` = '.$this->System->User->Id.
     41            $DbResult2 = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE (`User` = '.$User->Id.
    4142              ') AND (`Entry` = '.$EnglishFound['Entry'].') AND (`VersionStart` = '.$EnglishFound['VersionStart'].
    4243              ') AND (`VersionEnd` = '.$EnglishFound['VersionEnd'].')');
     
    110111              $Columns = '`Entry`, `VersionStart`, `VersionEnd`, `Language`, `User`, `Take`, `ModifyTime`';
    111112              $Values = $EnglishFound['Entry'].', '.$EnglishFound['VersionStart'].', '.
    112                   $EnglishFound['VersionEnd'].', '.$Language.', '.$this->System->User->Id.', '.$TakeID.', NOW()';
     113                  $EnglishFound['VersionEnd'].', '.$Language.', '.$User->Id.', '.$TakeID.', NOW()';
    113114
    114115              $CompleteParts = 0;
     
    178179    global $Message, $MessageType;
    179180
     181    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    180182    $Output = '';
    181183    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
     
    188190    $Group = $TranslationTree[$GroupId];
    189191    $Table = $Group['TablePrefix'];
    190     if ($this->System->User->Licence(LICENCE_USER))
     192    if ($User->Licence(LICENCE_USER))
    191193    {
    192194      if (array_key_exists('ID', $_POST) and is_numeric($_POST['ID']))
     
    202204        $Output .= $this->ShowRedirection($GroupId, $Table, $TextID);
    203205
    204         UserLevelUpdate($this->System->User->Id);
     206        UserLevelUpdate($User->Id);
    205207      } else $Output .= ShowMessage('Položka nenalezena', MESSAGE_CRITICAL);
    206208    } else
     
    237239  function ShowRedirection($GroupId, $Table, $TextID)
    238240  {
     241    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    239242    // Address and redirecting
    240243    $Output = '<br />'.T('Translate').': <a href="'.$this->System->Link('/TranslationList.php?group='.$GroupId.'&amp;state=1&amp;user=0&entry=').'">'.T('Not translated').'</a> ';
     
    243246    $next = FollowingTran($TextID, $Table, $GroupId);
    244247    $Output .= '<br /><br />';
    245     $DbResult = $this->Database->query('SELECT `Redirecting` FROM `User` WHERE `ID`='.$this->System->User->Id);
     248    $DbResult = $this->Database->query('SELECT `Redirecting` FROM `User` WHERE `ID`='.$User->Id);
    246249    $redirecting = $DbResult->fetch_assoc();
    247250
  • trunk/Modules/Translation/Translation.php

    r888 r893  
    1111class ModuleTranslation extends Module
    1212{
     13  public array $TranslationTree;
     14
    1315  function __construct(System $System)
    1416  {
     
    7981      (
    8082        'Title' => strip_tags($DbRow['Text'].' ('.$DbRow['UserName'].')'),
    81         'Link' => 'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/'),
     83        'Link' => 'http://'.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/'),
    8284        'Description' => $DbRow['Text'],
    8385        'Time' => $DbRow['Date'],
     
    8688    $Output = GenerateRSS(array
    8789    (
    88       'Title' => $this->System->Config['Web']['Title'].' - '.T('Last translations'),
    89       'Link' => 'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/'),
    90       'Description' => $this->System->Config['Web']['Description'],
    91       'WebmasterEmail' => $this->System->Config['Web']['AdminEmail'],
     90      'Title' => Core::Cast($this->System)->Config['Web']['Title'].' - '.T('Last translations'),
     91      'Link' => 'https://'.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/'),
     92      'Description' => Core::Cast($this->System)->Config['Web']['Description'],
     93      'WebmasterEmail' => Core::Cast($this->System)->Config['Web']['AdminEmail'],
    9294      'Items' => $Items,
    9395    ));
     
    113115            $DbRow['Id'].' AS `Group`, "'.addslashes($DbRow['Name']).'" AS `GroupName`, `T`.`Take` FROM `'.
    114116            $DbRow['TablePrefix'].'` AS `T`'.
    115             ' WHERE (`T`.`Complete` = 1) AND (`T`.`Language` != '.$this->System->Config['OriginalLanguage'].') ORDER BY `T`.`ModifyTime` DESC LIMIT '.
     117            ' WHERE (`T`.`Complete` = 1) AND (`T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'].') ORDER BY `T`.`ModifyTime` DESC LIMIT '.
    116118            $Count.') AS `T`';
    117119      }
     
    139141  {
    140142    if (isset($this->TranslationTree)) return $this->TranslationTree;
    141     else {
     143    else
     144    {
    142145      $Result = array();
    143146      $Groups = array();
     
    164167  function ShowTranslatedMenu()
    165168  {
     169    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    166170    $TranslationTree = $this->GetTranslationTree();
    167171
     
    183187        '&nbsp;<a title="Přeložené texty, můžete zde hlasovat, nebo opravovat překlady" href="'.
    184188        $this->System->Link('/TranslationList.php?group='.$Group['Id'].'&amp;state=2&amp;user=0&amp;entry=&amp;text=').'">'.T('Translated').'</a><br />';
    185       if (isset($this->System->User) and $this->System->User->Licence(LICENCE_USER))
     189      if (isset($User) and $User->Licence(LICENCE_USER))
    186190      {
    187191        $Output .= '&nbsp;<a title="'.T('Unfinished translations').'" href="'.$this->System->Link('/TranslationList.php?group='.$Group['Id'].'&amp;state=3').'">'.T('Unfinished').'</a><br />'.
    188192          '&nbsp;<a title="Všechny překlady, které jste přeložil" href="'.
    189193          $this->System->Link('/TranslationList.php?group='.$Group['Id'].'&amp;state=1&amp;user='.
    190           $this->System->User->Id).'&amp;entry=&amp;text=">'.T('Own').'</a><br />';
     194          $User->Id).'&amp;entry=&amp;text=">'.T('Own').'</a><br />';
    191195      }
    192196      $Output .= '&nbsp;<a title="'.T('Compose special filter').'" href="'.
     
    198202    return $Output;
    199203  }
     204
     205  static function Cast(Module $Module): ModuleTranslation
     206  {
     207    if ($Module instanceof ModuleTranslation)
     208    {
     209      return $Module;
     210    }
     211    throw new Exception('Expected '.ModuleTranslation::GetClassName().' type but got '.gettype($Module));
     212  }
    200213}
  • trunk/Modules/Translation/TranslationList.php

    r888 r893  
    1313}
    1414
    15 
    1615class PageTranslationList extends Page
    1716{
    1817  function ShowFilter($GroupId = 0)
    1918  {
    20     $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
     19    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     20    $TranslationTree = ModuleTranslation::Cast($this->System->GetModule('Translation'))->GetTranslationTree();
    2121
    2222    $Filter = array('SQL' => '');
     
    8585    $Output .= '</select></td>';
    8686
    87     if ($this->System->User->Licence(LICENCE_USER))
    88       $Filter['Version'] = GetParameter('version', $this->System->User->PreferredVersion, true, true);
     87    if ($User->Licence(LICENCE_USER))
     88      $Filter['Version'] = GetParameter('version', $User->PreferredVersion, true, true);
    8989    else
    9090      $Filter['Version'] = GetParameter('version', 0, true, true);
     
    176176    {
    177177        $WithoutAlter =       ' AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE '.
    178           '(`Sub`.`Language` <> '.$this->System->Config['OriginalLanguage'].')'.$LanguageFilterSub.
     178          '(`Sub`.`Language` <> '.Core::Cast($this->System)->Config['OriginalLanguage'].')'.$LanguageFilterSub.
    179179          ' AND (`Sub`.`Entry` = `T`.`Entry`) AND (`Sub`.`ID` != `T`.`ID`) AND (`Sub`.`Complete` = 1) AND '.
    180180          '(`Sub`.`VersionStart` = `T`.`VersionStart`) AND (`Sub`.`VersionEnd` = `T`.`VersionEnd`) LIMIT 1 ) ';
     
    184184                           ' < ('.
    185185                                          'SELECT LENGTH(`Sub`.`'.$GroupItem['Column'].'`) - LENGTH( REPLACE( `Sub`.`'.$GroupItem['Column'].'`,  \'$\',  \'\' ) ) FROM `'.$Table.'` AS `Sub` WHERE '.
    186                                           ' `Sub`.`Entry` = `T`.`Entry` AND `Sub`.`Language` = '.$this->System->Config['OriginalLanguage'].' AND '.
     186                                          ' `Sub`.`Entry` = `T`.`Entry` AND `Sub`.`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].' AND '.
    187187                                          '`Sub`.`VersionStart` = `T`.`VersionStart` AND `Sub`.`VersionEnd` = `T`.`VersionEnd` LIMIT 1 '.
    188188                              ')';
     
    192192      } else
    193193      if ($Filter['State'] == CompletionState::NotTranslated) {
    194         $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.$this->System->Config['OriginalLanguage'].') '.
     194        $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].') '.
    195195          'AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE '.
    196           '(`Sub`.`Language` <> '.$this->System->Config['OriginalLanguage'].') '.$LanguageFilterSub.$UserFilter.
     196          '(`Sub`.`Language` <> '.Core::Cast($this->System)->Config['OriginalLanguage'].') '.$LanguageFilterSub.$UserFilter.
    197197          ' AND (`Sub`.`Entry` = `T`.`Entry`) AND (`Sub`.`Complete` = 1) AND '.
    198198          '(`Sub`.`VersionStart` = `T`.`VersionStart`) AND (`Sub`.`VersionEnd` = `T`.`VersionEnd`))';
     
    202202      } else
    203203      if ($Filter['State'] == CompletionState::NotFinished) {
    204         $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Language` != '.$this->System->Config['OriginalLanguage'].
     204        $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'].
    205205      ') AND (`T`.`Complete` = 0)';
    206206      } else
    207207      if ($Filter['State'] == CompletionState::Original) {
    208         $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.$this->System->Config['OriginalLanguage'].')';
     208        $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.Core::Cast($this->System)->Config['OriginalLanguage'].')';
    209209      } else
    210210      if ($Filter['State'] == CompletionState::NotFinishedNotTranslated) {
    211211        $Filter['SQL'] .= $UserFilter.$VersionFilter.$WithoutAlter.
    212       ' AND (`T`.`Language` != '.$this->System->Config['OriginalLanguage'].
     212      ' AND (`T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'].
    213213      ') AND (`T`.`Complete` = 0)';
    214214      } else
    215215      if ($Filter['State'] == CompletionState::Missing1) {
    216         $Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '.$this->System->Config['OriginalLanguage'];
     216        $Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'];
    217217        $Filter['SQL'] .= ' AND ('.implode(' OR ', $ItemsVar).') ';
    218218      } else
    219219      if ($Filter['State'] == CompletionState::Missing2) {
    220         $Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '.$this->System->Config['OriginalLanguage'];
     220        $Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'];
    221221        $Filter['SQL'] .= ' '. $WithoutAlter;
    222222        $Filter['SQL'] .= ' AND ('.implode(' OR ', $ItemsVar).') ';
     
    333333  function ShowMenu()
    334334  {
     335    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    335336    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    336337
     
    351352          '<td>'.T('Texts marked as unfinished').'</td></tr>';
    352353
    353       if ($this->System->User->Licence(LICENCE_USER))
     354      if ($User->Licence(LICENCE_USER))
    354355      {
    355         $Output .= '<tr><td><a title="'.T('Unfinished texts').'" href="?group='.$GroupId.'&amp;state=3&amp;user='.$this->System->User->Id.'">'.T('My unfinished').'</a></td>
     356        $Output .= '<tr><td><a title="'.T('Unfinished texts').'" href="?group='.$GroupId.'&amp;state=3&amp;user='.$User->Id.'">'.T('My unfinished').'</a></td>
    356357        <td>'.T('Unfinished texts of logged-in user').'</td></tr>
    357         <tr><td><a title="'.T('Translated texts of logged-in user').'" href="?group='.$GroupId.'&amp;state=2&amp;user='.$this->System->User->Id.'">'.T('My translated').'</a></td>
     358        <tr><td><a title="'.T('Translated texts of logged-in user').'" href="?group='.$GroupId.'&amp;state=2&amp;user='.$User->Id.'">'.T('My translated').'</a></td>
    358359        <td>'.T('Translated texts of logged-in user').'</td></tr>';
    359360      }
     
    395396  function ShowList()
    396397  {
     398    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    397399    $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Group`');
    398400    $DbRow = $DbResult->fetch_row();
     
    408410      array('Name' => 'LastImport', 'Title' => T('Date of last import')),
    409411      array('Name' => 'LastVersion', 'Title' => T('Version of last import')),
    410    );
    411    if ($this->System->User->Licence(LICENCE_ADMIN))
    412    $TableColumns[] = array('Name' => '', 'Title' => T('Actions'));
    413 
    414    $Order = GetOrderTableHeader($TableColumns, 'Name', 0);
    415    $Output .= $Order['Output'];
    416 
    417    $DbResult = $this->Database->query('SELECT * FROM `Group`'.$Order['SQL'].$PageList['SQLLimit']);
    418    while ($Group = $DbResult->fetch_assoc())
    419    {
    420      $Output .= '<tr><td><a href="'.$this->System->Link('/TranslationList.php?group='.$Group['Id'].'&amp;action=filter').'">'.T($Group['Name']).'</a></td>'.
    421        '<td>'.$Group['SourceType'].'</td><td>';
    422      if ($Group['MangosTable'] != '') $Output .= $Group['MangosTable'].'.sql ';
    423      if ($Group['DBCFileName'] != '') $Output .= $Group['DBCFileName'].'.dbc ';
    424      if ($Group['LuaFileName'] != '') $Output .= $Group['LuaFileName'].'.lua ';
    425      $Output .= '</td>';
    426      if ($this->System->User->Licence(LICENCE_ADMIN))
    427        $Output .= '<td><a title="Změny po posledním importu u vybrané překladové skupiny" href="'.$this->System->Link('/log/?group='.
    428      $Group['Id'].'&amp;type=11').'">'.HumanDate($Group['LastImport']).'</a></td>';
    429        else $Output .= '<td>'.HumanDate($Group['LastImport']).'</td>';
    430      $Output .= '<td><a href="'.$this->System->Link('/client-version/?action=item&amp;id='.
    431        GetVersionWOWId($Group['LastVersion'])).'">'.GetVersionWOW($Group['LastVersion']).'</a></td>';
    432      if ($this->System->User->Licence(LICENCE_ADMIN))
    433        $Output .= '<td><a href="?action=groupdelete&amp;id='.$Group['Id'].'">'.T('Remove').'</a></td>';
    434      $Output .= '</tr>';
     412    );
     413    if ($User->Licence(LICENCE_ADMIN))
     414    $TableColumns[] = array('Name' => '', 'Title' => T('Actions'));
     415
     416    $Order = GetOrderTableHeader($TableColumns, 'Name', 0);
     417    $Output .= $Order['Output'];
     418
     419    $DbResult = $this->Database->query('SELECT * FROM `Group`'.$Order['SQL'].$PageList['SQLLimit']);
     420    while ($Group = $DbResult->fetch_assoc())
     421    {
     422      $Output .= '<tr><td><a href="'.$this->System->Link('/TranslationList.php?group='.$Group['Id'].'&amp;action=filter').'">'.T($Group['Name']).'</a></td>'.
     423        '<td>'.$Group['SourceType'].'</td><td>';
     424      if ($Group['MangosTable'] != '') $Output .= $Group['MangosTable'].'.sql ';
     425      if ($Group['DBCFileName'] != '') $Output .= $Group['DBCFileName'].'.dbc ';
     426      if ($Group['LuaFileName'] != '') $Output .= $Group['LuaFileName'].'.lua ';
     427      $Output .= '</td>';
     428      if ($User->Licence(LICENCE_ADMIN))
     429        $Output .= '<td><a title="Změny po posledním importu u vybrané překladové skupiny" href="'.$this->System->Link('/log/?group='.
     430      $Group['Id'].'&amp;type=11').'">'.HumanDate($Group['LastImport']).'</a></td>';
     431        else $Output .= '<td>'.HumanDate($Group['LastImport']).'</td>';
     432      $Output .= '<td><a href="'.$this->System->Link('/client-version/?action=item&amp;id='.
     433        GetVersionWOWId($Group['LastVersion'])).'">'.GetVersionWOW($Group['LastVersion']).'</a></td>';
     434      if ($User->Licence(LICENCE_ADMIN))
     435        $Output .= '<td><a href="?action=groupdelete&amp;id='.$Group['Id'].'">'.T('Remove').'</a></td>';
     436      $Output .= '</tr>';
    435437    }
    436438    $Output .= '</table>'.
    437439      '<br /><a title="'.T('Changelog of changes after import').'" href="'.$this->System->Link('/log/?type=11').'">'.T('Changelog of text modification during import').'</a><br/>';
    438     if ($this->System->User->Licence(LICENCE_ADMIN)) $Output .= '<a href="?action=groupadd">'.T('Add translation group').'</a>';
     440    if ($User->Licence(LICENCE_ADMIN)) $Output .= '<a href="?action=groupadd">'.T('Add translation group').'</a>';
    439441    return $Output;
    440442  }
     
    442444  function ShowGroupAdd()
    443445  {
    444     if ($this->System->User->Licence(LICENCE_ADMIN))
     446    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     447    if ($User->Licence(LICENCE_ADMIN))
    445448    {
    446449      $Output = '<h3>Vložení nové překladové skupiny</h3>'.
     
    457460  function ShowGroupAddFinish()
    458461  {
    459     if ($this->System->User->Licence(LICENCE_ADMIN))
     462    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     463    if ($User->Licence(LICENCE_ADMIN))
    460464    {
    461465      $TableName = 'Text'.$_POST['TablePrefix'];
     
    505509  function ShowGroupDelete()
    506510  {
    507     if ($this->System->User->Licence(LICENCE_ADMIN))
     511    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     512    if ($User->Licence(LICENCE_ADMIN))
    508513    {
    509514      $DbResult = $this->System->Database->select('Group', '*', '`Id`='.$_GET['id']);
  • trunk/Modules/User/Options.php

    r892 r893  
    55  function UserOptionsFrom()
    66  {
     7    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    78    $Output = '<form action="'.$this->System->Link('/options/?action=save').'" method="post">
    89    <fieldset><legend>'.T('User settings').'</legend>
    910    <table>
    10     <tr><td>'.T('E-mail').':</td><td><input type="text" name="Email" value="'.$this->System->User->Email.'" /></td></tr>
     11    <tr><td>'.T('E-mail').':</td><td><input type="text" name="Email" value="'.$User->Email.'" /></td></tr>
    1112    <tr><td>'.T('Original password').':</td><td><input type="password" name="OldPass" /></td></tr>
    1213    <tr><td>'.T('New password').':</td><td><input type="password" name="NewPass" /></td></tr>
    1314    <tr><td>'.T('New password confirmation').': </td><td><input type="password" name="NewPass2" /></td></tr>
    14     <tr><td>'.T('I will translate normally to').': </td><td>'.WriteLanguages($this->System->User->Language).'</td></tr>
     15    <tr><td>'.T('I will translate normally to').': </td><td>'.WriteLanguages($User->Language).'</td></tr>
    1516    <tr><td>'.T('After save translation redirect to').': </td><td>';
    1617    $Output .= '<select name="redirecting">'.
    1718      '<option value="0">'.T('Nowhere').'</option>'.
    1819      '<option value="1"';
    19     if ($this->System->User->Redirecting == '1') $Output .= ' selected="selected"';
     20    if ($User->Redirecting == '1') $Output .= ' selected="selected"';
    2021    $Output .= '>'.T('To untranslated').'</option>';
    2122    $Output .= '<option value="2"';
    22     if ($this->System->User->Redirecting == '2') $Output .= ' selected="selected"';
     23    if ($User->Redirecting == '2') $Output .= ' selected="selected"';
    2324    $Output .= '>'.T('To next translation').'</option>';
    2425    $Output .= '<option value="3"';
    25     if ($this->System->User->Redirecting == '3') $Output .= ' selected="selected"';
     26    if ($User->Redirecting == '3') $Output .= ' selected="selected"';
    2627    $Output .= '>'.T('To previous translation').'</option>';
    2728    $Output .= '</select>';
    2829
    2930    $Output .= '</td></tr>'.
    30       '<tr><td>'.T('Preferred client version').': </td><td>'.ClientVersionSelection($this->System->User->PreferredVersion).'</td></tr>'.
     31      '<tr><td>'.T('Preferred client version').': </td><td>'.ClientVersionSelection($User->PreferredVersion).'</td></tr>'.
    3132      '<tr><td>'.T('Public profile text').':</td><td>'.
    32       '<textarea name="info" cols="60" rows="10">'.htmlspecialchars($this->System->User->Info).'</textarea></td></tr>';
     33      '<textarea name="info" cols="60" rows="10">'.htmlspecialchars($User->Info).'</textarea></td></tr>';
    3334
    3435    $Output .= '<tr><td>';
     
    4041      $Query = 'SELECT * FROM `UserTag` '.
    4142      //'LEFT JOIN `UserTagType` ON `UserTagType`.`ID` = `UserTag`.`UserTagType` '.
    42       'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($this->System->User->Id * 1);
     43      'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($User->Id * 1);
    4344      $DbResult2 = $this->Database->query($Query);
    4445      if ($DbResult2->num_rows != 0) $checked = true;
     
    6465    {
    6566      $Output .= '<option value="'.$LineTeam['Id'].'"';
    66       if ($LineTeam['Id'] == $this->System->User->Team) $Output .= ' selected="selected"';
     67      if ($LineTeam['Id'] == $User->Team) $Output .= ' selected="selected"';
    6768      $Output .= '>'.htmlspecialchars($LineTeam['Name']).'</option>';
    6869    }
     
    7778  {
    7879    $Output = '';
     80    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    7981    if (array_key_exists('Email', $_POST))
    8082    {
     
    9496        if ($NewPass == $NewPass2)
    9597        {
    96           $DbResult = $this->System->Database->query('SELECT `Pass`, '.$this->System->User->CryptPasswordSQL('"'.$OldPass.'"', '`Salt`').' AS `Hash` FROM `User` WHERE `ID`= '.$this->System->User->Id);
     98          $DbResult = $this->System->Database->query('SELECT `Pass`, '.$User->CryptPasswordSQL('"'.$OldPass.'"', '`Salt`').' AS `Hash` FROM `User` WHERE `ID`= '.$User->Id);
    9799          $DbRow = $DbResult->fetch_assoc();
    98100          if ($DbRow['Hash'] == $DbRow['Pass'])
    99101          {
    100102            // Update password
    101             $Salt = $this->System->User->GetPasswordSalt();
    102             $this->Database->query('UPDATE `User` SET `Pass` = '.$this->System->User->CryptPasswordSQL('"'.$NewPass.'"', '"'.$Salt.'"').', `Salt`="'.$Salt.'" WHERE `ID` = '.$this->System->User->Id);
     103            $Salt = $User->GetPasswordSalt();
     104            $this->Database->query('UPDATE `User` SET `Pass` = '.$User->CryptPasswordSQL('"'.$NewPass.'"', '"'.$Salt.'"').', `Salt`="'.$Salt.'" WHERE `ID` = '.$User->Id);
    103105            $Output .= ShowMessage('Heslo změněno.');
    104106          } else $Output .= ShowMessage('Staré heslo neodpovídá.', MESSAGE_CRITICAL);
     
    113115        {
    114116          $Query = 'SELECT * FROM `UserTag` '.
    115             'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($this->System->User->Id * 1);
     117            'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($User->Id * 1);
    116118          $DbResult2 = $this->Database->query($Query);
    117119          if ($DbResult2->num_rows == 0)
    118120          {
    119121            $Query = 'INSERT INTO `UserTag` (`ID` ,`UserTagType`,`User` ) '.
    120               'VALUES (NULL, '.$UserTag['ID'].' , '.($this->System->User->Id * 1).')';
     122              'VALUES (NULL, '.$UserTag['ID'].' , '.($User->Id * 1).')';
    121123            $DbResult2 = $this->Database->query($Query);
    122124          }
     
    124126        {
    125127          $Query = 'DELETE FROM `UserTag` '.
    126             'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($this->System->User->Id * 1);
     128            'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($User->Id * 1);
    127129          $DbResult2 = $this->Database->query($Query);
    128130        }
    129131      }
    130132
    131       $this->Database->update('User', '`ID` = '.$this->System->User->Id, array('Email' => $Email,
     133      $this->Database->update('User', '`ID` = '.$User->Id, array('Email' => $Email,
    132134        'Language' => $Language, 'Redirecting' => $Redirecting, 'Info' => $Info,
    133135        'PreferredVersion' => $PreferredVersion));
    134       $Output .= ShowMessage('Úprava nastavení proběhla v pořádku, Email: <b>'.$Email.'</b> Uživatel: <b>'.$this->System->User->Name.'</b>');
     136      $Output .= ShowMessage('Úprava nastavení proběhla v pořádku, Email: <b>'.$Email.'</b> Uživatel: <b>'.$User->Name.'</b>');
    135137      $this->System->ModuleManager->Modules['Log']->WriteLog('Úprava nastavení!', LOG_TYPE_USER);
    136       $this->System->User->Load();
     138      $User->Load();
    137139    } else $Output .= ShowMessage('Nezadány údaje.', MESSAGE_CRITICAL);
    138140    return $Output;
     
    143145    $this->Title = T('User settings');
    144146    $Output = '';
    145     if ($this->System->User->Licence(LICENCE_USER))
     147    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     148    if ($User->Licence(LICENCE_USER))
    146149    {
    147150      if (array_key_exists('action', $_GET) and ($_GET['action'] == 'save'))
  • trunk/Modules/User/Profile.php

    r892 r893  
    55  function SendMail()
    66  {
     7    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    78    $Output = '';
    89    if (array_key_exists('text', $_POST))
    9     if ($this->System->User->Licence(LICENCE_ADMIN))
     10    if ($User->Licence(LICENCE_ADMIN))
    1011    {
    1112      $Text = $_POST['text'];
     
    1617        'Text: <strong>'.$Text.'</strong><br />';
    1718
    18       if (@mail($Email, $Subject, $Text, 'From: '.$this->System->Config['Web']['AdminEmail'].
    19         '\nReply-To: '.$this->System->Config['Web']['AdminEmail'].'\nX-Mailer: PHP/'))
     19      if (@mail($Email, $Subject, $Text, 'From: '.Core::Cast($this->System)->Config['Web']['AdminEmail'].
     20        '\nReply-To: '.Core::Cast($this->System)->Config['Web']['AdminEmail'].'\nX-Mailer: PHP/'))
    2021      {
    2122        $Output .= ShowMessage(T('Message was sent'));
     
    2930  {
    3031    $Output = '';
     32    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    3133    $Filter = ' WHERE `Export`.`User` = '.($_GET['user'] * 1);
    3234    $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Export` '.$Filter);
     
    6163      $Action = '<a href="'.$this->System->Link('/export/?Action=View&amp;ExportId='.$Export['Id'].'&amp;Tab=0').'">'.T('Show').'</a> '.
    6264        '<a href="'.$this->System->Link('/export/?Action=View&amp;ExportId='.$Export['Id'].'&amp;Tab=7').'">'.T('Export').'</a>';
    63       if ($Export['User'] == $this->System->User->Id) $Action .= ' <a href="?Action=Delete&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Really remove item?').'\');">'.T('Remove').'</a>';
    64       if ($this->System->User->Id != null) $Action .= ' <a href="'.$this->System->Link('/export/?Action=Clone&amp;ExportId='.$Export['Id']).'" onclick="return confirmAction(\''.T('Really clone item?').'\');">'.T('Clone').'</a>';
     65      if ($Export['User'] == $User->Id) $Action .= ' <a href="?Action=Delete&amp;ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Really remove item?').'\');">'.T('Remove').'</a>';
     66      if ($User->Id != null) $Action .= ' <a href="'.$this->System->Link('/export/?Action=Clone&amp;ExportId='.$Export['Id']).'" onclick="return confirmAction(\''.T('Really clone item?').'\');">'.T('Clone').'</a>';
    6567      $Output .= '<tr><td>'.HumanDate($Export['TimeCreate']).'</td>'.
    6668        '<td>'.htmlspecialchars($Export['Title']).'</td>'.
     
    9597          $DbRow['TablePrefix'].'` AS `T` '.
    9698          'WHERE (`T`.`Complete` = 1) AND '.
    97           '(`T`.`Language` != '.$this->System->Config['OriginalLanguage'].') AND '.
     99          '(`T`.`Language` != '.Core::Cast($this->System)->Config['OriginalLanguage'].') AND '.
    98100          '(`T`.`User` = '.($_GET['user'] * 1).') ORDER BY `T`.`ModifyTime` DESC LIMIT '.
    99101          $Count.') AS `T`';
     
    139141  {
    140142    $Output = '';
     143    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    141144    $Query = 'SELECT `User`.`Name`, `UserTrace`.`LastLogin`, `UserTrace`.`LastIP`, '.
    142145      '`User`.`Email`, `UserTrace`.`UserAgent`, `User`.`PreferredVersion`, '.
     
    190193        '</tr></table>';
    191194      $Output .= '<br />'.$this->ShowLastForum().'<br />';
    192       if ($this->System->User->Licence(LICENCE_MODERATOR))
     195      if ($User->Licence(LICENCE_MODERATOR))
    193196      {
    194197        $Output .= '<fieldset><legend>Moderování</legend>';
     
    239242          '<input type="text" name="email" value="'.$UserLine['Email'].'" /><br/>'.
    240243          'Předmět:'.
    241           '<input type="text" name="subject" value="'.$this->System->Config['Web']['Title'].'" />'.
     244          '<input type="text" name="subject" value="'.Core::Cast($this->System)->Config['Web']['Title'].'" />'.
    242245          '<br />'.
    243246          '<textarea name="text" rows="20" cols="62">'.
    244247          ''."\n".
    245           'S pozdravem '.$this->System->User->Name."\n".
     248          'S pozdravem '.$User->Name."\n".
    246249          '--------------------------------------------------------'."\n".
    247           $this->System->Config['Web']['Title'].' '.$this->System->Config['Web']['Host'].$this->System->Link('/')."\n".
     250          Core::Cast($this->System)->Config['Web']['Title'].' '.Core::Cast($this->System)->Config['Web']['Host'].$this->System->Link('/')."\n".
    248251          '</textarea><br/>'.
    249252          '<input type="submit" value="Odeslat" />'.
  • trunk/Modules/User/Registration.php

    r888 r893  
    8686  function CheckRegistration()
    8787  {
    88     global $Config;
    89 
    9088    $Output = '';
     89    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
    9190    $ShowForm = true;
    9291
     
    114113        if (($UserName != '') and ($Pass != '') and ($Pass2 != ''))
    115114        {
    116           if (!in_array(strtolower($UserName), $Config['ForbiddedUserNames']))
     115          if (!in_array(strtolower($UserName), Core::Cast($this->System)->Config['ForbiddedUserNames']))
    117116          {
    118117            if ($Pass == $Pass2)
     
    121120              $Line = $DbResult->fetch_row();
    122121              if (!$Line)
    123               {
     122              {               
    124123                if ($Team == 0) $Team = 'NULL';
    125                 $this->System->User->Register($UserName, $Pass, $Email, $Language, $Team, $PreferredVersion);
     124                $User->Register($UserName, $Pass, $Email, $Language, $Team, $PreferredVersion);
    126125                $Output .= ShowMessage(T('Registration was successful'));
    127126                $Output .= 'Přečtěte si pozorně <a href="'.$this->System->Link('/info/').'">pokyny pro překladání</a> a můžete pak hned začít překládat.';
    128                 $this->System->User->Login($UserName, $Pass);
     127                $User->Login($UserName, $Pass);
    129128                $this->System->ModuleManager->Modules['Log']->WriteLog('Uživatel se zaregistroval: '.$UserName, LOG_TYPE_USER);
    130129                $ShowForm = false;
     
    136135                if (array_key_exists('Tag'.$UserTag['ID'], $_POST)) {
    137136                  $Query = 'SELECT * FROM `UserTag` '.
    138                   'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($this->System->User->Id * 1);
     137                  'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($User->Id * 1);
    139138                  $DbResult2 = $this->Database->query($Query);
    140139                  if ($DbResult2->num_rows == 0) {
    141140                    $Query = 'INSERT INTO `UserTag` (`ID` ,`UserTagType`,`User` ) '.
    142                     'VALUES (NULL, '.$UserTag['ID'].' , '.($this->System->User->Id * 1).')';
     141                    'VALUES (NULL, '.$UserTag['ID'].' , '.($User->Id * 1).')';
    143142                    $DbResult2 = $this->Database->query($Query);
    144143                  }
    145144                } else {
    146145                  $Query = 'DELETE FROM `UserTag` '.
    147                   'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($this->System->User->Id * 1);
     146                  'WHERE `UserTagType` = '.$UserTag['ID'].' AND `User` = '.($User->Id * 1);
    148147                  $DbResult2 = $this->Database->query($Query);
    149148                }
  • trunk/Modules/User/User.php

    r892 r893  
    11<?php
    22
     3include_once(dirname(__FILE__).'/ModuleUser.php');
    34include_once(dirname(__FILE__).'/UserList.php');
    45include_once(dirname(__FILE__).'/Options.php');
    56include_once(dirname(__FILE__).'/Registration.php');
    67include_once(dirname(__FILE__).'/Profile.php');
    7 
    8 class ModuleUser extends Module
    9 {
    10   function __construct(System $System)
    11   {
    12     parent::__construct($System);
    13     $this->Name = 'User';
    14     $this->Version = '1.1';
    15     $this->Creator = 'Chronos';
    16     $this->License = 'GNU/GPL';
    17     $this->Description = 'User and permission management';
    18     $this->Dependencies = array();
    19   }
    20 
    21   function DoStart(): void
    22   {
    23     $this->System->User = new User($this->System);
    24     $this->System->RegisterPage(['users'], 'PageUserList');
    25     $this->System->RegisterPage(['options'], 'PageUserOptions');
    26     $this->System->RegisterPage(['registration'], 'PageUserRegistration');
    27     $this->System->RegisterPage(['user'], 'PageUserProfile');
    28     $this->System->RegisterPage(['login'], 'PageUserLogin');
    29     Core::Cast($this->System)->RegisterMenuItem(array(
    30       'Title' => T('Translators'),
    31       'Hint' => 'Seznam registrovaných uživatelů',
    32       'Link' => $this->System->Link('/users/'),
    33       'Permission' => LICENCE_ANONYMOUS,
    34       'Icon' => '',
    35     ), 0);
    36     if (array_key_exists('Search', $this->System->ModuleManager->Modules))
    37       $this->System->ModuleManager->Modules['Search']->RegisterSearch('user',
    38       T('Translators'), array('Name'), '`User`', $this->System->Link('/users/?search='));
    39       Core::Cast($this->System)->RegisterPageBarItem('Top', 'User', array($this, 'TopBarCallback'));
    40       Core::Cast($this->System)->RegisterPageBarItem('Left', 'User', array($this, 'ShowOnlineList'));
    41   }
    42 
    43   function ShowOnlineList()
    44   {
    45     $Output = T('Online translators').':<br />';
    46     $DbResult = $this->System->Database->query('SELECT * FROM ('.
    47       'SELECT `User`.`Name`, `User`.`ID` FROM `UserOnline` '.
    48       'JOIN `User` ON `User`.`ID` = `UserOnline`.`User` '.
    49       'WHERE (`ActivityTime` >= NOW() - 300) '.
    50       'ORDER BY `ActivityTime` DESC ) AS `T` GROUP BY `Name`');
    51     while ($DbUser = $DbResult->fetch_assoc())
    52     {
    53       $Name = '<a href="'.$this->System->Link('/user/?user='.$DbUser['ID']).'">'.$DbUser['Name'].'</a>';
    54       $Output .= $Name.'<br />';
    55     }
    56     return $Output;
    57   }
    58 
    59   function TopBarCallback()
    60   {
    61     $Output = '';
    62     if ($this->System->User->Licence(LICENCE_USER))
    63     {
    64       //$DbResult =$this->Database->query('SELECT `Id`, `Name` FROM `Team` WHERE `Id`='.$this->System->User->Team);
    65       //$Team = $DbResult->fetch_assoc();
    66       //$Output .= ''<span class="MenuItem">Moje překlady: <a href="">Dokončené</a> <a href="">Rozpracované</a> <a href="">Exporty</a> Tým: <a href="">'.$Team['name'].'</a></span>';
    67       $Output .= $this->System->User->Name.' <a href="'.$this->System->Link('/?action=logout').'">'.T('Logout').'</a>'.
    68           ' <a href="'.$this->System->Link('/user/?user='.$this->System->User->Id).'">'.T('My page').'</a>'.
    69           ' <a href="'.$this->System->Link('/options/').'">'.T('Options').'</a>'.
    70           ' <a title="Vámi přeložené texty" href="'.$this->System->Link('/TranslationList.php?user='.
    71           $this->System->User->Id.'&amp;group=0&amp;state=2&amp;text=&amp;entry=').'">'.T('Translated').'</a>'.
    72           ' <a title="Vaše rozpracované text" href="'.$this->System->Link('/TranslationList.php?user='.
    73           $this->System->User->Id.'&amp;group=0&amp;state=3&amp;text=&amp;entry=').'">'.T('Unfinished').'</a>'.
    74           ' <a title="Nikým nepřeložené texty" href="'.
    75           $this->System->Link('/TranslationList.php?user=0&amp;group=0&amp;state=1&amp;text=&amp;entry=').'">'.T('Untranslated').'</a>';
    76     } else
    77     {
    78       $Output .= '<a href="'.$this->System->Link('/login/').'">'.T('Login').'</a>&nbsp;'.
    79         '<a href="'.$this->System->Link('/registration/').'">'.T('Registration').'</a>';
    80     }
    81     return $Output;
    82   }
    83 }
    848
    859class PageUserLogin extends Page
     
    11741{
    11842  var $Id;
    119   var $Name;
     43  public string $Name;
    12044  var $Team;
    12145  var $Role;
     
    12650  var $OnlineStateTimeout;
    12751  var $PreferredVersion = 0;
     52  public string $PreferredVersionGame;
     53  public string $Email;
     54  public string $Info;
    12855
    12956  function __construct(System $System)
  • trunk/Modules/Wiki/Wiki.php

    r888 r893  
    11<?php
    22
    3 class ModuleWiki extends Module
    4 {
    5   function __construct(System $System)
    6   {
    7     parent::__construct($System);
    8     $this->Name = 'Wiki';
    9     $this->Version = '1.0';
    10     $this->Creator = 'Chronos';
    11     $this->License = 'GNU/GPLv3';
    12     $this->Description = 'Mediawiki style page management';
    13     $this->Dependencies = array();
    14   }
    15 
    16   function DoStart(): void
    17   {
    18     $this->LoadPages();
    19   }
    20 
    21   function LoadPages()
    22   {
    23     $DbResult = $this->Database->select('WikiPage', '*', '`VisibleInMenu`=1');
    24     while ($DbRow = $DbResult->fetch_assoc())
    25     {
    26       $this->System->RegisterPage($DbRow['NormalizedName'], 'PageWiki');
    27       Core::Cast($this->System)->RegisterMenuItem(array(
    28           'Title' => $DbRow['Name'],
    29           'Hint' => '',
    30           'Link' => $this->System->Link('/'.$DbRow['NormalizedName'].'/'),
    31           'Permission' => LICENCE_ANONYMOUS,
    32           'Icon' => '',
    33       ), 6);
    34     }
    35   }
    36 }
     3include_once(dirname(__FILE__).'/ModuleWiki.php');
    374
    385class PageWiki extends Page
     
    5219  function ShowContent()
    5320  {
    54     $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
     21    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     22    $PageName = Core::Cast($this->System)->PathItems[count(Core::Cast($this->System)->PathItems) - 1];
    5523    $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"');
    5624    if ($DbResult->num_rows > 0)
     
    6533          $Output = '<h3>Archív stránky '.$DbRow['Name'].' ('.HumanDateTime($DbRow2['Time']).')</h3>';
    6634          $Output .= $DbRow2['Content'];
    67           if ($this->System->User->Licence(LICENCE_MODERATOR))
     35          if ($User->Licence(LICENCE_MODERATOR))
    6836            $Output .= '<div><a href="?Action=Edit">Upravit nejnovější</a> <a href="?Action=History">Historie</a></div>';
    6937        } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
     
    7644          $Output = '<h3>'.$DbRow['Name'].'</h3>';
    7745          $Output .= $DbRow2['Content'];
    78           if ($this->System->User->Licence(LICENCE_MODERATOR))
     46          if ($User->Licence(LICENCE_MODERATOR))
    7947            $Output .= '<hr><div><a href="?Action=Edit">Upravit</a> <a href="?Action=History">Historie</a></div>';
    8048        } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
     
    8654  function EditContent()
    8755  {
    88     if ($this->System->User->Licence(LICENCE_MODERATOR))
     56    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     57    if ($User->Licence(LICENCE_MODERATOR))
    8958    {
    90     $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
     59    $PageName = Core::Cast($this->System)->PathItems[count(Core::Cast($this->System)->PathItems) - 1];
    9160    $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"');
    9261    if ($DbResult->num_rows > 0)
     
    11180  function SaveContent()
    11281  {
    113     if ($this->System->User->Licence(LICENCE_MODERATOR))
     82    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     83    if ($User->Licence(LICENCE_MODERATOR))
    11484    {
    115     $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
     85    $PageName = Core::Cast($this->System)->PathItems[count(Core::Cast($this->System)->PathItems) - 1];
    11686    $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"');
    11787    if ($DbResult->num_rows > 0)
     
    12191      {
    12292        $DbResult2 = $this->Database->insert('WikiPageContent', array('Content' => stripslashes($_POST['content']),
    123           'User' => $this->System->User->Id, 'Time' => 'NOW()', 'Page' => $DbRow['Id']));
     93          'User' => $User->Id, 'Time' => 'NOW()', 'Page' => $DbRow['Id']));
    12494        $Output = ShowMessage('Wiki stránka uložena', MESSAGE_INFORMATION);
    12595      } else $Output = ShowMessage('Nezadána platná data', MESSAGE_CRITICAL);
     
    132102  function ShowHistory()
    133103  {
    134     if ($this->System->User->Licence(LICENCE_MODERATOR))
     104    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     105    if ($User->Licence(LICENCE_MODERATOR))
    135106    {
    136       $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
     107      $PageName = Core::Cast($this->System)->PathItems[count(Core::Cast($this->System)->PathItems) - 1];
    137108      $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"');
    138109      if ($DbResult->num_rows > 0)
  • trunk/includes/Global.php

    r891 r893  
    118118}
    119119
    120 function GetTranslateGoogle($text, $withouttitle = false)
    121 {
    122   global $System;
    123 
     120function GetTranslateGoogle($System, $text, $withouttitle = false)
     121{
    124122//  $text = 'Balthule\'s letter is dire. This Cult of the Dark Strand is a thorn in my side that must be removed. I have been dealing with some of the Dark Strand scum northeast of here at Ordil\'Aran. One of their number possesses a soul gem that I believe holds the secret to the cult\'s power.$b$bBring it to me, and I will be able to decipher the secrets held within.';
    125123 // $text = htmlspecialchars($text);
     
    130128//  $text = str_replace('&','',$text);
    131129//  $text = str_replace(' ','%20',$text);
    132   $DbResult = $System->Database->select('Language', '`Code`', '`Id`='.$System->User->Language);
     130  $User = ModuleUser::Cast($System->GetModule('User'))->User;
     131  $DbResult = $System->Database->select('Language', '`Code`', '`Id`='.$User->Language);
    133132  $DbRow = $DbResult->fetch_assoc();
    134133  $lang = $DbRow['Code'];
     
    413412{
    414413  global $System;
    415   $TranslationTree = $System->ModuleManager->Modules['Translation']->GetTranslationTree();
     414  $TranslationTree = ModuleTranslation::Cast($System->ModuleManager->GetModule('Translation'))->GetTranslationTree();
    416415
    417416  if (array_key_exists('group', $_GET)) $GroupId = $_GET['group'] * 1;
     
    512511  global $System;
    513512
    514   $TranslationTree = $System->ModuleManager->Modules['Translation']->GetTranslationTree();
     513  $TranslationTree = ModuleTranslation::Cast($System->ModuleManager->GetModule('Translation'))->GetTranslationTree();
    515514
    516515  foreach ($TranslationTree as $TableID => $Value)
  • trunk/includes/PageEdit.php

    r888 r893  
    33class PageEdit extends Page
    44{
    5   var $Table;
    6   var $Definition;
    7   var $ItemActions;
     5  public string $Table;
     6  public string $TableSQL;
     7  public array $Definition;
     8  public array $ItemActions;
     9  public bool $AllowEdit;
    810
    911  function __construct($System)
     
    109111  {
    110112    $Output = '';
    111     if ($this->System->User->Licence(LICENCE_USER))
     113    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     114    if ($User->Licence(LICENCE_USER))
    112115    {
    113116      if (array_key_exists('finish', $_GET))
     
    140143  function DeleteItem()
    141144  {
    142     if ($this->System->User->Licence(LICENCE_USER))
     145    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     146    if ($User->Licence(LICENCE_USER))
    143147    {
    144       $this->Database->query('DELETE FROM `'.$this->Table.'` WHERE (`User`='.$this->System->User->Id.') AND (`Id`='.($_GET['id'] * 1).')');
     148      $this->Database->query('DELETE FROM `'.$this->Table.'` WHERE (`User`='.$User->Id.') AND (`Id`='.($_GET['id'] * 1).')');
    145149      $Output = ShowMessage(T('Record removed'));
    146150    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
Note: See TracChangeset for help on using the changeset viewer.