当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Event_BAO_Participant::save方法代码示例

本文整理汇总了PHP中CRM_Event_BAO_Participant::save方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Event_BAO_Participant::save方法的具体用法?PHP CRM_Event_BAO_Participant::save怎么用?PHP CRM_Event_BAO_Participant::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Event_BAO_Participant的用法示例。


在下文中一共展示了CRM_Event_BAO_Participant::save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:64,代码来源:Payment.php

示例2: key

 /**
  * 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.
  *
  * @return CRM_Event_BAO_Participant
  */
 public static function &add(&$params)
 {
     if (!empty($params['id'])) {
         CRM_Utils_Hook::pre('edit', 'Participant', $params['id'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Participant', NULL, $params);
     }
     // converting dates to mysql format
     if (!empty($params['register_date'])) {
         $params['register_date'] = CRM_Utils_Date::isoToMysql($params['register_date']);
     }
     if (!empty($params['participant_fee_amount'])) {
         $params['participant_fee_amount'] = CRM_Utils_Rule::cleanMoney($params['participant_fee_amount']);
     }
     if (!empty($params['fee_amount'])) {
         $params['fee_amount'] = CRM_Utils_Rule::cleanMoney($params['fee_amount']);
     }
     // ensure that role ids are encoded as a string
     if (isset($params['role_id']) && is_array($params['role_id'])) {
         if (in_array(key($params['role_id']), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
             $op = key($params['role_id']);
             $params['role_id'] = $params['role_id'][$op];
         } else {
             $params['role_id'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $params['role_id']);
         }
     }
     $participantBAO = new CRM_Event_BAO_Participant();
     if (!empty($params['id'])) {
         $participantBAO->id = CRM_Utils_Array::value('id', $params);
         $participantBAO->find(TRUE);
         $participantBAO->register_date = CRM_Utils_Date::isoToMysql($participantBAO->register_date);
     }
     $participantBAO->copyValues($params);
     //CRM-6910
     //1. If currency present, it should be valid one.
     //2. We should have currency when amount is not null.
     $currency = $participantBAO->fee_currency;
     if ($currency || !CRM_Utils_System::isNull($participantBAO->fee_amount)) {
         if (!CRM_Utils_Rule::currencyCode($currency)) {
             $config = CRM_Core_Config::singleton();
             $currency = $config->defaultCurrency;
         }
     }
     $participantBAO->fee_currency = $currency;
     $participantBAO->save();
     $session = CRM_Core_Session::singleton();
     CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush();
     if (!empty($params['id'])) {
         CRM_Utils_Hook::post('edit', 'Participant', $participantBAO->id, $participantBAO);
     } else {
         CRM_Utils_Hook::post('create', 'Participant', $participantBAO->id, $participantBAO);
     }
     return $participantBAO;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:66,代码来源:Participant.php

示例3:

 /**
  * 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']);
     }
     if (CRM_Utils_Array::value('participant_fee_amount', $params)) {
         $params['fee_amount'] = CRM_Utils_Rule::cleanMoney($params['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);
     //CRM-6910
     //1. If currency present, it should be valid one.
     //2. We should have currency when amount is not null.
     require_once 'CRM/Utils/Rule.php';
     $currency = $participantBAO->fee_currency;
     if ($currency || !CRM_Utils_System::isNull($participantBAO->fee_amount)) {
         if (!CRM_Utils_Rule::currencyCode($currency)) {
             $config = CRM_Core_Config::singleton();
             $currency = $config->defaultCurrency;
         }
     }
     $participantBAO->fee_currency = $currency;
     $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;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:63,代码来源:Participant.php


注:本文中的CRM_Event_BAO_Participant::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。