tiki-tracker_view_history.php 2.09 KB
Newer Older
1
<?php
changi67's avatar
changi67 committed
2 3 4
/**
 * @package tikiwiki
 */
5
// (c) Copyright 2002-2015 by authors of the Tiki Wiki CMS Groupware Project
6
//
7 8
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
9
// $Id$
10 11 12 13 14 15

$section = 'trackers';
require_once ('tiki-setup.php');

$access->check_feature('feature_trackers');

lphuberdeau's avatar
lphuberdeau committed
16
$trklib = TikiLib::lib('trk');
17 18 19 20 21 22 23 24

$auto_query_args = array('offset', 'itemId', 'fieldId', 'filter');

if (!empty($_REQUEST['itemId'])) {
	$item_info = $trklib->get_item_info($_REQUEST['itemId']);
	$perms = Perms::get(array('type'=>'tracker', 'object'=> $item_info['trackerId']));
	if (!$perms->view_trackers) {
		$smarty->assign('errortype', 401);
25
		$smarty->assign('msg', tra('You do not have permission to view this page.'));
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
		$smarty->display('error.tpl');
		die;
	}
	$fieldId = empty($_REQUEST['fieldId'])?0: $_REQUEST['fieldId'];
	$smarty->assign_by_ref('fieldId', $fieldId);
	$filter = array();
	if (!empty($_REQUEST['version'])) {
		$filter['version'] = $_REQUEST['version'];
	}
	$smarty->assign_by_ref('filter', $filter);
	$offset = empty($_REQUEST['offset'])? 0: $_REQUEST['offset'];
	$smarty->assign('offset', $offset);

	$history = $trklib->get_item_history($item_info, $fieldId, $filter, $offset, $prefs['maxRecords']);
	$smarty->assign_by_ref('history', $history['data']);
	$smarty->assign_by_ref('cant', $history['cant']);

	foreach ($history['data'] as $i=>$hist) {
		if (empty($field_option[$hist['fieldId']])) {
			$field_option[$hist['fieldId']] = $trklib->get_tracker_field($hist['fieldId']);
		}
	}
	$smarty->assign_by_ref('item_info', $item_info);
	$smarty->assign_by_ref('field_option', $field_option);
}
51 52

$tiki_actionlog_conf = TikiDb::get()->table('tiki_actionlog_conf');
53 54 55 56 57 58 59
$logging = $tiki_actionlog_conf->fetchCount(
	array(
		'objectType' => 'trackeritem',
		'action' =>  $tiki_actionlog_conf->in(array('Created','Updated')),
		'status' =>  $tiki_actionlog_conf->in(array('y','v')),
	)
);
60 61
$smarty->assign('logging', $logging);

62
$smarty->assign('mid', 'tiki-tracker_view_history.tpl');
63
$smarty->display('tiki.tpl');