Changeset 893 for trunk/Modules/Dictionary/Dictionary.php
- Timestamp:
- Mar 6, 2023, 1:48:45 AM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Dictionary/Dictionary.php
r888 r893 28 28 $this->System->ModuleManager->Modules['Search']->RegisterSearch('dictionary', 29 29 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`', 31 31 $this->System->Link('/dictionary/?search=')); 32 32 } … … 88 88 function DictionaryInsert() 89 89 { 90 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 90 91 $Output = ''; 91 if ($ this->System->User->Licence(LICENCE_USER))92 if ($User->Licence(LICENCE_USER)) 92 93 { 93 94 $Output .= '<form action="?action=save" method="post">'. … … 108 109 function DictionarySave() 109 110 { 110 if ($this->System->User->Licence(LICENCE_USER)) 111 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 112 if ($User->Licence(LICENCE_USER)) 111 113 { 112 114 if (array_key_exists('Original', $_POST) and array_key_exists('Translated', $_POST) and array_key_exists('Description', $_POST)) … … 114 116 // Check if original text exists and determine entry id 115 117 $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']); 117 119 if ($DbResult->num_rows > 0) 118 120 { … … 125 127 $Entry = $DbRow[0] + 1; 126 128 $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'].');'); 128 130 } 129 131 130 132 $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); 132 134 if ($DbResult->num_rows > 0) 133 135 { … … 138 140 $this->Database->query('INSERT INTO `Dictionary` ( `Text` , `Entry` , `Description` , '. 139 141 '`User`, `Language` ) VALUES ("'.$_POST['Translated'].'", "'.$Entry.'", "'. 140 $_POST['Description'].'", '.$ this->System->User->Id.', '.$_POST['Language'].')');142 $_POST['Description'].'", '.$User->Id.', '.$_POST['Language'].')'); 141 143 $Output = ShowMessage('Záznam byl uložen!'); 142 144 } else $Output = ShowMessage(T('You have to fill all column of form.'), MESSAGE_CRITICAL); … … 147 149 function DictionaryRemove() 148 150 { 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).')'); 152 155 $Output = ShowMessage(T('Record removed')); 153 156 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); … … 157 160 function DictionaryModify() 158 161 { 159 if ($this->System->User->Licence(LICENCE_USER)) 162 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 163 if ($User->Licence(LICENCE_USER)) 160 164 { 161 165 $DbResult = $this->Database->query('SELECT * FROM `Dictionary` WHERE `Id`='.($_GET['id'] * 1)); … … 164 168 $DbRow = $DbResult->fetch_assoc(); 165 169 $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'].')'); 167 171 $DbRow2 = $DbResult->fetch_assoc(); 168 172 $Output = '<form action="?action=save" method="post">'. … … 216 220 function DictionaryShow() 217 221 { 222 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 218 223 global $LanguageList; 219 224 … … 227 232 <input type="text" value="'.$Search.'" name="search" size="30" /> 228 233 <input type="submit" value="'.T('Search').'" />'; 229 if ($ this->System->User->Licence(LICENCE_USER))234 if ($User->Licence(LICENCE_USER)) 230 235 $Output .= ' <a href="?action=insert">'.T('Add word').'</a>'; 231 236 … … 258 263 '`T1`.`Entry`, `T2`.`Text` AS `Original`, `T1`.`Text` AS `Translated`, `T1`.`Description` '. 259 264 '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'].') '. 261 266 'JOIN `Language` ON `Language`.`Id` = `T1`.`Language` '. 262 267 'JOIN `User` ON `User`.`ID` = `T1`.`User` '. … … 279 284 $TableColumns[] = array('Name' => 'Description', 'Title' => T('Description')); 280 285 $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')); 282 287 $Order = GetOrderTableHeader($TableColumns, 'Original'); 283 288 $Output .= '<table class="BaseTable">'.$Order['Output']; … … 294 299 '<td><a href="'.$this->System->Link('/user/?user='.$Line['UserId']).'">'. 295 300 $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) 299 304 $Output .= '<td><a href="?action=remove&id='.$Line['Id']. 300 305 '" onclick="return confirmAction(\''.T('Do you really want to delete item?').'\');">'.T('Delete').'</a>'. … … 315 320 global $LanguageList; 316 321 322 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 317 323 $this->Title = T('Dictionary'); 318 324 … … 321 327 if (!isset($_SESSION['language'])) 322 328 { 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; 326 332 } else $_SESSION['language'] = ''; 327 333 }
Note:
See TracChangeset
for help on using the changeset viewer.