Changeset 378
- Timestamp:
- Jan 20, 2012, 3:32:02 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Model.php
r377 r378 229 229 if($Property['Type'] == PropertyOneToMany) 230 230 { 231 if(!$this->Module->Models[$Property['TargetModel']]->Installed) 232 $this->Module->Models[$Property['TargetModel']]->Install(); 231 if(array_key_exists($Property['TargetModel'], $this->Module->Models)) 232 { 233 if(!$this->Module->Models[$Property['TargetModel']]->Installed) 234 $this->Module->Models[$Property['TargetModel']]->Install(); 235 } 233 236 $this->Database->query('ALTER TABLE `'.$this->Name.'` ADD FOREIGN KEY (`'.$Property['Name'].'`) REFERENCES `'.$Property['TargetModel'].'` (`Id`);'); 234 237 } … … 238 241 function UnInstall() 239 242 { 240 foreach($ Model->Properties as $Property)243 foreach($this->Properties as $Property) 241 244 { 242 245 if($Property['Type'] == PropertyManyToMany) … … 244 247 } 245 248 $this->Database->query('DROP TABLE IF EXISTS `'.$this->Name.'`'); 249 $this->Installed = false; 246 250 } 247 251 } -
trunk/Common/Module.php
r377 r378 12 12 var $Dependencies; 13 13 var $Models = array(); 14 var $SupportedModels = array(); 14 15 var $Database; 15 16 var $Installed; … … 33 34 $this->System->Modules[$Dependency]->Install(); 34 35 $this->LoadModels(); 35 foreach($this->Models as $ ModelName)36 { 37 $this-> System->Models[$ModelName]->Install();36 foreach($this->Models as $Index => $Module) 37 { 38 $this->Models[$Index]->Install(); 38 39 } 39 40 $this->Database->query('UPDATE SystemModule SET Installed=1 WHERE Name="'.$this->Name.'"'); … … 43 44 { 44 45 DebugLog('Uninstalling module '.$this->Name.'...'); 45 foreach($this->Models as $ModelName) 46 { 47 $Model = new $ModelName($this->Database, $this->System); 48 $Model->UnInstall(); 49 unset($Model); 46 foreach($this->Models as $Index => $Model) 47 { 48 $this->Models[$Index]->UnInstall(); 50 49 } 51 50 $this->Database->query('UPDATE SystemModule SET Installed=0 WHERE Name="'.$this->Name.'"'); 51 $this->Installed = false; 52 52 } 53 53 … … 62 62 function LoadModels() 63 63 { 64 foreach($this->Models as $ModelName) 65 { 66 $this->System->Models[$ModelName] = new $ModelName($this->Database, $this->System); 67 $this->System->Models[$ModelName]->Module = &$this; 64 $this->Models = array(); 65 foreach($this->SupportedModels as $ModelName) 66 { 67 $NewModel = new $ModelName($this->Database, $this->System); 68 $NewModel->Module = &$this; 69 $this->Models[$ModelName] = $NewModel; 68 70 } 69 71 } -
trunk/Modules/Chat/Chat.php
r358 r378 91 91 $this->Description = 'Show history of IRC chat and previous SunriseChat'; 92 92 $this->Dependencies = array(); 93 $this-> Models = array();93 $this->SupportedModels = array(); 94 94 } 95 95 -
trunk/Modules/EmailQueue/EmailQueue.php
r373 r378 27 27 $this->Description = 'Queue for mass email send, log and review.'; 28 28 $this->Dependencies = array('User'); 29 $this-> Models = array('EmailQueue');29 $this->SupportedModels = array('EmailQueue'); 30 30 } 31 31 -
trunk/Modules/Finance/Finance.php
r377 r378 287 287 $this->Description = 'Accounting processing'; 288 288 $this->Dependencies = array('User', 'Subject'); 289 $this-> Models = array('FinanceYear', 'DocumentLine', 'DocumentLineSequence',289 $this->SupportedModels = array('FinanceYear', 'DocumentLine', 'DocumentLineSequence', 290 290 'FinanceTariff', 'FinanceOperation', 'FinanceClaimsLiabilities', 291 291 'FinanceBills', 'FinanceBillsItems', 'FinanceBillingPeriod', 'FinanceCharge', … … 398 398 399 399 $this->SpravaUsers = $this->InternetUsers; 400 $DbResult = $this->Database->query('SELECT SUM(`Consumption`) FROM ` network_segments`');400 $DbResult = $this->Database->query('SELECT SUM(`Consumption`) FROM `NetworkSegments`'); 401 401 $TotalConsumption = $DbResult->fetch_array(); 402 402 $this->TotalConsumption = $TotalConsumption[0]; … … 459 459 while($ID != 0) 460 460 { 461 $DbResult2 = $this->Database->query('SELECT * FROM ` network_segments` WHERE `id`='.$ID);461 $DbResult2 = $this->Database->query('SELECT * FROM `NetworkSegments` WHERE `Id`='.$ID); 462 462 $Device = $DbResult2->fetch_assoc(); 463 $NetworkDevice += $Device[' price'] / $Device['users'];464 $Consumption += $Device[' consumption'] / $Device['users_overheads'];463 $NetworkDevice += $Device['Price'] / $Device['Users']; 464 $Consumption += $Device['Consumption'] / $Device['UsersOverheads']; 465 465 //echo($ID.' '.$InternetSegment.' '.$InternetSegmentId.' '.$Row['inet_hw'].' '.$Price.'<br>'); 466 $ID = $Device[' parent'];466 $ID = $Device['Parent']; 467 467 } 468 468 … … 497 497 { 498 498 $Output = 'Aktualizuji parametry segmentů...<br />'; 499 $this->Database->query('UPDATE ` network_segments` SET `users` = 0, `users_overheads` = 0'); // Vynulovat počty uživatelů500 $DbResult = $this->Database->query('SELECT * FROM ` network_segments`');499 $this->Database->query('UPDATE `NetworkSegments` SET `Users` = 0, `UsersOverheads` = 0'); // Vynulovat počty uživatelů 500 $DbResult = $this->Database->query('SELECT * FROM `NetworkSegments`'); 501 501 while($NetworkSegment = $DbResult->fetch_array()) 502 502 { 503 503 //echo('Segment '.$Row['name'].'<br>'); 504 $DbResult2 = $this->Database->query('SELECT ` users` FROM `network_segments` WHERE `id`='.$NetworkSegment['id']);504 $DbResult2 = $this->Database->query('SELECT `Users` FROM `NetworkSegments` WHERE `Id`='.$NetworkSegment['Id']); 505 505 $RowP = $DbResult2->fetch_array(); 506 $DbResult2 = $this->Database->query('SELECT ` users_overheads` FROM `network_segments` WHERE `id`='.$NetworkSegment['id']);506 $DbResult2 = $this->Database->query('SELECT `UsersOverheads` FROM `NetworkSegments` WHERE `Id`='.$NetworkSegment['Id']); 507 507 $RowP2 = $DbResult2->fetch_array(); 508 508 509 $DbResult2 = $this->Database->query('SELECT SUM( price) as Price, SUM(consumption) as Consumption FROM network_devices WHERE segment='.$NetworkSegment['id'].' AND used=1');509 $DbResult2 = $this->Database->query('SELECT SUM(Price) as Price, SUM(Consumption) as Consumption FROM NetworkDevices WHERE Segment='.$NetworkSegment['id'].' AND Used=1'); 510 510 $Row2 = $DbResult2->fetch_array(); 511 511 $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM Member WHERE NetworkSegment='.$NetworkSegment['id']); 512 512 $Row3 = $DbResult2->fetch_array(); 513 $ID = $NetworkSegment[' parent'];513 $ID = $NetworkSegment['Parent']; 514 514 while($ID != 0) 515 515 { 516 516 //echo($ID.', '); 517 $DbResult2 = $this->Database->query('SELECT * FROM network_segments WHERE id='.$ID);517 $DbResult2 = $this->Database->query('SELECT * FROM NetworkSegments WHERE Id='.$ID); 518 518 $Row4 = $DbResult2->fetch_array(); 519 $this->Database->update(' network_segments', 'id='.$Row4['id'], array('users' => ($Row4['users'] + $Row3[0]), 'users_overheads' => ($Row4['users_overheads'] + $Row3[0])));520 $ID = $Row4[' parent'];519 $this->Database->update('NetworkSegments', 'Id='.$Row4['Id'], array('Users' => ($Row4['Users'] + $Row3[0]), 'UsersOverheads' => ($Row4['UsersOverheads'] + $Row3[0]))); 520 $ID = $Row4['Parent']; 521 521 } 522 $this->Database->update(' network_segments', 'id='.$NetworkSegment['id'], array('price' => $Row2['Price'], 'users' => ($Row3[0] + $RowP['users']), 'consumption' => $Row2['Consumption'], 'users_overheads' => ($Row3[0] + $RowP2['users_overheads'])));522 $this->Database->update('NetworkSegments', 'Id='.$NetworkSegment['Id'], array('Price' => $Row2['Price'], 'Users' => ($Row3[0] + $RowP['Users']), 'Consumption' => $Row2['Consumption'], 'UsersOverheads' => ($Row3[0] + $RowP2['UsersOverheads']))); 523 523 } 524 524 … … 526 526 $DbResult = $this->Database->select('Member', 'COUNT(*)'); 527 527 $Row = $DbResult->fetch_array(); 528 $DbResult = $this->Database->update(' network_segments','id='.$this->InternetSegmentId, array('users' => $Row[0], 'users_overheads' => $Row[0]));528 $DbResult = $this->Database->update('NetworkSegments', 'Id='.$this->InternetSegmentId, array('Users' => $Row[0], 'UsersOverheads' => $Row[0])); 529 529 $this->System->Modules['Log']->NewRecord('Finance', 'RecalculateSegmentParameters'); 530 530 return($Output); -
trunk/Modules/FrontPage/FrontPage.php
r372 r378 362 362 $this->Description = 'Main page of community network portal'; 363 363 $this->Dependencies = array('User', 'News', 'TV', 'Map', 'Chat', 'WebCam'); 364 $this-> Models = array('Hyperlink', 'HyperlinkGroup', 'Panel', 'PanelColumn');364 $this->SupportedModels = array('Hyperlink', 'HyperlinkGroup', 'Panel', 'PanelColumn'); 365 365 } 366 366 -
trunk/Modules/Log/Log.php
r375 r378 92 92 $this->Description = 'Logging of user operations'; 93 93 $this->Dependencies = array('User'); 94 $this-> Models = array('Log');94 $this->SupportedModels = array('Log'); 95 95 } 96 96 -
trunk/Modules/Map/Map.php
r358 r378 148 148 $this->Description = 'Show objects on Google maps'; 149 149 $this->Dependencies = array('Network'); 150 $this-> Models = array();150 $this->SupportedModels = array(); 151 151 } 152 152 -
trunk/Modules/Meals/Meals.php
r358 r378 216 216 $this->Description = 'Module for management meals. Can print week menu.'; 217 217 $this->Dependencies = array('Log'); 218 $this-> Models = array('Meals', 'MealsInfo');218 $this->SupportedModels = array('Meals', 'MealsInfo'); 219 219 } 220 220 -
trunk/Modules/Member/Member.php
r373 r378 59 59 $this->Description = 'Customer and member management'; 60 60 $this->Dependencies = array('User', 'Subject'); 61 $this-> Models = array('Member', 'MemberPayment');61 $this->SupportedModels = array('Member', 'MemberPayment'); 62 62 $this->View = array('MemberOptionsView'); 63 63 } -
trunk/Modules/Network/Network.php
r377 r378 78 78 $this->AddPropertyString('IPv6'); 79 79 $this->AddPropertyString('ExternalIP'); 80 $this->AddPropertyOneToMany('Device', ' Device');80 $this->AddPropertyOneToMany('Device', 'NetworkDevice'); 81 81 $this->AddPropertyBoolean('Online'); 82 82 $this->AddPropertyDateTime('LastOnline'); … … 153 153 } 154 154 } 155 156 class NetworkSegment extends Model 157 { 158 function __construct($Database, $System) 159 { 160 parent::__construct($Database, $System); 161 $this->Name = 'NetworkSegment'; 162 $this->AddPropertyString('Name'); 163 $this->AddPropertyInteger('Price'); 164 $this->AddPropertyOneToMany('Parent', 'NetworkSegment'); 165 $this->AddPropertyInteger('Users'); 166 $this->AddPropertyInteger('Consumption'); 167 $this->AddPropertyInteger('UsersOverheads'); 168 } 169 } 170 155 171 156 172 class EmailView extends ViewForm … … 221 237 $this->Description = 'Network device, interface and interconnection management'; 222 238 $this->Dependencies = array('User', 'Member'); 223 $this->Models = array('NetworkDevice', 'NetworkDeviceType', 'NetworkInterface', 224 'NetworkInterfaceType', 'NetworkPoint', 'NetworkLink', 'NetworkSubnet'); 239 $this->SupportedModels = array('NetworkDevice', 'NetworkDeviceType', 'NetworkInterface', 240 'NetworkInterfaceType', 'NetworkPoint', 'NetworkLink', 'NetworkSubnet', 241 'NetworkSegment'); 225 242 } 226 243 -
trunk/Modules/NetworkLinux/NetworkLinux.php
r369 r378 12 12 $this->Description = 'Network service configuration of Linux server'; 13 13 $this->Dependencies = array('Network'); 14 $this-> Models = array();14 $this->SupportedModels = array(); 15 15 } 16 16 -
trunk/Modules/NetworkRouterOS/NetworkRouterOS.php
r369 r378 12 12 $this->Description = 'Mikrotik RouterOS configuration'; 13 13 $this->Dependencies = array('Network'); 14 $this-> Models = array();14 $this->SupportedModels = array(); 15 15 } 16 16 -
trunk/Modules/NetworkShare/NetworkShare.php
r377 r378 43 43 $this->Description = 'System for loading network computer share file list and allow fast searching.'; 44 44 $this->Dependencies = array('Network'); 45 $this-> Models = array('NetworkShareItem', 'NetworkShareError');45 $this->SupportedModels = array('NetworkShareItem', 'NetworkShareError'); 46 46 } 47 47 -
trunk/Modules/NetworkTopology/NetworkTopology.php
r358 r378 141 141 $this->Description = 'Generate image of network device interconnection'; 142 142 $this->Dependencies = array('Network'); 143 $this-> Models = array();143 $this->SupportedModels = array(); 144 144 } 145 145 -
trunk/Modules/News/News.php
r373 r378 101 101 $this->Description = 'News and news groups management'; 102 102 $this->Dependencies = array('User', 'Log'); 103 $this-> Models = array('News', 'NewsCategory');103 $this->SupportedModels = array('News', 'NewsCategory'); 104 104 $this->Views = array('News'); 105 105 } -
trunk/Modules/OpeningHours/OpeningHours.php
r359 r378 249 249 $this->Description = 'Show subject opening hours with time to open or time to close'; 250 250 $this->Dependencies = array(); 251 $this-> Models = array('SubjectOpenTime', 'SubjectOpenTimeDay');251 $this->SupportedModels = array('SubjectOpenTime', 'SubjectOpenTimeDay'); 252 252 } 253 253 -
trunk/Modules/Project/Project.php
r377 r378 35 35 $this->Description = 'Project and task management'; 36 36 $this->Dependencies = array('User'); 37 $this-> Models = array('Project', 'ProjectComment');37 $this->SupportedModels = array('Project', 'ProjectComment'); 38 38 } 39 39 -
trunk/Modules/Subject/Subject.php
r373 r378 32 32 $this->Description = 'Subject management'; 33 33 $this->Dependencies = array(); 34 $this-> Models = array('Subject');34 $this->SupportedModels = array('Subject'); 35 35 } 36 36 -
trunk/Modules/TV/TV.php
r360 r378 17 17 function ShowChannelList() 18 18 { 19 global $Channels;20 21 19 $Output = 'Stažení přehrávače: <a href="http://www.videolan.org/vlc/">VLC Media Player</a><br/>'. 22 20 'Seznam všech kanálů do přehrávače: <a href="playlist.m3u">Playlist</a><br/>'. … … 25 23 '<div align="center"><strong>Výpis kanálů:</strong><br>'; 26 24 27 $Where =28 25 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `TV` WHERE (`Stream` <> "") OR (`StreamWeb` <> "")'); 29 26 $DbRow = $DbResult->fetch_row(); … … 132 129 $this->Description = 'IPTV channel database management'; 133 130 $this->Dependencies = array(); 134 $this-> Models = array('TV');131 $this->SupportedModels = array('TV'); 135 132 } 136 133 -
trunk/Modules/TimeMeasure/TimeMeasure.php
r373 r378 33 33 $this->Description = 'Time measure or values'; 34 34 $this->Dependencies = array('User'); 35 $this-> Models = array();35 $this->SupportedModels = array(); 36 36 } 37 37 -
trunk/Modules/User/User.php
r377 r378 372 372 $this->Description = 'User management'; 373 373 $this->Dependencies = array(); 374 $this-> Models = array('User', 'UserOnline');374 $this->SupportedModels = array('User', 'UserOnline'); 375 375 $this->Views = array('UserLogin', 'PasswordRecove', 'UserRegister', 'UserOptions', 376 376 'PermissionGroup', 'PermissionOperation', 'PermissionGroupAssignement', -
trunk/Modules/WebCam/WebCam.php
r358 r378 54 54 $this->Description = 'Web camera image presentetation'; 55 55 $this->Dependencies = array(); 56 $this-> Models = array();56 $this->SupportedModels = array(); 57 57 } 58 58
Note:
See TracChangeset
for help on using the changeset viewer.