source: trunk/Modules/NetworkConfig/NetworkConfig.php@ 781

Last change on this file since 781 was 781, checked in by chronos, 9 years ago
  • Modified: Network configure actions now can be executed through cmd.php interface using "php cmd.php config <action>".
File size: 2.7 KB
Line 
1<?php
2
3class ModuleNetworkConfig extends AppModule
4{
5 var $ConfigItems;
6
7 function __construct($System)
8 {
9 parent::__construct($System);
10 $this->Name = 'NetworkConfig';
11 $this->Version = '1.0';
12 $this->Creator = 'Chronos';
13 $this->License = 'GNU/GPL';
14 $this->Description = 'Network device remote configuration';
15 $this->Dependencies = array('Network');
16 $this->ConfigItems = array();
17 }
18
19 function DoInstall()
20 {
21 }
22
23 function DoUnInstall()
24 {
25 }
26
27 function DoStart()
28 {
29 $this->System->FormManager->RegisterClass('NetworkConfiguration', array(
30 'Title' => 'Restart síťových služeb',
31 'Table' => 'NetworkConfiguration',
32 'Items' => array(
33 'Caption' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
34 'Execute' => array('Type' => 'String', 'Caption' => 'Povely', 'Default' => ''),
35 'Changed' => array('Type' => 'TNetworkConfigurationState', 'Caption' => 'Stav', 'Default' => 0),
36 'LastTime' => array('Type' => 'DateTime', 'Caption' => 'Naposledy spuštěno', 'ReadOnly' => true),
37 'ExecutionTime' => array('Type' => 'Integer', 'Caption' => 'Doba běhu', 'Default' => '0', 'Suffix' => 'sekund', 'ReadOnly' => true),
38 'Enabled' => array('Type' => 'Boolean', 'Caption' => 'Povoleno', 'Default' => '0'),
39 'Period' => array('Type' => 'Integer', 'Caption' => 'Min. perioda', 'Default' => '60', 'Suffix' => 'sekund'),
40 ),
41 'ItemActions' => array(
42 array('Caption' => 'Záznam', 'URL' => '/is/?a=view&t=NetworkConfigurationLog&i=#RowId'),
43 ),
44 ));
45 $this->System->FormManager->RegisterClass('NetworkConfigurationLog', array(
46 'Title' => 'Záznam restartu síťových služeb',
47 'Table' => 'NetworkConfiguration',
48 'Items' => array(
49 'Caption' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''),
50 'Log' => array('Type' => 'Text', 'Caption' => 'Záznam', 'Default' => '', 'ReadOnly' => true),
51 ),
52 ));
53 $this->System->RegisterCommandLine('config', array($this, 'Config'));
54 }
55
56 function RegisterConfigItem($Name, $ClassName)
57 {
58 $this->ConfigItems[$Name] = $ClassName;
59 }
60
61 function UnregisterConfigItem($Name)
62 {
63 unset($this->ConfigItems[$Name]);
64 }
65
66 function Config($Parameters)
67 {
68 $Output = '';
69 if($Parameters >= 3)
70 {
71 $ConfigItemName = $Parameters[2];
72 if(array_key_exists($ConfigItemName, $this->ConfigItems))
73 {
74 $ClassName = $this->ConfigItems[$ConfigItemName];
75 $ConfigItem = new $ClassName($this->System);
76 $ConfigItem->Run();
77 } else $Output = 'Config item '.$ConfigItemName.' not found';
78 } else $Output = 'Not enough parameters';
79 return($Output);
80 }
81}
82
83class NetworkConfigItem extends Model
84{
85 function Run()
86 {
87
88 }
89}
Note: See TracBrowser for help on using the repository browser.