| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | include_once(dirname(__FILE__).'/../../Base/View.php');
|
|---|
| 4 |
|
|---|
| 5 | class UpdateView extends View
|
|---|
| 6 | {
|
|---|
| 7 | function ItemList()
|
|---|
| 8 | {
|
|---|
| 9 | $ServerId = $_GET['Id'];
|
|---|
| 10 | if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER)
|
|---|
| 11 | {
|
|---|
| 12 | $Server = new Server($this->System, $_GET['Id']);
|
|---|
| 13 | if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR))
|
|---|
| 14 | {
|
|---|
| 15 | $Server = new Server($this->System, $ServerId);
|
|---|
| 16 | $Output = '<h4>Seznam dostupných aktulizací</h4>';
|
|---|
| 17 | $Output .= 'Před provedením aktualizace bude server zastaven a provedena záloha databáze.';
|
|---|
| 18 | $Table = new Table('EmulatorList', $this->System);
|
|---|
| 19 | $Table->Definition['Table'] = substr($Table->Definition['Table'], 0, -1).' AND `Emulator`.`Revision` > '.$Server->Server['Database']['Emulator']['Revision'].' ORDER BY `Revision`)';
|
|---|
| 20 | $Table->Definition['Items']['Id'] = array('Type' => 'Hidden', 'Caption' => '', 'Default' => '');
|
|---|
| 21 | $Table->LoadValuesFromDatabase($this->Database);
|
|---|
| 22 | $Table->Definition['Items']['Actions'] = array('Type' => 'String', 'Caption' => '', 'Default' => '');
|
|---|
| 23 | foreach($Table->Values as $Index => $Item)
|
|---|
| 24 | {
|
|---|
| 25 | $Table->Values[$Index]['Actions'] = '<a href="?Action=EmulatorShow&Id='.$Item['Id'].'">Podrobnosti</a>';
|
|---|
| 26 | if($Server->Server['Lock'] == 0) $Table->Values[$Index]['Actions'] .= ' <a href="?Action=Update&Server='.$ServerId.'&Update='.$Item['Id'].'">Aktualizovat</a>';
|
|---|
| 27 | unset($Table->Values[$Index]['Id']);
|
|---|
| 28 | }
|
|---|
| 29 | $Output .= $Table->Show();
|
|---|
| 30 | } else $this->SystemMessage('Dostupné aktualizace', 'Nemáte oprávnění');
|
|---|
| 31 | } else $Output = USER_BAD_ROLE;
|
|---|
| 32 | return($Output);
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | function Update()
|
|---|
| 36 | {
|
|---|
| 37 | if(!array_key_exists('Server', $_GET)) $Output = $this->SystemMessage('Aktualizace serveru', 'Nebylo zadáno Id serveru');
|
|---|
| 38 | else if(!array_key_exists('Update', $_GET)) $Output = $this->SystemMessage('Aktualizace serveru', 'Nebylo zadáno Id aktualizace');
|
|---|
| 39 | else if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER)
|
|---|
| 40 | {
|
|---|
| 41 | $Server = new Server($this->System, $_GET['Server']);
|
|---|
| 42 | if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR))
|
|---|
| 43 | {
|
|---|
| 44 | $Output = $this->SystemMessage('Aktualizace serveru', $Server->Update($_GET['Update']));
|
|---|
| 45 | $Output = $this->ShowTaskList();
|
|---|
| 46 | } else $this->SystemMessage('Aktualizace serveru', 'Nemáte oprávnění');
|
|---|
| 47 | } else $Output = USER_BAD_ROLE;
|
|---|
| 48 | return($Output);
|
|---|
| 49 | }
|
|---|
| 50 | }
|
|---|