[580] | 1 | <?php
|
---|
| 2 |
|
---|
[589] | 3 | include_once(dirname(__FILE__).'/Update.php');
|
---|
| 4 | include_once(dirname(__FILE__).'/DefaultConfig.php');
|
---|
| 5 | include_once(dirname(__FILE__).'/FullInstall.php');
|
---|
| 6 | include_once(dirname(__FILE__).'/Updates.php');
|
---|
| 7 |
|
---|
[580] | 8 | class PageSetup extends Page
|
---|
| 9 | {
|
---|
[592] | 10 | var $UpdateManager;
|
---|
| 11 | var $ConfigDefinition;
|
---|
| 12 | var $Config;
|
---|
| 13 | var $DatabaseRevision;
|
---|
| 14 | var $Revision;
|
---|
| 15 | var $Updates;
|
---|
| 16 | var $ConfigDir;
|
---|
| 17 |
|
---|
[588] | 18 | function __construct($System)
|
---|
| 19 | {
|
---|
| 20 | parent::__construct($System);
|
---|
| 21 | $this->FullTitle = 'Instalace aplikace';
|
---|
| 22 | $this->ShortTitle = 'Instalátor';
|
---|
| 23 | //$this->ParentClass = 'PagePortal';
|
---|
[592] | 24 | $this->ConfigDir = dirname(__FILE__).'/../..';
|
---|
[588] | 25 | }
|
---|
| 26 |
|
---|
[592] | 27 | function LoginPanel()
|
---|
| 28 | {
|
---|
| 29 | $Output = '<h3>Přihlášení k instalaci</h3>'.
|
---|
[593] | 30 | '<form action="?" method="post">'.
|
---|
[592] | 31 | '<table>'.
|
---|
| 32 | '<tr><td>Systémové heslo:</td><td> <input type="password" name="SystemPassword" value=""/></td></tr>'.
|
---|
| 33 | '</table>'.
|
---|
| 34 | '<input type="submit" name="login" value="Přihlásit"/>'.
|
---|
| 35 | '</form>';
|
---|
| 36 | return($Output);
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | function ControlPanel()
|
---|
| 40 | {
|
---|
[593] | 41 | global $YesNo;
|
---|
| 42 | $Output = '';
|
---|
[592] | 43 |
|
---|
| 44 | $Output .= 'Je připojení k databázi: '.$YesNo[$this->UpdateManager->Database->Connected()].'<br/>';
|
---|
| 45 | if($this->UpdateManager->Database->Connected())
|
---|
| 46 | {
|
---|
| 47 | $Output .= 'Je instalováno: '.$YesNo[$this->UpdateManager->IsInstalled()].'<br/>';
|
---|
| 48 | if($this->UpdateManager->IsInstalled())
|
---|
| 49 | $Output .= 'Je aktuální: '.$YesNo[$this->UpdateManager->IsUpToDate()].'<br/>'.
|
---|
| 50 | 'Verze databáze: '.$this->UpdateManager->GetDbVersion().'<br/>';
|
---|
| 51 | $Output .= 'Verze databáze kódu: '.$this->UpdateManager->Revision.'<br/>';
|
---|
| 52 | if($this->UpdateManager->IsInstalled())
|
---|
| 53 | {
|
---|
| 54 | if(!$this->UpdateManager->IsUpToDate())
|
---|
[593] | 55 | $Output .= '<a href="?action=upgrade">Povýšit</a> ';
|
---|
| 56 | $Output .= '<a href="?action=insert_sample_data">Vložit vzorová data</a> ';
|
---|
[613] | 57 | $Output .= '<a href="?action=reload_modules">Obnovit seznam modulů</a> ';
|
---|
[593] | 58 | $Output .= '<a href="?action=uninstall">Odinstalovat</a> ';
|
---|
| 59 | $Output .= '<a href="?action=modules">Správa modulů</a> ';
|
---|
| 60 | } else $Output .= '<a href="?action=install">Instalovat</a> ';
|
---|
[592] | 61 | }
|
---|
[593] | 62 | $Output .= '<a href="?action=configure">Nastavit</a> ';
|
---|
| 63 | $Output .= '<a href="?action=logout">Odhlásit</a> ';
|
---|
| 64 | $Output .= '';
|
---|
[592] | 65 | return($Output);
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | function Show()
|
---|
| 69 | {
|
---|
[589] | 70 | global $ConfigDefinition, $DatabaseRevision, $Config, $Updates;
|
---|
| 71 |
|
---|
[595] | 72 | $this->UpdateManager = $this->System->Setup->UpdateManager;
|
---|
[589] | 73 | $DefaultConfig = new DefaultConfig();
|
---|
[592] | 74 | $this->ConfigDefinition = $DefaultConfig->Get();
|
---|
| 75 | $this->DatabaseRevision = $DatabaseRevision;
|
---|
[595] | 76 | $this->Config = &$Config;
|
---|
[592] | 77 |
|
---|
| 78 | $Output = '';
|
---|
| 79 | if(isset($this->Config))
|
---|
| 80 | {
|
---|
| 81 | if(!array_key_exists('SystemPassword', $_SESSION)) $_SESSION['SystemPassword'] = '';
|
---|
| 82 | if(array_key_exists('login', $_POST)) $_SESSION['SystemPassword'] = $_POST['SystemPassword'];
|
---|
| 83 | if(sha1($_SESSION['SystemPassword']) != $this->Config['SystemPassword'])
|
---|
| 84 | {
|
---|
| 85 | $Output .= $this->LoginPanel();
|
---|
| 86 | } else
|
---|
[595] | 87 | {
|
---|
[593] | 88 | if(array_key_exists('action', $_GET)) $Action = $_GET['action'];
|
---|
| 89 | else $Action = '';
|
---|
| 90 | if($Action == 'logout')
|
---|
[592] | 91 | {
|
---|
| 92 | $_SESSION['SystemPassword'] = '';
|
---|
| 93 | $Output .= 'Odhlášen';
|
---|
| 94 | $Output .= $this->LoginPanel();
|
---|
| 95 | } else
|
---|
[593] | 96 | if($Action == 'upgrade')
|
---|
| 97 | {
|
---|
| 98 | $Output .= '<h3>Povýšení</h3>';
|
---|
[619] | 99 | try {
|
---|
| 100 | $Output .= $this->System->Setup->Upgrade();
|
---|
| 101 | } catch (Exception $E) {
|
---|
| 102 | $Output .= $this->SystemMessage('Chyba aktualizace', 'Došlo k chybě v SQL dotazu při aktualizaci: <br/>'.$E->getMessage());
|
---|
| 103 | }
|
---|
| 104 | $Output .= $this->ControlPanel();
|
---|
[593] | 105 | } else
|
---|
| 106 | if($Action == 'install')
|
---|
| 107 | {
|
---|
| 108 | $Output .= '<h3>Instalace</h3>';
|
---|
| 109 | $this->System->Setup->Install();
|
---|
[613] | 110 | $this->System->ModuleManager->LoadModules();
|
---|
| 111 | $this->System->ModuleManager->SaveState();
|
---|
| 112 | //$Output .= $this->System->Setup->Upgrade();
|
---|
[593] | 113 | $Output .= $this->ControlPanel();
|
---|
| 114 | } else
|
---|
| 115 | if($Action == 'uninstall')
|
---|
| 116 | {
|
---|
| 117 | $Output .= '<h3>Odinstalace</h3>';
|
---|
| 118 | $this->System->Setup->Uninstall();
|
---|
| 119 | $Output .= $this->ControlPanel();
|
---|
| 120 | } else
|
---|
[613] | 121 | if($Action == 'reload_modules')
|
---|
| 122 | {
|
---|
| 123 | $Output .= '<h3>Znovunačtení seznamu modulů</h3>';
|
---|
| 124 | $this->System->ModuleManager->LoadModules();
|
---|
| 125 | $this->System->ModuleManager->SaveState();
|
---|
| 126 | $Output .= $this->ControlPanel();
|
---|
| 127 | } else
|
---|
[593] | 128 | if($Action == 'insert_sample_data')
|
---|
| 129 | {
|
---|
| 130 | $Output .= '<h3>Vložení vzorových dat</h3>';
|
---|
| 131 | $this->System->Setup->InsertSampleData();
|
---|
| 132 | $Output .= $this->ControlPanel();
|
---|
| 133 | } else
|
---|
| 134 | if($Action == 'modules')
|
---|
| 135 | {
|
---|
| 136 | $Output .= $this->ShowModules();
|
---|
| 137 | } else
|
---|
| 138 | if($Action == 'configure_save')
|
---|
| 139 | {
|
---|
| 140 | $Output .= $this->ConfigSave($this->Config);
|
---|
| 141 | $Output .= $this->ControlPanel();
|
---|
| 142 | } else
|
---|
| 143 | if($Action == 'configure')
|
---|
| 144 | {
|
---|
| 145 | $Output .= $this->PrepareConfig($this->Config);
|
---|
| 146 | } else
|
---|
| 147 | {
|
---|
| 148 | $Output .= $this->ControlPanel();
|
---|
| 149 | }
|
---|
[592] | 150 | }
|
---|
| 151 | } else
|
---|
| 152 | {
|
---|
| 153 | if(array_key_exists('configure_save', $_POST))
|
---|
| 154 | {
|
---|
| 155 | $Output .= $this->ConfigSave(array());
|
---|
| 156 | $Output .= 'Pokračujte k přihlášení <a href="">zde</a>';
|
---|
| 157 | } else {
|
---|
| 158 | $Output .= $this->PrepareConfig(array());
|
---|
| 159 | }
|
---|
| 160 | }
|
---|
| 161 | return($Output);
|
---|
| 162 | }
|
---|
| 163 |
|
---|
[593] | 164 | function ShowModules()
|
---|
[592] | 165 | {
|
---|
| 166 | $Output = '';
|
---|
[593] | 167 | if(array_key_exists('op', $_GET)) $Operation = $_GET['op'];
|
---|
| 168 | else $Operation = '';
|
---|
| 169 | if($Operation == 'install')
|
---|
[592] | 170 | {
|
---|
[593] | 171 | $this->System->ModuleManager->Modules[$_GET['name']]->Install();
|
---|
| 172 | $this->System->ModuleManager->SaveState();
|
---|
| 173 | $Output .= 'Modul '.$_GET['name'].' instalován<br/>';
|
---|
| 174 | } else
|
---|
| 175 | if($Operation == 'uninstall')
|
---|
| 176 | {
|
---|
| 177 | $this->System->ModuleManager->Modules[$_GET['name']]->Uninstall();
|
---|
| 178 | $this->System->ModuleManager->SaveState();
|
---|
| 179 | $Output .= 'Modul '.$_GET['name'].' odinstalován<br/>';
|
---|
| 180 | } else
|
---|
| 181 | if($Operation == 'enable')
|
---|
| 182 | {
|
---|
| 183 | $this->System->ModuleManager->Modules[$_GET['name']]->Enable();
|
---|
| 184 | $this->System->ModuleManager->SaveState();
|
---|
| 185 | $Output .= 'Modul '.$_GET['name'].' povolen<br/>';
|
---|
| 186 | } else
|
---|
| 187 | if($Operation == 'disable')
|
---|
| 188 | {
|
---|
| 189 | $this->System->ModuleManager->Modules[$_GET['name']]->Disable();
|
---|
| 190 | $this->System->ModuleManager->SaveState();
|
---|
| 191 | $Output .= 'Modul '.$_GET['name'].' zakázán<br/>';
|
---|
| 192 | } else
|
---|
| 193 | if($Operation == 'upgrade')
|
---|
| 194 | {
|
---|
| 195 | $this->System->ModuleManager->Modules[$_GET['name']]->Upgrade();
|
---|
| 196 | $this->System->ModuleManager->SaveState();
|
---|
| 197 | $Output .= 'Modul '.$_GET['name'].' povýšen<br/>';
|
---|
[592] | 198 | }
|
---|
[593] | 199 | $Output .= '<h3>Správa modulů</h3>';
|
---|
| 200 | $Output .= $this->ShowList();
|
---|
[592] | 201 | return($Output);
|
---|
| 202 | }
|
---|
| 203 |
|
---|
[593] | 204 | function ShowList()
|
---|
[592] | 205 | {
|
---|
[593] | 206 | global $YesNo;
|
---|
| 207 |
|
---|
[592] | 208 | $Output = '';
|
---|
[593] | 209 | $PageList = GetPageList(count($this->System->ModuleManager->Modules));
|
---|
[592] | 210 |
|
---|
| 211 | $Output .= $PageList['Output'];
|
---|
| 212 | $Output .= '<table class="WideTable" style="font-size: small;">';
|
---|
| 213 |
|
---|
| 214 | $TableColumns = array(
|
---|
| 215 | array('Name' => 'Name', 'Title' => 'Jméno'),
|
---|
| 216 | array('Name' => 'Creator', 'Title' => 'Tvůrce'),
|
---|
| 217 | array('Name' => 'Version', 'Title' => 'Verze'),
|
---|
| 218 | array('Name' => 'License', 'Title' => 'Licence'),
|
---|
| 219 | array('Name' => 'Installed', 'Title' => 'Instalováno'),
|
---|
[593] | 220 | array('Name' => 'Enabled', 'Title' => 'Povoleno'),
|
---|
[592] | 221 | array('Name' => 'Description', 'Title' => 'Popis'),
|
---|
| 222 | array('Name' => 'Dependencies', 'Title' => 'Závislosti'),
|
---|
| 223 | array('Name' => '', 'Title' => 'Akce'),
|
---|
| 224 | );
|
---|
| 225 | $Order = GetOrderTableHeader($TableColumns, 'Name', 0);
|
---|
| 226 | $Output .= $Order['Output'];
|
---|
| 227 |
|
---|
[593] | 228 | foreach($this->System->ModuleManager->Modules as $Module)
|
---|
[592] | 229 | {
|
---|
| 230 | if(($Module->Dependencies) > 0) $Dependencies = implode(',', $Module->Dependencies);
|
---|
[593] | 231 | else $Dependencies = ' ';
|
---|
| 232 | $Actions = '';
|
---|
| 233 | if($Module->Installed == true)
|
---|
| 234 | {
|
---|
| 235 | $Actions .= ' <a href="?action=modules&op=uninstall&name='.$Module->Name.'">Odinstalovat</a>';
|
---|
| 236 | if($Module->Enabled == true) $Actions .= ' <a href="?action=modules&op=disable&name='.$Module->Name.'">Zakázat</a>';
|
---|
| 237 | else $Actions .= ' <a href="?action=modules&op=enable&name='.$Module->Name.'">Povolit</a>';
|
---|
| 238 | if($Module->InstalledVersion != $Module->Version) $Actions .= ' <a href="?action=modules&op=upgrade&name='.$Module->Name.'">Povýšit</a>';
|
---|
| 239 | } else $Actions .= ' <a href="?action=modules&op=install&name='.$Module->Name.'">Instalovat</a>';
|
---|
| 240 |
|
---|
[592] | 241 | $Output .= '<tr><td>'.$Module->Name.'</td>'.
|
---|
| 242 | '<td>'.$Module->Creator.'</td>'.
|
---|
| 243 | '<td>'.$Module->Version.'</td>'.
|
---|
| 244 | '<td>'.$Module->License.'</td>'.
|
---|
[593] | 245 | '<td>'.$YesNo[$Module->Installed].'</td>'.
|
---|
| 246 | '<td>'.$YesNo[$Module->Enabled].'</td>'.
|
---|
[592] | 247 | '<td>'.$Module->Description.'</td>'.
|
---|
| 248 | '<td>'.$Dependencies.'</td>'.
|
---|
| 249 | '<td>'.$Actions.'</td></tr>';
|
---|
| 250 | }
|
---|
| 251 | $Output .= '</table>';
|
---|
| 252 | $Output .= $PageList['Output'];
|
---|
| 253 | //$Output .= '<p><a href="?A=SaveToDb">Uložit do databáze</a></p>';
|
---|
| 254 | return($Output);
|
---|
| 255 | }
|
---|
| 256 |
|
---|
| 257 | function PrepareConfig($Config)
|
---|
| 258 | {
|
---|
| 259 | $Output = '';
|
---|
| 260 | if(!file_exists($this->ConfigDir.'/config.php') and !is_writable($this->ConfigDir))
|
---|
| 261 | $Output .= 'Varování: Konfigurační soubor nebude možné zapsat, protože složka není povolená pro zápis!';
|
---|
| 262 | if(file_exists($this->ConfigDir.'/config.php') and !is_writable($this->ConfigDir.'/config.php'))
|
---|
| 263 | $Output .= 'Varování: Konfigurační soubor nebude možné zapsat, protože soubor config.php není povolen pro zápis!';
|
---|
| 264 | $Output .= '<h3>Nastavení systému</h3>'.
|
---|
[593] | 265 | '<form action="?action=configure_save" method="post">'.
|
---|
[592] | 266 | '<table>';
|
---|
| 267 | foreach($this->ConfigDefinition as $Def)
|
---|
| 268 | {
|
---|
| 269 | $PathParts = explode('/', $Def['Name']);
|
---|
| 270 | $TempConfig = &$Config;
|
---|
| 271 | foreach($PathParts as $Part)
|
---|
| 272 | if(array_key_exists($Part, $TempConfig))
|
---|
| 273 | {
|
---|
| 274 | $TempConfig = &$TempConfig[$Part];
|
---|
| 275 | }
|
---|
| 276 | if(!is_array($TempConfig)) $Value = $TempConfig;
|
---|
| 277 | else $Value = $Def['Default'];
|
---|
| 278 | $Output .= '<tr><td>'.$Def['Title'].'</td><td>';
|
---|
| 279 | if($Def['Type'] == 'String') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';
|
---|
| 280 | if($Def['Type'] == 'Password') $Output .= '<input type="password" name="'.$Def['Name'].'"/>';
|
---|
| 281 | if($Def['Type'] == 'PasswordEncoded') $Output .= '<input type="password" name="'.$Def['Name'].'"/>';
|
---|
| 282 | if($Def['Type'] == 'Integer') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';
|
---|
| 283 | if($Def['Type'] == 'Float') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';
|
---|
| 284 | if($Def['Type'] == 'Boolean') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';
|
---|
| 285 | }
|
---|
| 286 | $Output .= '</td></tr>'.
|
---|
| 287 | '<tr><td colspan="2"><input type="submit" name="configure_save" value="Nastavit"/></td></tr>'.
|
---|
| 288 | '</table>'.
|
---|
| 289 | '</form>';
|
---|
| 290 | return($Output);
|
---|
| 291 | }
|
---|
| 292 |
|
---|
| 293 | function ConfigSave($DefaultConfig)
|
---|
| 294 | {
|
---|
| 295 | $Config = $DefaultConfig;
|
---|
| 296 | foreach($this->ConfigDefinition as $Def)
|
---|
| 297 | {
|
---|
| 298 | $Value = null;
|
---|
| 299 | if($Def['Type'] == 'String') if(array_key_exists($Def['Name'], $_POST))
|
---|
| 300 | $Value = $_POST[$Def['Name']];
|
---|
| 301 | if($Def['Type'] == 'Password') if(array_key_exists($Def['Name'], $_POST) and ($_POST[$Def['Name']] != ''))
|
---|
| 302 | $Value = $_POST[$Def['Name']];
|
---|
| 303 | if($Def['Type'] == 'PasswordEncoded') if(array_key_exists($Def['Name'], $_POST) and ($_POST[$Def['Name']] != ''))
|
---|
| 304 | $Value = sha1($_POST[$Def['Name']]);
|
---|
| 305 | if($Def['Type'] == 'Integer') if(array_key_exists($Def['Name'], $_POST))
|
---|
| 306 | $Value = $_POST[$Def['Name']];
|
---|
| 307 | if($Def['Type'] == 'Float') if(array_key_exists($Def['Name'], $_POST))
|
---|
| 308 | $Value = $_POST[$Def['Name']];
|
---|
| 309 | if($Def['Type'] == 'Boolean') if(array_key_exists($Def['Name'], $_POST))
|
---|
| 310 | $Value = $_POST[$Def['Name']];
|
---|
| 311 | if(!is_null($Value))
|
---|
| 312 | {
|
---|
| 313 | $PathParts = explode('/', $Def['Name']);
|
---|
| 314 | $TempConfig = &$Config;
|
---|
| 315 | foreach($PathParts as $Part)
|
---|
| 316 | {
|
---|
| 317 | $TempConfig = &$TempConfig[$Part];
|
---|
| 318 | }
|
---|
| 319 | if(!is_array($TempConfig)) $TempConfig = $Value;
|
---|
| 320 | else $Value = $Def['Default'];
|
---|
| 321 | }
|
---|
| 322 | }
|
---|
| 323 | $ConfigText = $this->CreateConfig($Config);
|
---|
| 324 | file_put_contents($this->ConfigDir.'/config.php', $ConfigText);
|
---|
| 325 | $Output .= 'Konfigurace nastavena<br/>';
|
---|
| 326 | return($Output);
|
---|
| 327 | }
|
---|
| 328 |
|
---|
| 329 | function CreateConfig($Config)
|
---|
| 330 | {
|
---|
| 331 | $Output = "<?php\n\n".
|
---|
| 332 | "\$IsDeveloper = in_array(\$_SERVER['REMOTE_ADDR'], array('127.0.0.1'));\n\n";
|
---|
| 333 |
|
---|
| 334 | foreach($this->ConfigDefinition as $Def)
|
---|
| 335 | {
|
---|
| 336 | $PathParts = explode('/', $Def['Name']);
|
---|
| 337 | $Output .= "\$Config";
|
---|
| 338 | foreach($PathParts as $Part)
|
---|
| 339 | $Output .= "['".$Part."']";
|
---|
| 340 | $TempConfig = &$Config;
|
---|
| 341 | foreach($PathParts as $Part)
|
---|
| 342 | if(array_key_exists($Part, $TempConfig))
|
---|
| 343 | {
|
---|
| 344 | $TempConfig = &$TempConfig[$Part];
|
---|
| 345 | }
|
---|
| 346 | if(!is_array($TempConfig)) $Value = $TempConfig;
|
---|
| 347 | else $Value = $Def['Default'];
|
---|
| 348 | $Output .= " = '".$Value."';\n";
|
---|
| 349 | }
|
---|
| 350 | $Output .= "\n\n";
|
---|
| 351 | return($Output);
|
---|
| 352 | }
|
---|
[580] | 353 | }
|
---|
| 354 |
|
---|
| 355 | class PageSetupRedirect extends Page
|
---|
| 356 | {
|
---|
| 357 | function Show()
|
---|
| 358 | {
|
---|
[589] | 359 | $Output = '';
|
---|
| 360 | if(!$this->Database->Connected()) $Output .= 'Nelze se připojit k databázi.<br>';
|
---|
| 361 | else {
|
---|
[592] | 362 | if(!$this->System->Setup->UpdateManager->IsInstalled())
|
---|
[590] | 363 | $Output .= 'Systém vyžaduje instalaci databáze.<br>';
|
---|
| 364 | else
|
---|
[592] | 365 | if(!$this->System->Setup->UpdateManager->IsUpToDate())
|
---|
[590] | 366 | $Output .= 'Systém vyžaduje aktualizaci databáze.<br>';
|
---|
[589] | 367 | }
|
---|
| 368 | $Output .= 'Pokračujte <a href="'.$this->System->Link('/setup/').'">zde</a>';
|
---|
| 369 | return($Output);
|
---|
[580] | 370 | }
|
---|
| 371 | }
|
---|
| 372 |
|
---|
[592] | 373 | class Setup extends Model
|
---|
[589] | 374 | {
|
---|
[592] | 375 | var $UpdateManager;
|
---|
[589] | 376 |
|
---|
[592] | 377 | function Start()
|
---|
[586] | 378 | {
|
---|
[589] | 379 | global $DatabaseRevision;
|
---|
| 380 |
|
---|
[580] | 381 | $this->System->RegisterPage('', 'PageSetupRedirect');
|
---|
[589] | 382 | $this->System->RegisterPage('setup', 'PageSetup');
|
---|
| 383 |
|
---|
| 384 | // Check database persistence structure
|
---|
| 385 | $this->UpdateManager = new UpdateManager();
|
---|
[595] | 386 | $this->UpdateManager->Database = $this->Database;
|
---|
[589] | 387 | $this->UpdateManager->Revision = $DatabaseRevision;
|
---|
[595] | 388 | $Updates = new Updates();
|
---|
| 389 | $this->UpdateManager->Trace = $Updates->Get();
|
---|
| 390 | $this->UpdateManager->InstallMethod = 'FullInstall';
|
---|
[589] | 391 | }
|
---|
| 392 |
|
---|
[592] | 393 | function Stop()
|
---|
[590] | 394 | {
|
---|
| 395 | unset($this->UpdateManager);
|
---|
| 396 | $this->System->UnregisterPage('');
|
---|
| 397 | $this->System->UnregisterPage('setup');
|
---|
| 398 | }
|
---|
| 399 |
|
---|
[589] | 400 | function CheckState()
|
---|
| 401 | {
|
---|
| 402 | return($this->Database->Connected() and $this->UpdateManager->IsInstalled() and
|
---|
[590] | 403 | $this->UpdateManager->IsUpToDate());
|
---|
[593] | 404 | }
|
---|
| 405 |
|
---|
| 406 | function Install()
|
---|
| 407 | {
|
---|
[613] | 408 | global $DatabaseRevision;
|
---|
| 409 |
|
---|
[593] | 410 | $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemVersion` (
|
---|
| 411 | `Id` int(11) NOT NULL AUTO_INCREMENT,
|
---|
| 412 | `Revision` int(11) NOT NULL,
|
---|
| 413 | PRIMARY KEY (`Id`)
|
---|
| 414 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
|
---|
| 415 | $this->Database->query("INSERT INTO `SystemVersion` (`Id`, `Revision`) VALUES
|
---|
[613] | 416 | (1, '.$DatabaseRevision.');");
|
---|
[594] | 417 | $this->Database->query("CREATE TABLE IF NOT EXISTS `Module` (
|
---|
| 418 | `Id` int(11) NOT NULL AUTO_INCREMENT,
|
---|
| 419 | `Name` varchar(255) NOT NULL,
|
---|
| 420 | `Title` varchar(255) NOT NULL,
|
---|
| 421 | PRIMARY KEY (`Id`)
|
---|
| 422 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
|
---|
[593] | 423 | }
|
---|
| 424 |
|
---|
| 425 | function Uninstall()
|
---|
| 426 | {
|
---|
[594] | 427 | $this->System->ModuleManager->UninstallAll();
|
---|
| 428 | $this->Database->query('DROP TABLE `Module`');
|
---|
[593] | 429 | $this->Database->query('DROP TABLE `SystemVersion`');
|
---|
| 430 | }
|
---|
| 431 |
|
---|
| 432 | function IsInstalled()
|
---|
| 433 | {
|
---|
| 434 | $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->VersionTable.'"');
|
---|
| 435 | return($DbResult->num_rows > 0);
|
---|
| 436 | }
|
---|
| 437 |
|
---|
| 438 | function Upgrade()
|
---|
| 439 | {
|
---|
[594] | 440 | $Output = $this->UpdateManager->Upgrade();
|
---|
[593] | 441 | return($Output);
|
---|
[589] | 442 | }
|
---|
[580] | 443 | }
|
---|