Skip to content

Commit fcee019

Browse files
committed
Applicaton adapted on latest version of EaseFramework
Added namespaces and composer use.
1 parent a230491 commit fcee019

141 files changed

Lines changed: 4315 additions & 3419 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"psr-4": {
1616
"Icinga\\Editor\\": "src/classes/",
1717
"Icinga\\Editor\\Engine\\": "src/classes/engine/",
18-
"Icinga\\Editor\\UI\\": "src/classes/UI"
18+
"Icinga\\Editor\\UI\\": "src/classes/UI",
19+
"Icinga\\Editor\\modules\\": "src/modules"
1920
}
2021
},
2122
"require-dev": {

debian/bin/iecfgimporter.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env php
22
<?php
3+
4+
namespace Icinga\Editor;
5+
36
/**
47
* Import konfigurace ze souboru
58
*
@@ -11,11 +14,10 @@
1114
chdir('/usr/share/icinga-editor');
1215

1316
require_once 'includes/IEInit.php';
14-
require_once 'classes/IEImporter.php';
1517

1618
$params = array('public' => true, 'generate' => true);
1719

18-
$importer = new IEImporter($params);
20+
$importer = new Engine\IEImporter($params);
1921
$importer->importCfgFile('/etc/icinga/icinga.cfg');
2022

2123
foreach ($importer->files as $cfgFile) {

nbproject/private/private.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
<group name="Monitoring">
1111
<file>file:/home/vitex/Projects/VitexSoftware/iciedit/src/includes/Configure.php</file>
1212
</group>
13-
<group/>
13+
<group>
14+
<file>file:/home/vitex/Projects/VitexSoftware/icinga_configurator/src/classes/UI/WebPage.php</file>
15+
<file>file:/home/vitex/Projects/VitexSoftware/icinga_configurator/src/classes/UI/CfgEditor.php</file>
16+
<file>file:/home/vitex/Projects/VitexSoftware/icinga_configurator/src/classes/UI/MainMenu.php</file>
17+
<file>file:/home/vitex/Projects/VitexSoftware/icinga_configurator/src/service.php</file>
18+
<file>file:/home/vitex/Projects/VitexSoftware/icinga_configurator/src/classes/UI/BootstrapMenu.php</file>
19+
<file>file:/home/vitex/Projects/VitexSoftware/icinga_configurator/src/classes/UI/PageTop.php</file>
20+
<file>file:/home/vitex/Projects/VitexSoftware/icinga_configurator/src/hostgroups.php</file>
21+
</group>
1422
</open-files>
1523
</project-private>

src/apply.php

Lines changed: 54 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Icinga\Editor;
34

45
/**
@@ -21,57 +22,65 @@
2122
$forceUserID = $oPage->getRequestValue('force_user_id', 'int');
2223
if (!is_null($forceUserID)) {
2324
$originalUserID = $oUser->getUserID();
24-
\Ease\Shared::user(new EaseUser($forceUserID));
25+
\Ease\Shared::user(new \Ease\User($forceUserID));
2526
}
2627
}
2728

28-
$fileName = $oUser->getUserLogin() . '.cfg';
29+
$fileName = $oUser->getUserLogin().'.cfg';
2930

30-
$cfg = fopen(constant('CFG_GENERATED') . '/' . $fileName, 'w');
31+
$cfg = fopen(constant('CFG_GENERATED').'/'.$fileName, 'w');
3132
if ($cfg) {
3233
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');
3436
} 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');
3639
}
3740

38-
$generator = new IEImporter();
41+
$generator = new Engine\IEImporter();
3942
$generator->writeConfigs($fileName);
4043

4144
$testing = popen("sudo /usr/sbin/icinga -v /etc/icinga/icinga.cfg", 'r');
4245
if ($testing) {
43-
$errorCount = 0;
44-
$line_num = 0;
46+
$errorCount = 0;
47+
$line_num = 0;
4548
$WarningCount = null;
4649
while (!feof($testing)) {
4750
$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);
4953

5054
$line_num++;
5155

5256
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');
5561
$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'));
5965
break;
6066
}
6167

6268
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']));
6572

6673
$keywords = preg_split("/['(.*)']+/", $line);
6774
switch (trim($keywords[0])) {
6875
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]));
7179
break;
7280
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]));
7584
break;
7685

7786
default:
@@ -83,8 +92,9 @@
8392
switch (trim($keywords[2])) {
8493
case 'specified for contact':
8594
$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]));
8898
break;
8999

90100
default:
@@ -103,9 +113,12 @@
103113

104114
if (strstr($line, 'Error in configuration file')) {
105115

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);
107119

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']));
109122
$errorCount++;
110123
}
111124

@@ -115,29 +128,35 @@
115128
preg_match("/\'(.*)\'/", $line, $keywords);
116129
$host = & $generator->IEClasses['host'];
117130
$host->setmyKeyColumn($host->nameColumn);
118-
$host->loadFromMySql($keywords[1]);
131+
$host->loadFromSQL($keywords[1]);
119132
$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');
121134
} 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);
123138
}
124139

125140
//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']));
127143
}
128144

129145
if (strstr($line, 'Total Warnings')) {
130146
list($msg, $WarningCount) = explode(':', $line);
131147
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');
133150
} else {
134-
$oUser->addStatusMessage(_('test proběhl bez varování'), 'success');
151+
$oUser->addStatusMessage(_('test proběhl bez varování'),
152+
'success');
135153
}
136154
}
137155
if (strstr($line, 'Total Errors')) {
138156
list($msg, $errorCount) = explode(':', $line);
139157
if (intval(trim($errorCount))) {
140-
$oUser->addStatusMessage(sprintf(_('celkem %s chyb'), $errorCount), 'warning');
158+
$oUser->addStatusMessage(sprintf(_('celkem %s chyb'),
159+
$errorCount), 'warning');
141160
} else {
142161
$oUser->addStatusMessage(_('test proběhl bez chyb'), 'success');
143162
}
@@ -146,16 +165,17 @@
146165
fclose($testing);
147166

148167
if (!intval($errorCount) && !is_null($WarningCount)) {
149-
if (IECfg::reloadIcinga()) {
168+
if (IEcfg::reloadIcinga()) {
150169
$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'));
152172
\Ease\Shared::user()->setSettingValue('unsaved', false);
153173
}
154174
}
155175
}
156176

157177
if ($oUser->getSettingValue('admin') && isset($originalUserID)) {
158-
\Ease\Shared::user(new EaseUser($originalUserID));
178+
\Ease\Shared::user(new \Ease\User($originalUserID));
159179
\Ease\Shared::user()->loginSuccess();
160180
}
161181

src/cfgconfirm.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
$hash = $oPage->getRequestValue('hash');
1616

1717
if ($host_id && $hash) {
18-
$host = new IEHost($host_id);
18+
$host = new Engine\IEHost($host_id);
1919
$host->setDataValue('config_hash', $hash);
2020
if ($host->saveToSQL()) {
2121
echo sprintf(_('Konfigurace %s potvrzena'), $host->getName());

src/changepassword.php

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Icinga\Editor;
34

45
/**
@@ -18,7 +19,8 @@
1819
$formOK = false;
1920
} else {
2021
if ($_POST['password'] == $oUser->GetUserLogin()) {
21-
$oUser->addStatusMessage('Heslo se nesmí shodovat s přihlašovacím jménem', 'waring');
22+
$oUser->addStatusMessage('Heslo se nesmí shodovat s přihlašovacím jménem',
23+
'waring');
2224
$formOK = false;
2325
}
2426
/* TODO:
@@ -32,7 +34,8 @@
3234
$oUser->addStatusMessage('Prosím zadejte potvrzení hesla');
3335
$formOK = false;
3436
}
35-
if ((isset($_POST['passwordConfirm']) && isset($_POST['password'])) && ($_POST['passwordConfirm'] != $_POST['password'])) {
37+
if ((isset($_POST['passwordConfirm']) && isset($_POST['password'])) && ($_POST['passwordConfirm']
38+
!= $_POST['password'])) {
3639
$oUser->addStatusMessage('Zadaná hesla se neshodují', 'waring');
3740
$formOK = false;
3841
}
@@ -41,7 +44,8 @@
4144
$oUser->addStatusMessage('Prosím zadejte stávající heslo');
4245
$formOK = false;
4346
} else {
44-
if (!$oUser->PasswordValidation($_POST['CurrentPassword'], $oUser->GetDataValue($oUser->passwordColumn))) {
47+
if (!$oUser->PasswordValidation($_POST['CurrentPassword'],
48+
$oUser->GetDataValue($oUser->passwordColumn))) {
4549
$oUser->AddStatusMessage('Stávající heslo je neplatné', 'warning');
4650
$formOK = false;
4751
}
@@ -57,27 +61,36 @@
5761

5862
$oUser->addStatusMessage(_('Heslo bylo změněno'), 'success');
5963

60-
$email = $oPage->addItem(new EaseMail($oUser->getDataValue($oUser->mailColumn), _('Změněné heslo pro Monitoring')));
61-
$email->addItem(_('Vážený zákazníku vaše přihlašovací údaje byly změněny') . ":\n");
64+
$email = $oPage->addItem(new EaseMail($oUser->getDataValue($oUser->mailColumn),
65+
_('Změněné heslo pro Monitoring')));
66+
$email->addItem(_('Vážený zákazníku vaše přihlašovací údaje byly změněny').":\n");
6267

63-
$email->addItem(' Login: ' . $oUser->getUserLogin() . "\n");
64-
$email->addItem(' Heslo: ' . $plainPass . "\n");
68+
$email->addItem(' Login: '.$oUser->getUserLogin()."\n");
69+
$email->addItem(' Heslo: '.$plainPass."\n");
6570

6671
$email->send();
6772
}
6873
} else {
6974
$loginForm = new \Ease\Html\Form(NULL);
7075

71-
$loginForm->addItem(new EaseLabeledPasswordInput('CurrentPassword', NULL, _('Stávající heslo')));
76+
$loginForm->addItem(new \Ease\TWB\FormGroup(_('Stávající heslo'),
77+
new \Ease\Html\InputPasswordTag('CurrentPassword'), NULL
78+
));
79+
80+
$loginForm->addItem(new \Ease\TWB\FormGroup(_('Nové heslo'),
81+
new \Ease\Html\InputPasswordTag('password'), NULL
82+
));
7283

73-
$loginForm->addItem(new EaseLabeledPasswordStrongInput('password', NULL, _('Nové heslo') . ' *'));
74-
$loginForm->addItem(new EaseLabeledPasswordControlInput('passwordConfirm', NULL, _('potvrzení hesla') . ' *', array('id' => 'confirmation')));
84+
$loginForm->addItem(new \Ease\TWB\FormGroup(_('potvrzení hesla'),
85+
new \Ease\Html\InputPasswordTag('passwordConfirm'), NULL
86+
));
7587

76-
$loginForm->addItem(new \Ease\JQuery\SubmitButton('Ok', 'Změnit heslo'));
88+
$loginForm->addItem(new \Ease\TWB\SubmitButton(_('Změnit heslo')));
7789

7890
$loginForm->fillUp($_POST);
7991

80-
$oPage->columnII->addItem(new \Ease\TWB\Panel(_('změna hesla'), 'default', $loginForm));
92+
$oPage->columnII->addItem(new \Ease\TWB\Panel(_('změna hesla'), 'default',
93+
$loginForm));
8194
}
8295

8396
$oPage->addItem(new UI\PageBottom());

0 commit comments

Comments
 (0)