diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 768086bce6..c5aded1402 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2012-01-25 Sergio Martin + + * include/functions_incidents.php + operation/integria_incidents/incident.incident.php + operation/integria_incidents/incident.php: Fixed some bugs + of the Integria IMS integration + 2012-01-25 Junichi Satoh * godmode/menu.php, godmode/alerts/alert_special_days.php, diff --git a/pandora_console/include/functions_incidents.php b/pandora_console/include/functions_incidents.php index 5eac6f53e5..a91c1c5f58 100644 --- a/pandora_console/include/functions_incidents.php +++ b/pandora_console/include/functions_incidents.php @@ -442,7 +442,7 @@ function incidents_call_api($url, $postparameters = false) { * @return array A Json encoded array with xml content. */ function incidents_xml_to_array($xml) { - $xmlObj = simplexml_load_string($xml); + $xmlObj = simplexml_load_string($xml, null, LIBXML_NOCDATA); return json_decode(json_encode($xmlObj), true); } diff --git a/pandora_console/operation/integria_incidents/incident.incident.php b/pandora_console/operation/integria_incidents/incident.incident.php index a0d47ebd89..1febcd6b9b 100644 --- a/pandora_console/operation/integria_incidents/incident.incident.php +++ b/pandora_console/operation/integria_incidents/incident.incident.php @@ -48,6 +48,10 @@ if (isset ($result_users['id_user'])) { $users[$usr] = $usr; } } +else { + $users[$config['id_user']] = $config['id_user']; + +} if(!isset($result['id_incidencia'])) { $result['titulo'] = ''; $result['sla_disabled'] = 0; @@ -124,7 +128,7 @@ if(isset($result['id_incidencia'])) { echo ""; } else { - echo "
"; + echo ""; html_print_table($table); html_print_submit_button(__('Create'), 'submit_button'); html_print_input_hidden('tab', 'incident'); diff --git a/pandora_console/operation/integria_incidents/incident.php b/pandora_console/operation/integria_incidents/incident.php index ff32fa93b9..679db8c52a 100755 --- a/pandora_console/operation/integria_incidents/incident.php +++ b/pandora_console/operation/integria_incidents/incident.php @@ -30,6 +30,48 @@ $id_incident = get_parameter('id_incident', 0); // We choose a strange token to use texts with commas, etc. $token = ';,;'; +$update_incident = get_parameter('update_incident', 0); + +$integria_api = $config['integria_url']."/include/api.php?return_type=xml&user=".$config['id_user']."&pass=".$config['integria_api_password']; + +if($update_incident == 1) { + $values[0] = $id_incident; + $values[1] = str_replace(" ", "%20", io_safe_output(get_parameter('title'))); + $values[2] = str_replace(" ", "%20", io_safe_output(get_parameter('description'))); + $values[3] = str_replace(" ", "%20", io_safe_output(get_parameter('epilog'))); + $values[4] = get_parameter('group'); + $values[5] = get_parameter('priority'); + $values[6] = get_parameter('source'); + $values[7] = get_parameter('resolution'); + $values[8] = get_parameter('status'); + $values[9] = get_parameter('creator', get_parameter('creator_fix')); + + $params = implode($token, $values); + + $url = $integria_api."&op=update_incident&token=".$token."¶ms=".$params; + // Call the integria API + $result = incidents_call_api($url); +} + +$create_incident = get_parameter('create_incident', 0); + +if($create_incident == 1) { + $values[0] = str_replace(" ", "%20", io_safe_output(get_parameter('title'))); + $values[1] = get_parameter('group'); + $values[2] = get_parameter('priority'); + $values[3] = str_replace(" ", "%20", io_safe_output(get_parameter('description'))); + $values[4] = $config['integria_inventory']; + + $params = implode($token, $values); + + $url = $integria_api."&op=create_incident&token=".$token."¶ms=".$params; + + // Call the integria API + $result = incidents_xml_to_array(incidents_call_api($url)); + + $id_incident = $result['data']; +} + // Header if($tab == 'list' || $tab == 'editor') { $buttons = array( @@ -70,46 +112,6 @@ $buttons[$tab]['active'] = true; ui_print_page_header (__('Incident management'), "images/book_edit.png", false, "", false, $buttons); -$update_incident = get_parameter('update_incident', 0); - -$integria_api = $config['integria_url']."/include/api.php?return_type=xml&user=".$config['id_user']."&pass=".$config['integria_api_password']; - -if($update_incident == 1) { - $values[0] = $id_incident; - $values[1] = str_replace(" ", "%20", io_safe_output(get_parameter('title'))); - $values[2] = str_replace(" ", "%20", io_safe_output(get_parameter('description'))); - $values[3] = str_replace(" ", "%20", io_safe_output(get_parameter('epilog'))); - $values[4] = get_parameter('group'); - $values[5] = get_parameter('priority'); - $values[6] = get_parameter('source'); - $values[7] = get_parameter('resolution'); - $values[8] = get_parameter('status'); - $values[9] = get_parameter('creator', get_parameter('creator_fix')); - - $params = implode($token, $values); - - $url = $integria_api."&op=update_incident&token=".$token."¶ms=".$params; - // Call the integria API - $result = incidents_call_api($url); -} - -$create_incident = get_parameter('create_incident', 0); - -if($create_incident == 1) { - $values[0] = str_replace(" ", "%20", io_safe_output(get_parameter('title'))); - $values[1] = get_parameter('group'); - $values[2] = get_parameter('priority'); - $values[3] = str_replace(" ", "%20", io_safe_output(get_parameter('description'))); - $values[4] = $config['integria_inventory']; - - $params = implode($token, $values); - - $url = $integria_api."&op=create_incident&token=".$token."¶ms=".$params; - - // Call the integria API - $result = incidents_call_api($url); -} - $attach_file = get_parameter('attach_file', 0); if($attach_file == 1) {