From 2cbfca2cdd374aff406edb74df994db95f2267b8 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 9 Dec 2021 13:51:20 +0100 Subject: [PATCH 1/6] mr rev + timap_sites --- pandora_console/extras/mr/51.sql | 43 +++++++++++-------- .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 9 ++++ pandora_console/pandoradb.sql | 12 ++++++ 3 files changed, 45 insertions(+), 19 deletions(-) diff --git a/pandora_console/extras/mr/51.sql b/pandora_console/extras/mr/51.sql index 3398bed0c3..479305227d 100644 --- a/pandora_console/extras/mr/51.sql +++ b/pandora_console/extras/mr/51.sql @@ -12,31 +12,39 @@ ALTER TABLE `tpolicy_modules` ADD COLUMN `percentage_critical` tinyint(1) UNSIGN ALTER TABLE tagente_modulo MODIFY debug_content TEXT; CREATE TABLE IF NOT EXISTS `talert_calendar` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(100) NOT NULL default '', - `id_group` INT(10) NOT NULL DEFAULT 0, - `description` text, - PRIMARY KEY (`id`), - UNIQUE (`name`) + `id_group` INT(10) NOT NULL DEFAULT 0, + `description` text, + PRIMARY KEY (`id`), + UNIQUE (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -INSERT IGNORE INTO `talert_calendar` VALUES (1, 'Default', 0, 'Default calendar'); - CREATE TABLE IF NOT EXISTS `tipam_network_location` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(100) NOT NULL default '', - PRIMARY KEY (`id`), - UNIQUE (`name`) + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(100) NOT NULL default '', + PRIMARY KEY (`id`), + UNIQUE (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `tipam_sites` ( + `id` serial, + `name` varchar(100) UNIQUE NOT NULL default '', + `description` text, + `parent` bigint unsigned null, + PRIMARY KEY (`id`), + FOREIGN KEY (`parent`) REFERENCES `tipam_sites`.`id` ON UPDATE CASCADE ON DELETE SET NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -INSERT IGNORE INTO `tipam_network_location` (`name`) SELECT `location` FROM `tipam_network` WHERE `location` <> ''; -UPDATE `tipam_network` INNER JOIN `tipam_network_location` ON tipam_network_location.name=tipam_network.location SET tipam_network.location=tipam_network_location.id; ALTER TABLE `tipam_network` MODIFY `location` int(10) unsigned NULL; ALTER TABLE `tipam_network` ADD FOREIGN KEY (`location`) REFERENCES `tipam_network_location`(`id`) ON DELETE CASCADE; - +ALTER TABLE `tagent_repository` ADD COLUMN `deployment_timeout` INT UNSIGNED DEFAULT 600 AFTER `path`; ALTER TABLE `talert_special_days` ADD COLUMN `id_calendar` int(10) unsigned NOT NULL DEFAULT 1; ALTER TABLE `talert_special_days` ADD COLUMN `day_code` tinyint(2) unsigned NOT NULL DEFAULT 0; +ALTER TABLE `talert_special_days` DROP COLUMN `same_day`; +ALTER TABLE `talert_special_days` ADD FOREIGN KEY (`id_calendar`) REFERENCES `talert_calendar`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; +INSERT IGNORE INTO `talert_calendar` VALUES (1, 'Default', 0, 'Default calendar'); UPDATE `talert_special_days` set `day_code` = 1 WHERE `same_day` = 'monday'; UPDATE `talert_special_days` set `day_code` = 2 WHERE `same_day` = 'tuesday'; UPDATE `talert_special_days` set `day_code` = 3 WHERE `same_day` = 'wednesday'; @@ -45,11 +53,8 @@ UPDATE `talert_special_days` set `day_code` = 5 WHERE `same_day` = 'friday'; UPDATE `talert_special_days` set `day_code` = 6 WHERE `same_day` = 'saturday'; UPDATE `talert_special_days` set `day_code` = 7 WHERE `same_day` = 'sunday'; -ALTER TABLE `talert_special_days` DROP COLUMN `same_day`; -ALTER TABLE `talert_special_days` ADD FOREIGN KEY (`id_calendar`) REFERENCES `talert_calendar`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; - -ALTER TABLE `tagent_repository` ADD COLUMN `deployment_timeout` INT UNSIGNED DEFAULT 600 AFTER `path`; - +INSERT IGNORE INTO `tipam_network_location` (`name`) SELECT `location` FROM `tipam_network` WHERE `location` <> ''; +UPDATE `tipam_network` INNER JOIN `tipam_network_location` ON tipam_network_location.name=tipam_network.location SET tipam_network.location=tipam_network_location.id; UPDATE `tconfig` c1 JOIN (select count(*) as n FROM `tconfig` c2 WHERE (c2.`token` = "node_metaconsole" AND c2.`value` = 1) OR (c2.`token` = "centralized_management" AND c2.`value` = 1) ) v SET c1. `value` = 0 WHERE c1.token = "autocreate_remote_users" AND v.n = 2; COMMIT; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index ba0c0c32e3..a385b8def0 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -4052,6 +4052,15 @@ CREATE TABLE IF NOT EXISTS `tipam_network_location` ( UNIQUE (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `tipam_sites` ( + `id` serial, + `name` varchar(100) UNIQUE NOT NULL default '', + `description` text, + `parent` bigint unsigned null, + PRIMARY KEY (`id`), + FOREIGN KEY (`parent`) REFERENCES `tipam_sites`(`id`) ON UPDATE CASCADE ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + INSERT IGNORE INTO `tipam_network_location` (`name`) SELECT `location` FROM `tipam_network` WHERE `location` <> ''; UPDATE `tipam_network` INNER JOIN `tipam_network_location` ON tipam_network_location.name=tipam_network.location SET tipam_network.location=tipam_network_location.id; ALTER TABLE `tipam_network` MODIFY `location` int(10) unsigned NULL; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index f8b675c9d6..48c7c4a6d2 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3959,6 +3959,18 @@ CREATE TABLE IF NOT EXISTS `tipam_network_location` ( UNIQUE (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- ---------------------------------------------------------------------- +-- Table `tipam_sites` +-- ---------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tipam_sites` ( + `id` serial, + `name` varchar(100) UNIQUE NOT NULL default '', + `description` text, + `parent` bigint unsigned null, + PRIMARY KEY (`id`), + FOREIGN KEY (`parent`) REFERENCES `tipam_sites`(`id`) ON UPDATE CASCADE ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + -- ---------------------------------------------------------------------- -- Table `tipam_network` -- ---------------------------------------------------------------------- From cb6184a9434d380ca03ded812333cadef49dbefb Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 9 Dec 2021 14:02:06 +0100 Subject: [PATCH 2/6] mr fix --- pandora_console/extras/mr/51.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/extras/mr/51.sql b/pandora_console/extras/mr/51.sql index 479305227d..6e256b2cd8 100644 --- a/pandora_console/extras/mr/51.sql +++ b/pandora_console/extras/mr/51.sql @@ -33,7 +33,7 @@ CREATE TABLE IF NOT EXISTS `tipam_sites` ( `description` text, `parent` bigint unsigned null, PRIMARY KEY (`id`), - FOREIGN KEY (`parent`) REFERENCES `tipam_sites`.`id` ON UPDATE CASCADE ON DELETE SET NULL + FOREIGN KEY (`parent`) REFERENCES `tipam_sites`(`id`) ON UPDATE CASCADE ON DELETE SET NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ALTER TABLE `tipam_network` MODIFY `location` int(10) unsigned NULL; From e37cdc4459cca06b45dbe6101f4aa5c74a5f96c1 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 9 Dec 2021 14:57:37 +0100 Subject: [PATCH 3/6] Improvements in Entity class --- pandora_console/include/lib/Entity.php | 97 +++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/lib/Entity.php b/pandora_console/include/lib/Entity.php index 59306db0ca..4e7bc14153 100644 --- a/pandora_console/include/lib/Entity.php +++ b/pandora_console/include/lib/Entity.php @@ -43,6 +43,13 @@ abstract class Entity */ protected $existsInDB; + /** + * Fields to identify register. + * + * @var array + */ + protected $primaryKeys; + /** * Entity fields (from table). * @@ -126,6 +133,8 @@ abstract class Entity if (is_array($filters) === true) { // New one. + $this->primaryKeys = array_keys($filters); + $data = \db_get_row_filter( $this->table, $filters, @@ -292,8 +301,94 @@ abstract class Entity * Saves current object definition to database. * * @return boolean Success or not. + * @throws \Exception On error. */ - public abstract function save(); + public function save() + { + $updates = $this->fields; + // Clean null fields. + foreach ($updates as $k => $v) { + if ($v === null) { + unset($updates[$k]); + } + } + + if ($this->existsInDB === true) { + // Update. + $where = []; + + foreach ($this->primaryKeys as $key) { + $where[$key] = $this->fields[$key]; + } + + if (empty($where) === true) { + throw new \Exception( + __METHOD__.' error: Cannot identify object' + ); + } + + $rs = \db_process_sql_update( + $this->table, + $updates, + $where + ); + + if ($rs === false) { + global $config; + throw new \Exception( + __METHOD__.' error: '.$config['dbconnection']->error + ); + } + } else { + // New register. + $rs = \db_process_sql_insert( + $this->table, + $updates + ); + + if ($rs === false) { + global $config; + + throw new \Exception( + __METHOD__.' error: '.$config['dbconnection']->error + ); + } + + $this->existsInDB = true; + } + + return true; + + } + + + /** + * Remove this entity. + * + * @return void + * @throws \Exception If no primary keys are defined. + */ + public function delete() + { + if ($this->existsInDB === true) { + $where = []; + + foreach ($this->primaryKeys as $key) { + $where[$key] = $this->fields[$key]; + } + + if (empty($where) === true) { + throw new \Exception( + __METHOD__.' error: Cannot identify object on deletion' + ); + } + + \db_process_sql_delete( + $this->table, + $where + ); + } + } } From 5c25fa840651348a4fd1fa7dadbd8948f4263776 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 9 Dec 2021 15:07:35 +0100 Subject: [PATCH 4/6] mr updates and a pretty icon --- pandora_console/extras/mr/51.sql | 5 +++++ .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 14 ++++++++------ pandora_console/images/building.png | Bin 0 -> 5990 bytes pandora_console/pandoradb.sql | 8 ++++++-- 4 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 pandora_console/images/building.png diff --git a/pandora_console/extras/mr/51.sql b/pandora_console/extras/mr/51.sql index 6e256b2cd8..e92d9b853c 100644 --- a/pandora_console/extras/mr/51.sql +++ b/pandora_console/extras/mr/51.sql @@ -44,6 +44,11 @@ ALTER TABLE `talert_special_days` ADD COLUMN `day_code` tinyint(2) unsigned NOT ALTER TABLE `talert_special_days` DROP COLUMN `same_day`; ALTER TABLE `talert_special_days` ADD FOREIGN KEY (`id_calendar`) REFERENCES `talert_calendar`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `tipam_network` ADD COLUMN `id_site` bigint unsigned; +ALTER TABLE `tipam_network` ADD CONSTRAINT FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; +ALTER TABLE `tipam_supernet` ADD COLUMN `id_site` bigint unsigned; +ALTER TABLE `tipam_supernet` ADD CONSTRAINT FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; + INSERT IGNORE INTO `talert_calendar` VALUES (1, 'Default', 0, 'Default calendar'); UPDATE `talert_special_days` set `day_code` = 1 WHERE `same_day` = 'monday'; UPDATE `talert_special_days` set `day_code` = 2 WHERE `same_day` = 'tuesday'; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index a385b8def0..f8c14f5f7f 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -3970,15 +3970,18 @@ CREATE TABLE IF NOT EXISTS `tipam_network` ( `network` varchar(100) NOT NULL default '', `name_network` varchar(255) default '', `description` text NOT NULL, - `location` tinytext NOT NULL, + `location` int(10) unsigned NULL, `id_recon_task` int(10) unsigned NOT NULL, `scan_interval` tinyint(2) default 1, `monitoring` tinyint(2) default 0, `id_group` mediumint(8) unsigned NULL default 0, `lightweight_mode` tinyint(2) default 0, `users_operator` text, + `id_site` bigint unsigned, PRIMARY KEY (`id`), - FOREIGN KEY (`id_recon_task`) REFERENCES trecon_task(`id_rt`) ON DELETE CASCADE + FOREIGN KEY (`id_recon_task`) REFERENCES trecon_task(`id_rt`) ON DELETE CASCADE, + FOREIGN KEY (`location`) REFERENCES `tipam_network_location`(`id`) ON DELETE CASCADE, + FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `tipam_ip` ( @@ -4033,7 +4036,9 @@ CREATE TABLE IF NOT EXISTS `tipam_supernet` ( `address` varchar(250) NOT NULL, `mask` varchar(250) NOT NULL, `subneting_mask` varchar(250) default '', - PRIMARY KEY (`id`) + `id_site` bigint unsigned, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `tipam_supernet_network` ( @@ -4062,9 +4067,6 @@ CREATE TABLE IF NOT EXISTS `tipam_sites` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT IGNORE INTO `tipam_network_location` (`name`) SELECT `location` FROM `tipam_network` WHERE `location` <> ''; -UPDATE `tipam_network` INNER JOIN `tipam_network_location` ON tipam_network_location.name=tipam_network.location SET tipam_network.location=tipam_network_location.id; -ALTER TABLE `tipam_network` MODIFY `location` int(10) unsigned NULL; -ALTER TABLE `tipam_network` ADD FOREIGN KEY (`location`) REFERENCES `tipam_network_location`(`id`) ON DELETE CASCADE; SET @insert_type = 3; SET @insert_name = 'IPAM Recon'; diff --git a/pandora_console/images/building.png b/pandora_console/images/building.png new file mode 100644 index 0000000000000000000000000000000000000000..9083a60215593e7e3b53027e2affb971ed27d85f GIT binary patch literal 5990 zcmeHKdpJ~E8=r1&;~r8}W9UN0Tro4o{Wen#LT;h<%jCoUunklDs2Y9nRw=bejM$T#+Fpsiz?_G4j*rnq`M{fGeq39^EDoVRZ+Prp> zdF(zqOE}h{mNwmAO=CR?$C$_)PJD>B((RcE*ka<(KixUlzjFN2vawZR4h>5_Gz)f5 zxLhTT%&=PZ0y?6X#JzlxyiSL5XFuG6%uf3qey8!{Hn}~y!^3|WXHe-q!i&SIzrDDg z*Kx}*plRinDf=74ckc7FhnS5)_;d%=E?^?kJqatM~L6uk4V;?HbU!4 zAM7rmvvsz{hBTx5p7g*m`nkJ#@*~{PU@-he-cg6bs8=4Lcy=Kw5~CaO4DDf7$zfyp!o36f;`V z`$%5x>VeFpG)i0fE&AbZWqdmU9Q0>zKAeN&be7YcYjjTe_Ne;VQrrs$RePo#+AP|% z&HqdZ^drL8bYT{3I~u>>F+;tvpdP3Nm&98RDA$~lN}b2mam(1vOBr^UjYCBj;gJJT zPAV793k?;c>fZZi8YYa=25cTjCf%tb^ekaqT9V^wnKTLPu;^+(IrY?@eXyowgyEG_ zS^n75BK3NyM%rq=-|LX!*Jak$8woyDzBe%jCk;_XX{gpLW|l=jPc~zC73Wr#mWl2K z_tjHXZUZ5`js%VU(wob#Qn-`_eB51_gZb)zZSt-iEYAAf^PX-Uo!^qF%8J^Wv|wdl z;B=+?3DQ1?UX|gdVXDfcdP&J8NAZRzb$)EeD@XTyQ-x;h@P%(^>Q+V*rb>%j_q+Eh zq-GdYV3U2)VsAO_hle%-9_-g8D9Q)OF+!tsqE~2gGdEM?cmf#L}CsAKR%V~nZI^n;L$Cb zePQLN3J}}!<~`~{1lj0j$Z2@+RSKix9IeQ9y`8V^%GB&x{;6xi$~&ie@}4c-^;cV- z^0~)5jvA*AZf~pMd({SO%yY53em94dkd$Usm{GyA^zN!{0e6{?$Qdt=v6^Teu`R*u zLFa6VKk{DdB z#GJ}n_U2XV)0-v(!nZf?xtw25slIQ$f2VTg$}?-Ne{);;NIdx7hIY$EJ0j^&+9CNr z2G<7bug|yNDcaKsX`ik-rco$`w4X}f(T=6HB5moja%kq?K{wJd2$B+IRyr#aa zc!;)`;lRoDcXclE?Wr?U;YqB$SYUUTH%L57VcM5pE74;o)ms;-F>Sd(w z+;-OX`LMIYgKKu1Q^JZXQ40+!vKJm2F=*0F@X7KbZ`W0}2T#T*0*<#0e%FJymo?Bj z$U`ABscs(>i&D?#GvCygXYHaDpI*A7un%9~eOFF0K5p`;D0o=A<>K|UMKvtk<7R`_r;}J#S}_0CjSh*X;1XkW{~Zit2h=)26$tBJqF( zvTeA$zTyb{Ycu<3HrSJEGL8m*ZMV@A^&f=6<|T3*9X)7{j$gh$&^IS{N2V3E*+VO7 zwlqb}L^V=fODHxVB)<4v;DI}_r&v#1+#N*V^u>h@=7(su?K^+F9mBjsBP9V#MPvc zXzQ;;?YM8)IC)98jsP4SBUazL`xQ4rit2ezY*5FBXTXbrTPvseQ{`8(>xeaIj zj5q-pRVA;Ysvj#z(QK>IC<=kL#X61&pM?a4v~n+3ixH@6;NfX^@P4G0)ec=kZfta3}v8Tr6b zSb}>Jx2;mESo2Nv!}iUAd&P{9eFRX_T6badjv%=R+U z<&_*oQITubJu$RPSjK^N1Ag?4WTt>;2CxJS&`in`Lc0YRjAAPl0?aT_f?$9l9KJR3 z)uqcw1czmf^fjkr=t4&@ltYaXfnG6g-prUVCW(c#wNau-$q)b!lmG}RkINU6rPjzf zTr%`5>qa9Hb0U&3Yos6D1K}tTfe3;b!3=|PmU1F-NE;;tMZ{v0J)K-WLqKoV$WVzy zNJgWhqN2>A@MZ#02pUTwkjYLA@h%f%}gmn5>c)s{E3lJY@DIi2+%`j*l5B;r%SmGQBfqZu8A2r0@(54FQ z35o>~A|~h@3GyX|-$JmMU-g9%BJNx`EG8P{f;>o63|Yl~XVR5M_xP$IqacLC6V7Qt zWPc|q;jsTE>pS0MBXi+=>j5vPR16lUV{Lhee)y zB$6;B5Jx1U2t*PVMZlSZC=!STP#_D>uwY`$aU?AB8z>rIECKjTPzD8on{glj_pC>8_-Vp$B9IUb8* zku1$2Z!k<0q)&tzCSZxhfdqg^n1f<5$u0sB4}j9i;Q=8aTF4KX8;}uBw)db}BXMS! zzk58mfP@VxSR*%b_z}{-2fR5v&`Scy*u+}kNf>jyIgx;|G$&eqGBk(h1B%2@CCV_d z7&9DkPF2w<)siiPYb0s)CY5C7a0EO?b8(Ca^{8*h`F*Q1I$lG#6Tp-nll9HeHvnh0{jpVn%|!b>PtW8ACkqe zV6ZKj7EBbDjj@E1MPQ-;3=xMix5QeKFgObftR?t8x>&%LL;)huJ_L#siUum6xo8k; z=cqLPUOFlil<|bYVNqBd3PbY7;>matnLt>F!ICi;B>Ho}XxXg(5-|n+Uz||p1io1Y zAiYn0(DDMUR_L$G)o0FRH2xodpL6klv;aZ>H1b3I{-ocx@o$?YI-C6#rvZC@D(_4ilQ_y+$GR?`}n|SkF4?TH5pd~-{V5X55n|PIRZKxiu z)Z*a(?3iiR?W|Mm7B^$?Sk>>h`>M|rYNZD~=32dlYkhtH z_94&7pHA(Lnbm)glb`p( z|8k`?T2Wd(W7Y27)UV9;Jn`FD#2M4DCA54%-+gS}`PU@wEz-T9X;TAUaaK;tSkx1_ ziN~gu%!t190inF%tX{PuovTo0@@{tH-HXW#{ksWc4(A=ty*8Y#2XNV}|;02%f-ahRqmwP)7FrB*(Vu^#xpJQ9t8`@nv-#f-&?;L*+ j9ZpKwT-%_+puSgeVln}1?DjY)yD*xwn^UF3w)p=5R=;O3 literal 0 HcmV?d00001 diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 48c7c4a6d2..5a91e0b8bc 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3986,9 +3986,11 @@ CREATE TABLE IF NOT EXISTS `tipam_network` ( `id_group` mediumint(8) unsigned NULL default 0, `lightweight_mode` tinyint(2) default 0, `users_operator` text, + `id_site` bigint unsigned, PRIMARY KEY (`id`), FOREIGN KEY (`id_recon_task`) REFERENCES trecon_task(`id_rt`) ON DELETE CASCADE, - FOREIGN KEY (`location`) REFERENCES `tipam_network_location`(`id`) ON DELETE CASCADE + FOREIGN KEY (`location`) REFERENCES `tipam_network_location`(`id`) ON DELETE CASCADE, + FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ---------------------------------------------------------------------- @@ -4055,7 +4057,9 @@ CREATE TABLE IF NOT EXISTS `tipam_supernet` ( `address` varchar(250) NOT NULL, `mask` varchar(250) NOT NULL, `subneting_mask` varchar(250) default '', - PRIMARY KEY (`id`) + `id_site` bigint unsigned, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ---------------------------------------------------------------------- From b97ecda12bdf844e7263a69491d4bd555228c8d0 Mon Sep 17 00:00:00 2001 From: Daniel Barbero Martin Date: Thu, 9 Dec 2021 16:19:05 +0100 Subject: [PATCH 5/6] db changes --- pandora_console/extras/mr/51.sql | 2 ++ pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 4 +++- pandora_console/pandoradb.sql | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pandora_console/extras/mr/51.sql b/pandora_console/extras/mr/51.sql index e92d9b853c..6052b5f95a 100644 --- a/pandora_console/extras/mr/51.sql +++ b/pandora_console/extras/mr/51.sql @@ -48,6 +48,8 @@ ALTER TABLE `tipam_network` ADD COLUMN `id_site` bigint unsigned; ALTER TABLE `tipam_network` ADD CONSTRAINT FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; ALTER TABLE `tipam_supernet` ADD COLUMN `id_site` bigint unsigned; ALTER TABLE `tipam_supernet` ADD CONSTRAINT FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; +ALTER TABLE `tipam_network` ADD COLUMN `vrf` int(10) unsigned; +ALTER TABLE `tipam_network` ADD CONSTRAINT FOREIGN KEY (`vrf`) REFERENCES `tagente`(`id_agente`) ON DELETE SET NULL ON UPDATE CASCADE; INSERT IGNORE INTO `talert_calendar` VALUES (1, 'Default', 0, 'Default calendar'); UPDATE `talert_special_days` set `day_code` = 1 WHERE `same_day` = 'monday'; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index f8c14f5f7f..0a33a9f1ff 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -3978,10 +3978,12 @@ CREATE TABLE IF NOT EXISTS `tipam_network` ( `lightweight_mode` tinyint(2) default 0, `users_operator` text, `id_site` bigint unsigned, + `vrf` int(10) unsigned, PRIMARY KEY (`id`), FOREIGN KEY (`id_recon_task`) REFERENCES trecon_task(`id_rt`) ON DELETE CASCADE, FOREIGN KEY (`location`) REFERENCES `tipam_network_location`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE + FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE, + FOREIGN KEY (`vrf`) REFERENCES `tagente`(`id_agente`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `tipam_ip` ( diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 5a91e0b8bc..258f9409f1 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3987,10 +3987,12 @@ CREATE TABLE IF NOT EXISTS `tipam_network` ( `lightweight_mode` tinyint(2) default 0, `users_operator` text, `id_site` bigint unsigned, + `vrf` int(10) unsigned, PRIMARY KEY (`id`), FOREIGN KEY (`id_recon_task`) REFERENCES trecon_task(`id_rt`) ON DELETE CASCADE, FOREIGN KEY (`location`) REFERENCES `tipam_network_location`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE + FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE, + FOREIGN KEY (`vrf`) REFERENCES `tagente`(`id_agente`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ---------------------------------------------------------------------- From f8883151f346fe481fb9d2d6ad3875f0b3e999d8 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 10 Dec 2021 13:43:05 +0100 Subject: [PATCH 6/6] allow datatable to export all columns but latest one --- pandora_console/include/functions_ui.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 8e9fe01210..c143324c6a 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -3459,6 +3459,11 @@ function ui_print_datatable(array $parameters) } } + $export_columns = ''; + if ($parameters['csv_exclude_latest'] === true) { + $export_columns = ',columns: \'th:not(:last-child)\''; + } + $js .= ' if (dt_'.$table_id.'.page.info().pages > 1) { $("#'.$table_id.'_wrapper > .dataTables_paginate.paging_simple_numbers").show() @@ -3489,8 +3494,7 @@ function ui_print_datatable(array $parameters) order : "current", page : "All", search : "applied" - }, - columns: [1,'.$columns.'] + }'.$export_columns.' } } ],