2012-11-29 Miguel de Dios <miguel.dedios@artica.es>

* include/ajax/agent.php: optimiced the ajax hook "search_agents_2"
	for the metaconsoles.
	
	*include/functions_ui.php, include/functions_agents.php: cleaned
	source code style.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7205 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-11-29 16:14:45 +00:00
parent b1c4db4b9a
commit 7d3afcfb29
4 changed files with 43 additions and 32 deletions

View File

@ -1,3 +1,11 @@
2012-11-29 Miguel de Dios <miguel.dedios@artica.es>
* include/ajax/agent.php: optimiced the ajax hook "search_agents_2"
for the metaconsoles.
*include/functions_ui.php, include/functions_agents.php: cleaned
source code style.
2012-11-29 Vanessa Gil <vanessa.gil@artica.es>
* godmode/menu.php: Changed netflow title.

View File

@ -190,42 +190,43 @@ if ($search_agents_2 && (!defined('METACONSOLE'))) {
elseif ($search_agents_2 && ($config['metaconsole'] == 1) && defined('METACONSOLE')) {
$servers = db_get_all_rows_sql ("SELECT *
FROM tmetaconsole_setup");
FROM tmetaconsole_setup
WHERE disabled = 0");
if (!isset($servers)) {
return;
}
$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;
$data = array();
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;

View File

@ -355,7 +355,7 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
}
$status_sql = ' 1 = 1';
if (isset($filter['status'])) {
if (isset($filter['status'])) {
switch ($filter['status']) {
// Normal
case 0:
@ -430,13 +430,14 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
$fields[1] = "nombre";
}
if(isset($order['field'])) {
if (isset($order['field'])) {
if(!isset($order['order'])) {
$order['order'] = 'ASC';
}
if (!isset($order['field2'])) {
$order = 'ORDER BY '.$order['field'] . ' ' . $order['order'];
} else {
}
else {
$order = 'ORDER BY '.$order['field'] . ' ' . $order['order'] . ', ' . $order['field2'];
}
}
@ -457,7 +458,7 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
$where_nogroup = '1 = 1';
}
if($extra) {
if ($extra) {
$where = sprintf('(%s OR (%s)) AND (%s) AND (%s) %s', $sql_extra, $where, $where_nogroup, $status_sql, $search);
}
else {
@ -474,7 +475,7 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o
$limit_sql = " LIMIT $offset, $limit ";
}
$sql = sprintf("%s %s", $sql, $limit_sql);
//html_debug_print($sql, true);
if ($return)
return $sql;
else

View File

@ -1761,7 +1761,8 @@ function ui_toggle($code, $name, $title = '', $hidde_default = true, $return = f
// Link to toggle
$output = '';
$output .= '<a href="#" id="tgl_ctrl_'.$uniqid.'"><b>'.$name.'</b>&nbsp;'.html_print_image ($original, true, array ("title" => $title, "id" => "image_".$uniqid)).'</a><br /><br />';
$output .= '<a href="#" id="tgl_ctrl_'.$uniqid.'"><b>'.$name.'</b>&nbsp;'.html_print_image ($original, true, array ("title" => $title, "id" => "image_".$uniqid)).'</a>';
$output .= '<br /><br />';
// Code into a div
$output .= "<div id='tgl_div_".$uniqid."' style='".$style."'>\n";