|
1 | 1 | <?php |
| 2 | + |
2 | 3 | namespace Icinga\Editor; |
3 | 4 |
|
4 | 5 | /** |
|
21 | 22 | $forceUserID = $oPage->getRequestValue('force_user_id', 'int'); |
22 | 23 | if (!is_null($forceUserID)) { |
23 | 24 | $originalUserID = $oUser->getUserID(); |
24 | | - \Ease\Shared::user(new EaseUser($forceUserID)); |
| 25 | + \Ease\Shared::user(new \Ease\User($forceUserID)); |
25 | 26 | } |
26 | 27 | } |
27 | 28 |
|
28 | | -$fileName = $oUser->getUserLogin() . '.cfg'; |
| 29 | +$fileName = $oUser->getUserLogin().'.cfg'; |
29 | 30 |
|
30 | | -$cfg = fopen(constant('CFG_GENERATED') . '/' . $fileName, 'w'); |
| 31 | +$cfg = fopen(constant('CFG_GENERATED').'/'.$fileName, 'w'); |
31 | 32 | if ($cfg) { |
32 | 33 | fclose($cfg); |
33 | | - $oUser->addStatusMessage(sprintf(_('konfigurační soubor %s byl znovu vytvořen'), $fileName), 'success'); |
| 34 | + $oUser->addStatusMessage(sprintf(_('konfigurační soubor %s byl znovu vytvořen'), |
| 35 | + $fileName), 'success'); |
34 | 36 | } else { |
35 | | - $oUser->addStatusMessage(sprintf(_('konfigurační soubor %s nebyl znovu vytvořen'), $fileName), 'warning'); |
| 37 | + $oUser->addStatusMessage(sprintf(_('konfigurační soubor %s nebyl znovu vytvořen'), |
| 38 | + $fileName), 'warning'); |
36 | 39 | } |
37 | 40 |
|
38 | | -$generator = new IEImporter(); |
| 41 | +$generator = new Engine\IEImporter(); |
39 | 42 | $generator->writeConfigs($fileName); |
40 | 43 |
|
41 | 44 | $testing = popen("sudo /usr/sbin/icinga -v /etc/icinga/icinga.cfg", 'r'); |
42 | 45 | if ($testing) { |
43 | | - $errorCount = 0; |
44 | | - $line_num = 0; |
| 46 | + $errorCount = 0; |
| 47 | + $line_num = 0; |
45 | 48 | $WarningCount = null; |
46 | 49 | while (!feof($testing)) { |
47 | 50 | $line = fgets($testing); |
48 | | - $line = preg_replace("/\'([a-zA-Z0-9\.]*)\'/", '<a href="search.php?search=$1">$1</a>', $line); |
| 51 | + $line = preg_replace("/\'([a-zA-Z0-9\.]*)\'/", |
| 52 | + '<a href="search.php?search=$1">$1</a>', $line); |
49 | 53 |
|
50 | 54 | $line_num++; |
51 | 55 |
|
52 | 56 | if (($line === false) && ($line_num == 1)) { |
53 | | - $errorLine = $oPage->container->addItem(new \Ease\Html\Div( '<span class="label label-important">' . _('Chyba:') . '</span>', array('class' => 'alert alert-danger'))); |
54 | | - $oUser->addStatusMessage(_('Kontrola konfigurace nevrátila výsledek.'), 'error'); |
| 57 | + $errorLine = $oPage->container->addItem(new \Ease\Html\Div('<span class="label label-important">'._('Chyba:').'</span>', |
| 58 | + ['class' => 'alert alert-danger'])); |
| 59 | + $oUser->addStatusMessage(_('Kontrola konfigurace nevrátila výsledek.'), |
| 60 | + 'error'); |
55 | 61 | $errorLine->addItem(_('Zkontroluj prosím zdlali nechybí potřebný fragment v /etc/sudoers:')); |
56 | | - $errorLine->addItem(new \Ease\Html\Div( 'User_Alias APACHE = www-data')); |
57 | | - $errorLine->addItem(new \Ease\Html\Div( 'Cmnd_Alias ICINGA = /usr/sbin/icinga, /etc/init.d/icinga')); |
58 | | - $errorLine->addItem(new \Ease\Html\Div( 'APACHE ALL = (ALL) NOPASSWD: ICINGA')); |
| 62 | + $errorLine->addItem(new \Ease\Html\Div('User_Alias APACHE = www-data')); |
| 63 | + $errorLine->addItem(new \Ease\Html\Div('Cmnd_Alias ICINGA = /usr/sbin/icinga, /etc/init.d/icinga')); |
| 64 | + $errorLine->addItem(new \Ease\Html\Div('APACHE ALL = (ALL) NOPASSWD: ICINGA')); |
59 | 65 | break; |
60 | 66 | } |
61 | 67 |
|
62 | 68 | if (strstr($line, 'Error:')) { |
63 | | - $line = str_replace('Error:', '', $line); |
64 | | - $errorLine = $oPage->container->addItem(new \Ease\Html\Div( '<span class="label label-important">' . _('Chyba:') . '</span>', array('class' => 'alert alert-danger'))); |
| 69 | + $line = str_replace('Error:', '', $line); |
| 70 | + $errorLine = $oPage->container->addItem(new \Ease\Html\Div('<span class="label label-important">'._('Chyba:').'</span>', |
| 71 | + ['class' => 'alert alert-danger'])); |
65 | 72 |
|
66 | 73 | $keywords = preg_split("/['(.*)']+/", $line); |
67 | 74 | switch (trim($keywords[0])) { |
68 | 75 | case 'Service notification period': |
69 | | - $errorLine->addItem(' <a href="timeperiods.php">' . _('Notifikační perioda') . '</a> služeb '); |
70 | | - $errorLine->addItem(new \Ease\Html\ATag('timeperiod.php?timeperiod_name=' . $keywords[1], $keywords[1])); |
| 76 | + $errorLine->addItem(' <a href="timeperiods.php">'._('Notifikační perioda').'</a> služeb '); |
| 77 | + $errorLine->addItem(new \Ease\Html\ATag('timeperiod.php?timeperiod_name='.$keywords[1], |
| 78 | + $keywords[1])); |
71 | 79 | break; |
72 | 80 | case 'Host notification period': |
73 | | - $errorLine->addItem(' <a href="timeperiods.php">' . _('Notifikační perioda') . '</a> hostů'); |
74 | | - $errorLine->addItem(new \Ease\Html\ATag('timeperiod.php?timeperiod_name=' . $keywords[1], $keywords[1])); |
| 81 | + $errorLine->addItem(' <a href="timeperiods.php">'._('Notifikační perioda').'</a> hostů'); |
| 82 | + $errorLine->addItem(new \Ease\Html\ATag('timeperiod.php?timeperiod_name='.$keywords[1], |
| 83 | + $keywords[1])); |
75 | 84 | break; |
76 | 85 |
|
77 | 86 | default: |
|
83 | 92 | switch (trim($keywords[2])) { |
84 | 93 | case 'specified for contact': |
85 | 94 | $errorLine->addItem(' specifikovaná pro kontakt '); |
86 | | - $contact = new IEContact($keywords[3]); |
87 | | - $errorLine->addItem(new \Ease\Html\ATag('contact.php?contact_id=' . $contact->getMyKey(), $keywords[3])); |
| 95 | + $contact = new Engine\IEContact($keywords[3]); |
| 96 | + $errorLine->addItem(new \Ease\Html\ATag('contact.php?contact_id='.$contact->getMyKey(), |
| 97 | + $keywords[3])); |
88 | 98 | break; |
89 | 99 |
|
90 | 100 | default: |
|
103 | 113 |
|
104 | 114 | if (strstr($line, 'Error in configuration file')) { |
105 | 115 |
|
106 | | - $line = str_replace('Warning:', '<span class="label label-error">' . _('Chyba v konfiguračním souboru') . '</span>', $line); |
| 116 | + $line = str_replace('Warning:', |
| 117 | + '<span class="label label-error">'._('Chyba v konfiguračním souboru').'</span>', |
| 118 | + $line); |
107 | 119 |
|
108 | | - $oPage->container->addItem(new \Ease\Html\Div( $line, array('class' => 'alert alert-danger'))); |
| 120 | + $oPage->container->addItem(new \Ease\Html\Div($line, |
| 121 | + ['class' => 'alert alert-danger'])); |
109 | 122 | $errorCount++; |
110 | 123 | } |
111 | 124 |
|
|
115 | 128 | preg_match("/\'(.*)\'/", $line, $keywords); |
116 | 129 | $host = & $generator->IEClasses['host']; |
117 | 130 | $host->setmyKeyColumn($host->nameColumn); |
118 | | - $host->loadFromMySql($keywords[1]); |
| 131 | + $host->loadFromSQL($keywords[1]); |
119 | 132 | $host->resetObjectIdentity(); |
120 | | - $line = '<span class="label label-warning">' . _('Varování:') . '</span> Host ' . '<a href="host.php?host_id=' . $host->getMyKey() . '">' . $host->getName() . '</a> ' . _('nemá přiřazené žádné služby'); |
| 133 | + $line = '<span class="label label-warning">'._('Varování:').'</span> Host '.'<a href="host.php?host_id='.$host->getMyKey().'">'.$host->getName().'</a> '._('nemá přiřazené žádné služby'); |
121 | 134 | } else { |
122 | | - $line = str_replace('Warning:', '<span class="label label-warning">' . _('Varování:') . '</span>', $line); |
| 135 | + $line = str_replace('Warning:', |
| 136 | + '<span class="label label-warning">'._('Varování:').'</span>', |
| 137 | + $line); |
123 | 138 | } |
124 | 139 |
|
125 | 140 | //Duplicate definition found for command 'check_ping' (config file '/etc/icinga/generated/command_check_ping_vitex.cfg', starting on line 1) |
126 | | - $oPage->container->addItem(new \Ease\Html\Div( $line, array('class' => 'alert alert-warning'))); |
| 141 | + $oPage->container->addItem(new \Ease\Html\Div($line, |
| 142 | + ['class' => 'alert alert-warning'])); |
127 | 143 | } |
128 | 144 |
|
129 | 145 | if (strstr($line, 'Total Warnings')) { |
130 | 146 | list($msg, $WarningCount) = explode(':', $line); |
131 | 147 | if (intval(trim($WarningCount))) { |
132 | | - $oUser->addStatusMessage(sprintf(_('celkem %s varování'), $WarningCount), 'warning'); |
| 148 | + $oUser->addStatusMessage(sprintf(_('celkem %s varování'), |
| 149 | + $WarningCount), 'warning'); |
133 | 150 | } else { |
134 | | - $oUser->addStatusMessage(_('test proběhl bez varování'), 'success'); |
| 151 | + $oUser->addStatusMessage(_('test proběhl bez varování'), |
| 152 | + 'success'); |
135 | 153 | } |
136 | 154 | } |
137 | 155 | if (strstr($line, 'Total Errors')) { |
138 | 156 | list($msg, $errorCount) = explode(':', $line); |
139 | 157 | if (intval(trim($errorCount))) { |
140 | | - $oUser->addStatusMessage(sprintf(_('celkem %s chyb'), $errorCount), 'warning'); |
| 158 | + $oUser->addStatusMessage(sprintf(_('celkem %s chyb'), |
| 159 | + $errorCount), 'warning'); |
141 | 160 | } else { |
142 | 161 | $oUser->addStatusMessage(_('test proběhl bez chyb'), 'success'); |
143 | 162 | } |
|
146 | 165 | fclose($testing); |
147 | 166 |
|
148 | 167 | if (!intval($errorCount) && !is_null($WarningCount)) { |
149 | | - if (IECfg::reloadIcinga()) { |
| 168 | + if (IEcfg::reloadIcinga()) { |
150 | 169 | $oPage->container->addItem(_('Všechny vaše konfigurační soubory byly přegenerovány')); |
151 | | - $oPage->container->addItem(new \Ease\TWB\LinkButton('main.php', _('Hotovo') . ' ' . \Ease\TWB\Part::GlyphIcon('ok-sign'), 'success')); |
| 170 | + $oPage->container->addItem(new \Ease\TWB\LinkButton('main.php', |
| 171 | + _('Hotovo').' '.\Ease\TWB\Part::GlyphIcon('ok-sign'), 'success')); |
152 | 172 | \Ease\Shared::user()->setSettingValue('unsaved', false); |
153 | 173 | } |
154 | 174 | } |
155 | 175 | } |
156 | 176 |
|
157 | 177 | if ($oUser->getSettingValue('admin') && isset($originalUserID)) { |
158 | | - \Ease\Shared::user(new EaseUser($originalUserID)); |
| 178 | + \Ease\Shared::user(new \Ease\User($originalUserID)); |
159 | 179 | \Ease\Shared::user()->loginSuccess(); |
160 | 180 | } |
161 | 181 |
|
|
0 commit comments