Merge branch '3170-Cambios_custom_fields_view' into 'develop'

new fields form custom field view

See merge request artica/pandorafms!2030
This commit is contained in:
vgilc 2018-12-04 10:17:03 +01:00
commit 1e9be8d161
6 changed files with 255 additions and 82 deletions

View File

@ -0,0 +1,9 @@
START TRANSACTION;
ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `group_search` int(10) unsigned default '0';
ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `module_status` varchar(600) default '';
ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `recursion` int(1) unsigned default '0';
COMMIT;

View File

@ -1180,13 +1180,13 @@ ALTER TABLE titem MODIFY `source_data` int(10) unsigned;
INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 22); INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 23);
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png');
UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager'; UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager';
DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise'; DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise';
INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '729'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '730');
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `tconfig_os` -- Table `tconfig_os`
@ -1826,3 +1826,9 @@ CREATE TABLE IF NOT EXISTS `tagent_custom_fields_filter` (
`module_search` varchar(600) default '', `module_search` varchar(600) default '',
PRIMARY KEY(`id`) PRIMARY KEY(`id`)
) ENGINE = InnoDB DEFAULT CHARSET=utf8; ) ENGINE = InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `module_status` varchar(600) default '';
ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `recursion` int(1) unsigned default '0';
ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `group_search` int(10) unsigned default '0';

View File

@ -32,6 +32,7 @@ $append_tab_filter = (bool)get_parameter('append_tab_filter', 0);
$create_filter_cf = (bool)get_parameter('create_filter_cf', 0); $create_filter_cf = (bool)get_parameter('create_filter_cf', 0);
$update_filter_cf = (bool)get_parameter('update_filter_cf', 0); $update_filter_cf = (bool)get_parameter('update_filter_cf', 0);
$delete_filter_cf = (bool)get_parameter('delete_filter_cf', 0); $delete_filter_cf = (bool)get_parameter('delete_filter_cf', 0);
$change_name_filter = (bool)get_parameter('change_name_filter', 0);
if ($get_custom_fields_data){ if ($get_custom_fields_data){
$name_custom_fields = get_parameter("name_custom_fields", 0); $name_custom_fields = get_parameter("name_custom_fields", 0);
@ -40,7 +41,6 @@ if ($get_custom_fields_data){
return; return;
} }
if($build_table_custom_fields){ if($build_table_custom_fields){
$order = get_parameter("order", ''); $order = get_parameter("order", '');
$length = get_parameter("length", 20); $length = get_parameter("length", 20);
@ -237,6 +237,7 @@ if($build_table_child_custom_fields){
$id_agent = get_parameter("id_agent", 0); $id_agent = get_parameter("id_agent", 0);
$id_server = get_parameter("id_server", 0); $id_server = get_parameter("id_server", 0);
$module_search = str_replace('amp;', '',get_parameter("module_search", '')); $module_search = str_replace('amp;', '',get_parameter("module_search", ''));
$module_status = get_parameter("module_status", 0);
if(!$id_server || !$id_agent){ if(!$id_server || !$id_agent){
return false; return false;
@ -246,6 +247,46 @@ if($build_table_child_custom_fields){
$name_where = " AND tam.nombre LIKE '%" . $module_search . "%'"; $name_where = " AND tam.nombre LIKE '%" . $module_search . "%'";
} }
//filter by status module
$and_module_status = "";
if(is_array($module_status)){
if(!in_array(-1, $module_status)){
if(!in_array(AGENT_MODULE_STATUS_NOT_NORMAL, $module_status)){
if(count($module_status) > 0){
$and_module_status = " AND ( ";
foreach ($module_status as $key => $value) {
$and_module_status .= ($key != 0)
? " OR ("
: " (";
switch ($value) {
default:
case AGENT_STATUS_NORMAL:
$and_module_status .= " tae.estado = 0 OR tae.estado = 300 ) ";
break;
case AGENT_STATUS_CRITICAL:
$and_module_status .= " tae.estado = 1 OR tae.estado = 100 ) ";
break;
case AGENT_STATUS_WARNING:
$and_module_status .= " tae.estado = 2 OR tae.estado = 200 ) ";
break;
case AGENT_STATUS_UNKNOWN:
$and_module_status .= " tae.estado = 3 ) ";
break;
case AGENT_STATUS_NOT_INIT:
$and_module_status .= " tae.estado = 4 OR tae.estado = 5 ) ";
break;
}
}
$and_module_status .= " ) ";
}
}
else{
//not normal
$and_module_status = "AND tae.estado <> 0 AND tae.estado <> 300 ";
}
}
}
if (is_metaconsole()) { if (is_metaconsole()) {
$server = metaconsole_get_connection_by_id ($id_server); $server = metaconsole_get_connection_by_id ($id_server);
metaconsole_connect($server); metaconsole_connect($server);
@ -262,9 +303,10 @@ if($build_table_child_custom_fields){
INNER JOIN tagente_estado tae INNER JOIN tagente_estado tae
ON tam.id_agente_modulo = tae.id_agente_modulo ON tam.id_agente_modulo = tae.id_agente_modulo
WHERE tam.id_agente = %d WHERE tam.id_agente = %d
%s", %s %s",
$id_agent, $id_agent,
$name_where $name_where,
$and_module_status
); );
$modules = db_get_all_rows_sql ($query); $modules = db_get_all_rows_sql ($query);
@ -282,7 +324,7 @@ if($build_table_child_custom_fields){
$table_modules->head[5] = __('Status'); $table_modules->head[5] = __('Status');
$table_modules->data = array(); $table_modules->data = array();
$status_agent = -1;
if(isset($modules) && is_array($modules)){ if(isset($modules) && is_array($modules)){
foreach ($modules as $key => $value) { foreach ($modules as $key => $value) {
$table_modules->data[$key][0] = $value['nombre']; $table_modules->data[$key][0] = $value['nombre'];
@ -311,9 +353,6 @@ if($build_table_child_custom_fields){
switch ($value['estado']) { switch ($value['estado']) {
case 0: case 0:
case 300: case 300:
if($status_agent != 1 && $status_agent != 2 && $status_agent != 3){
$status_agent = 0;
}
$table_modules->data[$key][5] = html_print_image( $table_modules->data[$key][5] = html_print_image(
'images/status_sets/default/severity_normal.png', 'images/status_sets/default/severity_normal.png',
true, true,
@ -324,7 +363,6 @@ if($build_table_child_custom_fields){
break; break;
case 1: case 1:
case 100: case 100:
$status_agent = 1;
$table_modules->data[$key][5] = html_print_image( $table_modules->data[$key][5] = html_print_image(
'images/status_sets/default/severity_critical.png', 'images/status_sets/default/severity_critical.png',
true, true,
@ -335,10 +373,6 @@ if($build_table_child_custom_fields){
break; break;
case 2: case 2:
case 200: case 200:
if($status_agent != 1){
$status_agent = 2;
}
$table_modules->data[$key][5] = html_print_image( $table_modules->data[$key][5] = html_print_image(
'images/status_sets/default/severity_warning.png', 'images/status_sets/default/severity_warning.png',
true, true,
@ -348,10 +382,6 @@ if($build_table_child_custom_fields){
); );
break; break;
case 3: case 3:
if($status_agent != 1 && $status_agent != 2){
$status_agent = 3;
}
$table_modules->data[$key][5] = html_print_image( $table_modules->data[$key][5] = html_print_image(
'images/status_sets/default/severity_maintenance.png', 'images/status_sets/default/severity_maintenance.png',
true, true,
@ -362,9 +392,6 @@ if($build_table_child_custom_fields){
break; break;
case 4: case 4:
case 5: case 5:
if($status_agent == -1 || $status_agent == 4){
$status_agent = 5;
}
$table_modules->data[$key][5] = html_print_image( $table_modules->data[$key][5] = html_print_image(
'images/status_sets/default/severity_informational.png', 'images/status_sets/default/severity_informational.png',
true, true,
@ -374,10 +401,6 @@ if($build_table_child_custom_fields){
); );
break; break;
default: default:
if($status_agent != 1 && $status_agent != 2 && $status_agent != 3){
$status_agent = 0;
}
$table_modules->data[$key][5] = html_print_image( $table_modules->data[$key][5] = html_print_image(
'images/status_sets/default/severity_normal.png', 'images/status_sets/default/severity_normal.png',
true, true,
@ -390,6 +413,8 @@ if($build_table_child_custom_fields){
} }
} }
$status_agent = agents_get_status($id_agent, true);
if (is_metaconsole()) { if (is_metaconsole()) {
metaconsole_restore_db(); metaconsole_restore_db();
} }
@ -433,17 +458,19 @@ if($build_table_save_filter){
$table->id = 'save_filter_form'; $table->id = 'save_filter_form';
$table->width = '100%'; $table->width = '100%';
$table->class = 'databox'; $table->class = 'databox';
$array_filters = get_filters_custom_fields_view(0, true); $array_filters = get_filters_custom_fields_view(0, true);
$table->data[0][0] = __('Filter name'); $table->data[0][0] = __('Filter name');
$table->data[0][1] = html_print_select( $table->data[0][1] = html_print_select(
$array_filters, 'id_name', $array_filters, 'id_name',
'', '', '', '', '', '', '', '',
true, false, true, '', false true, false, true, '', false
); );
$table->data[0][3] = html_print_submit_button (__('Load filter'), 'load_filter', false, 'class="sub upd"', true); $table->data[0][3] = html_print_submit_button (__('Load filter'), 'load_filter', false, 'class="sub upd"', true);
echo "<form action='' method='post'>"; echo "<form action='' method='post'>";
html_print_table($table); html_print_table($table);
echo "</form>"; echo "</form>";
} }
@ -462,7 +489,16 @@ if($append_tab_filter){
echo "<div id='msg_error_create'></div>"; echo "<div id='msg_error_create'></div>";
$table->data[0][0] = __('Filter name'); $table->data[0][0] = __('Filter name');
$table->data[0][1] = html_print_input_text('id_name', '', '', 15, 255, true); $table->data[0][1] = html_print_input_text('id_name', '', '', 15, 255, true);
$table->data[0][2] = html_print_submit_button (__('Create filter'), 'create_filter', false, 'class="sub upd"', true);
$table->data[0][2] = __('Group');
$table->data[0][3] = html_print_select_groups(
$config['id_user'], 'AR', true, 'group_search_cr',
0, '', '', '0', true, false,
false, '', false, '', false, false,
'id_grupo', false
);
$table->data[0][4] = html_print_submit_button (__('Create filter'), 'create_filter', false, 'class="sub upd"', true);
} }
else{ else{
echo "<div id='msg_error_update'></div>"; echo "<div id='msg_error_update'></div>";
@ -470,12 +506,22 @@ if($append_tab_filter){
$array_filters = get_filters_custom_fields_view(0, true); $array_filters = get_filters_custom_fields_view(0, true);
$table->data[0][0] = __('Filter name'); $table->data[0][0] = __('Filter name');
$table->data[0][1] = html_print_select( $table->data[0][1] = html_print_select(
$array_filters, 'id_name', $array_filters, 'id_name', '',
'', '', __('None'), -1, 'filter_name_change_group(this.value)',
true, false, true, '', false __('None'), -1, true, false, true,
'', false
); );
$table->data[1][0] = __('Group');
$table->data[1][1] = html_print_select_groups(
$config['id_user'], 'AR', true, 'group_search_up',
$group, '', '', '0', true, false,
false, '', false, '', false, false,
'id_grupo', false
);
$table->data[0][2] = html_print_submit_button (__('Delete filter'), 'delete_filter', false, 'class="sub upd"', true); $table->data[0][2] = html_print_submit_button (__('Delete filter'), 'delete_filter', false, 'class="sub upd"', true);
$table->data[0][3] = html_print_submit_button (__('Update filter'), 'update_filter', false, 'class="sub upd"', true); $table->data[1][2] = html_print_submit_button (__('Update filter'), 'update_filter', false, 'class="sub upd"', true);
} }
html_print_table($table); html_print_table($table);
@ -491,6 +537,7 @@ if($create_filter_cf){
//initialize vars //initialize vars
$filters = json_decode(io_safe_output(get_parameter("filters", '')), true); $filters = json_decode(io_safe_output(get_parameter("filters", '')), true);
$name_filter = get_parameter("name_filter", ''); $name_filter = get_parameter("name_filter", '');
$group_search = get_parameter("group_search", 0);
//check that the name is not empty //check that the name is not empty
if($name_filter == ''){ if($name_filter == ''){
@ -529,11 +576,14 @@ if($create_filter_cf){
//insert //insert
$values = array(); $values = array();
$values['name'] = $name_filter; $values['name'] = $name_filter;
$values['group_search'] = $group_search;
$values['id_group'] = $filters['group']; $values['id_group'] = $filters['group'];
$values['id_custom_field'] = $filters['id_custom_fields']; $values['id_custom_field'] = $filters['id_custom_fields'];
$values['id_custom_fields_data'] = json_encode($filters['id_custom_fields_data']); $values['id_custom_fields_data'] = json_encode($filters['id_custom_fields_data']);
$values['id_status'] = json_encode($filters['id_status']); $values['id_status'] = json_encode($filters['id_status']);
$values['module_search'] = $filters['module_search']; $values['module_search'] = $filters['module_search'];
$values['module_status'] = json_encode($filters['module_status']);
$values['recursion'] = $filters['recursion'];
$insert = db_process_sql_insert('tagent_custom_fields_filter', $values); $insert = db_process_sql_insert('tagent_custom_fields_filter', $values);
@ -565,6 +615,7 @@ if($update_filter_cf){
//initialize vars //initialize vars
$filters = json_decode(io_safe_output(get_parameter("filters", '')), true); $filters = json_decode(io_safe_output(get_parameter("filters", '')), true);
$id_filter = get_parameter("id_filter", ''); $id_filter = get_parameter("id_filter", '');
$group_search = get_parameter("group_search", 0);
//check selected filter //check selected filter
if($id_filter == -1){ if($id_filter == -1){
@ -595,10 +646,13 @@ if($update_filter_cf){
//array values update //array values update
$values = array(); $values = array();
$values['id_group'] = $filters['group']; $values['id_group'] = $filters['group'];
$values['group_search'] = $group_search;
$values['id_custom_field'] = $filters['id_custom_fields']; $values['id_custom_field'] = $filters['id_custom_fields'];
$values['id_custom_fields_data'] = json_encode($filters['id_custom_fields_data']); $values['id_custom_fields_data'] = json_encode($filters['id_custom_fields_data']);
$values['id_status'] = json_encode($filters['id_status']); $values['id_status'] = json_encode($filters['id_status']);
$values['module_search'] = $filters['module_search']; $values['module_search'] = $filters['module_search'];
$values['module_status'] = json_encode($filters['module_status']);
$values['recursion'] = $filters['recursion'];
//update //update
$update = db_process_sql_update('tagent_custom_fields_filter', $values, $condition); $update = db_process_sql_update('tagent_custom_fields_filter', $values, $condition);
@ -669,7 +723,17 @@ if($delete_filter_cf){
return; return;
} }
if($change_name_filter){
$id_filter = get_parameter("id_filter", 0);
if(isset($id_filter)){
$res = get_group_filter_custom_field_view($id_filter);
echo json_encode($res);
return;
}
return json_encode(false);
}
} }

View File

@ -191,7 +191,7 @@ function get_custom_fields_data ($custom_field_name) {
} }
function agent_counters_custom_fields($filters){ function agent_counters_custom_fields($filters){
//filter by status //filter by status agent
$and_status = ""; $and_status = "";
if(is_array($filters['id_status'])){ if(is_array($filters['id_status'])){
if(!in_array(-1, $filters['id_status'])){ if(!in_array(-1, $filters['id_status'])){
@ -241,17 +241,100 @@ function agent_counters_custom_fields($filters){
} }
} }
//filter by status module
$and_module_status = "";
if(is_array($filters['module_status'])){
if(!in_array(-1, $filters['module_status'])){
if(!in_array(AGENT_MODULE_STATUS_NOT_NORMAL, $filters['module_status'])){
if(count($filters['module_status']) > 0){
$and_module_status = " AND ( ";
foreach ($filters['module_status'] as $key => $value) {
$and_module_status .= ($key != 0)
? " OR ("
: " (";
switch ($value) {
default:
case AGENT_STATUS_NORMAL:
$and_module_status .= " tae.estado = 0 OR tae.estado = 300 ) ";
break;
case AGENT_STATUS_CRITICAL:
$and_module_status .= " tae.estado = 1 OR tae.estado = 100 ) ";
break;
case AGENT_STATUS_WARNING:
$and_module_status .= " tae.estado = 2 OR tae.estado = 200 ) ";
break;
case AGENT_STATUS_UNKNOWN:
$and_module_status .= " tae.estado = 3 ) ";
break;
case AGENT_STATUS_NOT_INIT:
$and_module_status .= " tae.estado = 4 OR tae.estado = 5 ) ";
break;
}
}
$and_module_status .= " ) ";
}
}
else{
//not normal
$and_module_status = "AND tae.estado <> 0 AND tae.estado <> 300 ";
}
}
}
//filters module
if($filters['module_search']){
$and_module_search = 'AND nombre LIKE "%' . $filters['module_search'] . '%"';
}
$module_filter = "";
if($and_module_search != '' || $and_module_status != ''){
$module_filter = ' AND (
SELECT count(*) AS n
FROM tagente_modulo tam
INNER JOIN tagente_estado tae
ON tae.id_agente_modulo = tam.id_agente_modulo
WHERE tam.id_agente=ta.id_agente
'. $and_module_search . ' ' . $and_module_status .'
) > 0 ';
}
//filter group and check ACL groups //filter group and check ACL groups
$groups_and = ""; $groups_and = "";
if (!users_can_manage_group_all("AR")) { if (!users_can_manage_group_all("AR")) {
if(!$filters['group']){ if($filters['group']){
$id_groups = explode(", ", array_keys(users_get_groups())); $user_groups = array_keys(users_get_groups());
$id_groups = implode(", ", $user_groups);
$groups_and = " AND (ta.id_grupo IN ($id_groups) OR tasg.id_group IN($id_groups))"; $groups_and = " AND (ta.id_grupo IN ($id_groups) OR tasg.id_group IN($id_groups))";
} }
} }
if($filters['group']){ if($filters['group']){
$groups_and = " AND (ta.id_grupo =". $filters['group']." OR tasg.id_group =". $filters['group'].")"; //recursion check acl
if($filters['recursion']){
$recursion_groups = groups_get_id_recursive($filters['group'], true);
if (!users_can_manage_group_all("AR")) {
if(isset($user_groups) && is_array($user_groups)){
$groups_intersect = array_intersect($user_groups, $recursion_groups);
if(isset($groups_intersect) && is_array($groups_intersect)){
$groups_intersect = implode(", ", $groups_intersect);
$groups_and = " AND (ta.id_grupo IN ($groups_intersect) OR tasg.id_group IN($groups_intersect))";
}
else{
return false;
}
}
else{
return false;
}
}
else{
$recursion_groups = implode(", ", $recursion_groups);
$groups_and = " AND (ta.id_grupo IN ($recursion_groups) OR tasg.id_group IN($recursion_groups))";
}
}
else{
$groups_and = " AND (ta.id_grupo =". $filters['group']." OR tasg.id_group =". $filters['group'].")";
}
} }
//filter custom data //filter custom data
@ -264,17 +347,6 @@ function agent_counters_custom_fields($filters){
//filter custom name //filter custom name
$custom_field_name = $filters['id_custom_fields']; $custom_field_name = $filters['id_custom_fields'];
//filters module
$module_filter = "";
if($filters['module_search']){
$module_filter = ' AND (
SELECT count(*) AS n
FROM tagente_modulo
WHERE nombre LIKE "%' . $filters['module_search'] . '%"
AND id_agente=ta.id_agente
) > 0 ';
}
if(is_metaconsole()){ if(is_metaconsole()){
$metaconsole_connections = metaconsole_get_connection_names(); $metaconsole_connections = metaconsole_get_connection_names();
// For all nodes // For all nodes
@ -385,36 +457,38 @@ function agent_counters_custom_fields($filters){
); );
foreach ($result_meta as $k => $nodo) { foreach ($result_meta as $k => $nodo) {
foreach ($nodo as $key => $value) { if(isset($nodo) && is_array($nodo)){
//Sum counters total foreach ($nodo as $key => $value) {
$final_result['counters_total']['t_m_normal'] += $value['m_normal']; //Sum counters total
$final_result['counters_total']['t_m_critical'] += $value['m_critical']; $final_result['counters_total']['t_m_normal'] += $value['m_normal'];
$final_result['counters_total']['t_m_warning'] += $value['m_warning']; $final_result['counters_total']['t_m_critical'] += $value['m_critical'];
$final_result['counters_total']['t_m_unknown'] += $value['m_unknown']; $final_result['counters_total']['t_m_warning'] += $value['m_warning'];
$final_result['counters_total']['t_m_not_init'] += $value['m_not_init']; $final_result['counters_total']['t_m_unknown'] += $value['m_unknown'];
$final_result['counters_total']['t_m_alerts'] += $value['m_alerts']; $final_result['counters_total']['t_m_not_init'] += $value['m_not_init'];
$final_result['counters_total']['t_m_total'] += $value['m_total']; $final_result['counters_total']['t_m_alerts'] += $value['m_alerts'];
$final_result['counters_total']['t_a_critical'] += $value['a_critical']; $final_result['counters_total']['t_m_total'] += $value['m_total'];
$final_result['counters_total']['t_a_warning'] += $value['a_warning']; $final_result['counters_total']['t_a_critical'] += $value['a_critical'];
$final_result['counters_total']['t_a_unknown'] += $value['a_unknown']; $final_result['counters_total']['t_a_warning'] += $value['a_warning'];
$final_result['counters_total']['t_a_normal'] += $value['a_normal']; $final_result['counters_total']['t_a_unknown'] += $value['a_unknown'];
$final_result['counters_total']['t_a_not_init'] += $value['a_not_init']; $final_result['counters_total']['t_a_normal'] += $value['a_normal'];
$final_result['counters_total']['t_a_agents'] += $value['a_agents']; $final_result['counters_total']['t_a_not_init'] += $value['a_not_init'];
$final_result['counters_total']['t_a_agents'] += $value['a_agents'];
//Sum counters for data //Sum counters for data
$array_data[$value['name_data']]['m_normal'] += $value['m_normal']; $array_data[$value['name_data']]['m_normal'] += $value['m_normal'];
$array_data[$value['name_data']]['m_critical'] += $value['m_critical']; $array_data[$value['name_data']]['m_critical'] += $value['m_critical'];
$array_data[$value['name_data']]['m_warning'] += $value['m_warning']; $array_data[$value['name_data']]['m_warning'] += $value['m_warning'];
$array_data[$value['name_data']]['m_unknown'] += $value['m_unknown']; $array_data[$value['name_data']]['m_unknown'] += $value['m_unknown'];
$array_data[$value['name_data']]['m_not_init'] += $value['m_not_init']; $array_data[$value['name_data']]['m_not_init'] += $value['m_not_init'];
$array_data[$value['name_data']]['m_alerts'] += $value['m_alerts']; $array_data[$value['name_data']]['m_alerts'] += $value['m_alerts'];
$array_data[$value['name_data']]['m_total'] += $value['m_total']; $array_data[$value['name_data']]['m_total'] += $value['m_total'];
$array_data[$value['name_data']]['a_critical'] += $value['a_critical']; $array_data[$value['name_data']]['a_critical'] += $value['a_critical'];
$array_data[$value['name_data']]['a_warning'] += $value['a_warning']; $array_data[$value['name_data']]['a_warning'] += $value['a_warning'];
$array_data[$value['name_data']]['a_unknown'] += $value['a_unknown']; $array_data[$value['name_data']]['a_unknown'] += $value['a_unknown'];
$array_data[$value['name_data']]['a_normal'] += $value['a_normal']; $array_data[$value['name_data']]['a_normal'] += $value['a_normal'];
$array_data[$value['name_data']]['a_not_init'] += $value['a_not_init']; $array_data[$value['name_data']]['a_not_init'] += $value['a_not_init'];
$array_data[$value['name_data']]['a_agents'] += $value['a_agents']; $array_data[$value['name_data']]['a_agents'] += $value['a_agents'];
}
} }
} }
@ -432,8 +506,16 @@ function agent_counters_custom_fields($filters){
} }
function get_filters_custom_fields_view($id = 0, $for_select = false, $name = ""){ function get_filters_custom_fields_view($id = 0, $for_select = false, $name = ""){
//filter group and check ACL groups
$groups_and = "";
if (!users_can_manage_group_all()) {
$user_groups = array_keys(users_get_groups(false, "AR", false));
$id_groups = implode(", ", $user_groups);
$groups_and = " AND (group_search IN ($id_groups)) ";
}
if($for_select){ if($for_select){
$query = "SELECT id, `name` FROM tagent_custom_fields_filter"; $query = "SELECT id, `name` FROM tagent_custom_fields_filter WHERE 1=1" . $groups_and;
$rs = db_get_all_rows_sql($query); $rs = db_get_all_rows_sql($query);
if(isset($rs) && is_array($rs)){ if(isset($rs) && is_array($rs)){
foreach ($rs as $key => $value) { foreach ($rs as $key => $value) {
@ -445,7 +527,7 @@ function get_filters_custom_fields_view($id = 0, $for_select = false, $name = ""
} }
} }
else{ else{
$query = "SELECT * FROM tagent_custom_fields_filter WHERE 1=1"; $query = "SELECT * FROM tagent_custom_fields_filter WHERE 1=1" . $groups_and;
if($id){ if($id){
$query .= " AND id = " . $id; $query .= " AND id = " . $id;
@ -459,4 +541,13 @@ function get_filters_custom_fields_view($id = 0, $for_select = false, $name = ""
} }
return $result; return $result;
} }
function get_group_filter_custom_field_view ($id){
if(isset($id)){
$res = db_get_row_filter('tagent_custom_fields_filter',array('id' => $id));
return $res;
}
return false;
}
?> ?>

View File

@ -3371,5 +3371,8 @@ CREATE TABLE IF NOT EXISTS `tagent_custom_fields_filter` (
`id_custom_fields_data` varchar(600) default '', `id_custom_fields_data` varchar(600) default '',
`id_status` varchar(600) default '', `id_status` varchar(600) default '',
`module_search` varchar(600) default '', `module_search` varchar(600) default '',
`module_status` varchar(600) default '',
`recursion` int(1) unsigned default '0',
`group_search` int(10) unsigned default '0',
PRIMARY KEY(`id`) PRIMARY KEY(`id`)
) ENGINE = InnoDB DEFAULT CHARSET=utf8; ) ENGINE = InnoDB DEFAULT CHARSET=utf8;

View File

@ -109,10 +109,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('custom_report_front_logo', 'images/pandora_logo_white.jpg'), ('custom_report_front_logo', 'images/pandora_logo_white.jpg'),
('custom_report_front_header', ''), ('custom_report_front_header', ''),
('custom_report_front_footer', ''), ('custom_report_front_footer', ''),
('MR', 22), ('MR', 23),
('identification_reminder', 1), ('identification_reminder', 1),
('identification_reminder_timestamp', 0), ('identification_reminder_timestamp', 0),
('current_package_enterprise', '729'), ('current_package_enterprise', '730'),
('post_process_custom_values', '{"0.00000038580247":"Seconds&#x20;to&#x20;months","0.00000165343915":"Seconds&#x20;to&#x20;weeks","0.00001157407407":"Seconds&#x20;to&#x20;days","0.01666666666667":"Seconds&#x20;to&#x20;minutes","0.00000000093132":"Bytes&#x20;to&#x20;Gigabytes","0.00000095367432":"Bytes&#x20;to&#x20;Megabytes","0.0009765625":"Bytes&#x20;to&#x20;Kilobytes","0.00000001653439":"Timeticks&#x20;to&#x20;weeks","0.00000011574074":"Timeticks&#x20;to&#x20;days"}'), ('post_process_custom_values', '{"0.00000038580247":"Seconds&#x20;to&#x20;months","0.00000165343915":"Seconds&#x20;to&#x20;weeks","0.00001157407407":"Seconds&#x20;to&#x20;days","0.01666666666667":"Seconds&#x20;to&#x20;minutes","0.00000000093132":"Bytes&#x20;to&#x20;Gigabytes","0.00000095367432":"Bytes&#x20;to&#x20;Megabytes","0.0009765625":"Bytes&#x20;to&#x20;Kilobytes","0.00000001653439":"Timeticks&#x20;to&#x20;weeks","0.00000011574074":"Timeticks&#x20;to&#x20;days"}'),
('custom_docs_logo', 'default_docs.png'), ('custom_docs_logo', 'default_docs.png'),
('custom_support_logo', 'default_support.png'), ('custom_support_logo', 'default_support.png'),