本文整理汇总了PHP中CRM_Event_BAO_Event::getTemplateDefaultValues方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Event_BAO_Event::getTemplateDefaultValues方法的具体用法?PHP CRM_Event_BAO_Event::getTemplateDefaultValues怎么用?PHP CRM_Event_BAO_Event::getTemplateDefaultValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Event_BAO_Event
的用法示例。
在下文中一共展示了CRM_Event_BAO_Event::getTemplateDefaultValues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
/**
* Process the form submission.
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
//format params
$params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], $params['start_date_time']);
$params['end_date'] = CRM_Utils_Date::processDate(CRM_Utils_Array::value('end_date', $params), CRM_Utils_Array::value('end_date_time', $params), TRUE);
$params['has_waitlist'] = CRM_Utils_Array::value('has_waitlist', $params, FALSE);
$params['is_map'] = CRM_Utils_Array::value('is_map', $params, FALSE);
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
$params['is_public'] = CRM_Utils_Array::value('is_public', $params, FALSE);
$params['is_share'] = CRM_Utils_Array::value('is_share', $params, FALSE);
$params['default_role_id'] = CRM_Utils_Array::value('default_role_id', $params, FALSE);
$params['id'] = $this->_id;
$customFields = CRM_Core_BAO_CustomField::getFields('Event', FALSE, FALSE, CRM_Utils_Array::value('event_type_id', $params));
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $this->_id, 'Event');
//merge params with defaults from templates
if (!empty($params['template_id'])) {
$params = array_merge(CRM_Event_BAO_Event::getTemplateDefaultValues($params['template_id']), $params);
}
$event = CRM_Event_BAO_Event::create($params);
// now that we have the event’s id, do some more template-based stuff
if (!empty($params['template_id'])) {
CRM_Event_BAO_Event::copy($params['template_id'], $event, TRUE);
}
$this->set('id', $event->id);
$this->postProcessHook();
if ($this->_action & CRM_Core_Action::ADD) {
$url = 'civicrm/event/manage/location';
$urlParams = "action=update&reset=1&id={$event->id}";
// special case for 'Save and Done' consistency.
if ($this->controller->getButtonName('submit') == '_qf_EventInfo_upload_done') {
$url = 'civicrm/event/manage';
$urlParams = 'reset=1';
CRM_Core_Session::setStatus(ts("'%1' information has been saved.", array(1 => $this->getTitle())), ts('Saved'), 'success');
}
CRM_Utils_System::redirect(CRM_Utils_System::url($url, $urlParams));
}
parent::endPostProcess();
}
示例2: postProcess
/**
* Function to process the form
*
* @access public
*
* @return None
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
//format params
$params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], $params['start_date_time']);
$params['end_date'] = CRM_Utils_Date::processDate(CRM_Utils_Array::value('end_date', $params), CRM_Utils_Array::value('end_date_time', $params), TRUE);
$params['has_waitlist'] = CRM_Utils_Array::value('has_waitlist', $params, FALSE);
$params['is_map'] = CRM_Utils_Array::value('is_map', $params, FALSE);
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
$params['is_public'] = CRM_Utils_Array::value('is_public', $params, FALSE);
$params['is_share'] = CRM_Utils_Array::value('is_share', $params, FALSE);
$params['default_role_id'] = CRM_Utils_Array::value('default_role_id', $params, FALSE);
$params['id'] = $this->_id;
$customFields = CRM_Core_BAO_CustomField::getFields('Event', FALSE, FALSE, CRM_Utils_Array::value('event_type_id', $params));
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_id, 'Event');
//merge params with defaults from templates
if (CRM_Utils_Array::value('template_id', $params)) {
$params = array_merge(CRM_Event_BAO_Event::getTemplateDefaultValues($params['template_id']), $params);
}
$event = CRM_Event_BAO_Event::create($params);
// now that we have the event’s id, do some more template-based stuff
if (CRM_Utils_Array::value('template_id', $params)) {
// copy price sets if any
$priceSetId = CRM_Price_BAO_Set::getFor('civicrm_event', $params['template_id']);
if ($priceSetId) {
$isQuickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', $priceSetId, 'is_quick_config');
if ($isQuickConfig) {
$copyPriceSet =& CRM_Price_BAO_Set::copy($priceSetId);
$priceSetId = $copyPriceSet->id;
}
CRM_Price_BAO_Set::addTo('civicrm_event', $event->id, $priceSetId);
}
// link profiles if none linked
$ufParams = array('entity_table' => 'civicrm_event', 'entity_id' => $event->id);
if (!CRM_Core_BAO_UFJoin::findUFGroupId($ufParams)) {
CRM_Core_DAO::copyGeneric('CRM_Core_DAO_UFJoin', array('entity_id' => $params['template_id'], 'entity_table' => 'civicrm_event'), array('entity_id' => $event->id));
}
// if no Tell-a-Friend defined, check whether there’s one for template and copy if so
$tafParams = array('entity_table' => 'civicrm_event', 'entity_id' => $event->id);
if (!CRM_Friend_BAO_Friend::getValues($tafParams)) {
$tafParams['entity_id'] = $params['template_id'];
if (CRM_Friend_BAO_Friend::getValues($tafParams)) {
$tafParams['entity_id'] = $event->id;
if (isset($tafParams['id'])) {
unset($tafParams['id']);
}
CRM_Friend_BAO_Friend::addTellAFriend($tafParams);
}
}
//copy pcp settings
CRM_Core_DAO::copyGeneric('CRM_PCP_DAO_PCPBlock', array('entity_id' => $params['template_id'], 'entity_table' => 'civicrm_event'), array('entity_id' => $event->id), array('replace' => array('target_entity_id' => $event->id)));
//copy event schedule remainder
CRM_Core_DAO::copyGeneric('CRM_Core_DAO_ActionSchedule', array('entity_value' => $params['template_id']), array('entity_value' => $event->id));
}
$this->set('id', $event->id);
if ($this->_action & CRM_Core_Action::ADD) {
$url = 'civicrm/event/manage/location';
$urlParams = "action=update&reset=1&id={$event->id}";
// special case for 'Save and Done' consistency.
if ($this->controller->getButtonName('submit') == '_qf_EventInfo_upload_done') {
$url = 'civicrm/event/manage';
$urlParams = 'reset=1';
CRM_Core_Session::setStatus(ts("'%1' information has been saved.", array(1 => $this->getTitle())));
}
CRM_Utils_System::redirect(CRM_Utils_System::url($url, $urlParams));
}
parent::endPostProcess();
}