Merge branch 'ent-6126-add-csv-json-save-to-disk-console-task' into 'develop'

Added CSV an JSON formats in console task report save to disk

See merge request artica/pandorafms!3613
This commit is contained in:
Daniel Rodriguez 2021-01-28 10:23:22 +01:00
commit 147bac8e55
3 changed files with 34 additions and 37 deletions

View File

@ -135,6 +135,21 @@ UPDATE `trecon_script` SET `description`='Specific Pandora FMS In
ALTER TABLE `trecon_task` MODIFY COLUMN `review_mode` TINYINT(1) UNSIGNED DEFAULT 1;
DELETE FROM `tuser_task` WHERE id = 6;
UPDATE `tuser_task` SET `parameters`='a:4:{i:0;a:6:{s:11:"description";s:28:"Report pending to be created";s:5:"table";s:7:"treport";s:8:"field_id";s:9:"id_report";s:10:"field_name";s:4:"name";s:4:"type";s:3:"int";s:9:"acl_group";s:8:"id_group";}i:1;a:2:{s:11:"description";s:426:"Save to disk in path<a href="javascript:" class="tip" style="" ><img src="http://172.16.0.2/pandora_console/images/tip_help.png" data-title="The Apache user should have read-write access on this folder. E.g. /var/www/html/pandora_console/attachment" data-use_title_for_force_title="1" class="forced_title" alt="The Apache user should have read-write access on this folder. E.g. /var/www/html/pandora_console/attachment" /></a>";s:4:"type";s:6:"string";}i:2;a:2:{s:11:"description";s:16:"File nane prefix";s:4:"type";s:6:"string";}i:3;a:2:{s:11:"description";s:11:"Report Type";s:4:"type";s:11:"report_type";}}' WHERE `id`=3;
UPDATE `tuser_task_scheduled` SET
`args` = REPLACE (`args`, 'a:3', 'a:5'),
`args`= REPLACE(`args`, 's:15:"first_execution"', 'i:2;s:0:"";i:3;s:3:"PDF";s:15:"first_execution"')
WHERE `id_user_task` = 3;
UPDATE `tuser_task_scheduled` SET
`id_user_task` = 3,
`args` = REPLACE (`args`, 'a:3', 'a:5'),
`args`= REPLACE(`args`, 's:15:"first_execution"', 'i:2;s:0:"";i:3;s:3:"XML";s:15:"first_execution"')
WHERE `id_user_task` = 6;
ALTER TABLE `ttag` MODIFY COLUMN `name` text NOT NULL default '';
COMMIT;

View File

@ -2526,6 +2526,20 @@ ALTER TABLE `tnetflow_filter` MODIFY COLUMN `router_ip` text NOT NULL;
-- ----------------------------------------------------------------------
UPDATE tuser_task set parameters = 'a:5:{i:0;a:6:{s:11:\"description\";s:28:\"Report pending to be created\";s:5:\"table\";s:7:\"treport\";s:8:\"field_id\";s:9:\"id_report\";s:10:\"field_name\";s:4:\"name\";s:4:\"type\";s:3:\"int\";s:9:\"acl_group\";s:8:\"id_group\";}i:1;a:2:{s:11:\"description\";s:46:\"Send to email addresses (separated by a comma)\";s:4:\"type\";s:4:\"text\";}i:2;a:2:{s:11:\"description\";s:7:\"Subject\";s:8:\"optional\";i:1;}i:3;a:3:{s:11:\"description\";s:7:\"Message\";s:4:\"type\";s:4:\"text\";s:8:\"optional\";i:1;}i:4;a:2:{s:11:\"description\";s:11:\"Report Type\";s:4:\"type\";s:11:\"report_type\";}}' where function_name = "cron_task_generate_report";
INSERT IGNORE INTO tuser_task VALUES (8, 'cron_task_generate_csv_log', 'a:1:{i:0;a:2:{s:11:"description";s:14:"Send to e-mail";s:4:"type";s:4:"text";}}', 'Send csv log');
UPDATE `tuser_task` SET `parameters`='a:4:{i:0;a:6:{s:11:"description";s:28:"Report pending to be created";s:5:"table";s:7:"treport";s:8:"field_id";s:9:"id_report";s:10:"field_name";s:4:"name";s:4:"type";s:3:"int";s:9:"acl_group";s:8:"id_group";}i:1;a:2:{s:11:"description";s:426:"Save to disk in path<a href="javascript:" class="tip" style="" ><img src="http://172.16.0.2/pandora_console/images/tip_help.png" data-title="The Apache user should have read-write access on this folder. E.g. /var/www/html/pandora_console/attachment" data-use_title_for_force_title="1" class="forced_title" alt="The Apache user should have read-write access on this folder. E.g. /var/www/html/pandora_console/attachment" /></a>";s:4:"type";s:6:"string";}i:2;a:2:{s:11:"description";s:16:"File nane prefix";s:4:"type";s:6:"string";}i:3;a:2:{s:11:"description";s:11:"Report Type";s:4:"type";s:11:"report_type";}}' WHERE `id`=3;
DELETE FROM `tuser_task` WHERE id = 6;
-- Migrate old tasks
UPDATE `tuser_task_scheduled` SET
`args` = REPLACE (`args`, 'a:3', 'a:5'),
`args`= REPLACE(`args`, 's:15:"first_execution"', 'i:2;s:0:"";i:3;s:3:"PDF";s:15:"first_execution"')
WHERE `id_user_task` = 3;
UPDATE `tuser_task_scheduled` SET
`id_user_task` = 3,
`args` = REPLACE (`args`, 'a:3', 'a:5'),
`args`= REPLACE(`args`, 's:15:"first_execution"', 'i:2;s:0:"";i:3;s:3:"XML";s:15:"first_execution"')
WHERE `id_user_task` = 6;
-- ----------------------------------------------------------------------
-- ADD message in table 'tnews'
@ -3969,4 +3983,5 @@ SELECT `id_recon_script`,`type`, `name`, `description`, `script`, `macros` FROM
DELETE FROM `tconfig` WHERE `token` = 'ipam_installed';
DELETE FROM `tconfig` WHERE `token` = 'ipam_recon_script_id';
DELETE FROM `tconfig` WHERE `token` = 'ipam_recon_script_id';

View File

@ -600,42 +600,6 @@ function cron_list_table()
$data[0] = '';
}
$data[1] = $task['id_usuario'];
$data[2] = db_get_value(
'name',
'tuser_task',
'id',
$task['id_user_task']
);
$args = unserialize($task['args']);
$report = reports_get_report($args[0]);
// Check ACL in reports_get_report return false.
if ($report === false) {
continue;
}
$path = $args[1];
$data[2] .= '<br>- '.__('Report').": <a href='index.php?sec=reporting&sec2=operation/reporting/reporting_viewer";
$data[2] .= '&id='.$args[0]."'>".$report['name'].'</a>';
$data[2] .= '<br>- '.__('Path').': '.$path.'</a>';
break;
case 'cron_task_save_xml_report_to_disk':
if ($write_perms || $manage_pandora) {
$data[0] = '<a href="'.$url;
$data[0] .= 'force_run=1&id_user_task='.$task['id'].'">';
$data[0] .= html_print_image(
'images/target.png',
true,
['title' => __('Force run')]
);
$data[0] .= '</a>';
} else {
$data[0] = '';
}
$data[1] = $task['id_usuario'];
$data[2] = db_get_value('name', 'tuser_task', 'id', $task['id_user_task']);
$args = unserialize($task['args']);
@ -647,9 +611,12 @@ function cron_list_table()
}
$path = $args[1];
$report_type = $args[3];
$data[2] .= '<br>- '.__('Report').": <a href='index.php?sec=reporting&sec2=operation/reporting/reporting_viewer";
$data[2] .= '&id='.$args[0]."'>".$report['name'].'</a>';
$data[2] .= '<br>- '.__('Path').': '.$path.'</a>';
$data[2] .= '<br>- '.__('Report type').': '.$report_type;
break;
case 'cron_task_do_backup':