Changeset 425 for branches


Ignore:
Timestamp:
Oct 10, 2012, 12:21:38 PM (12 years ago)
Author:
chronos
Message:
  • Upraveno: Automatické spouštění instalovaných modulů.
Location:
branches/Modular
Files:
11 edited

Legend:

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

    r424 r425  
    8686  $ModuleSystem = new ModuleSystem($System->Database, $System);
    8787  $System->RegisterModule($ModuleSystem);
    88   if($System->Modules['System']->IsInstalled()) $System->Modules['System']->Start(); 
     88  if($System->Modules['System']->IsInstalled())
     89  {
     90    $System->Modules['System']->Start(); 
     91    $System->StartInstalled();
     92    //var_dump($System->Modules['News']->Models);
     93  }
    8994}
    9095
  • branches/Modular/Common/Module.php

    r424 r425  
    1818  var $Installed;
    1919  var $Running;
     20  var $System;
    2021  /** @var ModularSystem */
    21   var $ModularSystem;
     22  var $Manager;
    2223 
    2324 
     
    3839    // Install dependencies first
    3940    foreach($this->Dependencies as $Dependency) 
    40       $this->ModularSystem->Modules[$Dependency]->Install();
     41      $this->Manager->Modules[$Dependency]->Install();
    4142    $this->DoChange();
    4243  }
     
    6869    $this->Running = true;
    6970    foreach($this->Dependencies as $Dependency) 
    70       $this->System->Modules[$Dependency]->Start();
     71      $this->Manager->Modules[$Dependency]->Start();
    7172    $this->LoadModels();
    7273    $this->DoChange();
     
    8687  private function DoChange()
    8788  {
    88     if($this->ModularSystem->OnModuleChange)
    89       call_user_func_array($this->ModularSystem->OnModuleChange, array($this));
     89    if($this->Manager->OnModuleChange)
     90      call_user_func_array($this->Manager->OnModuleChange, array($this));
    9091  }
    9192 
     
    102103  function LoadModels()
    103104  {
     105    //echo($this->Name.'... ');
    104106    $this->Models = array();
    105107    foreach($this->SupportedModels as $ModelName)
     
    108110      $NewModel->Module = &$this;
    109111      $this->Models[$ModelName] = $NewModel;
     112      //DebugLog($ModelName.'.LoadModels()');
    110113    }       
    111114  }
     
    136139  }
    137140 
     141  function StartInstalled()
     142  {
     143    foreach($this->Modules as $Index => $Module)
     144    {     
     145      //DebugLog('Init module '.$Module->Name);
     146      if($Module->IsInstalled()) $this->Modules[$Index]->Start();
     147    }
     148  }
     149
    138150  function StopAll()
    139151  {
     
    187199  {
    188200    $this->Modules[$Module->Name] = &$Module; 
    189     $Module->ModularSystem = $this;
     201    $Module->Manager = &$this;
    190202    $Module->OnChange = &$this->OnModuleChange;
    191203  }
     
    224236    if(array_key_exists($Module->Name, $ModulesOnDisk))
    225237    {
    226       $this->ModularSystem->UnregisterModule($Module);
     238      $this->Manager->UnregisterModule($Module);
    227239    }
    228240  } 
  • branches/Modular/Install.php

    r424 r425  
    1414  foreach($System->Modules as $Module)
    1515  {
    16     if($Module->Installed) $Actions = '<a href="?a=uninstall&m='.$Module->Name.'">Odinstalovat</td>';
     16    if($Module->IsInstalled()) $Actions = '<a href="?a=uninstall&m='.$Module->Name.'">Odinstalovat</td>';
    1717      else $Actions = '<a href="?a=install&m='.$Module->Name.'">Instalovat</td>';
    18     if($Module->Installed) $Installed = 'Ano';
     18    if($Module->IsInstalled()) $Installed = 'Ano';
    1919      else $Installed = 'Ne';
    2020    $Deps = implode(', ', $Module->Dependencies);
  • branches/Modular/Modules/Finance/Finance.php

    r424 r425  
    451451      $Cash = $Cash[0];
    452452   
    453       $DbResult2 = $this->Database->query('SELECT SUM(consumption) FROM network_devices WHERE (user='.$Member['Id'].') AND (used = 1)');
     453      $DbResult2 = $this->Database->query('SELECT SUM(Consumption) FROM Product WHERE (User='.$Member['Id'].') AND (Used = 1)');
    454454      $ConsumptionPlus = $DbResult2->fetch_row();
    455455      $ConsumptionPlus = $ConsumptionPlus[0];
  • branches/Modular/Modules/Finance/FinanceOverview.php

    r377 r425  
    1414    $Output .= '<a href="tarify/">Tarify</a><br />';
    1515    $Output .= '<a href="zarizeni/">Výpis zařízení</a><br />';
    16     if($this->System->Models['User']->CheckPermission('Finance', 'SubjectList'))
     16    if($this->System->Modules['User']->Models['User']->CheckPermission('Finance', 'SubjectList'))
    1717      $Output .= '<a href="clenove/">Seznam členů</a><br />';
    1818    $Output .= '<a href="spotreba/">Spotřeba energie</a><br />';
     
    6060    $TotalGain = 0;
    6161    $TotalExpense = 0;
    62     $DbResult = $this->Database->query('SELECT SUM(Consumption) FROM network_devices WHERE used=1');
     62    $DbResult = $this->Database->query('SELECT SUM(Consumption) FROM Product WHERE Used=1');
    6363    $Row = $DbResult->fetch_array();
    6464    $TotalConsumption = $this->System->Modules['Finance']->W2Kc($Row[0]);
  • branches/Modular/Modules/Finance/MonthlyOverall.php

    r377 r425  
    2121        $Month['Administration'].'</td><td align="center">'.$Month['AdministrationTotal'].
    2222        '</td><td align="center">'.$Month['kWh'].'</td><td align="center">'.
    23         $Month['Consumption_Total'].'</td><td align="center">'.$Month['TotalPaid'].
     23        $Month['ConsumptionTotal'].'</td><td align="center">'.$Month['TotalPaid'].
    2424        '</td><td align="center">'.round($Month['TotalPaid'] / $Month['MemberCount']).
    2525        '</td><td align="center">'.$Month['Investment'].'</td></tr>';
  • branches/Modular/Modules/FrontPage/FrontPage.php

    r424 r425  
    171171      {
    172172        $UserOptions = new UserOptionsView($this->Database);
     173        print_r($this->System);
    173174        $UserOptions->LoadValuesFromDatabase($this->System->Modules['User']->Models['User']->User['Id']);
    174175        $UserOptions->OnSubmit = '?Action=UserOptionsSave';
     
    297298        if(($Panel['Module'] == 'Webcam') and (array_key_exists('WebCam', $this->System->Modules)))
    298299          $Output .= $this->Panel('Kamery', $this->WebcamPanel());
    299         else if($Panel['Module'] == 'NewsGroupList') $Output .= $this->Panel('Aktuality', $this->System->Modules['News']->Show(), array('<a href="?Action=CustomizeNews">Upravit</a>'));
     300        else if($Panel['Module'] == 'NewsGroupList')
     301          $Output .= $this->Panel('Aktuality', $this->System->Modules['News']->Show(), array('<a href="?Action=CustomizeNews">Upravit</a>'));
    300302      }
    301303      $Output .= '</td>';
  • branches/Modular/Modules/News/News.php

    r424 r425  
    148148          else $Author = $Row['Name'];
    149149        $Output .= '<tr><td onclick="window.location=\'aktuality/?action=view&amp;id='.$Row['Id'].'\'" onmouseover="zobraz('."'new".$Category.$Index."'".')" style="cursor: pointer; margin: 0px;"><table class="NewsItemFrame"><tr><td style="font-size: '.$FontSize.'pt"><strong>'.$Row['Title'].'</strong></td><td align="right" style="font-size: '.$FontSize.'pt">'.$Author.' ('.HumanDate($Row['Date']).')</td></tr></table>';
    150         $Output .= '<div id="new'.$Category.$Index.'" class="NewsTableItem">'.$this->ModifyContent($Row['Content']);
     150        //$Output .= '<div id="new'.$Category.$Index.'" class="NewsTableItem">'.$this->Models['News']->ModifyContent($Row['Content']);
    151151        if($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';
    152152
  • branches/Modular/Modules/System/System.php

    r424 r425  
    205205    parent::Start();
    206206    $this->System->Pages['module'] = 'PageModules';
    207     $this->ModularSystem->OnModuleChange = array($this, 'ModuleChange');
     207    $this->Manager->OnModuleChange = array($this, 'ModuleChange');
    208208    $this->LoadFromDatabase();
    209209  }
     
    224224  function ModuleChange($Module)
    225225  {
    226     if($this->IsInstalled())
    227     {
    228       if($Module->Installed)
     226    //if($this->IsInstalled())
     227    {
     228      if($Module->IsInstalled())
    229229      $this->Database->query('UPDATE `SystemModule` SET `Installed`=1 WHERE `Name`="'.$Module->Name.'"');
    230230        else $this->Database->query('UPDATE `SystemModule` SET `Installed`=0 WHERE `Name`="'.$Module->Name.'"');
     
    243243      include_once('Modules/'.$Module['Name'].'/'.$Module['Name'].'.php');
    244244      $ModuleClassName = 'Module'.$Module['Name'];
    245       $NewModule = new $ModuleClassName($this->Database, $this);     
     245      $NewModule = new $ModuleClassName($this->Database, $this->Manager);     
    246246      $NewModule->Id = $Module['Id'];
    247247      $NewModule->Installed = $Module['Installed'];     
    248       $this->ModularSystem->RegisterModule($NewModule);
     248      $this->Manager->RegisterModule($NewModule);
    249249    }     
    250250  }
     
    258258
    259259    // Add missing
    260     foreach($this->ModularSystem->Modules as $Module)   
     260    foreach($this->Manager->Modules as $Module)   
    261261    {     
    262262      if(!array_key_exists($Module->Name, $Modules))
     
    273273    // Remove exceeding
    274274    foreach($Modules as $Module)   
    275     if(!$this->ModularSystem->ModulePresent($Module['Name']))
     275    if(!$this->Manager->ModulePresent($Module['Name']))
    276276    {
    277277      DebugLog('Removing module '.$Module['Name'].' from list');
     
    285285      $DbDependency[$DbRow['Module']][] = $DbRow['DependencyModule'];
    286286   
    287     foreach($this->ModularSystem->Modules as $Module)
     287    foreach($this->Manager->Modules as $Module)
    288288    {
    289289      // Add missing
     
    291291      {
    292292        if(!array_key_exists($Module->Id, $DbDependency) or
    293         !in_array($this->ModularSystem->Modules[$Dependency]->Id, $DbDependency[$Module->Id]))
     293        !in_array($this->Manager->Modules[$Dependency]->Id, $DbDependency[$Module->Id]))
    294294        $this->Database->insert('SystemModuleDependency', array('Module' => $Module->Id,
    295           'DependencyModule' => $this->ModularSystem->Modules[$Dependency]->Id));       
     295          'DependencyModule' => $this->Manager->Modules[$Dependency]->Id));       
    296296      }
    297297     
     
    300300      foreach($DbDependency[$Module->Id] as $Dep)
    301301      {
    302         $DepModName = $this->ModularSystem->SearchModuleById($Dep);
     302        $DepModName = $this->Manager->SearchModuleById($Dep);
    303303        if(!in_array($DepModName, $Module->Dependencies))
    304304        $this->Database->query('DELETE FROM `SystemModuleDependency` WHERE `Module` = '.
  • branches/Modular/Modules/User/User.php

    r424 r425  
    189189  {
    190190    // Check group-group relation
    191     $DbResult = $this->Database->select('PermissionGroupAssignment', '*', '`Group`="'.$GroupId.'"');
     191    $DbResult = $this->Database->select('PermissionGroupAssignment', '*', '`Group`="'.$GroupId.'" AND (AssignedGroup IS NOT NULL)');
    192192    while($DbRow = $DbResult->fetch_array())
    193193    {
     
    232232
    233233      // Check user-group relation
    234       $DbResult = $this->Database->select('PermissionUserAssignment', 'AssignedGroup', '`User`="'.$this->User['Id'].'"');
     234      $DbResult = $this->Database->select('PermissionUserAssignment', 'AssignedGroup', '`User`="'.$this->User['Id'].'" AND (AssignedGroup IS NOT NULL)');
    235235      while($DbRow = $DbResult->fetch_array())
    236       {
    237        if($this->CheckGroupPermission($DbRow['AssignedGroup'], $OperationId) == true) return(true);
     236      {         
     237         if($this->CheckGroupPermission($DbRow['AssignedGroup'], $OperationId) == true) return(true);
    238238      }
    239239      return(false);
     
    380380  function Start()
    381381  {     
     382    if($this->Running) return;
    382383    parent::Start();
    383384    $this->System->Modules['User']->Models['User'] = new User($this->Database, $this->System);
    384     $thus->System->Modules['User']->Models['User']->AnonymousUserId = ANONYMOUS_ID;
     385    $this->System->Modules['User']->Models['User']->AnonymousUserId = ANONYMOUS_ID;
    385386    $this->System->Pages['uzivatele'] = 'UserListPage';
    386387    if(isset($_SERVER['REMOTE_ADDR'])) $this->System->Modules['User']->Models['User']->Check();   
     
    393394    if(!$Installed)
    394395    {
    395       $this->Database->insert('User', array('Id' => ANONYMOUS_ID, 'Login' => 'Anonymous', 'Name' => 'Anonymous',
    396         'Password' => ''));
     396      //$this->Database->insert('User', array('Id' => ANONYMOUS_ID, 'Login' => 'Anonymous', 'Name' => 'Anonymous',
     397      //  'Password' => ''));
    397398    }
    398399  }
  • branches/Modular/index.php

    r424 r425  
    44/* @var $System System */
    55$System = NULL;
     6/* @var $Database Database */
     7$Database = NULL;
    68GlobalInit();
    79$System->PathItems = ProcessURL();
     
    1113$Page = $System->PathItems[0];
    1214//if(substr($Page, -1) == '/') $Page = substr($Page, 0, -1);
    13 print_r($System->Pages);
     15//print_r($System->Pages);
    1416if(array_key_exists($Page, $System->Pages))
    1517{
     
    1719} else $PageClass = 'MissingPage';
    1820$PageObject = Page::Cast(new $PageClass());
     21//echo('dsds');
    1922$PageObject->Database = &$Database;
    2023$PageObject->System = &$System;
     24//print_r($System->Modules['News']);
    2125$PageObject->GetOutput();
    2226
Note: See TracChangeset for help on using the changeset viewer.