Changeset 731 for trunk/Modules/System/System.php
- Timestamp:
- Jan 17, 2015, 9:24:47 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/System/System.php
r712 r731 14 14 { 15 15 $Output = ''; 16 $DbResult = $this->Database->query('SELECT COUNT(*) FROM ` SystemModule`');16 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Module`'); 17 17 $DbRow = $DbResult->fetch_row(); 18 18 $PageList = GetPageList($DbRow[0]); … … 22 22 23 23 $TableColumns = array( 24 25 26 27 28 29 30 31 24 array('Name' => 'Name', 'Title' => 'Jméno'), 25 array('Name' => 'Creator', 'Title' => 'Tvůrce'), 26 array('Name' => 'Version', 'Title' => 'Verze'), 27 array('Name' => 'License', 'Title' => 'Licence'), 28 array('Name' => 'Installed', 'Title' => 'Instalováno'), 29 array('Name' => 'Description', 'Title' => 'Popis'), 30 array('Name' => 'Dependencies', 'Title' => 'Závislosti'), 31 array('Name' => '', 'Title' => 'Akce'), 32 32 ); 33 33 $Order = GetOrderTableHeader($TableColumns, 'Name', 0); 34 34 $Output .= $Order['Output']; 35 $Query = 'SELECT *, (SELECT GROUP_CONCAT(`T1`.`Name` SEPARATOR ", ") FROM ` SystemModuleDependency` '.36 'LEFT JOIN ` SystemModule` AS `T1` ON `T1`.`Id` = `SystemModuleDependency`.`DependencyModule` '.37 'WHERE ` SystemModuleDependency`.`Module` = `SystemModule`.`Id`) AS `Dependencies` '.38 'FROM ` SystemModule` '.$Order['SQL'].$PageList['SQLLimit'];35 $Query = 'SELECT *, (SELECT GROUP_CONCAT(`T1`.`Name` SEPARATOR ", ") FROM `ModuleLink` '. 36 'LEFT JOIN `Module` AS `T1` ON `T1`.`Id` = `ModuleLink`.`LinkedModule` '. 37 'WHERE `ModuleLink`.`Module` = `Module`.`Id`) AS `Dependencies` '. 38 'FROM `Module` '.$Order['SQL'].$PageList['SQLLimit']; 39 39 40 40 $DbResult = $this->Database->query($Query); … … 69 69 if($_GET['A'] == 'SaveToDb') 70 70 { 71 $ this->System->ModuleManager->Modules['System']->SaveToDatabase();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 … … 225 225 'Name' => array('Type' => 'String', 'Caption' => 'Systémové jméno', 'Default' => ''), 226 226 'Title' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''), 227 'Description' => array('Type' => 'Text', 'Caption' => 'Popis', 'Default' => ''), 228 'Version' => array('Type' => 'String', 'Caption' => 'Verze', 'Default' => ''), 229 'License' => array('Type' => 'String', 'Caption' => 'Licence', 'Default' => ''), 230 'Creator' => array('Type' => 'String', 'Caption' => 'Tvůrce', 'Default' => ''), 231 'HomePage' => array('Type' => 'Hyperlink', 'Caption' => 'Domovské stránky', 'Default' => ''), 232 'Installed' => array('Type' => 'Boolean', 'Caption' => 'Instalováno', 'Default' => '', 'ReadOnly' => true), 233 'Models' => array('Type' => 'TModelListModule', 'Caption' => 'Modely', 'Default' => ''), 234 'Links' => array('Type' => 'TModuleLinkListModule', 'Caption' => 'Vazby', 'Default' => ''), 235 ), 236 'Actions' => array( 237 array('Caption' => 'Aktualizovat z disku', 'URL' => '/module/?A=SaveToDb'), 238 ), 239 )); 240 $this->System->FormManager->RegisterFormType('TModule', array( 241 'Type' => 'Reference', 242 'Table' => 'Module', 243 'Id' => 'Id', 244 'Name' => 'Title', 245 'Filter' => '1', 246 )); 247 $this->System->FormManager->RegisterFormType('TModelListModule', array( 248 'Type' => 'ManyToOne', 249 'Table' => 'Model', 250 'Id' => 'Id', 251 'Ref' => 'Module', 252 'Filter' => '1', 253 )); 254 $this->System->FormManager->RegisterClass('Model', array( 255 'Title' => 'Modely', 256 'Table' => 'Model', 257 'Items' => array( 258 'Name' => array('Type' => 'String', 'Caption' => 'Systémové jméno', 'Default' => ''), 259 'Title' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''), 260 'Module' => array('Type' => 'TModule', 'Caption' => 'Module', 'Default' => ''), 261 'Query' => array('Type' => 'String', 'Caption' => 'SQL dotaz', 'Default' => ''), 262 'DefaultSortColumn' => array('Type' => 'String', 'Caption' => 'Výchozí sloupce řazení', 'Default' => ''), 263 'DefaultSortOrder' => array('Type' => 'Text', 'Caption' => 'Výchozí směr řazení', 'Default' => ''), 264 'Fields' => array('Type' => 'TModelFieldListModel', 'Caption' => 'Pole', 'Default' => ''), 265 ), 266 )); 267 $this->System->FormManager->RegisterFormType('TModel', array( 268 'Type' => 'Reference', 269 'Table' => 'Model', 270 'Id' => 'Id', 271 'Name' => 'Title', 272 'Filter' => '1', 273 )); 274 $this->System->FormManager->RegisterFormType('TModelFieldListModel', array( 275 'Type' => 'ManyToOne', 276 'Table' => 'ModelField', 277 'Id' => 'Id', 278 'Ref' => 'Model', 279 'Filter' => '1', 280 )); 281 $this->System->FormManager->RegisterClass('ModelField', array( 282 'Title' => 'Pole modelu', 283 'Table' => 'ModelField', 284 'Items' => array( 285 'Name' => array('Type' => 'String', 'Caption' => 'Systémové jméno', 'Default' => ''), 286 'Title' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''), 287 'Model' => array('Type' => 'TModel', 'Caption' => 'Model', 'Default' => ''), 288 'Query' => array('Type' => 'String', 'Caption' => 'SQL dotaz', 'Default' => ''), 289 'Type' => array('Type' => 'String', 'Caption' => 'Typ', 'Default' => ''), 290 'DefaultValue' => array('Type' => 'String', 'Caption' => 'Výchozí hodnota', 'Default' => ''), 291 'IsNull' => array('Type' => 'Boolean', 'Caption' => 'Také nulová hodnota', 'Default' => ''), 292 'Suffix' => array('Type' => 'String', 'Caption' => 'Text za', 'Default' => ''), 293 ), 294 )); 295 $this->System->FormManager->RegisterFormType('TModuleLink', array( 296 'Type' => 'Reference', 297 'Table' => 'ModuleLink', 298 'Id' => 'Id', 299 'Name' => 'Module', 300 'Filter' => '1', 301 )); 302 $this->System->FormManager->RegisterFormType('TModuleLinkListModule', array( 303 'Type' => 'ManyToOne', 304 'Table' => 'ModuleLink', 305 'Id' => 'Id', 306 'Ref' => 'Module', 307 'Filter' => '1', 308 )); 309 $this->System->FormManager->RegisterClass('ModuleLink', array( 310 'Title' => 'Vazby modulu', 311 'Table' => 'ModuleLink', 312 'Items' => array( 313 'Module' => array('Type' => 'TModule', 'Caption' => 'Modul', 'Default' => ''), 314 'LinkedModule' => array('Type' => 'TModule', 'Caption' => 'Vázaný modul', 'Default' => ''), 315 'Type' => array('Type' => 'String', 'Caption' => 'Typ vazby', 'Default' => ''), 227 316 ), 228 317 )); … … 232 321 'DefaultSortColumn' => 'Name', 233 322 'Items' => array( 234 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''), 323 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''), 235 324 ), 236 325 )); … … 337 426 if($Module->IsInstalled()) $Installed = 1; 338 427 else $Installed = 0; 339 $this->Database->query('UPDATE ` SystemModule` SET `Installed`=1 WHERE `Name`="'.$Module->Name.'"');428 $this->Database->query('UPDATE `Module` SET `Installed`=1 WHERE `Name`="'.$Module->Name.'"'); 340 429 } 341 430 } … … 345 434 //DebugLog('Loading modules...'); 346 435 $this->Modules = array(); 347 $Query = 'SELECT `Id`, `Name`,`Installed` FROM ` SystemModule`';436 $Query = 'SELECT `Id`, `Name`,`Installed` FROM `Module`'; 348 437 $DbResult = $this->Database->query($Query); 349 438 while($Module = $DbResult->fetch_array()) … … 361 450 function SaveToDatabase() 362 451 { 452 $Output = ''; 363 453 $Modules = array(); 364 $DbResult = $this->Database->query('SELECT * FROM ` SystemModule`');454 $DbResult = $this->Database->query('SELECT * FROM `Module`'); 365 455 while($DbRow = $DbResult->fetch_assoc()) 366 456 { … … 375 465 if(!array_key_exists($Module->Name, $Modules)) 376 466 { 377 $this->Database->insert('SystemModule', array('Name' => $Module->Name, 378 'Version' => $Module->Version, 'Creator' => $Module->Creator, 467 $this->Database->insert('Module', array('Name' => $Module->Name, 468 'Version' => $Module->Version, 'Creator' => $Module->Creator, 469 'HomePage' => $Module->HomePage, 'Title' => $Module->Title, 379 470 'Description' => $Module->Description, 'License' => $Module->License, 380 471 'Installed' => $Module->Installed)); 381 472 $this->System->ModuleManager->Modules[$Module->Name]->Id = $this->Database->insert_id; 382 473 } 383 else $this->Database->update('SystemModule', 'Name = "'.$Module->Name.'"', array( 384 'Version' => $Module->Version, 'Creator' => $Module->Creator, 474 else $this->Database->update('Module', 'Name = "'.$Module->Name.'"', array( 475 'Version' => $Module->Version, 'Creator' => $Module->Creator, 476 'HomePage' => $Module->HomePage, 'Title' => $Module->Title, 385 477 'Description' => $Module->Description, 'License' => $Module->License, 386 478 'Installed' => $Module->Installed)); … … 391 483 if(!$this->System->ModuleManager->ModulePresent($Module['Name'])) 392 484 { 393 DebugLog('Removing module '.$Module['Name'].' from list'); 394 $this->Database->query('DELETE FROM `SystemModule` WHERE `Id` = '.$Module['Id']); 485 $Output .= 'Removing module '.$Module['Name'].' from list</br/>'; 486 $this->Database->query('DELETE FROM `ModuleLink` WHERE `Module` = '.$Module['Id']); 487 $this->Database->query('DELETE FROM `ModuleLink` WHERE `LinkedModule` = '.$Module['Id']); 488 $DbResult = $this->Database->query('SELECT Id FROM `PermissionOperation` WHERE `Module` = '.$Module['Id']); 489 while($DbRow = $DbResult->fetch_assoc()) 490 { 491 $this->Database->query('DELETE FROM `PermissionGroupAssignment` WHERE `AssignedOperation` = '.$DbRow['Id']); 492 $this->Database->query('DELETE FROM `PermissionUserAssignment` WHERE `AssignedOperation` = '.$DbRow['Id']); 493 } 494 $this->Database->query('DELETE FROM `PermissionOperation` WHERE `Module` = '.$Module['Id']); 495 $this->Database->query('DELETE FROM `Model` WHERE `Module` = '.$Module['Id']); 496 $DbResult = $this->Database->query('SELECT Id FROM `Model` WHERE `Module` = '.$Module['Id']); 497 while($DbRow = $DbResult->fetch_assoc()) 498 $this->Database->query('DELETE FROM `ModelField` WHERE `Model` = '.$DbRow['Id']); 499 $this->Database->query('DELETE FROM `Module` WHERE `Id` = '.$Module['Id']); 395 500 } 396 501 397 502 // Reload dependencies 398 503 $DbDependency = array(); 399 $DbResult = $this->Database->query('SELECT * FROM ` SystemModuleDependency`');504 $DbResult = $this->Database->query('SELECT * FROM `ModuleLink`'); 400 505 while($DbRow = $DbResult->fetch_assoc()) 401 $DbDependency[$DbRow['Module']][] = $DbRow[' DependencyModule'];506 $DbDependency[$DbRow['Module']][] = $DbRow['LinkedModule']; 402 507 403 508 foreach($this->System->ModuleManager->Modules as $Module) … … 412 517 $DependencyId = $this->System->ModuleManager->Modules[$Dependency]->Id; 413 518 else throw new Exception('Dependent module '.$Dependency.' not found'); 414 $this->Database->insert(' SystemModuleDependency', array('Module' => $Module->Id,415 ' DependencyModule' => $DependencyId));519 $this->Database->insert('ModuleLink', array('Module' => $Module->Id, 520 'LinkedModule' => $DependencyId, 'Type' => 'DependOn')); 416 521 } 417 522 } … … 423 528 $DepModName = $this->System->ModuleManager->SearchModuleById($Dep); 424 529 if(!in_array($DepModName, $Module->Dependencies)) 425 $this->Database->query('DELETE FROM ` SystemModuleDependency` WHERE `Module` = '.426 $Module->Id.' AND DependencyModule='.$Dep);530 $this->Database->query('DELETE FROM `ModuleLink` WHERE `Module` = '. 531 $Module->Id.' AND LinkedModule='.$Dep); 427 532 } 428 533 } 534 return($Output); 429 535 } 430 536 }
Note:
See TracChangeset
for help on using the changeset viewer.