From d5197dcb40d516db0c4e90746337b015e912f3a6 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Thu, 17 Mar 2011 18:12:03 +0000 Subject: [PATCH] 2011-03-17 Sergio Martin * operation/integria_incidents operation/integria_incidents/incident.incident.php operation/integria_incidents/incident.php operation/integria_incidents/incident.files.php operation/integria_incidents/incident.tracking.php operation/integria_incidents/incident_detail.php operation/integria_incidents/incident.workunits.php operation/integria_incidents/incident.download_file.php operation/integria_incidents/incident.list.php operation/integria_incidents/incident_statistics.php: Added missed files from the last commit git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4106 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 14 + .../incident.download_file.php | 36 ++ .../integria_incidents/incident.files.php | 72 +++ .../integria_incidents/incident.incident.php | 119 +++++ .../integria_incidents/incident.list.php | 133 ++++++ .../operation/integria_incidents/incident.php | 270 +++++++++++ .../integria_incidents/incident.tracking.php | 45 ++ .../integria_incidents/incident.workunits.php | 67 +++ .../integria_incidents/incident_detail.php | 428 ++++++++++++++++++ .../incident_statistics.php | 67 +++ 10 files changed, 1251 insertions(+) create mode 100644 pandora_console/operation/integria_incidents/incident.download_file.php create mode 100644 pandora_console/operation/integria_incidents/incident.files.php create mode 100644 pandora_console/operation/integria_incidents/incident.incident.php create mode 100644 pandora_console/operation/integria_incidents/incident.list.php create mode 100755 pandora_console/operation/integria_incidents/incident.php create mode 100644 pandora_console/operation/integria_incidents/incident.tracking.php create mode 100644 pandora_console/operation/integria_incidents/incident.workunits.php create mode 100755 pandora_console/operation/integria_incidents/incident_detail.php create mode 100755 pandora_console/operation/integria_incidents/incident_statistics.php diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 903d67be5c..311a8d5fcd 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,17 @@ +2011-03-17 Sergio Martin + + * operation/integria_incidents + operation/integria_incidents/incident.incident.php + operation/integria_incidents/incident.php + operation/integria_incidents/incident.files.php + operation/integria_incidents/incident.tracking.php + operation/integria_incidents/incident_detail.php + operation/integria_incidents/incident.workunits.php + operation/integria_incidents/incident.download_file.php + operation/integria_incidents/incident.list.php + operation/integria_incidents/incident_statistics.php: Added + missed files from the last commit + 2011-03-17 Sergio Martin * pandoradb_data.sql diff --git a/pandora_console/operation/integria_incidents/incident.download_file.php b/pandora_console/operation/integria_incidents/incident.download_file.php new file mode 100644 index 0000000000..e280ef400f --- /dev/null +++ b/pandora_console/operation/integria_incidents/incident.download_file.php @@ -0,0 +1,36 @@ + diff --git a/pandora_console/operation/integria_incidents/incident.files.php b/pandora_console/operation/integria_incidents/incident.files.php new file mode 100644 index 0000000000..08659bf498 --- /dev/null +++ b/pandora_console/operation/integria_incidents/incident.files.php @@ -0,0 +1,72 @@ +width = "98%"; +$table->class = "databox"; + +$table->data = array(); + +$profiles = array(); +$table->data[0][0] = "".__('File')."
".print_input_file ('new_file', true, array('size' => "50%")); + +$table->data[1][0] = "".__('Description')."
".print_textarea('description', 3, 6, '' , '', true); + +$form = "
"; +$form .= print_table($table, true); +$form .= print_submit_button(__('Add'), 'submit_button', false, '', true); +$form .= print_input_hidden('tab', 'files', true); +$form .= print_input_hidden('attach_file', '1', true); +$form .= print_input_hidden('id_incident', $id_incident, true); +$form .= "
"; + +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] = ''.$value['filename'].''; + $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] = "".print_image("images/cross.png", true, array('title' => __('Delete file'))).""; + $row++; +} + +print_table($table); + +?> diff --git a/pandora_console/operation/integria_incidents/incident.incident.php b/pandora_console/operation/integria_incidents/incident.incident.php new file mode 100644 index 0000000000..f7087fba44 --- /dev/null +++ b/pandora_console/operation/integria_incidents/incident.incident.php @@ -0,0 +1,119 @@ +width = "98%"; +$table->class = "databox"; + +$table->data = array(); +$table->colspan[0][0] = 3; +$table->colspan[3][0] = 3; +$table->colspan[4][0] = 3; + +$table->data[0][0] = "".__('Title')."
".print_input_text("title", $result['titulo'], '', 50, 255, true); +if(isset($result['id_incidencia'])) { + $table->data[1][2] = "".__('Assigned user')."
".print_select ($users, 'id_user', $result['id_usuario'], '', '', 0, true, false, false); +} +else { + $table->data[1][2] = ""; +} + +$table->data[1][0] = "".__('Group')."
".print_select ($groups, 'group', $result['id_grupo'], '', '', 0, true, false, false); +$table->data[1][1] = "".__('Priority')."
".print_select (get_incidents_priorities (), 'priority', $result['prioridad'], '', '', 0, true, false, false); +$table->data[1][2] = "".__('Creator')."
".$result['id_creator']; + +if(isset($result['id_incidencia'])) { + $table->data[2][0] = "".__('Source')."
".print_select ($sources, 'source', $result['origen'], '', '', 0, true, false, false); + $table->data[2][1] = "".__('Resolution')."
".print_select ($resolutions, 'resolution', $result['resolution'], '', '', 0, true, false, false); + $table->data[2][2] = "".__('Status')."
".print_select ($status, 'status', $result['estado'], '', '', 0, true, false, false); +} + +if(is_array($result['descripcion'])) { + $result['descripcion'] = ""; +} + +$table->data[3][0] = "".__('Description')."
".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] = "".__('Resolution epilog')."
".print_textarea("epilog", 10, 6, $result['epilog'] , '', true); +} + +if(isset($result['id_incidencia'])) { + echo "
"; + print_table($table); + print_submit_button(__('Update'), 'submit_button'); + print_input_hidden('tab', 'incident'); + print_input_hidden('update_incident', '1'); + print_input_hidden('id_incident', $result['id_incidencia']); + echo "
"; +} +else { + echo "
"; + print_table($table); + print_submit_button(__('Create'), 'submit_button'); + print_input_hidden('tab', 'incident'); + print_input_hidden('create_incident', '1'); + echo "
"; +} +?> diff --git a/pandora_console/operation/integria_incidents/incident.list.php b/pandora_console/operation/integria_incidents/incident.list.php new file mode 100644 index 0000000000..1890489738 --- /dev/null +++ b/pandora_console/operation/integria_incidents/incident.list.php @@ -0,0 +1,133 @@ +'; + +echo '
'; +echo ''; +echo ''; +echo ''; +echo ''; +echo ''; +echo ''; +echo ''; +echo ''; +echo ''; +echo '
'; +echo "".__('Search string').""; +echo ''; +echo "".__('Status').""; +echo ''; +echo "".__('Group').""; +echo '
'; +print_input_text('search_string', $search_string, ''); +echo ''; +print_select ($status, 'search_status', $search_status, '', '', 0, false); +echo ''; +print_select ($groups, 'search_group', $search_group, '', '', 0, false, false, false); +echo ''; +print_submit_button (__('Search')); +echo '
'; + +echo ''; + + +// 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] = __('SLA'); +$table->head[2] = __('Incident'); +$table->head[3] = __('Group'); +$table->head[4] = __('Status')."
".__('Resolution').""; +$table->head[5] = __('Priority'); +$table->head[6] = __('Updated')."
".__('Started').""; +$table->head[7] = __('Details'); +$table->head[8] = __('Creator'); +$table->head[9] = __('Owner'); +$table->head[10] = __('Action'); + +$table->align[4] = "center"; +$table->align[5] = "center"; + +if(isset($result['incident'][0]) && is_array($result['incident'][0])){ + $incidents = $result['incident']; +} +else { + $incidents = $result; +} + +$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] = ''.$row["id_incidencia"].''; + //$data[1] = ""; + $data[2] = ''.substr(safe_output($row["titulo"]),0,45).''; + $data[3] = $groups[$row["id_grupo"]]; + $data[4] = $status[$row["estado"]]."
".$resolutions[$row["resolution"]].""; + $data[5] = print_incidents_priority_img ($row["prioridad"], true); + $data[6] = print_timestamp ($row["actualizacion"], true)."
".print_timestamp ($row["inicio"], true).""; + $data[7] = $row["workunits_hours"]." ".__('Hours')."
".$row["workunits_count"]." ".__('Workunits'); + $data[8] = $row["id_creator"]; + $data[9] = $row["id_usuario"]; + $data[10] = "".print_image("images/cross.png", true, array('title' => __('Delete incident')))."".print_image("images/config.png", true, array('title' => __('View incident details'))).""; + + array_push ($table->data, $data); +} + +print_table ($table); +?> diff --git a/pandora_console/operation/integria_incidents/incident.php b/pandora_console/operation/integria_incidents/incident.php new file mode 100755 index 0000000000..c0209b613e --- /dev/null +++ b/pandora_console/operation/integria_incidents/incident.php @@ -0,0 +1,270 @@ + array( + 'active' => false, + 'text' => '' . + print_image ("images/page_white_text.png", true, array ("title" => __('Incidents'))) .''), + 'editor' => array( + 'active' => false, + 'text' => '' . + print_image ("images/add.png", true, array ("title" => __('New Incident'))) .'')); +} +else { + $buttons = array( + 'list' => array( + 'active' => false, + 'text' => '' . + print_image ("images/page_white_text.png", true, array ("title" => __('Incidents'))) .''), + 'incident' => array( + 'active' => false, + 'text' => '' . + print_image ("images/eye.png", true, array ("title" => __('Incident details'))) .''), + 'workunits' => array( + 'active' => false, + 'text' => '' . + print_image ("images/computer.png", true, array ("title" => __('Workunits'))) .''), + 'files' => array( + 'active' => false, + 'text' => '' . + print_image ("images/file.png", true, array ("title" => __('Files'))) .''), + 'tracking' => array( + 'active' => false, + 'text' => '' . + print_image ("images/comments.png", true, array ("title" => __('Tracking'))) .'')); +} + +$buttons[$tab]['active'] = true; + +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", safe_output(get_parameter('title'))); + $values[2] = str_replace(" ", "%20", safe_output(get_parameter('description'))); + $values[3] = str_replace(" ", "%20", 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 = call_api($url); +} + +$create_incident = get_parameter('create_incident', 0); + +if($create_incident == 1) { + $values[0] = str_replace(" ", "%20", safe_output(get_parameter('title'))); + $values[1] = get_parameter('group'); + $values[2] = get_parameter('priority'); + $values[3] = str_replace(" ", "%20", 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 = call_api($url); +} + +$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] = str_replace(" ", "%20", 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 = call_api($url, array('params' => $params)); + } + else { + switch ($_FILES['new_file']['error']) { + case 1: + echo '

'.__('File is too big').'

'; + break; + case 3: + echo '

'.__('File was partially uploaded. Please try again').'

'; + break; + case 4: + echo '

'.__('No file was uploaded').'

'; + break; + default: + echo '

'.__('Generic upload error').'(Code: '.$_FILES['new_file']['error'].')

'; + } + } +} + +$delete_file = get_parameter('delete_file', 0); + +if($delete_file != 0) { + $url = $integria_api."&op=delete_file¶ms=".$delete_file; + + // Call the integria API + $result = call_api($url); +} + +$delete_incident = get_parameter('delete_incident', 0); + +if($delete_incident != 0) { + $url = $integria_api."&op=delete_incident¶ms=".$delete_incident; + + // Call the integria API + $result = call_api($url); +} + +$create_workunit = get_parameter('create_workunit', 0); + +if($create_workunit == 1) { + $values[0] = $id_incident; + $values[1] = str_replace(" ", "%20", 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."¶ms=".$params; + + // Call the integria API + $result = call_api($url); +} + +// 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."¶ms=".$params; + $url_resolutions = $integria_api."&op=get_incidents_resolutions"; + $url_status = $integria_api."&op=get_incidents_status"; + $url_groups = $integria_api."&op=get_groups¶ms=1"; + break; + case 'incident': + $url = $integria_api."&op=get_incident_details¶ms=".$id_incident; + case 'editor': + $url_resolutions = $integria_api."&op=get_incidents_resolutions"; + $url_status = $integria_api."&op=get_incidents_status"; + $url_sources = $integria_api."&op=get_incidents_sources"; + $url_groups = $integria_api."&op=get_groups¶ms=0"; + $url_users = $integria_api."&op=get_users"; + break; + case 'workunits': + $url = $integria_api."&op=get_incident_workunits¶ms=".$id_incident; + break; + case 'files': + $url = $integria_api."&op=get_incident_files¶ms=".$id_incident; + break; + case 'tracking': + $url = $integria_api."&op=get_incident_tracking¶ms=".$id_incident; + break; +} + +if(isset($url)) { + // Call the integria API + $xml = call_api($url); +} +else { + $xml = ""; +} + +// If is a valid XML, parse it +if(xml_parse(xml_parser_create(), $xml)) { + $result = xml_to_array($xml); + if($result == false) { + $result = array(); + } + switch($tab) { + case 'list': + $result_resolutions = xml_to_array(call_api($url_resolutions)); + $result_status = xml_to_array(call_api($url_status)); + $result_groups = xml_to_array(call_api($url_groups)); + require_once('incident.list.php'); + break; + case 'editor': + case 'incident': + $result_resolutions = xml_to_array(call_api($url_resolutions)); + $result_status = xml_to_array(call_api($url_status)); + $result_sources = xml_to_array(call_api($url_sources)); + $result_groups = xml_to_array(call_api($url_groups)); + $result_users = xml_to_array(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; + } +} + + +echo '
 
'; +?> diff --git a/pandora_console/operation/integria_incidents/incident.tracking.php b/pandora_console/operation/integria_incidents/incident.tracking.php new file mode 100644 index 0000000000..8226d7d511 --- /dev/null +++ b/pandora_console/operation/integria_incidents/incident.tracking.php @@ -0,0 +1,45 @@ +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++; +} + +print_table($table); + +?> diff --git a/pandora_console/operation/integria_incidents/incident.workunits.php b/pandora_console/operation/integria_incidents/incident.workunits.php new file mode 100644 index 0000000000..d8aefcd454 --- /dev/null +++ b/pandora_console/operation/integria_incidents/incident.workunits.php @@ -0,0 +1,67 @@ +width = "98%"; +$table->class = "databox"; + +$table->data = array(); +$table->colspan[1][0] = 3; + +$profiles = array(); +$default_time = "0.25"; +$table->data[0][0] = "".__('Time used')."
".print_input_text ('time_used', $default_time, '', 10, 255, true); +$table->data[0][1] = "".__('Have cost')."
".print_checkbox ('have_cost', '', false, true); +$table->data[0][2] = "".__('Public')."
".print_checkbox ('public', '', true, true); + +$table->data[1][0] = "".__('Description')."
".print_textarea('description', 3, 6, '' , '', true); + +$form = "
"; +$form .= print_table($table, true); +$form .= print_submit_button(__('Add'), 'submit_button', false, '', true); +$form .= print_input_hidden('tab', 'workunits', true); +$form .= print_input_hidden('create_workunit', '1', true); +$form .= print_input_hidden('id_incident', $id_incident, true); +$form .= print_input_hidden('profile', '0', true); +$form .= "
"; + +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']; + + print_table($table); +} +?> diff --git a/pandora_console/operation/integria_incidents/incident_detail.php b/pandora_console/operation/integria_incidents/incident_detail.php new file mode 100755 index 0000000000..373483c435 --- /dev/null +++ b/pandora_console/operation/integria_incidents/incident_detail.php @@ -0,0 +1,428 @@ + $config["id_user"], + 'id_incident' => $id_inc, + 'nota' => $nota); + $id_nota = process_sql_insert('tnota', $values); + + if ($id_nota !== false) { + process_incidents_touch ($id_inc); + } + print_result_message ($id_nota, + __('Successfully added'), + __('Could not be added')); + } + + // Delete note + if (isset ($_POST["delete_nota"])) { + $id_nota = get_parameter_post ("delete_nota", 0); + $note_user = get_incidents_notes_author ($id_nota); + if (((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($note_user == $config["id_user"])) OR ($id_owner == $config["id_user"])) { + // Only admins (manage incident) or owners can modify + // incidents notes. note authors are + // able to delete their own notes + $result = delete_incidents_note ($id_nota); + + if (!empty ($result)) { + process_incidents_touch ($id_inc); + } + print_result_message ($id_nota, + __('Successfully deleted'), + __('Could not be deleted')); + } + } + + // Delete file + if (((check_acl ($config["id_user"], $id_grupo, "IM")==1) OR ($id_owner == $config["id_user"])) AND isset ($_POST["delete_file"])) { + $file_id = (int) get_parameter_post ("delete_file", 0); + $filename = get_db_value ("filename", "tattachment", "id_attachment", $file_id); + + $result = process_sql_delete('tattachment', array('id_attachment' => $file_id)); + + if (!empty ($result)) { + unlink ($config["attachment_store"]."/pand".$file_id."_".$filename); + process_incidents_touch ($id_inc); + } + + print_result_message ($result, + __('Successfully deleted'), + __('Could not be deleted')); + } + + // Upload file + if ((check_acl ($config["id_user"], $id_grupo, "IW") == 1) AND isset ($_GET["upload_file"]) AND ($_FILES['userfile']['name'] != "")) { + $description = get_parameter_post ("file_description", __('No description available')); + + // Insert into database + $filename = safe_input ($_FILES['userfile']['name']); + $filesize = safe_input ($_FILES['userfile']['size']); + + //The following is if you have clamavlib installed + //(php5-clamavlib) and enabled in php.ini + //http://www.howtoforge.com/scan_viruses_with_php_clamavlib + if (extension_loaded ('clamav')) { + cl_setlimits (5, 1000, 200, 0, 10485760); + $malware = cl_scanfile ($_FILES['file']['tmp_name']); + if ($malware) { + $error = 'Malware detected: '.$malware.'
ClamAV version: '.clam_get_version(); + die ($error); //On malware, we die because it's not good to handle it + } + } + + $values = array( + 'id_incidencia' => $id_inc, + 'id_usuario' => $config["id_user"], + 'filename' => $filename, + 'description' => $description, + 'size' => $filesize); + $id_attachment = process_sql_insert('tattachment', $values); + + // Copy file to directory and change name + if ($id_attachment !== false) { + $nombre_archivo = $config["attachment_store"]."/pand".$id_attachment."_".$filename; + $result = copy ($_FILES['userfile']['tmp_name'], $nombre_archivo); + } + else { + echo '

'.__('File could not be saved due to database error').'

'; + $result = false; + } + + if ($result !== false) { + unlink ($_FILES['userfile']['tmp_name']); + process_incidents_touch ($id_inc); + } + else { + process_sql_delete('tattachment', array('id_attachment' => $id_attachment)); + } + + print_result_message ($result, + __('File uploaded'), + __('File could not be uploaded')); + } +} // else Not given id +// Create incident from event... read event data +elseif (isset ($_GET["insert_form"])) { + $titulo = ""; + $descripcion = ""; + $origen = ""; + $prioridad = 0; + $id_grupo = 0; + $estado = 0; + $texto = ""; + $usuario = $config["id_user"]; + $id_creator = $config["id_user"]; + + if (isset ($_GET["from_event"])) { + $event = get_parameter_get ("from_event"); + $titulo = get_event_description ($event); + $id_grupo = get_event_group ($event); + $origen = "Pandora FMS event"; + unset ($event); + } + $prioridad = 0; + $id_grupo = 0; +} else { + pandora_audit("HACK","Trying to get to incident details in an unusual way"); + require ("general/noaccess.php"); + exit; +} + + + +// ******************************************************************************************************** +// ******************************************************************************************************** +// Show the form +// ******************************************************************************************************** + +//This is for the pretty slide down attachment form +echo ""; + +if (isset ($id_inc)) { //If $id_inc is set (when $_GET["id"] is set, not $_GET["insert_form"] + print_page_header (__('Incident details'). ' #'.$id_inc, "images/book_edit.png", false, "", false, ""); + echo '
'; + echo ''; +} else { + print_page_header (__('Create incident'), "images/book_edit.png", false, "", false, ""); + echo ''; +} + +echo ''; +echo ''; + +echo ''; +echo ''; + +echo ''; + +echo '
'.__('Incident').''; + +if ((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"])) { + print_input_text ("titulo", $titulo,'', 70); +} else { + print_input_text_extended ("titulo", $titulo, "", "", 70, "", false, "", "readonly"); +} + +echo '
'.__('Opened at').''.date ($config['date_format'], $inicio).''.__('Updated at').''.date ($config['date_format'], $actualizacion).'
'.__('Owner').''; + +if ((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"])) { + print_select (get_users_info (), "usuario_form", $usuario, '', 'SYSTEM', '', false, false, true, "w135"); +} else { + print_select (get_users_info (), "usuario_form", $usuario, '', 'SYSTEM', '', false, false, true, "w135", true); +} +echo ''.__('Status').''; + +if ((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"])) { + print_select (get_incidents_status (), "estado_form", $estado, '', '', '', false, false, false, 'w135'); +} +else { + print_select (get_incidents_status (), "estado_form", $estado, '', '', '', false, false, false, 'w135', true); +} +echo '
'.__('Source').''; + +$fields = array (); +$return = get_db_all_rows_sql ("SELECT origen FROM torigen ORDER BY origen"); +if ($return === false) + $return[0] = $estado; //Something must be displayed + +foreach ($return as $row) { + $fields[$row["origen"]] = $row["origen"]; +} + +// Only owner could change source or user with Incident management privileges +if ((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"])) { + print_select ($fields, "origen_form", $estado, '', '', '', false, false, false, 'w135'); +} +else { + print_select ($fields, "origen_form", $estado, '', '', '', false, false, false, 'w135', true); +} +echo ''.__('Group').''; + +// Group combo +if ((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"])) { + print_select_groups($config["id_user"], "IR", true, "grupo_form", $id_grupo, '', '', '', false, false, false, 'w135'); +} else { + print_select_groups($config["id_user"], "IR", true, "grupo_form", $id_grupo, '', '', '', false, false, true, 'w135', true); +} + +echo '
'.__('Priority').''; + +if ((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"])) { + print_select (get_incidents_priorities (), "prioridad_form", $prioridad, '', '', '', false, false, false, 'w135'); +} else { + print_select (get_incidents_priorities (), "prioridad_form", $prioridad, '', '', '', false, false, false, 'w135', true); +} + +echo ''.__('Creator').''; +if (empty ($id_creator)) { + echo 'SYSTEM'; +} else { + echo $id_creator.' ('.get_user_fullname($id_creator).')'; +} + +echo '
'; + +if ((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"])) { + print_textarea ("descripcion", 15, 80, $texto, 'style="height:200px;"'); +} else { + print_textarea ("descripcion", 15, 80, $texto, 'style="height:200px;" disabled'); +} + +echo '
'; + +// Only if user is the used who opened incident or (s)he is admin +if (isset ($id_inc) AND ((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"]))) { + print_submit_button (__('Update incident'), "accion", false, 'class="sub upd"'); +} elseif (check_acl ($config["id_user"], $id_grupo, "IW")) { + print_submit_button (__('Create'), "accion", false, 'class="sub wand"'); +} else { + print_submit_button (__('Submit'), "accion", true, 'class="sub upd"'); +} +echo "
"; + +//If we're actually working on an incident +if (isset ($id_inc)) { + // ******************************************************************** + // Notes + // ******************************************************************** + + echo '
'; + + echo ''; + echo print_image ('images/add.png', true); + echo __('Add note'); + echo ''; + echo '
'; + echo '

'.__('Add note').'

'; + echo ' + + +
'; + + $result = get_incidents_notes ($id_inc); + + $table->cellpadding = 4; + $table->cellspacing = 4; + $table->class = "databox"; + $table->width = 600; + $table->data = array (); + $table->head = array (); + + foreach ($result as $row) { + $data = array (); + $data[0] = print_image("images/page_white_text.png", true, array("border" => '0')); + $data[1] = __('Author').': '.print_username ($row["id_usuario"], true).' ('.print_timestamp ($row["timestamp"], true).')'; + array_push ($table->data, $data); + + $data = array (); + $data[0] = ''; + if ((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($row["id_usuario"] == $config["id_user"])) { + $data[0] .= print_input_image ("delete_nota", "images/cross.png", $row["id_nota"], 'border:0px;" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;', true); + } + $data[1] = $row["nota"]; + array_push ($table->data, $data); + } + + if (!empty ($table->data)) { + echo "

".__('Notes attached to incident').'

'; + echo '
'; + print_table ($table); + echo '
'; + } + unset ($table); + + + // ************************************************************ + // Files attached to this incident + // ************************************************************ + + $result = get_incidents_attach ($id_inc); + + $table->cellpadding = 4; + $table->cellspacing = 4; + $table->class = "databox"; + $table->width = 650; + $table->head = array (); + $table->data = array (); + + $table->head[0] = __('Filename'); + $table->head[1] = __('Description'); + $table->head[2] = __('Size'); + $table->head[3] = __('Delete'); + + $table->align[2] = "center"; + $table->align[3] = "center"; + + foreach ($result as $row) { + $data[0] = print_image("images/disk.png", true, array("border" => '0', "align" => "top")) . '  '.$row["filename"].''; + $data[1] = $row["description"]; + $data[2] = format_for_graph ($row["size"])."B"; + if ((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"])) { + $data[3] = print_input_image ("delete_file", "images/cross.png", $row["id_attachment"], 'border:0px;" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;', true); + } else { + $data[3] = ''; + } + array_push ($table->data, $data); + } + + if (!empty ($table->data)) { + echo "

".__('Attached files')."

"; + echo '
'; + print_table ($table); + echo '
'; + } + unset ($table); + + // ************************************************************ + // Upload control + // ************************************************************ + + + // Upload control + if ((check_acl($config["id_user"], $id_grupo, "IW")==1)) { + + echo ''; + + echo '

'.__('Add attachment').'

'; + echo ' + + + +
'.__('Filename').'
'.__('Description').'
'; + } +} +?> diff --git a/pandora_console/operation/integria_incidents/incident_statistics.php b/pandora_console/operation/integria_incidents/incident_statistics.php new file mode 100755 index 0000000000..36623ad6e1 --- /dev/null +++ b/pandora_console/operation/integria_incidents/incident_statistics.php @@ -0,0 +1,67 @@ + +

'.__('Incidents by status').'

'; +if ($config['flash_charts']) { + echo graph_incidents_status (); +} +else { + echo ''; +} +echo '

'.__('Incidents by priority').'

'; +if ($config['flash_charts']) { + echo grafico_incidente_prioridad (); +} +else { + echo ''; +} +echo '

'.__('Incidents by group').'

'; +if ($config['flash_charts']) { + echo grafico_incidente_prioridad (); +} +else { + echo ''; +} +echo '

'.__('Incidents by user').'

'; +if ($config['flash_charts']) { + echo grafico_incidente_prioridad (); +} +else { + echo ''; +} +echo '

'.__('Incidents by source').'

'; +if ($config['flash_charts']) { + echo grafico_incidente_prioridad (); +} +else { + echo ''; +} +echo ''; +?>