Changeset 373 for trunk/Common/Module.php
- Timestamp:
- Jan 19, 2012, 9:43:36 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Module.php
r366 r373 28 28 { 29 29 $Model = new $ModelName($this->Database, $this->System); 30 $Model->Module = &$this; 30 31 $Model->Install(); 31 32 unset($Model); 32 33 } 33 $this->Database->query('UPDATE Module SET Installed=1 WHERE Name="'.$this->Name.'"');34 $this->Database->query('UPDATE SystemModule SET Installed=1 WHERE Name="'.$this->Name.'"'); 34 35 } 35 36 … … 43 44 unset($Model); 44 45 } 45 $this->Database->query('UPDATE Module SET Installed=0 WHERE Name="'.$this->Name.'"');46 $this->Database->query('UPDATE SystemModule SET Installed=0 WHERE Name="'.$this->Name.'"'); 46 47 } 47 48 … … 69 70 function Init($Installed = true) 70 71 { 71 $Query = 'SELECT Name FROM `Module`';72 $Query = 'SELECT `Id`, `Name` FROM `SystemModule`'; 72 73 if($Installed) $Query .= ' WHERE `Installed`=1'; 73 74 else $Query .= ' WHERE `Installed`=0'; … … 78 79 $ModuleClassName = 'Module'.$Module['Name']; 79 80 $this->Modules[$Module['Name']] = new $ModuleClassName($this->Database, $this); 81 $this->Modules[$Module['Name']]->Id = $Module['Id']; 80 82 $this->Modules[$Module['Name']]->Init(); 81 83 } … … 85 87 { 86 88 //DebugLog('Installing modular system core...'); 87 $this->Database->query('CREATE TABLE IF NOT EXISTS ` Module` (89 $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemModule` ( 88 90 `Id` int(11) NOT NULL AUTO_INCREMENT, 89 91 `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL, … … 94 96 `Description` text COLLATE utf8_czech_ci NOT NULL, 95 97 `Dependecies` varchar(255) COLLATE utf8_czech_ci NOT NULL, 98 PRIMARY KEY (`Id`) 99 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;'); 100 $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemModel` ( 101 `Id` int(11) NOT NULL AUTO_INCREMENT, 102 `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL, 103 `Module` int(11) NOT NULL, 104 KEY (`Module`), 105 PRIMARY KEY (`Id`) 106 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;'); 107 $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemModelProperty` ( 108 `Id` int(11) NOT NULL AUTO_INCREMENT, 109 `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL, 110 `Type` varchar(255) COLLATE utf8_czech_ci NOT NULL, 111 `Model` int(11) NOT NULL, 112 KEY (`Model`), 96 113 PRIMARY KEY (`Id`) 97 114 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;'); … … 109 126 foreach($this->Modules as $Index => $Module) 110 127 $this->Modules[$Index]->UnInstall(); 111 $this->Database->query('DROP TABLE IF EXISTS `Module`'); 128 129 // Delete tables with reverse order 130 $this->Database->query('DROP TABLE IF EXISTS `SystemModelProperty`'); 131 $this->Database->query('DROP TABLE IF EXISTS `SystemModel`'); 132 $this->Database->query('DROP TABLE IF EXISTS `SystemModule`'); 112 133 } 113 134 … … 116 137 // Load list of modules from database 117 138 $Modules = array(); 118 $DbResult = $this->Database->query('SELECT * FROM ` Module`');139 $DbResult = $this->Database->query('SELECT * FROM `SystemModule`'); 119 140 while($DbRow = $DbResult->fetch_assoc()) 120 141 $Modules[$DbRow['Name']] = $DbRow; … … 139 160 { 140 161 $Module = new $ModuleClassName($this->Database, $this); 141 $this->Database->insert(' Module', array('Name' => $Module->Name,162 $this->Database->insert('SystemModule', array('Name' => $Module->Name, 142 163 'Version' => $Module->Version, 'Creator' => $Module->Creator, 143 164 'Description' => $Module->Description, 'License' => $Module->License, … … 152 173 { 153 174 DebugLog('Removing module '.$Module['Name'].' from list'); 154 $this->Database->query('DELETE FROM ` Module` WHERE `Id` = '.$Module['Id']);175 $this->Database->query('DELETE FROM `SystemModule` WHERE `Id` = '.$Module['Id']); 155 176 } 156 177 }
Note:
See TracChangeset
for help on using the changeset viewer.