/**
     * List all the scheduled task in place on the forum.
     *
     * @uses ManageScheduledTasks template, view_scheduled_tasks sub-template
     */
    public function action_tasks()
    {
        global $context, $txt, $scripturl;
        // We'll need to recalculate dates and stuff like that.
        require_once SUBSDIR . '/ScheduledTasks.subs.php';
        // Mama, setup the template first - cause it's like the most important bit, like pickle in a sandwich.
        // ... ironically I don't like pickle. </grudge>
        $context['sub_template'] = 'view_scheduled_tasks';
        $context['page_title'] = $txt['maintain_tasks'];
        // Saving changes?
        if (isset($_REQUEST['save']) && isset($_POST['enable_task'])) {
            checkSession();
            // Enable and disable as required.
            $enablers = array(0);
            foreach ($_POST['enable_task'] as $id => $enabled) {
                if ($enabled) {
                    $enablers[] = (int) $id;
                }
            }
            // Do the update!
            updateTaskStatus($enablers);
            // Pop along...
            calculateNextTrigger();
        }
        // Want to run any of the tasks?
        if (isset($_REQUEST['run']) && isset($_POST['run_task'])) {
            // Lets figure out which ones they want to run.
            $tasks = array();
            foreach ($_POST['run_task'] as $task => $dummy) {
                $tasks[] = (int) $task;
            }
            // Load up the tasks.
            $nextTasks = loadTasks($tasks);
            // Lets get it on!
            require_once SUBSDIR . '/ScheduledTask.class.php';
            call_integration_include_hook('integrate_autotask_include');
            ignore_user_abort(true);
            foreach ($nextTasks as $task_id => $taskname) {
                run_this_task($task_id, $taskname);
            }
            // Things go as expected?  If not save the error in session
            if (!empty($context['scheduled_errors'])) {
                $_SESSION['st_error'] = $context['scheduled_errors'];
            }
            redirectexit('action=admin;area=scheduledtasks;done');
        }
        // Build the list so we can see the tasks
        $listOptions = array('id' => 'scheduled_tasks', 'title' => $txt['maintain_tasks'], 'base_href' => $scripturl . '?action=admin;area=scheduledtasks', 'get_items' => array('function' => array($this, 'list_getScheduledTasks')), 'columns' => array('name' => array('header' => array('value' => $txt['scheduled_tasks_name'], 'style' => 'width: 40%;'), 'data' => array('sprintf' => array('format' => '
								<a class="linkbutton" href="' . $scripturl . '?action=admin;area=scheduledtasks;sa=taskedit;tid=%1$d" title="' . $txt['scheduled_task_edit'] . ' %2$s"><i class="fa fa-pencil-square-o"></i> %2$s</a><br /><span class="smalltext">%3$s</span>', 'params' => array('id' => false, 'name' => false, 'desc' => false)))), 'next_due' => array('header' => array('value' => $txt['scheduled_tasks_next_time']), 'data' => array('db' => 'next_time', 'class' => 'smalltext')), 'regularity' => array('header' => array('value' => $txt['scheduled_tasks_regularity']), 'data' => array('db' => 'regularity', 'class' => 'smalltext')), 'enabled' => array('header' => array('value' => $txt['scheduled_tasks_enabled'], 'style' => 'width: 6%;text-align: center;'), 'data' => array('sprintf' => array('format' => '
								<input type="hidden" name="enable_task[%1$d]" id="task_%1$d" value="0" /><input type="checkbox" name="enable_task[%1$d]" id="task_check_%1$d" %2$s class="input_check" />', 'params' => array('id' => false, 'checked_state' => false)), 'class' => 'centertext')), 'run_now' => array('header' => array('value' => $txt['scheduled_tasks_run_now'], 'style' => 'width: 12%;text-align: center;'), 'data' => array('sprintf' => array('format' => '
								<input type="checkbox" name="run_task[%1$d]" id="run_task_%1$d" class="input_check" />', 'params' => array('id' => false)), 'class' => 'centertext'))), 'form' => array('href' => $scripturl . '?action=admin;area=scheduledtasks'), 'additional_rows' => array(array('class' => 'submitbutton', 'position' => 'below_table_data', 'value' => '
						<input type="submit" name="run" value="' . $txt['scheduled_tasks_run_now'] . '" class="right_submit" />
						<input type="submit" name="save" value="' . $txt['scheduled_tasks_save_changes'] . '" class="right_submit" />'), array('position' => 'after_title', 'value' => $txt['scheduled_tasks_time_offset'], 'class' => 'windowbg2')));
        require_once SUBSDIR . '/GenericList.class.php';
        createList($listOptions);
        $context['sub_template'] = 'view_scheduled_tasks';
        $context['tasks_were_run'] = isset($_GET['done']);
        // If we had any errors, place them in context as well
        if (isset($_SESSION['st_error'])) {
            $context['scheduled_errors'] = $_SESSION['st_error'];
            unset($_SESSION['st_error']);
        }
    }
예제 #2
0
Copyrights for portions of this file are retained by their owners.

Based on myTinyTodo by Max Pozdeev
(C) Copyright 2009-2010 Max Pozdeev <*****@*****.**>

Licensed under the GNU GPL v3 license. See file COPYRIGHT for details.
*/
require_once '../ajax.php';
$db = DBConnection::instance();
$list_id = isset($_GET['listid']) && intval($_GET['listid']) > 0 ? intval($_GET['listid']) : 0;
if (empty($list_id)) {
    die('Error!');
}
$q = $db->dq("SELECT * FROM {$db->prefix}lists WHERE id = " . $list_id . " ORDER BY ow ASC, id ASC");
$list_data = $q->fetch_assoc($q);
$list = loadTasks($list_id, 0, '', '', 1);
$total_time = 0;
$total_progress = 0;
foreach ($list['list'] as $item) {
    $total_time += floatval($item['duration']);
    $total_progress += floatval($item['progress_current']);
}
if ($total_time > 0) {
    $total_progress_value = round(100 * $total_progress / $total_time);
    $total_time_value = 100 - $total_progress_value;
} else {
    $total_progress_value = 0;
    $total_time_value = 100;
}
$total_days = 0;
$total_hours = 0;
예제 #3
0
    } else {
        $sqlWhere = '';
    }
    $t = array();
    $t['total'] = 0;
    $q = $db->dq("SELECT * FROM {$db->prefix}lists {$sqlWhere} ORDER BY ow ASC, id ASC");
    while ($r = $q->fetch_assoc($q)) {
        $t['total']++;
        $t['list'][] = prepareList($r);
    }
    jsonExit($t);
} elseif (isset($_GET['loadTasks'])) {
    stop_gpc($_GET);
    $listId = (int) _get('list');
    check_read_access($listId);
    $t = loadTasks($listId, _get('compl'), _get('t'), _get('s'), (int) _get('sort'), _get('setCompl'), _get('setNotification'));
    jsonExit($t);
} elseif (isset($_GET['newTask'])) {
    stop_gpc($_POST);
    $listId = (int) _post('list');
    check_write_access($listId);
    $t = array();
    $t['total'] = 0;
    $title = trim(_post('title'));
    $prio = 0;
    $tags = '';
    if (Config::get('smartsyntax') != 0) {
        $a = parse_smartsyntax($title);
        if ($a === false) {
            jsonExit($t);
        }
예제 #4
0
 public function loadTasks()
 {
     echo "test loadTasks is running \n";
     $res = loadTasks();
     $this->assertEquals(3, $res);
 }