コード例 #1
0
 }
 $values = array('inicio' => $timestamp, 'actualizacion' => $timestamp, 'titulo' => $titulo, 'descripcion' => $description, 'id_usuario' => $usuario, 'closed_by' => $closed_by, 'estado' => $estado, 'prioridad' => $priority, 'id_grupo' => $grupo, 'id_creator' => $id_creator, 'notify_email' => $email_notify, 'id_task' => $id_task, 'resolution' => $resolution, 'id_incident_type' => $id_incident_type, 'id_parent' => $idParentValue, 'sla_disabled' => $sla_disabled, 'email_copy' => $email_copy, 'editor' => $editor, 'id_group_creator' => $id_group_creator, 'blocked' => $blocked, 'old_status' => $old_status, 'old_resolution' => $old_resolution);
 $id = process_sql_insert('tincidencia', $values);
 if ($id !== false) {
     /* Update inventory objects in incident */
     update_incident_inventories($id, get_parameter('inventories'));
     $result_msg = '<h3 class="suc">' . __('Successfully created') . ' (id #' . $id . ')</h3>';
     $result_msg .= '<h4><a href="index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id=' . $id . '">' . __('Please click here to continue working with incident #') . $id . "</a></h4>";
     //Add traces and statistic information
     incidents_set_tracking($id, 'create', $priority, $estado, $resolution, $usuario, $grupo);
     audit_db($config["id_user"], $config["REMOTE_ADDR"], "Ticket created", "User " . $config['id_user'] . " created incident #" . $id);
     // Create automatically a WU with the editor ?
     if ($config["incident_creation_wu"] == 1) {
         $wu_text = __("WU automatically created by the editor on the incident creation.");
         // Do not send mail in this WU
         create_workunit($id, $wu_text, $editor, $config["iwu_defaultime"], 0, "", 1, 0);
     }
     // Email notify to all people involved in this incident
     if ($email_notify) {
         mail_incident($id, $usuario, "", 0, 1);
     }
     //insert data to incident type fields
     if ($id_incident_type != 0) {
         $sql_label = "SELECT `label` FROM `tincident_type_field` WHERE id_incident_type = {$id_incident_type}";
         $labels = get_db_all_rows_sql($sql_label);
         if ($labels === false) {
             $labels = array();
         }
         foreach ($labels as $label) {
             $id_incident_field = get_db_value_filter('id', 'tincident_type_field', array('id_incident_type' => $id_incident_type, 'label' => $label['label']), 'AND');
             $values_insert['id_incident'] = $id;
コード例 #2
0
ファイル: integria_cron.php プロジェクト: keunes/integriaims
/**
 * Auto close incidents mark as "pending to be deleted" and no activity in X hrs
 * Takes no parameters. Checked in the main loop.with the other tasks.
 */
function run_auto_incident_close()
{
    global $config;
    if (empty($config["auto_incident_close"]) || $config["auto_incident_close"] <= 0) {
        return;
    }
    require_once $config["homedir"] . "/include/functions_incidents.php";
    $utimestamp = date("U");
    $limit = date("Y-m-d H:i:s", $utimestamp - $config["auto_incident_close"] * 86400);
    // For each incident
    $incidents = get_db_all_rows_sql("SELECT * FROM tincidencia WHERE estado IN (1,2,3,4,5) AND actualizacion < '{$limit}'");
    $mailtext = __("This ticket has been closed automatically by Integria after waiting confirmation to close this ticket for \n") . $config["auto_incident_close"] . "  " . __("days");
    if ($incidents) {
        foreach ($incidents as $incident) {
            // Set status to "Closed" (# 7) and solution to 7 (Expired)
            process_sql("UPDATE tincidencia SET resolution = 7, estado = 7 WHERE id_incidencia = " . $incident["id_incidencia"]);
            // Add workunit
            create_workunit($incident["id_incidencia"], $mailtext, $incident["id_usuario"], 0, 0, "", 1);
            // Send mail warning about this autoclose
            if ($config["email_on_incident_update"] != 2 && $config["email_on_incident_update"] != 4) {
                mail_incident($incident["id_incidencia"], $incident["id_usuario"], $mailtext, 0, 10, 1);
            }
        }
    }
}
コード例 #3
0
ファイル: incident.php プロジェクト: keunes/integriaims
	$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'));
	}
	else {
		ui_print_error_message(__('There was a problem adding workunit'));
	}
	$active_tab = 'workunits';
}

// GET INCIDENT FROM DATABASE
$incident = get_full_incident($incident_id);

// TABS
?>
コード例 #4
0
 $nota = get_parameter("nota");
 $timeused = (double) get_parameter('duration');
 $have_cost = (int) get_parameter('have_cost');
 $profile = (int) get_parameter('work_profile');
 $public = (bool) get_parameter('public');
 // Adding a new workunit to a incident in NEW status
 // Status go to "Assigned" and Owner is the writer of this Workunit
 if ($incident["estado"] == 1 and $incident["id_creator"] != $config['id_user']) {
     $sql = sprintf('UPDATE tincidencia SET id_usuario = "%s", estado = 3,  affected_sla_id = 0, actualizacion = "%s" WHERE id_incidencia = %d', $config['id_user'], $timestamp, $id_incident);
     incident_tracking($id_incident, INCIDENT_STATUS_CHANGED, 3);
     incident_tracking($id_incident, INCIDENT_USER_CHANGED, $config["id_user"]);
 } else {
     $sql = sprintf('UPDATE tincidencia SET affected_sla_id = 0, actualizacion = "%s" WHERE id_incidencia = %d', $timestamp, $id_incident);
 }
 process_sql($sql);
 $workunit_id = create_workunit($id_incident, $nota, $config["id_user"], $timeused, $have_cost, $profile, $public);
 if (is_ajax()) {
     // Clean the output
     // A non empty ouptput will treated as a successful response
     ob_clean();
     if ($workunit_id !== false) {
         // Return the updated list
         $workunits = get_incident_workunits($id_incident);
         if ($workunits) {
             ob_clean();
             foreach ($workunits as $workunit) {
                 $workunit_data = get_workunit_data($workunit["id_workunit"]);
                 echo '<div class="comment">';
                 show_workunit_data($workunit_data, $title);
                 echo '</div>';
             }
コード例 #5
0
/**
 * Copy and insert in database a new file into incident
 *
 * @param int incident id
 * @param string file full path
 * @param string file description
 *
 */
function attach_incident_file($id, $file_temp, $file_description, $email_notify = false, $file_name = "")
{
    global $config;
    $file_temp = safe_output($file_temp);
    // Decoding HTML entities
    $filesize = filesize($file_temp);
    // In bytes
    if ($file_name != "") {
        $filename = $file_name;
    } else {
        $filename = basename($file_temp);
    }
    $filename = str_replace(array(" ", "(", ")"), "_", $filename);
    // Replace blank spaces
    $filename = filter_var($filename, FILTER_SANITIZE_URL);
    // Replace conflictive characters
    $sql = sprintf('INSERT INTO tattachment (id_incidencia, id_usuario,
			filename, description, size)
			VALUES (%d, "%s", "%s", "%s", %d)', $id, $config['id_user'], $filename, $file_description, $filesize);
    $id_attachment = process_sql($sql, 'insert_id');
    incident_tracking($id, INCIDENT_FILE_ADDED);
    $result_msg = ui_print_success_message(__('File added'), '', true);
    // Email notify to all people involved in this incident
    if ($email_notify) {
        if ($config["email_on_incident_update"] == 1) {
            mail_incident($id, $config['id_user'], 0, 0, 2);
        }
    }
    // Copy file to directory and change name
    $file_target = $config["homedir"] . "attachment/" . $id_attachment . "_" . $filename;
    $copy = copy($file_temp, $file_target);
    if (!$copy) {
        $result_msg = ui_print_error_message(__('File cannot be saved. Please contact Integria administrator about this error'), '', true);
        $sql = sprintf('DELETE FROM tattachment
				WHERE id_attachment = %d', $id_attachment);
        process_sql($sql);
    } else {
        // Delete temporal file
        unlink($file_temp);
        // Adding a WU noticing about this
        $link = "<a target='_blank' href='operation/common/download_file.php?type=incident&id_attachment=" . $id_attachment . "'>" . $filename . "</a>";
        $note = "Automatic WU: Added a file to this issue. Filename uploaded: " . $link;
        $public = 1;
        $timeused = 0;
        create_workunit($id, $note, $config["id_user"], $timeused, 0, "", $public);
        $timestamp = print_mysql_timestamp();
        $sql = sprintf('UPDATE tincidencia SET actualizacion = "%s" WHERE id_incidencia = %d', $timestamp, $id);
        process_sql($sql);
    }
    return $result_msg;
}
コード例 #6
0
function save_message_workunit()
{
    global $config;
    global $dir;
    global $id;
    include "include/functions_workunits.php";
    $return = array('correct' => false);
    $file_global_counter_chat = $dir . '/incident.' . $id . '.global_counter.txt';
    $log_chat_file = $dir . '/incident.' . $id . '.log.json.txt';
    //First lock the file
    $fp_global_counter = @fopen($file_global_counter_chat, "a+");
    if ($fp_global_counter === false) {
        echo json_encode($return);
        return;
    }
    //Try to look MAX_TIMES times
    $tries = 0;
    while (!flock($fp_global_counter, LOCK_EX)) {
        $tries++;
        if ($tries > MAX_TIMES) {
            echo json_encode($return);
            return;
        }
        sleep(1);
    }
    $text_encode = @file_get_contents($log_chat_file);
    $log = json_decode($text_encode, true);
    //debugPrint($log);
    $txtChat = __('---------- CHAT -------------');
    $txtChat .= "\n";
    foreach ($log as $message) {
        if ($message['type'] == 'notification') {
            //Disabled at the moment
            continue;
            //$txtChat .= __("<<SYSTEM>>");
        } else {
            $txtChat .= $message['user_name'];
        }
        $txtChat .= " :> ";
        $txtChat .= $message['text'];
        $txtChat .= "\n";
    }
    create_workunit($id, safe_input($txtChat), $config['id_user']);
    fclose($fp_global_counter);
    $return['correct'] = true;
    echo json_encode($return);
    return;
}