2012-07-18 Miguel de Dios <miguel.dedios@artica.es>

* extensions/resource_registration.php,
	extensions/update_manager/lib/libupdate_manager.php,
	extensions/plugin_registration.php,
	operation/incidents/incident.php,
	mobile/operation/agents/monitor_status.php,
	mobile/operation/agents/view_agents.php: cleaned source code style.

	* operation/tree.php: improve the code for to set more readble.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6789 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-07-18 14:31:58 +00:00
parent 5da06e0448
commit 50cd6e1033
8 changed files with 515 additions and 501 deletions

View File

@ -1,3 +1,14 @@
2012-07-18 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php,
extensions/update_manager/lib/libupdate_manager.php,
extensions/plugin_registration.php,
operation/incidents/incident.php,
mobile/operation/agents/monitor_status.php,
mobile/operation/agents/view_agents.php: cleaned source code style.
* operation/tree.php: improve the code for to set more readble.
2012-07-18 Miguel de Dios <miguel.dedios@artica.es>
* general/logon_ok.php, godmode/db/db_event.php,

View File

@ -105,7 +105,8 @@ class MonitorStatus {
$sqlStatus = " AND tagente_estado.estado = 3";
}
elseif ($status == 5) { //Not init
$sqlStatus = " AND tagente_estado.utimestamp = 0 AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,100)";
$sqlStatus = " AND tagente_estado.utimestamp = 0
AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,100)";
}

View File

@ -235,7 +235,6 @@ if (is_ajax ())
case 'module_group':
case 'policies':
case 'module':
$avariableGroups = users_get_groups();
$avariableGroupsIds = array_keys($avariableGroups);
@ -250,7 +249,8 @@ if (is_ajax ())
if ($search_free != '') {
$search_sql = " AND nombre COLLATE utf8_general_ci LIKE '%$search_free%'";
} else {
}
else {
$search_sql = '';
}
@ -261,152 +261,137 @@ if (is_ajax ())
//Skip agents which only have not init modules
$search_sql .= " AND id_agente NOT IN (SELECT tagente_estado.id_agente FROM
tagente_estado GROUP BY id_agente HAVING SUM(utimestamp) = 0)";
tagente_estado GROUP BY id_agente HAVING SUM(utimestamp) = 0)";
$sql = agents_get_agents(array (
'order' => 'nombre COLLATE utf8_general_ci ASC',
'id_grupo' => $id,
'disabled' => 0,
'status' => $statusSel,
'search' => $search_sql),
array ('*'),
'AR',
false,
true);
'order' => 'nombre COLLATE utf8_general_ci ASC',
'id_grupo' => $id,
'disabled' => 0,
'status' => $statusSel,
'search' => $search_sql),
array ('*'),
'AR',
false,
true);
break;
case 'os':
//Skip agents which only have not init modules
$search_sql .= " AND id_agente NOT IN (SELECT tagente_estado.id_agente FROM
tagente_estado GROUP BY id_agente HAVING SUM(utimestamp) = 0)";
tagente_estado GROUP BY id_agente HAVING SUM(utimestamp) = 0)";
$sql = agents_get_agents(array (
'order' => 'nombre COLLATE utf8_general_ci ASC',
'id_os' => $id,
'disabled' => 0,
'status' => $statusSel,
'search' => $search_sql),
array ('*'),
'AR',
false,
true);
'order' => 'nombre COLLATE utf8_general_ci ASC',
'id_os' => $id,
'disabled' => 0,
'status' => $statusSel,
'search' => $search_sql),
array ('*'),
'AR',
false,
true);
break;
case 'module_group':
//Skip agents which only have not init modules
$search_sql .= " AND id_agente NOT IN (SELECT tagente_estado.id_agente FROM tagente_estado
WHERE id_agente_modulo IN
(SELECT id_agente_modulo FROM tagente_modulo
WHERE id_module_group = $id)
GROUP BY id_agente HAVING SUM(utimestamp) = 0)";
WHERE id_agente_modulo IN
(SELECT id_agente_modulo FROM tagente_modulo
WHERE id_module_group = $id)
GROUP BY id_agente HAVING SUM(utimestamp) = 0)";
$sql = agents_get_agents(array (
'order' => 'nombre COLLATE utf8_general_ci ASC',
'disabled' => 0,
'status' => $statusSel,
'search' => $search_sql),
array ('*'),
'AR',
false,
true);
'order' => 'nombre COLLATE utf8_general_ci ASC',
'disabled' => 0,
'status' => $statusSel,
'search' => $search_sql),
array ('*'),
'AR',
false,
true);
// Skip agents without modules
$sql .= ' AND id_agente IN
(SELECT tagente.id_agente
FROM tagente, tagente_modulo
WHERE tagente.id_agente = tagente_modulo.id_agente
AND id_module_group = ' . $id . ' AND tagente.disabled = 0
AND tagente_modulo.disabled = 0
group by tagente.id_agente
having COUNT(*) > 0)';
(SELECT tagente.id_agente
FROM tagente, tagente_modulo
WHERE tagente.id_agente = tagente_modulo.id_agente
AND id_module_group = ' . $id . ' AND tagente.disabled = 0
AND tagente_modulo.disabled = 0
group by tagente.id_agente
having COUNT(*) > 0)';
break;
case 'policies':
$sql = agents_get_agents(array (
'order' => 'nombre COLLATE utf8_general_ci ASC',
'disabled' => 0,
'search' => $search_sql),
'order' => 'nombre COLLATE utf8_general_ci ASC',
'disabled' => 0,
'search' => $search_sql),
array ('*'),
'AR',
false,
true);
array ('*'),
'AR',
false,
true);
if ($id != 0) {
// Skip agents without modules
$sql .= ' AND tagente.id_agente IN
(SELECT tagente.id_agente
FROM tagente, tagente_modulo, tagente_estado, tpolicy_modules
WHERE tagente.id_agente = tagente_modulo.id_agente
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
AND tagente_modulo.id_policy_module = tpolicy_modules.id
AND tagente.disabled = 0
AND tagente_modulo.disabled = 0
AND tagente_estado.utimestamp != 0
AND tagente_modulo.id_policy_module != 0
AND tpolicy_modules.id_policy = ' . $id . '
group by tagente.id_agente
having COUNT(*) > 0)';
(SELECT tagente.id_agente
FROM tagente, tagente_modulo, tagente_estado, tpolicy_modules
WHERE tagente.id_agente = tagente_modulo.id_agente
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
AND tagente_modulo.id_policy_module = tpolicy_modules.id
AND tagente.disabled = 0
AND tagente_modulo.disabled = 0
AND tagente_estado.utimestamp != 0
AND tagente_modulo.id_policy_module != 0
AND tpolicy_modules.id_policy = ' . $id . '
group by tagente.id_agente
having COUNT(*) > 0)';
}
else if ($statusSel == 0) {
// If status filter is NORMAL add void agents
$sql .= " UNION SELECT * FROM tagente
WHERE tagente.disabled = 0
AND tagente.id_agente NOT IN (SELECT tagente_estado.id_agente
FROM tagente_estado)";
WHERE tagente.disabled = 0
AND tagente.id_agente NOT IN (SELECT tagente_estado.id_agente
FROM tagente_estado)";
}
break;
case 'module':
//Replace separator token "articapandora_32_pandoraartica_" for " "
//example:
// "Load_articapandora_32_pandoraartica_Average"
//result -> "Load Average"
// "Load_articapandora_32_pandoraartica_Average"
// result -> "Load Average"
$name = str_replace(array('_articapandora_'.ord(' ').'_pandoraartica_', '_articapandora_'.ord('#').'_pandoraartica_','_articapandora_'.ord('/').'_pandoraartica_'),array(' ','#','/'),$id);
$name = io_safe_input($name);
$sql = agents_get_agents(array (
'order' => 'nombre COLLATE utf8_general_ci ASC',
'disabled' => 0,
'status' => $statusSel,
'search' => $search_sql),
array ('*'),
'AR',
false,
true);
'order' => 'nombre COLLATE utf8_general_ci ASC',
'disabled' => 0,
'status' => $statusSel,
'search' => $search_sql),
array ('*'),
'AR',
false,
true);
$sql .= sprintf('AND id_agente IN (
SELECT id_agente
FROM tagente_modulo
WHERE nombre = \'%s\' AND disabled = 0
)
', $name);
SELECT id_agente
FROM tagente_modulo
WHERE nombre = \'%s\' AND disabled = 0
)
', $name);
break;
}
$sql .= ' AND tagente.disabled = 0'. $search_sql;
$countRows = db_get_num_rows($sql);
}
if ($countRows === 0) {
echo "<ul style='margin: 0; padding: 0;'>\n";
@ -441,8 +426,8 @@ if (is_ajax ())
$agent_info["alert_img"] = agents_tree_view_alert_img ($agent_info["monitor_alertsfired"]);
$agent_info["status_img"] = agetns_tree_view_status_img ($agent_info["monitor_critical"],
$agent_info["monitor_warning"],
$agent_info["monitor_unknown"]);
$agent_info["monitor_warning"],
$agent_info["monitor_unknown"]);
//Count all modules
$agent_info["modules"] = $agent_info["monitor_critical"] + $agent_info["monitor_warning"] + $agent_info["monitor_unknown"] + $agent_info["monitor_normal"];
@ -467,8 +452,8 @@ if (is_ajax ())
$agent_info["alert_img"] = agents_tree_view_alert_img ($agent_info["monitor_alertsfired"]);
$agent_info["status_img"] = agetns_tree_view_status_img ($agent_info["monitor_critical"],
$agent_info["monitor_warning"],
$agent_info["monitor_unknown"]);
$agent_info["monitor_warning"],
$agent_info["monitor_unknown"]);
//Count all modules
$agent_info["modules"] = $agent_info["monitor_critical"] + $agent_info["monitor_warning"] + $agent_info["monitor_unknown"] + $agent_info["monitor_normal"];
@ -484,8 +469,8 @@ if (is_ajax ())
$agent_info["alert_img"] = agents_tree_view_alert_img ($agent_info["monitor_alertsfired"]);
$agent_info["status_img"] = agetns_tree_view_status_img ($agent_info["monitor_critical"],
$agent_info["monitor_warning"],
$agent_info["monitor_unknown"]);
$agent_info["monitor_warning"],
$agent_info["monitor_unknown"]);
//Count all modules
$agent_info["modules"] = $agent_info["monitor_critical"] + $agent_info["monitor_warning"] + $agent_info["monitor_unknown"] + $agent_info["monitor_normal"];
@ -503,8 +488,8 @@ if (is_ajax ())
$agent_info["alert_img"] = agents_tree_view_alert_img ($agent_info["monitor_alertsfired"]);
$agent_info["status_img"] = agetns_tree_view_status_img ($agent_info["monitor_critical"],
$agent_info["monitor_warning"],
$agent_info["monitor_unknown"]);
$agent_info["monitor_warning"],
$agent_info["monitor_unknown"]);
//Count all modules
$agent_info["modules"] = $agent_info["monitor_critical"] + $agent_info["monitor_warning"] + $agent_info["monitor_unknown"] + $agent_info["monitor_normal"];
@ -522,8 +507,8 @@ if (is_ajax ())
$agent_info["alert_img"] = agents_tree_view_alert_img ($agent_info["monitor_alertsfired"]);
$agent_info["status_img"] = agetns_tree_view_status_img ($agent_info["monitor_critical"],
$agent_info["monitor_warning"],
$agent_info["monitor_unknown"]);
$agent_info["monitor_warning"],
$agent_info["monitor_unknown"]);
//Count all modules
$agent_info["modules"] = $agent_info["monitor_critical"] + $agent_info["monitor_warning"] + $agent_info["monitor_unknown"] + $agent_info["monitor_normal"];
@ -706,7 +691,7 @@ if (is_ajax ())
$new = true;
$count = 0;
echo "<ul style='margin: 0; padding: 0;'>\n";
while($row = db_get_all_row_by_steps_sql($new, $result, $sql)) {
while ($row = db_get_all_row_by_steps_sql($new, $result, $sql)) {
$new = false;
$count++;
echo "<li style='margin: 0; padding: 0;'><span style='min-width: 300px; display: inline-block;'>";
@ -800,9 +785,7 @@ if (is_ajax ())
break;
}
return;
}
@ -827,17 +810,21 @@ function printTree_($type) {
$avariableGroups = users_get_groups (); //db_get_all_rows_in_table('tgrupo', 'nombre');
//Get all groups with agents
$full_groups = db_get_all_rows_sql("SELECT DISTINCT tagente.id_grupo FROM tagente, tagente_estado WHERE
tagente.id_agente = tagente_estado.id_agente AND tagente_estado.utimestamp != 0
UNION SELECT tagente.id_grupo FROM tagente
WHERE disabled = 0
AND id_agente NOT IN (SELECT tagente.id_agente
FROM tagente, tagente_modulo
WHERE tagente.id_agente = tagente_modulo.id_agente
AND tagente.disabled = 0
AND tagente_modulo.disabled = 0
group by tagente.id_agente
having COUNT(*) > 0)");
$full_groups = db_get_all_rows_sql("SELECT DISTINCT tagente.id_grupo
FROM tagente, tagente_estado
WHERE tagente.id_agente = tagente_estado.id_agente AND
tagente_estado.utimestamp != 0
UNION
SELECT tagente.id_grupo
FROM tagente
WHERE disabled = 0
AND id_agente NOT IN (SELECT tagente.id_agente
FROM tagente, tagente_modulo
WHERE tagente.id_agente = tagente_modulo.id_agente
AND tagente.disabled = 0
AND tagente_modulo.disabled = 0
group by tagente.id_agente
having COUNT(*) > 0)");
$fgroups = array();
@ -870,9 +857,7 @@ function printTree_($type) {
}
break;
case WARNING:
foreach ($avariableGroups as $group_name) {
$id_group = db_get_value_sql('SELECT id_grupo FROM tgrupo where nombre ="' . $group_name . '"');
@ -882,9 +867,7 @@ function printTree_($type) {
unset($avariableGroups[$id_group]);
}
break;
case CRITICAL:
foreach ($avariableGroups as $group_name) {
$id_group = db_get_value_sql('SELECT id_grupo FROM tgrupo where nombre ="' . $group_name . '"');
@ -894,9 +877,7 @@ function printTree_($type) {
unset($avariableGroups[$id_group]);
}
break;
case UNKNOWN:
foreach ($avariableGroups as $group_name) {
$id_group = db_get_value_sql('SELECT id_grupo FROM tgrupo where nombre ="' . $group_name . '"');
@ -906,7 +887,6 @@ function printTree_($type) {
unset($avariableGroups[$id_group]);
}
break;
}
// If there are not groups display error and return
@ -920,8 +900,9 @@ function printTree_($type) {
if ($search_free != '') {
$sql_search = " AND id_grupo IN (SELECT id_grupo FROM tagente
WHERE nombre COLLATE utf8_general_ci LIKE '%$search_free%')";
} else {
WHERE nombre COLLATE utf8_general_ci LIKE '%$search_free%')";
}
else {
$sql_search ='';
}
@ -929,29 +910,27 @@ function printTree_($type) {
switch ($type) {
default:
case 'os':
//Skip agent with all modules in not init status
$sql_search .= " AND id_agente NOT IN (SELECT tagente_estado.id_agente FROM
tagente_estado GROUP BY id_agente HAVING SUM(utimestamp) = 0)";
tagente_estado GROUP BY id_agente HAVING SUM(utimestamp) = 0)";
$sql = agents_get_agents(array (
'order' => 'nombre COLLATE utf8_general_ci ASC',
'disabled' => 0,
'status' => $select_status,
'search' => $sql_search),
'order' => 'nombre COLLATE utf8_general_ci ASC',
'disabled' => 0,
'status' => $select_status,
'search' => $sql_search),
array ('tagente.id_os'),
'AR',
false,
true);
array ('tagente.id_os'),
'AR',
false,
true);
$sql_os = sprintf("SELECT * FROM tconfig_os WHERE id_os IN (%s)", $sql);
$list = db_get_all_rows_sql($sql_os);
break;
case 'group':
$stringAvariableGroups = (
implode(', ',
@ -971,37 +950,33 @@ function printTree_($type) {
break;
}
break;
case 'module_group':
//Skip agents which only have not init modules
$sql_search .= " AND id_agente NOT IN (SELECT tagente_estado.id_agente FROM
tagente_estado GROUP BY id_agente HAVING SUM(utimestamp) = 0)";
tagente_estado GROUP BY id_agente HAVING SUM(utimestamp) = 0)";
$sql = agents_get_agents(array (
'order' => 'nombre COLLATE utf8_general_ci ASC',
'disabled' => 0,
'status' => $select_status,
'search' => $sql_search),
array ('id_agente'),
'AR',
false,
true);
'order' => 'nombre COLLATE utf8_general_ci ASC',
'disabled' => 0,
'status' => $select_status,
'search' => $sql_search),
array ('id_agente'),
'AR',
false,
true);
// Skip agents without modules
$sql .= ' AND id_agente IN
(SELECT tagente.id_agente
FROM tagente, tagente_modulo
WHERE tagente.id_agente = tagente_modulo.id_agente
AND tagente.disabled = 0
AND tagente_modulo.disabled = 0
group by tagente.id_agente
having COUNT(*) > 0)';
(SELECT tagente.id_agente
FROM tagente, tagente_modulo
WHERE tagente.id_agente = tagente_modulo.id_agente
AND tagente.disabled = 0
AND tagente_modulo.disabled = 0
group by tagente.id_agente
having COUNT(*) > 0)';
$sql_module_groups = sprintf("SELECT * FROM tmodule_group
WHERE id_mg IN (SELECT id_module_group FROM tagente_modulo WHERE id_agente IN (%s))", $sql);
WHERE id_mg IN (SELECT id_module_group FROM tagente_modulo WHERE id_agente IN (%s))", $sql);
$list = db_get_all_rows_sql($sql_module_groups);
@ -1010,10 +985,9 @@ function printTree_($type) {
$list = array();
}
array_push($list, array('id_mg' => 0, 'name' => 'Not assigned'));
array_push($list, array('id_mg' => 0, 'name' => 'Not assigned'));
break;
case 'policies':
$avariableGroups = users_get_groups ();
@ -1021,11 +995,21 @@ function printTree_($type) {
$groups = implode(',',$groups_id);
if ($search_free != '') {
$sql = "SELECT DISTINCT tpolicies.id, tpolicies.name FROM tpolicies, tpolicy_modules, tagente_estado, tagente, tagente_modulo WHERE
tagente.id_agente = tagente_estado.id_agente AND tagente_modulo.id_agente = tagente_estado.id_agente AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND
tagente_estado.utimestamp != 0 AND tagente_modulo.id_policy_module != 0 AND tpolicy_modules.id = tagente_modulo.id_policy_module AND tpolicies.id = tpolicy_modules.id_policy AND
tagente.id_grupo IN ($groups) AND tagente.nombre LIKE '%$search_free%' AND tagente.disabled = 0 AND tagente_modulo.disabled = 0";
$sql = "SELECT DISTINCT tpolicies.id, tpolicies.name
FROM tpolicies, tpolicy_modules,
tagente_estado, tagente, tagente_modulo
WHERE
tagente.id_agente = tagente_estado.id_agente AND
tagente_modulo.id_agente = tagente_estado.id_agente AND
tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND
tagente_estado.utimestamp != 0 AND
tagente_modulo.id_policy_module != 0 AND
tpolicy_modules.id = tagente_modulo.id_policy_module AND
tpolicies.id = tpolicy_modules.id_policy AND
tagente.id_grupo IN ($groups) AND
tagente.nombre LIKE '%$search_free%' AND
tagente.disabled = 0 AND
tagente_modulo.disabled = 0";
$list = db_get_all_rows_sql($sql);
@ -1084,12 +1068,23 @@ function printTree_($type) {
$list = array();
array_push($list, array('id' => 0, 'name' => 'No policy'));
} else {
$list = db_get_all_rows_sql("SELECT DISTINCT tpolicies.id, tpolicies.name FROM tpolicies, tpolicy_modules, tagente_estado, tagente, tagente_modulo WHERE
tagente.id_agente = tagente_estado.id_agente AND tagente_modulo.id_agente = tagente_estado.id_agente AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND
tagente_estado.utimestamp != 0 AND tagente_modulo.id_policy_module != 0 AND tpolicy_modules.id = tagente_modulo.id_policy_module AND tpolicies.id = tpolicy_modules.id_policy AND
tagente.id_grupo IN ($groups) AND tagente.disabled = 0 AND tagente_modulo.disabled = 0");
}
else {
$list = db_get_all_rows_sql("SELECT DISTINCT tpolicies.id,
tpolicies.name
FROM tpolicies, tpolicy_modules, tagente_estado,
tagente, tagente_modulo
WHERE
tagente.id_agente = tagente_estado.id_agente AND
tagente_modulo.id_agente = tagente_estado.id_agente AND
tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND
tagente_estado.utimestamp != 0 AND
tagente_modulo.id_policy_module != 0 AND
tpolicy_modules.id = tagente_modulo.id_policy_module AND
tpolicies.id = tpolicy_modules.id_policy AND
tagente.id_grupo IN ($groups) AND
tagente.disabled = 0 AND
tagente_modulo.disabled = 0");
$element = 0;
switch ($select_status) {
@ -1145,19 +1140,18 @@ function printTree_($type) {
array_push($list, array('id' => 0, 'name' => 'No policy'));
}
break;
case 'module':
$avariableGroupsIds = implode(',',array_keys($avariableGroups));
if($avariableGroupsIds == ''){
$avariableGroupsIds == -1;
}
if ($search_free != '') {
$sql_search = " AND t1.id_agente IN (SELECT id_agente FROM tagente
WHERE nombre COLLATE utf8_general_ci LIKE '%$search_free%')";
} else {
$sql_search = '';
$sql_search = " AND t1.id_agente IN (SELECT id_agente FROM tagente
WHERE nombre COLLATE utf8_general_ci LIKE '%$search_free%')";
}
else {
$sql_search = '';
}
if ($select_status != -1)
@ -1167,22 +1161,33 @@ function printTree_($type) {
case "mysql":
case "postgresql":
$list = db_get_all_rows_sql('SELECT t1.nombre
FROM tagente_modulo t1, tagente t2, tagente_estado t3
WHERE t1.id_agente = t2.id_agente AND t1.id_agente_modulo = t3.id_agente_modulo
AND t2.disabled = 0 AND t1.disabled = 0
AND t3.utimestamp !=0 AND t2.id_grupo in (' . $avariableGroupsIds . ')' .$sql_search.'
FROM tagente_modulo t1, tagente t2,
tagente_estado t3
WHERE t1.id_agente = t2.id_agente AND
t1.id_agente_modulo = t3.id_agente_modulo AND
t2.disabled = 0 AND t1.disabled = 0 AND
t3.utimestamp !=0 AND
t2.id_grupo in (' . $avariableGroupsIds . ')' .
$sql_search.'
GROUP BY t1.nombre ORDER BY t1.nombre');
break;
case "oracle":
$list = db_get_all_rows_sql('SELECT dbms_lob.substr(t1.nombre,4000,1) as nombre
FROM tagente_modulo t1, tagente t2, tagente_estado t3
WHERE t1.id_agente = t2.id_agente AND t2.id_grupo in (' . $avariableGroupsIds . ') AND t1.id_agente_modulo = t3.id_agente_modulo
AND t2.disabled = 0 AND t1.disabled = 0 AND t3.utimestamp !=0 GROUP BY dbms_lob.substr(t1.nombre,4000,1) ORDER BY dbms_lob.substr(t1.nombre,4000,1) ASC');
$list = db_get_all_rows_sql('
SELECT dbms_lob.substr(t1.nombre,4000,1) as nombre
FROM tagente_modulo t1, tagente t2,
tagente_estado t3
WHERE t1.id_agente = t2.id_agente AND
t2.id_grupo in (' . $avariableGroupsIds . ') AND
t1.id_agente_modulo = t3.id_agente_modulo AND
t2.disabled = 0 AND
t1.disabled = 0 AND
t3.utimestamp !=0
GROUP BY dbms_lob.substr(t1.nombre,4000,1)
ORDER BY dbms_lob.substr(t1.nombre,4000,1) ASC');
break;
}
break;
}
if ($list === false) {
@ -1279,14 +1284,10 @@ function printTree_($type) {
echo "</ul>\n";
echo '</td>';
echo '<td style="width:38%" valign="top">';
echo '<div id="cont">';
echo '&nbsp;';
echo'</div>';
echo '<div id="cont">&nbsp;</div>';
echo '</td></tr>';
echo '</table>';
echo '</table>';
}
}
@ -1302,23 +1303,24 @@ $img_style = array ("class" => "top", "width" => 16);
$activeTab = get_parameter('sort_by','group');
$os_tab = array('text' => "<a href='index.php?sec=estado&sec2=operation/tree&refr=0&sort_by=os'>"
. html_print_image ("images/computer.png", true, array ("title" => __('OS'))) . "</a>", 'active' => $activeTab == "os");
. html_print_image ("images/computer.png", true, array ("title" => __('OS'))) . "</a>", 'active' => $activeTab == "os");
$group_tab = array('text' => "<a href='index.php?sec=estado&sec2=operation/tree&refr=0&sort_by=group'>"
. html_print_image ("images/group.png", true, array ("title" => __('Groups'))) . "</a>", 'active' => $activeTab == "group");
. html_print_image ("images/group.png", true, array ("title" => __('Groups'))) . "</a>", 'active' => $activeTab == "group");
$module_group_tab = array('text' => "<a href='index.php?sec=estado&sec2=operation/tree&refr=0&sort_by=module_group'>"
. html_print_image ("images/agents_group.png", true, array ("title" => __('Module groups'))) . "</a>", 'active' => $activeTab == "module_group");
. html_print_image ("images/agents_group.png", true, array ("title" => __('Module groups'))) . "</a>", 'active' => $activeTab == "module_group");
if ($enterpriseEnable) {
$policies_tab = array('text' => "<a href='index.php?sec=estado&sec2=operation/tree&refr=0&sort_by=policies'>"
. html_print_image ("images/policies.png", true, array ("title" => __('Policies'))) . "</a>", 'active' => $activeTab == "policies");
} else {
. html_print_image ("images/policies.png", true, array ("title" => __('Policies'))) . "</a>", 'active' => $activeTab == "policies");
}
else {
$policies_tab = '';
}
$module_tab = array('text' => "<a href='index.php?extension_in_menu=estado&sec=estado&sec2=operation/tree&refr=0&sort_by=module'>"
. html_print_image ("images/brick.png", true, array ("title" => __('Modules'))) . "</a>", 'active' => $activeTab == "module");
. html_print_image ("images/brick.png", true, array ("title" => __('Modules'))) . "</a>", 'active' => $activeTab == "module");
$onheader = array('os' => $os_tab, 'group' => $group_tab, 'module_group' => $module_group_tab, 'policies' => $policies_tab, 'module' => $module_tab);
@ -1377,140 +1379,140 @@ printTree_($activeTab);
var status = $('#status').val();
var search_free = $('#text-search_free').val();
/**
* loadSubTree asincronous load ajax the agents or modules (pass type, id to search and binary structure of branch),
* change the [+] or [-] image (with same more or less div id) of tree and anime (for show or hide)
* the div with id "div[id_father]_[type]_[div_id]"
*
* type string use in js and ajax php
* div_id int use in js and ajax php
* less_branchs int use in ajax php as binary structure 0b00, 0b01, 0b10 and 0b11
* id_father int use in js and ajax php, its useful when you have a two subtrees with same agent for diferent each one
*/
function loadSubTree(type, div_id, less_branchs, id_father) {
hiddenDiv = $('#tree_div'+id_father+'_'+type+'_'+div_id).attr('hiddenDiv');
loadDiv = $('#tree_div'+id_father+'_'+type+'_'+div_id).attr('loadDiv');
pos = parseInt($('#tree_image'+id_father+'_'+type+'_'+div_id).attr('pos_tree'));
//If has yet ajax request running
if (loadDiv == 2)
return;
/**
* loadSubTree asincronous load ajax the agents or modules (pass type, id to search and binary structure of branch),
* change the [+] or [-] image (with same more or less div id) of tree and anime (for show or hide)
* the div with id "div[id_father]_[type]_[div_id]"
*
* type string use in js and ajax php
* div_id int use in js and ajax php
* less_branchs int use in ajax php as binary structure 0b00, 0b01, 0b10 and 0b11
* id_father int use in js and ajax php, its useful when you have a two subtrees with same agent for diferent each one
*/
function loadSubTree(type, div_id, less_branchs, id_father) {
hiddenDiv = $('#tree_div'+id_father+'_'+type+'_'+div_id).attr('hiddenDiv');
loadDiv = $('#tree_div'+id_father+'_'+type+'_'+div_id).attr('loadDiv');
pos = parseInt($('#tree_image'+id_father+'_'+type+'_'+div_id).attr('pos_tree'));
if (loadDiv == 0) {
//If has yet ajax request running
if (loadDiv == 2)
return;
//Put an spinner to simulate loading process
$('#tree_div'+id_father+'_'+type+'_'+div_id).html("<img style='padding-top:10px;padding-bottom:10px;padding-left:20px;' src=images/spinner.gif>");
$('#tree_div'+id_father+'_'+type+'_'+div_id).show('normal');
if (loadDiv == 0) {
$('#tree_div'+id_father+'_'+type+'_'+div_id).attr('loadDiv', 2);
$.ajax({
type: "POST",
url: "ajax.php",
data: "page=<?php echo $_GET['sec2']; ?>&ajax_treeview=1&type=" +
type + "&id=" + div_id + "&less_branchs=" + less_branchs + "&id_father=" + id_father + "&status=" + status + "&search_free=" + search_free,
success: function(msg){
if (msg.length != 0) {
$('#tree_div'+id_father+'_'+type+'_'+div_id).hide();
$('#tree_div'+id_father+'_'+type+'_'+div_id).html(msg);
$('#tree_div'+id_father+'_'+type+'_'+div_id).show('normal');
//Put an spinner to simulate loading process
$('#tree_div'+id_father+'_'+type+'_'+div_id).html("<img style='padding-top:10px;padding-bottom:10px;padding-left:20px;' src=images/spinner.gif>");
$('#tree_div'+id_father+'_'+type+'_'+div_id).show('normal');
//change image of tree [+] to [-]
switch (pos) {
case 0:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src','operation/tree/first_expanded.png');
break;
case 1:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src','operation/tree/one_expanded.png');
break;
case 2:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src','operation/tree/expanded.png');
break;
case 3:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src','operation/tree/last_expanded.png');
break;
}
$('#tree_div'+id_father+'_'+type+'_'+div_id).attr('hiddendiv',0);
$('#tree_div'+id_father+'_'+type+'_'+div_id).attr('loadDiv', 1);
}
}
});
}
else {
if (hiddenDiv == 0) {
$('#tree_div'+id_father+'_'+type+'_'+div_id).hide('normal');
$('#tree_div'+id_father+'_'+type+'_'+div_id).attr('hiddenDiv',1);
//change image of tree [-] to [+]
switch (pos) {
case 0:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src','operation/tree/first_closed.png');
break;
case 1:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src','operation/tree/one_closed.png');
break;
case 2:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src','operation/tree/closed.png');
break;
case 3:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src','operation/tree/last_closed.png');
break;
}
}
else {
//change image of tree [+] to [-]
switch (pos) {
case 0:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src','operation/tree/first_expanded.png');
break;
case 1:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src','operation/tree/one_expanded.png');
break;
case 2:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src','operation/tree/expanded.png');
break;
case 3:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src','operation/tree/last_expanded.png');
break;
}
$('#tree_div'+id_father+'_'+type+'_'+div_id).show('normal');
$('#tree_div'+id_father+'_'+type+'_'+div_id).attr('hiddenDiv',0);
}
}
}
function changeStatus(newStatus) {
status = newStatus;
//reset all subtree
$(".tree_view").each(
function(i) {
$(this).attr('loadDiv', 0);
$(this).attr('hiddenDiv',1);
$(this).hide();
}
);
//clean all subtree
$(".tree_view").each(
function(i) {
$(this).html('');
}
);
}
function loadTable(type, div_id, less_branchs, id_father) {
id_agent = div_id;
$('#tree_div'+id_father+'_'+type+'_'+div_id).attr('loadDiv', 2);
$.ajax({
type: "POST",
url: "ajax.php",
data: "page=<?php echo $_GET['sec2']; ?>&printTable=1&id_agente=" +
id_agent, success: function(data){
$('#cont').html(data);
data: "page=<?php echo $_GET['sec2']; ?>&ajax_treeview=1&type=" +
type + "&id=" + div_id + "&less_branchs=" + less_branchs + "&id_father=" + id_father + "&status=" + status + "&search_free=" + search_free,
success: function(msg){
if (msg.length != 0) {
$('#tree_div'+id_father+'_'+type+'_'+div_id).hide();
$('#tree_div'+id_father+'_'+type+'_'+div_id).html(msg);
$('#tree_div'+id_father+'_'+type+'_'+div_id).show('normal');
//change image of tree [+] to [-]
switch (pos) {
case 0:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src','operation/tree/first_expanded.png');
break;
case 1:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src','operation/tree/one_expanded.png');
break;
case 2:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src','operation/tree/expanded.png');
break;
case 3:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src','operation/tree/last_expanded.png');
break;
}
$('#tree_div'+id_father+'_'+type+'_'+div_id).attr('hiddendiv',0);
$('#tree_div'+id_father+'_'+type+'_'+div_id).attr('loadDiv', 1);
}
}
});
}
else {
if (hiddenDiv == 0) {
$('#tree_div'+id_father+'_'+type+'_'+div_id).hide('normal');
$('#tree_div'+id_father+'_'+type+'_'+div_id).attr('hiddenDiv',1);
loadSubTree(type, div_id, less_branchs, id_father);
//change image of tree [-] to [+]
switch (pos) {
case 0:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src','operation/tree/first_closed.png');
break;
case 1:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src','operation/tree/one_closed.png');
break;
case 2:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src','operation/tree/closed.png');
break;
case 3:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src','operation/tree/last_closed.png');
break;
}
}
else {
//change image of tree [+] to [-]
switch (pos) {
case 0:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src','operation/tree/first_expanded.png');
break;
case 1:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src','operation/tree/one_expanded.png');
break;
case 2:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src','operation/tree/expanded.png');
break;
case 3:
$('#tree_image'+id_father+'_'+type+'_'+div_id).attr('src','operation/tree/last_expanded.png');
break;
}
$('#tree_div'+id_father+'_'+type+'_'+div_id).show('normal');
$('#tree_div'+id_father+'_'+type+'_'+div_id).attr('hiddenDiv',0);
}
}
}
function changeStatus(newStatus) {
status = newStatus;
//reset all subtree
$(".tree_view").each(
function(i) {
$(this).attr('loadDiv', 0);
$(this).attr('hiddenDiv',1);
$(this).hide();
}
);
//clean all subtree
$(".tree_view").each(
function(i) {
$(this).html('');
}
);
}
function loadTable(type, div_id, less_branchs, id_father) {
id_agent = div_id;
$.ajax({
type: "POST",
url: "ajax.php",
data: "page=<?php echo $_GET['sec2']; ?>&printTable=1&id_agente=" +
id_agent, success: function(data){
$('#cont').html(data);
}
});
loadSubTree(type, div_id, less_branchs, id_father);
}
</script>