summaryrefslogtreecommitdiffstats
path: root/apis/taskmanager.inc.php
blob: 8365aac7f2b952d3a7e69c98ee5f4e151336f90c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php

require_once 'inc/taskmanager.inc.php';
require_once 'inc/property.inc.php';

if (!is_array($_POST['ids'])) {
	die('{"error" : "No Task ids given in POST data."}');
}

$return = array();
foreach ($_POST['ids'] as $id) {
	$status = Taskmanager::status($id);
	if ($status === false) {
		$return[] = array('id' => $id, 'error' => 'No connection to TaskManager');
		continue;
	}
	$return[] = $status;
	if (!isset($status['statusCode']) || ($status['statusCode'] !== TASK_WAITING && $status['statusCode'] !== TASK_PROCESSING)) {
		Taskmanager::release($id);
	}
}

echo json_encode(array('tasks' => $return));