summaryrefslogtreecommitdiff
path: root/js/callbacks/gethistory.php
blob: 617b99244c89695d0cbf12c88cbaf7c3798c99b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/*
    This script gets the history of a task and
    returns it for HTML display in a page.
*/

define('IN_FS', true);

header('Content-type: text/html; charset=utf-8');

require_once('../../header.php');
require_once('../../includes/events.inc.php');

$csp->emit();

if( !isset($_GET['task_id']) or !is_numeric($_GET['task_id'])){
	die();
} else {
	$task_id = Get::num('task_id');
}

# recalculate $proj for permission check
$result = $db->query('SELECT project_id FROM {tasks} WHERE task_id = ?', array($task_id));
$project_id = $db->fetchOne($result);
if (!$project_id) {
	die();
}
$proj = new Project($project_id);

// Initialise user
if (Cookie::has('flyspray_userid') && Cookie::has('flyspray_passhash')) {
	$user = new User(Cookie::val('flyspray_userid'));
	$user->check_account_ok();
} else {
	$user = new User(0, $proj);
}

load_translations();

# set project of task asked for and then check permissions based on that
if ( !($task = Flyspray::getTaskDetails($task_id)) ) {
	die();
}

# also check the calculated view task permission in addition to view_history permission
if (!$user->can_view_task($task) or !$user->perms('view_history')) {
	die();
}

if ($details = Get::num('details')) {
    $details = " AND h.history_id = $details";
} else {
    $details = null;
}

$sql = get_events($task_id, $details);
$histories = $db->fetchAllArray($sql);

$page = new FSTpl;
$page->setTheme($proj->prefs['theme_style']);
$page->uses('histories', 'details');
if ($details) {
    event_description($histories[0]); // modifies global variables
    $page->assign('details_previous', $GLOBALS['details_previous']);
    $page->assign('details_new', $GLOBALS['details_new']);
}
$page->display('details.tabs.history.callback.tpl');

?>