好的,所以我确实设法使用验证器解决了这个问题:
<?php
function validator_Blacklist($input, $parameter = '', $message = '')
{
$trklib = TikiLib::lib('trk');
$query = strtoupper(trim($input)); //$input has a trailing space which affects the query, strtoupper probably not needed
$result = $trklib->get_item_id(4,14,$query,false); //usage: get_item_id(tracker_id,field_id,string_query,partial_match);
$info = $trklib->get_tracker_item($result); //pass item id retrieved above to get all it's fields
$status = intval($info[204]); //array item 204 has the customer service status, 205 has a descriptive comment
if ($status==1) {
return tra("<strong><font color=red>DO NOT SERVICE: " . $info[205] . "</font></strong>");
}
return true;
}
?>
还有一个问题是我的字段类型(项目链接)正在传递未定义的 $input。一些挖掘表明 validatorslib.php 没有将项目链接作为下拉类型处理(项目链接的字母键是“r”):
if ( $field_value['type'] == 'g' or $field_value['type'] == 'e' or $field_value['type'] == 'y' or $field_value['type'] == 'd' or $field_value['type'] == 'D') {
// Let's handle drop-down style fields
$validationjs .= 'return $(\'select[name="'.$prefix.$field_value['fieldId'].'"] option:selected\').text(); ';
} else { // Let's handle text style fields
$validationjs .= 'return $("#'.$prefix.$field_value['fieldId'].'").val(); ';
我将第一行更改为:
if ( $field_value['type'] == 'g' or $field_value['type'] == 'e' or $field_value['type'] == 'y' or $field_value['type'] == 'd' or $field_value['type'] == 'D' or $field_value['type'] == 'r') {
现在一切似乎都在工作(我不认为我在此过程中破坏了任何其他功能。)当我有时间时,我可能会使其更加健壮(将跟踪器和字段作为参数等)。