예제 #1
0
function task_breaker_transaction_fetch_task()
{
    $task_id = (int) filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
    $page = (int) filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT);
    $project_id = (int) filter_input(INPUT_GET, 'project_id', FILTER_VALIDATE_INT);
    $priority = (int) filter_input(INPUT_GET, 'priority', FILTER_VALIDATE_INT);
    $search = filter_input(INPUT_GET, 'search', FILTER_SANITIZE_URL);
    $show_completed = filter_input(INPUT_GET, 'show_completed', FILTER_SANITIZE_STRING);
    $callback_template = filter_input(INPUT_GET, 'template', FILTER_SANITIZE_STRING);
    $html_template = 'task_breaker_render_task';
    $template = '';
    if (!empty($callback_template) && function_exists($callback_template)) {
        $html_template = $callback_template;
    }
    if (!task_breaker_can_see_project_tasks($project_id)) {
        task_breaker_api_message(array('message' => 'fail', 'message_long' => __('Unable to access the task details. Only group members can access this page', 'task-breaker'), 'task' => array(), 'stats' => array(), 'debug' => __("Unauthorized Access", "task-breaker"), 'html' => ""));
        return;
    }
    $task = new ThriveProjectTasksController();
    $args = array('project_id' => $project_id, 'id' => $task_id, 'page' => $page, 'priority' => $priority, 'search' => $search, 'show_completed' => $show_completed, 'orderby' => 'priority', 'order' => 'desc', 'echo' => 'no');
    $task_collection = $task->renderTasks($args);
    // Push the ticket ID in the task_collection stack.
    $task_collection->task_id = absint($task_id);
    if (0 === $task_id) {
        $task_id = null;
        $template = $html_template($args);
    } else {
        if (!empty($callback_template)) {
            $template = $html_template($task_collection);
        }
    }
    $stats = array();
    if (array_key_exists('stats', $task_collection)) {
        $stats = $task_collection['stats'];
    }
    task_breaker_api_message(array('message' => 'success', 'task' => $task_collection, 'stats' => $stats, 'debug' => $task_id, 'html' => $template));
    return;
}
예제 #2
0
/**
 * Renders the tasks
 * @param  array $args The post type configs
 * @return void
 */
function task_breaker_the_tasks($args)
{
    ob_start();
    require_once plugin_dir_path(__FILE__) . '../controllers/tasks.php';
    $config = array('project_id' => 0, 'page' => 1, 'priority' => -1, 'search' => '', 'orderby' => 'date_created', 'order' => 'desc', 'show_completed' => 'no', 'echo' => true);
    foreach ($config as $option => $value) {
        if (!empty($args[$option])) {
            ${$option} = $args[$option];
        } else {
            ${$option} = $value;
        }
    }
    $task_breaker_tasks = new ThriveProjectTasksController();
    $tasks = $task_breaker_tasks->renderTasks($args);
    // Fallback to default values when there are no tasks.
    if (empty($tasks)) {
        // Default parameters.
        $tasks = array('stats' => array('total' => 0, 'perpage' => 5, 'current_page' => 1, 'total_page' => 1, 'min_page' => 0, 'max_page' => 0));
    }
    $tasks['project_id'] = $project_id;
    ?>

<div class="clearfix"></div>

<div id="task_breaker-project-tasks">

	<?php 
    task_breaker_locate_template('task-loop', $tasks);
    ?>

</div><!--#task_breaker-project-tasks-->

<?php 
    return ob_get_clean();
}