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 = '';
}
@ -269,12 +269,10 @@ if (is_ajax ())
'disabled' => 0,
'status' => $statusSel,
'search' => $search_sql),
array ('*'),
'AR',
false,
true);
break;
case 'os':
@ -290,12 +288,10 @@ if (is_ajax ())
'disabled' => 0,
'status' => $statusSel,
'search' => $search_sql),
array ('*'),
'AR',
false,
true);
break;
case 'module_group':
@ -312,7 +308,6 @@ if (is_ajax ())
'disabled' => 0,
'status' => $statusSel,
'search' => $search_sql),
array ('*'),
'AR',
false,
@ -327,7 +322,6 @@ if (is_ajax ())
AND tagente_modulo.disabled = 0
group by tagente.id_agente
having COUNT(*) > 0)';
break;
case 'policies':
@ -342,7 +336,6 @@ if (is_ajax ())
true);
if ($id != 0) {
// Skip agents without modules
$sql .= ' AND tagente.id_agente IN
(SELECT tagente.id_agente
@ -357,7 +350,6 @@ if (is_ajax ())
AND tpolicy_modules.id_policy = ' . $id . '
group by tagente.id_agente
having COUNT(*) > 0)';
}
else if ($statusSel == 0) {
@ -366,11 +358,7 @@ if (is_ajax ())
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 " "
@ -392,21 +380,18 @@ if (is_ajax ())
'AR',
false,
true);
$sql .= sprintf('AND id_agente IN (
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";
@ -800,9 +785,7 @@ if (is_ajax ())
break;
}
return;
}
@ -827,9 +810,13 @@ 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
$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
@ -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
@ -921,7 +901,8 @@ 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 {
}
else {
$sql_search ='';
}
@ -929,7 +910,6 @@ 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
@ -951,7 +931,6 @@ function printTree_($type) {
$list = db_get_all_rows_sql($sql_os);
break;
case 'group':
$stringAvariableGroups = (
implode(', ',
@ -971,11 +950,8 @@ 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)";
@ -984,7 +960,6 @@ function printTree_($type) {
'disabled' => 0,
'status' => $select_status,
'search' => $sql_search),
array ('id_agente'),
'AR',
false,
@ -1013,7 +988,6 @@ function printTree_($type) {
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,9 +1140,7 @@ function printTree_($type) {
array_push($list, array('id' => 0, 'name' => 'No policy'));
}
break;
case 'module':
$avariableGroupsIds = implode(',',array_keys($avariableGroups));
if($avariableGroupsIds == ''){
$avariableGroupsIds == -1;
@ -1156,7 +1149,8 @@ function printTree_($type) {
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 {
}
else {
$sql_search = '';
}
@ -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>';
}
}
@ -1313,7 +1314,8 @@ $module_group_tab = array('text' => "<a href='index.php?sec=estado&sec2=operatio
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 {
}
else {
$policies_tab = '';
}
@ -1377,6 +1379,7 @@ 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)
@ -1513,4 +1516,3 @@ printTree_($activeTab);
loadSubTree(type, div_id, less_branchs, id_father);
}
</script>