Changeset 398 for branches/Modular/Common/Module.php
- Timestamp:
- Mar 13, 2012, 4:08:31 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Modular/Common/Module.php
r383 r398 5 5 class Module 6 6 { 7 var $Id; 7 8 var $Name; 8 9 var $Version; … … 127 128 `Installed` int(11) NOT NULL, 128 129 `Description` text COLLATE utf8_czech_ci NOT NULL, 129 `Dependencies` varchar(255) COLLATE utf8_czech_ci NOT NULL,130 130 PRIMARY KEY (`Id`) 131 131 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;'); 132 133 $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemModuleDependency` ( 134 `Id` int(11) NOT NULL AUTO_INCREMENT, 135 `Module` int(11) NOT NULL, 136 `DependencyModule` int(11) NOT NULL, 137 PRIMARY KEY (`Id`), 138 KEY (`Module`), 139 KEY (`DependencyModule`), 140 UNIQUE (`Module` , `DependencyModule`) 141 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;'); 142 $this->Database->query('ALTER TABLE `SystemModuleDependency` ADD FOREIGN KEY ( `Module` ) REFERENCES `SystemModule` (`Id`)'); 143 $this->Database->query('ALTER TABLE `SystemModuleDependency` ADD FOREIGN KEY ( `DependencyModule` ) REFERENCES `SystemModule` (`Id`)'); 144 132 145 $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemModel` ( 133 146 `Id` int(11) NOT NULL AUTO_INCREMENT, … … 137 150 PRIMARY KEY (`Id`) 138 151 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;'); 152 $this->Database->query('ALTER TABLE `SystemModel` ADD FOREIGN KEY ( `Module` ) REFERENCES `SystemModule` (`Id`)'); 153 139 154 $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemModelProperty` ( 140 155 `Id` int(11) NOT NULL AUTO_INCREMENT, … … 145 160 PRIMARY KEY (`Id`) 146 161 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;'); 162 $this->Database->query('ALTER TABLE `SystemModelProperty` ADD FOREIGN KEY ( `Model` ) REFERENCES `SystemModel` (`Id`)'); 163 147 164 $this->ReloadList(); 148 165 $this->LoadModules(false); 149 foreach($this->Modules as $Index => $Module) 150 { 151 $this->Modules[$Index]->Install(); 152 } 166 $this->Modules['System']->Install(); 167 //foreach($this->Modules as $Index => $Module) 168 //{ 169 // $this->Modules[$Index]->Install(); 170 //} 153 171 } 154 172 … … 162 180 $this->Database->query('DROP TABLE IF EXISTS `SystemModelProperty`'); 163 181 $this->Database->query('DROP TABLE IF EXISTS `SystemModel`'); 182 $this->Database->query('DROP TABLE IF EXISTS `SystemModuleDependency`'); 164 183 $this->Database->query('DROP TABLE IF EXISTS `SystemModule`'); 165 184 } … … 195 214 'Version' => $Module->Version, 'Creator' => $Module->Creator, 196 215 'Description' => $Module->Description, 'License' => $Module->License, 197 'Installed' => 0 , 'Dependencies' => implode(',', $Module->Dependencies)));216 'Installed' => 0)); 198 217 unset($Module); 199 218 } else throw new Exception('Missing class '.$ModuleClassName.' in module '.$ModuleName); … … 207 226 $this->Database->query('DELETE FROM `SystemModule` WHERE `Id` = '.$Module['Id']); 208 227 } 228 229 // Reload dependencies 230 $this->LoadModules(false); 231 foreach($this->Modules as $Module) 232 { 233 foreach($Module->Dependencies as $Dependency) 234 { 235 $this->Database->insert('SystemModuleDependency', array('Module' => $Module->Id, 236 'DependencyModule' => $this->Modules[$Dependency]->Id)); 237 } 238 } 209 239 } 210 240 }
Note:
See TracChangeset
for help on using the changeset viewer.