Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2015-02-25-11-27-40
[civicrm-core.git] / CRM / Event / Page / AJAX.php
index 410c5e172fb404fb4bdad666e824bab17d743bc2..66ceb0e0e5c035f04faab0c722cd4432e198a33c 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
 class CRM_Event_Page_AJAX {
 
   /**
-   * Function for building EventFee combo box
+   * Building EventFee combo box.
+   * FIXME: This ajax callback could be eliminated in favor of an entityRef field but the priceFieldValue api doesn't currently support filtering on entity_table
    */
-  function eventFee() {
-    $name = trim(CRM_Utils_Type::escape($_GET['s'], 'String'));
+  public function eventFee() {
+    $name = trim(CRM_Utils_Type::escape($_GET['term'], 'String'));
 
     if (!$name) {
       $name = '%';
@@ -61,10 +62,9 @@ GROUP BY cv.label";
     $dao = CRM_Core_DAO::executeQuery($query);
     $results = array();
     while ($dao->fetch()) {
-      $results[$dao->id] = $dao->label;
+      $results[] = array('id' => $dao->id, 'text' => $dao->label);
     }
-    CRM_Core_Page_AJAX::autocompleteResults($results);
+    CRM_Utils_JSON::output($results);
   }
 
 }
-