X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2FParticipant.php;h=a84a8070428a93dfff7c09861a66fd66950e2f0d;hb=021da9cd67825c3a2ad1356fa08c4daa716f976a;hp=e3d1c74123ffe8d1f6ef18ae6c2c4e2edcfb1dbb;hpb=149e631532beb9953cde6af3e647bbc82ee2e3d5;p=civicrm-core.git diff --git a/api/v3/Participant.php b/api/v3/Participant.php index e3d1c74123..a84a807042 100644 --- a/api/v3/Participant.php +++ b/api/v3/Participant.php @@ -1,9 +1,8 @@ id]); @@ -122,6 +121,9 @@ function _civicrm_api3_participant_create_spec(&$params) { $params['register_date']['api.default'] = "now"; $params['event_id']['api.required'] = 1; $params['contact_id']['api.required'] = 1; + // These are for the sake of search builder options - can be removed if that is fixed + $params['role_id']['api.aliases'] = array('participant_role'); + $params['status_id']['api.aliases'] = array('participant_status'); } /** @@ -136,35 +138,15 @@ function _civicrm_api3_participant_create_spec(&$params) { * @access public */ function civicrm_api3_participant_get($params) { + $mode = CRM_Contact_BAO_Query::MODE_EVENT; + $entity = 'participant'; - $options = _civicrm_api3_get_options_from_params($params, TRUE,'participant','get'); - $sort = CRM_Utils_Array::value('sort', $options, NULL); - $offset = CRM_Utils_Array::value('offset', $options); - $rowCount = CRM_Utils_Array::value('limit', $options); - $smartGroupCache = CRM_Utils_Array::value('smartGroupCache', $params); - $inputParams = CRM_Utils_Array::value('input_params', $options, array()); - $returnProperties = CRM_Utils_Array::value('return', $options, NULL); - - if (empty($returnProperties)) { - $returnProperties = CRM_Event_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_EVENT); - } - $newParams = CRM_Contact_BAO_Query::convertFormValues($inputParams); - $query = new CRM_Contact_BAO_Query($newParams, $returnProperties, NULL, - FALSE, FALSE, CRM_Contact_BAO_Query::MODE_EVENT - ); - list($select, $from, $where, $having) = $query->query(); - - $sql = "$select $from $where $having"; - - if (!empty($sort)) { - $sql .= " ORDER BY $sort "; - } - $sql .= " LIMIT $offset, $rowCount "; - $dao = CRM_Core_DAO::executeQuery($sql); + list($dao, $query) = _civicrm_api3_get_query_object($params, $mode, $entity); $participant = array(); while ($dao->fetch()) { $participant[$dao->participant_id] = $query->store($dao); + //@todo - is this required - contribution & pledge use the same query but don't self-retrieve custom data _civicrm_api3_custom_data_get($participant[$dao->participant_id], 'Participant', $dao->participant_id, NULL); }