Ignore:
Timestamp:
Jan 19, 2012, 9:43:36 PM (13 years ago)
Author:
chronos
Message:
  • Přidáno: Různé knihovny pro zpracování HTML kódu, tabulek, stránkování, zasílání emailů, aj.
  • Přidáno: Kód zpracování fronty emailů přesunut z Global do modulu EmailQueue.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Module.php

    r366 r373  
    2828    {
    2929      $Model = new $ModelName($this->Database, $this->System);
     30      $Model->Module = &$this;
    3031      $Model->Install();
    3132      unset($Model);
    3233    }
    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.'"');
    3435  }
    3536 
     
    4344      unset($Model);
    4445    }
    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.'"');
    4647  }
    4748 
     
    6970  function Init($Installed = true)
    7071  {
    71     $Query = 'SELECT Name FROM `Module`';
     72    $Query = 'SELECT `Id`, `Name` FROM `SystemModule`';
    7273    if($Installed) $Query .= ' WHERE `Installed`=1';
    7374      else $Query .= ' WHERE `Installed`=0';
     
    7879      $ModuleClassName = 'Module'.$Module['Name'];
    7980      $this->Modules[$Module['Name']] = new $ModuleClassName($this->Database, $this);
     81      $this->Modules[$Module['Name']]->Id = $Module['Id'];
    8082      $this->Modules[$Module['Name']]->Init();
    8183    }     
     
    8587  {
    8688    //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` (
    8890  `Id` int(11) NOT NULL AUTO_INCREMENT,
    8991  `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
     
    9496  `Description` text COLLATE utf8_czech_ci NOT NULL,
    9597  `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`),
    96113  PRIMARY KEY (`Id`)
    97114) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;');
     
    109126    foreach($this->Modules as $Index => $Module)
    110127      $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`');
    112133  }
    113134 
     
    116137    // Load list of modules from database
    117138    $Modules = array();
    118     $DbResult = $this->Database->query('SELECT * FROM `Module`');
     139    $DbResult = $this->Database->query('SELECT * FROM `SystemModule`');
    119140    while($DbRow = $DbResult->fetch_assoc())
    120141      $Modules[$DbRow['Name']] = $DbRow;
     
    139160      {
    140161        $Module = new $ModuleClassName($this->Database, $this);
    141         $this->Database->insert('Module', array('Name' => $Module->Name,
     162        $this->Database->insert('SystemModule', array('Name' => $Module->Name,
    142163          'Version' => $Module->Version, 'Creator' => $Module->Creator,
    143164          'Description' => $Module->Description, 'License' => $Module->License,
     
    152173    {
    153174      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']);
    155176    }
    156177  }
Note: See TracChangeset for help on using the changeset viewer.