本文整理汇总了PHP中CRM_Event_BAO_Event::add方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Event_BAO_Event::add方法的具体用法?PHP CRM_Event_BAO_Event::add怎么用?PHP CRM_Event_BAO_Event::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Event_BAO_Event
的用法示例。
在下文中一共展示了CRM_Event_BAO_Event::add方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
public function postProcess()
{
$params = $this->exportValues();
$params['id'] = $this->_id;
CRM_Event_BAO_Event::add($params);
parent::endPostProcess();
}
示例2: crm_create_event
/**
* Create a Event
*
* This API is used for creating a Event
*
* @param array $params an associative array of title/value property values of civicrm_event
*
* @return array of newly created event property values.
* @access public
*/
function crm_create_event($params)
{
_crm_initialize();
if (!is_array($params)) {
return _crm_error('Params is not an array.');
}
if (!$params["title"] || !$params['event_type_id'] || !$params['start_date']) {
return _crm_error('Missing require fileds ( title, event type id,start date)');
}
$error = _crm_check_required_fields($params, 'CRM_Event_DAO_Event');
if (is_a($error, 'CRM_Core_Error')) {
return $error;
}
$ids['event'] = $params['id'];
$ids['eventTypeId'] = $params['event_type_id'];
$ids['startDate'] = $params['start_date'];
require_once 'CRM/Event/BAO/Event.php';
$eventBAO = CRM_Event_BAO_Event::add($params, $ids);
$event = array();
_crm_object_to_array($eventBAO, $event);
return $event;
}
示例3: postProcess
/**
* Process the form.
*/
public function postProcess()
{
$eventTitle = '';
$params = $this->exportValues();
$this->set('discountSection', 0);
if (!empty($_POST['_qf_Fee_submit'])) {
$this->buildAmountLabel();
$this->set('discountSection', 2);
return;
}
if (!empty($params['payment_processor'])) {
$params['payment_processor'] = str_replace(',', CRM_Core_DAO::VALUE_SEPARATOR, $params['payment_processor']);
} else {
$params['payment_processor'] = 'null';
}
$params['is_pay_later'] = CRM_Utils_Array::value('is_pay_later', $params, 0);
$params['is_billing_required'] = CRM_Utils_Array::value('is_billing_required', $params, 0);
if ($this->_id) {
// delete all the prior label values or discounts in the custom options table
// and delete a price set if one exists
//@todo note that this removes the reference from existing participants -
// even where there is not change - redress?
// note that a more tentative form of this is invoked by passing price_set_id as an array
// to event.create see CRM-14069
// @todo get all of this logic out of form layer (currently partially in BAO/api layer)
if (CRM_Price_BAO_PriceSet::removeFrom('civicrm_event', $this->_id)) {
CRM_Core_BAO_Discount::del($this->_id, 'civicrm_event');
}
}
if ($params['is_monetary']) {
if (!empty($params['price_set_id'])) {
//@todo this is now being done in the event BAO if passed price_set_id as an array
// per notes on that fn - looking at the api converting to an array
// so calling via the api may cause this to be done in the api
CRM_Price_BAO_PriceSet::addTo('civicrm_event', $this->_id, $params['price_set_id']);
if (!empty($params['price_field_id'])) {
$priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $params['price_field_id'], 'price_set_id');
CRM_Price_BAO_PriceSet::setIsQuickConfig($priceSetID, 0);
}
} else {
// if there are label / values, create custom options for them
$labels = CRM_Utils_Array::value('label', $params);
$values = CRM_Utils_Array::value('value', $params);
$default = CRM_Utils_Array::value('default', $params);
$options = array();
if (!CRM_Utils_System::isNull($labels) && !CRM_Utils_System::isNull($values)) {
for ($i = 1; $i < self::NUM_OPTION; $i++) {
if (!empty($labels[$i]) && !CRM_Utils_System::isNull($values[$i])) {
$options[] = array('label' => trim($labels[$i]), 'value' => CRM_Utils_Rule::cleanMoney(trim($values[$i])), 'weight' => $i, 'is_active' => 1, 'is_default' => $default == $i);
}
}
if (!empty($options)) {
$params['default_fee_id'] = NULL;
if (empty($params['price_set_id'])) {
if (empty($params['price_field_id'])) {
$setParams['title'] = $eventTitle = $this->_isTemplate ? $this->_defaultValues['template_title'] : $this->_defaultValues['title'];
$eventTitle = strtolower(CRM_Utils_String::munge($eventTitle, '_', 245));
if (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceSet', $eventTitle, 'id', 'name')) {
$setParams['name'] = $eventTitle;
} elseif (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceSet', $eventTitle . '_' . $this->_id, 'id', 'name')) {
$setParams['name'] = $eventTitle . '_' . $this->_id;
} else {
$timeSec = explode('.', microtime(TRUE));
$setParams['name'] = $eventTitle . '_' . date('is', $timeSec[0]) . $timeSec[1];
}
$setParams['is_quick_config'] = 1;
$setParams['financial_type_id'] = $params['financial_type_id'];
$setParams['extends'] = CRM_Core_Component::getComponentID('CiviEvent');
$priceSet = CRM_Price_BAO_PriceSet::create($setParams);
$fieldParams['name'] = strtolower(CRM_Utils_String::munge($params['fee_label'], '_', 245));
$fieldParams['price_set_id'] = $priceSet->id;
} else {
foreach ($params['price_field_value'] as $arrayID => $fieldValueID) {
if (empty($params['label'][$arrayID]) && empty($params['value'][$arrayID]) && !empty($fieldValueID)) {
CRM_Price_BAO_PriceFieldValue::setIsActive($fieldValueID, '0');
unset($params['price_field_value'][$arrayID]);
}
}
$fieldParams['id'] = CRM_Utils_Array::value('price_field_id', $params);
$fieldParams['option_id'] = $params['price_field_value'];
$priceSet = new CRM_Price_BAO_PriceSet();
$priceSet->id = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', CRM_Utils_Array::value('price_field_id', $params), 'price_set_id');
if ($this->_defaultValues['financial_type_id'] != $params['financial_type_id']) {
CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceSet', $priceSet->id, 'financial_type_id', $params['financial_type_id']);
}
}
$fieldParams['label'] = $params['fee_label'];
$fieldParams['html_type'] = 'Radio';
CRM_Price_BAO_PriceSet::addTo('civicrm_event', $this->_id, $priceSet->id);
$fieldParams['option_label'] = $params['label'];
$fieldParams['option_amount'] = $params['value'];
$fieldParams['financial_type_id'] = $params['financial_type_id'];
foreach ($options as $value) {
$fieldParams['option_weight'][$value['weight']] = $value['weight'];
}
$fieldParams['default_option'] = $params['default'];
$priceField = CRM_Price_BAO_PriceField::create($fieldParams);
//.........这里部分代码省略.........
示例4: postProcess
public function postProcess()
{
$params = array();
$params = $this->exportValues();
if (trim($params['parent_event_name']) === '') {
# believe me...
$params['parent_event_id'] = '';
}
//update events table
$params['id'] = $this->_id;
CRM_Event_BAO_Event::add($params);
parent::endPostProcess();
}
示例5: testEventFull
/**
* EventFull() method (checking the event for full )
*/
public function testEventFull()
{
$eventParams = array('max_participants' => 1, 'id' => $this->_eventId);
CRM_Event_BAO_Event::add($eventParams);
$participantId = Participant::create($this->_contactId, $this->_eventId);
$eventFull = CRM_Event_BAO_Participant::eventFull($this->_eventId);
$this->assertEquals($eventFull, 'This event is full.', 'Checking if Event is full.');
Participant::delete($participantId);
Contact::delete($this->_contactId);
Event::delete($this->_eventId);
}
示例6: testDeleteLocBlock
/**
* DeleteLocBlock() method
* delete the location block
* created with various elements.
*/
public function testDeleteLocBlock()
{
$this->_contactId = $this->individualCreate();
//create test event record.
$event = $this->eventCreate();
$params['location'][1] = array('location_type_id' => 1, 'is_primary' => 1, 'address' => array('street_address' => 'Saint Helier St', 'supplemental_address_1' => 'Hallmark Ct', 'supplemental_address_2' => 'Jersey Village', 'city' => 'Newark', 'postal_code' => '01903', 'country_id' => 1228, 'state_province_id' => 1029, 'geo_code_1' => '18.219023', 'geo_code_2' => '-105.00973'), 'email' => array('1' => array('email' => 'john.smith@example.org')), 'phone' => array('1' => array('phone_type_id' => 1, 'phone' => '303443689'), '2' => array('phone_type_id' => 2, 'phone' => '9833910234')), 'im' => array('1' => array('name' => 'jane.doe', 'provider_id' => 1)));
$params['entity_id'] = $event['id'];
$params['entity_table'] = 'civicrm_event';
//create location block.
//with various elements
//like address, phone, email, im.
$location = CRM_Core_BAO_Location::create($params, NULL, TRUE);
$locBlockId = CRM_Utils_Array::value('id', $location);
//update event record with location block id
$eventParams = array('id' => $event['id'], 'loc_block_id' => $locBlockId);
CRM_Event_BAO_Event::add($eventParams);
//delete the location block
CRM_Core_BAO_Location::deleteLocBlock($locBlockId);
//Now check DB for location elements.
//Now check DB for Address
$this->assertDBNull('CRM_Core_DAO_Address', 'Saint Helier St', 'id', 'street_address', 'Database check, Address deleted successfully.');
//Now check DB for Email
$this->assertDBNull('CRM_Core_DAO_Email', 'john.smith@example.org', 'id', 'email', 'Database check, Email deleted successfully.');
//Now check DB for Phone
$this->assertDBNull('CRM_Core_DAO_Phone', '303443689', 'id', 'phone', 'Database check, Phone deleted successfully.');
//Now check DB for Mobile
$this->assertDBNull('CRM_Core_DAO_Phone', '9833910234', 'id', 'phone', 'Database check, Mobile deleted successfully.');
//Now check DB for IM
$this->assertDBNull('CRM_Core_DAO_IM', 'jane.doe', 'id', 'name', 'Database check, IM deleted successfully.');
//cleanup DB by deleting the record.
$this->eventDelete($event['id']);
$this->contactDelete($this->_contactId);
//Now check DB for Event
$this->assertDBNull('CRM_Event_DAO_Event', $event['id'], 'id', 'id', 'Database check, Event deleted successfully.');
}
示例7: postProcess
/**
* Process the form submission.
*
*
* @return void
*/
public function postProcess()
{
$params = $this->exportValues();
$params['id'] = $this->_id;
// format params
$params['is_online_registration'] = CRM_Utils_Array::value('is_online_registration', $params, FALSE);
$params['is_confirm_enabled'] = CRM_Utils_Array::value('is_confirm_enabled', $params, FALSE);
// CRM-11182
$params['is_multiple_registrations'] = CRM_Utils_Array::value('is_multiple_registrations', $params, FALSE);
$params['allow_same_participant_emails'] = CRM_Utils_Array::value('allow_same_participant_emails', $params, FALSE);
$params['requires_approval'] = CRM_Utils_Array::value('requires_approval', $params, FALSE);
// reset is_email confirm if not online reg
if (!$params['is_online_registration']) {
$params['is_email_confirm'] = FALSE;
}
if (!$this->_isTemplate) {
$params['registration_start_date'] = CRM_Utils_Date::processDate($params['registration_start_date'], $params['registration_start_date_time'], TRUE);
$params['registration_end_date'] = CRM_Utils_Date::processDate($params['registration_end_date'], $params['registration_end_date_time'], TRUE);
}
CRM_Event_BAO_Event::add($params);
// also update the ProfileModule tables
$ufJoinParams = array('is_active' => 1, 'module' => 'CiviEvent', 'entity_table' => 'civicrm_event', 'entity_id' => $this->_id);
// first delete all past entries
CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams);
$uf = array();
$wt = 2;
if (!empty($params['custom_pre_id'])) {
$uf[1] = $params['custom_pre_id'];
$wt = 1;
}
if (!empty($params['custom_post_id'])) {
$uf[2] = $params['custom_post_id'];
}
if (!empty($params['custom_post_id_multiple'])) {
$uf = array_merge($uf, $params['custom_post_id_multiple']);
}
$uf = array_values($uf);
if (!empty($uf)) {
foreach ($uf as $weight => $ufGroupId) {
$ufJoinParams['weight'] = $weight + $wt;
$ufJoinParams['uf_group_id'] = $ufGroupId;
CRM_Core_BAO_UFJoin::create($ufJoinParams);
unset($ufJoinParams['id']);
}
}
// also update the ProfileModule tables
$ufJoinParamsAdd = array('is_active' => 1, 'module' => 'CiviEvent_Additional', 'entity_table' => 'civicrm_event', 'entity_id' => $this->_id);
// first delete all past entries
CRM_Core_BAO_UFJoin::deleteAll($ufJoinParamsAdd);
if (!empty($params['is_multiple_registrations'])) {
$ufAdd = array();
$wtAdd = 2;
if (array_key_exists('additional_custom_pre_id', $params)) {
if (empty($params['additional_custom_pre_id'])) {
$ufAdd[1] = $params['custom_pre_id'];
$wtAdd = 1;
} elseif (CRM_Utils_Array::value('additional_custom_pre_id', $params) == 'none') {
} else {
$ufAdd[1] = $params['additional_custom_pre_id'];
$wtAdd = 1;
}
}
if (array_key_exists('additional_custom_post_id', $params)) {
if (empty($params['additional_custom_post_id'])) {
$ufAdd[2] = $params['custom_post_id'];
} elseif (CRM_Utils_Array::value('additional_custom_post_id', $params) == 'none') {
} else {
$ufAdd[2] = $params['additional_custom_post_id'];
}
}
if (!empty($params['additional_custom_post_id_multiple'])) {
$additionalPostMultiple = array();
foreach ($params['additional_custom_post_id_multiple'] as $key => $value) {
if (is_null($value) && !empty($params['custom_post_id'])) {
$additionalPostMultiple[$key] = $params['custom_post_id'];
} elseif ($value == 'none') {
continue;
} elseif ($value) {
$additionalPostMultiple[$key] = $value;
}
}
$ufAdd = array_merge($ufAdd, $additionalPostMultiple);
}
$ufAdd = array_values($ufAdd);
if (!empty($ufAdd)) {
foreach ($ufAdd as $weightAdd => $ufGroupIdAdd) {
$ufJoinParamsAdd['weight'] = $weightAdd + $wtAdd;
$ufJoinParamsAdd['uf_group_id'] = $ufGroupIdAdd;
CRM_Core_BAO_UFJoin::create($ufJoinParamsAdd);
unset($ufJoinParamsAdd['id']);
}
}
}
// get the profiles to evaluate what they collect
//.........这里部分代码省略.........
示例8: testEventFull
/**
* EventFull() method (checking the event for full )
*/
public function testEventFull()
{
$eventParams = array('max_participants' => 1, 'id' => $this->_eventId);
CRM_Event_BAO_Event::add($eventParams);
$participantId = $this->participantCreate(array('contact_id' => $this->_contactId, 'event_id' => $this->_eventId));
$eventFull = CRM_Event_BAO_Participant::eventFull($this->_eventId);
$this->assertEquals($eventFull, 'Sorry! We are already full', 'Checking if Event is full.');
$this->participantDelete($participantId);
$this->contactDelete($this->_contactId);
$this->eventDelete($this->_eventId);
}
示例9: postProcess
/**
* Function to process the form
*
* @access public
* @return None
*/
public function postProcess()
{
$params = array();
$params = $this->exportValues();
$params['id'] = $this->_id;
//format params
$params['is_online_registration'] = CRM_Utils_Array::value('is_online_registration', $params, false);
$params['is_multiple_registrations'] = CRM_Utils_Array::value('is_multiple_registrations', $params, false);
$params['allow_same_participant_emails'] = CRM_Utils_Array::value('allow_same_participant_emails', $params, false);
$params['requires_approval'] = CRM_Utils_Array::value('requires_approval', $params, false);
// reset is_email confirm if not online reg
if (!$params['is_online_registration']) {
$params['is_email_confirm'] = false;
}
if (!$this->_isTemplate) {
$params['registration_start_date'] = CRM_Utils_Date::processDate($params['registration_start_date'], $params['registration_start_date_time'], true);
$params['registration_end_date'] = CRM_Utils_Date::processDate($params['registration_end_date'], $params['registration_end_date_time'], true);
}
require_once 'CRM/Event/BAO/Event.php';
CRM_Event_BAO_Event::add($params);
// also update the ProfileModule tables
$ufJoinParams = array('is_active' => 1, 'module' => 'CiviEvent', 'entity_table' => 'civicrm_event', 'entity_id' => $this->_id);
require_once 'CRM/Core/BAO/UFJoin.php';
// first delete all past entries
CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams);
if (!empty($params['custom_pre_id'])) {
$ufJoinParams['weight'] = 1;
$ufJoinParams['uf_group_id'] = $params['custom_pre_id'];
CRM_Core_BAO_UFJoin::create($ufJoinParams);
}
unset($ufJoinParams['id']);
if (!empty($params['custom_post_id'])) {
$ufJoinParams['weight'] = 2;
$ufJoinParams['uf_group_id'] = $params['custom_post_id'];
CRM_Core_BAO_UFJoin::create($ufJoinParams);
}
// CRM-4377: also update the profiles for additional participants
$ufJoinParams['module'] = 'CiviEvent_Additional';
$ufJoinParams['weight'] = 1;
$ufJoinParams['uf_group_id'] = $params['custom_pre_id'];
if ($params['additional_custom_pre_id'] == 'none') {
$ufJoinParams['is_active'] = 0;
} elseif ($params['additional_custom_pre_id']) {
$ufJoinParams['uf_group_id'] = $params['additional_custom_pre_id'];
}
CRM_Core_BAO_UFJoin::create($ufJoinParams);
$ufJoinParams['weight'] = 2;
$ufJoinParams['uf_group_id'] = $params['custom_post_id'];
if ($params['additional_custom_post_id'] == 'none') {
$ufJoinParams['is_active'] = 0;
} elseif ($params['additional_custom_post_id']) {
//minor fix for CRM-4377
$ufJoinParams['is_active'] = 1;
$ufJoinParams['uf_group_id'] = $params['additional_custom_post_id'];
}
CRM_Core_BAO_UFJoin::create($ufJoinParams);
parent::endPostProcess();
}
示例10: postProcess
/**
* Function to process the form
*
* @access public
* @return None
*/
public function postProcess()
{
$params = $this->exportValues();
$delteOldBlock = false;
// if 'use existing location' option is selected -
if ($params['location_option'] == 2 && CRM_Utils_Array::value('loc_event_id', $params) && $params['loc_event_id'] != $this->_oldLocBlockId) {
// if new selected loc is different from old loc, update the loc_block_id
// so that loc update would affect the selected loc and not the old one.
$delteOldBlock = true;
CRM_Core_DAO::setFieldValue('CRM_Event_DAO_Event', $this->_id, 'loc_block_id', $params['loc_event_id']);
}
// if 'create new loc' option is selected, set the loc_block_id for this event to null
// so that an update would result in creating a new loc.
if ($this->_oldLocBlockId && $params['location_option'] == 1) {
$delteOldBlock = true;
CRM_Core_DAO::setFieldValue('CRM_Event_DAO_Event', $this->_id, 'loc_block_id', 'null');
}
// if 'create new loc' optioin is selected OR selected new loc is different
// from old one, go ahead and delete the old loc provided thats not being
// used by any other event
if ($this->_oldLocBlockId && $delteOldBlock) {
CRM_Event_BAO_Event::deleteEventLocBlock($this->_oldLocBlockId, $this->_id);
}
// get ready with location block params
$params['entity_table'] = 'civicrm_event';
$params['entity_id'] = $this->_id;
require_once 'CRM/Core/BAO/LocationType.php';
$defaultLocationType =& CRM_Core_BAO_LocationType::getDefault();
foreach (array('address', 'phone', 'email') as $block) {
if (!CRM_Utils_Array::value($block, $params) || !is_array($params[$block])) {
continue;
}
foreach ($params[$block] as $count => &$values) {
if ($count == 1) {
$values['is_primary'] = 1;
}
$values['location_type_id'] = $defaultLocationType->id ? $defaultLocationType->id : 1;
}
}
// create/update event location
require_once 'CRM/Core/BAO/Location.php';
$location = CRM_Core_BAO_Location::create($params, true, 'event');
$params['loc_block_id'] = $location['id'];
// finally update event params
$params['id'] = $this->_id;
require_once 'CRM/Event/BAO/Event.php';
CRM_Event_BAO_Event::add($params);
parent::endPostProcess();
}
示例11: postProcess
/**
* Process the form
*
* @return void
* @access public
*/
public function postProcess()
{
$params = array();
$params = $this->exportValues();
$this->set('discountSection', 0);
if (CRM_Utils_Array::value('_qf_Fee_submit', $_POST)) {
$this->buildAmountLabel();
$this->set('discountSection', 1);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/manage', '#isDiscount'));
return;
}
$params['is_pay_later'] = CRM_Utils_Array::value('is_pay_later', $params, 0);
if ($this->_id) {
require_once 'CRM/Price/BAO/Set.php';
// delete all the prior label values or discounts in the custom options table
// and delete a price set if one exists
if (!CRM_Price_BAO_Set::removeFrom('civicrm_event', $this->_id)) {
require_once 'CRM/Core/OptionGroup.php';
CRM_Core_OptionGroup::deleteAssoc("civicrm_event.amount.{$this->_id}");
CRM_Core_OptionGroup::deleteAssoc("civicrm_event.amount.{$this->_id}.discount.%", "LIKE");
}
}
if ($params['is_monetary']) {
if ($params['price_set_id']) {
CRM_Price_BAO_Set::addTo('civicrm_event', $this->_id, $params['price_set_id']);
} else {
// if there are label / values, create custom options for them
$labels = CRM_Utils_Array::value('label', $params);
$values = CRM_Utils_Array::value('value', $params);
$default = CRM_Utils_Array::value('default', $params);
$options = array();
if (!CRM_Utils_System::isNull($labels) && !CRM_Utils_System::isNull($values)) {
for ($i = 1; $i < self::NUM_OPTION; $i++) {
if (!empty($labels[$i]) && !CRM_Utils_System::isNull($values[$i])) {
$options[] = array('label' => trim($labels[$i]), 'value' => CRM_Utils_Rule::cleanMoney(trim($values[$i])), 'weight' => $i, 'is_active' => 1, 'is_default' => $default == $i);
}
}
if (!empty($options)) {
$params['default_fee_id'] = null;
CRM_Core_OptionGroup::createAssoc("civicrm_event.amount.{$this->_id}", $options, $params['default_fee_id']);
}
}
if (CRM_Utils_Array::value('is_discount', $params) == 1) {
// if there are discounted set of label / values,
// create custom options for them
$labels = CRM_Utils_Array::value('discounted_label', $params);
$values = CRM_Utils_Array::value('discounted_value', $params);
$default = CRM_Utils_Array::value('discounted_default', $params);
if (!CRM_Utils_System::isNull($labels) && !CRM_Utils_System::isNull($values)) {
for ($j = 1; $j <= self::NUM_DISCOUNT; $j++) {
$discountOptions = array();
for ($i = 1; $i < self::NUM_OPTION; $i++) {
if (!empty($labels[$i]) && CRM_Utils_Array::value($j, $values[$i])) {
$discountOptions[] = array('label' => trim($labels[$i]), 'value' => CRM_Utils_Rule::cleanMoney(trim($values[$i][$j])), 'weight' => $i, 'is_active' => 1, 'is_default' => $default == $i);
}
}
if (!empty($discountOptions)) {
$params['default_discount_fee_id'] = null;
$discountOptionsGroupId = CRM_Core_OptionGroup::createAssoc("civicrm_event.amount.{$this->_id}.discount.{$params['discount_name'][$j]}", $discountOptions, $params['default_discount_fee_id'], $params['discount_name'][$j]);
$discountParams = array('entity_table' => 'civicrm_event', 'entity_id' => $this->_id, 'option_group_id' => $discountOptionsGroupId, 'start_date' => CRM_Utils_Date::format($params["discount_start_date"][$j]), 'end_date' => CRM_Utils_Date::format($params["discount_end_date"][$j]));
require_once 'CRM/Core/BAO/Discount.php';
CRM_Core_BAO_Discount::add($discountParams);
}
}
}
}
}
} else {
$params['contribution_type_id'] = '';
}
//update events table
require_once 'CRM/Event/BAO/Event.php';
$params['id'] = $this->_id;
CRM_Event_BAO_Event::add($params);
parent::endPostProcess();
}
示例12: postProcess
/**
* Function to process the form
*
* @access public
*
* @return None
*/
public function postProcess()
{
$params = array();
$params = $this->exportValues();
$params['id'] = $this->_id;
//format params
$params['is_online_registration'] = CRM_Utils_Array::value('is_online_registration', $params, FALSE);
$params['is_multiple_registrations'] = CRM_Utils_Array::value('is_multiple_registrations', $params, FALSE);
$params['allow_same_participant_emails'] = CRM_Utils_Array::value('allow_same_participant_emails', $params, FALSE);
$params['requires_approval'] = CRM_Utils_Array::value('requires_approval', $params, FALSE);
// reset is_email confirm if not online reg
if (!$params['is_online_registration']) {
$params['is_email_confirm'] = FALSE;
}
if (!$this->_isTemplate) {
$params['registration_start_date'] = CRM_Utils_Date::processDate($params['registration_start_date'], $params['registration_start_date_time'], TRUE);
$params['registration_end_date'] = CRM_Utils_Date::processDate($params['registration_end_date'], $params['registration_end_date_time'], TRUE);
}
CRM_Event_BAO_Event::add($params);
// also update the ProfileModule tables
$ufJoinParams = array('is_active' => 1, 'module' => 'CiviEvent', 'entity_table' => 'civicrm_event', 'entity_id' => $this->_id);
// first delete all past entries
CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams);
$uf = array();
$wt = 2;
if (!empty($params['custom_pre_id'])) {
$uf[1] = $params['custom_pre_id'];
$wt = 1;
}
if (!empty($params['custom_post_id'])) {
$uf[2] = $params['custom_post_id'];
}
if (CRM_Utils_Array::value('custom_post_id_multiple', $params)) {
$uf = array_merge($uf, $params['custom_post_id_multiple']);
}
$uf = array_values($uf);
if (!empty($uf)) {
foreach ($uf as $weight => $ufGroupId) {
$ufJoinParams['weight'] = $weight + $wt;
$ufJoinParams['uf_group_id'] = $ufGroupId;
CRM_Core_BAO_UFJoin::create($ufJoinParams);
unset($ufJoinParams['id']);
}
}
// also update the ProfileModule tables
$ufJoinParamsAdd = array('is_active' => 1, 'module' => 'CiviEvent_Additional', 'entity_table' => 'civicrm_event', 'entity_id' => $this->_id);
// first delete all past entries
CRM_Core_BAO_UFJoin::deleteAll($ufJoinParamsAdd);
if (CRM_Utils_Array::value('is_multiple_registrations', $params)) {
$ufAdd = array();
$wtAdd = 2;
if (array_key_exists('additional_custom_pre_id', $params)) {
if (!CRM_Utils_Array::value('additional_custom_pre_id', $params)) {
$ufAdd[1] = $params['custom_pre_id'];
$wtAdd = 1;
} elseif (CRM_Utils_Array::value('additional_custom_pre_id', $params) == 'none') {
} else {
$ufAdd[1] = $params['additional_custom_pre_id'];
$wtAdd = 1;
}
}
if (array_key_exists('additional_custom_post_id', $params)) {
if (!CRM_Utils_Array::value('additional_custom_post_id', $params)) {
$ufAdd[2] = $params['custom_post_id'];
} elseif (CRM_Utils_Array::value('additional_custom_post_id', $params) == 'none') {
} else {
$ufAdd[2] = $params['additional_custom_post_id'];
}
}
if (CRM_Utils_Array::value('additional_custom_post_id_multiple', $params)) {
$additionalPostMultiple = array();
foreach ($params['additional_custom_post_id_multiple'] as $key => $value) {
if (!$value && CRM_Utils_Array::value('custom_post_id', $params)) {
$additionalPostMultiple[$key] = $params['custom_post_id'];
} elseif ($value == 'none') {
continue;
} elseif ($value) {
$additionalPostMultiple[$key] = $value;
}
}
$ufAdd = array_merge($ufAdd, $additionalPostMultiple);
}
$ufAdd = array_values($ufAdd);
if (!empty($ufAdd)) {
foreach ($ufAdd as $weightAdd => $ufGroupIdAdd) {
$ufJoinParamsAdd['weight'] = $weightAdd + $wtAdd;
$ufJoinParamsAdd['uf_group_id'] = $ufGroupIdAdd;
CRM_Core_BAO_UFJoin::create($ufJoinParamsAdd);
unset($ufJoinParamsAdd['id']);
}
}
}
parent::endPostProcess();
//.........这里部分代码省略.........
示例13: postProcess
/**
* Process the form
*
* @return void
* @access public
*/
public function postProcess()
{
$params = array();
$eventTitle = '';
$params = $this->exportValues();
$this->set('discountSection', 0);
if (CRM_Utils_Array::value('_qf_Fee_submit', $_POST)) {
$this->buildAmountLabel();
$this->set('discountSection', 2);
return;
}
if (array_key_exists('payment_processor', $params) && !CRM_Utils_System::isNull($params['payment_processor'])) {
$params['payment_processor'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['payment_processor']));
} else {
$params['payment_processor'] = 'null';
}
$params['is_pay_later'] = CRM_Utils_Array::value('is_pay_later', $params, 0);
if ($this->_id) {
// delete all the prior label values or discounts in the custom options table
// and delete a price set if one exists
if (CRM_Price_BAO_Set::removeFrom('civicrm_event', $this->_id)) {
CRM_Core_BAO_Discount::del($this->_id, 'civicrm_event');
}
}
if ($params['is_monetary']) {
if (CRM_Utils_Array::value('price_set_id', $params)) {
CRM_Price_BAO_Set::addTo('civicrm_event', $this->_id, $params['price_set_id']);
if (CRM_Utils_Array::value('price_field_id', $params)) {
$priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', $params['price_field_id'], 'price_set_id');
CRM_Price_BAO_Set::setIsQuickConfig($priceSetID, 0);
}
} else {
// if there are label / values, create custom options for them
$labels = CRM_Utils_Array::value('label', $params);
$values = CRM_Utils_Array::value('value', $params);
$default = CRM_Utils_Array::value('default', $params);
$options = array();
if (!CRM_Utils_System::isNull($labels) && !CRM_Utils_System::isNull($values)) {
for ($i = 1; $i < self::NUM_OPTION; $i++) {
if (!empty($labels[$i]) && !CRM_Utils_System::isNull($values[$i])) {
$options[] = array('label' => trim($labels[$i]), 'value' => CRM_Utils_Rule::cleanMoney(trim($values[$i])), 'weight' => $i, 'is_active' => 1, 'is_default' => $default == $i);
}
}
if (!empty($options)) {
$params['default_fee_id'] = NULL;
if (!CRM_Utils_Array::value('price_set_id', $params)) {
if (!CRM_Utils_Array::value('price_field_id', $params)) {
$eventTitle = $this->_isTemplate ? $this->_defaultValues['template_title'] : $this->_defaultValues['title'];
if (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_Set', $eventTitle, 'id', 'title')) {
$setParams['name'] = $setParams['title'] = $eventTitle;
} elseif (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_Set', $eventTitle . '_' . $this->_id, 'id', 'title')) {
$setParams['name'] = $setParams['title'] = $eventTitle . '_' . $this->_id;
} else {
$timeSec = explode(".", microtime(true));
$setParams['name'] = $setParams['title'] = $eventTitle . '_' . date('is', $timeSec[0]) . $timeSec[1];
}
$setParams['is_quick_config'] = 1;
$setParams['extends'] = CRM_Core_Component::getComponentID('CiviEvent');
$priceSet = CRM_Price_BAO_Set::create($setParams);
$fieldParams['name'] = $fieldParams['label'] = $params['fee_label'];
$fieldParams['price_set_id'] = $priceSet->id;
} else {
foreach ($params['price_field_value'] as $arrayID => $fieldValueID) {
if (empty($params['label'][$arrayID]) && empty($params['value'][$arrayID]) && !empty($fieldValueID)) {
CRM_Price_BAO_FieldValue::setIsActive($fieldValueID, '0');
unset($params['price_field_value'][$arrayID]);
}
}
$fieldParams['id'] = CRM_Utils_Array::value('price_field_id', $params);
$fieldParams['option_id'] = $params['price_field_value'];
$priceSet->id = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', CRM_Utils_Array::value('price_field_id', $params), 'price_set_id');
}
$fieldParams['html_type'] = 'Radio';
CRM_Price_BAO_Set::addTo('civicrm_event', $this->_id, $priceSet->id);
$fieldParams['option_label'] = $params['label'];
$fieldParams['option_amount'] = $params['value'];
foreach ($options as $value) {
$fieldParams['option_weight'][$value['weight']] = $value['weight'];
}
$fieldParams['default_option'] = $params['default'];
$priceField = CRM_Price_BAO_Field::create($fieldParams);
}
}
}
$discountPriceSets = CRM_Utils_Array::value('discount_price_set', $this->_defaultValues) ? $this->_defaultValues['discount_price_set'] : array();
$discountFieldIDs = CRM_Utils_Array::value('discount_option_id', $this->_defaultValues) ? $this->_defaultValues['discount_option_id'] : array();
if (CRM_Utils_Array::value('is_discount', $params) == 1) {
// if there are discounted set of label / values,
// create custom options for them
$labels = CRM_Utils_Array::value('discounted_label', $params);
$values = CRM_Utils_Array::value('discounted_value', $params);
$default = CRM_Utils_Array::value('discounted_default', $params);
if (!CRM_Utils_System::isNull($labels) && !CRM_Utils_System::isNull($values)) {
for ($j = 1; $j <= self::NUM_DISCOUNT; $j++) {
//.........这里部分代码省略.........
示例14: testeventFull
/**
* eventFull() method (checking the event for full )
*/
function testeventFull()
{
require_once 'CRM/Event/BAO/Event.php';
CRM_Event_BAO_Event::add($eventParams = array('max_participants' => 1, 'id' => $this->_eventId));
$participantId = Participant::create($this->_contactId, $this->_eventId);
$eventFull = CRM_Event_BAO_Participant::eventFull($this->_eventId);
$this->assertEquals($eventFull, 'This event is full !!!', 'Checking if Event is full.');
Participant::delete($participantId);
Contact::delete($this->_contactId);
Event::delete($this->_eventId);
}