2012-12-20 Sergio Martin <sergio.martin@artica.es>
* include/ajax/agent.php include/functions_ui.php include/constants.php operation/events/events_list.php: Modify the event list filter to adapt the agent search to metaconsole. Fix little bug of autocomplete control too git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7314 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
f6da945f45
commit
4e4a8b9e95
|
@ -1,3 +1,12 @@
|
|||
2012-12-20 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* include/ajax/agent.php
|
||||
include/functions_ui.php
|
||||
include/constants.php
|
||||
operation/events/events_list.php: Modify the event list
|
||||
filter to adapt the agent search to metaconsole.
|
||||
Fix little bug of autocomplete control too
|
||||
|
||||
2012-12-19 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
||||
|
||||
* include/functions_users.php: Fixed warning when chat log file
|
||||
|
|
|
@ -26,7 +26,6 @@ enterprise_include_once ('include/functions_metaconsole.php');
|
|||
// * q
|
||||
// * id_group
|
||||
$search_agents = (bool) get_parameter ('search_agents');
|
||||
$search_agents_2 = (bool) get_parameter ('search_agents_2');
|
||||
$get_agents_group = (bool) get_parameter('get_agents_group', false);
|
||||
$force_local = (bool) get_parameter('force_local', false);
|
||||
|
||||
|
@ -76,96 +75,7 @@ if ($get_agents_group) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ($search_agents && ($config['metaconsole'] == 0)) {
|
||||
|
||||
require_once ('include/functions_agents.php');
|
||||
|
||||
$id_agent = (int) get_parameter ('id_agent');
|
||||
$string = (string) get_parameter ('q'); /* q is what autocomplete plugin gives */
|
||||
$id_group = get_parameter('id_group', -1);
|
||||
$addedItems = html_entity_decode((string) get_parameter('add'));
|
||||
$addedItems = json_decode($addedItems);
|
||||
|
||||
if ($addedItems != null) {
|
||||
foreach ($addedItems as $item) {
|
||||
echo $item . "|\n";
|
||||
}
|
||||
}
|
||||
|
||||
$filter = array ();
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
case "postgresql":
|
||||
$filter[] = '(nombre COLLATE utf8_general_ci LIKE "%'.$string.'%" OR direccion LIKE "%'.$string.'%" OR comentarios LIKE "%'.$string.'%")';
|
||||
break;
|
||||
case "oracle":
|
||||
$filter[] = '(UPPER(nombre) LIKE UPPER(\'%'.$string.'%\') OR UPPER(direccion) LIKE UPPER(\'%'.$string.'%\') OR UPPER(comentarios) LIKE UPPER(\'%'.$string.'%\'))';
|
||||
break;
|
||||
}
|
||||
|
||||
if ($id_group != -1)
|
||||
$filter['id_grupo'] = $id_group;
|
||||
|
||||
$agents = agents_get_agents ($filter, array ('id_agente','nombre', 'direccion'));
|
||||
if ($agents === false)
|
||||
return;
|
||||
|
||||
foreach ($agents as $agent) {
|
||||
echo io_safe_output($agent['nombre']) . "|" . io_safe_output($agent['id_agente']) . "|" . io_safe_output($agent['direccion']) . "\n";
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
elseif ($search_agents && ($config['metaconsole'] == 1)) {
|
||||
$servers = db_get_all_rows_sql ("SELECT * FROM tmetaconsole_setup");
|
||||
if (!isset($servers)) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($servers as $server) {
|
||||
if (metaconsole_load_external_db ($server) != NOERR) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$id_agent = (int) get_parameter ('id_agent');
|
||||
$string = (string) get_parameter ('q'); /* q is what autocomplete plugin gives */
|
||||
$id_group = (int) get_parameter('id_group');
|
||||
$addedItems = html_entity_decode((string) get_parameter('add'));
|
||||
$addedItems = json_decode($addedItems);
|
||||
|
||||
if ($addedItems != null) {
|
||||
foreach ($addedItems as $item) {
|
||||
echo $item . "|\n";
|
||||
}
|
||||
}
|
||||
|
||||
$filter = array ();
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
case "postgresql":
|
||||
$filter[] = '(nombre COLLATE utf8_general_ci LIKE "%'.$string.'%" OR direccion LIKE "%'.$string.'%" OR comentarios LIKE "%'.$string.'%")';
|
||||
break;
|
||||
case "oracle":
|
||||
$filter[] = '(UPPER(nombre) LIKE UPPER(\'%'.$string.'%\') OR UPPER(direccion) LIKE UPPER(\'%'.$string.'%\') OR UPPER(comentarios) LIKE UPPER(\'%'.$string.'%\'))';
|
||||
break;
|
||||
}
|
||||
|
||||
$filter['id_grupo'] = $id_group;
|
||||
|
||||
$agents = agents_get_agents ($filter, array ('id_agente','nombre', 'direccion'));
|
||||
if ($agents === false)
|
||||
continue;
|
||||
foreach ($agents as $agent) {
|
||||
echo io_safe_output($agent['nombre']) . " (" . io_safe_output($server['server_name']) . ") " . "|" . io_safe_output($agent['id_agente']) . "|" . io_safe_output($server['server_name']) . "|" . io_safe_output($agent['direccion']) . "|". "\n";
|
||||
}
|
||||
//Restore db connection
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ($search_agents_2 && ((!defined('METACONSOLE')) || $force_local)) {
|
||||
|
||||
if ($search_agents && ((!defined('METACONSOLE')) || $force_local)) {
|
||||
require_once ('include/functions_agents.php');
|
||||
|
||||
$id_agent = (int) get_parameter ('id_agent');
|
||||
|
@ -194,8 +104,16 @@ if ($search_agents_2 && ((!defined('METACONSOLE')) || $force_local)) {
|
|||
break;
|
||||
}
|
||||
|
||||
if ($id_group != -1)
|
||||
$filter['id_grupo'] = $id_group;
|
||||
if ($id_group != -1) {
|
||||
if($id_group == 0) {
|
||||
$user_groups = users_get_groups ($config['id_user'], "AR", true);
|
||||
|
||||
$filter['id_grupo'] = array_keys ($user_groups);
|
||||
}
|
||||
else {
|
||||
$filter['id_grupo'] = $id_group;
|
||||
}
|
||||
}
|
||||
|
||||
switch ($all) {
|
||||
case 'enabled':
|
||||
|
@ -216,8 +134,7 @@ if ($search_agents_2 && ((!defined('METACONSOLE')) || $force_local)) {
|
|||
|
||||
return;
|
||||
}
|
||||
elseif ($search_agents_2 && ($config['metaconsole'] == 1) && defined('METACONSOLE')) {
|
||||
|
||||
elseif ($search_agents && ($config['metaconsole'] == 1) && defined('METACONSOLE')) {
|
||||
$servers = db_get_all_rows_sql ("SELECT *
|
||||
FROM tmetaconsole_setup
|
||||
WHERE disabled = 0");
|
||||
|
@ -227,7 +144,7 @@ elseif ($search_agents_2 && ($config['metaconsole'] == 1) && defined('METACONSOL
|
|||
|
||||
$id_agent = (int) get_parameter ('id_agent');
|
||||
$string = (string) get_parameter ('q'); /* q is what autocomplete plugin gives */
|
||||
$id_group = (int) get_parameter('id_group');
|
||||
$id_group = (int) get_parameter('id_group', -1);
|
||||
$addedItems = html_entity_decode((string) get_parameter('add'));
|
||||
$addedItems = json_decode($addedItems);
|
||||
|
||||
|
@ -248,8 +165,17 @@ elseif ($search_agents_2 && ($config['metaconsole'] == 1) && defined('METACONSOL
|
|||
break;
|
||||
}
|
||||
|
||||
$filter['id_grupo'] = $id_group;
|
||||
|
||||
if ($id_group != -1) {
|
||||
if($id_group == 0) {
|
||||
$user_groups = users_get_groups ($config['id_user'], "AR", true);
|
||||
|
||||
$filter['id_grupo'] = array_keys ($user_groups);
|
||||
}
|
||||
else {
|
||||
$filter['id_grupo'] = $id_group;
|
||||
}
|
||||
}
|
||||
|
||||
$data = array();
|
||||
foreach ($servers as $server) {
|
||||
if (metaconsole_load_external_db ($server) != NOERR) {
|
||||
|
|
|
@ -49,6 +49,8 @@ define ('ERR_NOCHANGES', -60000);
|
|||
define ('ERR_NODATA', -70000);
|
||||
define ('ERR_CONNECTION', -80000);
|
||||
define ('ERR_DISABLED', -90000);
|
||||
define ('ERR_WRONG', -100000);
|
||||
define ('ERR_WRONG_NAME', -100001);
|
||||
|
||||
/* Event status code */
|
||||
define ('EVENT_STATUS_NEW',0);
|
||||
|
|
|
@ -2552,7 +2552,7 @@ function ui_print_agent_autocomplete_input($parameters) {
|
|||
}
|
||||
|
||||
$javascript_change_ajax_params_original = array('page' => '"' . $javascript_page . '"',
|
||||
'search_agents_2' => 1,
|
||||
'search_agents' => 1,
|
||||
'id_group' => 'function() {
|
||||
var group_id = 0;
|
||||
|
||||
|
@ -2829,10 +2829,7 @@ function ui_print_agent_autocomplete_input($parameters) {
|
|||
|
||||
var term = input_value; //Word to search
|
||||
|
||||
var data_params = {"page": "include/ajax/agent",
|
||||
"search_agents_2": 1,
|
||||
"id_group": 0,
|
||||
"q": term};
|
||||
' . $javascript_change_ajax_params_text . '
|
||||
|
||||
if (' . ((int) !$metaconsole_enabled) . ') {
|
||||
data_params[\'force_local\'] = 1;
|
||||
|
|
|
@ -141,12 +141,10 @@ $tag_without_json = io_safe_output(get_parameter("tag_without"));
|
|||
$tag_without = json_decode($tag_without_json, true);
|
||||
if (empty($tag_without)) $tag_without = array();
|
||||
|
||||
if ($id_agent == 0) {
|
||||
$text_agent = (string) get_parameter("text_agent", __("All"));
|
||||
|
||||
if ($text_agent != __('All')) {
|
||||
$id_agent = -1;
|
||||
}
|
||||
$text_agent = (string) get_parameter("text_agent", __("All"));
|
||||
|
||||
if ($id_agent == 0 && $text_agent != __('All')) {
|
||||
$id_agent = -1;
|
||||
}
|
||||
|
||||
$groups = users_get_groups($config['id_user'], 'IR');
|
||||
|
@ -205,16 +203,24 @@ if ($event_type != "") {
|
|||
if ($severity != -1)
|
||||
$sql_post .= " AND criticity = " . $severity;
|
||||
|
||||
switch ($id_agent) {
|
||||
case 0:
|
||||
break;
|
||||
case -1:
|
||||
// Agent doesnt exist. No results will returned
|
||||
$sql_post .= " AND 1 = 0";
|
||||
break;
|
||||
default:
|
||||
$sql_post .= " AND id_agente = " . $id_agent;
|
||||
break;
|
||||
// In metaconsole mode the agent search is performed by name
|
||||
if($meta) {
|
||||
if($text_agent != __('All')) {
|
||||
$sql_post .= " AND agent_name LIKE '%$text_agent%'";
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch ($id_agent) {
|
||||
case 0:
|
||||
break;
|
||||
case -1:
|
||||
// Agent doesnt exist. No results will returned
|
||||
$sql_post .= " AND 1 = 0";
|
||||
break;
|
||||
default:
|
||||
$sql_post .= " AND id_agente = " . $id_agent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($id_event != -1)
|
||||
|
@ -349,10 +355,17 @@ echo '<td class="datos">';
|
|||
$params = array();
|
||||
$params['show_helptip'] = false;
|
||||
$params['input_name'] = 'text_agent';
|
||||
$params['print_hidden_input_idagent'] = true;
|
||||
$params['hidden_input_idagent_name'] = 'id_agent';
|
||||
$params['value'] = $text_agent;
|
||||
$params['hidden_input_idagent_value'] = $id_agent;
|
||||
|
||||
if($meta) {
|
||||
$params['javascript_page'] = 'enterprise/meta/include/ajax/events.ajax';
|
||||
}
|
||||
else {
|
||||
$params['print_hidden_input_idagent'] = true;
|
||||
$params['hidden_input_idagent_name'] = 'id_agent';
|
||||
$params['hidden_input_idagent_value'] = $id_agent;
|
||||
}
|
||||
|
||||
ui_print_agent_autocomplete_input($params);
|
||||
echo '</td>';
|
||||
|
||||
|
|
Loading…
Reference in New Issue