예제 #1
0
 /**
  * Set variables up before form is built.
  *
  * @return void
  */
 public function preProcess()
 {
     $values = $ids = array();
     $participantID = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     $params = array('id' => $participantID);
     CRM_Event_BAO_Participant::getValues($params, $values, $ids);
     if (empty($values)) {
         CRM_Core_Error::statusBounce(ts('The requested participant record does not exist (possibly the record was deleted).'));
     }
     CRM_Event_BAO_Participant::resolveDefaults($values[$participantID]);
     if (!empty($values[$participantID]['fee_level'])) {
         CRM_Event_BAO_Participant::fixEventLevel($values[$participantID]['fee_level']);
     }
     $this->assign('contactId', $contactID);
     $this->assign('participantId', $participantID);
     $paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $participantID, 'id', 'participant_id');
     $this->assign('hasPayment', $paymentId);
     if ($parentParticipantId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $participantID, 'registered_by_id')) {
         $parentHasPayment = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $parentParticipantId, 'id', 'participant_id');
         $this->assign('parentHasPayment', $parentHasPayment);
     }
     $statusId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $participantID, 'status_id', 'id');
     $status = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantStatusType', $statusId, 'name', 'id');
     $status = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantStatusType', $statusId, 'name', 'id');
     if ($status == 'Transferred') {
         $transferId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $participantID, 'transferred_to_contact_id', 'id');
         $pid = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $transferId, 'id', 'contact_id');
         $transferName = current(CRM_Contact_BAO_Contact::getContactDetails($transferId));
         $this->assign('pid', $pid);
         $this->assign('transferId', $transferId);
         $this->assign('transferName', $transferName);
     }
     $participantStatuses = CRM_Event_PseudoConstant::participantStatus();
     if ($values[$participantID]['is_test']) {
         $values[$participantID]['status'] .= ' (test) ';
     }
     // Get Note
     $noteValue = CRM_Core_BAO_Note::getNote($participantID, 'civicrm_participant');
     $values[$participantID]['note'] = array_values($noteValue);
     // Get Line Items
     $lineItem = CRM_Price_BAO_LineItem::getLineItems($participantID);
     if (!CRM_Utils_System::isNull($lineItem)) {
         $values[$participantID]['lineItem'][] = $lineItem;
     }
     $values[$participantID]['totalAmount'] = CRM_Utils_Array::value('fee_amount', $values[$participantID]);
     // Get registered_by contact ID and display_name if participant was registered by someone else (CRM-4859)
     if (!empty($values[$participantID]['participant_registered_by_id'])) {
         $values[$participantID]['registered_by_contact_id'] = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $values[$participantID]['participant_registered_by_id'], 'contact_id', 'id');
         $values[$participantID]['registered_by_display_name'] = CRM_Contact_BAO_Contact::displayName($values[$participantID]['registered_by_contact_id']);
     }
     // Check if this is a primaryParticipant (registered for others) and retrieve additional participants if true  (CRM-4859)
     if (CRM_Event_BAO_Participant::isPrimaryParticipant($participantID)) {
         $values[$participantID]['additionalParticipants'] = CRM_Event_BAO_Participant::getAdditionalParticipants($participantID);
     }
     // get the option value for custom data type
     $roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name');
     $eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name');
     $eventTypeCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventType', 'name');
     $allRoleIDs = explode(CRM_Core_DAO::VALUE_SEPARATOR, $values[$participantID]['role_id']);
     $groupTree = array();
     $finalTree = array();
     foreach ($allRoleIDs as $k => $v) {
         $roleGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, NULL, $v, $roleCustomDataTypeID);
         $eventGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, NULL, $values[$participantID]['event_id'], $eventNameCustomDataTypeID);
         $eventTypeID = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $values[$participantID]['event_id'], 'event_type_id', 'id');
         $eventTypeGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, NULL, $eventTypeID, $eventTypeCustomDataTypeID);
         $groupTree = CRM_Utils_Array::crmArrayMerge($roleGroupTree, $eventGroupTree);
         $groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, $eventTypeGroupTree);
         $groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID));
         foreach ($groupTree as $treeId => $trees) {
             $finalTree[$treeId] = $trees;
         }
     }
     CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $finalTree, FALSE, NULL, NULL, NULL, $participantID);
     $eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $values[$participantID]['event_id'], 'title');
     //CRM-7150, show event name on participant view even if the event is disabled
     if (empty($values[$participantID]['event'])) {
         $values[$participantID]['event'] = $eventTitle;
     }
     //do check for campaigns
     if ($campaignId = CRM_Utils_Array::value('campaign_id', $values[$participantID])) {
         $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
         $values[$participantID]['campaign'] = $campaigns[$campaignId];
     }
     $this->assign($values[$participantID]);
     // add viewed participant to recent items list
     $url = CRM_Utils_System::url('civicrm/contact/view/participant', "action=view&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
     $recentOther = array();
     if (CRM_Core_Permission::check('edit event participants')) {
         $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/participant', "action=update&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
     }
     if (CRM_Core_Permission::check('delete in CiviEvent')) {
         $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/participant', "action=delete&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
     }
     $participantRoles = CRM_Event_PseudoConstant::participantRole();
     $displayName = CRM_Contact_BAO_Contact::displayName($values[$participantID]['contact_id']);
     $participantCount = array();
     $invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
     $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
     $totalTaxAmount = 0;
     foreach ($lineItem as $k => $v) {
         if (CRM_Utils_Array::value('participant_count', $lineItem[$k]) > 0) {
             $participantCount[] = $lineItem[$k]['participant_count'];
         }
         $totalTaxAmount = $v['tax_amount'] + $totalTaxAmount;
     }
     if ($invoicing) {
         $this->assign('totalTaxAmount', $totalTaxAmount);
     }
     if ($participantCount) {
         $this->assign('pricesetFieldsCount', $participantCount);
     }
     $this->assign('displayName', $displayName);
     // omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container
     CRM_Utils_System::setTitle(ts('View Event Registration for') . ' ' . $displayName);
     $roleId = CRM_Utils_Array::value('role_id', $values[$participantID]);
     $title = $displayName . ' (' . CRM_Utils_Array::value($roleId, $participantRoles) . ' - ' . $eventTitle . ')';
     $sep = CRM_Core_DAO::VALUE_SEPARATOR;
     $viewRoles = array();
     foreach (explode($sep, $values[$participantID]['role_id']) as $k => $v) {
         $viewRoles[] = $participantRoles[$v];
     }
     $values[$participantID]['role_id'] = implode(', ', $viewRoles);
     $this->assign('role', $values[$participantID]['role_id']);
     // add Participant to Recent Items
     CRM_Utils_Recent::add($title, $url, $values[$participantID]['id'], 'Participant', $values[$participantID]['contact_id'], NULL, $recentOther);
 }
예제 #2
0
 /**
  * This function sets the default values for the form in edit/view mode
  * the default values are retrieved from the database
  * 
  * @access public
  * @return None
  */
 public function setDefaultValues()
 {
     if ($this->_showFeeBlock) {
         return CRM_Event_Form_EventFees::setDefaultValues($this);
     }
     if ($this->_cdType) {
         return CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     $defaults = array();
     if ($this->_action & CRM_Core_Action::DELETE) {
         return $defaults;
     }
     if ($this->_id) {
         $ids = array();
         $params = array('id' => $this->_id);
         require_once "CRM/Event/BAO/Participant.php";
         CRM_Event_BAO_Participant::getValues($params, $defaults, $ids);
         $sep = CRM_Core_DAO::VALUE_SEPARATOR;
         if ($defaults[$this->_id]['role_id']) {
             foreach (explode($sep, $defaults[$this->_id]['role_id']) as $k => $v) {
                 $defaults[$this->_id]["role_id[{$v}]"] = 1;
             }
             unset($defaults[$this->_id]['role_id']);
         }
         $this->_contactId = $defaults[$this->_id]['contact_id'];
         $this->_statusId = $defaults[$this->_id]['participant_status_id'];
         //set defaults for note
         $noteDetails = CRM_Core_BAO_Note::getNote($this->_id, 'civicrm_participant');
         $defaults[$this->_id]['note'] = array_pop($noteDetails);
         // Check if this is a primaryParticipant (registered for others) and retrieve additional participants if true  (CRM-4859)
         if (CRM_Event_BAO_Participant::isPrimaryParticipant($this->_id)) {
             $this->assign('additionalParticipants', CRM_Event_BAO_Participant::getAdditionalParticipants($this->_id));
         }
         // Get registered_by contact ID and display_name if participant was registered by someone else (CRM-4859)
         if (CRM_Utils_Array::value('participant_registered_by_id', $defaults[$this->_id])) {
             $registered_by_contact_id = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $defaults[$this->_id]['participant_registered_by_id'], 'contact_id', 'id');
             $this->assign('participant_registered_by_id', $defaults[$this->_id]['participant_registered_by_id']);
             $this->assign('registered_by_contact_id', $registered_by_contact_id);
             require_once 'CRM/Contact/BAO/Contact.php';
             $this->assign('registered_by_display_name', CRM_Contact_BAO_Contact::displayName($registered_by_contact_id));
         }
     }
     if ($this->_action & (CRM_Core_Action::VIEW | CRM_Core_Action::BROWSE)) {
         $inactiveNeeded = true;
         $viewMode = true;
     } else {
         $viewMode = false;
         $inactiveNeeded = false;
     }
     //setting default register date
     if ($this->_action == CRM_Core_Action::ADD) {
         $statuses = array_flip($this->_participantStatuses);
         $defaults[$this->_id]['status_id'] = CRM_Utils_Array::value(ts('Registered'), $statuses);
         if (CRM_Utils_Array::value('event_id', $defaults[$this->_id])) {
             $contributionTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $defaults[$this->_id]['event_id'], 'contribution_type_id');
             if ($contributionTypeId) {
                 $defaults[$this->_id]['contribution_type_id'] = $contributionTypeId;
             }
         }
         if ($this->_mode) {
             $fields["email-{$this->_bltID}"] = 1;
             $fields["email-Primary"] = 1;
             if ($this->_contactId) {
                 require_once "CRM/Core/BAO/UFGroup.php";
                 CRM_Core_BAO_UFGroup::setProfileDefaults($this->_contactId, $fields, $defaults);
             }
             if (empty($defaults["email-{$this->_bltID}"]) && !empty($defaults["email-Primary"])) {
                 $defaults[$this->_id]["email-{$this->_bltID}"] = $defaults["email-Primary"];
             }
         }
         $submittedRole = $this->getElementValue('role_id');
         if (CRM_Utils_Array::value(0, $submittedRole)) {
             $roleID = $submittedRole[0];
         }
         $submittedEvent = $this->getElementValue('event_id');
         if ($submittedEvent[0]) {
             $eventID = $submittedEvent[0];
         }
     } else {
         $defaults[$this->_id]['record_contribution'] = 0;
         if ($defaults[$this->_id]['participant_is_pay_later']) {
             $this->assign('participant_is_pay_later', true);
         }
         $this->assign('participant_status_id', $defaults[$this->_id]['participant_status_id']);
         $roleID = $defaults[$this->_id]['participant_role_id'];
         $eventID = $defaults[$this->_id]['event_id'];
         $this->_eventTypeId = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $eventID, 'event_type_id', 'id');
         $this->_discountId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'discount_id');
         if ($this->_discountId) {
             $this->set('discountId', $this->_discountId);
         }
     }
     list($defaults[$this->_id]['register_date'], $defaults[$this->_id]['register_date_time']) = CRM_Utils_Date::setDateDefaults(CRM_Utils_Array::value('register_date', $defaults[$this->_id]), 'activityDateTime');
     //assign event and role id, this is needed for Custom data building
     $sep = CRM_Core_DAO::VALUE_SEPARATOR;
     if (CRM_Utils_Array::value('participant_role_id', $defaults[$this->_id])) {
         $roleIDs = explode($sep, $defaults[$this->_id]['participant_role_id']);
     }
     if (isset($roleIDs)) {
         $this->assign('roleID', $roleIDs);
     }
     if (isset($_POST['event_id'])) {
         $eventID = $_POST['event_id'];
         if ($eventID) {
             $this->_eventTypeId = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $eventID, 'event_type_id', 'id');
         }
     }
     if (isset($eventID)) {
         $this->assign('eventID', $eventID);
         $this->set('eventId', $eventID);
     }
     if (isset($this->_eventTypeId)) {
         $this->assign('eventTypeID', $this->_eventTypeId);
     }
     $this->assign('event_is_test', CRM_Utils_Array::value('event_is_test', $defaults[$this->_id]));
     return $defaults[$this->_id];
 }
예제 #3
0
 /**
  * This function sets the default values for the form in edit/view mode
  * the default values are retrieved from the database
  *
  *
  * @return void
  */
 public function setDefaultValues()
 {
     if ($this->_showFeeBlock) {
         return CRM_Event_Form_EventFees::setDefaultValues($this);
     }
     $defaults = array();
     if ($this->_action & CRM_Core_Action::DELETE) {
         return $defaults;
     }
     if ($this->_id) {
         $ids = array();
         $params = array('id' => $this->_id);
         CRM_Event_BAO_Participant::getValues($params, $defaults, $ids);
         $sep = CRM_Core_DAO::VALUE_SEPARATOR;
         if ($defaults[$this->_id]['role_id']) {
             $roleIDs = explode($sep, $defaults[$this->_id]['role_id']);
         }
         $this->_contactId = $defaults[$this->_id]['contact_id'];
         $this->_statusId = $defaults[$this->_id]['participant_status_id'];
         //set defaults for note
         $noteDetails = CRM_Core_BAO_Note::getNote($this->_id, 'civicrm_participant');
         $defaults[$this->_id]['note'] = array_pop($noteDetails);
         // Check if this is a primaryParticipant (registered for others) and retrieve additional participants if true  (CRM-4859)
         if (CRM_Event_BAO_Participant::isPrimaryParticipant($this->_id)) {
             $this->assign('additionalParticipants', CRM_Event_BAO_Participant::getAdditionalParticipants($this->_id));
         }
         // Get registered_by contact ID and display_name if participant was registered by someone else (CRM-4859)
         if (!empty($defaults[$this->_id]['participant_registered_by_id'])) {
             $registered_by_contact_id = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $defaults[$this->_id]['participant_registered_by_id'], 'contact_id', 'id');
             $this->assign('participant_registered_by_id', $defaults[$this->_id]['participant_registered_by_id']);
             $this->assign('registered_by_contact_id', $registered_by_contact_id);
             $this->assign('registered_by_display_name', CRM_Contact_BAO_Contact::displayName($registered_by_contact_id));
         }
     }
     if ($this->_action & (CRM_Core_Action::VIEW | CRM_Core_Action::BROWSE)) {
         $inactiveNeeded = TRUE;
         $viewMode = TRUE;
     } else {
         $viewMode = FALSE;
         $inactiveNeeded = FALSE;
     }
     //setting default register date
     if ($this->_action == CRM_Core_Action::ADD) {
         $statuses = array_flip($this->_participantStatuses);
         $defaults[$this->_id]['status_id'] = CRM_Utils_Array::value(ts('Registered'), $statuses);
         if (!empty($defaults[$this->_id]['event_id'])) {
             $contributionTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $defaults[$this->_id]['event_id'], 'financial_type_id');
             if ($contributionTypeId) {
                 $defaults[$this->_id]['financial_type_id'] = $contributionTypeId;
             }
         }
         if ($this->_mode) {
             $fields["email-{$this->_bltID}"] = 1;
             $fields['email-Primary'] = 1;
             if ($this->_contactId) {
                 CRM_Core_BAO_UFGroup::setProfileDefaults($this->_contactId, $fields, $defaults);
             }
             if (empty($defaults["email-{$this->_bltID}"]) && !empty($defaults['email-Primary'])) {
                 $defaults[$this->_id]["email-{$this->_bltID}"] = $defaults['email-Primary'];
             }
         }
         $submittedRole = $this->getElementValue('role_id');
         if (!empty($submittedRole[0])) {
             $roleID = $submittedRole[0];
         }
         $submittedEvent = $this->getElementValue('event_id');
         if (!empty($submittedEvent[0])) {
             $eventID = $submittedEvent[0];
         }
     } else {
         $defaults[$this->_id]['record_contribution'] = 0;
         if ($defaults[$this->_id]['participant_is_pay_later']) {
             $this->assign('participant_is_pay_later', TRUE);
         }
         $this->assign('participant_status_id', $defaults[$this->_id]['participant_status_id']);
         $eventID = $defaults[$this->_id]['event_id'];
         $this->_eventTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventID, 'event_type_id', 'id');
         $this->_discountId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'discount_id');
         if ($this->_discountId) {
             $this->set('discountId', $this->_discountId);
         }
     }
     list($defaults[$this->_id]['register_date'], $defaults[$this->_id]['register_date_time']) = CRM_Utils_Date::setDateDefaults(CRM_Utils_Array::value('register_date', $defaults[$this->_id]), 'activityDateTime');
     //assign event and role id, this is needed for Custom data building
     $sep = CRM_Core_DAO::VALUE_SEPARATOR;
     if (!empty($defaults[$this->_id]['participant_role_id'])) {
         $roleIDs = explode($sep, $defaults[$this->_id]['participant_role_id']);
     }
     if (isset($_POST['event_id'])) {
         $eventID = $_POST['event_id'];
     }
     if ($this->_eID) {
         $eventID = $this->_eID;
         //@todo - rationalise the $this->_eID with $POST['event_id'],  $this->_eid is set when eid=x is in the url
         $roleID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_eID, 'default_role_id');
         if (empty($roleIDs)) {
             $roleIDs = (array) ($defaults[$this->_id]['participant_role_id'] = $roleID);
         }
         $defaults[$this->_id]['event_id'] = $eventID;
     }
     if (!empty($eventID)) {
         $this->_eventTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventID, 'event_type_id', 'id');
     }
     //these should take precedence so we state them last
     $urlRoleIDS = CRM_Utils_Request::retrieve('roles', 'String');
     if ($urlRoleIDS) {
         $roleIDs = explode(',', $urlRoleIDS);
     }
     if (isset($roleIDs)) {
         $defaults[$this->_id]['role_id'] = implode(',', $roleIDs);
     }
     if (isset($eventID)) {
         $this->assign('eventID', $eventID);
         $this->set('eventId', $eventID);
     }
     if (isset($this->_eventTypeId)) {
         $this->assign('eventTypeID', $this->_eventTypeId);
     }
     $this->assign('event_is_test', CRM_Utils_Array::value('event_is_test', $defaults[$this->_id]));
     return $defaults[$this->_id];
 }
예제 #4
0
 /**  
  * Function to set variables up before form is built  
  *                                                            
  * @return void  
  * @access public  
  */
 public function preProcess()
 {
     require_once 'CRM/Event/BAO/Participant.php';
     require_once 'CRM/Core/DAO.php';
     $values = $ids = array();
     $participantID = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
     $contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, true);
     $params = array('id' => $participantID);
     CRM_Event_BAO_Participant::getValues($params, $values, $ids);
     if (empty($values)) {
         require_once 'CRM/Core/Error.php';
         CRM_Core_Error::statusBounce(ts('The requested participant record does not exist (possibly the record was deleted).'));
     }
     CRM_Event_BAO_Participant::resolveDefaults($values[$participantID]);
     if (CRM_Utils_Array::value('fee_level', $values[$participantID])) {
         CRM_Event_BAO_Participant::fixEventLevel($values[$participantID]['fee_level']);
     }
     if ($values[$participantID]['is_test']) {
         $values[$participantID]['status'] .= ' (test) ';
     }
     // Get Note
     $noteValue = CRM_Core_BAO_Note::getNote($participantID, 'civicrm_participant');
     $values[$participantID]['note'] = array_values($noteValue);
     require_once 'CRM/Price/BAO/LineItem.php';
     // Get Line Items
     $lineItem = CRM_Price_BAO_LineItem::getLineItems($participantID);
     if (!CRM_Utils_System::isNull($lineItem)) {
         $values[$participantID]['lineItem'][] = $lineItem;
     }
     $values[$participantID]['totalAmount'] = CRM_Utils_Array::value('fee_amount', $values[$participantID]);
     // Get registered_by contact ID and display_name if participant was registered by someone else (CRM-4859)
     if (CRM_Utils_Array::value('participant_registered_by_id', $values[$participantID])) {
         $values[$participantID]['registered_by_contact_id'] = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $values[$participantID]['participant_registered_by_id'], 'contact_id', 'id');
         require_once 'CRM/Contact/BAO/Contact.php';
         $values[$participantID]['registered_by_display_name'] = CRM_Contact_BAO_Contact::displayName($values[$participantID]['registered_by_contact_id']);
     }
     // Check if this is a primaryParticipant (registered for others) and retrieve additional participants if true  (CRM-4859)
     if (CRM_Event_BAO_Participant::isPrimaryParticipant($participantID)) {
         $values[$participantID]['additionalParticipants'] = CRM_Event_BAO_Participant::getAdditionalParticipants($participantID);
     }
     // get the option value for custom data type
     $roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name');
     $eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name');
     $eventTypeCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventType', 'name');
     $allRoleIDs = explode(CRM_Core_DAO::VALUE_SEPARATOR, $values[$participantID]['role_id']);
     $groupTree = array();
     $finalTree = array();
     foreach ($allRoleIDs as $k => $v) {
         $roleGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, null, $v, $roleCustomDataTypeID);
         $eventGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, null, $values[$participantID]['event_id'], $eventNameCustomDataTypeID);
         $eventTypeID = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $values[$participantID]['event_id'], 'event_type_id', 'id');
         $eventTypeGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, null, $eventTypeID, $eventTypeCustomDataTypeID);
         $groupTree = CRM_Utils_Array::crmArrayMerge($roleGroupTree, $eventGroupTree);
         $groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, $eventTypeGroupTree);
         $groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID));
         foreach ($groupTree as $treeId => $trees) {
             $finalTree[$treeId] = $trees;
         }
     }
     CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $finalTree);
     $eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $values[$participantID]['event_id'], 'title');
     //CRM-7150, show event name on participant view even if the event is disabled
     if (!CRM_Utils_Array::value('event', $values[$participantID])) {
         $values[$participantID]['event'] = $eventTitle;
     }
     $this->assign($values[$participantID]);
     // add viewed participant to recent items list
     require_once 'CRM/Utils/Recent.php';
     require_once 'CRM/Contact/BAO/Contact.php';
     $url = CRM_Utils_System::url('civicrm/contact/view/participant', "action=view&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
     $recentOther = array();
     if (CRM_Core_Permission::check('edit event participants')) {
         $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/participant', "action=update&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
     }
     if (CRM_Core_Permission::check('delete in CiviEvent')) {
         $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/participant', "action=delete&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
     }
     $participantRoles = CRM_Event_PseudoConstant::participantRole();
     $displayName = CRM_Contact_BAO_Contact::displayName($contactID);
     $participantCount = array();
     foreach ($lineItem as $k => $v) {
         if (CRM_Utils_Array::value('participant_count', $lineItem[$k]) > 0) {
             $participantCount[] = $lineItem['participant_count'];
         }
     }
     if ($participantCount) {
         $this->assign('pricesetFieldsCount', $participantCount);
     }
     $this->assign('displayName', $displayName);
     $title = $displayName . ' (' . $participantRoles[$values[$participantID]['role_id']] . ' - ' . $eventTitle . ')';
     require_once 'CRM/Core/DAO.php';
     $sep = CRM_Core_DAO::VALUE_SEPARATOR;
     $viewRoles = array();
     foreach (explode($sep, $values[$participantID]['role_id']) as $k => $v) {
         $viewRoles[] = $participantRoles[$v];
     }
     $values[$participantID]['role_id'] = implode(', ', $viewRoles);
     $this->assign('role', $values[$participantID]['role_id']);
     // add Participant to Recent Items
     CRM_Utils_Recent::add($title, $url, $values[$participantID]['id'], 'Participant', $values[$participantID]['contact_id'], null, $recentOther);
 }