diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 72b418104e..adeb56436d 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,5 +1,13 @@ -2012-04-25 Juan Manuel Ramon +2012-04-25 Miguel de Dios + + * include/functions_api.php, include/api.php: fixed when some error + in get_events__user, and added constants flags for debug in the + header of source file. + + MERGED FROM 4.0.2 +2012-04-25 Juan Manuel Ramon + * operation/menu.php operation/events/events.php: SoundEvent popup now it's resizable in IE. @@ -7,7 +15,7 @@ Merged from branches. 2012-04-25 Vanessa Gil - + * godmode/setup/performance.php: Changed the order of options. 2012-04-25 Dario Rodriguez diff --git a/pandora_console/include/api.php b/pandora_console/include/api.php index 04112e824e..37de860511 100644 --- a/pandora_console/include/api.php +++ b/pandora_console/include/api.php @@ -18,6 +18,10 @@ require_once("functions_api.php"); global $config; +define("DEBUG", 0); +define("VERBOSE", 0); + + enterprise_include_once ('include/functions_enterprise_api.php'); $ipOrigin = $_SERVER['REMOTE_ADDR']; @@ -69,6 +73,14 @@ if ($correctLogin) { if (!function_exists($op.'_'.$op2)) returnError('no_exist_operation', $returnType); else { + if (!DEBUG) { + error_reporting(0); + } + if (VERBOSE) { + error_reporting(E_ALL); + ini_set("display_errors", 1); + } + call_user_func($op.'_'.$op2, $id, $id2, $other, $returnType, $user_in_db); } } diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 2d725985ba..33a635fe8c 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -34,7 +34,7 @@ enterprise_include_once ('include/functions_local_components.php'); * @return mixed */ function parseOtherParameter($other, $otherType) { - + switch ($otherType) { case 'url_encode': $returnVar = array('type' => 'string', 'data' => urldecode($other)); @@ -61,7 +61,7 @@ function parseOtherParameter($other, $otherType) { * @param $returnType * @return unknown_type */ -function returnError($typeError, $returnType) { +function returnError($typeError, $returnType = 'string') { switch ($typeError) { case 'no_set_no_get_no_help': returnData($returnType, @@ -76,8 +76,8 @@ function returnError($typeError, $returnType) { array('type' => 'string', 'data' => __('Id does not exist in BD.'))); break; default: - returnData('string', - array('type' => 'string', 'data' => __($returnType))); + returnData($returnType, + array('type' => 'string', 'data' => __($typeError))); break; } } @@ -133,6 +133,9 @@ function returnData($returnType, $data, $separator = ';') { } } break; + case 'string': + echo $data['data']; + break; } break; } @@ -240,7 +243,7 @@ function get_agent_module_name_last_value($agentName, $moduleName, $other = ';', } } else { - get_module_last_value($idModuleAgent, null, $other, $returnType); + get_module_last_value($idModuleAgent, null, $other, $returnType); } } @@ -531,13 +534,13 @@ function get_tree_agents($trash1, $trahs2, $other, $returnType) else $data['list_index'] = array( 'type_row', - + 'group_id', 'group_name', 'group_parent', 'disabled', 'custom_id', - + 'agent_id', 'agent_name', 'agent_direction', @@ -603,7 +606,7 @@ function get_tree_agents($trash1, $trahs2, $other, $returnType) 'module_last_execution_try', 'module_status_changes', 'module_last_status', - + 'alert_id_agent_module', 'alert_id_alert_template', 'alert_internal_counter', @@ -680,7 +683,7 @@ function get_tree_agents($trash1, $trahs2, $other, $returnType) */ function set_new_agent($thrash1, $thrash2, $other, $thrash3) { global $config; - + $name = $other['data'][0]; $ip = $other['data'][1]; $idParent = $other['data'][2]; @@ -4465,6 +4468,8 @@ function get_events__with_user($trash1, $trash2, $other, $returnType, $user_in_d $groups = users_get_groups ($user_in_db, "IR"); $is_admin = (bool)db_get_value('is_admin', 'tusuario', 'id_user', $user_in_db); + $sql_post = ''; + if (!empty($groups)) { $sql_post = " AND id_grupo IN (".implode (",", array_keys ($groups)).")"; } @@ -4702,6 +4707,11 @@ function get_events__with_user($trash1, $trash2, $other, $returnType, $user_in_d function get_events($trash1, $trash2, $other, $returnType, $user_in_db = null) { if ($user_in_db !== null) { get_events__with_user($trash1, $trash2, $other, $returnType, $user_in_db); + $last_error = error_get_last(); + if (!empty($last_error)) { + returnError('ERROR_API_PANDORAFMS', $returnType); + } + return; } @@ -4716,11 +4726,17 @@ function get_events($trash1, $trash2, $other, $returnType, $user_in_db = null) { } else if ($other['type'] == 'array') { $separator = $other['data'][0]; - + $filterString = otherParameter2Filter($other); } $dataRows = db_get_all_rows_filter('tevento', $filterString); + $last_error = error_get_last(); + if (!empty($last_error)) { + returnError('ERROR_API_PANDORAFMS', $returnType); + + return; + } $data['type'] = 'array'; $data['data'] = $dataRows; diff --git a/pandora_console/include/functions_users.php b/pandora_console/include/functions_users.php index d6b79188cf..222b720c92 100644 --- a/pandora_console/include/functions_users.php +++ b/pandora_console/include/functions_users.php @@ -87,7 +87,11 @@ function users_get_all_model_groups () { function users_get_groups ($id_user = false, $privilege = "AR", $returnAllGroup = true, $returnAllColumns = false, $id_groups = null) { if (empty ($id_user)) { global $config; - $id_user = $config['id_user']; + + $id_user = null; + if (isset($config['id_user'])) { + $id_user = $config['id_user']; + } } if (isset($id_groups)) {