Changeset 873 for trunk/Modules/System/System.php
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/System/System.php
r825 r873 39 39 40 40 $DbResult = $this->Database->query($Query); 41 while ($Module = $DbResult->fetch_assoc())42 { 43 if ($Module['Dependencies'] != '') $Dependencies = $Module['Dependencies'];41 while ($Module = $DbResult->fetch_assoc()) 42 { 43 if ($Module['Dependencies'] != '') $Dependencies = $Module['Dependencies']; 44 44 else $Dependencies = ' '; 45 if ($Module['Installed'] == 1) $Installed = 'Ano';45 if ($Module['Installed'] == 1) $Installed = 'Ano'; 46 46 else $Installed = 'Ne'; 47 if ($Module['Installed'] == 1) $Actions = '<a href="?A=Uninstall&Id='.$Module['Id'].'">Odinstalovat</a>';47 if ($Module['Installed'] == 1) $Actions = '<a href="?A=Uninstall&Id='.$Module['Id'].'">Odinstalovat</a>'; 48 48 else $Actions = '<a href="?A=Install&Id='.$Module['Id'].'">Instalovat</a>'; 49 49 $Output .= '<tr><td>'.$Module['Name'].'</td>'. … … 59 59 $Output .= $PageList['Output']; 60 60 $Output .= '<p><a href="?A=SaveToDb">Uložit do databáze</a></p>'; 61 return ($Output);61 return ($Output); 62 62 } 63 63 … … 65 65 { 66 66 $Output = ''; 67 if (array_key_exists('A', $_GET))68 { 69 if ($_GET['A'] == 'SaveToDb')67 if (array_key_exists('A', $_GET)) 68 { 69 if ($_GET['A'] == 'SaveToDb') 70 70 { 71 71 $Output .= $this->System->ModuleManager->Modules['System']->SaveToDatabase(); 72 72 $Output .= $this->SystemMessage('Načtení modulů', 'Seznam modulů v databázi zaktualizován'); 73 73 } else 74 if ($_GET['A'] == 'Install')74 if ($_GET['A'] == 'Install') 75 75 { 76 76 $this->System->ModuleManager->LoadModules(false); 77 77 $ModuleName = $this->System->ModuleManager->SearchModuleById($_GET['Id']); 78 if ($ModuleName != '')78 if ($ModuleName != '') 79 79 { 80 80 $this->System->Modules[$ModuleName]->Install(); … … 83 83 84 84 } else 85 if ($_GET['A'] == 'Uninstall')85 if ($_GET['A'] == 'Uninstall') 86 86 { 87 87 $ModuleName = $this->System->ModuleManager->SearchModuleById($_GET['Id']); 88 if ($ModuleName != '')88 if ($ModuleName != '') 89 89 { 90 90 $this->System->ModuleManager->Modules[$ModuleName]->UnInstall(); … … 94 94 } 95 95 $Output .= $this->ShowList(); 96 return ($Output);96 return ($Output); 97 97 } 98 98 } … … 408 408 function IsInstalled() 409 409 { 410 if ($this->InstalledChecked == false)410 if ($this->InstalledChecked == false) 411 411 { 412 412 $DbResult = $this->Database->query('SELECT table_name FROM information_schema.tables 413 413 WHERE table_schema = "'.$this->Database->Database.'" AND table_name = "SystemVersion";'); 414 if ($DbResult->num_rows > 0) $this->Installed = true;414 if ($DbResult->num_rows > 0) $this->Installed = true; 415 415 else $this->Installed = false; 416 416 $this->InstalledChecked = true; 417 417 } 418 return ($this->Installed);418 return ($this->Installed); 419 419 } 420 420 421 421 function ModuleChange($Module) 422 422 { 423 //if ($this->IsInstalled())424 { 425 426 if ($Module->IsInstalled()) $Installed = 1;423 //if ($this->IsInstalled()) 424 { 425 426 if ($Module->IsInstalled()) $Installed = 1; 427 427 else $Installed = 0; 428 428 $this->Database->query('UPDATE `Module` SET `Installed`=1 WHERE `Name`="'.$Module->Name.'"'); … … 436 436 $Query = 'SELECT `Id`, `Name`,`Installed` FROM `Module`'; 437 437 $DbResult = $this->Database->query($Query); 438 while ($Module = $DbResult->fetch_array())438 while ($Module = $DbResult->fetch_array()) 439 439 { 440 440 //echo($Module['Name'].','); … … 453 453 $Modules = array(); 454 454 $DbResult = $this->Database->query('SELECT * FROM `Module`'); 455 while ($DbRow = $DbResult->fetch_assoc())455 while ($DbRow = $DbResult->fetch_assoc()) 456 456 { 457 457 $Modules[$DbRow['Name']] = $DbRow; 458 if ($this->System->ModuleManager->ModulePresent($DbRow['Name']))458 if ($this->System->ModuleManager->ModulePresent($DbRow['Name'])) 459 459 $this->System->ModuleManager->Modules[$DbRow['Name']]->Id = $DbRow['Id']; 460 460 } 461 461 462 462 // Add missing 463 foreach ($this->System->ModuleManager->Modules as $Module)464 { 465 if (!array_key_exists($Module->Name, $Modules))463 foreach ($this->System->ModuleManager->Modules as $Module) 464 { 465 if (!array_key_exists($Module->Name, $Modules)) 466 466 { 467 467 $this->Database->insert('Module', array('Name' => $Module->Name, … … 480 480 481 481 // Remove exceeding 482 foreach ($Modules as $Module)483 if (!$this->System->ModuleManager->ModulePresent($Module['Name']))482 foreach ($Modules as $Module) 483 if (!$this->System->ModuleManager->ModulePresent($Module['Name'])) 484 484 { 485 485 $Output .= 'Removing module '.$Module['Name'].' from list</br/>'; … … 487 487 $this->Database->query('DELETE FROM `ModuleLink` WHERE `LinkedModule` = '.$Module['Id']); 488 488 $DbResult = $this->Database->query('SELECT Id FROM `PermissionOperation` WHERE `Module` = '.$Module['Id']); 489 while ($DbRow = $DbResult->fetch_assoc())489 while ($DbRow = $DbResult->fetch_assoc()) 490 490 { 491 491 $this->Database->query('DELETE FROM `PermissionGroupAssignment` WHERE `AssignedOperation` = '.$DbRow['Id']); … … 495 495 $this->Database->query('DELETE FROM `Model` WHERE `Module` = '.$Module['Id']); 496 496 $DbResult = $this->Database->query('SELECT Id FROM `Model` WHERE `Module` = '.$Module['Id']); 497 while ($DbRow = $DbResult->fetch_assoc())497 while ($DbRow = $DbResult->fetch_assoc()) 498 498 $this->Database->query('DELETE FROM `ModelField` WHERE `Model` = '.$DbRow['Id']); 499 499 $this->Database->query('DELETE FROM `Module` WHERE `Id` = '.$Module['Id']); … … 503 503 $DbDependency = array(); 504 504 $DbResult = $this->Database->query('SELECT * FROM `ModuleLink`'); 505 while ($DbRow = $DbResult->fetch_assoc())505 while ($DbRow = $DbResult->fetch_assoc()) 506 506 $DbDependency[$DbRow['Module']][] = $DbRow['LinkedModule']; 507 507 508 foreach ($this->System->ModuleManager->Modules as $Module)508 foreach ($this->System->ModuleManager->Modules as $Module) 509 509 { 510 510 // Add missing 511 foreach ($Module->Dependencies as $Dependency)512 { 513 if (!array_key_exists($Module->Id, $DbDependency) or511 foreach ($Module->Dependencies as $Dependency) 512 { 513 if (!array_key_exists($Module->Id, $DbDependency) or 514 514 !in_array($this->System->ModuleManager->Modules[$Dependency]->Id, $DbDependency[$Module->Id])) 515 515 { 516 if (array_key_exists($Dependency, $this->System->ModuleManager->Modules))516 if (array_key_exists($Dependency, $this->System->ModuleManager->Modules)) 517 517 $DependencyId = $this->System->ModuleManager->Modules[$Dependency]->Id; 518 518 else throw new Exception('Dependent module '.$Dependency.' not found'); … … 523 523 524 524 // Remove exceeding 525 if (array_key_exists($Module->Id, $DbDependency))526 foreach ($DbDependency[$Module->Id] as $Dep)525 if (array_key_exists($Module->Id, $DbDependency)) 526 foreach ($DbDependency[$Module->Id] as $Dep) 527 527 { 528 528 $DepModName = $this->System->ModuleManager->SearchModuleById($Dep); 529 if (!in_array($DepModName, $Module->Dependencies))529 if (!in_array($DepModName, $Module->Dependencies)) 530 530 $this->Database->query('DELETE FROM `ModuleLink` WHERE `Module` = '. 531 531 $Module->Id.' AND LinkedModule='.$Dep); 532 532 } 533 533 } 534 return ($Output);534 return ($Output); 535 535 } 536 536 }
Note:
See TracChangeset
for help on using the changeset viewer.