本文整理汇总了PHP中CRM_Event_BAO_Participant::copyValues方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Event_BAO_Participant::copyValues方法的具体用法?PHP CRM_Event_BAO_Participant::copyValues怎么用?PHP CRM_Event_BAO_Participant::copyValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Event_BAO_Participant
的用法示例。
在下文中一共展示了CRM_Event_BAO_Participant::copyValues方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerParticipant
/**
* Register a participant.
*
* @param array $params
* @param CRM_Event_BAO_Participant $participant
* @param CRM_Event_BAO_Event $event
*
* @return mixed
*/
public function registerParticipant($params, &$participant, $event)
{
$transaction = new CRM_Core_Transaction();
// handle register date CRM-4320
$registerDate = date('YmdHis');
$participantParams = array('id' => $participant->id, 'event_id' => $event->id, 'register_date' => $registerDate, 'source' => CRM_Utils_Array::value('participant_source', $params, $this->description), 'is_pay_later' => $this->is_pay_later, 'fee_amount' => CRM_Utils_Array::value('amount', $params, 0), 'fee_currency' => CRM_Utils_Array::value('currencyID', $params));
if ($participant->must_wait) {
$participant_status = 'On waitlist';
} elseif (CRM_Utils_Array::value('is_pay_later', $params, FALSE)) {
$participant_status = 'Pending from pay later';
} else {
$participant_status = 'Registered';
}
$participant_statuses = CRM_Event_PseudoConstant::participantStatus();
$participantParams['status_id'] = array_search($participant_status, $participant_statuses);
$participant_status_label = CRM_Utils_Array::value($participantParams['status_id'], CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'));
$participantParams['participant_status'] = $participant_status_label;
$this->assign('isOnWaitlist', $participant->must_wait);
if ($this->_action & CRM_Core_Action::PREVIEW || CRM_Utils_Array::value('mode', $params) == 'test') {
$participantParams['is_test'] = 1;
} else {
$participantParams['is_test'] = 0;
}
if (self::is_administrator()) {
if (!empty($params['note'])) {
$note_params = array('participant_id' => $participant->id, 'contact_id' => self::getContactID(), 'note' => $params['note']);
CRM_Event_BAO_Participant::update_note($note_params);
}
}
$participant->copyValues($participantParams);
$participant->save();
if (!empty($params['contributionID'])) {
$payment_params = array('participant_id' => $participant->id, 'contribution_id' => $params['contributionID']);
$ids = array();
CRM_Event_BAO_ParticipantPayment::create($payment_params, $ids);
}
$transaction->commit();
$event_values = array();
CRM_Core_DAO::storeValues($event, $event_values);
$location = array();
if (CRM_Utils_Array::value('is_show_location', $event_values) == 1) {
$locationParams = array('entity_id' => $participant->event_id, 'entity_table' => 'civicrm_event');
$location = CRM_Core_BAO_Location::getValues($locationParams, TRUE);
CRM_Core_BAO_Address::fixAddress($location['address'][1]);
}
list($pre_id, $post_id) = CRM_Event_Cart_Form_MerParticipant::get_profile_groups($participant->event_id);
$payer_values = array('email' => '', 'name' => '');
if ($this->payer_contact_id) {
$payer_contact_details = CRM_Contact_BAO_Contact::getContactDetails($this->payer_contact_id);
$payer_values = array('email' => $payer_contact_details[1], 'name' => $payer_contact_details[0]);
}
$values = array('params' => array($participant->id => $participantParams), 'event' => $event_values, 'location' => $location, 'custom_pre_id' => $pre_id, 'custom_post_id' => $post_id, 'payer' => $payer_values);
CRM_Event_BAO_Event::sendMail($participant->contact_id, $values, $participant->id);
return $participant;
}
示例2: find_all_by_params
public static function find_all_by_params($params)
{
$participant = new CRM_Event_BAO_Participant();
$participant->copyValues($params);
$result = array();
if ($participant->find()) {
while ($participant->fetch()) {
$result[] = new CRM_Event_Cart_BAO_MerParticipant(clone $participant);
}
}
return $result;
}
示例3: getValues
/**
* Given the list of params in the params array, fetch the object
* and store the values in the values array
*
* @param array $params
* Input parameters to find object.
* @param array $values
* Output values of the object.
*
* @param $ids
*
* @return CRM_Event_BAO_Participant|null the found object or null
*/
public static function getValues(&$params, &$values, &$ids)
{
if (empty($params)) {
return NULL;
}
$participant = new CRM_Event_BAO_Participant();
$participant->copyValues($params);
$participant->find();
$participants = array();
while ($participant->fetch()) {
$ids['participant'] = $participant->id;
CRM_Core_DAO::storeValues($participant, $values[$participant->id]);
$participants[$participant->id] = $participant;
}
return $participants;
}
示例4:
/**
* takes an associative array and creates a participant object
*
* the function extract all the params it needs to initialize the create a
* participant object. the params array could contain additional unused name/value
* pairs
*
* @param array $params (reference ) an assoc array of name/value pairs
* @param array $ids the array that holds all the db ids
*
* @return object CRM_Event_BAO_Participant object
* @access public
* @static
*/
static function &add(&$params)
{
require_once 'CRM/Utils/Hook.php';
if (CRM_Utils_Array::value('id', $params)) {
CRM_Utils_Hook::pre('edit', 'Participant', $params['id'], $params);
} else {
CRM_Utils_Hook::pre('create', 'Participant', null, $params);
}
// converting dates to mysql format
if (CRM_Utils_Array::value('register_date', $params)) {
$params['register_date'] = CRM_Utils_Date::isoToMysql($params['register_date']);
}
if (CRM_Utils_Array::value('participant_fee_amount', $params)) {
$params['participant_fee_amount'] = CRM_Utils_Rule::cleanMoney($params['participant_fee_amount']);
}
$participantBAO = new CRM_Event_BAO_Participant();
if (CRM_Utils_Array::value('id', $params)) {
$participantBAO->id = CRM_Utils_Array::value('id', $params);
$participantBAO->find(true);
$participantBAO->register_date = CRM_Utils_Date::isoToMysql($participantBAO->register_date);
}
$participantBAO->copyValues($params);
//make sure we have currency when amount is not null CRM-4453
require_once 'CRM/Utils/Rule.php';
if (!CRM_Utils_System::isNull($participantBAO->fee_amount) && !CRM_Utils_Rule::currencyCode($participantBAO->fee_currency)) {
require_once 'CRM/Core/Config.php';
$config =& CRM_Core_Config::singleton();
$participantBAO->fee_currency = $config->defaultCurrency;
}
$participantBAO->save();
$session =& CRM_Core_Session::singleton();
// reset the group contact cache for this group
require_once 'CRM/Contact/BAO/GroupContactCache.php';
CRM_Contact_BAO_GroupContactCache::remove();
if (CRM_Utils_Array::value('id', $params)) {
CRM_Utils_Hook::post('edit', 'Participant', $participantBAO->id, $participantBAO);
} else {
CRM_Utils_Hook::post('create', 'Participant', $participantBAO->id, $participantBAO);
}
return $participantBAO;
}