Changeset 893 for trunk/Modules/Export/Page.php
- Timestamp:
- Mar 6, 2023, 1:48:45 AM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Export/Page.php
r888 r893 16 16 function ExportList() 17 17 { 18 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 18 19 $Output = '<a href="?Action=ViewList">'.T('All').'</a>'; 19 if ($ this->System->User->Licence(LICENCE_USER))20 if ($User->Licence(LICENCE_USER)) 20 21 { 21 22 $Output .= ' <a href="?Action=ViewList&Filter=Others">'.T('Others').'</a>'. … … 23 24 } 24 25 25 if ($ this->System->User->Licence(LICENCE_USER))26 if ($User->Licence(LICENCE_USER)) 26 27 $Output .= '<br/><div style="text-align: center;"><a href="?Action=Create">'.T('Create new export').'</a></div><br/>'; 27 28 … … 29 30 if (array_key_exists('Filter', $_GET)) 30 31 { 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; 33 34 } 34 35 … … 66 67 $Action = '<a href="?Action=View&ExportId='.$Export['Id'].'&Tab=0">'.T('View').'</a> '. 67 68 '<a href="?Action=View&ExportId='.$Export['Id'].'&Tab=7">'.T('Make export').'</a>'; 68 if ($Export['User'] == $ this->System->User->Id) $Action .= ' <a href="?Action=Delete&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&ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy clone item?').'\');">'.T('Clone').'</a>';69 if ($Export['User'] == $User->Id) $Action .= ' <a href="?Action=Delete&ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy delete item?').'\');">'.T('Delete').'</a>'; 70 if ($User->Id != null) $Action .= ' <a href="?Action=Clone&ExportId='.$Export['Id'].'" onclick="return confirmAction(\''.T('Realy clone item?').'\');">'.T('Clone').'</a>'; 70 71 $Output .= '<tr><td>'.HumanDate($Export['TimeCreate']).'</td>'. 71 72 '<td><a href="'.$this->System->Link('/user/?user='.$Export['User']).'">'.$Export['UserName'].'</a></td>'. … … 84 85 function ExportCreate() 85 86 { 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); 89 91 $DbRow = $DbResult->fetch_row(); 90 if ($DbRow[0] < $this->System->Config['MaxExportPerUser'])92 if ($DbRow[0] < Core::Cast($this->System)->Config['MaxExportPerUser']) 91 93 { 92 94 $Output = '<form action="?Action=CreateFinish" method="post">'. … … 96 98 '<tr><td colspan="2"><input type="submit" value="'.T('Create').'" /></td></tr>'. 97 99 '</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); 99 101 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 100 102 return $Output; … … 103 105 function ExportCreateFinish() 104 106 { 105 if ($this->System->User->Licence(LICENCE_USER)) 107 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 108 if ($User->Licence(LICENCE_USER)) 106 109 { 107 110 if (array_key_exists('Title', $_POST) and array_key_exists('Description', $_POST)) 108 111 { 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); 110 113 $DbRow = $DbResult->fetch_row(); 111 if ($DbRow[0] < $this->System->Config['MaxExportPerUser'])114 if ($DbRow[0] < Core::Cast($this->System)->Config['MaxExportPerUser']) 112 115 { 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'].'")'); 114 117 $ExportId = $this->System->Database->insert_id; 115 118 $Output = ShowMessage(T('New export created.<br />Direct link to export').': <a href="?Action=View&ExportId='.$ExportId.'">'.T('here').'</a>'); … … 117 120 $_GET['Filter'] = 'my'; 118 121 $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); 120 123 } else $Output = ShowMessage(T('Missing data in form.'), MESSAGE_CRITICAL); 121 124 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); … … 125 128 function ExportDelete() 126 129 { 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.')'); 130 134 if ($DbResult->num_rows > 0) 131 135 { … … 157 161 function ExportViewTranslators() 158 162 { 163 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 159 164 $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree(); 160 165 … … 163 168 $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']); 164 169 $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; 166 171 else $Editable = false; 167 172 … … 273 278 function ExportViewGeneral() 274 279 { 280 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 275 281 $DisabledInput = array(false => ' disabled="disabled"', true => ''); 276 282 $DisabledTextArea = array(false => ' readonly="yes"', true => ''); … … 278 284 $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']); 279 285 $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; 281 287 else $Editable = false; 282 288 … … 300 306 $Output .= '<form action="?Action=View&Tab=0&ExportId='.$Export['Id'].'" method="post">'. 301 307 '<table>'; 302 if ($ this->System->User->Id != null)308 if ($User->Id != null) 303 309 { 304 310 $Output .= '<input type="hidden" name="Operation" value="Save"/>'. … … 306 312 if ($Editable) $Output .= ' <input type="submit" value="'.T('Save').'" '.$DisabledInput[$Editable].'/>'; 307 313 $Output .= ' <a href="?Action=Clone&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)) 309 315 $Output .= CheckBox('Featured', $Export['Featured'], '', 'CheckBox', !$Editable). ' '.T('Recommended').' '; 310 316 $Output .= '</td></tr>'; … … 319 325 function ExportViewLanguages() 320 326 { 327 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 321 328 $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree(); 322 329 … … 325 332 $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']); 326 333 $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; 328 335 else $Editable = false; 329 336 … … 410 417 function ExportViewGroups() 411 418 { 419 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 412 420 $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree(); 413 421 … … 416 424 $DbRows = $this->System->Database->query('SELECT * FROM Export WHERE Id='.$_GET['ExportId']); 417 425 $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; 419 427 else $Editable = false; 420 428 … … 538 546 function ExportViewOutputFormat() 539 547 { 548 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 540 549 $Output = ''; 541 550 $DisabledInput = array(false => ' disabled="disabled"', true => ''); … … 546 555 { 547 556 $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; 549 558 else $Editable = false; 550 559 … … 583 592 function ExportViewVersion() 584 593 { 594 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 585 595 $Output = ''; 586 596 $DisabledInput = array(false => ' disabled="disabled"', true => ''); 587 597 $DbRows = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']); 588 598 $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; 590 600 else $Editable = false; 591 601 … … 697 707 '(SELECT COUNT(DISTINCT(`Entry`)) FROM ('. 698 708 ' 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'].')'. 700 710 ') AS `C2`) AS `Total`, "'.$DbRow['Name'].'" AS `Name`'; 701 711 } … … 777 787 function ExportClone() 778 788 { 779 if ($this->System->User->Licence(LICENCE_USER)) 789 $User = ModuleUser::Cast($this->System->GetModule('User'))->User; 790 if ($User->Licence(LICENCE_USER)) 780 791 { 781 792 if (array_key_exists('ExportId', $_GET) and is_numeric($_GET['ExportId'])) 782 793 { 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); 784 795 $DbRow = $DbResult->fetch_row(); 785 if ($DbRow[0] < $this->System->Config['MaxExportPerUser'])796 if ($DbRow[0] < Core::Cast($this->System)->Config['MaxExportPerUser']) 786 797 { 787 798 $DbResult = $this->System->Database->query('SELECT * FROM `Export` WHERE `Id`='.$_GET['ExportId']); … … 791 802 unset($DbRow['Id']); 792 803 $DbRow['UsedCount'] = '0'; 793 $DbRow['User'] = $ this->System->User->Id;804 $DbRow['User'] = $User->Id; 794 805 $DbRow['TimeCreate'] = 'NOW()'; 795 806 $DbRow['Title'] .= ' - '.T('clone'); … … 807 818 } else $Output = ShowMessage('Zdrojový export nenalezen', MESSAGE_CRITICAL); 808 819 } 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); 810 821 } else $Output = ShowMessage(T('Export not found.'), MESSAGE_CRITICAL); 811 822 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
Note:
See TracChangeset
for help on using the changeset viewer.