示例#1
0
function task_breaker_transaction_add_comment_to_ticket()
{
    require_once plugin_dir_path(__FILE__) . '../models/comments.php';
    require_once plugin_dir_path(__FILE__) . '../models/tasks.php';
    $comment = new ThriveComments();
    $task = new ThriveProjectTasksModel();
    $details = filter_input(INPUT_POST, 'details', FILTER_SANITIZE_STRING);
    $ticket_id = filter_input(INPUT_POST, 'ticket_id', FILTER_VALIDATE_INT);
    $priority = filter_input(INPUT_POST, 'priority', FILTER_VALIDATE_INT);
    $completed = filter_input(INPUT_POST, 'completed', FILTER_SANITIZE_STRING);
    $project_id = filter_input(INPUT_POST, 'project_id', FILTER_SANITIZE_STRING);
    // Check if current user can add comment
    if (!task_breaker_can_add_task_comment($project_id, $ticket_id)) {
        task_breaker_api_message(array('message' => 'fail', 'stats' => $task->getTaskStatistics($project_id, $ticket_id), 'result' => task_breaker_comments_template($added_comment)));
    }
    // Get the current user that is logged in.
    $user_id = get_current_user_id();
    // Update the priority.
    $task->update_priority($ticket_id, $priority);
    // Prepare the comment statuses.
    $status = array('no' => 0, 'yes' => 1, 'reopen' => 2);
    // Update the task status
    if ($completed === 'yes') {
        $task->completeTask($ticket_id, $user_id);
    }
    // Reopen task
    if ($completed === 'reopen') {
        $task->renewTask($ticket_id);
    }
    if (empty($user_id)) {
        task_breaker_api_message(array('message' => 'fail'));
    }
    $new_comment = $comment->set_details($details)->set_user($user_id)->set_status($status[$completed])->set_ticket_id($ticket_id)->save();
    if ($new_comment) {
        $added_comment = $comment->fetch($new_comment);
        task_breaker_api_message(array('message' => 'success', 'stats' => $task->getTaskStatistics($project_id, $ticket_id), 'result' => task_breaker_comments_template($added_comment)));
    }
    return;
}
示例#2
0
    ?>
                </h3>
            </li>

            <?php 
    $comments = task_breaker_get_tasks_comments($args->id);
    ?>

            <?php 
    if (!empty($comments)) {
        ?>
                <?php 
        foreach ($comments as $comment) {
            ?>
                    <?php 
            echo task_breaker_comments_template($comment, (array) $args);
            ?>
                <?php 
        }
        ?>
            <?php 
    }
    ?>

        </ul><!--#task-lists-->

        <?php 
    if (task_breaker_can_add_task_comment($args->project_id, $args->task_id)) {
        ?>

            <div id="task-editor">