Ignore:
Timestamp:
Sep 11, 2013, 10:37:54 PM (11 years ago)
Author:
chronos
Message:
  • Modified: Moved some code from global to system file. System class is now serving as main application class. Now old files which still use ShowPage function need system initialization with $InitSystem = true; before global.php inclusion.
  • Modified: Get rid of some global reference to $System, $Config and $User variables.
  • Modified: Search result functionality moved to application module from action.php file.
File:
1 edited

Legend:

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

    r569 r577  
    7676function DictionaryInsert()
    7777{
    78   global $User;
    79  
    8078  $Output = '';
    81   if($User->Licence(LICENCE_USER))
     79  if($this->System->User->Licence(LICENCE_USER))
    8280  {
    8381    $Output .= '<form action="?action=save" method="post">'.
     
    9896function DictionarySave()
    9997{
    100   global $User, $Config;
    101  
    102   if($User->Licence(LICENCE_USER))
     98  if($this->System->User->Licence(LICENCE_USER))
    10399  {
    104100    if(array_key_exists('Original', $_POST) and array_key_exists('Translated', $_POST) and array_key_exists('Description', $_POST))
     
    106102      // Check if original text exists and determine entry id
    107103      $DbResult = $this->Database->query('SELECT * FROM `Dictionary` WHERE '.
    108         '`Text` = "'.$_POST['Original'].'" AND `Language`= '.$Config['OriginalLanguage']);
     104        '`Text` = "'.$_POST['Original'].'" AND `Language`= '.$this->System->Config['OriginalLanguage']);
    109105      if($DbResult->num_rows > 0)
    110106      {
     
    117113        $Entry = $DbRow[0] + 1;
    118114        $this->Database->query('INSERT INTO `Dictionary` ( `Text` , `Entry` , `Description` , '.
    119           '`User`, `Language` ) VALUES ("'.$_POST['Original'].'", "'.$Entry.'", "", NULL, '.$Config['OriginalLanguage'].');');
     115          '`User`, `Language` ) VALUES ("'.$_POST['Original'].'", "'.$Entry.'", "", NULL, '.$this->System->Config['OriginalLanguage'].');');
    120116      }
    121117 
    122118      $DbResult = $this->Database->query('SELECT `Id` FROM `Dictionary` WHERE '.
    123         '`Entry` = '.$Entry.' AND `Language`='.$_POST['Language'].' AND `User`='.$User->Id);
     119        '`Entry` = '.$Entry.' AND `Language`='.$_POST['Language'].' AND `User`='.$this->System->User->Id);
    124120      if($DbResult->num_rows > 0)
    125121      {
     
    129125      } else
    130126        $this->Database->query('INSERT INTO `Dictionary` ( `Text` , `Entry` , `Description` , '.
    131           '`User`, `Language` ) VALUES ("'.$_POST['Translated'].'", "'.$Entry.'", "'.$_POST['Description'].'", '.$User->Id.', '.$_POST['Language'].')');
     127          '`User`, `Language` ) VALUES ("'.$_POST['Translated'].'", "'.$Entry.'", "'.
     128                $_POST['Description'].'", '.$this->System->User->Id.', '.$_POST['Language'].')');
    132129      $Output = ShowMessage('Záznam byl uložen!');
    133130    } else $Output = ShowMessage('Nebyly zaslány všechny položky formuláře.', MESSAGE_CRITICAL);
     
    138135function DictionaryRemove()
    139136{
    140   global $User;
    141  
    142   if($User->Licence(LICENCE_USER))
    143   {
    144     $this->Database->query('DELETE FROM `Dictionary` WHERE (`User`='.$User->Id.') AND (`Id`='.($_GET['id'] * 1).')');
     137  if($this->System->User->Licence(LICENCE_USER))
     138  {
     139    $this->Database->query('DELETE FROM `Dictionary` WHERE (`User`='.$this->System->User->Id.') AND (`Id`='.($_GET['id'] * 1).')');
    145140    $Output = ShowMessage('Záznam odstraněn.');
    146141  } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL);
     
    150145function DictionaryModify()
    151146{
    152   global $User, $Config;
    153  
    154   if($User->Licence(LICENCE_USER))
     147  if($this->System->User->Licence(LICENCE_USER))
    155148  {
    156149    $DbResult = $this->Database->query('SELECT * FROM `Dictionary` WHERE `Id`='.($_GET['id'] * 1));
     
    159152      $DbRow = $DbResult->fetch_assoc();
    160153      $DbResult = $this->Database->query('SELECT * FROM `Dictionary` WHERE (`User` IS NULL) '.
    161         'AND (`Entry`='.$DbRow['Entry'].') AND (`Language`= '.$Config['OriginalLanguage'].')');
     154        'AND (`Entry`='.$DbRow['Entry'].') AND (`Language`= '.$this->System->Config['OriginalLanguage'].')');
    162155      $DbRow2 = $DbResult->fetch_assoc();
    163156      $Output = '<form action="?action=save" method="post">'.
     
    180173function DictionaryGroup()
    181174{
    182   global $User, $TranslationTree;
     175  global $TranslationTree;
    183176 
    184177  $Output = '';
     
    211204function DictionaryShow()
    212205{
    213   global $User, $LanguageList, $Config;
     206  global $LanguageList;
    214207 
    215208  $Output = '<form action="?" method="get" style="margin: 0px; padding: 0px;">'.
     
    222215    <input type="text" value="'.$Search.'" name="search" size="30" />
    223216    <input type="submit" value="Vyhledat" />';
    224   if($User->Licence(LICENCE_USER)) $Output .= ' <a href="?action=insert">Vložit slovo</a>';
     217  if($this->System->User->Licence(LICENCE_USER))
     218        $Output .= ' <a href="?action=insert">Vložit slovo</a>';
    225219           
    226220  $Output .= '</td></tr>'.
     
    252246      '`T1`.`Entry`, `T2`.`Text` AS `Original`, `T1`.`Text` AS `Translated`, `T1`.`Description` '.   
    253247      'FROM `Dictionary` AS `T1` JOIN `Dictionary` AS `T2` '.
    254       'ON (`T2`.`Entry` = `T1`.`Entry`) AND (`T2`.`Language` = '.$Config['OriginalLanguage'].') '.
     248      'ON (`T2`.`Entry` = `T1`.`Entry`) AND (`T2`.`Language` = '.$this->System->Config['OriginalLanguage'].') '.
    255249      'JOIN `Language` ON `Language`.`Id` = `T1`.`Language` '.
    256250      'JOIN `User` ON `User`.`ID` = `T1`.`User` '.
     
    273267  $TableColumns[] = array('Name' => 'Description', 'Title' => 'Popis');
    274268  $TableColumns[] = array('Name' => 'UserName', 'Title' => 'Překladatel');   
    275   if($User->Licence(LICENCE_USER)) $TableColumns[] = array('Name' => '', 'Title' => 'Akce');
     269  if($this->System->User->Licence(LICENCE_USER)) $TableColumns[] = array('Name' => '', 'Title' => 'Akce');
    276270  $Order = GetOrderTableHeader($TableColumns, 'Original');
    277271  $Output .= '<table class="BaseTable">'.$Order['Output'];
     
    287281    $Output .= '<td>'.$Line['Description'].'</td>'.
    288282    '<td><a href="user.php?user='.$Line['UserId'].'">'.$Line['UserName'].'</a></td>';
    289     if($User->Licence(LICENCE_USER))
    290     {
    291       if($Line['UserId'] == $User->Id)
     283    if($this->System->User->Licence(LICENCE_USER))
     284    {
     285      if($Line['UserId'] == $this->System->User->Id)
    292286        $Output .= '<td><a href="?action=remove&amp;id='.$Line['Id'].'" onclick="return confirmAction(\'Opravdu smazat položku?\');">Smazat</a>'.
    293287        ' <a href="?action=modify&amp;id='.$Line['Id'].'">Upravit</a></td>';
     
    305299function Show()
    306300{
    307         global $LanguageList, $User;
     301        global $LanguageList;
    308302       
    309303$LanguageList = GetLanguageList();
     
    311305if(!isset($_SESSION['language']))
    312306{
    313         if($User->Licence(LICENCE_USER))
     307        if($this->System->User->Licence(LICENCE_USER))
    314308        {
    315                 $_SESSION['language'] = $User->Language;
     309                $_SESSION['language'] = $this->System->User->Language;
    316310  } else $_SESSION['language'] = '';
    317311}
Note: See TracChangeset for help on using the changeset viewer.