Changeset 425 for branches/Modular
- Timestamp:
- Oct 10, 2012, 12:21:38 PM (12 years ago)
- Location:
- branches/Modular
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Modular/Common/Global.php
r424 r425 86 86 $ModuleSystem = new ModuleSystem($System->Database, $System); 87 87 $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 } 89 94 } 90 95 -
branches/Modular/Common/Module.php
r424 r425 18 18 var $Installed; 19 19 var $Running; 20 var $System; 20 21 /** @var ModularSystem */ 21 var $M odularSystem;22 var $Manager; 22 23 23 24 … … 38 39 // Install dependencies first 39 40 foreach($this->Dependencies as $Dependency) 40 $this->M odularSystem->Modules[$Dependency]->Install();41 $this->Manager->Modules[$Dependency]->Install(); 41 42 $this->DoChange(); 42 43 } … … 68 69 $this->Running = true; 69 70 foreach($this->Dependencies as $Dependency) 70 $this-> System->Modules[$Dependency]->Start();71 $this->Manager->Modules[$Dependency]->Start(); 71 72 $this->LoadModels(); 72 73 $this->DoChange(); … … 86 87 private function DoChange() 87 88 { 88 if($this->M odularSystem->OnModuleChange)89 call_user_func_array($this->M odularSystem->OnModuleChange, array($this));89 if($this->Manager->OnModuleChange) 90 call_user_func_array($this->Manager->OnModuleChange, array($this)); 90 91 } 91 92 … … 102 103 function LoadModels() 103 104 { 105 //echo($this->Name.'... '); 104 106 $this->Models = array(); 105 107 foreach($this->SupportedModels as $ModelName) … … 108 110 $NewModel->Module = &$this; 109 111 $this->Models[$ModelName] = $NewModel; 112 //DebugLog($ModelName.'.LoadModels()'); 110 113 } 111 114 } … … 136 139 } 137 140 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 138 150 function StopAll() 139 151 { … … 187 199 { 188 200 $this->Modules[$Module->Name] = &$Module; 189 $Module->M odularSystem =$this;201 $Module->Manager = &$this; 190 202 $Module->OnChange = &$this->OnModuleChange; 191 203 } … … 224 236 if(array_key_exists($Module->Name, $ModulesOnDisk)) 225 237 { 226 $this->M odularSystem->UnregisterModule($Module);238 $this->Manager->UnregisterModule($Module); 227 239 } 228 240 } -
branches/Modular/Install.php
r424 r425 14 14 foreach($System->Modules as $Module) 15 15 { 16 if($Module->I nstalled) $Actions = '<a href="?a=uninstall&m='.$Module->Name.'">Odinstalovat</td>';16 if($Module->IsInstalled()) $Actions = '<a href="?a=uninstall&m='.$Module->Name.'">Odinstalovat</td>'; 17 17 else $Actions = '<a href="?a=install&m='.$Module->Name.'">Instalovat</td>'; 18 if($Module->I nstalled) $Installed = 'Ano';18 if($Module->IsInstalled()) $Installed = 'Ano'; 19 19 else $Installed = 'Ne'; 20 20 $Deps = implode(', ', $Module->Dependencies); -
branches/Modular/Modules/Finance/Finance.php
r424 r425 451 451 $Cash = $Cash[0]; 452 452 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)'); 454 454 $ConsumptionPlus = $DbResult2->fetch_row(); 455 455 $ConsumptionPlus = $ConsumptionPlus[0]; -
branches/Modular/Modules/Finance/FinanceOverview.php
r377 r425 14 14 $Output .= '<a href="tarify/">Tarify</a><br />'; 15 15 $Output .= '<a href="zarizeni/">Výpis zařízení</a><br />'; 16 if($this->System->Mod els['User']->CheckPermission('Finance', 'SubjectList'))16 if($this->System->Modules['User']->Models['User']->CheckPermission('Finance', 'SubjectList')) 17 17 $Output .= '<a href="clenove/">Seznam členů</a><br />'; 18 18 $Output .= '<a href="spotreba/">Spotřeba energie</a><br />'; … … 60 60 $TotalGain = 0; 61 61 $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'); 63 63 $Row = $DbResult->fetch_array(); 64 64 $TotalConsumption = $this->System->Modules['Finance']->W2Kc($Row[0]); -
branches/Modular/Modules/Finance/MonthlyOverall.php
r377 r425 21 21 $Month['Administration'].'</td><td align="center">'.$Month['AdministrationTotal']. 22 22 '</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']. 24 24 '</td><td align="center">'.round($Month['TotalPaid'] / $Month['MemberCount']). 25 25 '</td><td align="center">'.$Month['Investment'].'</td></tr>'; -
branches/Modular/Modules/FrontPage/FrontPage.php
r424 r425 171 171 { 172 172 $UserOptions = new UserOptionsView($this->Database); 173 print_r($this->System); 173 174 $UserOptions->LoadValuesFromDatabase($this->System->Modules['User']->Models['User']->User['Id']); 174 175 $UserOptions->OnSubmit = '?Action=UserOptionsSave'; … … 297 298 if(($Panel['Module'] == 'Webcam') and (array_key_exists('WebCam', $this->System->Modules))) 298 299 $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>')); 300 302 } 301 303 $Output .= '</td>'; -
branches/Modular/Modules/News/News.php
r424 r425 148 148 else $Author = $Row['Name']; 149 149 $Output .= '<tr><td onclick="window.location=\'aktuality/?action=view&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']); 151 151 if($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>'; 152 152 -
branches/Modular/Modules/System/System.php
r424 r425 205 205 parent::Start(); 206 206 $this->System->Pages['module'] = 'PageModules'; 207 $this->M odularSystem->OnModuleChange = array($this, 'ModuleChange');207 $this->Manager->OnModuleChange = array($this, 'ModuleChange'); 208 208 $this->LoadFromDatabase(); 209 209 } … … 224 224 function ModuleChange($Module) 225 225 { 226 if($this->IsInstalled())227 { 228 if($Module->I nstalled)226 //if($this->IsInstalled()) 227 { 228 if($Module->IsInstalled()) 229 229 $this->Database->query('UPDATE `SystemModule` SET `Installed`=1 WHERE `Name`="'.$Module->Name.'"'); 230 230 else $this->Database->query('UPDATE `SystemModule` SET `Installed`=0 WHERE `Name`="'.$Module->Name.'"'); … … 243 243 include_once('Modules/'.$Module['Name'].'/'.$Module['Name'].'.php'); 244 244 $ModuleClassName = 'Module'.$Module['Name']; 245 $NewModule = new $ModuleClassName($this->Database, $this );245 $NewModule = new $ModuleClassName($this->Database, $this->Manager); 246 246 $NewModule->Id = $Module['Id']; 247 247 $NewModule->Installed = $Module['Installed']; 248 $this->M odularSystem->RegisterModule($NewModule);248 $this->Manager->RegisterModule($NewModule); 249 249 } 250 250 } … … 258 258 259 259 // Add missing 260 foreach($this->M odularSystem->Modules as $Module)260 foreach($this->Manager->Modules as $Module) 261 261 { 262 262 if(!array_key_exists($Module->Name, $Modules)) … … 273 273 // Remove exceeding 274 274 foreach($Modules as $Module) 275 if(!$this->M odularSystem->ModulePresent($Module['Name']))275 if(!$this->Manager->ModulePresent($Module['Name'])) 276 276 { 277 277 DebugLog('Removing module '.$Module['Name'].' from list'); … … 285 285 $DbDependency[$DbRow['Module']][] = $DbRow['DependencyModule']; 286 286 287 foreach($this->M odularSystem->Modules as $Module)287 foreach($this->Manager->Modules as $Module) 288 288 { 289 289 // Add missing … … 291 291 { 292 292 if(!array_key_exists($Module->Id, $DbDependency) or 293 !in_array($this->M odularSystem->Modules[$Dependency]->Id, $DbDependency[$Module->Id]))293 !in_array($this->Manager->Modules[$Dependency]->Id, $DbDependency[$Module->Id])) 294 294 $this->Database->insert('SystemModuleDependency', array('Module' => $Module->Id, 295 'DependencyModule' => $this->M odularSystem->Modules[$Dependency]->Id));295 'DependencyModule' => $this->Manager->Modules[$Dependency]->Id)); 296 296 } 297 297 … … 300 300 foreach($DbDependency[$Module->Id] as $Dep) 301 301 { 302 $DepModName = $this->M odularSystem->SearchModuleById($Dep);302 $DepModName = $this->Manager->SearchModuleById($Dep); 303 303 if(!in_array($DepModName, $Module->Dependencies)) 304 304 $this->Database->query('DELETE FROM `SystemModuleDependency` WHERE `Module` = '. -
branches/Modular/Modules/User/User.php
r424 r425 189 189 { 190 190 // 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)'); 192 192 while($DbRow = $DbResult->fetch_array()) 193 193 { … … 232 232 233 233 // 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)'); 235 235 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); 238 238 } 239 239 return(false); … … 380 380 function Start() 381 381 { 382 if($this->Running) return; 382 383 parent::Start(); 383 384 $this->System->Modules['User']->Models['User'] = new User($this->Database, $this->System); 384 $th us->System->Modules['User']->Models['User']->AnonymousUserId = ANONYMOUS_ID;385 $this->System->Modules['User']->Models['User']->AnonymousUserId = ANONYMOUS_ID; 385 386 $this->System->Pages['uzivatele'] = 'UserListPage'; 386 387 if(isset($_SERVER['REMOTE_ADDR'])) $this->System->Modules['User']->Models['User']->Check(); … … 393 394 if(!$Installed) 394 395 { 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' => '')); 397 398 } 398 399 } -
branches/Modular/index.php
r424 r425 4 4 /* @var $System System */ 5 5 $System = NULL; 6 /* @var $Database Database */ 7 $Database = NULL; 6 8 GlobalInit(); 7 9 $System->PathItems = ProcessURL(); … … 11 13 $Page = $System->PathItems[0]; 12 14 //if(substr($Page, -1) == '/') $Page = substr($Page, 0, -1); 13 print_r($System->Pages);15 //print_r($System->Pages); 14 16 if(array_key_exists($Page, $System->Pages)) 15 17 { … … 17 19 } else $PageClass = 'MissingPage'; 18 20 $PageObject = Page::Cast(new $PageClass()); 21 //echo('dsds'); 19 22 $PageObject->Database = &$Database; 20 23 $PageObject->System = &$System; 24 //print_r($System->Modules['News']); 21 25 $PageObject->GetOutput(); 22 26
Note:
See TracChangeset
for help on using the changeset viewer.