Erase integria incidents integration with integria tickets - #29

This commit is contained in:
enriquecd 2017-01-25 12:40:42 +01:00
parent 1970167df4
commit d066c5f88f
14 changed files with 4 additions and 1002 deletions

View File

@ -196,7 +196,6 @@ if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM") || check_ac
}
// Calculate opened incidents (id integria incidents are not enabled)
if ($config['integria_enabled'] == 0) {
$shortcut_incidents = sc_get_opened_incidents();
$shortcut_html .= "<a class='shortcut_item' href='index.php?sec=incidencias&sec2=operation/incidents/incident&estado=0'>";
@ -206,7 +205,6 @@ if ($config['integria_enabled'] == 0) {
$shortcut_html .= "</a>";
$num_shortcut_items++;
}
if ($num_shortcut_items > 0) {
$shortcut_html .= "<span class='shortcut_item' href='javascript:;'>";

View File

@ -388,7 +388,7 @@ if ($id_agente) {
$total_incidents = agents_get_count_incidents($id_agente);
/* Incident tab */
if ($config['integria_enabled'] == 0 and $total_incidents > 0) {
if ($total_incidents > 0) {
$incidenttab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=incident&amp;id_agente='.$id_agente.'">'
. html_print_image ("images/book_edit.png", true, array ("title" =>__('Incidents')))
. '</a>';

View File

@ -103,82 +103,6 @@ $table->data[17][0] = __('Enable GIS features in Pandora Console');
$table->data[17][1] = __('Yes').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button ('activate_gis', 1, '', $config["activate_gis"], true).'&nbsp;&nbsp;';
$table->data[17][1] .= __('No').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button ('activate_gis', 0, '', $config["activate_gis"], true);
$table->data[18][0] = __('Enable Integria incidents in Pandora Console');
$table->data[18][1] = __('Yes').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button ('integria_enabled', 1, '', $config["integria_enabled"], true).'&nbsp;&nbsp;';
$table->data[18][1] .= __('No').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button ('integria_enabled', 0, '', $config["integria_enabled"], true);
if ($config["integria_enabled"]) {
require_once('include/functions_incidents.php');
$invent = incidents_call_api(
$config['integria_url'] . "/include/api.php?" .
"user=" . $config['id_user'] . "&" .
"pass=" . io_output_password($config['integria_api_password']) ."&" .
"op=get_inventories");
$bad_input = false;
// Wrong connection to api, bad password
if (empty($invent)) {
$bad_input = true;
}
$inventories = array();
// Right connection but theres is no inventories
if ($invent == 'false') {
unset($invent);
$invent = array();
}
// Checks if URL is right
else {
$invent = explode("\n",$invent);
}
// Wrong URL
if ((strripos($config['integria_url'], '.php') !== false)) {
$bad_input = true;
}
// Check page result and detect errors
else {
foreach ($invent as $inv) {
if ((stristr($inv, 'ERROR 404') !== false)
OR (stristr($inv, 'Status 404') !== false)
OR (stristr($inv, 'Internal Server Error') !== false)) {
$inventories[""] = __('None');
$bad_input = true;
break;
}
}
}
$table->data[20][0] = __('Integria URL') . ui_print_help_icon ("integria_url", true);
$table->data[20][1] = html_print_input_text('integria_url',
$config["integria_url"], '', 25, 255, true);
// If something goes wrong
if ($bad_input) {
$table->data[20][1] .= html_print_image('images/error.png',
true, array('title' => __('URL and/or Integria password are incorrect')));
}
$table->data[21][0] = __('Integria API password');
$table->data[21][1] = html_print_input_text('integria_api_password',
io_output_password($config["integria_api_password"]), '', 25, 25, true);
if (!$bad_input) {
foreach ($invent as $inv) {
if ($inv == '') {
continue;
}
$invexp = explode(',',$inv);
if (count($invexp) > 2) {
if (substr($invexp[1], 0, 1) == '"'
&& substr($invexp[1], strlen($invexp[1])-1, 1) == '"') {
$invexp[1] = substr($invexp[1], 1, strlen($invexp[1])-2);
}
$inventories[$invexp[0]] = $invexp[1];
}
}
}
$table->data[22][0] = __('Integria inventory');
$table->data[22][1] = html_print_select($inventories, 'integria_inventory', $config["integria_inventory"], '', '', '', true);
}
$table->data[19][0] = __('Enable Netflow');
$rbt_disabled = false;
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {

View File

@ -1370,22 +1370,6 @@ function config_process_config () {
config_update_value ('saml_path', '/opt/');
}
if (!isset ($config['integria_enabled'])) {
config_update_value ( 'integria_enabled', '0');
}
if (!isset ($config['integria_api_password'])) {
config_update_value ( 'integria_api_password', '');
}
if (!isset ($config['integria_inventory'])) {
config_update_value ( 'integria_inventory', '0');
}
if (!isset ($config['integria_url'])) {
config_update_value ( 'integria_url', '');
}
if (!isset ($config['autoupdate'])) {
config_update_value ( 'autoupdate', 1);
}

View File

@ -1068,7 +1068,7 @@ if ($config['activate_gis']) {
/* Incident tab */
$total_incidents = agents_get_count_incidents($id_agente);
if ($config['integria_enabled'] == 0 and $total_incidents > 0) {
if ($total_incidents > 0) {
$incidenttab['text'] = '<a href="index.php?sec=gagente&amp;sec2=operation/agentes/ver_agente&tab=incident&id_agente='.$id_agente.'">'
. html_print_image ("images/book_edit.png", true, array ("title" =>__('Incidents')))
. '</a>';

View File

@ -1,36 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
require_once ("../../include/functions_incidents.php");
require_once ("../../include/config.php");
$id_file = $_GET["id_file"];
$filename = $_GET["filename"];
$id_user = $_GET["id_user"];
$integria_api = $config['integria_url']."/include/api.php?return_type=csv&user=".$config['id_user']."&pass=".io_output_password($config['integria_api_password']);
$url = $integria_api."&op=download_file&params=".$id_file;
// Call the integria API
$file = incidents_call_api($url);
header("Content-type: binary");
header("Content-Disposition: attachment; filename=\"".$filename."\"");
header("Pragma: no-cache");
header("Expires: 0");
echo base64_decode($file);
?>

View File

@ -1,72 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $result;
$table->width = "98%";
$table->class = "databox";
$table->data = array();
$profiles = array();
$table->data[0][0] = "<b>".__('File')."</b><br/>".html_print_input_file ('new_file', true, array('size' => "50%"));
$table->data[1][0] = "<b>".__('Description')."</b><br/>".html_print_textarea('description', 3, 6, '' , '', true);
$form = "<form method='post' action='' enctype='multipart/form-data'>";
$form .= html_print_table($table, true);
$form .= html_print_submit_button(__('Add'), 'submit_button', false, 'class="sub next"', true);
$form .= html_print_input_hidden('tab', 'files', true);
$form .= html_print_input_hidden('attach_file', '1', true);
$form .= html_print_input_hidden('id_incident', $id_incident, true);
$form .= "</form>";
ui_toggle($form, __('Add a file'));
unset($table);
$table->width = "98%";
$table->class = "databox";
$table->head[0] = __('Filename');
$table->head[1] = __('Timestamp');
$table->head[2] = __('Description');
$table->head[3] = __('Size');
$table->head[4] = __('Delete');
$table->data = array();
if (isset($result['file'][0]) && is_array($result['file'][0])) {
$files = $result['file'];
}
else {
$files = $result;
}
$row = 0;
foreach($files as $value) {
$table->data[$row][0] = '<a href="operation/integria_incidents/incident.download_file.php?tab=files&id_incident='.$value['id_incidencia'].'&id_file='.$value['id_attachment'].'&filename='.$value['filename'].'&id_user='.$config['id_user'].'&rintegria_server='.$config['rintegria_server'].'">'.$value['filename'].'</a>';
$table->data[$row][1] = $value['id_usuario'];
if(is_array($value['description'])) {
$value['description'] = '';
}
$table->data[$row][2] = $value['description'];
$table->data[$row][3] = $value['size'];
$table->data[$row][4] = "<a href='index.php?sec=workspace&sec2=operation/integria_incidents/incident&tab=files&id_incident=".$value['id_incidencia']."&delete_file=".$value['id_attachment']."'>".html_print_image("images/cross.png", true, array('title' => __('Delete file')))."</a>";
$row++;
}
html_print_table($table);
?>

View File

@ -1,131 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $result;
global $result_resolutions;
global $result_status;
global $result_groups;
global $result_users;
require_once ("include/functions_events.php"); //To get events group information
$resolutions[0] = __('None');
if (isset ($result_resolutions['resolution'])) {
foreach($result_resolutions['resolution'] as $res) {
$resolutions[$res['id']] = $res['name'];
}
}
if (isset ($result_status['status'])) {
foreach($result_status['status'] as $st) {
$status[$st['id']] = $st['name'];
}
}
if (isset ($result_groups['group'])) {
foreach($result_groups['group'] as $gr) {
$groups[$gr['id']] = $gr['name'];
}
}
if (isset ($result_users['id_user'])) {
foreach($result_users['id_user'] as $usr) {
$users[$usr] = $usr;
}
}
else {
$users[$config['id_user']] = $config['id_user'];
}
if(!isset($result['id_incidencia'])) {
$result['titulo'] = '';
$result['sla_disabled'] = 0;
$result['notify_email'] = 0;
$result['estado'] = 0;
$result['prioridad'] = 0;
$result['resolution'] = 0;
$result['id_parent'] = 0;
$result['id_incident_type'] = 0;
$result['id_task'] = 0;
$result['id_creator'] = $config['id_user'];
$result['id_grupo'] = 0;
$result['id_usuario'] = 0;
$result['id_task'] = 0;
$result['descripcion'] = '';
$result['epilog'] = '';
if (isset ($_GET["from_event"])) {
$event = get_parameter ("from_event");
$result['descripcion'] = io_safe_output(events_get_description ($event));
$result['titulo'] = ui_print_truncate_text($result['descripcion'], 'description', false, true, false);
unset ($event);
}
}
$table->width = "98%";
$table->class = "databox";
$table->data = array();
$table->colspan[0][0] = 2;
$table->colspan[3][0] = 3;
$table->colspan[4][0] = 3;
$table->data[0][0] = "<b>".__('Title')."</b><br/>".html_print_input_text("title", $result['titulo'], '', 80, 255, true);
$table->data[0][1] = "<b>".__('Creator')."</b><br/>".$result['id_creator'];
if (isset($groups)) {
$table->data[1][0] = "<b>".__('Group')."</b><br/>".html_print_select ($groups, 'group', $result['id_grupo'], '', '', 0, true, false, false);
}
$table->data[1][1] = "<b>".__('Priority')."</b><br/>".html_print_select (incidents_get_priorities (), 'priority', $result['prioridad'], '', '', 0, true, false, false);
if (isset($result['id_incidencia'])) {
$table->data[1][2] = "<b>".__('Assigned user')."</b><br/>".html_print_select ($users, 'id_user_assigned', $result['id_usuario'], '', '', 0, true, false, false);
}
if (isset($result['id_incidencia'])) {
$table->data[2][0] = "<b>".__('Resolution')."</b><br/>".html_print_select ($resolutions, 'resolution', $result['resolution'], '', '', 0, true, false, false);
$table->data[2][1] = "<b>".__('Status')."</b><br/>".html_print_select ($status, 'status', $result['estado'], '', '', 0, true, false, false);
}
if (is_array($result['descripcion'])) {
$result['descripcion'] = "";
}
$table->data[3][0] = "<b>".__('Description')."</b><br/>".html_print_textarea("description", 10, 6, $result['descripcion'] , '', true);
if (isset($result['id_incidencia'])) {
if(is_array($result['epilog'])) {
$result['epilog'] = implode(',', $result['epilog']);
}
$table->data[4][0] = "<b>".__('Resolution epilog')."</b><br/>".html_print_textarea("epilog", 10, 6, $result['epilog'] , '', true);
}
if (isset($result['id_incidencia'])) {
echo "<form method='post' action=''>";
html_print_table($table);
html_print_submit_button(__('Update'), 'submit_button', false, "class='sub upd'");
html_print_input_hidden('tab', 'incident');
html_print_input_hidden('update_incident', '1');
html_print_input_hidden('id_incident', $result['id_incidencia']);
echo "</form>";
}
else {
echo "<form method='post' action='index.php?login=1&sec=workspace&sec2=operation/integria_incidents/incident&tab=incident'>";
html_print_table($table);
html_print_submit_button(__('Create'), 'submit_button', false, "class='sub next'");
html_print_input_hidden('tab', 'list');
html_print_input_hidden('create_incident', '1');
echo "</form>";
}
?>

View File

@ -1,141 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $search_status;
global $search_group;
global $search_string;
global $result;
global $result_status;
global $result_groups;
global $result_resolutions;
if (isset ($result_status['status'])) {
foreach($result_status['status'] as $st) {
$status[$st['id']] = $st['name'];
}
}
// Add special status cases
$status[0] = __('Any');
$status[-10] = __('Not closed');
if (isset ($result_groups['group'])) {
foreach($result_groups['group'] as $gr) {
$groups[$gr['id']] = $gr['name'];
}
}
$resolutions[0] = __('None');
if (isset ($result_resolutions['resolution'])) {
foreach ($result_resolutions['resolution'] as $res) {
$resolutions[$res['id']] = $res['name'];
}
}
echo '<form method="post">';
echo '<br><table width="98%" border=0>';
echo '<tr>';
echo '<td>';
echo "<b>".__('Search string')."</b>";
echo '</td>';
echo '<td>';
echo "<b>".__('Status')."</b>";
echo '</td>';
echo '<td>';
echo "<b>".__('Group')."</b>";
echo '</td>';
echo '</tr><tr>';
echo '<td>';
html_print_input_text('search_string', $search_string, '');
echo '</td>';
echo '<td>';
html_print_select ($status, 'search_status', $search_status, '', '', 0, false);
echo '</td>';
echo '<td>';
if (isset($groups)) {
html_print_select ($groups, 'search_group', $search_group, '', '', 0, false, false, false);
}
echo '</td>';
echo '<td>';
html_print_submit_button (__('Search'), '', false, "class='sub search'");
echo '</td>';
echo '</tr></table>';
echo '</form>';
// Show headers
$table->width = "98%";
$table->class = "databox";
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->head = array ();
$table->data = array ();
$table->size = array ();
$table->align = array ();
$table->head[0] = __('ID');
$table->head[1] = __('Incident');
$table->head[2] = __('Group');
$table->head[3] = __('Status')."<br/><i>".__('Resolution')."</i>";
$table->head[4] = __('Priority');
$table->head[5] = __('Updated')."<br/><i>".__('Started')."</i>";
$table->head[6] = __('Details');
$table->head[7] = __('Creator');
$table->head[8] = __('Owner');
$table->head[9] = __('Action');
$table->align[3] = "center";
$table->align[4] = "center";
if(isset($result['incident'][0]) && is_array($result['incident'][0])) {
$incidents = $result['incident'];
}
else {
$incidents = array($result['incident']);
}
$rowPair = true;
$iterator = 0;
foreach ($incidents as $row) {
if ($rowPair)
$table->rowclass[$iterator] = 'rowPair';
else
$table->rowclass[$iterator] = 'rowOdd';
$rowPair = !$rowPair;
$iterator++;
$data = array();
$data[0] = '<a href="index.php?login=1&sec=workspace&sec2=operation/integria_incidents/incident&tab=incident&id_incident='.$row["id_incidencia"].'">'.$row["id_incidencia"].'</a>';
$data[1] = '<a href="index.php?login=1&sec=workspace&sec2=operation/integria_incidents/incident&tab=incident&id_incident='.$row["id_incidencia"].'">'.substr(io_safe_output($row["titulo"]),0,45).'</a>';
$data[2] = $groups[$row["id_grupo"]];
$data[3] = $status[$row["estado"]]."<br/><i>".$resolutions[$row["resolution"]]."</i>";
$data[4] = incidents_print_priority_img ($row["prioridad"], true);
$data[5] = ui_print_timestamp ($row["actualizacion"], true)."<br/><i>" . ui_print_timestamp ($row["inicio"], true)."</i>";
$data[6] = $row["workunits_hours"]." ".__('Hours')."<br/>".$row["workunits_count"]." ".__('Workunits');
$data[7] = !empty($row["id_creator"]) ? $row["id_creator"] : __('None');
$data[8] = !empty($row["id_usuario"]) ? $row["id_usuario"] : __('None');
$data[9] = "<a href='index.php?sec=workspace&sec2=operation/integria_incidents/incident&delete_incident=".$row['id_incidencia']."'>".html_print_image("images/cross.png", true, array('title' => __('Delete incident')))."</a><a href='index.php?login=1&sec=workspace&sec2=operation/integria_incidents/incident&tab=incident&id_incident=".$row["id_incidencia"]."'>".html_print_image("images/config.png", true, array('title' => __('View incident details')))."</a>";
array_push ($table->data, $data);
}
html_print_table ($table);
?>

View File

@ -1,343 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config;
require_once ("include/functions_incidents.php");
check_login ();
if (! check_acl ($config['id_user'], 0, "IR")) {
db_pandora_audit("ACL Violation","Trying to access incident viewer");
require ("general/noaccess.php");
exit;
}
$tab = get_parameter('tab', 'list');
$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=".io_output_password($config['integria_api_password']);
// Header
if ($tab == 'list' || $tab == 'editor') {
$buttons = array(
'list' => array(
'active' => false,
'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=list">' .
html_print_image ("images/list.png", true, array ("title" => __('Incidents'))) .'</a>'),
'editor' => array(
'active' => false,
'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=editor">' .
html_print_image ("images/pen.png", true, array ("title" => __('New Incident'))) .'</a>'));
}
else {
$buttons = array(
'list' => array(
'active' => false,
'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=list">' .
html_print_image ("images/list.png", true, array ("title" => __('Incidents'))) .'</a>'),
'incident' => array(
'active' => false,
'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=incident&id_incident='.$id_incident.'">' .
html_print_image ("images/zoom_mc.png", true, array ("title" => __('Incident details'))) .'</a>'),
'workunits' => array(
'active' => false,
'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=workunits&id_incident='.$id_incident.'">' .
html_print_image ("images/star_white.png", true, array ("title" => __('Workunits'))) .'</a>'),
'files' => array(
'active' => false,
'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=files&id_incident='.$id_incident.'"">' .
html_print_image ("images/save_mc.png", true, array ("title" => __('Files'))) .'</a>'),
'tracking' => array(
'active' => false,
'text' => '<a href="index.php?login=1&sec=incidencias&sec2=operation/integria_incidents/incident&tab=tracking&id_incident='.$id_incident.'"">' .
html_print_image ("images/gm_log.png", true, array ("title" => __('Tracking'))) .'</a>'));
}
$buttons[$tab]['active'] = true;
ui_print_page_header (__('Incident management'), "images/book_edit.png", false, "", false, $buttons);
if ($update_incident == 1) {
$values[0] = $id_incident;
$values[1] = urlencode(io_safe_output(get_parameter('title')));
$values[2] = urlencode(io_safe_output(get_parameter('description')));
$values[3] = urlencode(io_safe_output(get_parameter('epilog')));
$values[4] = get_parameter('group');
$values[5] = get_parameter('priority');
$values[6] = get_parameter('resolution');
$values[7] = get_parameter('status');
$values[8] = get_parameter('id_user_assigned');
$params = implode($token, $values);
$url = $integria_api."&op=update_incident&token=".$token."&params=".$params;
// Call the integria API
$result = incidents_call_api($url);
$result_array = incidents_xml_to_array($result);
if ($result_array['data']) {
ui_print_success_message (__("Incident updated"));
}
else {
ui_print_error_message (__("There was a problem updating the incident, please check if any field was modified and the values are correct."));
}
}
$create_incident = get_parameter('create_incident', 0);
if ($create_incident == 1) {
$values[0] = urlencode(io_safe_output(get_parameter('title')));
$values[1] = get_parameter('group');
$values[2] = get_parameter('priority');
$values[3] = urlencode(io_safe_output(get_parameter('description')));
$values[4] = $config['integria_inventory'];
$params = implode($token, $values);
$url = $integria_api."&op=create_incident&token=".$token."&params=".$params;
// Call the integria API
$result = incidents_call_api($url);
$result_array = incidents_xml_to_array($result);
if ($result_array['data']) {
ui_print_success_message (__("Incident created"));
}
else {
ui_print_error_message (__("There was a problem creating incident"));
}
}
$attach_file = get_parameter('attach_file', 0);
if ($attach_file == 1) {
if ($_FILES['new_file']['name'] != "" && $_FILES['new_file']['error'] == 0) {
$file_content = file_get_contents($_FILES["new_file"]["tmp_name"]);
$values[0] = $id_incident;
$values[1] = $_FILES['new_file']['name'];
$values[2] = $_FILES['new_file']['size'];
$values[3] = io_safe_output(get_parameter('description'), __('No description available'));
$values[4] = base64_encode($file_content);
$params = implode($token, $values);
$url = $integria_api."&op=attach_file&token=".$token;
// Call the integria API
$result = incidents_call_api($url, array('params' => $params));
$result_array = incidents_xml_to_array($result);
if ($result_array['data'] == 0) {
ui_print_success_message (__("File uploaded"));
}
else {
ui_print_error_message (__("There was a problem uploading file"));
}
}
else {
switch ($_FILES['new_file']['error']) {
case 1:
ui_print_error_message (__('File is too big'));
break;
case 3:
ui_print_error_message (__('File was partially uploaded. Please try again'));
break;
case 4:
ui_print_error_message (__('No file was uploaded'));
break;
default:
ui_print_error_message (__('Generic upload error').'(Code: '.$_FILES['new_file']['error'].')');
break;
}
}
}
$delete_file = get_parameter('delete_file', 0);
if ($delete_file != 0 && !$attach_file) {
$url = $integria_api."&op=delete_file&params=".$delete_file;
// Call the integria API
$result = incidents_call_api($url);
$result = incidents_call_api($url);
$result_array = incidents_xml_to_array($result);
if ($result_array['data'] == 0 || $result_array['data'] == -2) {
ui_print_success_message (__("File deleted"));
}
else if ($result_array['data'] == -1) {
ui_print_error_message (__("You user doesn't have enough rights to delete this file"));
}
}
$delete_incident = get_parameter('delete_incident', 0);
if ($delete_incident != 0) {
$url = $integria_api."&op=delete_incident&params=".$delete_incident;
// Call the integria API
$result = incidents_call_api($url);
$result_array = incidents_xml_to_array($result);
if ($result_array['data']) {
ui_print_success_message (__("Incident deleted"));
}
else {
ui_print_error_message (__("There was a problem deteling incident"));
}
}
$create_workunit = get_parameter('create_workunit', 0);
if ($create_workunit == 1) {
$values[0] = $id_incident;
$values[1] = str_replace(" ", "%20", io_safe_output(get_parameter('description')));
$values[2] = get_parameter('time_used');
$values[3] = get_parameter('have_cost');
$values[4] = get_parameter('public');
$values[5] = get_parameter('profile');
$params = implode($token, $values);
$url = $integria_api."&op=create_workunit&token=".$token."&params=".$params;
// Call the integria API
$result = incidents_call_api($url);
$result_array = incidents_xml_to_array($result);
if ($result_array['data']) {
ui_print_success_message (__("Workunit added"));
}
else {
ui_print_error_message (__("There was a problem adding workunit"));
}
}
$params = array();
// Set the url with parameters to call the api
switch ($tab) {
case 'list':
$search_string = get_parameter('search_string', "");
$params[0] = $search_string;
$search_status = get_parameter('search_status', -10);
$params[1] = $search_status;
$search_group = get_parameter('search_group', 1);
$params[2] = $search_group;
$params = implode($token,$params);
$url = $integria_api."&op=get_incidents&token=".$token."&params=".$params;
$url_resolutions = $integria_api."&op=get_incidents_resolutions";
$url_status = $integria_api."&op=get_incidents_status";
$url_groups = $integria_api."&op=get_groups&params=1";
break;
case 'incident':
case 'editor':
//Request incident information if any
if ($id_incident) {
$url = $integria_api."&op=get_incident_details&params=".$id_incident;
}
else {
$url = $integria_api."&op=get_incident_details";
}
$url_resolutions = $integria_api."&op=get_incidents_resolutions";
$url_status = $integria_api."&op=get_incidents_status";
$url_groups = $integria_api."&op=get_groups&params=0";
$url_users = $integria_api."&op=get_users";
break;
case 'workunits':
$url = $integria_api."&op=get_incident_workunits&params=".$id_incident;
break;
case 'files':
$url = $integria_api."&op=get_incident_files&params=".$id_incident;
break;
case 'tracking':
$url = $integria_api."&op=get_incident_tracking&params=".$id_incident;
break;
}
if (isset($url)) {
// Call the integria API
$xml = incidents_call_api($url);
}
else {
$xml = "<xml></xml>";
}
// If is a valid XML, parse it
if (xml_parse(xml_parser_create(), $xml)) {
// Check if xml is empty
if($xml == "<xml>\n</xml>\n") {
$result = false;
}
else {
$result = incidents_xml_to_array($xml);
}
if($result == false) {
$result = array();
}
switch($tab) {
case 'list':
$result_resolutions = incidents_xml_to_array(incidents_call_api($url_resolutions));
$result_status = incidents_xml_to_array(incidents_call_api($url_status));
$result_groups = incidents_xml_to_array(incidents_call_api($url_groups));
require_once('incident.list.php');
break;
case 'editor':
case 'incident':
$result_resolutions = incidents_xml_to_array(incidents_call_api($url_resolutions));
$result_status = incidents_xml_to_array(incidents_call_api($url_status));
$result_groups = incidents_xml_to_array(incidents_call_api($url_groups));
$result_users = incidents_xml_to_array(incidents_call_api($url_users));
require_once('incident.incident.php');
break;
case 'workunits':
require_once('incident.workunits.php');
break;
case 'files':
require_once('incident.files.php');
break;
case 'tracking':
require_once('incident.tracking.php');
break;
}
}
else {
ui_print_error_message(__("There is a error in the message from your Integria or there is not connection."));
}
echo '<div style="clear:both">&nbsp;</div>';
?>

View File

@ -1,45 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $result;
$table->width = "98%";
$table->class = "databox";
$table->head[0] = __('Description');
$table->head[1] = __('User');
$table->head[2] = __('Date');
$table->data = array();
if (isset($result['tracking'][0]) && is_array($result['tracking'][0])) {
$tracking = $result['tracking'];
}
else {
$tracking = $result;
}
$row = 0;
foreach ($tracking as $value) {
$table->data[$row][0] = $value['description'];
$table->data[$row][1] = $value['id_user'];
$table->data[$row][2] = $value['timestamp'];
$row++;
}
html_print_table($table);
?>

View File

@ -1,67 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $result;
global $id_incident;
$table->width = "98%";
$table->class = "databox";
$table->data = array();
$table->colspan[1][0] = 3;
$profiles = array();
$default_time = "0";
$table->data[0][0] = "<b>".__('Time used')."</b><br/>".html_print_input_text ('time_used', $default_time, '', 10, 255, true);
$table->data[0][1] = "<b>".__('Have cost')."</b><br/>".html_print_checkbox ('have_cost', '', false, true);
$table->data[0][2] = "<b>".__('Public')."</b><br/>".html_print_checkbox ('public', '', true, true);
$table->data[1][0] = "<b>".__('Description')."</b><br/>".html_print_textarea('description', 3, 6, '' , '', true);
$form = "<form method='post' action=''>";
$form .= html_print_table($table, true);
$form .= html_print_submit_button(__('Add'), 'submit_button', false, 'class="sub next"', true);
$form .= html_print_input_hidden('tab', 'workunits', true);
$form .= html_print_input_hidden('create_workunit', '1', true);
$form .= html_print_input_hidden('id_incident', $id_incident, true);
$form .= html_print_input_hidden('profile', '0', true);
$form .= "</form>";
ui_toggle($form, __('Add workunit'));
if (isset($result['workunit'][0]) && is_array($result['workunit'][0])) {
$workunits = $result['workunit'];
}
else {
$workunits = $result;
}
foreach ($workunits as $value) {
$table->width = "98%";
$table->class = "databox";
$table->colspan[1][0] = 4;
$table->size[0] = "80%";
$table->size[1] = "20%";
$table->data = array();
$table->data[0][0] = $value['id_user'] . " " . __('said') . " " . $value['timestamp'];
$table->data[0][1] = $value['duration'] . " " . __('Hours') . " " . __('Public') . ": " . $value['public'];
$table->data[1][0] = $value['description'];
html_print_table($table);
}
?>

View File

@ -1,62 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
global $config;
require_once ($config["homedir"] . '/include/functions_graph.php');
check_login ();
if (! check_acl ($config['id_user'], 0, "IR") == 1) {
db_pandora_audit("ACL Violation", "Trying to access Incident section");
require ("general/noaccess.php");
exit;
}
ui_print_page_header (__('Statistics'), "images/book_edit.png", false, "", false, "");
$integria_api = $config['integria_url']."/include/api.php?user=".$config['id_user']."&pass=".io_output_password($config['integria_api_password']);
$op = 'get_stats';
$url = "$integria_api&op=$op";
$curlObj = curl_init();
curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlObj, CURLOPT_URL, $url . "&params=opened");
$opened_tickets = curl_exec($curlObj);
curl_setopt($curlObj, CURLOPT_URL, $url . "&params=closed");
$closed_tickets = curl_exec($curlObj);
curl_close($curlObj);
$opened_tickets = trim($opened_tickets);
$closed_tickets = trim($closed_tickets);
if (!is_numeric($opened_tickets))
$opened_tickets = 0;
if (!is_numeric($closed_tickets))
$closed_tickets = 0;
$data = array();
$data[__('Opened tickets')] = $opened_tickets;
$data[__('Closed tickets')] = $closed_tickets;
echo '<table width="90%">
<tr><td valign="top"><h3>'.__('Incidents by status').'</h3>';
echo pie3d_graph($config['flash_charts'], $data, 370, 180,
__('Other'), '', $config['homedir'] . "/images/logo_vertical_water.png",
$config['fontpath'], $config['font_size']);
echo '</table>';
?>

View File

@ -349,15 +349,8 @@ if (check_acl ($config['id_user'], 0, "IR")
|| check_acl ($config['id_user'], 0, "IW")
|| check_acl ($config['id_user'], 0, "IM")) {
$temp_sec2 = $sec2;
if($config['integria_enabled']) {
$sec2 = "incident";
$sec2sub = "operation/integria_incidents/incident_statistics";
}
else {
$sec2 = "incident";
$sec2sub = "operation/incidents/incident_statistics";
}
$sec2 = "incident";
$sec2sub = "operation/incidents/incident_statistics";
$sub[$sec2]["text"] = __('Incidents');
$sub[$sec2]["id"] = 'Incidents';
$sub[$sec2]["type"] = "direct";