0) { db_pandora_audit("Massive management", "Delete conf file " . $id_agent); } else { db_pandora_audit("Massive management", "Try to delete conf file " . $id_agent); } ui_print_result_message ($n_deleted > 0, __('Configuration files deleted successfully') . '(' . $n_deleted . ')', __('Configuration files cannot be deleted')); } if (empty($values) && empty($fields)) { $id_agents = array(); } $n_edited = 0; $result = false; foreach ($id_agents as $id_agent) { if (!empty($values)) { $group_old = false; $disabled_old = false; if($values['id_grupo'] || isset($values['disabled'])){ $values_old = db_get_row_filter('tagente', array('id_agente' => $id_agent), array('id_grupo', 'disabled')); if ($values_old['id_grupo']) $group_old = $values_old['id_grupo']; if (isset($values['disabled'])) $disabled_old = $values_old['disabled']; } $result = db_process_sql_update ('tagente', $values, array ('id_agente' => $id_agent)); if ($result && $config['metaconsole_agent_cache'] == 1) { $server_name['server_name'] = db_get_sql("SELECT server_name FROM tagente WHERE id_agente =" .$id_agent); // Force an update of the agent cache. $result_metaconsole = agent_update_from_cache($id_agent,$values,$server_name); } if ($disabled_old !== false && $disabled_old != $values['disabled']) { enterprise_hook( 'config_agents_update_config_token', array($id_agent, 'standby', $values['disabled']) ); } if($group_old || $result){ if ($group_old && $group_old != null) { $tpolicy_group_old = db_get_all_rows_sql("SELECT id_policy FROM tpolicy_groups WHERE id_group = ".$group_old); } else { $tpolicy_group_old = db_get_all_rows_sql("SELECT id_policy FROM tpolicy_groups"); } if($tpolicy_group_old){ foreach ($tpolicy_group_old as $key => $value) { $tpolicy_agents_old= db_get_sql("SELECT * FROM tpolicy_agents WHERE id_policy = ".$value['id_policy'] . " AND id_agent = " .$id_agent); if($tpolicy_agents_old){ $result2 = db_process_sql_update ('tpolicy_agents', array('pending_delete' => 1), array ('id_agent' => $id_agent, 'id_policy' => $value['id_policy'])); } } } if ($values['id_grupo'] && $values['id_grupo'] != null) { $tpolicy_group_new = db_get_all_rows_sql("SELECT id_policy FROM tpolicy_groups WHERE id_group = ".$values['id_grupo']); } else { $tpolicy_group_new = db_get_all_rows_sql("SELECT id_policy FROM tpolicy_groups"); } if($tpolicy_group_new){ foreach ($tpolicy_group_new as $key => $value) { $tpolicy_agents_new= db_get_sql("SELECT * FROM tpolicy_agents WHERE id_policy = ".$value['id_policy'] . " AND id_agent =" .$id_agent); if(!$tpolicy_agents_new){ db_process_sql_insert ('tpolicy_agents', array('id_policy' => $value['id_policy'], 'id_agent' => $id_agent)); } else { $result3 = db_process_sql_update ('tpolicy_agents', array('pending_delete' => 0), array ('id_agent' => $id_agent, 'id_policy' => $value['id_policy'])); } } } } } $info = array(); // Update Custom Fields foreach ($fields as $field) { $info[$field['id_field']] = $field['name']; if (get_parameter_post ('customvalue_' . $field['id_field'], '') != '') { $key = $field['id_field']; $value = get_parameter_post ('customvalue_' . $field['id_field'], ''); $old_value = db_get_all_rows_filter('tagent_custom_data', array('id_agent' => $id_agent, 'id_field' => $key)); if ($old_value === false) { // Create custom field if not exist $result = db_process_sql_insert ('tagent_custom_data', array('id_field' => $key, 'id_agent' => $id_agent, 'description' => $value)); } else { $result = db_process_sql_update ('tagent_custom_data', array('description' => $value), array('id_field' => $key,'id_agent' => $id_agent)); } } } $n_edited += (int)$result; } if ($result !== false) { db_pandora_audit("Massive management", "Update agent " . $id_agent, false, false, json_encode($info)); } else { if (isset ($id_agent)) { db_pandora_audit("Massive management", "Try to update agent " . $id_agent, false, false, json_encode($info)); } } ui_print_result_message ($result !== false, __('Agents updated successfully') . '(' . $n_edited . ')', __('Agents cannot be updated (maybe there was no field to update)')); } $id_group = 0; $groups = users_get_groups(); $table = new StdClass(); $table->id = 'delete_table'; $table->class = 'databox filters'; $table->width = '100%'; $table->data = array (); $table->style = array (); $table->style[0] = 'font-weight: bold;'; $table->style[2] = 'font-weight: bold'; $table->size = array (); $table->size[0] = '15%'; $table->size[1] = '35%'; $table->size[2] = '15%'; $table->size[3] = '35%'; $table->data = array (); $table->data[0][0] = __('Group'); $table->data[0][1] = html_print_select_groups(false, "AW", true, 'id_group', $id_group, false, '', '', true); $table->data[0][2] = __('Group recursion'); $table->data[0][3] = html_print_checkbox ("recursion2", 1, $recursion, true, false); $status_list = array (); $status_list[AGENT_STATUS_NORMAL] = __('Normal'); $status_list[AGENT_STATUS_WARNING] = __('Warning'); $status_list[AGENT_STATUS_CRITICAL] = __('Critical'); $status_list[AGENT_STATUS_UNKNOWN] = __('Unknown'); $status_list[AGENT_STATUS_NOT_NORMAL] = __('Not normal'); $status_list[AGENT_STATUS_NOT_INIT] = __('Not init'); $table->data[1][0] = __('Status'); $table->data[1][1] = html_print_select($status_list, 'status_agents', 'selected', '', __('All'), AGENT_STATUS_ALL, true); $table->data[1][2] = __('Show agents'); $table->data[1][3] = html_print_select (array(0 => 'Only enabled',1 => 'Only disabled'), 'disabled',2,'',__('All'), 2,true,'','','','','width:30%;'); $table->data[2][0] = __('Agents'); $table->data[2][0] .= ''; $enabled_agents = agents_get_group_agents (array_keys (users_get_groups ($config["id_user"], "AW", false)), array('disabled' => 0), "none"); $all_agents = agents_get_group_agents (array_keys (users_get_groups ($config["id_user"], "AW", false)), array('disabled' => 1), "none") + $enabled_agents; $table->data[2][1] = html_print_select ($all_agents, 'id_agents[]', 0, false, '', '', true, true); echo '
'; html_print_table ($table); $nombre_agente = ""; $direccion_agente = ""; $id_agente = 0; $id_parent = 0; $cascade_protection = 0; $group = 0; $interval = ''; $id_os = 0; $server_name = 0; $description = ""; echo '
'; ui_require_jquery_file ('form'); ui_require_jquery_file ('pandora.controls'); ui_require_jquery_file ('pandora.controls'); ui_require_jquery_file ('ajaxqueue'); ui_require_jquery_file ('bgiframe'); ?>