X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2FGeneric%2FGetlist.php;h=7a5255f3bb77bc9a5c16fa1dcfa1ce91f789a36a;hb=03c24df0b528f700e6765cc18a2c14d4d70e4bdf;hp=7e6a4f6dc99127f415f199ee4d8aa2a12a13eb77;hpb=75918412f2a62b58b74c99643262cf440505cc54;p=civicrm-core.git diff --git a/api/v3/Generic/Getlist.php b/api/v3/Generic/Getlist.php index 7e6a4f6dc9..7a5255f3bb 100644 --- a/api/v3/Generic/Getlist.php +++ b/api/v3/Generic/Getlist.php @@ -2,9 +2,9 @@ /* +--------------------------------------------------------------------+ -| CiviCRM version 4.4 | +| CiviCRM version 4.5 | +--------------------------------------------------------------------+ -| Copyright CiviCRM LLC (c) 2004-2013 | +| Copyright CiviCRM LLC (c) 2004-2014 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -50,13 +50,15 @@ function civicrm_api3_generic_getList($apiRequest) { $fnName = function_exists($fnName) ? $fnName : '_civicrm_api3_generic_getlist_output'; $values = $fnName($result, $request); - $last = $request['params']['limit'] - 1; - $output = array( + $output = array('page_num' => $request['page_num']); + + // Limit is set for searching but not fetching by id + if (!empty($request['params']['options']['limit'])) { // If we have an extra result then this is not the last page - 'more_results' => isset($values[$last]), - 'page_num' => $request['page_num'], - ); - unset($values[$last]); + $last = $request['params']['options']['limit'] - 1; + $output['more_results'] = isset($values[$last]); + unset($values[$last]); + } return civicrm_api3_create_success($values, $request['params'], $entity, 'getlist', CRM_Core_DAO::$_nullObject, $output); } @@ -111,9 +113,11 @@ function _civicrm_api3_generic_getList_defaults($entity, &$request) { } // When looking up a field e.g. displaying existing record if (!empty($request['id'])) { - if (is_string($request['id']) && strpos(',', $request['id'])) { - $request['id'] = explode(',', $request['id']); + if (is_string($request['id']) && strpos($request['id'], ',')) { + $request['id'] = explode(',', trim($request['id'], ', ')); } + // Don't run into search limits when prefilling selection + unset($params['options']['limit'], $params['options']['offset'], $request['params']['options']['limit'], $request['params']['options']['offset']); $params[$request['id_field']] = is_array($request['id']) ? array('IN' => $request['id']) : $request['id']; } $request['params'] += $params;