2013-12-05 Miguel de Dios <miguel.dedios@artica.es>

* include/functions_api.php: fixed the get events when not found the
	agent, before it returned the systems events, now it returns empty
	list.
	
	MERGED FROM THE BRANCH PANDORA_4




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9169 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-12-05 14:00:51 +00:00
parent c38d9e02f3
commit f30a3708dd
2 changed files with 41 additions and 15 deletions

View File

@ -1,3 +1,11 @@
2013-12-05 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_api.php: fixed the get events when not found the
agent, before it returned the systems events, now it returns empty
list.
MERGED FROM THE BRANCH PANDORA_4
2013-12-05 Dario Rodriguez <dario@artica.es>
* mobile/operation/agents.php: Removed a filter option which

View File

@ -133,9 +133,9 @@ function returnData($returnType, $data, $separator = ';') {
}
else {
if (!empty($data['data'])) {
foreach($data['data'] as $dataContent) {
foreach ($data['data'] as $dataContent) {
$clean = array_map("array_apply_io_safe_output", $dataContent);
foreach($clean as $k => $v) {
foreach ($clean as $k => $v) {
$clean[$k] = str_replace("\r", "\n", $clean[$k]);
$clean[$k] = str_replace("\n", " ", $clean[$k]);
$clean[$k] = strip_tags($clean[$k]);
@ -333,6 +333,7 @@ function api_get_tree_agents($trash1, $trahs2, $other, $returnType)
foreach($fields as $index => $field)
$fields[$index] = trim($field);
}
}
else {
if (strlen($other['data']) == 0)
@ -2939,7 +2940,7 @@ function api_set_validate_all_alerts($id, $thrash1, $other, $thrash3) {
}
}
if ($total_alerts > $count_results){
if ($total_alerts > $count_results) {
$errors = $total_alerts - $count_results;
returnError('error_validate_all_alerts', __('Error validate all alerts. Failed ' . $errors . '.'));
}
@ -4463,8 +4464,14 @@ function otherParameter2Filter($other, $return_as_array = false) {
$idAgent = null;
if (isset($other['data'][2]) && $other['data'][2] != '') {
$idAgent = agents_get_agent_id($other['data'][2]);
if (!empty($idAgent)) {
$filter['id_agente'] = $idAgent;
}
else {
$filter['sql'] = "1=0";
}
}
$idAgentModulo = null;
if (isset($other['data'][3]) && $other['data'][3] != '') {
@ -4725,6 +4732,7 @@ function api_set_module_data($id, $thrash2, $other, $trash1) {
$idAgentModule = $id;
$data = $other['data'][0];
$time = $other['data'][1];
if ($time == 'now') $time = time();
$agentModule = db_get_row_filter('tagente_modulo', array('id_agente_modulo' => $idAgentModule));
@ -5493,6 +5501,11 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
$sql_post .= " AND tags LIKE '%" . io_safe_input($tag) . "%'";
}
//Inject the raw sql
if (isset($filter['sql'])) {
$sql_post .= " AND (" . $filter['sql'] . ") ";
}
if ($group_rep == 0) {
switch ($config["dbtype"]) {
case "mysql":
@ -5636,6 +5649,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
}
}
$data['type'] = 'array';
$data['data'] = $result;
@ -5671,6 +5685,8 @@ function api_get_events($trash1, $trash2, $other, $returnType, $user_in_db = nul
return;
}
if ($other['type'] == 'string') {
if ($other['data'] != '') {
returnError('error_parameter', 'Error in the parameters.');
@ -5686,6 +5702,8 @@ function api_get_events($trash1, $trash2, $other, $returnType, $user_in_db = nul
$filterString = otherParameter2Filter($other);
}
$dataRows = db_get_all_rows_filter('tevento', $filterString);
$last_error = error_get_last();
if (empty($dataRows)) {
@ -6496,7 +6514,7 @@ function api_get_pandora_servers($trash1, $trash2, $other, $returnType) {
}
/**
* Enable/disable agent given an id
* Enable/Disable agent given an id
*
* @param string $id String Agent ID
* @param $thrash2 not used.