function support_reference_autocomplete in Support Ticketing System 6
Same name and namespace in other branches
- 7 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 - Implementation of hook_menu().
File
- support_reference/
support_reference.module, line 148 - 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 = %d AND r.rnid = s.nid) WHERE s.client = %d AND s.nid <> %d ORDER BY n.nid DESC', $skipnid, $client->clid, $skipnid);
while ($ticket = db_fetch_object($result)) {
// 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.
$matches[] = t('[#@nid]: @title (remove)', array(
'@nid' => $ticket->nid,
'@title' => $ticket->title,
));
}
else {
$matches[] = t('[#@nid]: @title', array(
'@nid' => $ticket->nid,
'@title' => $ticket->title,
));
}
}
}
drupal_json($matches);
}