list-tracker_field_values_ajax.php 1.42 KB
Newer Older
1
<?php
2
// (c) Copyright 2002-2011 by authors of the Tiki Wiki CMS Groupware Project
changi67's avatar
changi67 committed
3 4 5 6 7
// 
// 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.
// $Id$

8 9
require_once('tiki-setup.php');
global $trklib; include_once('lib/trackers/trackerlib.php');
10 11 12 13 14 15
$err = false;

if ($prefs['feature_trackers'] !== 'y' || $prefs['feature_jquery'] !== 'y' || $prefs['feature_jquery_autocomplete'] !== 'y' ||
				empty($_REQUEST['fieldId'])) {
	$err = true;
} else if (empty($_REQUEST['trackerId'])) {
16 17 18 19
	$field_info = $trklib->get_tracker_field($_REQUEST['fieldId']);
	$_REQUEST['trackerId'] = $field_info['trackerId'];
}
if (empty($_REQUEST['trackerId'])) {
20 21 22 23 24 25 26 27 28 29 30
	$err = true;
} else {
	$tracker_info = $trklib->get_tracker($_REQUEST['trackerId']);
	if (empty($tracker_info)) {
		$err = true;
	} else {
		$tikilib->get_perm_object($_REQUEST['trackerId'], 'tracker', $tracker_info, true);
		if ($tiki_p_view_trackers != 'y') {
			$err = true;
		}
	}
31 32 33 34 35
}
if (!isset($_REQUEST['lang'])) {
	$_REQUEST['lang'] = '';
}

36 37 38 39 40 41 42 43 44 45 46
$values = array();
if (!$err) {	// errors
	$vals = $trklib->list_tracker_field_values($_REQUEST['trackerId'], $_REQUEST['fieldId'], 'opc', 'y', $_REQUEST['lang']);
	if (!empty($_REQUEST['q'])) {
		foreach ( $vals as &$val ) {
			if (strpos( $val, $_REQUEST['q']) !== false) {
				$values[] = $val;
			}
		}
	}
}
47

48
$access->output_serialized($values);