function field_permissions_autocomplete in Field Permissions 6
Menu callback; Field permissions autocomplete.
1 string reference to 'field_permissions_autocomplete'
- _field_permissions_menu in includes/
admin.inc - Implementation of hook_menu().
File
- includes/
admin.inc, line 209 - Administrative interface for the Field Permissions module.
Code
function field_permissions_autocomplete($type = '', $string = '') {
$matches = array();
if (!empty($string)) {
if ($type == 'nodes') {
$result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title FROM {node} n WHERE LOWER(n.title) LIKE LOWER('%%%s%%') ORDER BY n.title"), $string, 0, 10);
while ($row = db_fetch_object($result)) {
$matches[$row->title . " [nid:{$row->nid}]"] = '<div class="reference-autocomplete">' . check_plain($row->title) . '</div>';
}
}
elseif ($type == 'users') {
$result = db_query_range("SELECT name FROM {users} WHERE LOWER(name) LIKE LOWER('%%%s%%') AND uid <> 0 ORDER BY name", $string, 0, 10);
while ($row = db_fetch_object($result)) {
$matches[$row->name] = check_plain($row->name);
}
}
}
drupal_json($matches);
}