function patron_autocomplete in Library 6
Same name and namespace in other branches
- 5.2 patron/patron.module \patron_autocomplete()
Retrieve a pipe delimited string of autocomplete suggestions for existing patron
1 string reference to 'patron_autocomplete'
- patron_menu in patron/
patron.module - Implementation of hook_menu()
File
- patron/
patron.module, line 348
Code
function patron_autocomplete($string) {
$matches = array();
$result = db_query_range("SELECT n.nid, lp.barcode, n.title FROM {node} n, {library_patrons} lp WHERE lp.nid = n.nid AND n.type = 'patron' AND lp.disabled = %d AND (LOWER(n.title) LIKE LOWER('%%%s%%') OR lp.barcode = '%s')", PATRON_ENABLED, check_plain($string), check_plain($string), 0, 10);
$barcodes = variable_get('patron_use_barcodes', PATRON_NO_BARCODES);
while ($patron = db_fetch_object($result)) {
if ($barcodes == PATRON_BARCODES && !empty($patron->barcode)) {
$matches[$patron->title . ' [nid:' . $patron->nid . ']'] = check_plain($patron->barcode) . ' (' . check_plain($patron->title) . ')';
}
else {
$matches[$patron->title . ' [nid:' . $patron->nid . ']'] = check_plain($patron->title);
}
}
print drupal_to_js($matches);
exit;
}