function course_object_autocomplete_node in Course 6
Same name and namespace in other branches
- 8.3 course.module \course_object_autocomplete_node()
- 8.2 course.module \course_object_autocomplete_node()
- 7.2 course.module \course_object_autocomplete_node()
- 7 course.module \course_object_autocomplete_node()
Helper function for autocompletion of node titles.
1 string reference to 'course_object_autocomplete_node'
- course_menu in ./
course.module - Implements hook_menu().
File
- ./
course.module, line 2628 - course.module Core functionality for Courses.
Code
function course_object_autocomplete_node($types, $string) {
$values = explode(',', $types);
$placeholders = db_placeholders($values, 'varchar');
$values[] = $string;
$values[] = $string;
$result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, u.name FROM {node} n\n INNER JOIN {users} u ON u.uid = n.uid\n WHERE n.type IN ({$placeholders}) AND (title LIKE '%%%s%%' OR n.nid = %d)"), $values, 0, 10);
$matches = array();
while ($node = db_fetch_object($result)) {
$matches[$node->title . " [nid: {$node->nid}]"] = '<span class="autocomplete_title">' . check_plain($node->title) . '</span>';
}
drupal_json($matches);
}