api.onumaster.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <?php
  2. /**
  3. * Class for managing ONU/ONT.
  4. * Change/Add/Delete description. Only for BDCOM.
  5. * Reboot ONU. Only for BDCOM.
  6. * Registering ONU/ONT GePON + GPON. Only for ZTE.
  7. */
  8. class OnuMaster {
  9. /**
  10. * Placeholder for OnuDescribe class
  11. *
  12. * @var object
  13. */
  14. public $describe = '';
  15. /**
  16. * Placeholder for OnuReboot class
  17. *
  18. * @var object
  19. */
  20. public $reboot = '';
  21. /**
  22. * Placeholder for OnuDlp class
  23. *
  24. * @var object
  25. */
  26. public $dlp = '';
  27. /**
  28. * Placeholder for OnuElp class
  29. *
  30. * @var object
  31. */
  32. public $elp = '';
  33. /**
  34. * Placeholder for OnuDeregister class
  35. *
  36. * @var object
  37. */
  38. public $deregister = '';
  39. /**
  40. * Placeholder for OnuDelete class
  41. *
  42. * @var object
  43. */
  44. public $delete = '';
  45. /**
  46. * Flag to determine if a particular user has an attached ONU actually
  47. *
  48. * @var bool
  49. */
  50. public $userHasONU = false;
  51. /**
  52. * Flag to determine if at least one of the ONU actions is enabled
  53. * Must be set to false with any of available actions/options.
  54. *
  55. * @var bool
  56. */
  57. public $noActionsEnabled = true;
  58. /**
  59. * Contains system alter config as key=>value
  60. *
  61. * @var array
  62. */
  63. protected $altCfg = array();
  64. /**
  65. * System messages helper placeholder
  66. *
  67. * @var object
  68. */
  69. protected $messages = '';
  70. /**
  71. * Base constructor for class
  72. *
  73. * @return void
  74. */
  75. public function __construct($login) {
  76. $this->initMessages();
  77. $this->loadAlter();
  78. $tmpBaseONU = new OnuBase($login);
  79. $onuData = $tmpBaseONU->getDataONU();
  80. if ($this->altCfg['ONUAUTO_CONFIG_DESCRIBE']) {
  81. $this->describe = new OnuDescribe($login);
  82. $this->noActionsEnabled = false;
  83. }
  84. if ($this->altCfg['ONUAUTO_CONFIG_REBOOT']) {
  85. $this->reboot = new OnuReboot($login);
  86. $this->noActionsEnabled = false;
  87. }
  88. if ($this->altCfg['ONUAUTO_CONFIG_DLP']) {
  89. $this->dlp = new OnuDlp($login);
  90. $this->noActionsEnabled = false;
  91. }
  92. if ($this->altCfg['ONUAUTO_CONFIG_ELP']) {
  93. $this->elp = new OnuElp($login);
  94. $this->noActionsEnabled = false;
  95. }
  96. if (isset($this->altCfg['ONUAUTO_CONFIG_DEREGISTER']) and $this->altCfg['ONUAUTO_CONFIG_DEREGISTER']) {
  97. $this->deregister = new OnuDeregister($login);
  98. $this->noActionsEnabled = false;
  99. }
  100. if (isset($this->altCfg['ONUAUTO_CONFIG_DELETE']) and $this->altCfg['ONUAUTO_CONFIG_DELETE']) {
  101. $this->delete = new OnuDelete($login);
  102. $this->noActionsEnabled = false;
  103. }
  104. $this->userHasONU = (!empty($onuData));
  105. }
  106. /**
  107. * Initializes the messages object.
  108. *
  109. * @return void
  110. */
  111. protected function initMessages() {
  112. $this->messages = new UbillingMessageHelper();
  113. }
  114. /**
  115. * load alter.ini config
  116. *
  117. * @return void
  118. */
  119. protected function loadAlter() {
  120. global $ubillingConfig;
  121. $this->altCfg = $ubillingConfig->getAlter();
  122. }
  123. /**
  124. * Renders main window for managing ONU.
  125. *
  126. * @param $login
  127. *
  128. * @throws Exception
  129. */
  130. public function renderMain($login) {
  131. $windowContents = '';
  132. if (!empty($login)) {
  133. if ($this->noActionsEnabled) {
  134. $windowContents .= $this->messages->getStyledMessage(__('Seems no options for describe, reboot, deregister or delete actions are enabled. Check ONUAUTO_CONFIG_* options statuses in alter.ini.'), 'warning');
  135. }
  136. if ($this->userHasONU) {
  137. if ($this->altCfg['ONUAUTO_CONFIG_DESCRIBE']) {
  138. $windowContents .= $this->describe->DescribeForm($login) . wf_delimiter(0);
  139. }
  140. if ($this->altCfg['ONUAUTO_CONFIG_DLP']) {
  141. $windowContents .= $this->dlp->dlpForm() . wf_delimiter(0);
  142. }
  143. if ($this->altCfg['ONUAUTO_CONFIG_ELP']) {
  144. $windowContents .= $this->elp->elpForm() . wf_delimiter(0);
  145. }
  146. if ($this->altCfg['ONUAUTO_CONFIG_REBOOT']) {
  147. $windowContents .= $this->reboot->rebootForm() . wf_delimiter(0);
  148. }
  149. if (isset($this->altCfg['ONUAUTO_CONFIG_DEREGISTER']) and $this->altCfg['ONUAUTO_CONFIG_DEREGISTER']) {
  150. $windowContents .= $this->deregister->deregForm() . wf_delimiter(0);
  151. }
  152. if (isset($this->altCfg['ONUAUTO_CONFIG_DELETE']) and $this->altCfg['ONUAUTO_CONFIG_DELETE']) {
  153. $windowContents .= $this->delete->delForm() . wf_delimiter(0);
  154. }
  155. } else {
  156. $windowContents .= $this->messages->getStyledMessage(__('User has no ONU assigned'), 'error');
  157. }
  158. show_window(__('ONU operations for login') . ':' . wf_nbsp(2) . $login, $windowContents);
  159. show_window('', web_UserControls($login));
  160. }
  161. }
  162. }