/** * Function to create Participant * * @param array $params array of contact id and event id values * * @return int $id of participant created */ function participantCreate($params) { $params = array('contact_id' => $params['contactID'], 'event_id' => $params['eventID'], 'status_id' => 2, 'role_id' => 1, 'register_date' => 20070219, 'source' => 'Wimbeldon', 'event_level' => 'Payment'); $result = civicrm_participant_create($params); if (CRM_Utils_Array::value('is_error', $result)) { throw new Exception('Could not create participant'); } return $result['result']; }
/** * check without event_id */ function testUpdateWithoutEventId() { $participantId = $this->participantCreate(array('contactID' => $this->_individualId, 'eventID' => $this->_eventID)); $params = array('contact_id' => $this->_individualId, 'status_id' => 3, 'role_id' => 3, 'register_date' => '2006-01-21', 'source' => 'US Open', 'event_level' => 'Donation'); $participant =& civicrm_participant_create($params); $this->assertEquals($participant['is_error'], 1); $this->assertEquals($participant['error_message'], 'Required parameter missing'); // Cleanup created participant records. $result = $this->participantDelete($participantId); }
/** * * @param <type> $params * @param <type> $onDuplicate * @return <type> */ function civicrm_create_participant_formatted(&$params, $onDuplicate) { _civicrm_initialize(); // return error if we have no params if (empty($params)) { return civicrm_create_error('Input Parameters empty'); } require_once 'CRM/Event/Import/Parser.php'; if ($onDuplicate != CRM_Event_Import_Parser::DUPLICATE_NOCHECK) { CRM_Core_Error::reset(); $error = civicrm_participant_check_params($params); if (civicrm_error($error)) { return $error; } } return civicrm_participant_create($params); }