Changeset 398 for branches


Ignore:
Timestamp:
Mar 13, 2012, 4:08:31 PM (12 years ago)
Author:
chronos
Message:
  • Upraveno: Seznam závislostí modulů načítán do samostatné tabulky.
  • Upraveno: V základu načíst jen základní moduly a umožnit doinstalaci dalších.
Location:
branches/Modular
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/Modular/Common/Model.php

    r378 r398  
    3333  var $Module;
    3434  var $Installed;
     35  var $Parent;
    3536 
    3637  function __construct($Database, $System)
     
    181182      if($Property['Null']) $Null = 'NULL';
    182183        else $Null = 'NOT NULL';
     184      $Null = 'NULL';
    183185      if($Property['Type'] == PropertyDateTime)
    184186        $Query .= '`'.$Property['Name'].'` DATETIME '.$Null.',';
     
    223225    }
    224226    $Query .= 'PRIMARY KEY (`Id`)'.
    225       ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci AUTO_INCREMENT=1 ;';         
     227      ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci AUTO_INCREMENT=1;';         
    226228    $this->Database->query($Query);
    227229    foreach($this->Properties as $Property)
  • branches/Modular/Common/Module.php

    r383 r398  
    55class Module
    66{
     7  var $Id;
    78  var $Name;
    89  var $Version;
     
    127128  `Installed` int(11) NOT NULL,
    128129  `Description` text COLLATE utf8_czech_ci NOT NULL,
    129   `Dependencies` varchar(255) COLLATE utf8_czech_ci NOT NULL,
    130130  PRIMARY KEY (`Id`)
    131131) 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   
    132145    $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemModel` (
    133146  `Id` int(11) NOT NULL AUTO_INCREMENT,
     
    137150  PRIMARY KEY (`Id`)
    138151) 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   
    139154    $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemModelProperty` (
    140155  `Id` int(11) NOT NULL AUTO_INCREMENT,
     
    145160  PRIMARY KEY (`Id`)
    146161) 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   
    147164    $this->ReloadList();
    148165    $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    //}
    153171  }
    154172 
     
    162180    $this->Database->query('DROP TABLE IF EXISTS `SystemModelProperty`');
    163181    $this->Database->query('DROP TABLE IF EXISTS `SystemModel`');
     182    $this->Database->query('DROP TABLE IF EXISTS `SystemModuleDependency`');
    164183    $this->Database->query('DROP TABLE IF EXISTS `SystemModule`');
    165184  }
     
    195214          'Version' => $Module->Version, 'Creator' => $Module->Creator,
    196215          'Description' => $Module->Description, 'License' => $Module->License,
    197           'Installed' => 0, 'Dependencies' => implode(',', $Module->Dependencies)));
     216          'Installed' => 0));
    198217        unset($Module);
    199218      } else throw new Exception('Missing class '.$ModuleClassName.' in module '.$ModuleName);
     
    207226      $this->Database->query('DELETE FROM `SystemModule` WHERE `Id` = '.$Module['Id']);
    208227    }
     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    }
    209239  }
    210240}
  • branches/Modular/Modules/Member/Member.php

    r379 r398  
    4040    $this->AddPropertyBoolean('Blocked');
    4141  }
     42}
     43
     44class MemberUser extends Model
     45{
     46  function __construct($Database, $System)
     47  {
     48    parent::__construct($Database, $System);
     49    $this->Name = 'MemberUser';
     50    $this->Parent = 'User';
     51    $this->AddPropertyOneToMany('Member', 'Member', true);
     52  }   
    4253}
    4354
  • branches/Modular/Modules/System/System.php

    r383 r398  
    4444    $this->License = 'GNU/GPL';
    4545    $this->Description = 'Base system module';
    46     $this->Dependencies = array();
     46    $this->Dependencies = array('User');
    4747    $this->SupportedModels = array('SystemMenu', 'SystemView', 'SystemAction');
    4848  }
  • branches/Modular/Modules/User/User.php

    r383 r398  
    4848    $this->AddPropertyString('Password');   
    4949    $this->AddPropertyString('Email');   
    50     $this->AddPropertyString('LastIpAddress');   
    51     $this->AddPropertyDateTime('LastLoginTime');
    52     $this->AddPropertyDateTime('RegistrationTime');
    53     $this->AddPropertyOneToMany('Member', 'Member');
     50    $this->AddPropertyString('LastIpAddress');
     51    $this->AddPropertyDateTime('LastLoginTime', true);
     52    $this->AddPropertyDateTime('RegistrationTime', true);
    5453    $this->AddPropertyBoolean('Locked');
    5554    $this->AddPropertyInteger('ICQ');
    56     $this->AddPropertyString('PhoneNumber');   
    57     $this->AddPropertyString('InitPassword');   
     55    $this->AddPropertyString('PhoneNumber');
     56    $this->AddPropertyString('InitPassword');
    5857  }   
    5958
     
    372371    $this->License = 'GNU/GPL';
    373372    $this->Description = 'User management';
    374     $this->Dependencies = array();
     373    $this->Dependencies = array('System');
    375374    $this->SupportedModels = array('User', 'UserOnline');
    376375    $this->Views = array('UserLogin', 'PasswordRecove', 'UserRegister', 'UserOptions',
     
    389388  function Install()
    390389  {
     390    $Installed = $this->Installed;
    391391    parent::Install();
    392     if(!$this->Installed)
     392    if(!$Installed)
    393393    {
    394394      $this->Database->insert('User', array('Id' => ANONYMOUS_ID, 'Login' => 'Anonymous', 'Name' => 'Anonymous',
  • branches/Modular/config.sample.php

    r344 r398  
    77  'Database' => array
    88  (
    9     'Host' => 'centrala',
     9    'Host' => 'localhost',
    1010    'User' => 'root',
    1111    'Password' => '',
    12     'Database' => 'is',
     12    'Database' => 'centrala',
    1313    'Prefix' => '',
    1414    'Charset' => 'utf8',
     
    2525    'Admin' => 'Admin',
    2626    'AdminEmail' => 'admin@localhost',
    27     'ShowSQLError' => false,
     27    'ShowSQLError' => $IsDeveloper,
    2828    'ShowSQLQuery' => false,
    29     'ShowPHPError' => false,
     29    'ShowPHPError' => $IsDeveloper,
    3030    'ShowRuntimeInfo' => false,
     31    'ShowDebug' => $IsDeveloper,
    3132    'ErrorLogFile' => '/var/www/html/dev/centrala/www/php_script_error.log',   
    3233    'WebcamPassword' => '',
Note: See TracChangeset for help on using the changeset viewer.