本文整理汇总了PHP中CRM_Event_DAO_Participant类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Event_DAO_Participant类的具体用法?PHP CRM_Event_DAO_Participant怎么用?PHP CRM_Event_DAO_Participant使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Event_DAO_Participant类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteParticipantStatusType
/**
* @param int $id
*
* @return bool
*/
public static function deleteParticipantStatusType($id)
{
// return early if there are participants with this status
$participant = new CRM_Event_DAO_Participant();
$participant->status_id = $id;
if ($participant->find()) {
return FALSE;
}
CRM_Utils_Weight::delWeight('CRM_Event_DAO_ParticipantStatusType', $id);
$dao = new CRM_Event_DAO_ParticipantStatusType();
$dao->id = $id;
$dao->find(TRUE);
$dao->delete();
return TRUE;
}
示例2: deleteParticipantStatusType
static function deleteParticipantStatusType($id)
{
// return early if there are participants with this status
require_once 'CRM/Event/DAO/Participant.php';
$participant = new CRM_Event_DAO_Participant();
$participant->status_id = $id;
if ($participant->find()) {
return false;
}
require_once 'CRM/Utils/Weight.php';
CRM_Utils_Weight::delWeight('CRM_Event_DAO_ParticipantStatusType', $id);
$dao = new CRM_Event_DAO_ParticipantStatusType();
$dao->id = $id;
$dao->find(true);
$dao->delete();
return true;
}
示例3: postProcess
/**
* Process the form when submitted.
*
* @return void
*/
public function postProcess()
{
$participant = new CRM_Event_DAO_Participant();
$participant->event_id = $this->_id;
if ($participant->find()) {
$searchURL = CRM_Utils_System::url('civicrm/event/search', 'reset=1');
CRM_Core_Session::setStatus(ts('This event cannot be deleted because there are participant records linked to it. If you want to delete this event, you must first find the participants linked to this event and delete them. You can use use <a href=\'%1\'> CiviEvent >> Find Participants page </a>.', array(1 => $searchURL)), ts('Deletion Error'), 'error');
return;
}
CRM_Event_BAO_Event::del($this->_id);
if ($this->_isTemplate) {
CRM_Core_Session::setStatus(ts("'%1' has been deleted.", array(1 => $this->_title)), ts('Template Deleted'), 'success');
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/eventTemplate', 'reset=1'));
} else {
CRM_Core_Session::setStatus(ts("'%1' has been deleted.", array(1 => $this->_title)), ts('Event Deleted'), 'success');
}
}
示例4: deleteContactParticipant
/**
* Delete participants of contact.
*
* CRM-12155
*
* @param int $contactId
* Contact id.
*
*/
public static function deleteContactParticipant($contactId)
{
$participant = new CRM_Event_DAO_Participant();
$participant->contact_id = $contactId;
$participant->find();
while ($participant->fetch()) {
self::deleteParticipant($participant->id);
}
}
示例5: updateRecords
/**
* Updates contacts affected by the option value passed.
*
* @param int $optionValueId
* The option value id.
* @param int $action
* The action describing whether prefix/suffix was UPDATED or DELETED.
*
* @return bool
*/
public static function updateRecords(&$optionValueId, $action)
{
//finding group name
$optionValue = new CRM_Core_DAO_OptionValue();
$optionValue->id = $optionValueId;
$optionValue->find(TRUE);
$optionGroup = new CRM_Core_DAO_OptionGroup();
$optionGroup->id = $optionValue->option_group_id;
$optionGroup->find(TRUE);
// group name
$gName = $optionGroup->name;
// value
$value = $optionValue->value;
// get the proper group name & affected field name
// todo: this may no longer be needed for individuals - check inputs
$individuals = array('gender' => 'gender_id', 'individual_prefix' => 'prefix_id', 'individual_suffix' => 'suffix_id', 'communication_style' => 'communication_style_id');
$contributions = array('payment_instrument' => 'payment_instrument_id');
$activities = array('activity_type' => 'activity_type_id');
$participant = array('participant_role' => 'role_id');
$eventType = array('event_type' => 'event_type_id');
$aclRole = array('acl_role' => 'acl_role_id');
$all = array_merge($individuals, $contributions, $activities, $participant, $eventType, $aclRole);
$fieldName = '';
foreach ($all as $name => $id) {
if ($gName == $name) {
$fieldName = $id;
}
}
if ($fieldName == '') {
return TRUE;
}
if (array_key_exists($gName, $individuals)) {
$contactDAO = new CRM_Contact_DAO_Contact();
$contactDAO->{$fieldName} = $value;
$contactDAO->find();
while ($contactDAO->fetch()) {
if ($action == CRM_Core_Action::DELETE) {
$contact = new CRM_Contact_DAO_Contact();
$contact->id = $contactDAO->id;
$contact->find(TRUE);
// make sure dates doesn't get reset
$contact->birth_date = CRM_Utils_Date::isoToMysql($contact->birth_date);
$contact->deceased_date = CRM_Utils_Date::isoToMysql($contact->deceased_date);
$contact->{$fieldName} = 'NULL';
$contact->save();
}
}
return TRUE;
}
if (array_key_exists($gName, $contributions)) {
$contribution = new CRM_Contribute_DAO_Contribution();
$contribution->{$fieldName} = $value;
$contribution->find();
while ($contribution->fetch()) {
if ($action == CRM_Core_Action::DELETE) {
$contribution->{$fieldName} = 'NULL';
$contribution->save();
}
}
return TRUE;
}
if (array_key_exists($gName, $activities)) {
$activity = new CRM_Activity_DAO_Activity();
$activity->{$fieldName} = $value;
$activity->find();
while ($activity->fetch()) {
$activity->delete();
}
return TRUE;
}
//delete participant role, type and event type option value
if (array_key_exists($gName, $participant)) {
$participantValue = new CRM_Event_DAO_Participant();
$participantValue->{$fieldName} = $value;
if ($participantValue->find(TRUE)) {
return FALSE;
}
return TRUE;
}
//delete event type option value
if (array_key_exists($gName, $eventType)) {
$event = new CRM_Event_DAO_Event();
$event->{$fieldName} = $value;
if ($event->find(TRUE)) {
return FALSE;
}
return TRUE;
}
//delete acl_role option value
if (array_key_exists($gName, $aclRole)) {
//.........这里部分代码省略.........
示例6: addLineItemParticipants
private function addLineItemParticipants()
{
$participant = new CRM_Event_DAO_Participant();
$participant->query("INSERT INTO civicrm_line_item (`entity_table`, `entity_id`, contribution_id, `price_field_id`, `label`, `qty`, `unit_price`, `line_total`, `participant_count`, `price_field_value_id`, `financial_type_id`)\nSELECT 'civicrm_participant', cp.id, cpp.contribution_id, cpfv.price_field_id, cpfv.label, 1, cpfv.amount, cpfv.amount as line_total, 0, cpfv.id, cpfv.financial_type_id FROM civicrm_participant cp LEFT JOIN civicrm_participant_payment cpp ON cpp.participant_id = cp.id\nLEFT JOIN civicrm_price_set_entity cpe ON cpe.entity_id = cp.event_id LEFT JOIN civicrm_price_field cpf ON cpf.price_set_id = cpe.price_set_id LEFT JOIN civicrm_price_field_value cpfv ON cpfv.price_field_id = cpf.id WHERE cpfv.label = cp.fee_level");
}
示例7: _assignMessageVariablesToTemplate
//.........这里部分代码省略.........
$template->assign('pcpBlock', TRUE);
$template->assign('pcp_display_in_roll', $softDAO->pcp_display_in_roll);
$template->assign('pcp_roll_nickname', $softDAO->pcp_roll_nickname);
$template->assign('pcp_personal_note', $softDAO->pcp_personal_note);
//assign the pcp page title for email subject
$pcpDAO = new CRM_PCP_DAO_PCP();
$pcpDAO->id = $softDAO->pcp_id;
if ($pcpDAO->find(TRUE)) {
$template->assign('title', $pcpDAO->title);
}
}
}
if ($this->financial_type_id) {
$values['financial_type_id'] = $this->financial_type_id;
}
$template->assign('trxn_id', $this->trxn_id);
$template->assign('receive_date', CRM_Utils_Date::mysqlToIso($this->receive_date));
$template->assign('contributeMode', 'notify');
$template->assign('action', $this->is_test ? 1024 : 1);
$template->assign('receipt_text', CRM_Utils_Array::value('receipt_text', $values));
$template->assign('is_monetary', 1);
$template->assign('is_recur', (bool) $recur);
$template->assign('currency', $this->currency);
$template->assign('address', CRM_Utils_Address::format($input));
if (!empty($values['customGroup'])) {
$template->assign('customGroup', $values['customGroup']);
}
if ($this->_component == 'event') {
$template->assign('title', $values['event']['title']);
$participantRoles = CRM_Event_PseudoConstant::participantRole();
$viewRoles = array();
foreach (explode(CRM_Core_DAO::VALUE_SEPARATOR, $this->_relatedObjects['participant']->role_id) as $k => $v) {
$viewRoles[] = $participantRoles[$v];
}
$values['event']['participant_role'] = implode(', ', $viewRoles);
$template->assign('event', $values['event']);
$template->assign('participant', $values['participant']);
$template->assign('location', $values['location']);
$template->assign('customPre', $values['custom_pre_id']);
$template->assign('customPost', $values['custom_post_id']);
$isTest = FALSE;
if ($this->_relatedObjects['participant']->is_test) {
$isTest = TRUE;
}
$values['params'] = array();
//to get email of primary participant.
$primaryEmail = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Email', $this->_relatedObjects['participant']->contact_id, 'email', 'contact_id');
$primaryAmount[] = array('label' => $this->_relatedObjects['participant']->fee_level . ' - ' . $primaryEmail, 'amount' => $this->_relatedObjects['participant']->fee_amount);
//build an array of cId/pId of participants
$additionalIDs = CRM_Event_BAO_Event::buildCustomProfile($this->_relatedObjects['participant']->id, NULL, $this->_relatedObjects['contact']->id, $isTest, TRUE);
unset($additionalIDs[$this->_relatedObjects['participant']->id]);
//send receipt to additional participant if exists
if (count($additionalIDs)) {
$template->assign('isPrimary', 0);
$template->assign('customProfile', NULL);
//set additionalParticipant true
$values['params']['additionalParticipant'] = TRUE;
foreach ($additionalIDs as $pId => $cId) {
$amount = array();
//to change the status pending to completed
$additional = new CRM_Event_DAO_Participant();
$additional->id = $pId;
$additional->contact_id = $cId;
$additional->find(TRUE);
$additional->register_date = $this->_relatedObjects['participant']->register_date;
$additional->status_id = 1;
$additionalParticipantInfo = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Email', $additional->contact_id, 'email', 'contact_id');
//if additional participant dont have email
//use display name.
if (!$additionalParticipantInfo) {
$additionalParticipantInfo = CRM_Contact_BAO_Contact::displayName($additional->contact_id);
}
$amount[0] = array('label' => $additional->fee_level, 'amount' => $additional->fee_amount);
$primaryAmount[] = array('label' => $additional->fee_level . ' - ' . $additionalParticipantInfo, 'amount' => $additional->fee_amount);
$additional->save();
$additional->free();
$template->assign('amount', $amount);
CRM_Event_BAO_Event::sendMail($cId, $values, $pId, $isTest, $returnMessageText);
}
}
//build an array of custom profile and assigning it to template
$customProfile = CRM_Event_BAO_Event::buildCustomProfile($this->_relatedObjects['participant']->id, $values, NULL, $isTest);
if (count($customProfile)) {
$template->assign('customProfile', $customProfile);
}
// for primary contact
$values['params']['additionalParticipant'] = FALSE;
$template->assign('isPrimary', 1);
$template->assign('amount', $primaryAmount);
$template->assign('register_date', CRM_Utils_Date::isoToMysql($this->_relatedObjects['participant']->register_date));
if ($this->payment_instrument_id) {
$paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
$template->assign('paidBy', $paymentInstrument[$this->payment_instrument_id]);
}
// carry paylater, since we did not created billing,
// so need to pull email from primary location, CRM-4395
$values['params']['is_pay_later'] = $this->_relatedObjects['participant']->is_pay_later;
}
return $template;
}
示例8: checkRegistration
function checkRegistration($params)
{
$alreadyRegistered = false;
if (!CRM_Utils_Array::value('contact_id', $params)) {
return $alreadyRegistered;
}
require_once 'CRM/Event/PseudoConstant.php';
require_once 'CRM/Event/DAO/Participant.php';
$statusTypes = CRM_Event_PseudoConstant::participantStatus(null, "is_counted = 1");
$participant = new CRM_Event_DAO_Participant();
$participant->copyValues($params);
$participant->is_test = CRM_Utils_Array::value('is_test', $params, 0);
$participant->selectAdd();
$participant->selectAdd('status_id');
if ($participant->find(true) && array_key_exists($participant->status_id, $statusTypes)) {
$alreadyRegistered = true;
}
return $alreadyRegistered;
}
示例9: checkRegistration
/**
* @param $params
*
* @return bool
*/
static function checkRegistration($params)
{
$alreadyRegistered = FALSE;
if (empty($params['contact_id'])) {
return $alreadyRegistered;
}
$statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1');
$participant = new CRM_Event_DAO_Participant();
$participant->copyValues($params);
$participant->is_test = CRM_Utils_Array::value('is_test', $params, 0);
$participant->selectAdd();
$participant->selectAdd('status_id');
if ($participant->find(TRUE) && array_key_exists($participant->status_id, $statusTypes)) {
$alreadyRegistered = TRUE;
}
return $alreadyRegistered;
}
示例10: sendMail
//.........这里部分代码省略.........
}
}
require_once 'CRM/Utils/Address.php';
$template->assign('address', CRM_Utils_Address::format($input));
if ($input['component'] == 'event') {
require_once 'CRM/Core/OptionGroup.php';
$participant_role = CRM_Core_OptionGroup::values('participant_role');
$values['event']['participant_role'] = $participant_role[$participant->role_id];
$template->assign('event', $values['event']);
$template->assign('location', $values['location']);
$template->assign('customPre', $values['custom_pre_id']);
$template->assign('customPost', $values['custom_post_id']);
$isTest = false;
if ($participant->is_test) {
$isTest = true;
}
$values['params'] = array();
require_once "CRM/Event/BAO/Event.php";
//to get email of primary participant.
$primaryEmail = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Email', $participant->contact_id, 'email', 'contact_id');
$primaryAmount[] = array('label' => $participant->fee_level . ' - ' . $primaryEmail, 'amount' => $participant->fee_amount);
//build an array of cId/pId of participants
$additionalIDs = CRM_Event_BAO_Event::buildCustomProfile($participant->id, null, $ids['contact'], $isTest, true);
unset($additionalIDs[$participant->id]);
//send receipt to additional participant if exists
if (count($additionalIDs)) {
$template->assign('isPrimary', 0);
$template->assign('customProfile', null);
//set additionalParticipant true
$values['params']['additionalParticipant'] = true;
foreach ($additionalIDs as $pId => $cId) {
$amount = array();
//to change the status pending to completed
$additional = new CRM_Event_DAO_Participant();
$additional->id = $pId;
$additional->contact_id = $cId;
$additional->find(true);
$additional->register_date = $participant->register_date;
$additional->status_id = 1;
$additionalParticipantInfo = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Email', $additional->contact_id, 'email', 'contact_id');
//if additional participant dont have email
//use display name.
if (!$additionalParticipantInfo) {
require_once "CRM/Contact/BAO/Contact.php";
$additionalParticipantInfo = CRM_Contact_BAO_Contact::displayName($additional->contact_id);
}
$amount[0] = array('label' => $additional->fee_level, 'amount' => $additional->fee_amount);
$primaryAmount[] = array('label' => $additional->fee_level . ' - ' . $additionalParticipantInfo, 'amount' => $additional->fee_amount);
$additional->save();
$additional->free();
$template->assign('amount', $amount);
CRM_Event_BAO_Event::sendMail($cId, $values, $pId, $isTest, $returnMessageText);
}
}
//build an array of custom profile and assigning it to template
$customProfile = CRM_Event_BAO_Event::buildCustomProfile($participant->id, $values, null, $isTest);
if (count($customProfile)) {
$template->assign('customProfile', $customProfile);
}
// for primary contact
$values['params']['additionalParticipant'] = false;
$template->assign('isPrimary', 1);
$template->assign('amount', $primaryAmount);
$template->assign('register_date', CRM_Utils_Date::isoToMysql($participant->register_date));
if ($contribution->payment_instrument_id) {
require_once 'CRM/Contribute/PseudoConstant.php';
示例11: _civicrm_api3_deprecated_participant_formatted_param
/**
* take the input parameter list as specified in the data model and
* convert it into the same format that we use in QF and BAO object
*
* @param array $params
* Associative array of property name/value.
* pairs to insert in new contact.
* @param array $values
* The reformatted properties that we can use internally.
*
* @param array|bool $create Is the formatted Values array going to
* be used for CRM_vent_BAO_Participant:create()
*
* @return array|CRM_Error
*/
function _civicrm_api3_deprecated_participant_formatted_param($params, &$values, $create = FALSE)
{
$fields = CRM_Event_DAO_Participant::fields();
_civicrm_api3_store_values($fields, $params, $values);
require_once 'CRM/Core/OptionGroup.php';
$customFields = CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, NULL, NULL, FALSE, FALSE, FALSE);
foreach ($params as $key => $value) {
// ignore empty values or empty arrays etc
if (CRM_Utils_System::isNull($value)) {
continue;
}
// Handling Custom Data
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
$values[$key] = $value;
$type = $customFields[$customFieldID]['html_type'];
if ($type == 'CheckBox' || $type == 'Multi-Select') {
$mulValues = explode(',', $value);
$customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE);
$values[$key] = array();
foreach ($mulValues as $v1) {
foreach ($customOption as $customValueID => $customLabel) {
$customValue = $customLabel['value'];
if (strtolower(trim($customLabel['label'])) == strtolower(trim($v1)) || strtolower(trim($customValue)) == strtolower(trim($v1))) {
if ($type == 'CheckBox') {
$values[$key][$customValue] = 1;
} else {
$values[$key][] = $customValue;
}
}
}
}
} elseif ($type == 'Select' || $type == 'Radio') {
$customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE);
foreach ($customOption as $customFldID => $customValue) {
$val = CRM_Utils_Array::value('value', $customValue);
$label = CRM_Utils_Array::value('label', $customValue);
$label = strtolower($label);
$value = strtolower(trim($value));
if ($value == $label || $value == strtolower($val)) {
$values[$key] = $val;
}
}
}
}
switch ($key) {
case 'participant_contact_id':
if (!CRM_Utils_Rule::integer($value)) {
return civicrm_api3_create_error("contact_id not valid: {$value}");
}
$dao = new CRM_Core_DAO();
$qParams = array();
$svq = $dao->singleValueQuery("SELECT id FROM civicrm_contact WHERE id = {$value}", $qParams);
if (!$svq) {
return civicrm_api3_create_error("Invalid Contact ID: There is no contact record with contact_id = {$value}.");
}
$values['contact_id'] = $values['participant_contact_id'];
unset($values['participant_contact_id']);
break;
case 'participant_register_date':
if (!CRM_Utils_Rule::dateTime($value)) {
return civicrm_api3_create_error("{$key} not a valid date: {$value}");
}
break;
case 'event_title':
$id = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $value, 'id', 'title');
$values['event_id'] = $id;
break;
case 'event_id':
if (!CRM_Utils_Rule::integer($value)) {
return civicrm_api3_create_error("Event ID is not valid: {$value}");
}
$dao = new CRM_Core_DAO();
$qParams = array();
$svq = $dao->singleValueQuery("SELECT id FROM civicrm_event WHERE id = {$value}", $qParams);
if (!$svq) {
return civicrm_api3_create_error("Invalid Event ID: There is no event record with event_id = {$value}.");
}
break;
case 'participant_status_id':
if (!CRM_Utils_Rule::integer($value)) {
return civicrm_api3_create_error("Event Status ID is not valid: {$value}");
}
break;
case 'participant_status':
$status = CRM_Event_PseudoConstant::participantStatus();
//.........这里部分代码省略.........
示例12: isPrimaryParticipant
/**
* check for whether participant is primary or not
*
* @param $participantId
*
* @return true if participant is primary
* @access public
*/
static function isPrimaryParticipant($participantId)
{
$participant = new CRM_Event_DAO_Participant();
$participant->registered_by_id = $participantId;
if ($participant->find(TRUE)) {
return TRUE;
}
return FALSE;
}
示例13: deleteParticipant
/**
* Delete the record that are associated with this participation
*
* @param int $id id of the participation to delete
*
* @return void
* @access public
* @static
*/
static function deleteParticipant($id)
{
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
//delete activity record
require_once "CRM/Activity/BAO/Activity.php";
$params = array('source_record_id' => $id, 'activity_type_id' => 5);
// activity type id for event registration
CRM_Activity_BAO_Activity::deleteActivity($params);
// delete the participant payment record
// we need to do this since the cascaded constraints
// dont work with join tables
require_once 'CRM/Event/BAO/ParticipantPayment.php';
$p = array('participant_id' => $id);
CRM_Event_BAO_ParticipantPayment::deleteParticipantPayment($p);
// cleanup line items.
require_once 'CRM/Price/BAO/LineItem.php';
CRM_Price_BAO_LineItem::deleteLineItems($id, 'civicrm_participant');
$participant = new CRM_Event_DAO_Participant();
$participant->id = $id;
$participant->delete();
$transaction->commit();
// delete the recently created Activity
require_once 'CRM/Utils/Recent.php';
CRM_Utils_Recent::del($id);
return $participant;
}
示例14: isPrimaryParticipant
/**
* check for whether participant is primary or not
* @param $participantId
* @return true if participant is primary
* @access public
*/
static function isPrimaryParticipant($participantId)
{
$participant = new CRM_Event_DAO_Participant();
$participant->registered_by_id = $participantId;
if ($participant->find(true)) {
return true;
}
return false;
}
示例15: addParticipant
/**
* Process the participant.
*
* @param CRM_Core_Form $form
* @param int $contactID
*
* @return \CRM_Event_BAO_Participant
*/
public static function addParticipant(&$form, $contactID)
{
if (empty($form->_params)) {
return NULL;
}
$params = $form->_params;
$transaction = new CRM_Core_Transaction();
$groupName = 'participant_role';
$query = "\nSELECT v.label as label ,v.value as value\nFROM civicrm_option_value v,\n civicrm_option_group g\nWHERE v.option_group_id = g.id\n AND g.name = %1\n AND v.is_active = 1\n AND g.is_active = 1\n";
$p = array(1 => array($groupName, 'String'));
$dao = CRM_Core_DAO::executeQuery($query, $p);
if ($dao->fetch()) {
$roleID = $dao->value;
}
// handle register date CRM-4320
$registerDate = NULL;
if (!empty($form->_allowConfirmation) && $form->_participantId) {
$registerDate = $params['participant_register_date'];
} elseif (!empty($params['participant_register_date']) && is_array($params['participant_register_date']) && !empty($params['participant_register_date'])) {
$registerDate = CRM_Utils_Date::format($params['participant_register_date']);
}
$participantFields = CRM_Event_DAO_Participant::fields();
$participantParams = array('id' => CRM_Utils_Array::value('participant_id', $params), 'contact_id' => $contactID, 'event_id' => $form->_eventId ? $form->_eventId : $params['event_id'], 'status_id' => CRM_Utils_Array::value('participant_status', $params, 1), 'role_id' => CRM_Utils_Array::value('participant_role_id', $params, $roleID), 'register_date' => $registerDate ? $registerDate : date('YmdHis'), 'source' => CRM_Utils_String::ellipsify(isset($params['participant_source']) ? CRM_Utils_Array::value('participant_source', $params) : CRM_Utils_Array::value('description', $params), $participantFields['participant_source']['maxlength']), 'fee_level' => CRM_Utils_Array::value('amount_level', $params), 'is_pay_later' => CRM_Utils_Array::value('is_pay_later', $params, 0), 'fee_amount' => CRM_Utils_Array::value('fee_amount', $params), 'registered_by_id' => CRM_Utils_Array::value('registered_by_id', $params), 'discount_id' => CRM_Utils_Array::value('discount_id', $params), 'fee_currency' => CRM_Utils_Array::value('currencyID', $params), 'campaign_id' => CRM_Utils_Array::value('campaign_id', $params));
if ($form->_action & CRM_Core_Action::PREVIEW || CRM_Utils_Array::value('mode', $params) == 'test') {
$participantParams['is_test'] = 1;
} else {
$participantParams['is_test'] = 0;
}
if (!empty($form->_params['note'])) {
$participantParams['note'] = $form->_params['note'];
} elseif (!empty($form->_params['participant_note'])) {
$participantParams['note'] = $form->_params['participant_note'];
}
// reuse id if one already exists for this one (can happen
// with back button being hit etc)
if (!$participantParams['id'] && !empty($params['contributionID'])) {
$pID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $params['contributionID'], 'participant_id', 'contribution_id');
$participantParams['id'] = $pID;
}
$participantParams['discount_id'] = CRM_Core_BAO_Discount::findSet($form->_eventId, 'civicrm_event');
if (!$participantParams['discount_id']) {
$participantParams['discount_id'] = "null";
}
$participant = CRM_Event_BAO_Participant::create($participantParams);
$transaction->commit();
return $participant;
}