Skip to content
This repository
Browse code

Allow one to disable components

  • Loading branch information...
commit dcb0e9de8738939d5ceb67c1dabf75e8e8c2240f 1 parent 6a2cae0
Barry O'Donovan barryo authored
7 application/configs/application.ini.dist
@@ -36,6 +36,13 @@ cmd.dot = "/usr/bin/dot"
36 36 utilsClass = 'OSS_NOCtools_Utils'
37 37
38 38
  39 +;; Selectivily disable components you do not want by setting to false
  40 +controller.asterisk.enabled = true
  41 +controller.cdp.enabled = true
  42 +controller.stp.enabled = true
  43 +controller.vlan.enabled = true
  44 +
  45 +
39 46 [production : user]
40 47
41 48 ; Use minified CSS / JS
22 application/controllers/AsteriskController.php
@@ -48,16 +48,16 @@ public function indexAction()
48 48 private function _timeticksToString( $tt )
49 49 {
50 50 $secs = floor( $tt / 100 );
51   -
  51 +
52 52 $days = floor( $secs / 60 / 60 / 24 );
53 53 $secs -= $days * 60 * 60 * 24;
54   -
  54 +
55 55 $hrs = floor( $secs / 60 / 60 );
56 56 $secs -= $hrs * 60 * 60;
57   -
  57 +
58 58 $mins = floor( $secs / 60 );
59 59 $secs -= $mins * 60;
60   -
  60 +
61 61 return sprintf( "%d days, %02d:%02d:%02d", $days, $hrs, $mins, $secs );
62 62 }
63 63
@@ -71,25 +71,25 @@ public function ajaxGetForHostAction()
71 71 if( $host )
72 72 {
73 73 $device = new \OSS_SNMP\SNMP( $host, $this->_options['community'] );
74   -
  74 +
75 75 $details['astVersion'] = $device->useAsterisk()->version();
76 76 $details['astTag'] = $device->useAsterisk()->tag();
77   -
  77 +
78 78 $details['astUptime'] = $this->_timeticksToString( $device->useAsterisk()->uptime() );
79 79 $details['astReload'] = $this->_timeticksToString( $device->useAsterisk()->reloadTime() );
80   -
  80 +
81 81 $details['astCallsProcessed'] = $device->useAsterisk()->callsProcessed();
82 82 $details['astCallsActive'] = $device->useAsterisk()->callsActive();
83   -
  83 +
84 84 $details['calls'] = $device->useAsterisk_Channels()->channelDetails( true );
85   -
  85 +
86 86 unset( $device );
87   -
  87 +
88 88 $this->getResponse()
89 89 ->setHeader('Content-Type', 'application/json')
90 90 ->setBody( Zend_Json::encode( $details ) )
91 91 ->sendResponse();
92   -
  92 +
93 93 exit( 0 );
94 94 }
95 95 }
1  application/views/index/index.phtml
@@ -13,6 +13,7 @@
13 13 </p>
14 14 </div>
15 15
  16 +{OSS_Message}
16 17
17 18 <div class="row-fluid">
18 19
32 application/views/menu.phtml
@@ -8,18 +8,26 @@
8 8 <li {if $controller eq 'index'}class="active"{/if}>
9 9 <a href="{genUrl}">Home</a>
10 10 </li>
11   - <li {if $controller eq 'asterisk'}class="active"{/if}>
12   - <a href="{genUrl controller="asterisk"}">Asterisk</a>
13   - </li>
14   - <li {if $controller eq 'cdp'}class="active"{/if}>
15   - <a href="{genUrl controller="cdp"}">CDP</a>
16   - </li>
17   - <li {if $controller eq 'stp'}class="active"{/if}>
18   - <a href="{genUrl controller="stp"}">STP</a>
19   - </li>
20   - <li {if $controller eq 'vlan'}class="active"{/if}>
21   - <a href="{genUrl controller="vlan"}">VLAN</a>
22   - </li>
  11 + {if !isset( $options.controller.asterisk.enabled ) or $options.controller.asterisk.enabled}
  12 + <li {if $controller eq 'asterisk'}class="active"{/if}>
  13 + <a href="{genUrl controller="asterisk"}">Asterisk</a>
  14 + </li>
  15 + {/if}
  16 + {if !isset( $options.controller.cdp.enabled ) or $options.controller.cdp.enabled}
  17 + <li {if $controller eq 'cdp'}class="active"{/if}>
  18 + <a href="{genUrl controller="cdp"}">CDP</a>
  19 + </li>
  20 + {/if}
  21 + {if !isset( $options.controller.stp.enabled ) or $options.controller.stp.enabled}
  22 + <li {if $controller eq 'stp'}class="active"{/if}>
  23 + <a href="{genUrl controller="stp"}">STP</a>
  24 + </li>
  25 + {/if}
  26 + {if !isset( $options.controller.vlan.enabled ) or $options.controller.vlan.enabled}
  27 + <li {if $controller eq 'vlan'}class="active"{/if}>
  28 + <a href="{genUrl controller="vlan"}">VLAN</a>
  29 + </li>
  30 + {/if}
23 31 </ul>
24 32 </div>
25 33 </div>
10 library/OSS/Controller/Action.php
@@ -168,10 +168,18 @@ public function __construct(
168 168 if( is_readable( APPLICATION_PATH . '/configs/devices.ini' ) )
169 169 {
170 170 $this->_devices = new Zend_Config_Ini( APPLICATION_PATH . '/configs/devices.ini' );
171   -
  171 +
172 172 $this->view->devices_ini = $this->_devices;
173 173 $this->view->_devices = $this->_devices->devices;
174 174 }
  175 +
  176 + // make sure the controller is enabled
  177 + if( isset( $this->_options['controller'][$this->_controller]['enabled'] ) && !$this->_options['controller'][$this->_controller]['enabled'] )
  178 + {
  179 + $this->addMessage( 'The requested component has been disabled by the administrator.', OSS_Message::ERROR );
  180 + $this->_redirect();
  181 + die();
  182 + }
175 183 }
176 184
177 185

0 comments on commit dcb0e9d

Please sign in to comment.
Something went wrong with that request. Please try again.