示例#1
0
 /**
  * check with event_id
  * fetch with limit
  */
 function testSearchByEventWithLimit()
 {
     // Should 2 participant records since we're passing rowCount = 2.
     $params = array('event_id' => $this->_eventID, 'rowCount' => 3);
     $participant =& civicrm_participant_search($params);
     $this->assertEquals(count($participant), 3);
 }
示例#2
0
/**
 * Retrieve a specific participant, given a set of input params
 * If more than one matching participant exists, return an error, unless
 * the client has requested to return the first found contact
 *
 * @param  array   $params           (reference ) input parameters
 *
 * @return array (reference )        array of properties, if error an array with an error id and error message
 * @static void
 * @access public
 */
function &civicrm_participant_get(&$params)
{
    _civicrm_initialize();
    $values = array();
    if (empty($params)) {
        $error = civicrm_create_error(ts('No input parameters present'));
        return $error;
    }
    if (!is_array($params)) {
        $error = civicrm_create_error(ts('Input parameters is not an array'));
        return $error;
    }
    if (isset($params['id'])) {
        $params['participant_id'] = $params['id'];
        unset($params['id']);
    }
    $participant =& civicrm_participant_search($params);
    if (count($participant) != 1 && !CRM_Utils_Array::value('returnFirst', $params)) {
        $error = civicrm_create_error(ts('%1 participant matching input params', array(1 => count($participant))), $participant);
        return $error;
    }
    if (civicrm_error($participant)) {
        return $participant;
    }
    $participant = array_values($participant);
    return $participant[0];
}