Skip to content

Commit 78fedee

Browse files
committed
Importer is now able import initial configuration
1 parent 3137d10 commit 78fedee

7 files changed

+146
-12
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
use Phinx\Migration\AbstractMigration;
4+
5+
class NormalCheckInterval extends AbstractMigration
6+
{
7+
/**
8+
* Change Method.
9+
*
10+
* Write your reversible migrations using this method.
11+
*
12+
* More information on writing migrations is available here:
13+
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
14+
*
15+
* Remember to call "create()" or "update()" and NOT "save()" when working
16+
* with the Table class.
17+
*/
18+
public function change()
19+
{
20+
$table = $this->table('service');
21+
$table
22+
->addColumn('normal_check_interval', 'boolean', ['null' => true,'default'=>60])
23+
->addColumn('retry_check_interval', 'boolean', ['null' => true,'default'=>60])
24+
25+
->update();
26+
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
use Phinx\Migration\AbstractMigration;
4+
5+
class BiggerNotifOpts extends AbstractMigration {
6+
7+
/**
8+
* Change Method.
9+
*
10+
* Write your reversible migrations using this method.
11+
*
12+
* More information on writing migrations is available here:
13+
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
14+
*
15+
* Remember to call "create()" or "update()" and NOT "save()" when working
16+
* with the Table class.
17+
*/
18+
public function change() {
19+
20+
//set sql_mode = 'STRICT_ALL_TABLES';
21+
22+
// $this->getAdapter()->execute('SET sql_mode="STRICT_ALL_TABLES"');
23+
//
24+
// $hostgroup = $this->table('service');
25+
// $hostgroup->changeColumn('notification_options', 'string', ['limit' => 10])
26+
// ->save();
27+
}
28+
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
use Phinx\Migration\AbstractMigration;
4+
5+
class DefaultPublic extends AbstractMigration {
6+
7+
/**
8+
* Change Method.
9+
*
10+
* Write your reversible migrations using this method.
11+
*
12+
* More information on writing migrations is available here:
13+
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
14+
*
15+
* Remember to call "create()" or "update()" and NOT "save()" when working
16+
* with the Table class.
17+
*/
18+
public function change() {
19+
$service = $this->table('service');
20+
$service->changeColumn('public', 'boolean', ['default' => false])
21+
->save();
22+
$command = $this->table('command');
23+
$command->changeColumn('public', 'boolean', ['default' => false])
24+
->save();
25+
$contact = $this->table('contact');
26+
$contact->changeColumn('public', 'boolean', ['default' => false])
27+
->save();
28+
$host = $this->table('host');
29+
$host->changeColumn('public', 'boolean', ['default' => false])
30+
->save();
31+
$script = $this->table('script');
32+
$script->changeColumn('public', 'boolean', ['default' => false])
33+
->save();
34+
$tp = $this->table('timperiod');
35+
$tp->changeColumn('public', 'boolean', ['default' => false])
36+
->save();
37+
}
38+
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
use Phinx\Migration\AbstractMigration;
4+
5+
class HostgroupBgimageDef extends AbstractMigration
6+
{
7+
/**
8+
* Change Method.
9+
*
10+
* Write your reversible migrations using this method.
11+
*
12+
* More information on writing migrations is available here:
13+
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
14+
*
15+
* Remember to call "create()" or "update()" and NOT "save()" when working
16+
* with the Table class.
17+
*/
18+
public function change()
19+
{
20+
$hg = $this->table('hostgroup');
21+
$hg->removeColumn('bgimages')
22+
->save();
23+
}
24+
}

debian/sql/install/mysql

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ CREATE TABLE IF NOT EXISTS `contact` (
4141
`service_notifications_enabled` tinyint(1) DEFAULT NULL,
4242
`host_notification_period` varchar(64) COLLATE utf8_czech_ci DEFAULT NULL,
4343
`service_notification_period` varchar(64) COLLATE utf8_czech_ci DEFAULT NULL,
44-
`host_notification_options` varchar(6) COLLATE utf8_czech_ci DEFAULT NULL,
45-
`service_notification_options` varchar(7) COLLATE utf8_czech_ci DEFAULT NULL,
44+
`host_notification_options` varchar(10) COLLATE utf8_czech_ci DEFAULT NULL,
45+
`service_notification_options` varchar(10) COLLATE utf8_czech_ci DEFAULT NULL,
4646
`host_notification_commands` varchar(255) COLLATE utf8_czech_ci DEFAULT NULL,
4747
`service_notification_commands` varchar(255) COLLATE utf8_czech_ci DEFAULT NULL,
4848
`email` varchar(128) COLLATE utf8_czech_ci DEFAULT NULL,
@@ -156,7 +156,7 @@ CREATE TABLE IF NOT EXISTS `host` (
156156
`notification_interval` tinyint(3) DEFAULT NULL,
157157
`first_notification_delay` tinyint(3) DEFAULT NULL,
158158
`notification_period` varchar(64) COLLATE utf8_czech_ci DEFAULT NULL,
159-
`notification_options` varchar(5) COLLATE utf8_czech_ci DEFAULT NULL,
159+
`notification_options` varchar(20) COLLATE utf8_czech_ci DEFAULT NULL,
160160
`notifications_enabled` tinyint(1) DEFAULT NULL,
161161
`stalking_options` varchar(3) COLLATE utf8_czech_ci DEFAULT NULL,
162162
`notes` text COLLATE utf8_czech_ci,
@@ -275,7 +275,7 @@ CREATE TABLE IF NOT EXISTS `service` (
275275
`notification_interval` tinyint(3) DEFAULT NULL,
276276
`first_notification_delay` tinyint(3) DEFAULT NULL,
277277
`notification_period` varchar(64) COLLATE utf8_czech_ci DEFAULT NULL,
278-
`notification_options` varchar(6) COLLATE utf8_czech_ci DEFAULT NULL,
278+
`notification_options` varchar(20) COLLATE utf8_czech_ci DEFAULT NULL,
279279
`notifications_enabled` tinyint(1) DEFAULT NULL,
280280
`contacts` varchar(255) COLLATE utf8_czech_ci DEFAULT NULL,
281281
`contact_groups` varchar(255) COLLATE utf8_czech_ci DEFAULT NULL,

src/classes/engine/Configurator.php

+21-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Správce konfigurace
55
*
66
* @author Vitex <vitex@hippy.cz>
7-
* @copyright 2012 Vitex@hippy.cz (G)
7+
* @copyright 2012-2020 Vitex@hippy.cz (G)
88
*/
99

1010
namespace Icinga\Editor\Engine;
@@ -799,12 +799,6 @@ public function saveToSQL($data = null, $searchForID = false) {
799799
}
800800
}
801801

802-
if (array_key_exists('use', $data) && ($this->getPdo()->getAttribute(\PDO::ATTR_DRIVER_NAME) == 'mysql')) {
803-
$use = $data['use'];
804-
unset($data['use']);
805-
$data['`use`'] = $use;
806-
}
807-
808802
$result = parent::saveToSQL($data, $searchForID);
809803
if (!is_null($result) && (get_class($this->user) == 'Icinga\Editor\User')) {
810804
Shared::user()->setSettingValue('unsaved', true);
@@ -815,6 +809,26 @@ public function saveToSQL($data = null, $searchForID = false) {
815809
return $result;
816810
}
817811

812+
/**
813+
* Insert record to SQL database.
814+
*
815+
* @param array $data
816+
*
817+
* @return int|null id of new row in database
818+
*/
819+
public function insertToSQL($data = null) {
820+
if (is_null($data)) {
821+
$data = $this->getData();
822+
}
823+
if (array_key_exists('use', $data) && ($this->getPdo()->getAttribute(\PDO::ATTR_DRIVER_NAME) == 'mysql')) {
824+
$use = $data['use'];
825+
unset($data['use']);
826+
$data['`use`'] = $use;
827+
}
828+
829+
return parent::insertToSQL($data);
830+
}
831+
818832
/**
819833
* Načte z MySQL data k aktuálnímu $ItemID
820834
*

src/iecfgimporter

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ if (isset($argv[2])) {
3636
$public = boolval($argv[2]);
3737
}
3838

39-
$params = ['public' => $public, 'generate' => true, 'user_id' => $owner,'platform'=>'generic','autocfg'=>false];
39+
$params = ['public' => $public, 'generate' => true, 'user_id' => $owner];
4040

4141
$importer = new Engine\Importer($params);
4242
$importer->importCfgPath($cfgFile);

0 commit comments

Comments
 (0)