$id_incident_field = get_db_value('id', 'tincident_type_field', 'id_incident_type', $id_incident_type); process_sql_insert('tincident_field_data', $values_insert); } } // ATTACH A FILE IF IS PROVIDED $upfiles = json_decode(safe_output($upfiles), true); if (!empty($upfiles)) { include_once 'include/functions_workunits.php'; foreach ($upfiles as $file) { if (is_array($file)) { if ($file['description']) { $file_description = $file['description']; } else { $file_description = __('No description available'); } $file_result = attach_incident_file($id, $file["location"], $file_description, false, $file["name"]); } } } // If the ticket creation is successful, redirect the page to the ticket dashboard detail of the new ticket echo "<script type=\"text/javascript\">"; echo "document.location.search= \"?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id={$id}\""; echo "</script>"; exit; } else { $result_msg = '<h3 class="error">' . __('Could not be created') . '</h3>'; } } } if (defined('AJAX')) { echo $result_msg;
ui_print_error_message(__('Ticket not found')); exit; } // GET ACTION PARAMETERS $upload_file = get_parameter('upload_file'); $add_workunit = get_parameter('add_workunit'); // ACTIONS if($upload_file) { $filename = get_parameter('upfile'); $file_description = get_parameter('description',__('No description available')); $file_temp = sys_get_temp_dir()."/$filename"; $result = attach_incident_file ($incident_id, clean_output($file_temp), $file_description); echo $result; $active_tab = 'files'; } if($add_workunit) { $note = get_parameter('note'); $public = 1; $timeused = "0.05"; $result = create_workunit ($incident_id, $note, $config["id_user"], $timeused, 0, "", $public, 0); if($result) { ui_print_success_message(__('Workunit added'));
$id_incident_field = get_db_value('id', 'tincident_type_field', 'id_incident_type', $id_incident_type); process_sql_insert('tincident_field_data', $values_insert); } } } else { $result_msg = ui_print_error_message(__('Could not be created'), '', true); } echo $result_msg; // ATTACH A FILE IF IS PROVIDED $upfile = get_parameter('upfile'); $file_description = get_parameter('file_description'); if ($upfile != '') { $filename = get_parameter('upfile'); $file_description = get_parameter('file_description', __('No description available')); $file_temp = sys_get_temp_dir() . "/{$filename}"; $result = attach_incident_file($id, $file_temp, $file_description); echo $result; $active_tab = 'files'; } } echo '<h1>' . __('My tickets') . '</h1>'; $statuses = get_indicent_status(); $statuses[-10] = __("Not closed"); $resolutions = get_incident_resolutions(); // FILTER // GET FILTER PARAMETERS $status = get_parameter('status', 0); $search = get_parameter('search', ''); unset($table); $table->class = 'result_table'; $table->width = '98%';
public function insertIncidentFile($file) { $system = System::getInstance(); if (include_once $system->getConfig('homedir') . "/include/functions_incidents.php") { include_once $system->getConfig('homedir') . "/include/functions_workunits.php"; $filename = $_FILES[$file]['name']; $filename = str_replace(" ", "_", $filename); $filename = filter_var($filename, FILTER_SANITIZE_URL); // Replace conflictive characters $correct_file_path = sys_get_temp_dir() . "/{$filename}"; $file_tmp = $_FILES[$file]['tmp_name']; if (rename($file_tmp, $correct_file_path)) { $file_path = $correct_file_path; } else { $file_path = $file_tmp; } $description_file = (string) $system->getRequest('description_file', ''); $result = attach_incident_file($this->id_incident, $file_path, $description_file); if (preg_match("/" . __('File added') . "/i", $result)) { $return = true; } else { $return = false; } } else { $return = false; } return $return; }