function support_reference_autocomplete in Support Ticketing System 7
Same name and namespace in other branches
- 6 support_reference/support_reference.module \support_reference_autocomplete()
@todo: should we allow cross-client references?
1 string reference to 'support_reference_autocomplete'
- support_reference_menu in support_reference/
support_reference.module - Implements hook_menu().
File
- support_reference/
support_reference.module, line 160 - Support ticket references.
Code
function support_reference_autocomplete($client = NULL, $skipnid = 0) {
$matches = array();
if (is_object($client) && isset($client->clid) && support_access_clients($client)) {
$result = db_query('SELECT n.nid, n.title, r.rnid FROM {support_ticket} s INNER JOIN {node} n ON s.nid = n.nid LEFT JOIN {support_reference} r ON (r.nid = :skipnid AND r.rnid = s.nid) WHERE s.client = :client AND s.nid <> :skipnid ORDER BY n.nid DESC', array(
':skipnid' => $skipnid,
':client' => $client->clid,
));
foreach ($result as $ticket) {
// We are using the titles directly from the database instead of using node_load() for speed / memory reasons.
if (!empty($ticket->rnid)) {
// If rnid is non null, there's a reference already, so indicate that choosing it will cause removal.
// NOTE: check_plain() here causes double escaping on Drupal 7. (But not Drupal 6!)
$matches[] = t('[#!nid]: !title (remove)', array(
'!nid' => $ticket->nid,
'!title' => $ticket->title,
));
}
else {
// NOTE: check_plain() here causes double escaping on Drupal 7. (But not Drupal 6!)
$matches[] = t('[#!nid]: !title', array(
'!nid' => $ticket->nid,
'!title' => $ticket->title,
));
}
}
}
drupal_json_output($matches);
}