You are here

function uc_coupon_autocomplete_node in Ubercart Discount Coupons 7.2

Same name and namespace in other branches
  1. 5 uc_coupon.module \uc_coupon_autocomplete_node()
  2. 6 uc_coupon.admin.inc \uc_coupon_autocomplete_node()
  3. 7.3 uc_coupon.admin.inc \uc_coupon_autocomplete_node()

Autocomplete callback for product restrictions.

1 string reference to 'uc_coupon_autocomplete_node'
uc_coupon_menu in ./uc_coupon.module
Implements hook_menu().

File

./uc_coupon.admin.inc, line 896
Discount Coupons administration pages.

Code

function uc_coupon_autocomplete_node($string) {
  $matches = array();
  $product_types = uc_product_types();
  $result = db_query("SELECT nid, title FROM {node} WHERE type IN (:types) AND title LIKE :title", array(
    ':types' => $product_types,
    ':title' => "%{$string}%",
  ));
  foreach ($result as $row) {
    $title = check_plain($row->title);
    $matches[$title . ' [nid:' . $row->nid . ']'] = $title;
  }
  print drupal_json_encode($matches);
  exit;
}