Ignore:
Timestamp:
Mar 6, 2023, 1:48:45 AM (22 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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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    }
Note: See TracChangeset for help on using the changeset viewer.