function discussthis_autocomplete in Discuss This! 5
Same name and namespace in other branches
- 6 discussthis.autocomplete.inc \discussthis_autocomplete()
- 7.2 discussthis.autocomplete.inc \discussthis_autocomplete()
- 7 discussthis.autocomplete.inc \discussthis_autocomplete()
Autocomplete a forum topic discussion title
1 string reference to 'discussthis_autocomplete'
- discussthis_menu in ./
discussthis.module - hook_menu implementation
File
- ./
discussthis.module, line 513
Code
function discussthis_autocomplete($tid, $string = '') {
// The user enters a title for a forum topic.
if ($string != '') {
// Grab the first 10 forum nodes with titles like the string typed by the user
$result = db_query_range(db_rewrite_sql('SELECT n.nid,n.title FROM {node} n WHERE n.type = "forum" AND LOWER(n.title) LIKE LOWER("%s%%")'), $string, 0, 10);
$matches = array();
while ($node = db_fetch_object($result)) {
$n = $node->title;
// Quote any commas or doublequotes for security reasons (XSS)
if (strpos($node->title, ',') !== false || strpos($node->title, '"') !== false) {
$n = '"' . str_replace('"', '""', $node->title) . '"';
}
$matches[$n] = check_plain($node->title);
}
echo drupal_to_js($matches);
exit;
}
}