$data['status'] = 'error';
            echo json_encode($data);
        } else {
            $data['status'] = 'OK';
            echo json_encode($data);
        }
        exit;
    } else {
        if (is_array($validation_errors) && !empty($validation_errors)) {
            $data['status'] = 'error';
            $data['data'] = $validation_errors;
        } else {
            $data['status'] = 'OK';
            $action = POST('s_action');
            if ($action == 'subscribe') {
                Incident::insert_subscription($conn, $incident_id, $login);
            } elseif ($action == 'unsubscribe') {
                Incident::delete_subscriptions($conn, $incident_id, $login);
            }
            $db->close();
            header("Location: incident.php?id={$incident_id}&edit={$edit}");
            exit;
        }
    }
}
if (is_array($data['data']) && !empty($data['data'])) {
    $txt_error = "<div>" . _('We found the following errors') . ":</div>\n\t\t\t\t\t\t  <div style='padding:0px 3px 3px 15px;'>" . implode("<br/>", $data['data']) . "</div>";
    $config_nt = array('content' => $txt_error, 'options' => array('type' => 'nf_error', 'cancel_button' => FALSE), 'style' => 'width: 80%; margin: 20px auto; text-align: left;');
    $nt = new Notification('nt_1', $config_nt);
    $nt->show();
}
Esempio n. 2
0
}
/* Subscriptions Management */
if ($action == 'subscrip') {
    // Only admin, entity admin and ticket owner
    if (!Incident::user_incident_perms($conn, $id, $action)) {
        die_error(_("You are not allowed to subscribe a new user because you are neither *admin* or the ticket owner"));
    }
    if (POST('login')) {
        if (!ossim_valid($id, OSS_DIGIT)) {
            die_error("Wrong ID");
        }
        if (ossim_valid(POST('login'), OSS_USER)) {
            if (POST('subscribe')) {
                Incident::insert_subscription($conn, $id, $_POST['login']);
            } elseif (POST('unsubscribe')) {
                Incident::delete_subscriptions($conn, $id, $_POST['login']);
            }
        } else {
            die_error("Invalid user");
        }
    }
    if (intval(POST('nohmenu')) == 1) {
        header("Location: incident.php?id={$id}&edit={$edit}&nohmenu=1");
    } else {
        header("Location: incident.php?id={$id}&edit={$edit}");
    }
    exit;
}
/* New ticket */
if ($action == 'newticket') {
    if (!ossim_valid($id, OSS_DIGIT)) {