tiki-list_trackers.php 2.39 KB
Newer Older
1
<?php
changi67's avatar
changi67 committed
2 3 4
/**
 * @package tikiwiki
 */
5
// (c) Copyright 2002-2016 by authors of the Tiki Wiki CMS Groupware Project
rjsmelo's avatar
rjsmelo committed
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$
changi67's avatar
changi67 committed
10

11
$section = 'trackers';
rjsmelo's avatar
rjsmelo committed
12
require_once('tiki-setup.php');
lphuberdeau's avatar
lphuberdeau committed
13
$trklib = TikiLib::lib('trk');
14
$access->check_feature('feature_trackers');
rjsmelo's avatar
rjsmelo committed
15
$auto_query_args = ['sort_mode', 'offset', 'find'];
16 17

// Only used to call an edit dialog directly from other pages
rjsmelo's avatar
rjsmelo committed
18 19
$auto_query_args = ['trackerId'];
if (! isset($_REQUEST["trackerId"])) {
20
	$_REQUEST["trackerId"] = 0;
21
}
rjsmelo's avatar
rjsmelo committed
22
if (! empty($_REQUEST['trackerId'])) {
23
	$smarty->assign('trackerInfo', $trklib->get_tracker($_REQUEST['trackerId']));
24
}
25 26
$smarty->assign('trackerId', $_REQUEST["trackerId"]);

rjsmelo's avatar
rjsmelo committed
27
if (! isset($_REQUEST["sort_mode"])) {
28
	$sort_mode = 'created_desc';
29
} else {
30
	$sort_mode = $_REQUEST["sort_mode"];
31
}
32
$smarty->assign_by_ref('sort_mode', $sort_mode);
rjsmelo's avatar
rjsmelo committed
33
if (! isset($_REQUEST["offset"])) {
34
	$offset = 0;
35
} else {
36
	$offset = $_REQUEST["offset"];
37
}
38 39 40 41 42
$smarty->assign_by_ref('offset', $offset);
if (isset($_REQUEST["find"])) {
	$find = $_REQUEST["find"];
} else {
	$find = '';
43
}
44
$smarty->assign('find', $find);
45 46 47 48 49
$trackers = $trklib->list_trackers($offset, $maxRecords, $sort_mode, $find, true);

foreach ($trackers["data"] as &$tracker) {
	if ($userlib->object_has_one_permission($tracker["trackerId"], 'tracker')) {
		$tracker["individual"] = 'y';
50
	} else {
51
		$tracker["individual"] = 'n';
52
	}
rjsmelo's avatar
rjsmelo committed
53

54
	$tracker['watched'] = $user && $tikilib->user_watches($user, 'tracker_modified', $tracker["trackerId"], 'tracker');
rjsmelo's avatar
rjsmelo committed
55

56
	// Could be used with object_perms_summary.tpl instead of the above but may be less performant
57 58 59 60 61 62 63 64 65
	//	$objectperms = Perms::get('tracker', trackerId);
	//	$smarty->assign('permsType', $objectperms->from());

	if ($tiki_p_admin_trackers !== 'y') {
		$tracker_info = $trklib->get_tracker_options($tracker['trackerId']);
		if ($tracker_info['adminOnlyViewEditItem'] === 'y') {
			$tracker = null;
		}
	}
66
}
67
$trackers['data'] = array_filter($trackers['data']);
68 69 70 71 72 73 74

$smarty->assign_by_ref('cant', $trackers['cant']);
$smarty->assign_by_ref('trackers', $trackers["data"]);

// disallow robots to index page:
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');

rjsmelo's avatar
rjsmelo committed
75
include_once('tiki-section_options.php');
76
$smarty->assign('title', tr('Trackers'));
77

78
// Display the template
lphuberdeau's avatar
lphuberdeau committed
79
$smarty->display("tiki-list_trackers.tpl");