public static function getPCPList() {
$name = CRM_Utils_Array::value('term', $_GET);
$name = CRM_Utils_Type::escape($name, 'String');
- $limit = '10';
+ $limit = $max = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'search_autocomplete_count', NULL, 10);
$where = ' AND pcp.page_id = cp.id AND pcp.contact_id = cc.id';
$whereClause = " WHERE ( sort_name LIKE '$strSearch' $includeNickName ) {$where} ";
}
- if (!empty($_GET['limit'])) {
- $limit = CRM_Utils_Type::escape($_GET['limit'], 'Positive');
+ $offset = $count = 0;
+ if (!empty($_GET['page'])) {
+ $page = (int) $_GET['page'];
+ $offset = $limit * ($page - 1);
+ $limit++;
}
$select = 'cc.sort_name, pcp.title, cp.title';
FROM civicrm_pcp pcp, civicrm_event cp, civicrm_contact cc
{$includeEmailFrom}
{$whereClause} AND pcp.page_type = 'event'
- LIMIT 0, {$limit}
) t
ORDER BY sort_name
+ LIMIT $offset, $limit
";
$dao = CRM_Core_DAO::executeQuery($query);
- $results = array();
+ $output = array('results' => array(), 'more' => FALSE);
while ($dao->fetch()) {
- $results[] = array('id' => $dao->id, 'text' => $dao->data);
+ if (++$count > $max) {
+ $output['more'] = TRUE;
+ }
+ else {
+ $output['results'][] = array('id' => $dao->id, 'text' => $dao->data);
+ }
}
- CRM_Utils_JSON::output($results);
+ CRM_Utils_JSON::output($output);
}
public static function relationship() {
minimumInputLength: 1,
ajax: {
url: pcpURL,
- data: function(term) {
- return {term: term};
+ data: function(term, page) {
+ return {term: term, page: page};
},
results: function(response) {
- return {results: response};
+ return response;
}
},
initSelection: function(el, callback) {